import type { MemoryControlObjectKind, MemoryGovernanceDocs, MemoryGovernanceObjects, MemoryOriginCause } from "./types.js";
import { type SessionPollutionObjects } from "./layout.js";
import { type ProcessCensus, type ProcessUncheckable } from "../process-identity.js";
/** A row's FIRST-WRITE status. Rows are immutable after their first write — every later transition
 *  is an append-only event ({@link SettlementEvent}); the effective status is the fold. */
export type SettlementRowStatus = "pending" | "unattestable";
/** The effective (folded) status vocabulary. */
export type SettlementStatus = "pending" | "clean" | "external" | "expired" | "void" | "unattestable";
/** One delegation's launch fact (write-ahead: this row lands BEFORE the delegation registers or
 *  invokes — a launch that cannot be accounted must not run). */
export interface DelegationSettlementRow {
    /** Background lane: minted at the write-ahead point (the launch site holds it thereafter).
     *  Sync lane: the injective `(sessionId, toolCallId)` encoding ({@link syncSettleId}). */
    settleId: string;
    sessionId: string;
    launchedAt: number;
    lane: "background" | "sync";
    status: SettlementRowStatus;
    /** The delegation TOOL CALL that launched this row (background lane) — the receipt-exemption
     *  anchor: a sync delivery claiming to be a background launch receipt is honored only when a
     *  write-ahead row for ITS OWN toolUseId exists (a status string alone must not buy the
     *  exemption — adversarial round 2's forged-receipt vehicle). */
    toolUseId?: string;
}
/** One append-only transition/annotation event. Idempotent per eventId. */
export interface SettlementEvent {
    settleId: string;
    eventId: string;
    at: number;
    kind: "settle" | "admin-resolve" | "annotation";
    /** For `settle`: the observed terminal (`"unattestable"` = the delegation terminated but its
     *  conduct is permanently unprovable — a recorder-less or incomplete chain). For `admin-resolve`:
     *  the host's ruling ("clean"|"external"). */
    status?: "clean" | "external" | "expired" | "void" | "unattestable";
    /** Audit attribution for `admin-resolve` (who asked — required there, refused absent). */
    requestId?: string;
    note?: string;
}
/** The injective sync-lane settleId: `encodeURIComponent` on both members keeps the separator
 *  unambiguous (neither side can smuggle a `:`), so `(sessionId, toolCallId)` is one-to-one. */
export declare function syncSettleId(sessionId: string, toolCallId: string): string;
/**
 * §3.3 write-ahead — land the pending row for a BACKGROUND delegation, before registration and
 * before invoke (行→注册→invoke). Idempotent per settleId (a revive cycle re-registers under a
 * fresh settleId; a crash-retry of the same launch replays the same row). Throws on an unwritable
 * or corrupt ledger — the launch site fails the launch loudly (a delegation that cannot be
 * accounted must not run: the whole point is that no child exists outside the account).
 */
export declare function registerDelegationLaunch(docs: MemoryGovernanceDocs, input: {
    settleId: string;
    sessionId: string;
    now: () => number;
    toolUseId?: string;
}): Promise<void>;
/**
 * §3.5 (r5-3) — the SYNC lane's unattestable row: a synchronous delegation delivered with a
 * missing/unknown attestation under the "attested-only" evidence standard. The row is a durable
 * TERMINAL at first write (there is nothing left to settle — the window is already closed
 * unprovable), and it must commit BEFORE the result enters the transcript: the caller treats a
 * throw here as "deliver an error instead" (fail-closed — unattested content must not ride into
 * the transcript of a session whose account could not record the fact).
 */
export declare function recordSyncUnattestable(docs: MemoryGovernanceDocs, input: {
    sessionId: string;
    toolCallId: string;
    now: () => number;
}): Promise<void>;
/**
 * §3.3 settle — append one observed terminal (idempotent per eventId; the default eventId keys on
 * (settleId, status) so an at-least-once observer replays into one event). Transition legality is
 * the FOLD's question, not the append's: an event that the fold rules out (e.g. `clean` arriving
 * after `expired`) still lands — as an event row the fold reads as an annotation-grade fact — so
 * the account never loses an observation (事件不丢), it just doesn't let it rewrite history.
 */
