UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

438 lines (437 loc) • 44.6 kB
import type { Checkpoint, ProbeCause, StoreFidelity } from "./checkpoint-store.js"; import type { SteerReplayFacet } from "./steer-replay.js"; import type { ConfigRefusalInput } from "./config-refusal-input.js"; import type { UnstartedRowOutcome } from "./terminal-cause.js"; import type { CallRiskAxes } from "./ask-origin.js"; /** True ONLY for a PLAIN data record (not null / array / class-instance / proxy-with-odd-prototype) — the only * shape we safely digest. Adversarial args (a proxy, a getter that throws) must never crash the mint, so this + * {@link safeDataValue}/{@link safeKeys} make {@link buildRiskDescriptor} fully TOTAL. */ export declare function isPlainRecord(x: unknown): x is Record<string, unknown>; /** Read `obj[key]` as a DATA property only — NEVER invokes a getter/accessor (so a throwing getter can't escape * AND a non-deterministic getter can't vary the digest); a trapped descriptor read ⇒ undefined. */ export declare function safeDataValue(obj: Record<string, unknown>, key: string): unknown; /** * The descriptor's `riskAxes` from what the park's mint handed {@link buildRiskDescriptor}: each of the two members only when it * is a boolean (a judged `false` stays), copied — the row is persisted, never aliased to the caller's object — and the whole * member only when one stays. Data-property reads only, so a hostile value can neither throw nor vary. It judges nothing: the * judgment is the projection's (`riskAxesOf`, the card's too), read by the park at its own moment and copied here. */ export declare function copiedRiskAxes(given: unknown): { riskAxes?: CallRiskAxes; }; /** * The ONE validator for a {@link ProbeCause} arriving from a probe. * * The value crosses a trust boundary twice — once at the gate (where a deployment-supplied probe hands * it over) and once at the persist boundary (where {@link buildRiskDescriptor} is an exported function a * caller may reach directly) — so both call it rather than each writing its own idea of "valid". A * malformed cause yields `undefined`: the ASK still stands (the verdict was never this member's to * decide), the card simply carries no account. Fail-closed on the disclosure, never on the gate. * * Every field is re-derived rather than trusted: strings are neutralized and capped individually, the * shown list is clamped, and `total` is coerced to a non-negative integer that cannot understate what is * shown (a `total` below `shown.length` would turn an honest count into a false reassurance). */ export declare function normalizeProbeCause(value: unknown): ProbeCause | undefined; /** * The checkpoint FEATURE TABLE — one row per feature whose presence a row's reader must know about: where it came * from and what a mint owes when the feature is present (`writes`, prose). The row FORMAT is one number, * {@link MAX_SUPPORTED_CHECKPOINT_VERSION} (10, the `requirements` row): every live mint stamps it and lists the row's * reader-requirement words beside it (`Checkpoint.requires`, checkpoint-requirements.ts) — a later segment adds a * word there, never a row here. Each feature key below (but `requirements`) is itself one of those words, and whether * a row carries the feature is read off the row's content by the requirement tables, never off a number. * * A row below the format (an earlier release's, stamped by the highest feature it carried, or with no version at * all) is read by no rule here: the row's judge refuses it as a retired seat (checkpoint-row-verdict.ts) — it stays * pending, nothing is consumed, and the way out is to expire it and run the work again. */ export declare const CHECKPOINT_FEATURES: { /** A `resource_limit` suspend: `resourceLedger` plus a `resource_limit` gate/pendingAction. */ readonly resource: { readonly introduced: "design/74"; readonly writes: "resourceLedger; gate/pendingAction kind resource_limit"; }; /** A HUMAN-DECISION park (tool approval or plan_review): the decision-action binding (`boundCallId` + * `boundInputHash` on a tool_approval) is enforced ENTIRELY by the resuming worker; a tool approval without its * hash is a damaged row (the resume binding rung). */ readonly binding: { readonly introduced: "design/80"; readonly writes: "pendingAction.boundCallId + boundInputHash on a tool_approval; a plan_review carries no binding"; }; /** A ledger carrying a cross-slice TOKEN allocation: the window clamp and the exhausted-resume fail-fast * live in the resuming worker. */ readonly token: { readonly introduced: "design/164"; readonly writes: "resourceLedger.totalTokens"; }; /** Org-memory admission freeze state (the adjudicated-empty record included): the session/delegation * freeze on resume and the tenant-admission door live in the resuming worker. */ readonly orgAdmission: { readonly introduced: "org-admission"; readonly writes: "inheritedGate.admittedOrgScopes / ownAdmittedOrgScopes / ownAdmittedOrgWriteScope / orgAdmissionGoverned"; }; /** The F-012 durable enforcement fields: the frozen ancestor projection chain + its digest (one write, the * resume-edit re-adjudication executes it) and/or the delegation-provenance aggregate a resume re-seeds. */ readonly f012: { readonly introduced: "F-012"; readonly writes: "inheritedGate.constraintChain + constraintDigest together; delegationProvenance"; }; /** A gate carrying {@link RealApprovalGateBit}: the no-org-wiring refusal and the org_unavailable resume * belt live in the resuming worker. Minted at ONE site (the approval park); the two always-mounted * integrity policies mint it on any durable deployment, org-governed or not. */ readonly realApproval: { readonly introduced: "#130/#120"; readonly writes: "gate.realApproval (a well-formed bit) + pendingAction.requiresRealApproval; readFace.realApproval = true beside it"; }; /** The READ-face section ({@link CheckpointState.readFace}): resolved face + normalized deny-set additions, * written only for a non-default posture; the stricter-wins fold lives in the resuming worker. Carries the * redundant governance marker for `realApproval`. Absent ⇒ default posture. */ readonly face: { readonly introduced: "design/199"; readonly writes: "state.readFace { face, denyEntries? } for a non-default posture; realApproval: true only at the mint whose gate carries the bit (a hands-less re-park never carries the seed's marker forward)"; }; /** The frame: the reader-requirement words ({@link CheckpointRow.requires}) and the row digest. Every live mint * writes them at the row format, so a worker of v7.24.2–7.48.x (ceiling 9) refuses every row minted since, * `version_newer`, pre-CAS. */ readonly requirements: { readonly introduced: "#1320"; readonly writes: "requires (the row's words) + requirementsDigest (the row digest), both derived from its content (checkpoint-requirements.ts)"; }; }; /** One row of {@link CHECKPOINT_FEATURES}. */ export interface CheckpointFeatureRow { /** Where the feature came from — a design or ticket tag, documentation only. */ readonly introduced: string; /** What a mint writes when the feature is present (prose; the mint sites are the code). */ readonly writes: string; } /** The feature words — the row keys of {@link CHECKPOINT_FEATURES}. */ export type CheckpointFeature = keyof typeof CHECKPOINT_FEATURES; /** The checkpoint row FORMAT — the one {@link Checkpoint.version} this engine reads, and the stamp of every live mint * (frozen: a later segment adds a reader-requirement word, never a number). A higher one is rejected pre-CAS with * {@link CheckpointError} `unsupported_version` / `version_newer` (the row stays `pending`, retryable on a newer worker); * a lower one with `unsupported_version` / `seat_retired` (the row stays `pending`; expire it and run the work again). */ export declare const MAX_SUPPORTED_CHECKPOINT_VERSION = 10; /** * Read a checkpoint's schema version, defaulting an absent field to **`0`** (a row written before the field * existed — below the format, so its judge refuses it as a retired seat). */ export declare function checkpointVersionOf(cp: Pick<Checkpoint, "version">): number; /** * WHICH arm of a multi-arm {@link CheckpointError} `code` fired (requested 2026-08-10: a deployment retry * policy needs to tell "a newer worker can redeem this row" from "this row is damaged/caller-declared and * no worker ever will" — blanket-retriable and gate-shape heuristics were both refuted downstream, so the * throw site carries the fact it always knew). * * A CLOSED SET with one home, registered in `docs/CLOSED-SETS.md`. It is carried in an OPTIONAL member, so * the compiler is silent when a throw site omits it, and a site that omits it hands the host a refusal it * cannot classify — the registry's mint-obligation leg is what makes the omission loud (every * `checkpoint.unsupported_version` construction site must spell one of these words AT the site). * * · `unsupported_version` arms: `"version_newer"` (the row's format is newer than this worker's, or it lists a * reader-requirement word this worker lacks — `detail.requires` names those words — retryable on a newer * worker), `"env_factory_missing"` (retryable on a factory-wired worker), * `"governed_unwired"` (retryable on an org-wired worker), `"origin_missing"` (a pending approval row * minted before the ask's origin was persisted on the park — terminal for the row's bytes; the host * decides the orphaned card itself, no worker version redeems it), `"tool_identity_missing"` (a pending approval row * whose tool member is not whole — parked before 7.58.0 recorded the declaration, or damaged: an allow is refused, a deny * settles it; a worker of the release that parked it still reads it), `"ledger_event_unknown"` (a durable * LEDGER carries an event kind this binary does not know, so the replay is refused rather than served * incomplete — the one arm that is not row-scoped: NO row in that data directory is readable here, so * the host rolls the binary forward instead of routing one token elsewhere), `"seat_retired"` (the row * carries a seat this engine no longer reads — terminal for the row's bytes: the retired pre-queue single * steer seat, which no worker version reads and the host decides itself, a retired mode-seed member of * `inheritedGate`, which an engine at 7.38.x or earlier still reads once, or a row below the format, which an * earlier engine read by its number — expire it and run the work again), `"leg_not_resumable"` (a row a synchronous child * parked under an earlier release — it carries the synchronous-child block — whose leg nobody resumes: its result has no road back to * the run that spawned it; terminal for the row's bytes on every worker of this release — expire it and run the work again), * `"reading_changed"` (the row is intact and an earlier release parked it, reading part of it the way this release no longer * does — a member a decision binds, which reads as written under the earlier reading the requirement tables record; or its * frozen inherited constraint chain, which matches its digest under the earlier projection meaning that digest's prefix names). * · `invalid_outcome` pre-CAS row-integrity arms: `"real_approval_damaged"`, * `"read_face_damaged"`, `"write_face_damaged"`, `"skill_grants_damaged"`, `"skill_scopes_damaged"`, `"constraint_chain_missing"`, `"hands_coordinates_damaged"`, `"requirements_damaged"`, `"execution_recorded"`, `"bound_input_hash_missing"`. * Whether ANY release still resumes a row its judge refuses is not restated per word here: it is the row judge's one table * (`checkpoint-row-verdict.ts`, read as the verdict's `terminal`), beside the refusal's fixed sentence. * * THE ONE RULE for `checkpoint.invalid_outcome` (registered in `docs/CLOSED-SETS.md`, which also says what a host reads from it): `detail.reason` is a * ROW-INTEGRITY word and only that, `detail.field` ({@link CheckpointErrorField}) names the cell of the decision to act on, a refusal carries at most * one of them, and a refusal with neither is never a damaged row. */ export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "governed_unwired" | "origin_missing" | "tool_identity_missing" | "ledger_event_unknown" | "seat_retired" | "leg_not_resumable" /** An intact row an earlier release parked, which this release reads differently: the input hash of a tool approval parked before * 7.63.0, or a member whose earlier reading the requirement tables record (`EarlierReading`) and the row's content cannot show * agrees with this release's. */ | "reading_changed" | "real_approval_damaged" | "read_face_damaged" /** `state.writeFace` is present but not a well-formed section (legal and absent on any row, so "missing" is never * damage — and a fabricated "open" still needs the LIVE resolution to say open too). */ | "write_face_damaged" | "skill_grants_damaged" /** `state.skillScopes` is present but not a list of skill names (the active skills whose hooks the resumed leg reopens). */ | "skill_scopes_damaged" | "constraint_chain_missing" /** `state.handsRoot` / `state.handsHome` / `state.handsCwd` is present but not an absolute path (the row's hands' coordinates). */ | "hands_coordinates_damaged" /** The row's content does not read the way it was recorded when it was parked: its reader-requirement list * ({@link CheckpointRow.requires}) is missing, is not a list of words, or does not equal * the words the row's content carries, or its digest does not equal its content's — and no earlier reading the requirement * tables record explains it (that is `reading_changed`); a member the shape table refuses; a row its judge cannot read. */ | "requirements_damaged" /** A row that reads `pending` yet records what became of its decided action (`executionOutcome`): the decision before it was lost * in storage AFTER the action was taken up, so — unlike every other damaged row — the action may already have run or been refused. * Terminal for the row's bytes; its sentence says to check the recorded outcome before running the work again. */ | "execution_recorded" /** A pending tool approval that carries no persisted `boundInputHash` — every mint writes one, so its absence is corruption or a * caller-declared downgrade, and the decision-action input binding has nothing to bind to. Terminal for the row's bytes. */ | "bound_input_hash_missing" /** On `resume.parent_constraint_mismatch`: a re-supplied chain entry whose path rules depend on the leg that installed it has * no installation record (a chain written before the record existed) / a record that does not cover the chain entry for * entry / a record member naming no absolute root. */ | "installation_record_absent" | "installation_record_misaligned" | "installation_record_invalid" /** On `resume.parent_constraint_mismatch` — its other three causes: the chain the resume runs under is not the one the row * recorded (`"constraint_changed"`: another layer count, or a layer whose facts or frozen deny data differ — hand back the chain * as it was at the park, or deny the card); the row's own recorded chain does not match the digest it records * (`"constraint_chain_damaged"`: the row is damaged — expire it); the chain could not be judged (`"constraint_unjudgeable"`: an * entry that is neither one caller policy nor one installation, or a judgment that threw — the host checks the chain it hands). * Every refusal the engine answers on the code names one of its six causes. */ | "constraint_changed" | "constraint_chain_damaged" | "constraint_unjudgeable" /** On `checkpoint.config_refused` with `detail.code` `config.tool_face_control` — the arm prepare's own refusal carries as its `detail.reason`: * a tool-name list the row recorded is not a list / has a member that is not a string / has a spelling no tool name can have / is not in * the one spelling a row records (`"not_a_list"`, `"not_a_string"`, `"unknown_name"`, `"unsupported_pattern"`; the re-supplied config's own four lists — * `allowTools`, `excludeTools`, `deferTools`, `alwaysLoadTools` — are refused as `"not_a_list"` / `"not_a_string"`, and its whole-face switch `excludeAllTools` when it is not a boolean as `"not_a_boolean"`); the record of the delegation tool that * wrote the leg's lists is not one (`"invalid_record"`); the roster the resume hands mounts a delegation tool under another name than it declares * (`"renamed_mount"`); the process-wide table of declared names is occupied by a value that is not the engine's (`"registry_occupied"`). */ | "not_a_list" | "not_a_string" | "not_a_boolean" | "unknown_name" | "unsupported_pattern" | "invalid_record" | "renamed_mount" | "registry_occupied" /** On `config.unknown_role` (a fresh run's terminal `detail.detail.reason`; on a resume, `detail.reason` of `checkpoint.config_refused` with `detail.code` `config.unknown_role`) * — a model binding or a role word the engine cannot read: a word the model catalog does not hold (`"unknown_model_ref"`), a value that is * no model reference at all — a number, a boolean, a list (`"not_a_model_ref"`), or a role word outside the vocabulary — a `roles` key, a `modelRole` value (`"unknown_role_word"`) — or a task naming no model whose requested role and fallback chain supply none (`"no_model_for_role"`, `field` the requested role's seat). The sentence names the seat the refusal's `field` names (`roles.consolidate`, `tiers.pro`, `TaskSpec.model`). */ | "unknown_model_ref" | "not_a_model_ref" | "unknown_role_word" | "no_model_for_role" /** On `resume.composition_mismatch` — the two arms of the one code: `"live_leg_contradicts_row"` (a resume handed a composition leg that * differs from the one the row recorded: the composition's resume entry was handed another card's identity; the row stays pending, * re-resume with the recorded value or none) and `"not_a_verifier_card"` (`Runner.voidVerifierPause` was handed a card whose recorded * leg is not a verification gate's `verify` leg, or records none: nothing was settled, the row is as it was). */ | "live_leg_contradicts_row" | "not_a_verifier_card" /** On `resume.agent_definition_mismatch` — the two arms of the one code, both pre-CAS with the row `pending`: `"live_lists_contradict_row"` * (the delegation lane resolved the parked agent's name to a definition whose own tool lists digest differently from the lists the row * recorded — another definition wears the name now) and `"row_records_no_lists"` (the delegation lane handed a live record but the row * records no readable digest of its own lists — a row parked before the record existed, or one whose record cannot be read). */ | "live_lists_contradict_row" | "row_records_no_lists"; /** * The codes a RESUME's pre-claim configuration screen carries as `detail.code` of a `checkpoint.config_refused` — the words prepare's * doors throw, held unchanged so one refusal reads the same on a fresh run (`TaskResult.errorCode`) and on a resume: the mode, output-style, language, * approval-reach, invoked-skill, attachment, recorded-mode and tool-face doors (`config.spec_retired_key` … `config.tool_face_control`, the first * ten — `detail.reason` names the tool-face arm: {@link CheckpointErrorReason}), and every value door of the config-door phase over the * re-supplied config and the deployment's deps (`configValueDoors`, the rest): the retired deps seats and caller-policy members * (`config.deps_retired_key`), the peer presence, the restore selector, the microCompact knob, the prompt selectors, `resumeAt` on a resume * (`resume_at.conflicts_resume`, `resume_at.mode_without_target` — a resume carrying `resumeAt` is refused as a conflict before its mode is * read, so `resume_at.invalid_mode` is a fresh run's word only), the containment faces, the add-only seats and the MCP / A2A `toolAxes` (`config.invalid_argument`), an MCP server's `toolFaces` (`config.tool_face_invalid`), the three memory seats, the cross-boundary posture, the advisor switch and the advisor model's shape, * the auto-consolidation arming (its role key too, and the role seats and tier bindings it reads: `config.unknown_role`, `detail.reason` naming the arm), the materialize strategy and persistence flag, the lock layer (`config.locked_registry`, * `config.locked_key`), an MCP server's content class, the skills-listing seats (`config.skill_listing_budget_invalid`), the limits and the * resource-suspend knobs, the attachment modes, the governance windows, the brain-call guardrail, the host floor (`config.host_floor_invalid`) and the retention declaration over the stores the leg * would run on (`config.retention_policy`, `config.retention_capability`), and the checkpoint store seat itself (`config.invalid_checkpoint_store`: the * retired `null` spelling, a store without a required verb, a grant holder over a store that does not judge it), the session store seat's holder * door (`config.invalid_session_store`: a holder over a session store that does not declare the fence, a `requireHolder` store and a host * resume without a holder, a declaration the seat refuses), and the skills seat and the hands band (`config.invalid_argument`; * a skill's `baseDir` by its own reader, `config.skill_base_dir_invalid`), and the value arms of three doors whose other arms need the leg: * the interaction posture's word and its contradiction with `interactiveTools: false` (`config.interaction_posture`), the requested role's * word (`config.unknown_role`, `detail.reason` `unknown_role_word`), and per-task agents beside a roster the receipt reads whole that mounts no * delegation tool (`config.agents.no_delegation_tool`). A door not entered here (the leg's model, its rebuilt * roster, its answer face, the approval seat's value, whether the posture's human is reachable) still refuses after the claim, each for a stated reason (INTEGRATION-CORE, "A resume's two doors"). * The re-supplied config's one read (`readCallerSpec`, the read a run takes of its spec) refuses with its own two words, last in the set: * a member whose read throws (`config.spec_member_unreadable`) and a key the engine does not read (`config.spec_unknown_key`); its third, * a retired key, is `config.spec_retired_key` (first); the project seat it screens refuses as `config.invalid_argument` or, for an `id` that * is no UUID, `config.project_id_invalid` (last). * * A SUBSET of {@link CONFIG_REFUSAL_CODES}, the family's whole refusal vocabulary: the words a resume's screen can produce, held to that set at compile time. */ export declare const CHECKPOINT_CONFIG_REFUSAL_CODES: readonly ["config.spec_retired_key", "config.output_style_invalid", "config.language_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.run_origin_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.invalid_session_store", "config.skill_base_dir_invalid", "config.host_floor_invalid", "config.credential_in_declaration", "config.credential_ref_invalid", "config.peer_seat_missing", "config.interaction_posture", "config.agents.no_delegation_tool", "config.spec_member_unreadable", "config.spec_unknown_key", "config.agent_config_dir_invalid", "config.agent_home_dir_invalid", "config.project_id_invalid"]; export type CheckpointConfigRefusalCode = (typeof CHECKPOINT_CONFIG_REFUSAL_CODES)[number]; export declare const isCheckpointConfigRefusalCode: (word: unknown) => word is CheckpointConfigRefusalCode; /** The words of a {@link CheckpointError}'s optional `detail.field` (what each means: the `detail` member's doc). A CLOSED SET with one home, registered in * `docs/CLOSED-SETS.md`: a consumer holding a table over it is tsc-red on a new word until it places the word. */ export type CheckpointErrorField = "boundCallId" | "boundInputHash" | "boundGrantDigest" | "answer" | "hostDecision" | "approver" | "feedback" | "outcome" | "updatedInput" | "decision" | "reason" | ConfigRefusalInput | "rootPolicy"; /** * The words of a {@link CheckpointError}'s optional `detail.settler` — who settled the row when the deployment's `resumePreflight` ruled * a resume PERMANENTLY blocked (its `terminal` verdict). The member is present on exactly those three arms of `resume.preflight_rejected` * and absent on its retry-later arms (a deadline, a throw, an unreadable or plain refusal answer), so a host reads the settlement off the * word instead of off the sentence. A CLOSED SET with one home, registered in `docs/CLOSED-SETS.md`: a consumer holding a table over it is * tsc-red on a new word until it places the word. * * · `"this_refusal"` — this refusal's own single-shot expire settled the row (`expired`): the token is not redeemable; * · `"concurrent_actor"` — the expire lost its race and the live row is no longer `pending`: another actor had already settled it, nothing was * settled by this refusal, and the token is consumed; * · `"nobody"` — the expire lost its race but the live row is `pending` again (a concurrent resolve / reopen cycle moved it): nothing was settled * and the same token is redeemable once more — re-resume against the current state. */ export type ResumePreflightSettler = "this_refusal" | "concurrent_actor" | "nobody"; /** * Every code a {@link CheckpointError} carries — the frozen runtime set the type {@link CheckpointErrorCode} is derived from, root-exported * so a host that mirrors these codes word for word can check its table against the engine's at run time. A CLOSED SET with one home, * registered in `docs/CLOSED-SETS.md`. What each code means is written on its entry below. The codes a retained child's resume handle * rejects with (`Error.code`, minted outside this class) are their own set, {@link SPAWN_RESUME_REFUSAL_CODES}. */ export declare const CHECKPOINT_ERROR_CODES: readonly ["checkpoint.already_exists", "checkpoint.already_resolved", "checkpoint.not_found", "checkpoint.gate_mismatch", "checkpoint.resume_aborted", "checkpoint.invalid_outcome", "checkpoint.unsupported_version", "checkpoint.config_refused", "checkpoint.cwd_conflicts_restore", "checkpoint.walltime_axis_retired", "checkpoint.reopen_revote", "checkpoint.reopened_concurrently", "checkpoint.reopen_failed", "checkpoint.void_unpin_failed", "checkpoint.execution_outcome_conflict", "steering.invalid_content", "steering.queue_full", "steering.duplicate_input_id", "steering.blocked_by_hook", "wake.gate_pending", "wake.nothing_to_deliver", "resume.parent_constraint_missing", "resume.parent_constraint_mismatch", "resume.parent_constraint_unrebuildable", "resume.usage_window_exhausted", "resume.principal_mismatch", "resume.isolation_scope_mismatch", "resume.placement_mismatch", "resume.composition_mismatch", "resume.agent_definition_mismatch", "resume.preflight_rejected", "resume.constraint_rejected", "resume.constraint_unprojectable"]; /** The code of a {@link CheckpointError} — derived from {@link CHECKPOINT_ERROR_CODES}, its one home. */ export type CheckpointErrorCode = (typeof CHECKPOINT_ERROR_CODES)[number]; export declare const isCheckpointErrorCode: (word: unknown) => word is CheckpointErrorCode; /** * The codes a retained child's resume handle (`SpawnHandle.resume`) rejects with — an `Error.code` the delegation tool mints, not a * {@link CheckpointError}: `steering.still_running` (the child, or a prior resume of it, still runs: steer it or wait), `resume.retain_off` * (the parent run did not retain this child), `resume.evicted` (the retained session was evicted — its TTL, the retain bound, or the * parent run's end), `resume.session_not_found` (the retained session is gone from the store, or holds no committed history), * `resume.row_recycling` (the agent's durable row is being adjudicated by a revival claim or a reap sweep: send again in a moment) and * `resume.row_gone` (the agent's durable row no longer exists: relaunch). A CLOSED SET with one home, registered in `docs/CLOSED-SETS.md`; * the delegation tool's mint takes its word from this type. */ export declare const SPAWN_RESUME_REFUSAL_CODES: readonly ["steering.still_running", "resume.retain_off", "resume.evicted", "resume.session_not_found", "resume.row_recycling", "resume.row_gone"]; export type SpawnResumeRefusalCode = (typeof SPAWN_RESUME_REFUSAL_CODES)[number]; /** A typed checkpoint-store error so callers branch on `code` (mirrors `SessionError`); the codes are {@link CHECKPOINT_ERROR_CODES}. */ export declare class CheckpointError extends Error { readonly code: CheckpointErrorCode; /** Structured discrimination a caller can branch on where the code alone is ambiguous. `field` * names WHICH part of the decision payload was rejected on a * `checkpoint.invalid_outcome` — `"boundCallId"` (the action you decided on has been replaced: * re-fetch the pending list), `"boundInputHash"` (the input you reviewed has changed under the same * action: re-review), `"boundGrantDigest"` (a parked `Skill` approval does not cover the skill the decision selects — another skill, or the card's with other lists: deny, re-activate), or `"answer"` (the content-ask answer is missing, or was attached to a * decision that cannot carry one: re-decide with a well-formed answer — ruled 2026-08-04), or * `"hostDecision"` (a tool approval's or a plan pause's decision facts are missing, name a decider outside * `person`/`sla_timeout`/`policy`, pair the sweep's `sla_timeout` with an allow or put it on a row a sweep does not * resolve, or try to supply the minted record), or — design/252 G-7 — `"approver"` (the attribution is not a * well-formed identifier: re-decide with a plain, bounded, control-character-free string, or omit * it), or `"feedback"` (the allow's `feedback` is not fit to deliver — it carries the engine's `<system-reminder>` tag, is not a string, rides a deny, * or rides a decide a machine made: re-decide with the words changed or dropped; the binding did not change), or — an approval decide's own * payload — `"outcome"` (the resume's outcome is not an object naming its gate: send one), `"updatedInput"` (the person's edit is not plain JSON data the * engine can capture: re-decide with a plain edit, or without one), `"decision"` (the verdict word is neither `allow` nor `deny`) or `"reason"` (the deny's * words are not a plain string, or carry the engine's `<system-reminder>` tag: change or drop them; the binding did not change). On a `checkpoint.config_refused` `field` names which INPUT carries the refusal — `"taskConfig"` * (the re-supplied config: correct it and resume the same token), `"deps"` (the deployment's own seat — and the policies the * caller re-supplies as inherited constraints: correct them and resume the same token) or `"inheritedGate"` (the row's record: no config reaches it; expire the row). The throw * sites always knew which arm fired; this carries that fact instead of dropping it (ruled * 2026-08-03, cross-repo HITL discussion). Additive and optional — `code` remains the only REQUIRED * discriminant. */ readonly detail?: { field?: CheckpointErrorField; /** On `checkpoint.config_refused` — prepare's own code for the refusal ({@link CheckpointConfigRefusalCode}), the * word a fresh run of the same bad config reports as its `errorCode`. Absent on every other code. */ code?: CheckpointConfigRefusalCode; /** #449 G1 — on `resume.usage_window_exhausted`: how long until the binding window frees * (the same wait a suspended row carries as `gate.resumeAfterMs`). design/380 O2 — on a * retry-later `resume.preflight_rejected`: the deployment preflight's own wait hint, when it * gave one (same carrier, same semantics: retry the SAME token after the wait). Absent on * every other code. */ retryAfterMs?: number; /** WHICH arm fired, where one `code` covers several — the word list and what each word means to a * host live at {@link CheckpointErrorReason}, its one home. Additive and optional like `field` * (`code` remains the only REQUIRED discriminant), which is exactly why the obligation to SPELL it * is a gate rather than a type: see the closed set's own doc. */ reason?: CheckpointErrorReason; /** On the permanent arms of `resume.preflight_rejected` (the deployment's `terminal` verdict) — who settled the row ({@link ResumePreflightSettler}). * Absent on every retry-later arm of that code and on every other code. */ settler?: ResumePreflightSettler; /** On a resume aborted after its claim and before its leg started, where the engine reversed the claim — what became of the * row ({@link UnstartedRowOutcome}, the word a failed result states as `terminal.unstartedRow`): `"reopened"` on * `checkpoint.resume_aborted`, `"declined"` / `"unknown"` on `checkpoint.reopen_failed`. The message's sentence is derived * from the word; branch on the word. Absent on every other code and on every other arm of `checkpoint.resume_aborted` (an abort * before the claim, the row untouched; an abort after the row's park was claimed, the row consumed — the code alone does not say which). */ unstartedRow?: UnstartedRowOutcome; /** On a `version_newer` refusal of a v10 row: the reader-requirement words the row lists that this worker lacks * (sorted, display only). Absent on every other arm. */ requires?: readonly string[]; /** On a `requirements_damaged` refusal of a row its judge could not read at all (a member that throws when read, a * container that is not one): the name of what was thrown while judging it (bounded; never its message). Its presence * tells an engine defect from a row whose content does not match what it says. Absent on every other refusal. */ thrownName?: string; /** On `steering.duplicate_input_id` — the facets the repeat differs from the parked steer in (closed * {@link SteerReplayFacet}, in that set's order; always present on that code, never empty). Absent on * every other code. The live verb's refusal carries the same value. */ differs?: readonly SteerReplayFacet[]; /** On `resume.constraint_rejected` ⇔ the resume-edit policy accepts the person's edit only rewritten: `acceptableForm` * is that form, the outlet a host may offer; a decide carrying it as `updatedInput` runs exactly those bytes. */ editRewritten?: import("./rewrite-rejudge.js").EditRewritten; } | undefined; constructor(code: CheckpointErrorCode, message: string, /** Structured discrimination a caller can branch on where the code alone is ambiguous. `field` * names WHICH part of the decision payload was rejected on a * `checkpoint.invalid_outcome` — `"boundCallId"` (the action you decided on has been replaced: * re-fetch the pending list), `"boundInputHash"` (the input you reviewed has changed under the same * action: re-review), `"boundGrantDigest"` (a parked `Skill` approval does not cover the skill the decision selects — another skill, or the card's with other lists: deny, re-activate), or `"answer"` (the content-ask answer is missing, or was attached to a * decision that cannot carry one: re-decide with a well-formed answer — ruled 2026-08-04), or * `"hostDecision"` (a tool approval's or a plan pause's decision facts are missing, name a decider outside * `person`/`sla_timeout`/`policy`, pair the sweep's `sla_timeout` with an allow or put it on a row a sweep does not * resolve, or try to supply the minted record), or — design/252 G-7 — `"approver"` (the attribution is not a * well-formed identifier: re-decide with a plain, bounded, control-character-free string, or omit * it), or `"feedback"` (the allow's `feedback` is not fit to deliver — it carries the engine's `<system-reminder>` tag, is not a string, rides a deny, * or rides a decide a machine made: re-decide with the words changed or dropped; the binding did not change), or — an approval decide's own * payload — `"outcome"` (the resume's outcome is not an object naming its gate: send one), `"updatedInput"` (the person's edit is not plain JSON data the * engine can capture: re-decide with a plain edit, or without one), `"decision"` (the verdict word is neither `allow` nor `deny`) or `"reason"` (the deny's * words are not a plain string, or carry the engine's `<system-reminder>` tag: change or drop them; the binding did not change). On a `checkpoint.config_refused` `field` names which INPUT carries the refusal — `"taskConfig"` * (the re-supplied config: correct it and resume the same token), `"deps"` (the deployment's own seat — and the policies the * caller re-supplies as inherited constraints: correct them and resume the same token) or `"inheritedGate"` (the row's record: no config reaches it; expire the row). The throw * sites always knew which arm fired; this carries that fact instead of dropping it (ruled * 2026-08-03, cross-repo HITL discussion). Additive and optional — `code` remains the only REQUIRED * discriminant. */ detail?: { field?: CheckpointErrorField; /** On `checkpoint.config_refused` — prepare's own code for the refusal ({@link CheckpointConfigRefusalCode}), the * word a fresh run of the same bad config reports as its `errorCode`. Absent on every other code. */ code?: CheckpointConfigRefusalCode; /** #449 G1 — on `resume.usage_window_exhausted`: how long until the binding window frees * (the same wait a suspended row carries as `gate.resumeAfterMs`). design/380 O2 — on a * retry-later `resume.preflight_rejected`: the deployment preflight's own wait hint, when it * gave one (same carrier, same semantics: retry the SAME token after the wait). Absent on * every other code. */ retryAfterMs?: number; /** WHICH arm fired, where one `code` covers several — the word list and what each word means to a * host live at {@link CheckpointErrorReason}, its one home. Additive and optional like `field` * (`code` remains the only REQUIRED discriminant), which is exactly why the obligation to SPELL it * is a gate rather than a type: see the closed set's own doc. */ reason?: CheckpointErrorReason; /** On the permanent arms of `resume.preflight_rejected` (the deployment's `terminal` verdict) — who settled the row ({@link ResumePreflightSettler}). * Absent on every retry-later arm of that code and on every other code. */ settler?: ResumePreflightSettler; /** On a resume aborted after its claim and before its leg started, where the engine reversed the claim — what became of the * row ({@link UnstartedRowOutcome}, the word a failed result states as `terminal.unstartedRow`): `"reopened"` on * `checkpoint.resume_aborted`, `"declined"` / `"unknown"` on `checkpoint.reopen_failed`. The message's sentence is derived * from the word; branch on the word. Absent on every other code and on every other arm of `checkpoint.resume_aborted` (an abort * before the claim, the row untouched; an abort after the row's park was claimed, the row consumed — the code alone does not say which). */ unstartedRow?: UnstartedRowOutcome; /** On a `version_newer` refusal of a v10 row: the reader-requirement words the row lists that this worker lacks * (sorted, display only). Absent on every other arm. */ requires?: readonly string[]; /** On a `requirements_damaged` refusal of a row its judge could not read at all (a member that throws when read, a * container that is not one): the name of what was thrown while judging it (bounded; never its message). Its presence * tells an engine defect from a row whose content does not match what it says. Absent on every other refusal. */ thrownName?: string; /** On `steering.duplicate_input_id` — the facets the repeat differs from the parked steer in (closed * {@link SteerReplayFacet}, in that set's order; always present on that code, never empty). Absent on * every other code. The live verb's refusal carries the same value. */ differs?: readonly SteerReplayFacet[]; /** On `resume.constraint_rejected` ⇔ the resume-edit policy accepts the person's edit only rewritten: `acceptableForm` * is that form, the outlet a host may offer; a decide carrying it as `updatedInput` runs exactly those bytes. */ editRewritten?: import("./rewrite-rejudge.js").EditRewritten; } | undefined); } /** THE copy mint: a second throw of an existing refusal — a new `CheckpointError` with the instance's own code, message, detail and * `cause` (with `reason` given, `detail.reason` is that word). Its code is one the instance's mint was judged for, so this is the one * construction `gate:closed-sets` reads with a code it does not spell (scripts/verify-closed-sets.mjs `COPY_MINT`); a construction * anywhere else still spells its code. The instance may be a host's (the class is exported): its message, its detail's members and * its `cause` are each read once under a guard, and one that throws when read is not carried — the copy keeps the code, never the * host's failure. */ export declare function copyOfCheckpointError(refusal: CheckpointError, reason?: CheckpointErrorReason): CheckpointError; /** * Project an already-captured value onto what a backend of the given {@link StoreFidelity} can hold, so * everything minted from it — the row's args, the approval preview, the binding hash, the risk * descriptor — describes the value that comes BACK, not the one that went in. * * `"structured-clone"` is the identity: the caller's snapshot already is what such a backend stores. * `"json"` runs the backend's own codec (`JSON.stringify` → `JSON.parse`, `toJSON` hooks included, since * that is exactly what the backend will do to it). The input is expected to be an accessor-free snapshot * already, so no property is read a second time here. * * A value JSON cannot ENCODE AT ALL (a `BigInt`, a cycle) fails instead of degrading — those would throw * inside the backend's own write anyway, and failing here means the caller can say why while nothing has * been committed. The thrown value rides out on `cause` so the caller decides how to word the refusal. */ export declare function encodeAtFidelity(fidelity: StoreFidelity, value: unknown): { ok: true; value: unknown; } | { ok: false; cause: unknown; };