import type { MailboxAppendMessage, MailboxStore } from "./mailbox-store.js";
import { type EngineNotice } from "./engine-notice.js";
import type { DelegationUnreviewed } from "./classifier-unavailable-arm.js";
import type { TaskEvent } from "./task-event.js";
import { type SemaTaskType } from "./task-registry-shared.js";
import { type A2AWaitingFor } from "./a2a-task-state.js";
import type { AskDestination } from "./mcp-server-spec.js";
import { ONE_SHOT_WAIT_CEILING_DEFAULT_MS } from "../config/defaults.js";
import { readsTaskFrame } from "./a2a-deployment-switches.js";
export { ONE_SHOT_WAIT_CEILING_DEFAULT_MS };
/** The TERMINAL words of {@link TaskNotificationStatus}: the one table every "is this frame a completion?"
 *  reading asks, exported as a value so a consumer outside the package reads these words rather than its own list. */
export declare const TASK_NOTIFICATION_TERMINAL_STATUSES: readonly ["completed", "failed", "killed", "cancelled"];
export type TaskNotificationTerminalStatus = (typeof TASK_NOTIFICATION_TERMINAL_STATUSES)[number];
/** design/135 G2: `"event"` is the ONE non-terminal member — a Monitor batch notification (new stdout
 *  lines from a still-running watch). Everything else is a terminal completion notification. */
export type TaskNotificationStatus = TaskNotificationTerminalStatus | "event";
export type SystemInjectionPriority = "now" | "next" | "later";
/**
 * The outcome an injection entry settles with — what the session did with the frame:
 *  · `queued` — a live lane took it (it rides that run's next turn boundary; accepted, not yet consumed);
 *  · `parked` — no live lane; pended IN PROCESS on {@link PendingSessionNotifications} for the
 *    session's next run on any Runner given the same session store and mailbox objects (a process restart loses it);
 *  · `parked_durably` — no live lane; appended to the session's DURABLE box
 *    ({@link PendingSessionNotifications.admit}) — the next run drains it, in any process;
 *  · `dropped_duplicate` — the session already delivered this exact frame;
 *  · `refused` — a live lane took it and the session's receiving station did not hand it over: an extension consumed it,
 *    or a handler there failed ({@link FrameReceiver}); or it was addressed to an occupant the session no longer holds
 *    (discarded, announced); or the durable box of a session no Runner over the same session store and mailbox holds a seat for
 *    failed it twice (disclosed, and nothing is kept — no leg of that session would read the in-process park). The model never
 *    saw it, and it is not owed again.
 * The park backend is the seat's choice ({@link routeOrParkNotification}), never the producer's.
 */
export type NotificationInjectionOutcome = "queued" | "parked" | "parked_durably" | "dropped_duplicate" | "refused";
export declare const NOTIFICATION_INJECTION_OUTCOMES: readonly ["queued", "parked", "parked_durably", "dropped_duplicate", "refused"];
/** Is `value` one of the injector's outcome words? A host-wired uplink may answer anything (a bare
 *  `void`, an array's `push` count) — such an answer reads as "outcome not reported", never as a word. */
export declare function isNotificationInjectionOutcome(value: unknown): value is NotificationInjectionOutcome;
/** The disposition a park/route decision reports back — the injection outcome minus the dedup fold. */
export type NotificationDisposition = Exclude<NotificationInjectionOutcome, "dropped_duplicate">;
/** The closed value set of {@link SystemInjectionPriority}, as data — the wire-facing entries validate
 *  against THIS rather than against three inline string literals, so widening the type widens the guard.
 *  (Names taken from the reference; see the semantics note on
 *  {@link SystemInjection.priority} for which of CC's behaviors this engine implements.) */
export declare const SYSTEM_INJECTION_PRIORITIES: readonly SystemInjectionPriority[];
/** backlog #389 伴生 (D-3, bad-value loudness) — is this a priority this engine knows at all? A value
 *  outside the set is a caller bug that must be refused, never silently folded into a default: the
 *  no-subscriber retain path indexes `queues[priority]` and the park path stores it verbatim, so an
 *  unknown value used to travel until something downstream failed on it (or didn't, and lied). */
export declare function isSystemInjectionPriority(value: unknown): value is SystemInjectionPriority;
/** The ONE reading of a steer's priority: a parked row or an accepted input that carries none means `"next"`
 *  (the default the live admission has always applied) — so a retry that spells the default and a row parked
 *  without it are the same instruction, whichever side normalized. A tier outside the closed set throws
 *  (`steering.invalid_content`, the sentence names the set); `null` is such a tier, not an absent one. */
export declare function steerPriorityOf(x: {
    readonly priority?: SystemInjectionPriority;
}): SystemInjectionPriority;
/** The two queues a person's input rides on a live run: the `steer` lane (the running turn's next boundary) and the
 *  `followUp` lane (the run's would-otherwise-stop seat). They are also the two families of the stranded-input account — an
 *  input's account is the one of the lane it was queued on (`USER_INPUT_UNDRAINED_FAMILIES`). */
export type UserInputLane = "steer" | "followUp";
/** The ONE reading of "which lane carries this tier": `"later"` rides the follow-up lane (never folded into work in
 *  progress), `"next"` and `"now"` ride the steer lane (`"now"` additionally cuts the running turn). Both injection
 *  seats — the steer verb and the notification lane — branch on it. A parked row that carries no tier reads through
 *  {@link steerPriorityOf} first: `injectionLaneOf(steerPriorityOf(row))`. A tier outside the closed set throws
 *  (`steering.invalid_content`, the same check and sentence as {@link steerPriorityOf}). */