export declare function settleDelegation(docs: MemoryGovernanceDocs, input: {
    settleId: string;
    status: "clean" | "external" | "expired" | "void" | "unattestable";
    now: () => number;
    eventId?: string;
    note?: string;
}): Promise<void>;
/**
 * §3.3 host valve — `resolveSettlement(settleId, "clean"|"external", requestId)`. Advisory, same
 * trust plane as the host API family; `requestId` is the audit anchor and is REQUIRED (a
 * settlement resolution without attribution is refused loudly, #123 posture). Effective-state
 * semantics live in the fold: an admin `clean` flips the EFFECTIVE state (releases post-expiry)
 * but never the history bit, and a LATER observed `external` overrides it (观测证据>admin 裁决).
 */
export declare function resolveSettlementRecord(docs: MemoryGovernanceDocs, input: {
    settleId: string;
    to: "clean" | "external";
    requestId: string;
    now: () => number;
}): Promise<void>;
/** One settlement's folded (effective) view. */
export interface EffectiveSettlement {
    row: DelegationSettlementRow;
    /** The effective status after the fold (终局序: clean/external 互斥首达胜; external 可覆写
     *  expired; admin clean 翻 effective 不翻史; admin 之后的 observed external 再覆写). */
    effective: SettlementStatus;
    /** Monotonic history bit: an `external` was EVER observed (never cleared, admin included not —
     *  admin resolves are rulings, not observations). */
    everExternal: boolean;
    /** The terminal event whose identity keys the external-effects replay (undefined while pending). */
    terminalEventId?: string;
}
/** Lock-less folded read of the whole ledger (journal-aware, fail-closed on corruption). */
export declare function effectiveSettlements(docs: MemoryGovernanceDocs): Promise<EffectiveSettlement[]>;
/** One session's folded rows (the harvest classifier's input). */
export declare function sessionSettlements(docs: MemoryGovernanceDocs, sessionId: string): Promise<EffectiveSettlement[]>;
/**
 * §3.1 — the session exposure classifier over the settlement account (the durable pollution marker
 * is the OTHER input; the caller ORs them). `exposed` ⇔ any {external, unattestable, expired}
 * effective row; `pending` ⇔ not exposed ∧ any pending row. The mint cause follows the strongest
 * evidence: an external row is an observed fact; unattestable/expired are evidence windows that
 * closed unprovable (the static-standard cause).
 */
export declare function classifySessionSettlements(rows: readonly EffectiveSettlement[]): {
    state: "clean" | "pending" | "exposed";
    cause?: MemoryOriginCause;
    reason?: string;
};
/**
 * §3.3-4 — expire overdue pending rows (reconciliation's first leg). Every expiry is an event
 * (idempotent by (settleId, "expired") key); returns the settleIds newly expired this pass.
 */
export declare function expireOverdueSettlements(docs: MemoryGovernanceDocs, input: {
    timeoutMs: number;
    now: () => number;
}): Promise<string[]>;
/**
 * §3.3-2 — replay the EXTERNAL rows' side effects (账先落、副作用可重放): ensure the durable
 * pollution marker is in place (wx, first-write-wins) and the retroaction challenge sweep has
 * covered the session's unmarked committed contributions (eventId keyed to the terminal event —
 * a replay lands the SAME generation, a later terminal re-arms). Also enqueues the next-session
 * announcement once per terminal event. Idempotent throughout; the watermark only skips work.
 * `carry` scopes the sweep domain exactly like the engine's own sweeps (marked rows carry their
 * account under "carry"; the "off" width challenges everything).
 */
export declare function replayExternalSettlementEffects(docs: MemoryGovernanceDocs & SessionPollutionObjects, input: {
    carry: boolean;
    now: () => number;
}): Promise<Array<{
    settleId: string;
    sessionId: string;
}>>;
/** One member of the sticky set: the ledger form `(scope, rel)` — `rel` relative to the scope's
 *  home, `/`-separated. Location-free, so a home move never re-keys the membership. */
