import type { CompositionLeg, RunInternals } from "./contracts.js";
import type { CheckpointState } from "../checkpoint-store.js";
/**
 * The SINGLE derivation of a durable-suspend checkpoint's scope — the LEG's scope, computed once per prepare and
 * read by every mint lane of that leg (approval park, resource and `plan_review` parks, the forceDurableGate
 * synthesis) and by its children; a re-derived copy that drifted was the exact bug the park tests caught (expire
 * against the wrong scope silently no-ops). `seat` is the scope the leg was already given: on a spawn lane the
 * PARENT leg's (`RunInternals.checkpointScope`) — a child's rows land where its parent's do, which the child's own
 * spec cannot say, since the synchronous lane does not carry the parent's `durableApproval` (it would also arm the
 * child's plain asks to park); on a resume that hands no seat, the leg's own recorded scope
 * (`CheckpointState.legScope`), so the resume config cannot move it. The seat moves the scope and nothing else. A
 * root leg's first prepare has no seat.
 *
 * `||` on EVERY rung (not `??`): a blank string — a config-centre / env lookup that came back empty is the
 * realistic source — is the absence of an isolation key wearing its clothes. Kept as a literal `""` it would be
 * one bucket for every tenant that hit it: `listByScope("")` reads all their pending approvals (with each
 * summary's `toolInput` preview) and `reap("")` / `resolve(token, "")` act across all of them.
 *
 * The last rung is the task's scope key ({@link scopeKeyOf}: its ISOLATION SCOPE — its `isolationScope`, else its principal): a parked
 * row is working state of one scope of a person's work, so two scopes of one person never share a bucket. A task that sets an
 * isolation scope may only declare a `durableApproval.scope` equal to it (the config door), so the rung above it cannot split them.
 * A `durableApproval` that is there names its scope ({@link declaredCheckpointScope}: the task door refuses one that does not), so the
 * second rung is a value a task declared, never an omission this ladder fills in.
 *
 * A task with none of these — no seat, no opt-in, no identity — parks in the anonymous working scope (`ANONYMOUS_SCOPE`), where every other
 * piece of its working state already lives (its runs, journals, scripts, mailbox and background rows): the work of a task with no
 * principal is filed in ONE scope, not split between that and a key of the park lane's own. What KIND of park a row is (an unattended
 * irreversible ask, a resource park, a plan park) is the row's gate (`gate.kind`), never its scope. A row an earlier version parked
 * under the retired key `"irreversible"` keeps it: a resume reads the row's own `scope` and `legScope` (the seat above), so it resumes
 * and parks again where it was filed.
 */
export declare function checkpointScopeOf(spec: {
    durableApproval?: {
        scope?: string;
    };
    principal?: string;
    isolationScope?: string;
}, seat?: string): string;
/** What an opt-in names: its scope, or why it names none — a clause for a refusal sentence. */
export type DeclaredScopeReading = {
    readonly kind: "scope";
    readonly scope: string;
} | {
    readonly kind: "none";
    readonly fault: string;
    readonly at?: "scope" | "ttlMs" | "undeclared";
};
/**
 * The ONE reading of "this opt-in names its scope": a `durableApproval` — the task's own, or the record a parked row keeps of it — names
 * the scope its approvals are filed under as the plain-data record's own `scope` member, a string that is a NAME: the engine's one name
 * rule (`principalNameOf`, the rule `TaskSpec.isolationScope` is judged by), so the key every durable approval is filed under is one a
 * principal could have — visible content, no control, separator or format character — and `isolationScopeOf`'s fall-through never
 * reads it as another quantity. The opt-in is read as data ({@link DECLARED_SCOPE_DATA}): nothing of the host's runs in the look.
 * Answers the scope, or why there is none (not an object, not plain data, no such member, a non-string, not a name). The task door
 * (`assertDurableApprovalDeclaresScope`) refuses an opt-in this reads no scope in, and the revival of a delegated child from its row
 * (`subagent.ts`) re-derives the opt-in only from a record this reads a scope in, through {@link declaredCheckpointScope} — so the two
 * read "an opt-in without a scope" the same way: it is not one. A row filed by a host before the door judged the name (or one a store
 * hands back as something other than data) reads, on revival, as no opt-in (the conservative side: a second plain ask headless-denies
 * instead of parking again), and the revival says so through the deployment's observer-error sink.
 */