export declare function injectionLaneOf(priority: SystemInjectionPriority): UserInputLane;
export interface TaskNotificationPayload {
    task_id: string;
    /** design/144 §2: `"external"` is CORE-MINTED ONLY — `TaskStream.notify()` casts it onto every
     *  externally injected event, and the input type ({@link ExternalNotificationInput}) deliberately has
     *  no `task_type` field, so an outside producer can never wear an internal lane's type (a caller-declared
     *  "background_bash completed" impersonating a real child). */
    task_type: SemaTaskType | "external";
    toolUseId?: string;
    status: TaskNotificationStatus;
    /** design/135 G2 (Monitor): the batched stdout lines of ONE `status:"event"` notification (lines that
     *  arrived within the same batch window). `result` carries the same text joined/clipped for the model;
     *  this structured mirror is for SDK/UI consumers. */
    lines?: string[];
    /** Per-task monotonically increasing counter. Load-bearing for dedup — {@link taskNotificationDedupKey}
     *  folds it in, so successive notifications of the same task_id+status don't collapse into one queue
     *  entry. Its SEMANTICS are per-task_type (design/144 §1.1):
     *   - `monitor`: the `status:"event"` BATCH counter (design/135 G2) — one per stdout batch window;
     *     terminal notifications omit it (one per status, as before).
     *   - `background_agent`: the STOP-CYCLE number — the row's, as the claim that opened the cycle wrote
     *     it. First settle (spawn stop) = 1; every won wake — the retained fast lane, a tier-3 or drain
     *     revival, a parked resume's consume flip, in this process or another — writes one past the row's,
     *     so the woken run's settle notifies with the next number and one row's numbers never repeat: a
     *     stop→wake→stop second-cycle frame is not swallowed by the dedup key, whichever lanes ran the
     *     cycles. Always present on a background row's frames (retained or not, fork lane included: the attempt
     *     reads it once, when its claim won, so a row collected before its unwind keeps it) and on a synchronously
     *     born child's woken cycles (2, 3, … — its first cycle sends no notification).
     *   - `external`: caller-supplied verbatim ({@link ExternalNotificationInput.seq}) — the injector's
     *     own dedup discriminator across same-task_id+status events.
     *   - `peer_task`: per-row monotonically increasing counter (`lastSeq + 1` on every progress, reminder,
     *     reschedule, terminal, and overdue-tail frame, starting at 1, never reused).
     *  Consumers (server inbox fold / shell render) key `taskId:status[:seq]` — a frame WITHOUT seq keeps
     *  the old two-part key (single-cycle semantics), by contract. */
    seq?: number;
    /** design/144 §2 (external lane only): WHO sent this event — a deployment-provided attribution label
     *  (e.g. a webhook origin). UNTRUSTED: rendered into the `<task-notification … from="…">` header via
     *  `inlineUntrusted` + attribute-escaping, never as authority. Absent on every internal lane. */
    source?: string;
    /** design/134 §3.3: only on `status:"killed"` — who stopped it. MIRROR of task-registry `StopSource`
     *  (the single source; inlined here to avoid an import cycle — task-registry imports this module);
     *  `BackgroundChildEvent.stoppedBy` is typed by this member and projected from it. OPEN ENUM:
     *  consumers must tolerate unknown values (a future "timeout" etc. is not breaking) and fall back
     *  to default copy. */
    stoppedBy?: "user" | "parent" | "manager" | "system" | (string & {});
    /** Present only as `true`, minted by the engine: this frame must not start a turn of an idle session on its own — a host that
     *  wakes an idle session for a completion keeps this one for the session's next turn that something else starts (a person's
     *  message, a still-open run). Minted by {@link peerTaskNotification} iff an overdue-tail late `event` arrives from an
     *  `outside` peer (wired when the peer-task lane launches); ABSENT = handle the frame as before. */
    noWake?: true;
    summary: string;
    /** RB-386① — the failure reason DIGEST on a `status:"failed"` terminal notification
     *  (background_agent lanes): the same bounded text the settle stored as the registry row's `error`
     *  (the completed frame carries the full `result`; the failed frame used to carry NOTHING machine-
     *  readable — consumers had to parse the summary prose, which pre-fix didn't even include the
     *  reason). UNTRUSTED (child/provider-influenceable text) — render-fence before display. Absent on
     *  every non-failed frame and on pre-RB-386 producers. */
    error?: string;
    /** RB-386① — the machine-readable failure code beside {@link error}, when one is known: the child's
     *  `TaskResult.errorCode` taxonomy (brain `[code]` prefixes via extractErrorCode, `limit.*`,
     *  `budget.*`, …). Engine-minted, never model text. Absent when the failure carried no code. */
    errorCode?: string;
    /** Terminal, delegation lanes: the settling run's PROVIDER-BOUNDARY fault assertion, mirrored from
     *  its `TaskResult.apiFailure`. Its PRESENCE is the claim — "this failure came from the transport or
     *  the provider, not from this deployment refusing to send, a limit, or unusable model output" — and
     *  `errorCode` beside it names WHICH terminal; the two answer different questions and neither implies
     *  the other. Members are whatever the failing attempt stated about itself (`status` when the provider
     *  answered with one, `requestId` when it named one), so an EMPTY object is meaningful: "provider
     *  fault, unlabelled", which is not the same statement as absence. Absent on every non-provider
     *  terminal, on every completed run, and on the non-delegation lanes (bash/monitor), whose failures do
     *  not pass through a model provider at all. */
    apiFailure?: {
        status?: number;
        requestId?: string;
    };
    /** Structured exit code of a background command's terminal notification (bash lane): the process
     *  exited on its own with this code. Lets consumers branch on success/failure without parsing the
     *  summary wording. Absent when the process never exited by itself (killed / spawn-failed lanes). */
    exitCode?: number;
    result?: string;
    /** Present (`true`) only on a `status:"killed"` notification that carries a `result` slice: the text
     *  was produced BEFORE the stop won the status race, so it is the child's partial work — the same
     *  semantics as the poll face's `partial_result` flag (one meaning across both surfaces). Absent on
     *  every other notification (a completed result is never flagged). */
    partial?: boolean;
    /** Delegation lanes, terminal frames: the child's EXPLICIT `Agent({name})` spawn key — the same word
     *  its `task_progress.spawnName`, roster row and hook identity carry, rendered as `<agent-name>` so
     *  the parent can `SendMessage({to})` it by name. Minted from the identity the frame's producer holds
     *  (never from the description); ABSENT = an unnamed delegation. */
    spawnName?: string;
    /** Delegation lanes, terminal frames — how the child's report reached this frame under the
     *  hand-back contract: `send` = a report was delivered; `flagged` = delivered under the hand-back
     *  screening's SECURITY WARNING; `withheld` = nothing was delivered (no result text, no partial text).
     *  Absent on non-terminal frames and on the non-delegation lanes. The model face renders a
     *  `<handback>` line only for `flagged` / `withheld` — the parent is told when a report did not
     *  arrive plainly, and nothing for the ordinary case. */
    handback?: HandbackState;
    /** Delegation lanes, terminal frames, present iff auto mode's classifier gave no ruling on the work this child handed back
     *  (`{ handback: <AutoModeFallbackCause> }`): the report went on under the reference's note at the head of `result`
     *  (`handback` stays `send` — the note is not a flag). The Agent card carries the same record; the spawn slot rides the
     *  launch receipt, not this frame. */
    unreviewed?: Pick<DelegationUnreviewed, "handback">;
    /** Delegation lanes, terminal frames, present iff the child's leg compacted its context at least once
     *  or opened its compaction breaker: `passes` = landed compactions, `breakerOpen` = compaction was
     *  disabled for the rest of the leg (later context was trimmed, not summarized), `kind` = the last
     *  landed pass's trigger. The parent otherwise cannot tell that a child forgot. */
    compaction?: {
        passes: number;
        breakerOpen: boolean;
        kind?: CompactionKind;
    };
    /**
     * The INBOX NOTICE carrier: one drain pass of this session's box stopped with records still waiting
     * (the pass budget, an admission stop, a lane refusal). `pending` = records still leased and not yet
     * injected when the pass ended; `delivered` = records injected this pass; `urgent` = how many of the
     * waiting ones their sender marked urgent (absent = 0); `box` = the session box. Its PRESENCE is the
     * render discriminator: the model reads ONE engine line (`[Inbox notice] …`), never a shell. Minted
     * ONLY by the engine's session-box drain, keyed `task_id: "inbox:<box>"` with the pass counter as
     * `seq` so it never collides with a message frame's key; absent when the pass emptied the box.
     */
    inboxNotice?: {
        pending: number;
        delivered: number;
        urgent?: number;
        resupplied?: number;
        box: string;
    };
    /** #1036 — THIS occurrence is a RE-SUPPLY of a record the model was already shown once and
     *  whose frame a compaction then summarized away. Same record, same `task_id`, same `seq`, a new
     *  occurrence: `attempt` says which one. ABSENT = not a re-supply (a first delivery); there is no
     *  `false` form. Only the session-box drain mints it. */
    resupplied?: true;
    /** #1036 — which DELIVERY ATTEMPT of this record's frame this occurrence is: 1 = the first
     *  delivery, 2 = the one re-supply a summarized record gets. ABSENT = 1 (there is no `0`, and a
     *  consumer must not read absence as "unknown"). It folds into the injection queue's dedup key
     *  ({@link taskNotificationDedupKey}), which is what keeps a re-supply from collapsing into the
     *  first occurrence's entry. Only the session-box drain mints it. */
    attempt?: number;
    output_file?: string;
    /** Whatever the settling lane knows about its own spend, JSON-rendered verbatim into one `<usage>`
     *  tag. Deliberately untyped — the lanes report different quantities and nothing here should force
     *  one to fabricate a figure it does not have. What IS contracted is the VOCABULARY: a name that two
     *  lanes both publish must mean the same thing on both. The delegation lanes
     *  (`background_agent`, its fork/revive cycles) and the workflow lane therefore agree on
     *  `tokens`/`turns`/`costMicroUsd`/`tool_uses`/`duration_ms`; the workflow lane's fan-out counters
     *  (`agent_count`, `agents_done`, …) and resume counters have no delegation analog and are its own. */
    usage?: unknown;
    /** CC `<diagnostics>` parity: ENGINE-MINTED teaching text for the "result is empty/unexpected —
     *  now what" moment (per-agent read route / journal coordinate / resume command). Producers must mint it
     *  from engine values only (ids, store locators) — never from model-influenceable text. */
    diagnostics?: string;
    /** The child run's SESSION id, when known. A shell keys its fleet/footer rows by its own
     *  local ids; the a* task_id alone can be unmappable on its side — sessionId is the stable cross-system
     *  anchor (the same handle TaskResult.sessionId / fleet rows carry). Optional: bash lane has none. */
    sessionId?: string;
    /** Residual lane A — the child's last ≤10 completed tool steps, so the parent can write a precise resume
     *  prompt for a killed/stopped child without reading the transcript. Rendered as a compact block.
     *  Background-agent lane only; bounded upstream. */
    recentSteps?: import("../agents/subagent-steps.js").SubagentStep[];
    /** Residual lane D (core half) — files the child mutated with edit counts. Background-agent lane only. */
    editedFiles?: import("../agents/subagent-steps.js").SubagentEditedFile[];
    /** What the child did, counted over its whole event stream (`SubagentActions`: tool calls by tool, the shell commands with
     *  their exit codes, the files it changed — `none` included), rendered as the `<actions>` section beside the child's own
     *  words. Present only on a terminal frame of the background-agent lane whose parent run declares a member ledger
     *  (`TaskSpec.runLedger`); absent on every other frame, so a run without one reads its notifications unchanged. */
    actions?: import("./actions-digest.js").SubagentActions;
    /** How the child ended — the background agent row's outcome (`MemberOutcome`), the one object the row, this frame and the
     *  parent's report read: its ending word and its ONE refusal record (asks nobody could answer, calls a person or anything else
     *  refused, a verdict that never landed, a person's halt). Present on a terminal frame of the background-agent lane whenever the
     *  row carries one. The model reads its refusals as `refused-asks` (the asks nobody could answer) and `refused` (the rest). */
    outcome?: import("./member-outcome.js").MemberOutcome;
    /** How each member of a workflow run ended, and the run-level reading derived from them (`MemberLedger`) — the object the
     *  summary line counted and the deployment notifier carries. Workflow lane terminal frames only, on both legs (a failed run
     *  delivers no return value, and this still names the members that completed). Never folded into `result`. */
    members?: import("./member-outcome.js").MemberLedger;
    /** Residual lane E — `true` when the parent model's next SendMessage can continue the child: the continuation judge's
     *  answer (`agentContinuationOf`, the one every face of the child reads — the ListAgents column too). No user stop, a
     *  parent model shown a SendMessage, and either a durable record the durable rung admits (any non-fork row, named or
     *  not) where the parent's SendMessage mount can revive, or a live retained conversation in this engine process. Lets the
     *  parent decide continue-vs-restart without trial-and-error. Background-agent lane only; absent on a synchronous child's
     *  resumed cycle (an operator's handle resume — no row a SendMessage addresses). */
    resumable?: boolean;
    /** With `resumable: true` from a live retained conversation (and no durable record behind it): the deadline (epoch ms)
     *  the retention holds it until — the settle instant of this cycle plus the retain window. An UPPER bound: the ledger's
     *  capacity, a session reap or the parent run's end can release it earlier. ABSENT whenever the answer is not a retained
     *  one (`false`, or a durable continuation — no deadline this engine sets). Host lane only: never rendered on the model's
     *  face. Background-agent lane only. */
    resumableUntil?: number;
    /** A cross-channel correlation key for ONE completion event — the same task's completion fans out
     *  across several independent read faces (this live notification frame, a durable inbox entry, and the
     *  host task poll projection). Minted ONCE per completion, fill-once (first writer wins), on the
     *  same task-registry handle/record every read face serves from — see
     *  {@link "./task-registry.js".UnifiedTaskOutput.completionId} for the shared contract (open-shape
     *  `string`, absent until terminal settle, absent on a pre-P1-3 core build). Deliberately ABSENT on
     *  the `"external"` lane (`TaskStream.notify()`): that lane has its own caller-supplied `seq`
     *  correlation key and no registry-side settle point to mint this from. */
    completionId?: string;
    /** design/176 — the peer-message marker + hop-chain carrier, present ONLY on payloads minted by
     *  the SendMessage delivery legs (the engine's single peer-carrier producer). Three uses: it
     *  carries the forwarding chain (engine-read side channel — never rendered to the model face),
     *  it marks the payload as peer-class for the consumption-boundary chain recording, and it keys
     *  the discipline-block pairing. Deliberately NOT on {@link ExternalNotificationInput}: an
     *  outside caller can neither mint a chain nor wear the peer class. */
    peer?: {
        hopChain: string[];
        /** The SENDING run's session id, when the producer knows it — the reply/receipt address a durable
         *  park of this frame records (`MailboxPeerMeta.fromSession`). Engine-read; never rendered. */
        fromSession?: string;
        /** The sender's admission key (the same token the send-point gate charged), so a durable park
         *  re-judges the frame under the same sender at the drain. Engine-read; never rendered. */
        senderKey?: string;
    };
    /** Facade carried on `task_type: "peer_task"` frames (named `peerTask` because {@link peer} is SendMessage's
     *  hop-chain carrier). Core fields are minted by the peer-task lane; `reminder` is reserved for the reminder
     *  producer, and `peerFinalBy` / `approvalBy` / `clock` are reserved for the deadline-extension producer. */
    peerTask?: PeerTaskNotification;
    /**
     * design/385 §1.4 d1 — the delegated-child → parent UPLINK carrier (`SendMessage("main")`). Its
     * PRESENCE is the render discriminator: the frame reaches the parent's model as a top-level
     * `<agent-message from="…">` user frame (the same-process lane's carrier, distinct from both the
     * `<task-notification>` shell and the cross-session envelope) followed by the peer discipline block.
     * `body` is the child's message as bounded by the producer (no discipline block inside it — the
     * block is frame-adjacent by rule). The classic members (`summary`/`result`) stay filled beside it
     * for wire consumers that project the frame as a card; they are not what the model reads.
     * Minted ONLY by the SendMessage uplink leg (engine-side); an external `notify()` cannot wear it.
     */
    agentMessage?: {
        from: string;
        body: string;
    };
    /**
     * design/385 §4.1 — the CROSS-SESSION carrier (a peer session's message drained from this session's
     * own box). Its PRESENCE is the render discriminator: the model reads a top-level
     * `<cross-session-message from="…" …>` envelope (design/385 §4.2 model-face codec — from-session /
     * from-name / from-mode / from-scope as the typed record carried them; the hop chain never appears)
     * followed by the cross-session discipline block, never a `<task-notification>` shell. The
     * attributes are a PROJECTION of the store record's typed `peerMeta` — the text is presentation,
     * the typed side record ({@link _sema_provenance}) is the authority. Minted ONLY by the engine's
     * session-box drain; an external `notify()` cannot wear it.
     */
    crossSessionMessage?: import("../agents/cross-session-envelope.js").CrossSessionEnvelopeFields & {
        body: string;
    };
    /**
     * design/385 §4.4 / §5.2 (slice 4) — the CROSS-SESSION NOTICE carrier: a delivery receipt about one of
     * THIS session's own outbound messages (held / held_by_policy / denied / expired / delivered / refused / dropped) or an
     * idle notice for a `notify_when_idle` ask (idle / exited / unavailable / expired), drained from this
     * session's own box as a notice-kind record. Its PRESENCE is the render discriminator: the model reads
     * the engine-rendered notice line as-is (CC injects `[Cross-session delivery notice] …` /
     * `[Cross-session idle notice] …` as a plain user-frame line) — never a `<task-notification>` shell,
     * never the peer-message envelope (a notice is engine speech about a peer, not a peer's words; the
     * envelope would put it past the parity judgment as a peer's request). `text` is rendered by the
     * drain from the record's TYPED `peerMeta.notice` (the authority, which rides THIS frame once, at
     * `_sema_provenance.peerMeta.notice` — a host renders a card from there, never by parsing `text`); the
     * record's own `content` mirror is never what reaches the model. Minted ONLY by the engine's session-box drain.
     */
    crossSessionNotice?: {
        kind: "delivery_notice" | "idle_notice";
        text: string;
    };
    /**
     * design/385 §1.4 d1 / §4.1 — the engine-minted PROVENANCE side record of an engine-injected peer
     * frame, a typed key (never model text) so a host can attribute and correlate the injection on the
     * wire. Present exactly when one of the four peer carriers is ({@link agentMessage}, {@link crossSessionMessage},
     * {@link crossSessionNotice}, {@link inboxNotice}) — one record per frame, `kind` naming which. Its fields are read per `kind` (see {@link SemaProvenance}):
     * on the agent-message lane `from` is the sender label the frame's attribute spells, `taskId` the
     * sender's run/agent id, `seq` the producer's per-frame counter (= this payload's `seq`) and
     * `agentType` the sender's resolved agent type when the producer knows it; on the two box-record
     * lanes `from` is the sender's ADDRESS, `taskId` the recipient's own box handle, `seq` the box seq,
     * and the record's typed peer metadata rides in `peerMeta` (on a notice frame its `notice` is THE typed notice).
     */
    _sema_provenance?: SemaProvenance;
    /**
     * The text a receiving extension handed the model in place of this frame's rendering (the `session.receive` station,
     * {@link FrameReceiver}), and who changed it. Set only on the copy a delivery carries — never on the frame a producer,
     * a park or a box holds — and {@link renderTaskNotificationXml} returns it verbatim: every face that renders the frame
     * (the live lane, the turn-open redelivery, a `ReadInbox` result, its receipt ask) reads the one rendering.
     */
    received?: {
        readonly text: string;
        readonly rewrittenBy: readonly string[];
    };
}
/**
 * The session's one receiving station (`session.receive`): every face a frame reaches the model by — the live lane (a
 * producer's injection, a frame routed in from another run of the session, a peer letter the box drain pushes), the
 * turn-open redelivery of what was parked, and the box's `ReadInbox` pull — hands the frame to it before the hand-over, and
 * hands over what it answers. Awaited; with no handler listening, nothing is raised and a caller keeps its own path.
 */