export interface UnattributedMember {
    scope: string;
    rel: string;
}
export interface SessionAccountRow {
    sessionId: string;
    openedAt: number;
    /** The scope this session writes (its write home) — the layer it is a live writer of until
     *  `terminatedAt` ({@link foreignWriterCandidates}). Absent on rows written before the field. */
    writeScope?: string;
    /** The session's leg ENDED here: its terminal harvest returned (whatever it admitted — a refused,
     *  zero-admission or budget-deferred pass ends the leg all the same), the host valve closed the
     *  row, or a writer reading proved its holding process gone ({@link legLive}). A lifecycle fact, independent of `closedAt` (every full harvest closes the account — a
     *  checkpoint harvest too — while the session may keep writing); cleared when a resume re-opens
     *  the row. */
    terminatedAt?: number;
    /** The LEG that holds the row now: minted by the materialize that opened (or re-opened) it and
     *  carried on that mount's handle. A close or a leg end made for another leg — an earlier leg
     *  whose harvest finished after a resume re-opened the row — is not this leg's and is not written. */
    leg?: string;
    /** The PROCESS that opened the current leg, written by that open ({@link openSessionAccount}). A leg
     *  whose process is proven gone is over ({@link legLive}): a process killed outright never runs the
     *  harvest that would have ended it. Absent on rows written before the field — such a leg cannot be
     *  proven over and reads as running, its refusals naming the host valve. */
    holder?: SessionAccountHolder;
    /** The STICKY unattributed set, frozen at materialize (§3.6 归属判据): pre-existing, uncommitted
     *  files seen while a FOREIGN dangling open row stood. Membership never shrinks on later writes
     *  (the sticky law); it clears only when the row is re-opened with a fresh classification (the
     *  residue was adjudicated by an intervening harvest). */
    unattributed: UnattributedMember[];
    /** The v1 members (memory-dir-relative paths) the registry could not attribute at the one-time
     *  conversion. Kept, never dropped; while any stands, EVERY membership question about
     *  this session answers "unattributed" (over-marking is the safe direction). */
    unattributable?: string[];
    closedAt?: number;
    /** r7-3 — the host valve closed this row WITHOUT adjudication: it stops dangling but keeps
     *  triggering the residue arm until the next FULL-domain harvest closes an account normally
     *  (an unadjudicated close must not launder the residue window it covered). */
    unadjudicated?: true;
}
/** The process holding a row's current leg: the leg, and the fingerprint (pid, start times, host, pid
 *  namespace where the host names one) of the process whose materialize opened it. */
export interface SessionAccountHolder {
    leg: string;
    pid: number;
    startedAtMs: number | null;
    startedSinceBootMs: number | null;
    host: string;
    /** Absent where the opening host names no pid namespace (macOS): the host name alone then decides
     *  whether a reader shares its process table. */
    pidNs?: string;
}
/** The one-time v1 key-form conversions of the three engine sidecars, in one call (each in its own
 *  lock, each idempotent). The layout adoption runs this before any later scope registration can
 *  change what a v1 key's first segment names. A step of the File layout's own upgrade: it converts
 *  the hold ledger and the session-account document the File store keeps under `controlDir`, in place
 *  (a store that keeps documents elsewhere never held the v1 form), and the control-plane adoption runs
 *  it on a replica before handing these documents to another store. It is the one converter: the
 *  readers below refuse the v1 form ({@link sessionAccountsV2}). */
export declare function convertV1SidecarKeys(controlDir: string): void;
/** The session-account document of `controlDir` converted in place when it stands in the v1 key form (in its lock);
 *  any other form — v2, absent, or one its readers refuse as corrupt — is left exactly as it stands. The control-plane
 *  adoption runs this before handing the document to another store (#3484): that store's readers refuse the v1 form,
 *  and nothing there converts it. The conversion is the File layout's own ({@link convertSessionAccounts}). */
export declare function convertV1SessionAccountsAt(controlDir: string): void;
/** The asking mount, excluded from {@link foreignWriterCandidates}: its own leg (another leg of the
 *  same session is another writer), its own session id, or both. */
export interface WriterCandidateSelf {
    sessionId?: string;
    leg?: string;
}
/** Why an open leg could not be proven over — each a reason it may still be running. */
export type LegUnprovable = 
/** The row records no process for its leg (written before the field, or before legs were recorded). */
"no_holder"
/** The recorded process opened an EARLIER leg: a later open replaced the leg without recording its own. */
 | "earlier_leg"
/** The row changed between the census and the record of its end (a resume re-opened it) — twice. */
 | "contended" | ProcessUncheckable;
