@sema-agent/core
Version:
Stateless, task-oriented AI agent core
1,415 lines • 111 kB
TypeScript
/**
* The ORIGIN of a surviving `ask` — WHICH AUTHORITY raised it, or took it over — as one word from a
* closed set; and, below it, the ask's CLASS SET, the mode × class arbitration table and the one predicate a
* permission mode is read through.
*
* Why an axis of its own. The tool gate has several automatic ask-resolution lanes (the auto-mode
* classifier today; the persisted-rule lane and the sandbox-admission leg are the same shape), and each
* one's eligibility used to be written as a growing conjunction of NEGATIVES — "not an org ask, not a
* hook ask, not a matched ask rule, not the classifier's own fallback, not the question tool, not a
* marked call…" — one more conjunct per kind of ask the engine learned to mint. Every conjunct was
* right; the FORM was the debt: a new kind of ask had to be remembered at every lane, and forgetting
* one was a silent loosening (the new ask fell into whichever lane nobody had excluded it from).
*
* The replacement: the gate derives the origin ONCE from the facts its layers established
* ({@link askOriginOf}) and stamps it on the surviving ask as the DISCLOSED word; the lanes read the ask's
* class SET ({@link classifyAsk}) folded onto one row of a table that MUST name every class
* ({@link MODE_ARBITRATION}, fenced by {@link AssertAllKeysHandled}). Adding a kind of ask is then: one
* class here, one arm in the derivation, one row in the table — and the compiler refuses the build until
* the row exists, so the default for an unconsidered class is a red build, never a silent allow.
*
* What is and is not an origin. An origin is WHO raised the question. Two facts that ride beside it
* are deliberately not origins: `requiresRealApproval` says what may CLEAR the question (a governance
* bit any origin can carry — a safety policy's own ask carries it with origin `policy`), and the
* gate's `autoMode` seat says whether a classifier is WIRED at all (a property of the session, not of
* the ask). Both stay where they are and are consumed beside the origin, not folded into it.
*
* Where an ask says WHY. An asker's own words have one machine-read seat, the ask's `askReasons` entries ({@link AskReason});
* a fact that rides a typed member is said by that member — the class (`askClass` / `classes`), the origin, the mandate word,
* and the account of a finding a read station or a deployment's reversibility probe made (`probeReason`, the `probe_mandate`
* word's disclosure). The ask's `message` is the one line a person or the model reads, not a second reason seat: a structured
* approval surface reads its reasons from the entries and the typed members, never from it.
*/
import type { PermissionResult } from "./tool-policy.js";
import { type EngineAttestation } from "./engine-attestation.js";
import type { ContainmentFace } from "../tools/fs/containment-face.js";
import type { ShellReadVerdictFacts } from "../tools/fs/shell-read-check.js";
import type { AssertAllKeysHandled } from "@sema-agent/primitives";
/**
* The closed set, in AUTHORITY order — the order {@link askOriginOf} resolves a fold in when several
* facts hold on one call (a hook ask folded over a policy ask, an org stamp over either). The order
* decides only the WORD; every lane table below is total over the set, so it can never turn an ask
* one member would have excluded into one another member admits (the invariant is pinned).
*
* - `content_question` — the reserved question tool: a content-ROUTING signal, not a permission
* question; it leaves the gate through the content channel, never through a permission decider.
* - `plan_review` — a durable PLAN pause: the model's own request (the first-party plan tool) stopped the run for a human
* verdict on a PLAN. Same family as `content_question` — a content-routing ask, never a permission question, so no
* permission decider, classifier or mode answers it and it never reaches an approver as an `AskRequest`. The word is stamped
* by the plan pause's decide lane alone (derived from the row's kind, nothing persisted), so the decided row's record names
* the ask it settled like every other settlement does.
* - `ancestor_marked` — the call is MARKED by an ancestor (an inherited approver-unavailable float, or
* a durable mandate floated down because this task can park it): it must reach the park with no
* synchronous decision-maker in between. The word names WHO raised it (an ancestor's mark), like every
* other member; whether the ask can be resolved is the park's business, not the origin's.
* - `org_unavailable` — the deployment is org-governed and could not read its snapshot: the fail-closed
* tighten, cleared by a person only ("does the org forbid this?" is unanswered, and no automatic
* lane may answer it; the class `org_unreadable`).
* - `org_rule` — an organization policy rule asked (or stamped an existing ask): "no configuration
* clears this, a person nods".
* - `rule_store_unavailable` — the person's rule store WAS read, but the CALL could not be read against
* their standing deny/ask rows (the tightening lexer's `unreadable` word: an expansion where a rule
* reads a word, an unterminated quote, a syntax error — the answer's `reason`): whether one of those
* rows forbids this call is unknown, so an allow tightens to an ask a person must clear and no automatic
* lane may answer (the class `call_unreadable`). A store (or a partition of it) that could not be READ is this
* word too — a row inside it may forbid the call and nobody can tell (the class `rule_unreadable`, which the
* two relaxed modes answer: auto mode's classifier, the bypass release); the run then also carries one
* `permission.rule_store_unavailable` notice under every mode (plus `permission.rule_store_unreadable_relaxed` for the operator under relaxed modes).
* - `hook` — a deployment's PreToolUse screening face raised or co-raised the ask; the word is
* engine-stamped at the fold and is the deployment's own per-call adjudication.
* - `ask_rule` — an EXPLICIT `ask` permission rule matched: a person's standing "ask me each time",
* an instruction rather than hesitation.
* - `denial_limit_fallback` — the auto-mode classifier reached its denial bound and handed the call
* to a person; the classifier stands BEFORE this ask, never after it.
* - `integrity_guard` — an always-on engine integrity guard put the question in its own words: a removal of a protected
* location, an unverifiable recursive delete, shell text the engine cannot read, the session-transcript write. Read off the
* guard's own account of the sentence the ask still says ({@link engineSentenceOf}`(…).guard`), never off the record's
* `guards` (a read station's silence lists a guard behind a question another layer raised): a later layer that rewrote the
* message without restating that account leaves the ask to the words below. Above the two tighten words: a tighten only
* ever replaces an allow, so the two never hold together on one pass, and where a pass's tighten fact outlived its turn
* (an approved edit's re-check) the decision's own record is the one that speaks for it. The reference implementation's
* `safetyCheck`.
* - `shell_gate_tighten` — the gate's own irreversibility tighten raised the ask over a tier the COARSE
* shell seat installed (the shape tier on every full shell, or the `shellGate: "always"` floor), not an
* explicit per-tool mark. The gate records that its own tighten spoke; a policy stamping
* `decisionReason: "safety"` on its own ask does not become one.
* - `safety_tighten` — the gate's own post-fold tightens over an EXPLICIT fact of the call: the tool's
* egress mark, its irreversibility mark, a peer-message referral in auto mode, a write onto the
* write-protected table. Same recording rule as above.
* - `policy` — everything else: a deployment `ToolPolicy` ask or a mode-default ask. This is the
* hesitation family — the one an armed classifier exists to resolve. The two tighten words are
* classifier-eligible too (arming auto mode is the deployment's explicit choice to let the
* classifier be the explicit ask-resolution for those classes); they are separate words so a deny
* observer or an approval card can say WHICH engine layer raised the question, which one word
* could not.
*/
export declare const ASK_ORIGINS: readonly ["content_question", "plan_review", "ancestor_marked", "org_unavailable", "org_rule", "rule_store_unavailable", "hook", "ask_rule", "denial_limit_fallback", "integrity_guard", "shell_gate_tighten", "safety_tighten", "policy"];
export type AskOrigin = (typeof ASK_ORIGINS)[number];
/** Whether a value is a member of the closed origin set. Exported because the word crosses process
* boundaries: a host validating one it received must not hand-roll the set. */
export declare function isAskOrigin(v: unknown): v is AskOrigin;
/**
* WHY a hook asked about a call — the closed set a hook seat's answer states beside its `ask` (`questionCause`), read by the
* hook entry of {@link AskReason}: `asked` — the hook itself asks, in its own words (the answer's `message`); `verdict_unreadable`
* — the hook's host could not read the verdict the hook gave, so it asks a person instead; `verdict_unfinished` — the hook did not
* finish with a verdict (it timed out, exited, could not be run), so its host asks a person. On the two `verdict_*` words the
* answer's `message` is the host's own account and is not the hook's words: no entry carries it — the entry's `words` are the
* engine's own sentence for the cause ({@link HOOK_CAUSE_WORDS}). An answer that states no cause reads as `asked`.
*/
export declare const HOOK_QUESTION_CAUSES: readonly ["asked", "verdict_unreadable", "verdict_unfinished"];
export type HookQuestionCause = (typeof HOOK_QUESTION_CAUSES)[number];
/**
* The engine's own words for a hook cause that is not the hook's own question — the ONE sentence of each, minted into the hook
* entry's `words` and read back by the request's sentence ({@link import("./tool-policy.js").extensionQuestionText}) and by the
* row's screen ({@link receiveAskReasons}). Whose words an entry's `words` are is read off its `cause`: the hook's for `asked`, the
* engine's for these two.
*/
export declare const HOOK_CAUSE_WORDS: Readonly<{
readonly verdict_unreadable: "the hook's verdict could not be read";
readonly verdict_unfinished: "the hook did not finish with a verdict";
}>;
/** Membership test for {@link HookQuestionCause} — the receipt's screen of the hook seat's member. */
export declare function isHookQuestionCause(v: unknown): v is HookQuestionCause;
/**
* One asker of a call and what it said, in its OWN words — an entry of `askReasons` on the approval request and its parked row.
* The one law: an entry carries a question's asker's own words (a policy chain's ask sentence — the deployment's, an integrity
* guard's, a rule's —, a hook's or an extension's reason, a hook host's cause word); a sentence the engine composes about a call
* whose fact already rides a typed member (a tool mark, an allow layer's shadow, a classifier's no-ruling, a generic question)
* is no entry. `by` names the asker with the {@link AskOrigin} word for it; a hook entry names its registration when the engine
* knows it and the {@link HookQuestionCause}, and carries `words` — the hook's own on `asked` (absent when it gave no reason), the
* engine's sentence for the cause on the two `verdict_*` words ({@link HOOK_CAUSE_WORDS}); whose words they are is read off `cause`.
* `words` is untrusted display text, already one line and capped ({@link ASK_REASON_WORDS_MAX}).
*/
export type AskReason = {
readonly by: "hook";
readonly registration?: string;
readonly cause: HookQuestionCause;
readonly words?: string;
} | {
readonly by: Exclude<AskOrigin, "hook">;
readonly words: string;
};
/** The cap on an entry's `words` — the one an extension's reason has always been shown under in the question's sentence. */
export declare const ASK_REASON_WORDS_MAX = 500;
/**
* The facts no layer BEFORE the gate holds about a call — the gate's org layer, its question-tool and marked-call lanes, its
* tightens and the tool seat's marks all read as absent. Two readers. An inherited station: the delegation half of the live
* gate's classifier eligibility — the SAME class row answers for the FROZEN classifier (an ask raised by a hook, minted by an
* explicit `ask` rule, or already a denial-limit fallback is as out of the frozen decider's reach as the live one's: the standing
* decision travels with the frozen entry); an ancestor's frozen classifier runs inside the policy fold, before the live gate's
* org layer has spoken and before its question-tool and marked-call lanes run, so those asks meet their exclusions downstream,
* where the facts exist, and excluded asks fall through to the frozen approver chain. The mandate marks are empty (the base
* names no seat): the policy-chain phase builds each call's facts over this base with THIS task's tool seat, so a marked tool's
* ask is classified at the station as at the gate; no call either (each station's own). And the receipt of a policy chain's ask,
* whose entry names the asker its own members say ({@link chainAskReasonsOf}) — not a word the gate's later layers would add.
*/
export declare const INHERITED_STATION_FACTS: Omit<AskOriginFacts, "call">;
/** A hook's entry ({@link AskReason}): the registration that answered (when the engine knows it), the cause, and its words — the
* hook's own reason as untrusted display text when the hook itself asked (none when it gave none), the engine's sentence for the
* cause otherwise ({@link HOOK_CAUSE_WORDS}; the host's account in `reason` is carried by no entry). Every station that reads a
* hook's or an extension's `ask` mints it here. */
export declare function hookAskReasonOf(registration: string | undefined, cause: HookQuestionCause, reason: string | undefined): Extract<AskReason, {
by: "hook";
}>;
/**
* The entry of a policy chain's ask, minted where the ask is RECEIVED (the gate's adjudication and its approved-edit re-check, an
* inherited station's read of an ancestor's ask): the receipt's own words, under the asker its own members name (the origin
* ladder over {@link INHERITED_STATION_FACTS} — a rule it matched, a classifier fallback it replays, else the policy). None when
* the ask has no words, or when its engine record says its words are the engine's generic question for the call
* ({@link engineSentenceOf}, while the ask's sentence is still that one: a write gate's default question, the plan mode's — the
* call's arguments and the ask's class already say it).
*/
export declare function chainAskReasonsOf(receipt: Extract<PermissionResult, {
action: "ask";
}>, call: AskOriginFacts["call"]): readonly AskReason[] | undefined;
/** A received decision with its policy chain's entry stamped ({@link chainAskReasonsOf}) — the gate's two adjudication receipts
* (the first judgment, an approved edit's re-check), right after the receipt. Not an ask, or no entry ⇒ the decision itself. */
export declare function withChainAskReasons(d: PermissionResult, call: AskOriginFacts["call"]): PermissionResult;
/** Two askers' entries in fold order — the standing ask's first, then the one folded over it; absent when neither has any. An
* entry is minted once, so the same entry reached twice (one ask relayed into the fold over itself) is one asker, listed once. */
export declare function joinAskReasons(standing: readonly AskReason[] | undefined, folded: readonly AskReason[] | undefined): readonly AskReason[] | undefined;
/** The `askReasons` member as a request, a carry and a parked row spread it — present ⇔ the ask carries at least one entry. The ONE
* reader of a surviving ask's entries for the four request mint stations and the park's carry (one value on the card and the row). */
export declare function askReasonsOf(d: PermissionResult): {
askReasons?: readonly AskReason[];
};
/**
* The entries as a boundary a host reads back holds them (the parked row): a list of well-formed entries copied fresh, else
* nothing — the row's twin is written from the gate's carry, but the row is a boundary, so the value is screened where it is
* published (the screen the row's `origin` and class pair take). A malformed list publishes no entry at all, never a partial one;
* an entry's members are read as its own data members (an inherited or accessor member is no member).
*/
export declare function receiveAskReasons(v: unknown): readonly AskReason[] | undefined;
/** The compile-time fence beside every table meant to be TOTAL over a closed set — one declaration, the zero-dependency package's
* (a set that lives there fences its tables with it too); handed on here to the engine's tables under the name they always read. */
export type { AssertAllKeysHandled };
/** The facts about one call that only the gate holds — the derivation's inputs beyond the decision
* itself. Every member is a plain boolean/word read ONCE by the gate, so the derivation is a pure
* function that a test can drive arm by arm. */
export interface AskOriginFacts {
/** The call these facts are about — the one an engine record on the decision must be bound to for the derivation to read it
* ({@link import("./engine-attestation.js").attestationOf}): a record handed back for another call reads as absent. */
readonly call: {
readonly toolCallId: string;
readonly toolName: string;
};
/** The call is on the reserved question tool. */
readonly contentQuestion: boolean;
/** The call is marked unresolvable by an ancestor (see the gate's `isMarkedUnresolvable` seat). */
readonly markedUnresolvable: boolean;
/** Which org state, if any, spoke on this call — the gate's own record of its org layer, never a
* read-back off the decision (a policy can put `decisionReason: "org_rule"` on its own ask; the
* gate's cell cannot be written by a policy). */
readonly org: "rule" | "unavailable" | undefined;
/** The gate's own record of its persisted-rule lane's READ: the store was read, but THIS CALL could not be read
* against the person's deny/ask rows (the lane's answer carried the lexer's reason) — the origin
* `rule_store_unavailable`, the class `call_unreadable`. Absent: the lane read the call, or the store
* could not be read (see {@link ruleStoreUnreadable}). Written only by the gate. */
readonly ruleCallUnreadable?: boolean;
/** The gate's own record of the same read when a PARTITION of the store (or all of it) could not be read: a deny / ask
* row inside it may forbid this call and nobody can tell — the same origin as {@link ruleCallUnreadable}, the class
* `rule_unreadable` (the person's rules themselves unread). Exclusive with it. Written only by the gate. */
readonly ruleStoreUnreadable?: boolean;
/** Which of the gate's OWN post-fold stations minted the standing ask, if one did — again the gate's
* record of its own layer (a station replaces an `allow` wholesale, so at most one fires per pass),
* never a read-back of `decisionReason: "safety"` off a decision a policy could have composed. `unstated` is
* the last station: the mode's answer for a call to a tool that states no permission of its own when no answer
* covers the fold's allow — its origin is `policy` (no tighten word), its class `unstated`. */
readonly tightened: "shell_gate" | "safety" | "unstated" | undefined;
/** The MANDATE mark inputs of this call — the tool SEAT's marks plus the gate's own per-call records
* ({@link MandateMarks}), read from the same two places the lane's own derivation reads them. The
* per-call PROBE member is deliberately not here: it is engine-stamped on the DECISION, and
* {@link ruleClearanceOf} reads it there, so one fact cannot arrive twice with two values. An inherited
* station passes the tool SEAT's marks of the task it runs in (its per-call records are the gate's, absent
* there); a station holding no seat at all passes `{}` — an honest empty, since the decision's own
* members still answer. */
readonly mandateMarks: Omit<MandateMarks, "probeMandated">;
}
/**
* The ONE derivation of an ask's origin, from the surviving decision plus the gate's own facts. The
* arms are in {@link ASK_ORIGINS} order (strongest authority first); the members it reads off the
* decision are the three the engine already treats as tighten-only provenance (`decisionReason:
* "hook"` is engine-stamped at both fold arms; `matchedAskRule` and `denialLimitFallback` are stamped
* by their mint sites and, when self-declared by a policy, can only opt that policy's own ask OUT of
* automatic resolution — the safe direction). Nothing here reads a member that could loosen.
*/
export declare function askOriginOf(decision: Extract<PermissionResult, {
action: "ask";
}>, facts: AskOriginFacts): AskOrigin;
/**
* Stamp the ask's origin word — and withdraw the disclosures that speak for the TIGHTEN alone when some
* layer above it is the reason this call is being asked about. Today that is one member: the read
* boundary's directory offer, whose claim holds only while the tighten is the whole reason. Every higher
* rung is a layer with a reason of its own — a standing `ask` row, a call unreadable against the rows, an org
* verdict, a hook, the denial-limit fallback — which no directory grant answers, so the ask would stand
* after the grant and the offer would have promised a clearing it cannot deliver (measured: `cat
* <out-of-root>` under a standing `Bash(cat:*)` ask rule offered the directory and kept asking after it).
* It lives at the one derivation rather than the three stamp sites: the withdrawal's input IS the origin
* word, so a site that stamped without it would be a second, quieter answer to one question.
* The same stamp writes the ask's CLASS members (`askClass` / `classes`, {@link askClassMembersOf} over the
* `classification` the caller derived from this decision under these facts): the word and the class leave the
* gate on one object. No policy states either (the decision receipt refuses a stamp member). An ask whose word is the escape
* (`sandbox_override`) leaves it in the escape's sentence: the reference's escape question replaces the hesitation it stands over
* — its message is "Run outside of the sandbox" for every reader (the card, the park row, the mode's refusal, the classifier).
*/
export declare function stampAskOrigin<T extends Extract<PermissionResult, {
action: "ask";
}>>(decision: T, facts: AskOriginFacts, classification: AskClassification): T & {
origin: AskOrigin;
} & AskClassMembers;
/**
* WHY an approval card offers no persisted allow rule, one word per reason — the closed set of `ruleOffersAbsence`
* on the ask and its park twin, written by the one offer factory: `mandated` (no persisted rule may clear the ask),
* `allow_outranked` (an allow-layer member already matched this call and the question outranks it), `ask_rule_matched`
* (an explicit `ask` rule matched: it keeps asking), `lane_cannot_speak` (a rule could clear the ask and this card offers none
* for the call: the lane has no text for it, or the call leaves the run's sandbox by its own escape). The first three are
* {@link ruleClearanceOf}'s doors.
*/
export declare const RULE_OFFERS_ABSENCES: readonly ["mandated", "allow_outranked", "ask_rule_matched", "lane_cannot_speak"];
export type RuleOffersAbsence = (typeof RULE_OFFERS_ABSENCES)[number];
/** Membership test for {@link RuleOffersAbsence} — screens a parked row's value before publishing it on a summary. */
export declare function isRuleOffersAbsence(v: unknown): v is RuleOffersAbsence;
/**
* CAN a persisted allow rule clear this ask — and, if not, which door closed? ONE derivation with TWO
* readers, which is the whole point of the shape: the approval card's `ruleOffersAbsence` word and the
* ask's own {@link import("./tool-policy.js").AskRequest.mandated} bit. They used to be two
* enumerations of one boundary, and the drift was live — the card's lane speaks for one tool, only
* where a rule store is wired and only on a task that can hold a rule, so the same mandated read asked
* as a mandated question on the shell tool and as an apparently ordinary one on the monitor tool.
*
* "Allow rules silence the classifier's questions, never a mandated one." The doors, as a SET:
* · the MARKS family — {@link persistedRuleMandateOf} over the tool seat's marks and the gate's own
* per-call records (the read station's structural demotion, an unanswered probe, an operator's
* per-call shell doctrine, the tool's own egress / irreversibility marks, a write the protection
* judge matched or could not resolve);
* · GOVERNANCE (`requiresRealApproval`) — an org verdict, a safety policy's own demand, the
* classifier's denial-limit fallback: only judgment clears it;
* · a HOOK-raised ask — the deployment's own per-call screening authority, which the lane's clearing
* conjuncts refuse;
* · ANCESTOR authority (`inheritedUnresolved` / `ancestorResolved`) — the ask belongs to an ancestor's
* approver and this task's rule lane never adjudicates it;
* · the bit already stamped on the ask, which no layer below the mint may clear (tightening-only).
*
* And two doors that are not mandates, each its own word: an allow-layer member already matched and is outranked
* (`allowRuleShadowed` ⇒ `allow_outranked`), or the person's explicit "ask me each time" rule matched
* (`matchedAskRule` ⇒ `ask_rule_matched`). A rule minted from such a card silences nothing, so the lane offers none — but
* the reason is that a RULE is already speaking, not that the question is beyond rules, and a surface
* that auto-answers by posture is not crossing a mandate when it answers one.
*
* THREE named readings of the one pass, because three callers need three different things and taking
* the wrong one is how this boundary drifts. None is the ENFORCEMENT reading: whether an allow rule clears the ask is the
* class row's `ruleMayClear` ({@link classifyAsk} — every door below is a class there), read once by the gate's allow layer.
* · `word` — the DISCLOSED reason ({@link RuleOffersAbsence}), first door wins, in the display order the card has always
* used (governance, the outranked allow, the hook, the ask rule, the two ancestor doors, then the marks). Display
* only. The structural door the offer factory owns (no rule speaks for the call: no lane wired, a
* task that cannot hold a rule, a call the lane does not judge) is decided BEFORE this and is deliberately silent;
* · `mandated` — the FACT the ask carries as its own member. Read off the whole mandate set, so which
* door is DISPLAYED cannot change it: an ask that is both outranked and mandated is mandated;
* · `mandate` — WHICH table word the bit stands on, only when the MARKS family is its whole reason (no
* governance, hook or ancestor door, and no bit stamped without a word; a written ask rule, standing or folded, is no
* door); absent, the bit's reason is not one word.
*/
export declare function ruleClearanceOf(ask: RuleClearanceFacts | undefined, marks: Omit<MandateMarks, "probeMandated">): {
word?: Exclude<RuleOffersAbsence, "lane_cannot_speak">;
mandated: boolean;
mandate?: PersistedRuleMandate;
};
/**
* Would saving a standing allow rule stop this question being asked again — the ONE answer, and it is the allow layer's own two
* readings of the call's class SET: `any` where a rule member clears it ({@link allowMayClearOn} over the folded row, no face moves
* `ruleMayClear`); `bound` where only a grant bound to an inside peer's current identity stamp does ({@link boundGrantMayClear}); `none`
* otherwise. The approval card's headline says it (`ask-headline.ts`, its remedy half) and no reason sentence does (`SHADOW_REASON`, the
* mandate disclosures above say WHY only). Per call, not per class word. `mandated` / `ruleOffersAbsence` ({@link ruleClearanceOf})
* answer another question — whether THIS card offers a rule to save — and do not enter this one.
*/
export declare function standingRuleClearance(classes: Iterable<AskClass>): "any" | "bound" | "none";
/** The facts one ask carries about whether a rule could clear it — the members {@link ruleClearanceOf}
* reads beside the tool seat's marks. Every one is either engine-stamped or, where a caller can
* self-declare it, tightening-only: a claim here can opt an ask OUT of automatic answering and never
* into it. */
export interface RuleClearanceFacts {
/** The bit a gate already stamped (see {@link import("./tool-policy.js").AskRequest.mandated}). */
mandated?: true;
/** The table word a gate stamped beside that bit (see {@link import("./tool-policy.js").AskRequest.mandate}). */
mandate?: PersistedRuleMandate;
requiresRealApproval?: boolean;
/** Allow-layer members matched and did not clear the ask (see {@link import("./allow-rule-shadow.js").AllowRuleShadow}). */
allowRuleShadowed?: readonly import("./allow-rule-shadow.js").AllowRuleShadow[];
decisionReason?: import("./tool-policy.js").DecisionReason;
/** An EXPLICIT `ask` permission rule matched this call (DSL, stamped at the rule policy's three
* matched-ask exits — bare, covering and param). */
matchedAskRule?: string;
/** The ask was minted by the deployment's own governance layer (see {@link import("./tool-policy.js").PermissionResult}). */
authoredBy?: "deployment";
/** The engine-stamped probe mandate (the reversibility probe declared this call's demotion
* structural — for the built-in shell probe, a read outside the session's allowed directories). */
probeMandated?: boolean;
/** The ask stands on the call's cross-boundary obligation (see {@link import("./tool-policy.js").PermissionResult}). */
crossBoundaryMandated?: boolean;
/** An ancestor's approver answered "unavailable" for this call, or a durable mandate was floated here. */
inheritedUnresolved?: boolean;
/** The ask is being resolved at an ANCESTOR's frozen approver (the three inherited-lane mint sites
* pass it literally) — this task's rule lane never adjudicates it. */
ancestorResolved?: boolean;
/** The classes of the contributors the policy fold carried under this ask — the decision's engine record's
* ({@link EngineAttestation.foldedClasses}), filled in by the builder of these facts ({@link withFoldedOf}); a member whose row
* no rule may clear keeps the question a person's. */
foldedClasses?: readonly AskClass[];
}
/** `facts` with the folded contributors' classes the decision's record carries for its call — the one way a builder of
* {@link RuleClearanceFacts} fills them (a decision carries no such member: the record is their one carrier). */
export declare function withFoldedOf<F extends RuleClearanceFacts>(facts: F, record: EngineAttestation | undefined): F;
/** The ask FACE's mandate members — the bit and its table word, spread at the four mint stations and the
* park row. The stations hand it the SAME facts object they hand the rule-offer factory, so the card's word
* and these members are readings of one derivation and cannot drift. The tool SEAT's marks (`marks`): a gate-stamped ask
* carries them already (folded into its bit and word), so its mint hands none; an inherited station minting its card from an
* ANCESTOR's decision hands the leg's seat marks the card's rule-offer word reads — the card a person answers there covers this leg's gate. */
export declare function askMandateMember(ask: RuleClearanceFacts | undefined, marks?: Omit<MandateMarks, "probeMandated">): {
mandated?: true;
mandate?: PersistedRuleMandate;
authoredBy?: "deployment";
};
/**
* A MANDATE merged onto an ask another layer raised — the one writer of both merge arms (the read station's, the reversibility
* probe's; `gate-fold.ts`). The mandate is the fact that a standing allow rule may not clear the ask, and its account is the only
* sentence that can say why (the allow layer's disclosure words a `probe_mandate` with it, on the card and in the parked row): the
* two travel together. The FIRST layer to mandate an ask brings its account, or none: a `probeReason` the ask arrived with is another
* station's account of a finding that did not mandate it (no policy states one: the receipt refuses it — the read station's account of
* an ask it raised without a mandate, which the reversibility probe's merge arm meets), and is replaced by the account — or removed
* where the mandating layer gave none, so it is never read as the reason the mandate stands; an ask already mandated keeps the first
* layer's. The ask's action, message, reason and every other disclosure are untouched.
*/
export declare function withProbeMandate<D extends Extract<PermissionResult, {
action: "ask";
}>>(decision: D, account: string | undefined): D;
/** The clearance facts of an ask the engine did not construct (a policy's verdict), each member read ONCE into
* an engine-owned value — for a station that keeps the answer past its own side effects, where the verdict's
* accessors must not run again. The members a verdict may carry that narrow what may clear it, and the folded classes its
* record carries for `call`. */
export declare function ownedClearanceFacts(d: Extract<PermissionResult, {
action: "ask";
}>, call: AskOriginFacts["call"]): RuleClearanceFacts;
/**
* Which origins IMPLY the `requiresRealApproval` bit, and WHERE that implication is verified — the
* consistency table {@link askOriginOf} reads. An ask of a must-carry origin exists so that no automatic
* lane clears it (the org's asks: "no configuration clears this, a person nods"; the classifier's
* fallback: no automatic lane may re-clear what the classifier already refused), so the bit must ride
* it. The bit is NOT derived from this table: the write sites each have their own reason, and a
* table-derived bit would have to either strip a safety policy's mandate or make every hook ask
* non-budgetable. The table only refuses the one shape that is a defect: a must-carry origin without
* the bit — and says where that refusal can honestly happen:
* - `"at_derivation"` — the origin is derived from a GATE fact only the engine writes (`facts.org`),
* so a missing bit is an engine defect and {@link askOriginOf} fails loud;
* - `"at_mint"` — the origin is derived from a decision MEMBER a policy may compose
* (`denialLimitFallback`: a self-declared one opts the policy's own ask out of automatic
* resolution, the safe direction, not a defect), so the invariant is pinned at the engine's two
* mint sites (the gate's fallback re-mint and the inherited station's) rather than thrown at
* derivation, where a policy's own object could trip it;
* - `false` — the origin says nothing about the bit: a `policy` ask may carry it (a safety policy's
* own mandate) or not, and both are legal; an `integrity_guard` ask carries it exactly when its guard's class
* explains it ({@link RRA_EXPLAINERS}: a protected-location removal, the session-transcript write — pinned at
* those two mint sites) and not for the two the engine raises because it could not read or verify the command.
*/
export declare const ORIGIN_IMPLIES_REAL_APPROVAL: {
readonly content_question: false;
readonly plan_review: false;
readonly ancestor_marked: false;
readonly org_unavailable: "at_derivation";
readonly org_rule: "at_derivation";
readonly rule_store_unavailable: "at_derivation";
readonly hook: false;
readonly ask_rule: false;
readonly denial_limit_fallback: "at_mint";
readonly integrity_guard: false;
readonly shell_gate_tighten: false;
readonly safety_tighten: false;
readonly policy: false;
};
/** The fence over the consistency table: `never` while every origin has a row. */
export type RealApprovalTableCoversEveryOrigin = AssertAllKeysHandled<Exclude<AskOrigin, keyof typeof ORIGIN_IMPLIES_REAL_APPROVAL>>;
/**
* The MANDATE family — the closed set of words for "this ask stands by STRUCTURE, so a standing allow
* rule may not retire it". A DISCLOSURE vocabulary: the word rides the approval card and the park row
* ({@link persistedRuleMandateOf} picks one), while what a live lane may do with the ask is decided by
* the ask's CLASS SET ({@link classifyAsk}, {@link MODE_ARBITRATION}) — never by this one word.
*
* - `operator_always` — the operator's `always` floor: per-call confirmation for shell commands.
* - `tool_marks` — the tool's own egress / irreversibility / interaction declaration.
* - `probe_mandate` — this call's reversibility probe declared the demotion STRUCTURAL. For the engine's own shell station it
* is a FINDING about this call — a path outside the allowed directories (read or written) or a command whose reads it could
* not establish — and the finding's account (the ask's `probeReason`) is the word's whole disclosure ({@link FINDING_ACCOUNT}).
* - `probe_unanswered` — the probe was consulted and did not answer: whether the call is reversible is UNKNOWN.
* - `write_protection` — the table covers this write's target. A write onto load-executed configuration
* re-authorizes the agent, so the question is a property of the TARGET, not of anyone's hesitation.
* - `target_unresolved` — the reading of a written target could not say where it leads on disk:
* `probe_unanswered`'s doctrine one layer over.
* - `cross_boundary_taint` — the call's cross-boundary obligation is a person's confirmation (an org-side write from a tree
* that executes on a device of a multi-tenant deployment, or a device-bound call after an off-target read): a fact of
* the tree, not of the tool; read off the ask's own `crossBoundaryMandated` ({@link ruleClearanceOf}).
*/
export declare const PERSISTED_RULE_MANDATES: readonly ["operator_always", "tool_marks", "probe_mandate", "probe_unanswered", "write_protection", "target_unresolved", "cross_boundary_taint"];
export type PersistedRuleMandate = (typeof PERSISTED_RULE_MANDATES)[number];
/** Membership test for {@link PersistedRuleMandate} — the screen a row reader applies to a stored word. */
export declare function isPersistedRuleMandate(v: unknown): v is PersistedRuleMandate;
/** The row of a word whose reason is a FINDING about this very call (what the read station found — a path outside the allowed
* directories, read or written, or a command whose reads it could not establish): no sentence of the table can say which, so
* the reason is the finding's own account — the sentence the station minted for the card, which the ask carries as
* `probeReason` ({@link mandateDisclosureOf} reads it there). A row, not an absence: the word is disclosed, by the ask. */
export declare const FINDING_ACCOUNT: Readonly<{
readonly reasonIs: "the account of the finding, carried on the ask as probeReason";
}>;
/** WHY a matching persisted allow rule did not clear the ask, in the sentence a PERSON reads — one row per
* word (the ladder this replaces ended in a catch-all arm). Display prose; nothing reads it back to decide. A row says WHY only:
* whether a standing allow rule would stop the question is the call's own answer ({@link standingRuleClearance}, the card's headline),
* which no row says a second time. */
export declare const MANDATE_DISCLOSURE: {
readonly probe_mandate: Readonly<{
readonly reasonIs: "the account of the finding, carried on the ask as probeReason";
}>;
readonly probe_unanswered: "the reversibility check did not answer for this call (it timed out or failed), so whether the call is reversible is unknown";
readonly operator_always: "this deployment mandates per-call confirmation for shell commands (shellGate: always)";
readonly tool_marks: "this tool carries egress/irreversibility/interaction marks (a mandated confirmation)";
readonly write_protection: "this write's target is on the deployment's write-protection table (the agent's own configuration is guarded one look per write)";
readonly target_unresolved: "where this write leads on disk could not be determined (a link on the way could not be examined, or the environment could not resolve the target), so whether it lands on a guarded path is unknown; no automatic decider answers for it, though a wired approver seat can";
readonly cross_boundary_taint: "this run executes on a device outside the deployment's trust boundary and the deployment is multi-tenant, so an org-side write — or, after an off-target read, a call bound for the device — is confirmed by the deployment's approver for this call: no automatic lane answers for it, and an allow the configuration gives (a blanket seat or a policy's answer) is refused";
};
/** The fence over the disclosure table: `never` while every word has a row. */
export type DisclosureTableCoversEveryMandate = AssertAllKeysHandled<Exclude<PersistedRuleMandate, keyof typeof MANDATE_DISCLOSURE>>;
/** The sentence for the lane's OTHER refusal — no mandate: a standing "ask me each time" rule matched, which outranks the
* remembered yes on its own. */
export declare const ASK_RULE_DISCLOSURE = "an explicit ask rule matched this call (a person's or the deployment's ask-me-each-time outranks a standing allow rule)";
/**
* The disclosed reason for one word. `undefined` — no mandate — is the lane's OTHER refusal ({@link ASK_RULE_DISCLOSURE}).
* A word whose row is {@link FINDING_ACCOUNT} is disclosed by the ask's own account of its finding (`account`, the
* `probeReason` the ask carries) and by nothing else: with no account there is no sentence (`undefined`) — a word whose reason is
* a finding is never worded from a general statement, which would be true of one finding and false of the next. Every
* mandate the engine's own read station raises carries its account; an ask that arrives without one (a deployment probe that
* supplied no `reason`, a station the host mounted) is a mandate stated without a reason, and the card does not invent one.
*/
export declare function mandateDisclosureOf(mandate: PersistedRuleMandate | undefined, account?: string): string | undefined;
/**
* The mandate provenance of one call, judged from the SAME mark inputs the gate is driven with —
* the WORD a mandated ask discloses for its marks (the class derivation reads the same marks as classes,
* and the allow layer reads the classes). Allow rules silence the classifier's questions, never a
* mandated one; this is the mark family's word for that boundary:
* · `probeMandated` — this CALL's own reversibility probe declared its demotion STRUCTURAL
* (`"probe_mandate"`), judged FIRST because it is the only per-call member here: the three below
* are properties of the TOOL and are true of every call on the seat, so a mandate that is true of
* this one call must not be shadowed by the tier that happens to carry it (#502: the built-in
* shell probe raises it for a listed reader naming a path outside the session's roots — a boundary
* the deployment declared, which is exactly what the shape tier alone cannot say);
* · `egress` — the tool's own external-write mark, judged next: it is the tool's declaration even
* when the shell seat also installed a tier on the same name;
* · `shellGated` + tier `"always"` — the operator's `always` floor, a per-call confirmation
* (`"operator_always"`); without the floor the shell seat installs the shape tier's `"maybe"`,
* and THOSE asks stay the rule lane's home turf (`undefined`) — that is the don't-ask-again main case, and the per-call member
* above is deliberately the ONLY thing that carves a mandate out of it;
* · a tool's OWN `"always"`/`"maybe"` irreversibility tier without the doctrine (`"tool_marks"`).
*
* The unresolved written target sits ABOVE the probe words (the read station mints both on one call, and this one names
* why its finding stands); the matched write-protection row sits BELOW them and ABOVE the seat marks, on the ladder's rule:
* a word no lane may answer outranks the rest, and a fact about THIS call outranks a property of the tool. Judged HERE, not
* in {@link irreversibilityMandateOf} which {@link safetyAxisOf} shares: such a write is not an irreversible action, and
* its park stays budgetable.
*
* Two consumers, one derivation: the ask's stamped `mandated` / `mandate` members and the runner's suggestion factory (a
* mandated ask offers no "stop asking me this" option — a rule minted from it would never clear it). Every word here is also a
* class the allow layer reads, so an ask this derivation mandates is never cleared by a rule; the converse does not hold — a
* class with no word here (a caller policy's own guard on an ask without the real-approval bit) leaves the ask unmandated, and its
* card can offer a rule the allow layer then discloses as outranked. The per-call member reaches both
* the same way every other per-call fact does: the gate stamps it on the surviving ask, the
* synchronous sites read it off the decision they spread, and the park leg threads its own parameter.
*/
export declare function persistedRuleMandateOf(marks: MandateMarks): PersistedRuleMandate | undefined;
/** The mark inputs of the two mandate derivations — properties of the tool SEAT (`egress`, `shellGated`,
* `irreversibility`) beside the two per-call facts the gate stamps. */
export interface MandateMarks {
egress?: boolean;
/** The tool's server declared that a call must be put to a person
* ({@link import("../engine/loop/types.js").AgentTool.mcpRequiresUserInteraction}): a mark of the tool's own, like `egress` — no
* persisted allow rule or standing grant clears the ask, and the class `requires_user_interaction` rides every ask on the call. */
requiresUserInteraction?: boolean;
shellGated?: boolean;
irreversibility?: "never" | "maybe" | "always";
/** The surviving ask's engine-stamped `probeMandated` — see
* {@link import("./types.js").ReversibilityVerdict.mandated}. */
probeMandated?: boolean;
/** The gate's own record that the write-protection judge covered this call and its table MATCHED
* (`GatePass.writeProtected`, written at the fourth post-fold tighten for a write tool's target and by the read station
* for a shell command's written targets). A GATE fact like the org words: it rides the pass, not the decision, so no
* layer outside the engine declares it. */
writeProtected?: boolean;
/** The same judge's record that a written target met its table only where the path resolves on disk (its real target, a hop
* of its link chain) — the path as written names no row (`GatePass.writeProtectedOnDisk`; the two writers of
* `writeProtected`, the reading of each target being one or the other). A GATE fact like `writeProtected`. */
writeProtectedOnDisk?: boolean;
/** The gate's record that the READING of a written target could not say where it leads on disk (`GatePass.targetUnresolved`:
* a target a shell command's program writes, placed, whose destination the read station could not resolve) — a fact of
* the reading, never a judge's verdict. The write face's twin of `probeUnanswered`. */
targetUnresolved?: boolean;
/** The pass's own record that the probe was consulted and did not answer (`GatePass.probeUnanswered`):
* the boundary is unknown, which no standing yes may stand in for. The runner's suggestion factory does
* not see the pass and never passes it — a card may offer a rule the lane then discloses as outranked
* (loud, never a silent override), the same drift window the `matchedAskRule` conjunct already has. */
probeUnanswered?: boolean;
}
/**
* The SAFETY AXIS of one ask — what makes its durable park NON-BUDGETABLE (`irreversible_ask`), judged
* from the same mark inputs as the rule-lane mandate plus the gate's own record of which tighten minted the
* ask. `egress` is the tool's static external-write mark, as it always was. `irreversible` is a mandate of
* THIS call: the tool's own tier (`tool_marks` — the deployment declared the tool may be irreversible,
* and a policy or hook asking first does not un-declare it), the operator's per-call doctrine
* (`operator_always`), the probe's structural verdict (`probe_mandate` / `probe_unanswered`), OR — under a
* shell-seat-installed `"maybe"` tier — the shell gate's own tighten having minted this ask (the doctrine's
* probe judged THIS command not reversible). A policy ask on a shell-gated tool that the doctrine's probe
* did not tighten and did not mandate is a plain ask: the tier was the probe's instrument, not a risk
* label, and the park stays the budgetable kind. Before this derivation the static tier alone set the bit,
* so every policy ask on the full shell face parked non-budgetable.
*
* Deliberately NOT the rule-lane predicate verbatim: a shell tighten's ask is rule-clearable (a person's
* past yes to this command shape stands) yet non-budgetable (a budget's mechanical yes is not a person's).
* The two derivations share every other row through {@link irreversibilityMandateOf}.
*/
export declare function safetyAxisOf(marks: MandateMarks & {
readonly tightened: AskOriginFacts["tightened"];
}): {
egress: boolean;
irreversible: boolean;
shell?: boolean;
} | undefined;
/**
* The engine's judgment of WHAT a call is, on the two axes a person scrutinizes differently — "cannot be undone" and "data
* leaves the machine" — as the live approval card (`AskRequest.riskAxes`) and the parked row (`RiskDescriptor.riskAxes`) both
* carry it: one type, one mint (the policy chain's `riskAxesOf`). Each member is three-valued: `true` and `false` are
* judgments; ABSENT means the engine did not judge that axis (read it as unjudged, never as `false`), and the whole member is
* absent when neither was judged. It is NOT the set of axes that TRIPPED the gate ({@link SafetyAxis} / `RiskDescriptor.axes`,
* which says why a gate fired: a shell-seat ask trips `shell` and never `irreversible`, though its `"maybe"` tier reads
* `irreversible: true` here). Display / triage metadata: nothing reads it to gate.
*/
export interface CallRiskAxes {
readonly irreversible?: boolean;
readonly egress?: boolean;
}
/**
* The permission-mode closed set — the ONE key a caller sets (`TaskSpec.permissionMode`), spelled as the wire and
* the reference implementation spell it. A root task's absent key reads `default`; a child's absent key inherits
* its parent's effective mode ({@link clampPermissionMode}).
*/
export declare const PERMISSION_MODES: readonly ["default", "acceptEdits", "plan", "auto", "bypassPermissions", "dontAsk"];
export type PermissionMode = (typeof PERMISSION_MODES)[number];
/** Membership test for {@link PermissionMode} — the word crosses process boundaries (a request body, a checkpoint row). */
export declare function isPermissionMode(v: unknown): v is PermissionMode;
/**
* The reference implementation's mode RANK, used for one thing only: a child's declared mode may not outrank
* the ceiling its parent hands down (a declaration is adopted iff `rank[declared] <= rank[ceiling]`, and
* `acceptEdits` / `auto` are incomparable). It is a clamping relation, not a per-class strictness order —
* `default` and `dontAsk` share a rank, and whether a mode releases a given ask is {@link MODE_ARBITRATION}'s.
*/
export declare const PERMISSION_MODE_RANK: {
readonly plan: 0;
readonly default: 1;
readonly dontAsk: 1;
readonly acceptEdits: 2;
readonly auto: 3;
readonly bypassPermissions: 4;
};
/** The fence over the rank table: `never` while every mode has a rank. */
export type RankTableCoversEveryMode = AssertAllKeysHandled<Exclude<PermissionMode, keyof typeof PERMISSION_MODE_RANK>>;
/**
* Clamp a child's DECLARED mode under its parent's ceiling. An absent declaration inherits the ceiling; a
* declaration the rank table does not admit under the ceiling is folded back to the ceiling (`clamped: true`
* — the caller discloses it, never silently). `bypassPermissions` is adopted only under a `bypassPermissions`
* parent, and the incomparable pair (`acceptEdits` ↔ `auto`) is never adopted across.
*/
export declare function clampPermissionMode(declared: PermissionMode | undefined, ceiling: PermissionMode): {
effective: PermissionMode;
clamped: boolean;
};
/** WHO put a tool's egress / irreversibility mark on the seat — the deployment's own declaration (`spec.tools`),
* a protocol server's self-report (MCP annotations), or the A2A default (every peer skill is an external write). */
export type ToolMarkSource = "deployment" | "mcp_annotation" | "a2a_default";
/**
* The ask CLASS set — WHY a surviving ask exists, as the set of authorities that stand behind it. One ask can
* belong to several classes at once (a hook door and an org verdict on one call); a class is derived from the
* FACTS the gate's layers established ({@link classifyAsk}), never from the disclosed `origin` / `mandate`
* words, which are single-winner projections and hide the members behind them. The array ORDER decides one
* thing only: which member is the DISCLOSED word (`askClass`) when several hold — the door-before-word,
* most-immune-first order; every lane reads the folded row ({@link foldArbitrationRow}), never the word.
* `shell_floor` is the operator's `shellGate: "always"` floor on a shell-running seat — the question the `operator_always`
* mandate word discloses, as a class of its own so a set that holds another forced question still holds it.
* `requires_user_interaction` is the SERVER's declaration on the called tool (`_meta["anthropic/requiresUserInteraction"] === true`), or
* the HOST's on the skill a `Skill` call activates (`SkillSpec.createdBy: "proposal"` with tools to grant, read per call): a
* permission question, unlike `content_question` (the reserved question tool's content-routing signal) — it carries that class's arbitration
* row cell by cell, because the reference implementation judges the declaration ahead of its allow-rule lookup and its bypass release.
* `cross_boundary` is an ask carrying `crossBoundaryMandated` (the gate's cross-boundary station mints it with the real-approval bit; the
* decision receipt adds the bit to a policy's or hook's own): no rule, classifier, sandbox or mode answers it.
* `unstated` is the mode's answer for a call nobody stated: a tool whose permission seat is `passthrough` (it states no
* permission of its own — a remote peer's tool) reached the end of the fold with an allow no answer covers.
* `a2a_inside` is every ask on a call to an A2A peer registered inside the trust boundary (the gate's `a2aInsidePeer` record): no
* egress mark stands on it, and only a grant bound to the peer's CURRENT identity stamp clears it — the allow layer's one law for
* it ({@link boundGrantMayClear}; the members' bindings read by `a2a-bound-grant.ts`), read before the question reaches a person. So its row says no
* standing rule clears it (a rule without that stamp, a hook's allow and a skill's grant never do); it is not a mandate (the
* classifier answers it, `bypassPermissions` releases it, a person's answer is a plain one). Under `RunnerDeps.a2a.isolatePeers`
* an inside peer is no such destination: its skills keep the egress default and the operator's mandate.
* `classifier_no_ruling` is a classifier station's question to a person because the auto-mode classification did not rule
* (`classifierNoRuling` — it could not run, or replied with no verdict): the denial-limit fallback's row (only a person
* answers it; the classifier is never asked again).
* `dangerous_delete` is a removal whose target is a protected location (`dangerousRemovalOf`: the filesystem root, a
* top-level directory, a home directory, or a workspace directory — the task root, the working directory, an additional
* working directory — or an ancestor of one): the reference implementation's dangerous-removal breaker, which no mode,
* allow rule or classifier answers. `unverifiable_delete` is a recursive forced removal whose target the command text cannot
* resolve; `unverifiable_shell_text` is a shell handed text the command does not spell (a program's output, a substitution,
* a file's content, an argv a stream fills in, a program word the command's own text fills in): the engine cannot read what
* that shell will execute. What the engine cannot read or verify is no reason to ask more strictly than an ordinary question,
* so those two read the ordinary row ({@link ORDINARY_ROW}); they stay words of their own for the reason a card and a release name.
* `unfinished_check` is the read station's check that did not finish — the environment left a lookup of the command's reads
* unanswered, or the station's judgment did not finish (it timed out or threw), so the safety checks on what the command reads did
* not run: the reference implementation's unfinished check (`checkIncomplete`, its circuit breaker `unfinishedCheck`, a safety check
* no classifier answers and no allow rule silences). Only a person answers it under every mode; its one minter is the station's
* silence, which also puts the real-approval bit on the ask, and the class explains that bit.
* `sandbox_network` is a command running in the run's sandbox connecting to a host neither of the requirement's domain lists names
* (the engine's own question about a connection, put while the command runs): the reference implementation's network question —
* `bypassPermissions` releases it, `dontAsk` refuses it, auto mode's classifier answers it, an allow rule clears it, and the sandbox
* admits nothing on its behalf (it is the sandbox's own question).
* `sandbox_override` is a shell call that leaves the run's command sandbox by its own `dangerouslyDisableSandbox` (the gate's record,
* read off the call's sandbox plan): the reference implementation's `sandboxOverride` question — an explicit allow rule keeps
* it allowed, `bypassPermissions` releases it, auto mode's classifier answers it, and the sandbox admits nothing on its behalf
* (it is the call that leaves the sandbox). The reference's rule check answers `ask` for it (`hookAskFloor`): a hook's word beside
* it — its allow as its ask — leaves the call to the full pipeline. An ask whose word it is IS the escape's question: it speaks
* the escape's sentence ({@link sandboxOverrideMessage}), whatever hesitation it stands over.
* A rule that may govern the call and cannot be read for it is one of three facts, each its own class because each is its own
* question: the ORGANIZATION's snapshot cannot be read — `org_unreadable` (`org_rule`'s row: no configuration, mode or classifier
* answers for the organization; its own words, since none of the organization's rules asked); the PERSON's rules cannot be read — a partition of their store, or the rows the
* read station stands on (`rule_unreadable`: the person's own rules, which the person's relaxed mode answers — auto mode's classifier
* judges the call, `bypassPermissions` releases it — while the asking modes still put it to the person); or rules that WERE read
* cannot be read against this call — the lexer's word against a stored row, a content-form deny / ask row (`call_unreadable`: the
* engine cannot tell what the call does against a rule it holds, which only a person answers, under every mode).
* `write_protection` and `write_protection_on_disk` are the two readings of one table hit, judged per written target and never
* both for one target: the path AS WRITTEN names a row of the write-protection table (`write_protection`), or only where the path
* resolves on disk does (`write_protection_on_disk` — its real target, or a link on the way: an innocent spelling the disk carries
* onto a guarded path). The two read one arbitration row; they stay two classes because the card says which reading met the row.
* A command writing several targets may carry both.
*/
export declare const ASK_CLASSES: readonly ["content_question", "hook", "ancestor", "dangerous_delete", "transcript_write", "org_rule", "org_unreadable", "rule_unreadable", "call_unreadable", "ask_rule", "denial_limit_fallback", "classifier_no_ruling", "requires_user_interaction", "cross_boundary", "operator_forced", "shell_floor", "target_unresolved", "probe", "write_protection_on_disk", "write_protection", "tool_marks_mcp", "tool_marks_a2a", "unfinished_check", "policy_rra", "artifact_shared_read", "mode", "a2a_inside", "unverifiable_delete", "unverifiable_shell_text", "sandbox_override", "sandbox_network", "unstated", "ordinary"];
export type AskClass = (typeof ASK_CLASSES)[number];
/** Membership test for {@link AskClass} — the word crosses the wire on `tool_end.gate.disposition`. */
export declare function isAskClass(v: unknown): v is AskClass;
/** The escape question's sentence (the reference's "Run outside of the sandbox"): the message of every ask whose word is
* `sandbox_override` — what a card shows, the mode's refusal quotes and auto mode's classifier reads for a call that leaves the
* run's sandbox by its own `dangerouslyDisableSandbox`. */
export declare function sandboxOverrideMessage(toolName: string): string;
/** The words an ask takes from its class word: the escape's word (`sandbox_override`) speaks the escape's sentence — the reference's
* escape question replaces the hesitation it stands over — and every other word leaves the ask's own. The one reading both stations
* that derive an ask's class apply: the gate's origin stamp and an inherited station's judgment. */
export declare function classWordsOf(classification: Pick<AskClassification, "askClass">, toolName: string): {
message?: string;
};
/** The four switches a class carries, one row per class ({@link MODE_ARBITRATION}). */
export interface ModeArbitrationRow {
/** The ask still reaches a person under `bypassPermissions` (the reference implementation's `bypassImmune`). */
readonly bypassImmune: boolean;
/** The auto-mode classifier may answer it — as the class stands on its own: the folded row of an ask
* ({@link foldArbitrationRow}) also takes the read face the ask was raised under. */
readonly classifierEligible: boolean;
/** The sandbox-admission leg may admit it (containment holds the effect). */
readonly sandboxAdmission: boolean;
/** A persisted allow rule may clear it. */
readonly ruleMayClear: boolean;
/** The reference implementation's rule / safety check answers `ask` for it, so a hook's word beside it is not the hook's
* decision: the call runs the full permission pipeline (the reference's `hookAskFloor`) — a hook's ask under `dontAsk` is a
* refusal rather than a person's question, and a hook's allow clears nothing ({@link allowMayClearOn}). */
readonly hookAskFloor: boolean;
}
/**
* May an allow member clear an ask whose folded row is `row`? The allow layer's ONE reading, by the member's kind: a `rule` — a
* list entry, a stored row, a skill's grant, the read-only reader — where the row's `ruleMayClear` says so; an extension's word
* (`hook`: a PreToolUse `allow`, a `tool.check` `allow`) only where, besides, the reference's rule check would not answer `ask`
* for the ask (`hookAskFloor`) — the reference sends a hook's allow back through that check and, where it asks, through the full
* pipeline, so beside such a class the hook's allow decides nothing.
*/
export declare function allowMayClearOn(row: ModeArbitrationRow, kind: "rule" | "hook"): boolean;
/**
* May a grant BOUND to an inside peer's current identity stamp clear an ask holding `classes`? Only an ask that holds `a2a_inside`
* asks it; the answer is the `ruleMayClear` of the row folded over the ask's OTHER classes — the class itself withholds every unbound
* clear, and a bound one meets only what else the question says (an explicit ask rule, a mark, a governance verdict, a hook's ask).
* The one reading the allow layer's law and the headless remedy take; no face enters it (neither face moves `ruleMayClear`).
*/
export declare function boundGrantMayClear(classes: ReadonlySet<AskClass>): boolean;
/**
* The mode × class table. `bypassImmune` is the one new column (nothing said it before); the classifier and
* sandbox columns are the fold of the two former per-word lane tables (only `probe` moved: the classifier may
* now answer it — the read boundary's unestablishable spelling is fed to it as a deny-table row instead), and
* `ruleMayClear` is the allow layer's reading: an allow member clears a standing ask exactly when the folded row says so
* (every class a real-approval bit, a governance verdict, a hook, a mark or an ask rule brings says no) — and an extension's
* word not beside a `hookAskFloor` class ({@link allowMayClearOn}).
* `probe`'s `classifierEligible` is the OPEN read face's reading: a narrowed (`roots`) face withholds the classifier from the class,
* folded where the ask's row is ({@link foldArbitrationRow}).
* `mode` is the permission mode's OWN question (`plan`'s two sentences, `decisionReason: "mode"`): the reference
* implementation puts it to a person past every allow rule and never to an automatic lane, and its bypass conversion
* releases it like any other non-immune ask. `unstated` is the reference implementation's passthrough conversion: an allow
* rule or a bypass mode clears it, auto mode's classifier answers it, and a sandbox admits nothing on its behalf (the
* tool's effect lands at a remote peer, outside any containment the leg declares). `hookAskFloor` marks the classes the reference's rule / safety check answers
* `ask` for — an ask rule, a question the tool needs a person for, a dangerous removal, a protected or unresolvable write
* target, the session transcript, another's shared artifact, a command leaving the sandbox by its own escape, a check that did not finish. `write_protection_on_disk`
* reads `write_protection`'s row whole, and auto mode's classifier answers `artifact_shared_read`: where the reference keeps its
* classifier off a question (a settings file reached through a link, another person's shared artifact), this table hands those two
* to it — the two relaxed modes ask a person nothing their mode can answer. `rule_unreadable` (the person's own rules unread) is
* answered by the person's relaxed mode the same way; `call_unreadable`, `org_rule` and `org_unreadable` are not.
* A row is a class's reading on every face but the ones {@link RELEASED_ON_SHELL_FACE} names: `target_unresolved`'s
* `bypassImmune` is the file face's (and every other face's) reading, and the shell face reads it released — folded where the
* ask's row is ({@link foldArbitrationRow}), listed per face by {@link releasableAskClassesFor}.
*/
export declare const MODE_ARBITRATION: {
readonly content_question: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly hook: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly ancestor: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly dangerous_delete: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly transcript_write: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly org_rule: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly org_unreadable: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly rule_unreadable: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly call_unreadable: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly ask_rule: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly denial_limit_fallback: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly classifier_no_ruling: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly requires_user_interaction: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly cross_boundary: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly operator_forced: {
readonly bypassImmune: true;
readonly classifierEligible: true;
readonly sandboxAdmission: true;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly shell_floor: {
readonly bypassImmune: true;
readonly classifierEligible: true;
readonly sandboxAdmission: true;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly target_unresolved: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: true;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly probe: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly write_protection_on_disk: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: true;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly write_protection: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: true;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly tool_marks_mcp: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: true;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly tool_marks_a2a: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: true;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly unfinished_check: {
readonly bypassImmune: true;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly policy_rra: {
readonly bypassImmune: true;
readonly classifierEligible: true;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly artifact_shared_read: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: true;
};
readonly mode: {
readonly bypassImmune: false;
readonly classifierEligible: false;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly a2a_inside: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: false;
readonly ruleMayClear: false;
readonly hookAskFloor: false;
};
readonly unverifiable_delete: Readonly<{
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: true;
readonly ruleMayClear: true;
readonly hookAskFloor: false;
}>;
readonly unverifiable_shell_text: Readonly<{
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: true;
readonly ruleMayClear: true;
readonly hookAskFloor: false;
}>;
readonly sandbox_override: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: false;
readonly ruleMayClear: true;
readonly hookAskFloor: true;
};
readonly sandbox_network: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: false;
readonly ruleMayClear: true;
readonly hookAskFloor: false;
};
readonly unstated: {
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: false;
readonly ruleMayClear: true;
readonly hookAskFloor: false;
};
readonly ordinary: Readonly<{
readonly bypassImmune: false;
readonly classifierEligible: true;
readonly sandboxAdmission: true;
readonly ruleMayClear: true;
readonly hookAskFloor: false;
}>;
};
/** The fence over the arbitration table: `never` while every class has a row. */
export type ArbitrationTableCoversEveryClass = AssertAllKeysHandled<Exclude<AskClass, keyof typeof MODE_ARBITRATION>>;
/**
* The FACE a question was put on — the second axis the permission mode reads a class under, beside the leg's read face
* ({@link ContainmentFace}). `shell`: the call's `command` argument is a shell command line the command grammar judges (the
* tool catalog's shell face — Bash, Monitor); `other`: every other call (the file tools, MCP, A2A, a caller's own tool). The set
* is closed; {@link askFaceOf} is the one derivation of a face from a tool name.
*/
export declare const ASK_FACES: readonly ["shell", "other"];
export type AskFace = (typeof ASK_FACES)[number];
/** The face of a call, by its WIRE name (the name the gate resolved the call to — a release widens, so an alias a tool merely
* wears does not count): the catalog's shell face for exactly the names that declare the command grammar, `other` for every
* other name. */
export declare function askFaceOf(toolName: string): AskFace;
/** The classes `bypassPermissions` releases on a CONFINED Runner (`RunnerDeps.deploymentShape` declared) although their row says
* immune — the same kind of reading as {@link RELEASED_ON_SHELL_FACE}: one column, read at the mode point only (the fold, the
* classifier, the card and the park row read the table's rows). A read check that did not finish. */
export declare const RELEASED_ON_CONFINED_RUNNER: readonly ["unfinished_check"];
/** The classes whose own mint puts the `requiresRealApproval` bit on the ask — a bit one of them explains is not
* the bare bit `policy_rra` names. The mark classes (probe / write protection / tool marks / operator forced / the
* shell floor) mint no bit and explain none — except `requires_user_interaction`, whose declaration the origin stamp
* turns into the bit on every ask of the tool. */
export declare const RRA_EXPLAINERS: ReadonlySet<AskClass>;
/** Whether a set of classes holds one that explains the `requiresRealApproval` bit ({@link RRA_EXPLAINERS}) — the ONE reading of the
* bit's fence. A bit a member explains is that member's demand for a person, not the bare bit `policy_rra` names: the mint reads it over
* an ask's own members ({@link ownAskClassesOf}) and again over the whole set ({@link classifyAsk}), and the edit re-check reads it
* over the classes a person answered ({@link import("./real-approval.js").editRecheckUnanswered}). */
export declare function explainsRealApprovalBit(classes: Iterable<AskClass>): boolean;
/** The classes a permission mode can RELEASE for a call on `face`, in {@link ASK_CLASSES} order. The same list on every face
* but one class — {@link RELEASED_ON_SHELL_FACE}. A frozen list: a caller holding it cannot change the next read. A word
* outside {@link ASK_FACES} throws. A Runner that declares its shape releases more: {@link confinedReleasableAskClassesFor}. */
export declare function releasableAskClassesFor(face: AskFace): readonly AskClass[];
/** {@link releasableAskClassesFor} on a Runner that declares its shape (`RunnerDeps.deploymentShape`): the list with
* {@link RELEASED_ON_CONFINED_RUNNER} in it — released only where no person was already required on the question, the call's own
* destination stays on the leg's hands and what the check did not see guards nothing ({@link ConfinedCall}); a release that stood on
* it says `confined: true`. A word outside {@link ASK_FACES} throws. */
export declare function confinedReleasableAskClassesFor(face: AskFace): readonly AskClass[];
/**
* The closed set of `reason` words a mode release carries (`GateDisposition.released.reason`, the `released` arm of
* {@link Arbitration}): each is a releasable class the release record names on its own — `target_unresolved`, a release
* (the shell face only, {@link RELEASED_ON_SHELL_FACE}) over a write target whose reading could not say where it leads. A
* release carries the first member (array order) its class set holds, and none when it holds no member. {@link arbitrateByMode} and {@link isModeReleaseReason} read one copy
* of this list taken at load (a caller that writes into the exported array changes neither), so a new reason is one
* word here.
*/
export declare const MODE_RELEASE_REASONS: readonly ["target_unresolved"];
export type ModeReleaseReason = (typeof MODE_RELEASE_REASONS)[number];
/** Membership test for {@link ModeReleaseReason} — the word crosses the wire on `tool_end.gate.disposition.released.reason`. */
export declare function isModeReleaseReason(v: unknown): v is ModeReleaseReason;
/**
* The facts the class derivation reads beside the decision: the origin facts the gate holds, plus the tool
* seat's mark PROVENANCE ({@link ToolMarkSource}; a mark with no source reads as the deployment's, fail-closed),
* the A2A isolation switch (a set switch turns the A2A default into an operator's mandate), and — at an
* ancestor station — the classes the ancestor's own ask carries.
*/
export interface AskClassFacts extends AskOriginFacts {
readonly toolMarkSources?: ReadonlySet<ToolMarkSource>;
readonly a2aIsolatePeers?: boolean;
readonly ancestorClasses?: ReadonlySet<AskClass>;
/** The read face the leg this ask was raised on resolved ({@link ContainmentFace}); absent ⇒ none resolved (a leg with no hands). */
readonly readFace?: ContainmentFace;
/** The tool face the question was put on ({@link askFaceOf} of the call's tool name); absent ⇒ the face-less reading, which is the `other` face's. */
readonly askFace?: AskFace;
/** The gate's record that this call leaves the run's command sandbox by its own `dangerouslyDisableSandbox` (`GatePass.leavesSandbox`):
* the class `sandbox_override`. Written only by the gate. */
readonly leavesSandbox?: boolean;
/** The gate's record that this call goes to an A2A peer registered inside the trust boundary (`ToolGateInput.a2aInsidePeer`): the
* class `a2a_inside`. Written only by the gate. */
readonly a2aInside?: boolean;
}
/** The classification the arbitration reads: the whole set, the disclosed word (the set's first member in
* {@link ASK_CLASSES} order) and the row folded across the set. */
export interface AskClassification {
readonly classes: ReadonlySet<AskClass>;
readonly askClass: AskClass;
readonly row: ModeArbitrationRow;
/** The tool face the classification was derived on ({@link AskClassFacts.askFace}); absent ⇒ the face-less reading, the `other`
* face's. The mode point and the headless remedy read the face here and nowhere else ({@link bypassImmuneOf}). */
readonly askFace?: AskFace;
}
/** The two members an ask's classification puts on the approval request and the park row: the disclosed word and
* the whole set, the set as an array in {@link ASK_CLASSES} order (so `classes[0] === askClass`). */
export interface AskClassMembers {
readonly askClass: AskClass;
readonly classes: readonly AskClass[];
}
/** The ONE projection of a classification onto {@link AskClassMembers} — every station that carries an ask's class
* spells it through this, so the word and the set cannot be read from two derivations. The array is a fresh frozen
* copy per call: an approver that holds it cannot reach the park row's copy or the next card's. */
export declare function askClassMembersOf(c: AskClassification): AskClassMembers;
/** The screen a boundary applies to the pair where a host reads it back (the park row, a store's copy of it): both or neither, and
* only a well-formed pair — every member of `classes` in the closed set, no repeat, at least one, and `askClass` one of them.
* The pair returned is DERIVED from the set under this release's order (the word the set's first member in {@link ASK_CLASSES}
* order, `classes` in that order), so a pair stored under another release's order — whose word was the first member there — reads
* as the pair this release would have written for the same set; a word outside the set answers nothing. The copy returned is
* fresh and frozen, never the caller's array. */
export declare function screenAskClassMembers(askClass: unknown, classes: unknown): AskClassMembers | undefined;
/**
* The OWN half of the class derivation — what ONE ask says about itself through its own members, and the integrity guards
* its engine record carries for its call (`record`, read by the caller through {@link attestationOf}): the guards are engine
* findings, never a member, so a policy cannot move a real-approval question into a guard's class. The bare-bit rules are
* applied over THIS ask's own set: `requiresRealApproval` with no explaining class is `policy_rra` ({@link bareBit}); a self-declared
* `mandated` with no other class is `operator_forced` (a deployment probe's own mandate, read conservatively). Returns the
* specific classes only — an empty set is "nothing but hesitation", which the caller reads as `ordinary`.
*/
export declare function ownAskClassesOf(d: Extract<PermissionResult, {
action: "ask";
}>, record: EngineAttestation | undefined): Set<AskClass>;
/** The DECISION's classes as the policy fold reads a contributing ask: its own ({@link ownAskClassesOf}) and the classes of the
* asks a fold already collapsed into it ({@link EngineAttestation.foldedClasses}) — both off its record for `call`, so a
* fact the fold does not copy is not lost behind the ask that won the slot. */
export declare function decisionAskClassesOf(d: Extract<PermissionResult, {
action: "ask";
}>, call: AskOriginFacts["call"]): Set<AskClass>;
/** Fold a class set onto one row: `bypassImmune` and `hookAskFloor` by OR (any immune member keeps the ask; any floored
* member floors a hook's ask), the three permissive switches by AND (one refusing member withholds the lane). An empty
* set is `ordinary`. The two faces the ask was raised under enter HERE and nowhere else, so every reader of the folded row
* reads it already folded: `readFace` — `roots` takes the classifier's lane from a set that holds a class the narrowed face
* withholds from it; `askFace` — `shell` reads a class {@link RELEASED_ON_SHELL_FACE} holds as not bypass-immune. Absent
* faces read the table's own rows. */
export declare function foldArbitrationRow(classes: ReadonlySet<AskClass>, readFace?: ContainmentFace, askFace?: AskFace): ModeArbitrationRow;
/**
* The ONE class derivation: the decision half ({@link decisionAskClassesOf}) joined with the gate's own facts —
* the question tool, an ancestor's mark, the org layer's two arms, the persisted lane's unreadable call, the tool
* seat's marks with their provenance, the read probe and the write-protection judge's records — then the bare
* real-approval rule re-read over the WHOLE set (an org verdict explains a bit the policy did not mint). The
* derivation reads facts and members, never the `origin` / `mandate` words.
*/
export declare function classifyAsk(d: Extract<PermissionResult, {
action: "ask";
}>, facts: AskClassFacts): AskClassification;
/** The opening words of the refusals the reference implementation words alike, spelled once: a person's refusal of a tool use on a
* parent thread (`USER_REFUSED_TOOL_USE`), and the "permission was denied" opening a delegated child reads — after a person's refusal
* (`humanRefusalSentence`, the question tool's decline) and when nobody could be asked ({@link unresolvedAskDenialMessage}). */
export declare const USER_REFUSED_TOOL_USE = "The user doesn't want to proceed with this tool use", DELEGATED_TOOL_USE_DENIED = "Permission for this tool use was denied";
/** The causes whose refusal sentence is minted by {@link unresolvedAskDenialMessage}: nobody could be asked because no approver is
* wired, or because the wired one answered `unavailable` for this ask, or (`approval_window_expired`) the wired one answered
* `window_expired`: its own approval window for this ask closed with no one answering it. */
export type UnresolvedAskCause = "no_approver_wired" | "approver_unavailable" | "approval_window_expired";
/** What a model whose question got no answer is told to do — the one instruction every refusal and every no-answer exit of the
* question tool gives it, and the one the tool's card promises ("you will be told to proceed with your best judgment"). */
export declare const PROCEED_ON_JUDGMENT = "Proceed with your best judgment: pick the most reasonable option, state the assumption you made, and continue.";
/** One ask nobody could answer, as {@link unansweredAskRefusal} words it: a permission ask (`cause` says why nobody answered it — no
* approver, or the approver reported nobody reachable — and `question` is what it asked), or the agent's own question. The park state:
* `parkFailed`, a durable park was ATTEMPTED for the call and could not be minted; `noAttempt`, the leg cannot hold a park and none was
* attempted. Either way the note the gate's deny exit appends ({@link import("./runner/gate-exit.js")}) is then the only sentence that
* speaks about the park, so a clause that depends on the park state is in exactly one form: "do not retry it in this session" and
* "nothing here can keep the request waiting" belong to a run with no park attempt, "it can be issued again once its park can be
* minted" to a park that failed, and no refusal says both. A question on a leg whose parks cannot be resumed carries `leg` — that
* leg's own account of why nothing kept the question waiting (park-resumability's `questionNotShownOnLeg` words it; no park is ever
* attempted there) — and the account takes the parenthesis slot the park-state clause takes elsewhere. */
export type UnansweredAsk = {
readonly cause: UnresolvedAskCause;
readonly question: string;
readonly parkFailed: boolean;
} | {
readonly cause: "question";
readonly noAttempt: false;
} | {
readonly cause: "question";
readonly noAttempt: true;
readonly leg?: string;
};
/**
* THE refusal a model reads for an ask nobody could answer — the one mint of all three (an approval nobody could be asked for, an
* approval the approver said nobody could be reached for, the agent's own question), in one shape: why (the opening and its cause),
* that it did not happen, and one way on. The two permission forms are the reference implementation's sentence (its no-prompt
* refusal; the ask's prompt as what was requested — the gate appends the caller-side remedy after it); the question is not an approval,
* so its opening says a question went unanswered and its way on is {@link PROCEED_ON_JUDGMENT}, its only instruction — on every
* leg, a leg that cannot be resumed included (its cause in the parenthesis, never a second opening or a second instruction).
*/
export declare function unansweredAskRefusal(ask: UnansweredAsk): string;
/** {@link unansweredAskRefusal} of a permission ask: the sentence the ask resolver refuses with (no park attempt yet), and the one the
* deny exit re-mints over the same question once the park state is known. */
export declare function unresolvedAskDenialMessage(cause: UnresolvedAskCause, question: string, parkFailed: boolean): string;
/** The resolver's own account of a refusal it minted with {@link unresolvedAskDenialMessage} (`EngineAttestation.unanswered`): the
* cause and the question it quoted, and the sentence as minted — the deny exit re-mints over that question only while the decision's
* text is still that sentence, byte for byte. */
export interface UnansweredMint {
readonly cause: UnresolvedAskCause;
readonly question: string;
readonly text: string;
}
/** What the model is told after a refusal nobody could answer, where nobody on the leg may approve the ask (its approval seat is no
* person's callback and no armed park can take the ask for one): no person to find, so no further ask, and no other road to the same
* effect around the approval — it goes on with what needs no approval and names, in its result, the step skipped and still waiting
* for an approval. It takes the person clause's place in the model's sentence (the `nobody` seat of {@link headlessApprovalRemedy},
* and the deny exit's tail where the refusal has no remedy) — the leg's tool text, and the parent's report of the leg (the refused-ask
* record's `modelRemedy`); the host's sentence (the `delegation.ask_unresolvable` notice, the record's `remedy`) keeps the person
* clause. No capital, no stop. */
export declare const NOBODY_CAN_APPROVE = "nobody on this run can approve it, so do not ask for it again, and do not get the same effect another way to avoid the approval \u2014 go on with the work that does not need it, and say in your final result which step was skipped and still needs approval";
/**
* The refusal the model reads when the `dontAsk` permission mode refuses an ask (`deniedBy: "mode"`): the reference implementation's
* head (whose permission, which mode — with the ask's own question beside it, which says where and why; nothing when the ask carries no message, never the class word) and its guidance ({@link REFUSED_CAPABILITY_GUIDANCE}), then
* the way out, the ONE remedy function's `dontAsk` arm ({@link headlessApprovalRemedy}) — the same sentence a headless refusal's
* remedy is written by, so a mode refusal and a headless one say the way out in one voice. `ruleShape` is the shape of the allow
* rule that would speak for the call (`ruleShapeOf` under `allow`, the rule model's reading of the call's grammar). The sentence
* names where allow rules live in a person's words (a settings file, the request's or the deployment's allow list), never a seat
* of the library: a host reads the same answer off the denied disposition — `deniedBy: "mode"`, `mode`, and the folded
* `classes`, whose row ({@link foldArbitrationRow}) says `ruleMayClear` — and offers its own seat.
*/
export declare function dontAskRefusalMessage(input: {
readonly toolName: string;
readonly classification: AskClassification;
readonly coveredWrite: boolean;
readonly ruleShape: string; /** the ask's own message, untrusted display text (see the body) */
readonly question?: string;
}): string;
/** The state of the approver seat a remedy is written for: `absent` — no approver is wired for the leg; `unavailable` — one is
* wired and answered that nobody is reachable for this ask; `policy` — the approver wired is the deployment's approval policy
* (`asPolicyApprover`) and it answered `unavailable` for this ask; `declared_none` — the run declared that nobody on it can be
* asked (`approvalReach: "none"`), whatever is wired; `nobody` — the model's sentence where nobody may answer on the leg: the arm names
* its own changes and then {@link NOBODY_CAN_APPROVE} in the person clause's place; `window_expired` — one is wired and answered that
* its own approval window for this ask closed with no one answering it. Absent in the input reads as `absent` (the posture
* the function was written for). */
export type HeadlessApproverSeat = "absent" | "unavailable" | "policy" | "declared_none" | "nobody" | "window_expired";
/** The kinds of way out a refusal carries as DATA: `approver` — a person who can answer becomes reachable (the sentence's approver clause);
* `permission_mode` — a mode that releases the ask with nobody answering it (`bypassPermissions`, unless the deployment's caps deny it:
* a denied bypass folds to `default`); `park` (#5244) — the durable approval park that was attempted for the call succeeds, so the ask waits
* for a person: why it failed, and what makes it succeed, are the same frame's `parkFailed` / `parkFailedReason` (this kind repeats neither).
* A host renders a kind or leaves it unrendered; the sentence a user reads never teaches the release. */
export declare const APPROVAL_REMEDY_KINDS: readonly ["approver", "permission_mode", "park"];
export type ApprovalRemedyKind = (typeof APPROVAL_REMEDY_KINDS)[number];
/** Membership test for {@link ApprovalRemedyKind} — the word rides a notice detail across process boundaries. */
export declare function isApprovalRemedyKind(v: unknown): v is ApprovalRemedyKind;
/** One way out, discriminated by `kind` ({@link APPROVAL_REMEDY_KINDS}). `permission_mode` names the mode (`value`: `bypassPermissions`, the one
* mode that releases an ask a person did not answer) and where the release is disclosed (`disclosedOn`: the allowed disposition's `released`
* member on the call's `tool_end.gate`) — the disclosure a host shows beside the offer. */
export type ApprovalRemedy = {
readonly kind: "approver";
} | {
readonly kind: "permission_mode";
readonly value: "bypassPermissions";
readonly disclosedOn: "gate.disposition.released";
} | {
readonly kind: "park";
};
/** One {@link ApprovalRemedy} read from `v`, as a fresh plain object holding only the fields its kind owns — or `undefined` when `v` is not exactly
* one (a kind outside the closed set, a member missing, a member beyond the kind's own, any field inherited rather than own). Each field is read
* once; the notice mint copies through this and refuses what it cannot read. */
export declare function readApprovalRemedy(v: unknown): ApprovalRemedy | undefined;
/** The headless remedy: `sentence` — the user-facing way out, which names the approver and never offers the bypass release — and `remedies` — every way out as data, the approver first. */
export interface HeadlessApprovalRemedy {
readonly sentence: string;
readonly remedies: readonly ApprovalRemedy[];
}
/**
* The host's way out of a refusal whose durable park was attempted and failed (#5244), off the headless remedy and the park's failure:
* the park first — in the sentence (why it could not be set aside, quoted as the deny's note quotes it, and that once it can be the ask
* waits for a person) and in the data (`{ kind: "park" }`, first) — then the headless remedy's own. ONE rule, which the deny exit reads
* and the notice's mint holds it to: a `park` way out rides exactly where the frame carries `parkFailed`.
*/
export declare function withParkRemedy(headless: HeadlessApprovalRemedy, parkFailed: string): HeadlessApprovalRemedy;
/**
* The ONE answer a headless auto-deny (an ask that reached its final deny because no approver is wired) adds
* after its refusal: the caller-side change that would have let this call run, as a sentence (`sentence`) and as the
* ways out in data (`remedies`, {@link ApprovalRemedy}: the approver in every arm). Read off the effective mode, the
* ask's folded class row and whether the call is a covered write (the mode write gate's own question):
* · a class no permission mode releases (`bypassImmune`) — only a person can answer it: wire an approver (a `cross_boundary` ask adds
* that an earlier yes from the policy or an approval factory does not answer it, {@link CROSS_BOUNDARY_EARLIER_YES});
* · the plan mode's own question (`mode`) — leave plan (steer the mode, or approve the plan) or wire an approver;
* · the write gate's own ask under `default` / `auto` — `acceptEdits` lets writes inside the working
* directories through without asking;
* · the same ask under `acceptEdits` — the target lies outside the working directories: add its directory to
* `additionalDirectories`;
* · any other releasable ask, and a tool that states no permission of its own — `bypassPermissions` releases it (disclosed on the call):
* the sentence does not say so; `remedies` carries it as a `permission_mode` member for a host that chooses to offer it.
* Every arm also names the approver, in the clause of the seat's own state ({@link HeadlessApproverSeat}): none wired ⇒
* wire one; one wired that answered `unavailable` for this ask ⇒ make a person reachable through it (a wired approver is
* never told to be wired); the deployment's approval policy answered `unavailable` ⇒ park it for a person, or run it where a
* person can be asked (a policy is not a person to make reachable); the run declared nobody can be asked ⇒ run it where a person can be, or park it (omitting the park clause when `approvalParkWithheld` is true). The `delegation.ask_unresolvable` notice and the run's refused-ask record carry this sentence —
* they call this function, neither spells it — and the notice carries `remedies` beside it; the refusal's tool text carries it where a
* person may answer on the leg, and where nobody may (the deny exit's one reading) this function's sentence for the `nobody` seat — the
* same arm, its own changes kept, {@link NOBODY_CAN_APPROVE} in the person clause's place — which the refused-ask record carries
* beside it (`modelRemedy`) for the parent's model to read.
* Under `dontAsk` (the mode answers no ask: {@link dontAskRefusalMessage} carries this arm) the one question is whether an allow
* rule may clear the ask — the folded row's `ruleMayClear`, the allow layer's own reading: yes ⇒ add an allow rule covering the
* call, in the tool's rule shape (`ruleShape`, the caller's reading of the call's grammar — never a rule minted for the call), or
* run under a mode with an approver; no ⇒ only a person can answer it.
*/
export declare function headlessApprovalRemedy(input: {
readonly mode: PermissionMode | undefined;
readonly classification: AskClassification | undefined;
readonly coveredWrite: boolean;
readonly unplacedOptions?: {
readonly program: "cp" | "mv";
};
readonly approverSeat?: HeadlessApproverSeat;
readonly approvalParkWithheld?: boolean;
readonly ruleShape?: string;
readonly notResumableWayOut?: string; /** a confined Runner's facts for the call: bypass is a way out exactly where the mode point would release ({@link ConfinedCall}) */
readonly confined?: ConfinedCall; /** the ask is a write-face ask row's own question — the row the read station found a written target under raised it, no other rule did ({@link writeAskRowsCountNow}) */
readonly writeAskRowOwnCard?: boolean;
}): HeadlessApprovalRemedy;
/** The reference implementation's sentence for a `cp` / `mv` the mode will not answer because it carries option
* words — the approval card's message under `acceptEdits` and the head of the headless remedy. */
export declare function fileCommandOptionsSentence(program: "cp" | "mv"): string;
/** What the mode arbitration decided for one surviving ask. `ask` hands it on unchanged (park / approver); `accepted` is
* the mode answering an ordinary question itself (`acceptEdits` on one of its file commands — an allow of the mode's own
* policy, like its in-root write gate, and no release: nothing is disclosed as released);
* `released` is an allow the mode granted (disclosed on `tool_end.gate.disposition.released`); `denied_by_mode`
* is a refusal the mode made (`deniedBy: "mode"`). */
export type Arbitration = {
kind: "ask";
heldByWriteAskRow?: true;
} | {
kind: "accepted";
mode: "acceptEdits";
} | {
kind: "released";
mode: PermissionMode;
askClass: AskClass;
classes: readonly AskClass[];
origin?: AskOrigin;
mandate?: PersistedRuleMandate;
reason?: ModeReleaseReason;
confined?: true;
} | {
kind: "denied_by_mode";
mode: "bypassPermissions" | "dontAsk";
askClass: AskClass;
classes: readonly AskClass[];
};
/**
* What a CONFINED Runner (`RunnerDeps.deploymentShape` declared) lends the mode point for one call — three facts (and, for the headless
* way out, whether bypass would arm), each read only in the one cell that needs it (`bypassPermissions`, a class set that only {@link RELEASED_ON_CONFINED_RUNNER} keeps immune), never by the
* other modes or the other readers of the class set:
* - `personAlreadyRequired` — a person was already required on this question when the read check went silent (the real-approval
* bit stood before the silence put its own there; the silence's class explains the bit, so the class set cannot say it). The gate's
* answer is the engine's record of the silence; a question with no such record answers `true`.
* - `destinationOnHands` — the call's own declared destination, on the arguments that run, stays on the leg's hands: a hand of the
* environment, no egress mark, every boundary leg the call declares is the environment's.
* - `unseenGuardsNothing` — what the check that did not finish left unseen can hold no write a deny row protects: where the read
* station answered, no row that guards writes stands on the call's own table or on the one in force now, or the engine's read-only
* reader proves the command read-only; where the gate put the station's fallback in its place (the station gave no answer), no deny
* row at all stands on either table. Rows that could not be read count as rows. Read under the mode the reader reads now: where
* that mode counts the write-face ask rows ({@link writeAskRowsCountNow}), such a row on either table guards the command's writes
* too (a command the reader proves read-only still writes nothing).
* The mode releases only when the first is `false` and the other two `true`.
*/
export interface ConfinedCall {
readonly personAlreadyRequired: () => boolean;
readonly destinationOnHands: () => boolean;
readonly unseenGuardsNothing: (mode?: PermissionMode) => boolean;
/** Asking for `bypassPermissions` now would run the leg under it — the leg's own mode fold over its ceiling and the deployment's
* arming facts (`PermissionModeController.armsAs`). Read by the headless way out alone: the mode point is already in the mode. */
readonly bypassArmed: () => boolean;
}
/**
* Under which permission mode the read station's WRITE-face ask fact counts ({@link ShellReadVerdictFacts.writeAskRule}: a target
* a shell command writes meets a person's or the task's policy's `Edit(<path>)` ask row) — one cell per mode, true under
* `bypassPermissions` alone: there the row is its own question (`ask_rule`), as the same row is on the Edit tool; every other mode
* reads the command as the mode reads any command (its own question, the shape tier, the allow rules). The read face's ask row
* counts under every mode. The table is read through {@link writeAskRowsCountNow} alone.
*/
export declare const WRITE_FACE_ASK_ROW_COUNTS: Readonly<{
readonly default: false;
readonly acceptEdits: false;
readonly plan: false;
readonly auto: false;
readonly dontAsk: false;
readonly bypassPermissions: true;
}>;
/**
* Whether the write-face ask rows exist for a judgment made under `mode` — the one door every reader of them passes: the shell read
* boundary hands the station the rows (and says a row it cannot anchor) only where this answers `true`, the fold and the mode read
* point read the station's fact only then, the two belts and the edit's re-judge likewise, a confined Runner's unfinished check counts
* the rows only then, and the headless way out names the row only then. Under every other mode the rows are not read at all: what
* that mode decides, says and asks is what it was without them. `undefined` ⇒ no mode seat: they do not exist.
*/
export declare function writeAskRowsCountNow(mode: PermissionMode | undefined): boolean;
/** The ask row a read station's answer stands on under `mode` ({@link writeAskRowsCountNow}): the one its reads meet, under
* every mode; else the one a written target meets, where the mode counts it. `policy` ⇔ the row is the task's permission
* policy's; `face` names which of the two it is. `undefined` ⇒ no row stands. */
export declare function stationAskRowOf(verdict: Pick<ShellReadVerdictFacts, "askRule" | "askRuleOfPolicy" | "writeAskRule" | "writeAskRuleOfPolicy">, mode: PermissionMode | undefined): {
readonly rule: string;
readonly policy: boolean;
readonly face: "read" | "write";
} | undefined;
/** Whether `mode` answers an ask of class `c` with nobody asked — the class's row read under the mode, on the face-less reading:
* `bypassPermissions` releases a class it is not immune to, auto mode's classifier judges a class it may answer; the other modes put
* it to a person (`dontAsk` refuses it, which a person is still told about). For a reader that tells a person what a class costs them
* meanwhile — never a second arbitration: the gate's answer is {@link arbitrateByMode} and the classifier station. */
export declare function modeAnswersUnasked(mode: PermissionMode, c: AskClass): boolean;
/**
* The ONE mode read point. `dontAsk` refuses every ask — one value for every class — but a hook's that no member of the
* set floors (`hookAskFloor`: a hook's ask beside a rule's or a safety check's ask is refused, as the reference's full
* pipeline refuses it; a hook's ask alone is the reference's forced decision, which never reaches that conversion);
* `bypassPermissions` refuses a write whose target's reading could not say where it leads on a face where THAT class stays
* immune (every face but the shell's: a person cannot be asked — the class's own reading on the face the classification records,
* {@link bypassImmuneOn}; another immune class beside it does not make it immune), keeps every immune class and releases the
* rest: the shell face releases that class ({@link RELEASED_ON_SHELL_FACE}), the reference implementation's answer for a
* command whose written target could not be resolved — so on that face an immune class beside it keeps the question;
* `acceptEdits` answers an ORDINARY ask itself on a call the caller vouches is one of the mode's file commands
* (`call.fileCommand`, `accepted`); `plan`, `default` and `auto` hand every ask on (plan's own questions were raised by
* its write gate; the reference implementation refuses nothing at this point under plan — auto's classifier reads the
* row at its own station). Reads the class SET on the face the classification records ({@link bypassImmuneOf}) and the folded
* row's face-free `hookAskFloor` — never the row's `bypassImmune`, never the disclosed word. On a CONFINED Runner (`call.confined`,
* {@link ConfinedCall}) `bypassPermissions` also releases a set that only {@link RELEASED_ON_CONFINED_RUNNER} keeps immune — where no
* person was already required on the question, the call's destination stays on the hands and what the check did not see guards
* nothing — and the release says `confined: true`; every other cell reads as on any Runner.
*/
export declare function arbitrateByMode(mode: PermissionMode, c: AskClassification, disclosure?: {
origin?: AskOrigin;
mandate?: PersistedRuleMandate;
}, call?: {
readonly fileCommand?: boolean;
readonly confined?: ConfinedCall; /** the read station said a target the call writes meets a write-face ask row ({@link WRITE_FACE_ASK_ROW_COUNTS}) */
readonly writeAskRow?: boolean;
}): Arbitration;