export interface FrameReceiver {
    /** Does a handler listen? `false` ⇒ the frame passes as made, and nothing is raised. */
    listens(): boolean;
    /** What becomes of `payload`: handed over (the frame, or a copy carrying {@link TaskNotificationPayload.received}), or
     *  consumed — not handed over, by the extension `by` (or the engine, when the station could not judge), for `reason`. */
    receive(payload: TaskNotificationPayload): Promise<ReceivedFrame>;
}
export type ReceivedFrame = {
    readonly kind: "arrived";
    readonly payload: TaskNotificationPayload;
} | {
    readonly kind: "consumed";
    readonly by: string;
    readonly reason: string;
};
/** design/385 §1.4 d1 / §4.1 — see {@link TaskNotificationPayload._sema_provenance}. `kind` is a
 *  closed set of the engine carriers that mint the record; a future carrier adds a member, never a
 *  second key. */
export interface SemaProvenance {
    /** `agent_message` = the same-process uplink (§1.4 d1); `cross_session_message` / `cross_session_notice` =
     *  the session-box drain over a box record (§4.1 / §4.4) — `from` is then the sender's ADDRESS, `taskId` the
     *  recipient's own box handle, `seq` the box seq, and the record's typed meta rides in `peerMeta`;
     *  `inbox_notice` = the drain's own line about its box (no record behind it: its facts are the carrier's). */
    kind: "agent_message" | "cross_session_message" | "cross_session_notice" | "inbox_notice";
    from: string;
    taskId: string;
    seq: number;
    agentType?: string;
    /** The two box-record kinds (`cross_session_message`, `cross_session_notice`) — the store record's typed peer
     *  metadata, verbatim (authority; a notice frame's `peerMeta.notice` is the typed notice, its carrier holds only
     *  the rendered line). Absent on `agent_message` / `inbox_notice`, and on a record that carried no peerMeta. */
    peerMeta?: import("./mailbox-store.js").MailboxPeerMeta;
}
/**
 * design/144 §2 — the caller-facing input of `TaskStream.notify()`: a STRUCTURED external event to inject
 * into the running task's notification lane (same delivery machinery as background_bash/monitor/agent
 * completions: SystemInjectionQueue dedup → steer/followUp/idle-park three-state delivery).
 *
 * Deliberately a SUBSET of {@link TaskNotificationPayload}: NO `task_type` (core mints `"external"` — a
 * caller can never impersonate an internal lane) and none of the internal-lane fields (lines/stoppedBy/
 * usage/…). Every field is treated as UNTRUSTED data on the model face (the XML renderer sanitizes) —
 * transport, inbound authn, and idle-session durable park are the DEPLOYMENT half (design/43: no
 * daemon/webhook semantics in core; core only takes "a structured event that already reached this
 * process" into THIS run's injection queue).
 */
export interface ExternalNotificationInput {
    /** The caller's correlation id for the event source (free-form; part of the dedup key). */
    task_id: string;
    status: TaskNotificationStatus;
    summary: string;
    result?: string;
    /** Caller-side dedup discriminator: successive events of the same task_id+status need distinct `seq`s
     *  or the queue's dedup key swallows the repeats (same contract as every internal lane). */
    seq?: number;
    /** Attribution label rendered into the `from="…"` header (untrusted; sanitized). */
    source?: string;
}
export interface SystemInjection<TPayload = unknown> {
    kind: "task_notification";
    /**
     * design/373 — the injection ladder is LIVE (all three values carry delivery semantics, the reference's
     * form; the flat "every priority delivers at the next boundary" era ended with this
     * design — its H-1 anchor-correction note is preserved in the design archive, and the ruled
     * changes it named are exactly what landed here):
     *
     *  - `"next"` — the running turn's NEXT boundary (mid-work included), arrival order, consecutive
     *    engine-note frames batch. The pre-373 behavior, byte-identical (the regression baseline).
     *  - `"later"` — never folded into the work in progress: delivered at the run's natural
     *    would-otherwise-stop seat (one closing turn takes consecutive queued `"later"` notifications
     *    at once, each its own message; an input queued between them ends the batch). A run that never reaches that seat
     *    (abort/maxTurns) re-pends the frame per session — the session's NEXT run delivers it at
     *    turn-open. Structural honesty note: once parked, delivery depends on a next run HAPPENING
     *    (this engine does not own an idle process the way the CC client does) — a recorded
     *    weakening, not a bug.
     *  - `"now"` — `"next"`'s delivery guarantee PLUS the boundary is manufactured early: on the
     *    notification lane the frame takes the queue's class head and the earliest natural boundary
     *    (NO turn interrupt — interrupt authority belongs exclusively to the caller-provenance
     *    steer face, `TaskStream.steer({ priority: "now" })`; the external `notify()` verb REFUSES
     *    `"now"` typed). An unknown value is refused at every entry (bad-value loudness).
     *
     * Park/uplink: the pend store carries the frame's priority ({@link PendingSessionNotifications})
     * and the turn-open batch delivers priority-major (pend order within a class); a record with no
     * carried priority ranks AS `later` and its wire field stays honestly absent.
     */
    priority: SystemInjectionPriority;
    dedupKey: string;
    payload: TPayload;
    /** S2b' — resolved with the ACTUAL injection outcome by the runner's subscribe
     *  listener: "queued" once the boundary steer accepted, "parked" when the idle tail-race (or the
     *  engine-note backlog cap) rejected and the payload was pended per session. Absent =
     *  fire-and-forget producer (no receipt to honor). */
    onDisposition?: (d: NotificationDisposition) => void;
}
/** design/373 (adversarial r3, recorded rule): the key deliberately EXCLUDES the injection tier.
 *  The key names an EVENT's identity; `priority` is delivery metadata about one submission of it.
 *  A repeat under an in-flight key therefore FOLDS regardless of the repeat's tier — the tier of
 *  record is the FIRST accept's, and the folded caller's "queued" receipt is true of that standing
 *  entry. A producer that wants a NEW occurrence delivered under a different tier mints a fresh
 *  `seq` (the documented repeat discipline); silently migrating a queued frame between lanes on a
 *  repeat, or refusing the repeat typed, would each turn a dedup fold into a delivery mutation. */
export declare function taskNotificationDedupKey(n: Pick<TaskNotificationPayload, "task_id" | "task_type" | "status" | "seq" | "attempt">): string;
/**
 * The one set of options a task notification is handed to the model under, on every road it takes — the live lane (a running
 * leg's steer / follow-up) and the turn-open redelivery (a frame parked while the session sat idle): engine-note provenance
 * (visible to the model and to derived views, never the user's speech), the frame itself as the payload sidecar, and its
 * {@link taskNotificationDedupKey} as the durable key on the transcript entry it becomes — the key the entry's
 * `message_committed` frame states as `noteKey`, so a frame and its row join by key whichever road the frame took.
 */
export declare function taskNotificationNoteOptions(payload: TaskNotificationPayload, 
/** The tier the frame rides under, when it has one: carried beside the payload sidecar, so a frame the run ends without
 *  delivering is parked under the tier it was injected with. */
priority?: SystemInjectionPriority): {
    readonly provenance: "engine-note";
    readonly enginePayload: TaskNotificationPayload;
    readonly engineNoteKey: string;
    readonly engineTier?: SystemInjectionPriority;
};
/**
 * The one frame a task notification is pushed to the host as, on every road it takes — the live lane at accept time and the
 * turn-open redelivery of a parked frame: the payload, its tier when it has one (absent stays absent), and its
 * {@link taskNotificationDedupKey} as `noteKey` — the very key {@link taskNotificationNoteOptions} stamps on the transcript row the
 * frame becomes, which that row's `message_committed` states as its own `noteKey`. A caller adds its run identity beside it.
 */
export declare function taskNotificationFrame(payload: TaskNotificationPayload, priority?: SystemInjectionPriority): Extract<TaskEvent, {
    type: "task_notification";
}>;
/**
 * The lane-scoped identity of a task, extracted from {@link taskNotificationDedupKey} so every
 * place that treats "same task" as one bucket applies the SAME lane rule.
 *
 * The dedup key had the lane segment from the start; three other sites did not — the pending store's
 * per-task quota, its eviction victim predicate, and its drop ledger key were all the bare `task_id`.
 * The lane segment exists because `task_id` is caller-supplied free-form on the external lane, so an
 * external injector that picks a real child's id landed in the child's quota, evicted the child's frames,
 * and merged into one ledger row carrying ONE `taskType` — the exact impersonation direction this
 * module's header says cannot happen. One rule, one helper, one place to change it.
 */
export declare function taskNotificationLaneKey(n: Pick<TaskNotificationPayload, "task_id" | "task_type">): string;
/** Attribute-context escape for the external `from="…"` header: the value already went through
 *  `inlineUntrusted` (one-line, capped, sanitized), but a `"` would still close the attribute — escape
 *  the XML structural chars so the header can never be broken out of. Exported for the design/171
 *  human-input projection, which renders the same kind of untrusted attribution label — one escape
 *  implementation, never a per-renderer copy. */
export declare function attrEscape(value: string): string;
/** Max rendered length of an untrusted attribution label (the external `from="…"` header and the
 *  design/171 speaker envelope share it — same concern: a display label, not a payload). */
export declare const EXTERNAL_SOURCE_MAX = 120;
/** design/385 §1.4 d1 — the same-process lane's carrier tag (CC `iTe`). */
export declare const AGENT_MESSAGE_TAG = "agent-message";
/**
 * design/385 §1.4 d1 — render the child → parent uplink as CC's same-process form: a top-level
 * `<agent-message from="…">` frame (CC `ZSe`: attribute-escaped sender, nested-tag-neutralized body,
 * no header prose — the attribution IS the attribute) followed by the peer discipline block OUTSIDE
 * the frame (design/176 §3.4 placement: a sender-embedded copy inside the body arrives neutralized,
 * so position distinguishes the real block). The body first passes the harness AUTHORITY-family
 * neutralization ({@link neutralizePeerBody}: every engine envelope a model reads as harness speech —
 * `task-notification`, `user_memory`, `skills`, … — not the reminder tag alone), because the child's
 * text is model output; the pre-carrier `<task-notification>` shell entity-escaped every byte of it,
 * and the carrier form must contain at least as much.
 */
export declare function renderAgentMessageFrame(frame: {
    from: string;
    body: string;
}): string;
/**
 * design/385 §4.1 — render a drained peer-session message as the model-face envelope (the §4.2
 * codec: canonical attribute order, neutralized body) followed by the cross-session discipline block
 * OUTSIDE the envelope. Distinct from {@link renderAgentMessageFrame}: another lane, another trust
 * level, another block — sharing either would blur the classifier's lane judgment.
 */
export declare function renderCrossSessionMessageFrame(frame: NonNullable<TaskNotificationPayload["crossSessionMessage"]>): string;
/**
 * design/385 §4.4 / §5.2 — render a cross-session notice line. The text is engine-authored from typed
 * fields (every untrusted label inside it already passed the lane's label sanitizer); the reminder-tag
 * defusal runs once more here so no carrier can smuggle a system-reminder into the model face.
 */
export declare function renderCrossSessionNoticeLine(notice: NonNullable<TaskNotificationPayload["crossSessionNotice"]>): string;
/** #1036 — the ONE preamble a re-supplied occurrence carries, ahead of whatever carrier it is
 *  riding. It says the true thing (you read this once; the summary that replaced it did not keep it)
 *  without asking the model to reconcile two copies: the first occurrence is gone from the context. */