/** A leg that is still open: proven running, or not provable either way (and why). */
export type LegStanding = {
    readonly state: "running";
} | {
    readonly state: "unprovable";
    readonly why: LegUnprovable;
};
/**
 * Is the row's leg still a writer? ONE rule: a leg is over when it was recorded over, or when the process
 * holding it is proven gone.
 *
 *  · RECORDED OVER — `terminatedAt` (its harvest returned, the host valve closed it, or an earlier census
 *    proved it gone). A row written before its leg or write scope was recorded keeps its own reading (the
 *    engine then closed the account at every full harvest, so only a never-closed row is a writer) and
 *    records no process this engine wrote, so its leg is never proven over by a census.
 *  · PROVEN GONE — the holder's process, judged by {@link processCensus}: only a pid this host's process
 *    table says does not exist, or one now held by a process that started after the holder did, is gone.
 *    Everything the census cannot establish — a holder from another host or pid namespace, one written
 *    without its namespace on a host that has one, no comparable start time — leaves the leg a writer.
 *
 * `gone` carries the holder the verdict was reached on: recording the end is conditional on the row still
 * naming that same holder ({@link foreignWriterCandidates}).
 */
export declare function legLive(row: SessionAccountRow, census: ProcessCensus): {
    readonly state: "ended";
} | {
    readonly state: "gone";
    readonly holder: SessionAccountHolder;
} | LegStanding;
/** The words for each {@link LegUnprovable}. */
export declare function legUnprovableText(why: LegUnprovable): string;
/** One candidate of {@link foreignWriterCandidates}: the account row as the reading answers it, and its leg —
 *  still open (proven running, or not provable either way, and why) or over. The row names no write scope where
 *  its layer is not known (written before the field; re-opened on another layer over a generation that never
 *  closed normally; changing again while the census read it): a writer of every layer. */
export type ForeignWriter = SessionAccountRow & {
    readonly standing: LegStanding | {
        readonly state: "ended";
    };
};
/** A leg the reading proved gone and recorded over — handed to the reader the moment its record lands, for the
 *  reader to say once (a reading that fails afterwards has handed it over all the same). */
export interface ProvenEndedLeg {
    readonly sessionId: string;
    readonly leg: string;
    readonly writeScope?: string;
}
/**
 * THE liveness reading of the session account — the one answer to "which other writers may have put bytes on
 * this layer since `since`, and which of them may still be writing". A row is asked about when it is not the
 * asking mount's ({@link WriterCandidateSelf}) and writes `layer` (or records no write scope — a writer of every
 * layer; `layer` absent asks about every layer). Its leg is judged by ONE rule ({@link legLive}): over when
 * recorded over, or when the process holding it is proven gone — and a leg proven gone is RECORDED over here
 * (`terminatedAt`, written only while the row still names the leg and holder the verdict was reached on: a resume
 * that re-opened the row in between is a live leg, and the census runs again on the fresh row, once; a row that
 * changes again stays a writer, of every layer — the scope this census read is no longer the one it holds). The
 * process table is asked once per pid however many rows name it, and outside the ledger's lock. Each leg this
 * reading records over goes to `onEnded` as its record lands.
 *
 * A row is a CANDIDATE when its leg is still open, or ended after `since`, or its account never closed (a terminal
 * harvest that deferred files, a failed prepare, a leg proven gone — none adjudicated the plane), or the host valve
 * closed it without adjudication; a row written before its leg and write scope were recorded, while its account
 * never closed or was valve-closed. The account close alone is not the answer (every full harvest closes it, a
 * checkpoint harvest too, while the leg keeps writing), and the leg end alone is not either (a deferred terminal
 * harvest ends the leg over files it never adjudicated).
 *
 * Its readers: the materialize residue arm (`since` = the mount) and the harvest's window (`since` = the handle's
 * last baseline) judge every candidate's state; the read-only-layer restore waits on the candidates whose leg is
 * open — the edit it must not overwrite is one a writer may still be making, and a leg that is over has made its
 * last (its unadjudicated bytes are the residue arm's to judge). The host audit reads it whole. Sessions that open
 * no row (no session id, provenance "off", an adoption-restricted mount) are not visible here. Throws on a corrupt
 * ledger.
 */
export declare function foreignWriterCandidates(docs: MemoryGovernanceDocs, input: {
    layer?: string;
    since: number;
    self: WriterCandidateSelf;
    now: () => number;
    onEnded: (leg: ProvenEndedLeg) => void;
}): Promise<ForeignWriter[]>;
/** The leg that holds `sessionId`'s account row (undefined ⇔ no row, or a row without one). */
export declare function sessionAccountLeg(docs: MemoryGovernanceDocs, sessionId: string): Promise<string | undefined>;
/** The write scope `sessionId`'s account row records — the scope its newest account-opening mount wrote
 *  under (the value that mount's handle carries as `writeScope`), whether that leg is still live or has
 *  ended. Undefined ⇔ no row, or a row written before the field. Throws on a corrupt ledger, and on one still in the v1
 *  key form (refused like every reader of it, {@link sessionAccountsV2}). */
