UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

56 lines (55 loc) • 5.06 kB
/** * The resume ladder's CHECKPOINT SCREEN (E5) and its abort / workspace-handle / inherited- * constraint rungs (E6), verbatim from `Runner.resumeStream`: the rungs a deployment fact or a resume input decides — the * org-governance wiring check, the already-aborted signal, the remote-handle factory requirement, the requestedCwd conflict, * the row's recorded ceiling and own lists (each when the leg runs under it), a renamed delegation mount, the parent-constraint * count / content / installation checks, and the array-level snapshot of the validated chain. The rungs the row and the engine * decide alone are the row's verdict, judged at admission (`judgeCheckpointRow`). * Synchronous; every refusal is pre-CAS — thrown, except the chain's, which is returned for the ladder to throw after the * run's identity rungs. */ import { type Checkpoint, CheckpointError } from "../checkpoint-store.js"; import type { InheritedGate, RunInternals, RunnerDepsSeat } from "./contracts.js"; export interface ResumeCheckpointScreenInput { /** borrowed-readonly — the pending row; every invariant is judged on its persisted fields. */ cp: Checkpoint; /** borrowed-readonly — the ONE signal read from admission; `.aborted` is read live here. */ resumeSignal: AbortSignal | undefined; /** borrowed-readonly — the internals snapshot (the re-supplied chain, the requested cwd). */ internals: RunInternals | undefined; /** borrowed-readonly — the roster the resume hands (`ResumeTaskConfig.tools`), as the caller mounts it. */ tools: unknown; /** borrowed-readonly — the chain's refusal admission deferred (`ResumeAdmissionResult.chainRefusal`), returned by the chain rung (3). */ chainRefusal: CheckpointError | undefined; /** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (reads `permissionRuleStore` and `executionEnvFactory`); the one home of why it is a * seat and not a captured object is {@link RunnerDepsSeat}. */ runner: RunnerDepsSeat; } export interface ResumeCheckpointScreenResult { /** The internals the resumed leg is handed: the validated chain frozen at the array level (entries by reference). */ resumeInternals: RunInternals | undefined; /** The chain's refusal, for the ladder to throw after the run's identity rungs (`thrownChainRefusal`, chain-refusal-throw.ts). */ chainRung?: CheckpointError; } export declare function resumeCheckpointScreen(input: ResumeCheckpointScreenInput): ResumeCheckpointScreenResult; /** * Whether the parent-constraint chain `supplied` may drive the row whose state is `state` — the resume screen's rungs * (3)–(3c), pure: `undefined` = it may; otherwise the refusal (built, not thrown) the screen throws pre-CAS. A workflow * park's continuation asks the same question of the chain it would hand the parked child, before anything starts. * * (3) the suspended task ran under inherited OPAQUE parent-policy constraints (live ToolPolicy/onAsk closures — they * cannot persist; the checkpoint records only `requiresParentConstraint`). Resuming without them would silently DROP * the ancestors' gate — a WIDENING, the exact thing the inheritance seam forbids — so the resume is refused (the * checkpoint stays `pending`) until the caller re-supplies the chain. `requiresParentConstraint: false` / an absent * `inheritedGate` (a task that inherited nothing, incl. every pre-seam checkpoint) resumes as before. * (3b) the re-supplied chain must have the SAME length the suspend recorded — a partial re-supply would run the resumed * leg under a thinner (or different) ancestor chain. Older checkpoints (no recorded count) keep only the check above. * (3c) F-012 L1 — the re-supplied chain's projections must digest to the recorded value (the count alone accepted a same-length * chain of DIFFERENT policies). A layer that projects no component (opaque, or empty with a live remainder) is judged live, whole * — swapping its live rules still passes (nothing content-addressable to compare; the live-resupply trust contract governs those * layers); layers are compared position by position, so a change in the number of layers, a layer's kind or facts, or a projected * component refuses, while swapping two non-projecting layers whose facts are the same is the same chain. The same mint body the * park used, with the arming carry taken from the ROW (`constraintChainEntryOfSuppliedLayer`, positional against the persisted * chain the row's verdict validated): a row that recorded a recipe must have it handed back; one value in its two spellings is one * value (`inRecordedSpelling`). PRE-F-012 checkpoints (no digest) keep the count-only contract — and only they do. An earlier meaning: `reading_changed`. */ export declare function parentConstraintChainVerdict(state: Pick<Checkpoint["state"], "inheritedGate">, supplied: InheritedGate["parentConstraints"] | undefined): CheckpointError | undefined;