export declare const RESUPPLIED_FRAME_PREAMBLE = "[Re-supplied] You were shown this message once before; the compaction that replaced older context with a summary did not keep it, so the engine is handing it over again. It is the SAME message, not a new one \u2014 act on it once.";
export declare function renderTaskNotificationXml(n: TaskNotificationPayload): string;
/** The one sentence a parent reads about a child that compacted: how often, on what trigger, and
 *  whether compaction gave up (after which older context was trimmed away rather than summarized). */
export declare function renderCompactionDisclosure(c: NonNullable<TaskNotificationPayload["compaction"]>): string;
/** The `[Inbox notice]` line — counts only, engine-authored; the records themselves arrive on their
 *  own frames (this pass's) or the next passs', and the pull tool reads them on demand. */
export declare function renderInboxNoticeLine(n: NonNullable<TaskNotificationPayload["inboxNotice"]>): string;
/**
 * The BETWEEN-TURNS pending lane. A task notification born while the session has NO live lane at all
 * (every run of it is over, or the one that is live rejected the injection because its agent was
 * already idle) is parked PER SESSION; the session's next run drains it at start and rides the payloads
 * down the SAME notification lane (steer at the next turn boundary), so in-turn and between-turn events
 * keep one shape. A frame whose session DOES have a live lane never reaches this store —
 * {@link SessionLiveNotificationLanes} takes it to that run's next turn boundary.
 *
 * Bounds (1.254 F4 家族纪律): per-task cap + per-session cap + session-count cap, oldest dropped first —
 * preferring NON-terminal victims (an exit/killed terminal is the single most load-bearing notification of
 * a watch and dies only when nothing else can) — and every drop is counted per task and DISCLOSED on
 * delivery ({@link discloseDroppedPending}), never silent.
 *
 * Dedup (design/144 X4): `pend` drops a payload whose {@link taskNotificationDedupKey} is already parked
 * for the session — the ended-run park leg honors the same key contract as the live queue's enqueue
 * (before this, a repeat external notify() after the run ended would deliver DUPLICATE frames on the next
 * run's drain, violating the notify contract). HONEST WINDOW LIMIT: the dedup set lives and dies with one
 * session's parked batch — it does NOT span the live queue (a key delivered live and then pended after
 * teardown is a fresh domain) and it resets at `drain` (a repeat arriving after the next run drained is
 * deliverable again — same posture as the queue, whose drain also releases keys). A bound-evicted victim
 * releases its key (mirror of SystemInjectionQueue cap eviction), so the set is bounded by the item caps.
 *
 * NOT checkpointed (durable-resume ruling, recorded): the registry itself (`defaultTaskRegistry`) is
 * process-local — a cross-process durable resume cannot reconnect a monitor's watcher/process anyway, so a
 * pending queue that outlives the process would advertise events for handles that no longer exist. Same-
 * process resume legs share this store via the Runner and drain normally.
 */
export declare const MAX_PENDING_EVENTS_PER_TASK = 50;
export declare const MAX_PENDING_EVENTS_PER_SESSION = 200;
export declare const MAX_PENDING_SESSIONS = 100;
/** Session-box bindings are three references and a handle; bounded far above the parked-session cap so
 *  a long-lived leader's binding is not evicted by parked traffic (eviction = the park backend degrades
 *  to in-process, which the receipt then says). */
export declare const MAX_SESSION_BOX_BINDINGS = 4096;
/**
 * WHERE a frame for one session goes: the session id and the occupant of its row — `SessionMetadata.incarnation`, as the
 * run that names the address acquired the row (`undefined` = no token: a row written before occupants were minted, or a
 * read that failed). A session id can be deleted and created again under the same spelling, by another principal or the
 * same one; the new row is another occupant, and a frame addressed to the one before it is never delivered to it
 * ({@link sameOccupant}). Every seat of {@link PendingSessionNotifications} — its live lanes, its durable box, its
 * parked records — is held for one address, and only for one that names an occupant ({@link addressNamesOccupant}).
 */
export interface SessionAddress {
    readonly sessionId: string;
    readonly occupant: string | undefined;
    /** The leg could not read its occupant (the read threw): `occupant` is then no answer, and the address is nobody's. The store
     *  takes the leg as no admission, drains it nothing, registers no live lane for it, and discards (announced) what is routed
     *  to it ({@link PendingSessionNotifications.admit}, {@link PendingSessionNotifications.discardsStale}). */
    readonly unread?: true;
    /** The scope the session's legs mount its durable box in, as the address's minter recorded it (a delegation tree's root
     *  anchor carries the one its root leg mounted). Read only where the store holds no seat for the session: the box is then the
     *  one {@link PendingSessionNotifications}' unseated box seat judges at this scope. Absent ⇒ no box is judged for it. */
    readonly scope?: string;
}
/**
 * Does a frame wait at a seat for this address — parked for the session's next run, offered to another run's live lane, kept in
 * the session's durable box? Only when the address names an occupant: its occupant was read ({@link SessionAddress.unread}) and is
 * a token ({@link isOccupantToken}). A row with no token — whatever its store declares — cannot be told from the next row created
 * under the id, so nothing waits for it: its leg registers no live lane and binds no box, and a frame addressed to it is discarded
 * at the route's door, announced. The way out is a token: minted by the write that creates the row, or given once to a standing row
 * (`incarnationCell(row, "mint")`). The leg's own live lane is the run's, not the address's, and takes its producers' frames as before.
 */
export declare function addressNamesOccupant(address: SessionAddress): boolean;
/** The session box a leg binds — its park seat ({@link PendingSessionNotifications.admit}) and its drain ({@link import("../agents/peer-session-drain.js").peerDrainLanesOf}) —
 *  given the box its mount judgment found: that box for an address that names an occupant, none for any other ({@link addressNamesOccupant}). */
export declare function frameSeatBox<B>(address: SessionAddress, box: B | undefined): B | undefined;
/** A run leg's own session address — the session it prepared and the occupant its acquire read (the one construction). */
export declare function sessionAddressOf(leg: {
    readonly sessionId: string;
    readonly sessionIncarnation?: string;
    readonly sessionIncarnationUnread?: true;
}): SessionAddress;
/** The words {@link DiscardedDeliveryPath} is made of, as a value (#3505): the closed set a host reads off
 *  `delegation.delivery_discarded`'s `detail.path` against, so it does not copy the four words by hand. Root-exported. */
export declare const DISCARDED_DELIVERY_PATHS: readonly ["live", "box", "drain", "notice"];
/** Which seat a delivery addressed to an earlier occupant of a session would have reached under the occupant the session
 *  holds now: for a frame, that occupant's live run, its durable box, or its next run's turn-open drain; for a delegated leg's
 *  user-face notice addressed to its tree's root, the notice sink that routes it to the root session (`notice`). Derived from
 *  {@link DISCARDED_DELIVERY_PATHS}, so the type and the value are one set. */
export type DiscardedDeliveryPath = (typeof DISCARDED_DELIVERY_PATHS)[number];
/** What a discarded delivery was, by name only: a frame's task (its id and type), or a delegated leg's user-face notice (the
 *  leg it came from — its agent id, else its session — and the notice's code). */
export interface DiscardedDelivery {
    readonly taskId: string;
    readonly taskType: string;
}
/** The Runner's judge of a delegated leg's notice destination ({@link PendingSessionNotifications.discardsStaleNotice}): `true`
 *  = the notice is addressed to an occupant the root no longer holds, and was discarded and announced. */
export type NoticeDestinationJudge = (destination: SessionAddress, delivery: DiscardedDelivery) => boolean;
/** A frame's name as a discarded delivery: its task id and type, nothing of its text. */
export declare function frameDelivery(payload: TaskNotificationPayload): DiscardedDelivery;
/**
 * The account of a delivery discarded because its address names an occupant the session no longer holds — the one mint of
 * `delegation.delivery_discarded`. Counts and words only: the delivery's text (a child's summary, a peer's words, a notice's
 * sentence) never rides it, nor either occupant token (only whether each side had one).
 */
export declare function deliveryDiscardedNotice(address: Pick<SessionAddress, "sessionId" | "occupant">, current: string | undefined, delivery: DiscardedDelivery, path: DiscardedDeliveryPath): EngineNotice;
/**
 * A session's DURABLE box, bound to the park seat by the leg that mounts its session-box drain — one
 * mint (the drain mount judgment), two readers (the drain and {@link routeOrParkNotification}), so
 * "a frame parked here is drained there" holds by construction. Absent for a session whose legs mount
 * no drain (a delegated child, an ungrammatical id, no cross-process-safe mailbox).
 */
export interface SessionBoxBinding {
    mailbox: MailboxStore;
    /** The registry/mailbox scope the session's legs mount in (the drain reads the same scope). */
    scope: string;
    /** The box handle (`session.<id>`), minted after the address grammar passed. */
    handle: string;
    /** The session id the box belongs to — the `fromRoot` a durably parked child frame records. */
    sessionId: string;
    /** The deployment's engine-frame floor (`RunnerDeps.sessionBoxEngineFrames`): `true` ⇒ an engine
     *  frame parks in this box as an `engine_frame` record; otherwise it parks in process. */
    engineFrames?: boolean;
    /** Where an append fault is disclosed. For a session the store holds a seat for, a second fault leaves the frame on the
     *  in-process park its next leg on any Runner of the same store × mailbox pair settles with the box; for one it holds none for, the second fault is disclosed
     *  here too and nothing is kept — no leg of that session would read it. */
    onError?: (e: unknown) => void;
}
/** Why no durable box is judged for a session id at a scope ({@link SessionBoxVerdict}): the deployment wires no mailbox store;
 *  the mailbox, or the session store's by-id read, is not safe to share across processes (`reason` = the mount verdict's own
 *  sentence); the id is outside the box address grammar. */
export type SessionBoxRefusal = {
    readonly code: "no_mailbox";
} | {
    readonly code: "mailbox_unsafe";
    readonly reason: string;
} | {
    readonly code: "ungrammatical";
};
/** The one judgment of a session's durable box at a scope: its binding, or why there is none. */
export type SessionBoxVerdict = {
    readonly ok: true;
    readonly box: SessionBoxBinding;
} | {
    readonly ok: false;
    readonly cause: SessionBoxRefusal;
};
/** A completion sink: a background producer's frame and its tier, the shape a mount's `notify` takes. */
export type TaskNotificationSink = (n: TaskNotificationPayload, opts?: {
    priority?: SystemInjectionPriority;
}) => void;
/** Why a completion addressed to a session does not take the route ({@link PendingSessionNotifications.completionLaneOf}): the box
 *  judgment's refusal ({@link SessionBoxRefusal}); the deployment declares no durable engine frames (`floor_off`); the address names
 *  no scope its box lives in (`no_root_scope`). Engine-internal: it picks a sentence, it never rides the wire. */
export type SessionCompletionLaneCause = SessionBoxRefusal | {
    readonly code: "floor_off";
} | {
    readonly code: "no_root_scope";
};
/** The route's sink for a completion addressed to a session, or why there is none. */
export type SessionCompletionLane = {
    readonly ok: true;
    readonly sink: TaskNotificationSink;
} | {
    readonly ok: false;
    readonly cause: SessionCompletionLaneCause;
};
/** The hand-back contract's three words (see {@link TaskNotificationPayload.handback}). */
export declare const HANDBACK_STATES: readonly ["send", "flagged", "withheld"];
export type HandbackState = (typeof HANDBACK_STATES)[number];
/** THE hand-back projection, one rule every terminal frame producer calls: a warning ⇒ `flagged`; any
 *  report or partial text ⇒ `send`; neither ⇒ `withheld`. */
export declare function handbackStateOf(facts: {
    result?: string | undefined;
    partialText?: string | undefined;
    warning?: string | undefined;
}): HandbackState;
/** The three-way compaction trigger word a terminal frame carries (the wire's `forced` is `reactive` here). */
export declare const COMPACTION_KINDS: readonly ["manual", "auto", "reactive"];
export type CompactionKind = (typeof COMPACTION_KINDS)[number];
/** The wire trigger word → the frame's kind word (`forced` = a reactive pass the run could not skip). */
export declare function compactionKindOf(trigger: "auto" | "manual" | "forced"): CompactionKind;
/**
 * THE projection every delegation terminal frame calls for its identity + hand-back + context facets:
 * the spawn key from the identity the producer holds (never the description), the hand-back state from
 * the delivered text and the screening's warning, and the child's compaction record verbatim. Absent
 * inputs stay absent; `handback` is always minted (a terminal always says how the report reached it).
 */