export declare function readDeclaredCheckpointScope(declared: unknown): DeclaredScopeReading;
/** The scope an opt-in names ({@link readDeclaredCheckpointScope}), or `undefined` when it names none. */
export declare function declaredCheckpointScope(declared: unknown): string | undefined;
/**
 * The ONE spelling of the placement fields' empty-string discipline: `""` is absence
 * wearing clothes (the resume entry's principal-rung posture), and every placement read that must
 * treat it so — the resume rung's two sides (runtask), the restore fold's seed and the suspend
 * stamp — goes through THIS helper, so three sites cannot drift into three readings. Deliberately
 * NOT applied to the live `internals.placementRoot`/`rootSessionId` reads of the RESOLUTION fold:
 * an empty supplied claim there is an assembly error `readRootOccupant` refuses the run for, on every path, and normalizing it
 * away would silently repair what should be loud.
 */
export declare function placementValueOrAbsent(value: string | undefined): string | undefined;
/**
 * The ONE reading of a composition leg's identity ({@link CompositionLeg}) — the record its three readers share: the driver
 * resolves the leg's value once at prepare through it (the live member, else the row's), the suspend stamp writes what it
 * resolved, and the resume rung compares a live value with the row's through {@link sameCompositionLeg}. A plain copy of the
 * three members, so what the row records is data the leg's caller cannot rewrite afterwards; absent stays absent. An `entry`
 * outside the closed set is refused here (`config.invalid_argument`, `detail.field`), so no reader takes it and no card records it.
 */
export declare function compositionLegRecord(leg: CompositionLeg | undefined): CompositionLeg | undefined;
/**
 * THE reader of the session whose work a composition's leg does: its identity names it — a cascade rung's host session, a verifier's
 * implementation session (`hostSessionId` of both). The leg stands where that session's legs stand (`readStandingCheckout`); a live
 * leg reads it off the identity its composition minted, a resumed leg off the row's (the host resumes a paused verifier by its token
 * directly, through no composition), both through this one function. The composition's entry only mints the identity.
 */
export declare function workSessionOfLeg(leg: CompositionLeg | undefined): string | undefined;
/** Whether two composition-leg records name the same leg of the same composition for the same host session. */
export declare function sameCompositionLeg(a: CompositionLeg, b: CompositionLeg): boolean;
/** The identity a resumed leg runs as, read off the parked row it resumes: the registry row it ran as ({@link RunInternals.rowTaskId}),
 *  its spawning task ({@link RunInternals.parentTaskId}), its tree's root address — id, box scope and occupant (one anchor: taken
 *  whole or not at all) — and its explicit spawn name ({@link RunInternals.explicitAgentName}), each the live seat when the resuming call hands one,
 *  else the row's record (`CheckpointState.rowTaskId` / `legIdentity`) — folded into internals once, so the resume screen and every
 *  reader of the resumed leg (its prepare's mints, its stations, the throw backstop) read one value. A row that records none leaves
 *  the internals as handed. The rule session the row records (`legIdentity.ruleSessionId`) is no internals member: prepare reads it off the row (`recordedRuleSessionOf`). */
export declare function restoreRowIdentity(internals: RunInternals | undefined, state: Pick<CheckpointState, "rowTaskId" | "legIdentity"> | undefined): RunInternals | undefined;
/** The task id a resumed leg's host declared: the resume config's, else the one the parked row records its host declared
 *  (`CheckpointState.legIdentity.declaredTaskId`) — so a resume that names none runs as the task that parked, never as its session. */
export declare function resumedDeclaredTaskId(config: {
    readonly taskId?: string | undefined;
}, state: Pick<CheckpointState, "legIdentity">): string | undefined;
