import { type LifecycleDelivery, type ScopeLifecycle, type StoredScopeLifecycle } from '@substrat-run/contracts'; import type { SwitchSql } from './system-switch.js'; /** * The one statement that stores a delivered lifecycle, with its key written in. A delivery changes * what the store may run and none of its data, so the scope DO lets this statement through its * bookkeeping path without advancing the write revision a carry fences on (`isLifecycleWrite`), * as it does the copy marker. The key is a literal so that path cannot write any other row. */ export declare const WRITE_LIFECYCLE_SQL = "INSERT OR REPLACE INTO _substrat_meta (key, value) VALUES ('scope_lifecycle', ?)"; /** Whether a statement is `WRITE_LIFECYCLE_SQL`, whitespace aside. */ export declare const isLifecycleWrite: (sql: string) => boolean; /** The stored lifecycle, or null when none was delivered. A row that does not parse reads as none. */ export declare function readLifecycle(sql: SwitchSql): StoredScopeLifecycle | null; /** A stored or dumped value as a lifecycle, or null when it is absent or does not parse. */ export declare function parseLifecycle(value: unknown): StoredScopeLifecycle | null; /** * Store a delivered lifecycle, unless the store already holds one as new or newer. `applied` says whether * this delivery is now the stored state, and `changed` whether the gate's answer moved with it. */ export declare function writeLifecycle(sql: SwitchSql, next: ScopeLifecycle): LifecycleDelivery; /** * The row a load leaves (#1713): the store's own when the load is a copy, otherwise the newer of * the store's and the dump's. Null means no row. */ export declare function lifecycleAfterLoad(before: StoredScopeLifecycle | null, dumped: StoredScopeLifecycle | null, copy: boolean): StoredScopeLifecycle | null; /** * Settle the row after a load replaced `_substrat_meta` wholesale (#1713): `lifecycleAfterLoad` of * the row read before the load (`before`) and the one the dump brought, put in place or removed. */ export declare function settleLifecycleAfterLoad(sql: SwitchSql, before: StoredScopeLifecycle | null, copy: boolean): void; /** * THE lifecycle gate (#1713): null when the scope may run, or the refusal's message. Both halves must be * `active`, the tenant judged first, exactly as the directory's `scopeAccessRefusal` judges them, * so a CP-less deployment and a CP-backed one refuse the same scope in the same words. No stored * lifecycle passes. */ export declare function lifecycleRefusal(state: Pick | null, ids?: { tenantId: string; scopeId: string; }): string | null; /** * The directory's record of what a deployment last acknowledged, compared with the directory's * own lifecycle by the heal sweep: the statuses AND the full revision, so a restore that left the * statuses as they were still reads as drift, and the scope is brought onto the new epoch. Never * `at`, so a re-read of an unchanged directory is not drift. A lifecycle stored before revisions * has none, and reads as drift against any directory. */ export declare const lifecycleReceipt: (state: Pick) => string; //# sourceMappingURL=scope-lifecycle.d.ts.map