export declare function terminalFrameFacets(facts: {
    spawnName?: string | undefined;
    result?: string | undefined;
    partialText?: string | undefined;
    warning?: string | undefined;
    compaction?: TaskNotificationPayload["compaction"] | undefined;
}): Pick<TaskNotificationPayload, "spawnName" | "handback" | "compaction">;
/** What the deployment hears when a report the frame carried whole could not be stored: the task row keeps no read handle. */
export declare const SHORT_REPORT_UNSTORED = "a background task's report could not be stored (the write failed or went unconfirmed): its completion frame carried the whole report, but its task row keeps no read handle for a later list";
/**
 * A delegated child's report as its completion frame carries it — the one value the parent's notification and the fleet
 * terminal projected from that frame both read: redacted BEFORE the cut, with the pass the task row's copy uses (a token
 * across the cut is never half-shown), then cut with an honest total. The report is the task's result artifact whatever its
 * length: `persist` stores the whole redacted report and `record` hands the stored ref to the task row as its read handle
 * (a list of tasks names it when the frame itself is lost) — only after the write landed. A report longer than the frame
 * carries is cut, and its cut line names that ref, so the frame waits for the write; a report the frame carries whole does
 * not wait (its write lands on its own and records the ref then — a stalled store never holds a complete answer back).
 * That unawaited write still has a failure path: a write that went unconfirmed, or anything thrown on the way, reaches the
 * caller's `notifier` (its first failure per site is disclosed on the deployment's channel), never the floor. `record`
 * names the settle the result belongs to, so a write landing after the row moved on records nothing. Absent in ⇒ absent out.
 */
export declare function completionResultField(result: string | undefined, persist: (report: string) => Promise<import("./tool-result-store.js").TaskArtifact>, record: (ref: string) => void, notifier: Pick<import("./safe-notify.js").SafeNotifier, "notifyAsync">): Promise<{
    readonly text: string;
} | undefined>;
/** Whether a peer accepts follow-up messages on a dispatched `peer_task`. */
export declare const PEER_TASK_FOLLOW_UPS: readonly ["accepted", "not_accepted"];
export type PeerTaskFollowUps = (typeof PEER_TASK_FOLLOW_UPS)[number];
/** Cancellation state of a `peer_task` row. */
export declare const PEER_TASK_CANCEL_STATES: readonly ["not_requested", "requested", "confirmed"];
export type PeerTaskCancelState = (typeof PEER_TASK_CANCEL_STATES)[number];
/** Peer-reported deadline clock state (`sema.deadline.clock`); not minted in this release. */
export declare const PEER_TASK_CLOCK_STATES: readonly ["running", "paused"];
export type PeerTaskClockState = (typeof PEER_TASK_CLOCK_STATES)[number];
/** Target of a `peer_task` reminder; not minted in this release. */
export declare const PEER_TASK_REMINDER_TARGETS: readonly ["peer", "peer_owner", "peer_approver"];
export type PeerTaskReminderTarget = (typeof PEER_TASK_REMINDER_TARGETS)[number];
/** Disposition of one `peer_task` reminder attempt; not minted in this release. */
export declare const PEER_TASK_REMINDER_DISPOSITIONS: readonly ["due", "skipped_not_sent", "sent", "received", "answered"];
export type PeerTaskReminderDisposition = (typeof PEER_TASK_REMINDER_DISPOSITIONS)[number];
/** Where the serving peer routed a received/answered reminder; not minted in this release. */
export declare const PEER_TASK_REMINDER_ROUTES: readonly ["pending_list", "run", "none"];
export type PeerTaskReminderRoute = (typeof PEER_TASK_REMINDER_ROUTES)[number];
/** Reminder disposition facet on a reminder `event` frame; not minted in this release. */
export interface PeerTaskReminderFacet {
    readonly n: number;
    readonly target: PeerTaskReminderTarget;
    readonly disposition: PeerTaskReminderDisposition;
    /** Present only when `disposition` is `"received"` or `"answered"`; not minted in this release. */
    readonly routedTo?: PeerTaskReminderRoute;
}
/** Facade on `task_type: "peer_task"` notification frames. Every member is optional on the wire shape;
 *  `reminder` and `peerFinalBy` / `approvalBy` / `clock` are reserved and not minted in this release. */
export interface PeerTaskNotification {
    readonly destination?: AskDestination;
    readonly followUps?: PeerTaskFollowUps;
    readonly cancel?: PeerTaskCancelState;
    readonly waitingFor?: A2AWaitingFor;
    readonly remoteMayContinue?: true;
    readonly ackBy?: number;
    readonly finalBy?: number;
    /** Reserved for deadline-extension responses; not minted in this release. */
    readonly peerFinalBy?: number;
    /** Reserved for deadline-extension responses; not minted in this release. */
    readonly approvalBy?: number;
    /** Reserved for deadline-extension responses; not minted in this release. */
    readonly clock?: PeerTaskClockState;
    /** Reserved for reminder frames; not minted in this release. */
    readonly reminder?: PeerTaskReminderFacet;
}
/** Input to {@link peerTaskNotification} (internal builder; reserved reminder and deadline-extension members are excluded). */
export interface PeerTaskNotificationInput {
    readonly task_id: string;
    readonly status: TaskNotificationStatus;
    readonly seq: number;
    readonly summary: string;
    readonly result?: string;
    readonly error?: string;
    readonly errorCode?: string;
    readonly stoppedBy?: TaskNotificationPayload["stoppedBy"];
    readonly outcome?: import("./member-outcome.js").MemberOutcome;
    readonly completionId?: string;
    /** True iff this `status: "event"` frame carries a late result arriving inside the overdue tail. */
    readonly overdueTail?: boolean;
    readonly peerTask: {
        readonly destination: AskDestination;
        readonly followUps: PeerTaskFollowUps;
        readonly cancel: PeerTaskCancelState;
        readonly ackBy: number;
        readonly finalBy: number;
        readonly waitingFor?: A2AWaitingFor;
        readonly remoteMayContinue?: true;
    };
}
/** Pure builder for `peer_task` frames (internal to core; no live run emits outward frames in this release).
 *  Mints `noWake: true` iff `overdueTail === true && status === "event" && destination.boundary === "outside"`.
 *  Never mints reserved reminder or deadline-extension members (`peerFinalBy`, `approvalBy`, `clock`, `reminder`). */
export declare function peerTaskNotification(input: PeerTaskNotificationInput): TaskNotificationPayload;
/** Highest `engine_frame` codec version this engine reads (D1-b: writer picks the lowest readable version per frame). */
export declare const ENGINE_FRAME_CODEC_VERSION = 2;
/** The engine's own lanes — the only frames the durable park may encode (an `external` event never is). */
export declare const ENGINE_FRAME_TASK_TYPES: readonly ["background_agent", "monitor", "workflow", "peer_task"];
/** Lowest codec version whose reader understands `taskType` (D1-b: v2 for `peer_task`, v1 for the three original lanes). */
export declare function engineFrameCodecVersionFor(taskType: TaskNotificationPayload["task_type"]): number;
/** May this frame take the durable engine-frame park? Its lane must be one of the engine's own and it
 *  must wear no shell-less carrier. */
export declare function isEngineFrameParkable(payload: TaskNotificationPayload): boolean;
/** The record text of a durably parked engine frame: the lowest codec version that reads this lane
 *  ({@link engineFrameCodecVersionFor}), the injection tier, and the frame itself. */
export declare function encodeEngineFrame(payload: TaskNotificationPayload, priority: SystemInjectionPriority): string;
export type EngineFrameDecode = {
    ok: true;
    payload: TaskNotificationPayload;
    priority: SystemInjectionPriority;
}
/** A version this engine does not read: the record is a NEWER engine's; leave it for one. */
 | {
    ok: false;
    reason: "newer";
    codecVersion: number;
}
/** Not this codec at all (or a frame outside the engine's lanes): settle it without delivery. */
 | {
    ok: false;
    reason: "malformed";
    detail: string;
};
/** Read an `engine_frame` record back. Every field the lane reads is re-typed here; a carrier the
 *  writer must never have encoded is dropped rather than trusted. */
export declare function decodeEngineFrame(content: string): EngineFrameDecode;
/** The durable form of an engine frame: the codec text under `kind: "engine_frame"`, stamped with
 *  the box owner as `fromRoot` (the park seat's own fact, as for a peer-words record) and with the occupant the frame is
 *  addressed to (`occupant`, when the address has one); no hop chain — it is not a peer message and is never admitted as one. */
export declare function engineFrameRecordOf(payload: TaskNotificationPayload, priority: SystemInjectionPriority, to: Pick<SessionAddress, "sessionId" | "occupant">): MailboxAppendMessage;
/**
 * RB-375 A2 (ruled 2026-08-03) — is this frame the TERMINAL of a delegated background agent?
 *
 * It is the one notification class whose audience is the whole DELEGATION TREE rather than the
 * session that produced it: the frame answers "the work you delegated is over", and the party that
 * asked for the work is the conversation at the root of the tree, not necessarily the run that
 * happened to issue the spawn call. Every other class (a shell completion, a Monitor batch, a
 * SendMessage delivery, an external `notify()` event) is addressed to THIS session and stays there.
 *
 * Reuses {@link TERMINAL_STATUSES} — the same terminal-vs-event rule the pending store's eviction
 * preference applies, so "terminal" can never mean two things in this module.
 */
export declare function isDelegatedAgentTerminal(n: Pick<TaskNotificationPayload, "task_type" | "status">): boolean;
/**
 * design/373 (#445 saturation prerequisite) — is this frame a TERMINAL notification (any lane)?
 * Reuses {@link TERMINAL_STATUSES} — the same terminal-vs-event rule the pending store's eviction
 * preference applies, so "terminal" can never mean two things in this module. The runner marks
 * INTERNAL-lane terminal frames cap-preferred at the delivery queue's mouth: a watcher's event
 * storm may delay its own batches, never crowd a completion out of the run waiting on it. The
 * external lane never gets the preference (its `status` is caller-supplied — an untrusted injector
 * must not be able to claim the internal completions' reservation); this predicate itself stays
 * lane-blind, the trust cut is the marking site's.
 */
export declare function isTerminalTaskNotification(n: Pick<TaskNotificationPayload, "status">): boolean;
/**
 * THE completion-sink resolution every background producer reads — a background command, a Monitor watch, a background
 * agent, a workflow run: the run lane the call carries (`ToolExecuteContext.onTaskNotification`) when there is one, else
 * the mount's own sink. One value per launch: the producer judges "will a completion reach the model" by it, delivers
 * through it, and owes its terminal frame to it ({@link oweTerminalDelivery}) — never one sink for the judgment and
 * another for the delivery. A parked agent's redemption takes over the debt its park left owed (it opens the next cycle;
 * the park sent no frame): when the call carries no lane of its own, its lane is the one that park recorded
 * (`TaskRegistry.parkedCompletionSink`) where this process's registry holds the park, else the tree root's session through
 * the runner's route while that root has a durable box the route reaches, else the mount's own sink.
 */
export declare function resolveCompletionSink<C, M>(callSink: C | undefined, mountSink: M | undefined): C | M | undefined;
/**
 * THE background admission every producer applies at launch — a background command, a Monitor watch, a background
 * agent, a workflow run, a continued agent: the launch is made only when its completion will come back — the one
 * resolved completion sink ({@link resolveCompletionSink}) is there, or the deployment wired a channel of its own for
 * this producer outside the engine (a workflow's durable notifier; a host that announces a continued agent itself).
 * No channel ⇒ no background launch: an agent runs synchronously instead, every other producer refuses before any
 * side effect. Judged at the call, never at the mount — a mount cannot know the run lane a call will carry (a
 * caller-mounted tool gets its run's lane on the call's context only) — so a mount offers its background option on its
 * own capability, and every "you will be notified" a face says holds for any launch this admits.
 */
export declare function admitsBackgroundLaunch<S>(sink: S | undefined): sink is S;
export declare function admitsBackgroundLaunch(sink: unknown, deploymentChannel: boolean): boolean;
/**
 * The terminal frames a run's notification lane is still OWED — the one book a one-shot submission's ending waits on.
 * A loop-type background task (a background agent, a continued agent, a workflow run) whose completion sink is a run's
 * lane is entered when it is admitted ({@link oweTerminalDelivery}, on the sink it will deliver through); its terminal
 * frame reaching that sink discharges it — whatever the lane then does with the frame (queues it for this run, or parks
 * it for the session's next run): either way nothing more for that cycle will arrive on this lane. A debt is per CYCLE:
 * an agent continued while its previous cycle's frame is still on its way owes two frames, and one frame — counted once,
 * by its identity (`taskNotificationDedupKey`) — settles one. A debt is booked under the task's lane key
 * ({@link taskNotificationLaneKey}, the pending store's own bucket key): admission, discharge and release all name the
 * task by the frame it delivers, so a frame of another lane carrying the same `task_id` settles nothing here. A background
 * command or a Monitor watch never enters: its lifetime is its process's (it may never end), and a one-shot ending treats
 * it by the run's teardown rules without waiting. A sink no lane bound (a host's own) owes nothing.
 *
 * A cycle that PARKS on an approval sends no frame: its debt stays where it was booked and passes to the cycle the
 * redemption opens (the parked cycle's frame is never sent, so one frame is still owed) — the redemption books nothing
 * new, and its frame settles that debt. Where the redemption completes into another lane, the debt moves there when the
 * approval is consumed ({@link moveTerminalDelivery}) — one handle, one debt.
 */