export declare function sessionAccountWriteHome(docs: MemoryGovernanceDocs, sessionId: string): Promise<{
    writeScope: string;
    openedAt: number;
} | undefined>;
/** The membership question the harvest asks per file: is `(scope, rel)` in the session's sticky
 *  set? A session carrying members the conversion could not attribute answers yes for every seat. */
export interface SessionUnattributedSet {
    has(scope: string, rel: string): boolean;
    /** True when no seat can answer yes (no members, none unattributable). */
    readonly empty: boolean;
}
export declare function emptyUnattributedSet(): SessionUnattributedSet;
/** Open (or re-open, on a same-session resume) the session's account row, persisting the sticky
 *  unattributed classification frozen at THIS materialize. The leg's holder is the process doing the
 *  open (fingerprinted before the ledger's lock is taken). */
export declare function openSessionAccount(docs: MemoryGovernanceDocs, input: {
    sessionId: string;
    now: () => number;
    unattributed: readonly UnattributedMember[];
    writeScope?: string;
    leg?: string;
}): Promise<void>;
/** The current session's sticky unattributed set (the harvest's residue-arm input). */
export declare function sessionUnattributedSet(docs: MemoryGovernanceDocs, sessionId: string): Promise<SessionUnattributedSet>;
/** Close the session's account row — called ONLY after a FULL-domain harvest (zero BUDGET-deferred
 *  files, i.e. `HarvestReport.degraded` absent): a partial harvest's close would launder the deferred
 *  residue window (§3.6 序则②). A normal full close also clears every standing `unadjudicated` flag
 *  (r7-3: the valve's conservative window ends when a full harvest has adjudicated the plane).
 *
 *  ORTHOGONAL to the projection-debt ledger: neither this close nor the valve's
 *  `closed-unadjudicated` close reads, settles or faults a debt row, so a projection-debt deferral
 *  OUTLIVES the close and is re-judged by the next harvest's consult — it is not a partial-harvest
 *  condition and does not hold the close, but the caller DISCLOSES any standing deferral beside it
 *  (a close over id-less deferred files must not read as a clean full pass).
 *
 *  Returns what happened ({@link SessionAccountWrite}): `"absent"` (a session that never opened an
 *  account — e.g. an adoption-restricted materialize — has no close, and the caller's disclosure
 *  must not claim one), or `"stale"` when `leg` names a mount that no longer holds the row. */
export declare function closeSessionAccount(docs: MemoryGovernanceDocs, input: {
    sessionId: string;
    now: () => number;
    leg?: string;
}): Promise<SessionAccountWrite>;
/** What a close / leg end did: wrote the row, found none, or found the row held by ANOTHER leg (the
 *  caller's leg is over — a resume re-opened the row — so nothing was written). */
export type SessionAccountWrite = "written" | "absent" | "stale";
/** Record that the session's leg ended ({@link SessionAccountRow.terminatedAt}). Touches nothing
 *  else — `closedAt` stays whatever the harvests made it. `leg` (the caller's mount) must hold the
 *  row: a leg that is over does not end the one that re-opened it. */
export declare function terminateSessionAccount(docs: MemoryGovernanceDocs, input: {
    sessionId: string;
    now: () => number;
    leg?: string;
}): Promise<SessionAccountWrite>;
/** The host valve for a dangling row (advisory; §3.6 — dangling rows never auto-expire). The
 *  close is `closed-unadjudicated` (r7-3): it stops the row dangling but the residue arm keeps
 *  firing until a full-domain harvest closes normally. `requestId` required (audit, #123).
 *
 *  `leg` names the leg the caller means to close — the one a refusal it read named (`null` for a row
 *  without one). A row held by any other leg is refused (`memory.session_account_resolve_stale`) and
 *  nothing is written: a resume that re-opened the row after the refusal was read is a live writer, and
 *  closing it would hand its uncommitted edits to the next restore. */
export declare function resolveSessionAccountRecord(docs: MemoryGovernanceDocs, input: {
    sessionId: string;
    requestId: string;
    leg: string | null;
    now: () => number;
}): Promise<void>;
/** The hold ledger's file: the File store's coordinate of the governance document `holds` (read here only by the
 *  File layout's own key-form upgrade, {@link convertV1SidecarKeys}). */