export declare class DeliveryObligations {
    /** lane key → admitted cycles whose terminal frame has not reached the sink. */
    private readonly owed;
    /** The terminal frames already counted (their dedup keys): a repeat of one settles nothing more. */
    private readonly counted;
    private readonly wakers;
    /** When the waiting stops whatever is still owed (monotonic) — set by the first wait, never moved; `null` once a first wait ran
     *  with no ceiling of its own. */
    private waitDeadline;
    /** The wait ended at its ceiling with something still owed — the one fact `task.wait_ceiling_reached` is minted on. */
    private stoppedAtCeiling;
    owe(task: Pick<TaskNotificationPayload, "task_id" | "task_type">): void;
    discharge(frame: TaskNotificationPayload): void;
    /** A cycle whose terminal frame was voided before it reached the sink (a continuation dropped its deferred frame) owes
     *  nothing more: one debt is released, the same way its frame would have released it. */
    retire(task: Pick<TaskNotificationPayload, "task_id" | "task_type">): void;
    private release;
    /** Wake a wait to re-check its condition (a discharge, or input the run can now drain). */
    wake(): void;
    /** The lane keys still owed (an internal lane's is its task id), in admission order. */
    get pending(): readonly string[];
    /** Resolves at the next wake, when `signal` aborts, or after `withinMs` — at once when nothing is owed, it has already
     *  aborted, or no time is left. */
    nextDischarge(signal: AbortSignal, withinMs: number): Promise<void>;
    /**
     * Wait out the debt the way a one-shot ending does: wake by wake, while something is owed, `keepWaiting()` holds (no
     * input is queued for the run yet, the run is not ending) and `signal` has not aborted — and never past `ceilingMs`, counted
     * from this book's first wait (`0` = no ceiling of its own: the walltime and the cancel still end it). The reference's same
     * wait reads `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS` (cli321.js:282495), its default `JQt` (cli321.js:282481) = 600 000, and its
     * `0` is (cli321.js:312481) "wait indefinitely"; the host's knob here is {@link oneShotWaitCeilingOf}. `onInput` subscribes a wake to every
     * input that reaches the run's queues meanwhile (a steer, a child's message, any engine note) — the wait re-checks. A wait that
     * ends at the ceiling with debt still owed is remembered ({@link stoppedWaitingAtCeiling}).
     *
     * Answers what ended THIS wait, read at the check that ended it, in the order the loop asks: nothing was owed (`"nothing_owed"`),
     * the debt was paid (`"discharged"`), `keepWaiting()` turned false (`"input"`), `signal` aborted while debt was still owed
     * (`"signal"`), or the ceiling (`"ceiling"`).
     */
    waitOut(signal: AbortSignal, keepWaiting: () => boolean, onInput: (wake: () => void) => () => void, ceilingMs: number): Promise<OneShotWaitEnd>;
    /** Did this book's last wait stop at its ceiling with something still owed, and was nothing admitted since? (What is still owed
     *  is {@link pending}.) */
    get stoppedWaitingAtCeiling(): boolean;
}
/** What ended one {@link DeliveryObligations.waitOut}. */
export type OneShotWaitEnd = "nothing_owed" | "discharged" | "input" | "signal" | "ceiling";
/** The ceiling a one-shot ending waits under: the host's `limits.oneShotWaitCeilingMs` (judged at the door; `0` = none of its
 *  own), else {@link ONE_SHOT_WAIT_CEILING_DEFAULT_MS}. */
export declare const oneShotWaitCeilingOf: (limits: {
    readonly oneShotWaitCeilingMs?: number;
} | undefined) => number;
/** The book a run's ending waits on: a one-shot submission's lane book ({@link DeliveryObligations.waitOut}); any other run waits on none. */
export declare const oneShotEndingBook: (oneShot: boolean | undefined, book: DeliveryObligations) => DeliveryObligations | undefined;
export declare function bindDeliveryObligations(sink: object, book: DeliveryObligations): void;
/** An admitted loop-type task owes `sink` its terminal frame — named by that frame's `task_id` and `task_type` (a no-op
 *  for a sink no run lane bound, or none). */
export declare function oweTerminalDelivery(sink: unknown, task: Pick<TaskNotificationPayload, "task_id" | "task_type">): void;
/** A cycle whose terminal frame will never reach `sink` (it was voided) releases its debt there (no-op for an unbound sink). */
export declare function retireTerminalDelivery(sink: unknown, task: Pick<TaskNotificationPayload, "task_id" | "task_type">): void;
/** A parked cycle's debt follows its redemption: released on the lane the park left it owed to (`from`, absent when this
 *  process holds no park of it), owed on the lane the redemption completes into (`to`) — nothing moves when they are one. */
export declare function moveTerminalDelivery(from: unknown, to: unknown, task: Pick<TaskNotificationPayload, "task_id" | "task_type">): void;
export interface DrainedPendingNotifications {
    /** Payloads still held when the session's next run drained. design/373 §3.5: batch order is
     *  PRIORITY-MAJOR (now < next < later; a record with no carried priority ranks AS later —
     *  the conservative seat), pend order (chronological) within a class — the idle-dequeue form. */
    items: TaskNotificationPayload[];
    /** design/373 §3.5 — the parked priority per item, keyed by payload identity, present exactly for
     *  records whose pend CARRIED one. A missing key is a fact (a tier-unknown park, one made by a caller
     *  that named none): the wire field stays honestly absent rather than fabricating `later`. The park seat
     *  always names a tier, so a frame it parks is never in that case. */
    priorities?: Map<TaskNotificationPayload, SystemInjectionPriority>;
    /** task_id → notifications evicted by the bounds while pending (never delivered). `taskType` remembers
     *  the victim's lane so a survivors-none disclosure can still render an honest synthetic payload. */
    /** Keyed by {@link taskNotificationLaneKey}, NOT the bare `task_id` — the external lane's ids are
     *  caller-supplied, so one bare-id row could cover two lanes and name only one of their types. `taskId`
     *  carries the victim's real id back out (the lane key is process-internal and must never be rendered). */
    dropped: Map<string, {
        count: number;
        taskType: TaskNotificationPayload["task_type"];
        taskId: string;
    }>;
    /**
     * Notifications lost when this whole SESSION was evicted by the
     * session-count cap, kept OUT of `dropped`. RB-91 folded them in under a `"(evicted-session)"` string
     * key, which put a session-level fact into a per-task ledger and broke twice for it: the key could
     * collide with a real, free-form external `task_id` (merging two unrelated counts and mislabelling the
     * lane — design/144 X1 already ruled that the external lane needs its own key space), and the
     * survivors-none renderer told the model to poll a task id `"(evicted-session)"`, an instruction with
     * nothing behind it. The count is a session fact; it now has a session field.
     */
    droppedWholeSession?: number;
}
/**
 * One run's seat in {@link SessionLiveNotificationLanes}: hand this payload to that run's live
 * injection queue. Four answers:
 *  · `"taken"` — newly enqueued on that run's lane; `onDisposition` (when supplied) is settled by the
 *    queue with the real outcome. Nothing is DELIVERED yet: the boundary can still refuse it;
 *  · `"pending"` — that lane already holds this exact key IN FLIGHT. `onDisposition` is NOT settled
 *    here: the in-flight entry owns the OUTCOME and this copy is no delivery;
 *  · `"duplicate"` — that stream has already DELIVERED this exact frame: nothing to enqueue, nothing
 *    to park; `onDisposition` is NOT settled, the word belongs to the caller;
 *  · `"unavailable"` — the lane can no longer take anything; the caller tries the next lane, and
 *    finally the parked store.
 */
export type LiveNotificationLane = (payload: TaskNotificationPayload, priority: SystemInjectionPriority, onDisposition?: (d: NotificationDisposition) => void) => "taken" | "pending" | "duplicate" | "unavailable";
/** One run's seat: its two entry points, plus the two bookkeeping verbs its owner drives. */
export interface LiveNotificationLaneSeat {
    /**
     * The entry for THIS run's OWN producers. It accepts whenever the lane is live: the frame is
     * enqueued (so the queue's own dedup folds a retry), the wire event goes out, and if the agent turns
     * out to be idle the steer's rejection parks it. No route-specific condition is allowed onto it.
     */
    readonly take: LiveNotificationLane;
    /**
     * The entry {@link SessionLiveNotificationLanes} holds (stable identity for register/withdraw) — a
     * frame ANOTHER run of the session is offering. It additionally requires that this lane can deliver
     * at this instant: accepting a foreign frame and then refusing it asynchronously strands it behind
     * this run's own parked-store intake, whereas declining hands it straight back to the router.
     */
    readonly takeAsDestination: LiveNotificationLane;
    /**
     * Record that this lane HANDED this frame away — to the session route, or to the park seat (it accepted the frame and
     * then could not deliver it: its agent was already idle, its backlog was full, or the run ended). The route entry then
     * refuses the key for good (the lane that handed it away must not be offered it by the route it took), remembered per
     * LANE rather than per delivery, so a route of any length terminates on the parked store; and the producer entry gives
     * the claim up, once per hand-away, when the frame comes back from the session's BOX (see `enter`). A lane that is no longer live records
     * NOTHING (it already answers "unavailable" by liveness). What IS remembered is bounded exactly like the queue's own
     * dedup set — same cap, same insertion-order eviction, and an evicted key is as re-deliverable here as it is there.
     */
    handOff(payload: TaskNotificationPayload): void;
    /** Drop that memory when the lane stops; every later answer is "unavailable" by liveness anyway. */
    release(): void;
}
/**
 * Build one run's lane seat over its injection queue: the SINGLE enqueue site a frame reaches,
 * whether the run produced it or another run of the same session routed it here — so the tier
 * routing, the dedup key and the already-delivered fold cannot fork between the two arrivals.
 */
export declare function createLiveNotificationLane(seat: {
    /** The run's injection queue; its subscriber is what routes an accepted frame by tier. */
    queue: SystemInjectionQueue;
    /**
     * Is the agent in a turn, so the boundary a frame would ride actually exists? Read LIVE, and read
     * ONLY by {@link LiveNotificationLaneSeat.takeAsDestination}.
     */
    canTakeNow: () => boolean;
    /**
     * Has this lane NOT been torn down? The gate for this run's own producers, and the gate on
     * remembering a handoff: a lane merely BETWEEN turns may take again in a moment, so what it handed
     * away must still be remembered; a lane that is over will never take anything.
     */
    isLive: () => boolean;
    /** Keys this run's stream already delivered at turn-open (the cross-layer double-park fold). */
    alreadyDelivered: (dedupKey: string) => boolean;
    /** Does the session hold this frame in its DURABLE box right now? (The seat's own record of what it parked there.) */
    parkedDurably: (dedupKey: string) => boolean;
}): LiveNotificationLaneSeat;
/**
 * The per-session LIVE LANE registry — the destination half of {@link PendingSessionNotifications}.
 * A run registers its injection lane once its session anchor is bound and withdraws it the moment the
 * lane stops accepting (a clean end, a throw, an abort — the run's own teardown), so an entry's
 * lifetime is exactly the lane's liveness.
 *
 * The key is the session the producing lane is ANCHORED to, so this is never a cross-session route: a
 * peer session's live run is not a destination, and a delegated child's own session is not its
 * parent's. A session with no live lane keeps the parked form unchanged.
 *
 * Several lanes may sit under one key: the NEWEST registration is tried first — "the session's current
 * run" — and every lane is tried once, so a lane that has stopped, or that has already handed this very
 * frame away, is passed over rather than swallowing it. A lane that refused a frame therefore cannot be
 * reached by it again, which is what makes a route of any length terminate on the parked store.
 *
 * A lane sits under its run's {@link SessionAddress}: a frame is offered only to the lanes of the occupant it is
 * addressed to ({@link sameOccupant}). A run of another occupant of the same id — the id deleted and created again,
 * by another principal or the same one — is never a destination for it; a run whose address names no occupant
 * ({@link addressNamesOccupant}) registers no lane here.
 */
export declare class SessionLiveNotificationLanes {
    private readonly lanes;
    register(address: SessionAddress, lane: LiveNotificationLane): void;
    /** Idempotent (a lane withdraws at its stop AND again at its outermost teardown). The key is dropped
     *  with its last lane so an idle process holds no per-session entry. */
    unregister(address: SessionAddress, lane: LiveNotificationLane): void;
    /**
     * Offer the payload to the addressed occupant's live lanes, newest first. The caller's OWN lane is not
     * special-cased: a lane that just refused this frame reports `"unavailable"` for it from then on.
     */
    deliver(address: SessionAddress, payload: TaskNotificationPayload, priority: SystemInjectionPriority, opts?: {
        onDisposition?: (d: NotificationDisposition) => void;
    }): "taken" | "pending" | "duplicate" | "unavailable";
    /** Does the addressed occupant hold a live lane here? */
    holds(address: SessionAddress): boolean;
    /** Sessions holding at least one live lane (observability + the tests' rollback detector). */
    get size(): number;
}
/**
 * What a double fault at the park seat leaves beside its in-process copy: the box the record was meant for (the binding
 * the seat asked, as it was then — the store object, scope and handle) and the record it asked with. The copy is a debt
 * owed to THAT box, settled by asking it again ({@link PendingSessionNotifications.settleBoxDebts}) — never by comparing
 * it with whatever box the session binds later.
 */
export interface SessionBoxDebt {
    readonly box: SessionBoxBinding;
    readonly record: MailboxAppendMessage;
}
/** A session's parked record as this store keeps it: the occupant it is parked for, the drained shape, its dedup keys, and the debt each copy owes its box (keyed by the copy). */
type PendingSessionRecord = DrainedPendingNotifications & {
    occupant: string | undefined;
    keys: Set<string>;
    boxDebts?: Map<TaskNotificationPayload, SessionBoxDebt>;
};
/** A per-session set of dedup keys (delivered, or parked durably), held for one occupant. */
type OccupantKeys = {
    occupant: string | undefined;
    keys: Set<string>;
};
/** The session's seat as its latest leg in this process admitted it ({@link PendingSessionNotifications.admit}). */
type SessionSeat = {
    readonly occupant: string | undefined;
    readonly box?: SessionBoxBinding;
};
/**
 * Would a session's durable box take this frame? A peer's words (`agentMessage`) always; the engine's own frame (one of
 * {@link ENGINE_FRAME_TASK_TYPES}, wearing no shell-less carrier) only where the deployment declares every drainer reads the codec
 * (`sessionBoxEngineFrames: true` — any other value is "no"). The question the park seat asks of the box it holds, and the one a
 * host asks with its own deps: whether the frame parks there at all is the box binding's business — a frame with a live lane to
 * take it never parks, and a delegated child, an ungrammatical id or a deployment without a cross-process-safe mailbox has no box.
 */
export declare function parksInSessionBox(payload: TaskNotificationPayload, deployment: {
    readonly sessionBoxEngineFrames?: boolean;
}): boolean;
/**
 * The session route's state — what {@link PendingSessionNotifications} answers "where does a notification addressed to
 * session S go?" from: the parked records, the live lanes, the delivered and durably parked keys, each session's current
 * occupant and box binding, and the eviction tombstones. It belongs to a session store object and a mailbox object
 * together ({@link sessionRouteTableOf}): every Runner of a process over that pair reads this one table, so a frame parked
 * or routed by one of them is the next leg's on any of them. Each bound counts once per table, whatever the number of
 * Runners reading it. Not checkpointed and process-local, as the producers that feed it are.
 */
export declare class SessionRouteTable {
    /** Each session's parked record (insertion-ordered: the oldest session is the first evicted). */
    readonly sessions: Map<string, PendingSessionRecord>;
    /**
     * The LIVE half of the same question the parked records answer. Together they are one seat — "where does a
     * notification addressed to session S go?" — with two answers: the session's live lane when it has
     * one, the parked queue when it does not. One table, one lifetime, one key (the session address).
     */
    readonly liveLanes: SessionLiveNotificationLanes;
    /** Whole sessions evicted by {@link MAX_PENDING_SESSIONS} (their pendings were never delivered). */
    droppedSessions: number;
    /**
     * A TOMBSTONE per whole-session eviction, so that session's next drain
     * can still say what it lost. The two item-level caps disclose their drops per task (they mutate a
     * surviving session's `dropped` map), but the session-count cap deleted the whole record and only
     * bumped a global, unattributed counter — from the evicted session's point of view its next drain
     * returned `undefined`, which is exactly what "nothing ever happened" looks like. The class contract
     * says every drop is disclosed on delivery and never silent; this arm was the exception.
     * Bounded like the sessions map itself (a tombstone is two numbers and a lane tag).
     */
    readonly evictedSessions: Map<string, {
        occupant: string | undefined;
        count: number;
    }>;
    /** Whole-session losses whose tombstone was itself evicted — the count survives, the attribution
     *  does not. Surfaced on the next session-level disclosure so it is never simply forgotten. */
    unattributedDrops: number;
    /** Each session's current occupant and its durable park backend ({@link SessionBoxBinding}) as the session's latest leg on any
     *  Runner reading this table admitted it — the binding, its `onError` included, is that leg's; insertion-ordered, bounded. */
    readonly seats: Map<string, SessionSeat>;
    /**
     * Keys a live lane of this session has already put in front of a model (the delivered half of the
     * ledger {@link PendingSessionNotifications.holdsKey} reads). Kept beside the parked keys because the WINDOW is the session's,
     * not any one run's: the destination run's own queue dedup dies with it. Released at drain, exactly like the
     * parked keys. Bounded like everything else here; an evicted key only ever costs a duplicate in the
     * extreme, never a loss.
     */
    readonly routed: Map<string, OccupantKeys>;
    /** Keys the session's DURABLE box took ({@link routeOrParkNotification}'s durable arm) — the third holder
     *  {@link PendingSessionNotifications.holdsKey} consults, so a retry of a frame the box already holds folds exactly as one the
     *  in-process store holds. Bounded like {@link routed}; a key is released when the append faulted and
     *  the frame took the in-process park instead (that store then owns it). */
    readonly durable: Map<string, OccupantKeys>;
}
/**
 * The session route table of `store` and `mailbox` — the one table every Runner over that pair reads (made on its first ask).
 * The same pair is the same two OBJECTS (no mailbox — absent or `null` — on both sides counts as the same): a store wrapped in
 * another object, a second handle onto the same backend, or another mailbox object is another pair, with its own table.
 * `engineFrames` is the asking Runner's box floor (`sessionBoxEngineFrames === true`). A pair with a mailbox registers one floor
 * for as long as its store lives, and a Runner declaring the other is refused here (`config.session_box_floor_mismatch`) — two
 * declarations of whether every drainer of these boxes reads the codec cannot both be true. Without a mailbox there is no box,
 * and the floor decides nothing, so nothing is compared.
 */
export declare function sessionRouteTableOf(store: object, mailbox: object | null | undefined, engineFrames: boolean): SessionRouteTable;
/**
 * Where a notification addressed to a session goes ({@link SessionAddress}): its live lanes, its durable box, its parked
 * records — every seat held for ONE occupant of the session id. The session's CURRENT occupant is the one its latest leg in
 * this process acquired ({@link admit}): an acquire answers the row as it stands, a row created again under the id is
 * another occupant, and an occupant once replaced never stands again. So from an admission on, whatever is addressed to,
 * or kept for, another occupant of that id is discarded — announced `delegation.delivery_discarded` (operator), never
 * delivered and never silent. A session no leg of which was admitted here (or whose seat aged out of the bound) has no
 * current occupant on record: its frames park under their own address and are judged by the leg that drains them — in the
 * durable box the unseated box seat judges for an address that names its box's scope, else in process.
 *
 * One Runner's view of a {@link SessionRouteTable}: the state is the table's (shared by every Runner over the same session store
 * and mailbox objects), the two seats are this view's own — a discard this view makes is announced on its Runner's notice
 * sink, and the box of a session the table holds no seat for is judged by its Runner's deployment. A view built without a
 * table holds a table of its own, registered on no store.
 */