export declare const HOLDS_FILE: string;
/** The hold custody directory: the File store's directory of the control-object kind `hold`. */
export declare const HOLD_DIR: string;
/** What a hold is kept through: the governance store's ledger document `holds`, its `hold` custody objects and the
 *  `quarantine` objects a disposal moves them to. */
type HoldStore = MemoryGovernanceDocs & MemoryGovernanceObjects;
export type HoldStatus = "capturing" | "held" | "released" | "disposed";
export type HoldTerminal = "dirty" | "expired" | "conflict" | "discarded" | "capture_lost";
export interface HoldRow {
    holdId: string;
    /** The WRITER session (lineage attribution on release records this id — the true author). */
    sessionId: string;
    /** The committed entry this hold's file addressed, when it addressed one (update form). */
    entryId?: string;
    op: "add" | "update";
    /** CAS anchor at capture time (update form): release refuses to blind-write over a later edit. */
    baseRev?: string;
    /** The plane seat the file was removed from, in the ledger form: relative to the write scope's
     *  home (`<memoryDir>/<label>`), `/`-separated — `${slug}.md`. Location-free, so a home move never
     *  re-keys a hold. */
    rel: string;
    /** The entry slug (path relative to the scope dir, sans `.md`) — the release leg's projection
     *  identity and its filename-scan input. */
    slug: string;
    /** The write scope the capture belonged to — the release commits into it. */
    scope: string;
    /** The custody file name under `hold/`. */
    captureName: string;
    /** sha256 over the captured bytes (minted from the ONE read buffer — the same buffer writes the
     *  custody file and, verified, is what release commits: no verify-reread window). */
    contentDigest: string;
    capturedAt: number;
    status: HoldStatus;
    disposition?: {
        terminal: HoldTerminal;
        quarantineName?: string;
    };
    /** Host valve verdict awaiting the next harvest ("release" commits with cause "static"). */
    resolved?: "release" | "discard";
    /** The verdict's GENERATION (strictly increases on every re-resolution): the settle leg's
     *  consumed-verdict exit clears only the exact generation it read, so a host re-resolution
     *  racing a failing release attempt is never erased by the stale attempt's cleanup. Absent on
     *  rows resolved before the member existed (a generation-less clear matches those). */
    resolvedAt?: number;
}
export declare function readHolds(docs: MemoryGovernanceDocs): Promise<HoldRow[]>;
/** Where a plane file is staged while it is displaced: a SIBLING in the file's OWN directory.
 *  `rename` is atomic only WITHIN one filesystem, and the control plane is routinely a different mount
 *  from the memory dir — staging there surrenders the atomicity the rename-first law exists for, and a
 *  cross-device refusal is the ordinary shape of a two-volume deployment, not an exotic failure. A
 *  sibling is on the file's filesystem by construction, so one path serves both layouts. The staged
 *  name is never `.md`-suffixed; custody stays in the control plane ({@link retireStagingToObject}). */
export declare function stagingPathBeside(absPath: string, stagingName: string): string;
/** Move whatever still sits at a staged generation into the governance store's control objects and report WHERE the
 *  bytes ended up. Withheld bytes belong in the control plane, never on the model-visible plane — but a copy that
 *  cannot be made there leaves the only copy where it is and SAYS so, so the coordinate is the host's recovery address
 *  either way and `settled` answers one question: in the store, with nothing left beside the seat? Takes an
 *  ALREADY-CLAIMED path (read, decision and removal address one inode): the staged bytes become the `kind` object
 *  `name`, read back through the store before the staged copy is removed. The removal is an act on the memory plane
 *  after this function's awaits, so `refusedAt` (the caller's anchor read) runs immediately before it — a refusal
 *  leaves the staged copy where it is and reports it, exactly as an unremovable copy does. */
export declare function retireStagingToObject(objects: Pick<MemoryGovernanceObjects, "putObject" | "getObject">, claimedPath: string, kind: MemoryControlObjectKind, name: string, refusedAt: () => string | undefined): Promise<{
    settled: boolean;
    at: string;
}>;
/** ATOMIC no-replace restore of a staged file onto a plane path (adversarial round 2: an
 *  existsSync-then-rename pair is a TOCTOU — POSIX rename REPLACES a destination created between
 *  the check and the call, clobbering a third writer's newer bytes). `link` refuses EEXIST
 *  atomically: on success the staging name is dropped (one inode, two names → one); on EEXIST the
 *  staging file is KEPT (custody — never overwrite the plane's newer legal bytes). */