export declare class PendingSessionNotifications {
    private readonly table;
    /** Where a discard is announced: the deployment's notice sink, read when the discard happens (absent ⇒ the process default seat). */
    private readonly noticeSeat;
    /** The durable box of a session this store holds no seat for, judged by the deployment as it stands when asked (absent ⇒ none). */
    private readonly unseatedBoxSeat;
    constructor(seats?: {
        readonly table?: SessionRouteTable;
        readonly onNotice?: () => ((notice: EngineNotice) => void) | undefined;
        readonly boxFor?: (address: SessionAddress & {
            readonly scope: string;
        }) => SessionBoxVerdict;
    });
    /** The table's live lanes ({@link SessionRouteTable.liveLanes}). */
    get liveLanes(): SessionLiveNotificationLanes;
    /** Whole sessions the table evicted by {@link MAX_PENDING_SESSIONS}. */
    get droppedSessions(): number;
    /**
     * A leg of the session has acquired its row as `address.occupant` — its current occupant from now on — and binds (or, with
     * `undefined`, unbinds) the session's durable box. Written at EVERY drain mount of a session's leg, so the binding tracks the
     * deployment's current seats (a mailbox swapped out unbinds at the next mount); a re-admission refreshes the entry's LRU
     * position. What this store still keeps for another occupant of the id — parked frames, their tombstone, their delivered and
     * durable keys — is addressed to a row that will never stand again: the frames are discarded, each announced.
     * A leg that could not read its occupant (`address.unread`) is no admission: the current occupant on record and what is kept
     * for it stand for the next leg that reads its own. A leg whose row holds no token is admitted (what is kept for another
     * occupant goes as above) but binds no box: nothing waits for it ({@link addressNamesOccupant}). A seat is aged out only while the store keeps no record for its session,
     * so a parked record is always judged against the occupant that parked it, never against whichever frame arrives next.
     */
    admit(address: SessionAddress, box: SessionBoxBinding | undefined): void;
    /** The addressed occupant's durable box. A session a leg of which this store admitted answers by its seat alone: the box that
     *  leg bound, never another occupant's. One it holds no seat for answers by {@link boxVerdictOf} — a judgment, not an
     *  admission: it writes no seat, and the occupant the box's drain hands the record to is judged there. An address that names
     *  no occupant has no box ({@link addressNamesOccupant}). */
    sessionBoxFor(address: SessionAddress): SessionBoxBinding | undefined;
    /** Does a leg of the session hold a seat on this table — so its next leg, on any Runner over the table, reads what is parked for it here? */
    holdsSeat(sessionId: string): boolean;
    /** The deployment's judgment of the address's durable box at the scope the address names (the unseated box seat, read now) —
     *  what the route reads for a session no leg of which is seated here; `undefined` when the address names no scope or the
     *  store was handed no seat. */
    boxVerdictOf(address: SessionAddress): SessionBoxVerdict | undefined;
    /** A completion addressed to `address` (a delegation tree's root, by a drive with no run lane of its own) through this store's
     *  route ({@link routeOrParkNotification}): its sink while the deployment judges the address a durable box that takes engine
     *  frames ({@link boxVerdictOf}) — the route then reaches its live run here, else its seat here, else that box — or why not.
     *  An address that names no occupant keeps the route: its door discards each frame and announces it ({@link discardsStale}),
     *  so no frame of such a tree leaves for another channel.
     *  `unkept` takes a frame the box of a session seated nowhere here failed twice (the route keeps no copy of it). */
    completionLaneOf(address: SessionAddress, unkept?: TaskNotificationSink): SessionCompletionLane;
    /**
     * Is `address` an earlier occupant of a session whose current occupant is another? Then the frame is discarded here —
     * announced with the seat it would have reached under the current occupant — and the answer is `true`: nothing routes,
     * parks or folds it. `false` for the current occupant, and for a session with no current occupant on record. An address
     * that names no occupant ({@link addressNamesOccupant}: unread, or no token) is no seat's: its frames are discarded the same
     * way, whatever the seat.
     */
    discardsStale(address: SessionAddress, payload: TaskNotificationPayload): boolean;
    /**
     * The same question for a delegated leg's user-face notice, addressed to its tree's root: is `destination` (the root's id
     * and the occupant the tree was born under) an earlier occupant of a session whose current occupant is another? Then the
     * notice is discarded — announced with path `notice` — and the answer is `true`: the leg delivers nothing. `false` for the
     * current occupant, and for a root no leg of which this process admitted. A notice cannot wait for the root's next leg
     * the way a frame parks, so a root that was created again but not yet admitted here is not known to be another occupant.
     */
    discardsStaleNotice(destination: SessionAddress, delivery: DiscardedDelivery): boolean;
    /** The one judgement both discards read: `undefined` when `address` is the session's current occupant, or the session has
     *  none on record; else the seat it was judged against (absent for an unread address on a session with no seat). */
    private staleAgainst;
    /** The one place a discarded delivery is announced. */
    private announceDiscard;
    /** Discard a record parked for an occupant the session no longer holds: every frame in it is announced; the record's own
     *  bookkeeping (its eviction counts, its box debts) belongs to that occupant and goes with it. */
    private discardRecord;
    /** The session's record when it is parked for the addressed occupant. */
    private recordOf;
    /**
     * Settle what the session's pending copies owe their boxes ({@link SessionBoxDebt}): each is asked of its own box once
     * more, under its record, in pend order. A box that answers took the record — it holds it, or received it already —
     * so the delivery is the box's and the copy is dropped (the box then owns the key, as after a durable park). A box
     * that refuses, whatever the refusal, is disclosed once on that binding and the copy stays an ordinary pending
     * notification. Never rejects. `undefined` when nothing is owed: a leg with no debt takes no store round trip. ONE
     * pass over what is owed when it starts, stopped by `signal`: a debt that arrives meanwhile, or one an abort left
     * unasked, stays owed — and a copy that owes its box is never drained ({@link drain} keeps it back) — until a later
     * leg's settlement asks.
     */
    settleBoxDebts(address: SessionAddress, signal?: AbortSignal): Promise<void> | undefined;
    /** What a drain hands out of a parked record: everything but the copies that still owe their box and the frames the drainer does not
     *  read (`readsTaskFrame`: a `peer_task` frame where its deployment does not declare them) — those go back into the store as the
     *  session's record (with their occupant, keys, tiers and debts) for the leg that settles or reads them. */
    private keepBackOwing;
    private settleBoxDebt;
    /** Park a frame for the addressed occupant's next run. A frame addressed to an occupant the session no longer holds is
     *  discarded ({@link discardsStale}); a record kept for another occupant of an id no leg of which this process admitted (a
     *  record-holding seat is never aged out) names one of the two only — the newer arrival's record replaces it, its frames
     *  announced as discarded. `true` = the frame is
     *  parked for the address (a repeat of a parked key folds into it); `false` = discarded. */
    pend(address: SessionAddress, n: TaskNotificationPayload, priority?: SystemInjectionPriority, debt?: SessionBoxDebt): boolean;
    /** Remove and return the session's pendings (one-shot — the next run consumes them exactly once); a copy that
     *  still owes its box stays parked for the leg that settles it ({@link settleBoxDebts}), and a frame the drainer does not read
     *  (`reader`: its deployment's switches, read by `readsTaskFrame`; none handed ⇒ no `peer_task` frame is read) stays for a run that reads it.
     *  design/373 §3.5: the batch comes out PRIORITY-MAJOR (stable sort — pend order within a class;
     *  a no-priority record ranks as later), the idle-dequeue min-value-first form. */
    drain(address: SessionAddress, reader?: Parameters<typeof readsTaskFrame>[0]): DrainedPendingNotifications | undefined;
    /**
     * Does this session's addressed occupant ALREADY own this exact frame — parked, or routed onto a live lane? Only one of
     * the two may hold a key: a producer retrying a frame the session has already taken must FOLD rather
     * than be handed to whichever run has since gone live, which would deliver it there and again at the
     * next drain. Callers ask BEFORE routing and BEFORE parking. Another occupant's keys answer nothing here.
     */
    holdsKey(address: SessionAddress, dedupKey: string): boolean;
    /** Is this frame parked in the addressed occupant's DURABLE box (the seat took it there and the append has not faulted twice)? */
    holdsDurably(address: SessionAddress, dedupKey: string): boolean;
    /** The durable box took this frame for the addressed occupant ({@link SessionRouteTable.durable}). */
    noteDurablePark(address: SessionAddress, dedupKey: string): void;
    forgetDurablePark(address: SessionAddress, dedupKey: string): void;
    /** Record that this session's addressed occupant has DELIVERED this frame — see {@link SessionRouteTable.routed}. Written at ONE place, the
     *  harness's consumption sink (the step where a queued frame enters the model's input), so the record
     *  can never run ahead of the delivery it claims. An address that names no occupant keeps no key: no route reads one for it
     *  ({@link addressNamesOccupant}). */
    markDelivered(address: SessionAddress, dedupKey: string): void;
    get size(): number;
}
/**
 * The durable box appends ONE run leg caused — its obligations. Attribution is by execution: an append
 * belongs to the leg whose execution (its tools, its producers, its teardown reap, a child terminal it
 * hands up the delegation chain) reached the park seat, whichever lane's routing carried it there. A
 * leg's teardown awaits its own obligations and nobody else's — another session's pending append is
 * never a condition of this leg's completion. A park reached outside any leg is nobody's obligation.
 */
export declare class DurableAppendObligations {
    private static readonly scope;
    private readonly inFlight;
    /** The obligations of the leg whose execution is running now; undefined outside every leg. */
    static current(): DurableAppendObligations | undefined;
    /** Run `body` as this leg (synchronous: the body's own return value, no added tick). */
    run<R>(body: () => R): R;
    track(p: Promise<unknown>): void;
    /** Resolves when every append this leg caused has settled — the fault arm already re-parked in process. */
    settle(): Promise<void>;
}
/**
 * WHERE A FRAME ADDRESSED TO ONE SESSION GOES — the single decision, so the two addresses that ask it
 * (a run's own session, and the delegation tree's root anchor — a revived run's lane, a lane-less drive's completion) cannot
 * drift apart. Three outcomes:
 *  · the session ALREADY OWNS the key (parked, or routed onto a live lane) ⇒ fold — neither route it
 *    nor park a second copy; `"parked"` is the word a folded repeat has always been given;
 *  · a live lane takes it ⇒ it rides that run's next turn boundary. This decision records NOTHING in
 *    the ledger: a destination that ACCEPTED a frame can still refuse it at its boundary and park it
 *    then, so only the lane that actually delivers writes ownership
 *    ({@link LiveNotificationLaneSeat.markDelivered});
 *  · nothing can take it ⇒ park, carrying the tier, for the session's next run.
 * The address names the session's occupant ({@link SessionAddress}): every one of the three is that occupant's — its keys,
 * its live lanes, its box, its record — and a frame addressed to an occupant the session no longer holds is discarded
 * before any of them ({@link PendingSessionNotifications.discardsStale}); its receipt says `"refused"`. `onUnkept` is told,
 * before that receipt, when the refusal is the one that keeps nothing: the box of a session seated nowhere here failed twice.
 */
export declare function routeOrParkNotification(store: PendingSessionNotifications, address: SessionAddress, payload: TaskNotificationPayload, priority: SystemInjectionPriority, onDisposition?: (d: NotificationDisposition) => void, onUnkept?: () => void): void;
/**
 * THE PARK SEAT, third outcome of {@link routeOrParkNotification} and the one road a recovered frame takes: the frames a
 * run's queue held and no one delivered (the end-of-run sweep, and the one a full backlog displaces mid-run) are parked here
 * DIRECTLY — not through the arrival judgments before it (fold on a key the session already took, offer to a live lane),
 * because those judge a frame ARRIVING: a frame the run's consumption sink or turn-open ledger marked as taken, but whose
 * delivery never completed, is exactly what the sweep exists to keep, and the lane it was queued on is the one lane that
 * must not be offered it again. The address's own occupant is judged here as everywhere ({@link PendingSessionNotifications.discardsStale}).
 * Every parked frame carries a tier, in process and in the box alike.
 */
export declare function parkAtSeat(store: PendingSessionNotifications, address: SessionAddress, payload: TaskNotificationPayload, priority: SystemInjectionPriority, onDisposition?: (d: NotificationDisposition) => void, onUnkept?: () => void): void;
/**
 * The durable form of a parked peer-words frame: the SAME `peer_message` record the cross-session lane
 * appends (the recipient's drain renders it through the one envelope and judges it through the one
 * admission gate), with `fromRoot` = the box owner's own session — a frame reaches this seat only
 * through the injector its owner handed to a child of its tree, so the same-tree fact is the seat's to
 * state, not the producer's to claim.
 */
export declare function sessionBoxRecordOf(payload: TaskNotificationPayload & {
    agentMessage: {
        from: string;
        body: string;
    };
}, to: Pick<SessionAddress, "sessionId" | "occupant">): MailboxAppendMessage;
/**
 * Delivery-side overflow disclosure: fold the per-task drop counts into the drained payloads. Two
 * carrier shapes, chosen per survivor:
 *  · a CLASSIC survivor (renders through the `<task-notification>` shell) is annotated IN PLACE — the
 *    first surviving payload of a task that lost events gets a `[task_id]`-prefixed disclosure line
 *    prepended to its summary (backgroundTasks 同规: the id keeps the loss addressable);
 *  · an AGENT-MESSAGE survivor (design/385 §1.4 d1; renders as the `<agent-message>` carrier, its
 *    `summary` wire-only) is left byte-unchanged, and the disclosure rides as a SEPARATE engine-authored
 *    `event` payload inserted immediately AHEAD of it (engine speech never goes inside a peer frame;
 *    peer speech never goes inside the authority shell that line renders through).
 * The returned array is therefore NOT a 1:1 image of `drained.items`: it can be longer (one inserted
 * line per disclosed agent-message lane, plus the per-lane "nothing survived" lines and the
 * whole-session line below) — consume it by iteration, never by index-pairing against `items`. The
 * zero-disclosure path returns `drained.items` itself (identity, no allocation). A task whose EVERY
 * pending item was evicted still gets one honest synthetic `event` payload saying so — a fully silent
 * loss is never allowed. `readHandleOf` = the leg's reading of a task's read handle (`Prepared.taskReadHandleOf`): that
 * synthetic line names where the task's output or result is read, or that its row is no longer readable from this run.
 * `tasks` = the leg's background-task table, finished rows included (`Prepared.listBackgroundTasks({ settled: true })`):
 * a whole-session loss names no task, so its line carries that table instead — every task the run can still reach, live
 * or finished, and where each is read — or says the run has none. A caller with neither reading claims nothing.
 */
export declare function discloseDroppedPending(drained: DrainedPendingNotifications, readHandleOf?: (taskId: string) => string | undefined, tasks?: () => ReadonlyArray<BackgroundTaskTableRow>): TaskNotificationPayload[];
/** One task as the background-task table lists it: its id (TaskStop addresses it), its description, its status, and its read
 *  handle (`TaskRegistry.readHandleOf`) — where its output or result is read; absent = nothing to read yet. */
export interface BackgroundTaskTableRow {
    id: string;
    description?: string;
    status: string;
    read?: string;
}
/**
 * THE background-task table body — every model-facing list of a run's background tasks renders through it (the
 * post-compaction announce, a whole-session loss line). The per-task status phrase is the reference's attachment-renderer
 * wording (cli309.js:296735) "completed in background" — completed → "completed in background" · killed → "stopped" ·
 * running → "still running in background" · anything else → the raw status (CC's own fallback arm); the line mirrors CC's
 * `Task "${description}" ${phrase}` with the sema task_id prefixed and the row's read handle after it. A capped list says
 * how many it left out, so a short count is never passed off as the whole.
 */
export declare function renderBackgroundTaskTable(tasks: ReadonlyArray<BackgroundTaskTableRow>): string;
export declare class SystemInjectionQueue<TPayload = TaskNotificationPayload> {
    private readonly queues;
    private readonly dedup;
    private readonly listeners;
    /** F4 observability: how many queued items were evicted by the retention cap (never delivered). */
    droppedOldest: number;
    enqueue(item: SystemInjection<TPayload>): boolean;
    /** Stop remembering a key: the frame it names left this queue's owner undelivered (handed to a park), so a later
     *  arrival of the same frame is enqueued, not folded into an entry that is no longer on its way. A delivered frame's
     *  key stays — it is what folds a duplicate. */
    forget(dedupKey: string): void;
    drain(priority?: SystemInjectionPriority): Array<SystemInjection<TPayload>>;
    subscribe(listener: (item: SystemInjection<TPayload>) => void): () => void;
    get size(): number;
}