export declare function noReplaceRestore(stagingPath: string, destPath: string): "restored" | "kept" | "stranded";
/**
 * §4.2 — open one hold over an instruction-form file: the two-stage journal.
 *   ① append row `status:"capturing"` (deterministic captureName + contentDigest minted from the
 *     one read buffer) — the account exists before any byte moves;
 *   ② write the custody object FROM THE SAME BUFFER, read it back through the store, verify the digest;
 *   ③ the anchor read at the act (`actRefused` — ① and ② awaited the store), then remove the plane
 *     file RENAME-FIRST (atomic move to a staged sibling in the file's OWN
 *     directory — {@link stagingPathBeside}), then hash what actually moved: equal ⇒ the staged
 *     duplicate is dropped (custody already holds verified bytes); unequal ⇒ a third writer replaced
 *     the file between read and rename — NO-CLOBBER rollback (the newer bytes go back ONLY if the
 *     plane path is still absent; a re-created path keeps both copies, the staged bytes retire into
 *     control-plane custody and the caller hears "conflict" — never an overwrite of newer legal bytes);
 *   ④ flip the row to `"held"`.
 * Every failure path returns a structured outcome (never throws past the row append): the caller
 * fail-closes the file through the ordinary quarantine containment instead — an instruction file
 * must never stay on the plane because its hold failed. A directory that refuses the move (read-only
 * plane, revoked permission) is one such refusal: the file would stay on the plane, the one outcome
 * a hold may not produce.
 */
export declare function openInstructionHold(store: HoldStore, input: {
    sessionId: string;
    /** The seat in the ledger form (relative to the write scope's home). */
    rel: string;
    absPath: string;
    content: string;
    entryId?: string;
    op: "add" | "update";
    baseRev?: string;
    slug: string;
    scope: string;
    now: () => number;
    /** The caller's act gate on the memory plane (the engine's anchor read), asked immediately before each act this
     *  function performs there: the refusal's text, or `undefined` when the act may proceed. */
    actRefused: (path: string, act: string) => string | undefined;
}): Promise<{
    ok: true;
    holdId: string;
    thirdWriterStrandedAt?: string;
} | {
    ok: false;
    holdId?: string;
    reason: string;
}>;
/**
 * §4.2 reconciliation — converge half-way holds (a crash between the journal stages):
 *  - `capturing` + custody file present & digest-equal ⇒ flip held (the crash was after ②);
 *  - `capturing` + custody absent + plane file present & digest-equal ⇒ complete the capture and
 *    continue the two-stage walk; digest-UNEQUAL ⇒ the bytes were replaced — `capture_lost`
 *    (the file stays on the plane and walks the ordinary/§3.6 arms; never "capture whatever is
 *    there now" — that would hold a third writer's bytes under the first writer's account);
 *  - `capturing` + custody absent + plane file gone ⇒ `capture_lost` (nothing to hold).
 *  - `held` + plane file REAPPEARED at the seat ⇒ left alone (a fresh write is a fresh file —
 *    the next harvest judges it on its own; the hold's custody bytes stay the hold's).
 *  - `disposed` + the row names its quarantine seat + the custody object still stands
 *    ⇒ the disposal's move finishes (the row is written before the bytes move).
 * The walk awaits the store between its acts on the memory plane, so the caller's anchor read
 * (`actRefused`) is asked immediately before each of them.
 */
export declare function reconcileHolds(store: HoldStore, input: {
    homeOf: (scope: string) => string;
    now: () => number;
    onStranded: (scope: string, line: string) => void;
    actRefused: (path: string, act: string) => string | undefined;
}): Promise<void>;
/** The quarantine seat of a hold's custody bytes: a function of the ROW, never of a clock. The same
 *  row names the same seat on every call, in every process, after any crash — the family's one name
 *  ({@link quarantineObjectNameOf}) over the row's own content digest and `hold-<captureName>` (a row's
 *  captureName is a safe basename, so the label passes through unchanged). */
export declare function holdQuarantineNameOf(row: Pick<HoldRow, "captureName" | "contentDigest">): string;
/** Dispose one held row: the row records its terminal and the quarantine seat NAMED BY THE ROW
 *  ({@link holdQuarantineNameOf}) first, then the custody bytes move there (host-auditable;
 *  from-row-to-bytes addressing survives every terminal). Row first, bytes second: a crash between
 *  the two leaves a row whose bytes are at the custody seat or the quarantine seat — both of which
 *  {@link readHoldCustody} tries — and {@link reconcileHolds} finishes the move; the reverse order
 *  would leave bytes in quarantine under a name no row recorded. Whether the row names a seat is
 *  decided inside the ledger's update, on the fresh row, from what stands at the custody seat and the
 *  quarantine seat as read just before it (the update's callback runs synchronously and reads no
 *  object; a mover between that read and the update is the compound-decision window, KL-3308-c): a
 *  row with no custody bytes anywhere records the terminal with no name (nothing to move). The
 *  verdict always lands: a quarantine seat held by something that is not the hold's bytes records the
 *  terminal with no name, leaves the custody bytes where they are and replaces nothing — and then
 *  refuses loudly (the caller hears it; a refused intake is terminal all the same). */
export declare function disposeHold(store: HoldStore, input: {
    holdId: string;
    terminal: HoldTerminal;
}): Promise<{
    ok: boolean;
    quarantineName?: string;
}>;
/** Flip one row to released (the caller — the harvest release leg — has already committed the
 *  custody bytes through the full gate set; the custody object is deleted after the flip). */
export declare function markHoldReleased(store: HoldStore, input: {
    holdId: string;
    now: () => number;
}): Promise<void>;
/** The host valve — `resolveHold(holdId, "release"|"discard", requestId)`: records the verdict on
 *  the row; the NEXT harvest reconciliation executes it ("release" re-walks the full gates and
 *  commits WITH cause "static" — a timeout release is not proof of cleanliness; "discard"
 *  disposes to quarantine). requestId required (audit, #123). */
export declare function resolveHoldRecord(docs: MemoryGovernanceDocs, input: {
    holdId: string;
    action: "release" | "discard";
    requestId: string;
    now: () => number;
}): Promise<void>;
/**
 * Consume a standing valve verdict WITHOUT any other transition — the settle leg's exit for a
 * valve release that FAILED on an already-disposed row (an expired hold whose release hit a
 * judgment refusal: lost custody, re-scan refusal, CAS conflict). `disposeHold` is a no-op there
 * (the row is already terminal), so leaving `resolved` standing would re-run the identical failing
 * release — and re-announce a disposal that never happened — on every subsequent harvest, forever.
 * Clearing it returns the row to its plain disposed/expired state: the failure is disclosed by the
 * caller, custody/quarantine bytes stay addressable, and `resolveHold(holdId, "release")` remains
 * admissible after the host reconciles. GENERATION-KEYED: only the exact verdict generation the
 * caller read is cleared — a host re-resolution that landed while the failing attempt was in
 * flight is a NEWER generation and stands (the stale attempt's cleanup must not erase a live host
 * action). A generation-less verdict (a row written before the member existed) is consumable
 * against a generation-less read — every CURRENT writer mints a generation, so the only verdict
 * such a clear can erase is one written by a PRE-generation writer racing on the same control
 * plane: the standing mixed-version-writer class the upgrade-order duty prices, kept consumable
 * on purpose (refusing it would revive the forever-re-firing valve loop for every verdict minted
 * before the upgrade). Idempotent; unknown/verdict-less/other-generation rows are a no-op.
 */
export declare function clearHoldResolution(docs: MemoryGovernanceDocs, input: {
    holdId: string;
    ifResolvedAt: number | undefined;
}): Promise<void>;
/** Read one hold's custody bytes (release leg + expired-release valve). Returns undefined when
 *  the custody object is gone or fails its digest — the caller records capture_lost, never commits
 *  unverified bytes. For an expired-released row the bytes may already sit in quarantine
 *  (disposition.quarantineName) — both seats are tried, digest-verified either way. */
export declare function readHoldCustody(objects: Pick<MemoryGovernanceObjects, "getObject">, row: HoldRow): Promise<string | undefined>;
/** True ⇔ the session's pollution marker or any non-clean settlement row blocks a clean release
 *  (§4.2-1: any non-clean row in the session's account keeps the hold held/disposed). */
export declare function sessionBlocksCleanRelease(docs: MemoryGovernanceDocs & SessionPollutionObjects, sessionId: string): Promise<boolean>;
export {};
