import type { KyroScopeEntry, ScopeCompletion, ScopeReopenRecord, SprintFile } from '../types'; /** * The exact after-states that `kyro scope complete` and `kyro scope reopen` write. * * These builders are the single source of truth for both the writers and the checkpoint verifier. * A close checkpoint commits to the live state as it stood at close; an explicit completion or * reopen legitimately moves live state off that image. Doctor therefore does not trust the presence * of a lifecycle record — it *replays* the recorded transitions from the checkpoint's after-image * through these same functions and requires the result to reproduce the live state exactly. Any edit * a lifecycle transition could not have produced still reads as divergence. */ export declare const SCOPE_COMPLETION_KIND: "scope-completion"; export declare const SCOPE_COMPLETION_SCHEMA_VERSION: 1; export declare const SCOPE_REOPEN_KIND: "scope-reopen"; export declare const SCOPE_REOPEN_SCHEMA_VERSION: 1; /** * Request and registry digests live here, beside the builders, because the verifier needs the exact * same derivation the writers use. A digest recomputed by a second implementation would only prove * that two copies of the formula agree. */ export declare function scopeCompletionRequestDigest(scope: string, normalizedSummary: string | null): string; export declare function scopeReopenRequestDigest(scope: string, reason: string, completion: ScopeCompletion): string; export declare function completionRegistryEntryDigest(entry: KyroScopeEntry): string; export declare function reopenRegistryEntryDigest(entry: KyroScopeEntry): string; export declare function completedSprintState(sprint: SprintFile, completion: ScopeCompletion): SprintFile; export declare function completedScopeEntry(entry: KyroScopeEntry, completion: ScopeCompletion): KyroScopeEntry; /** Reopen clears the live completion and preserves it in append-only history — it never erases it. */ export declare function reopenedSprintState(sprint: SprintFile, record: ScopeReopenRecord, completionHistory?: ScopeReopenRecord[]): SprintFile; export declare function reopenedScopeEntry(entry: KyroScopeEntry, record: ScopeReopenRecord, sprint: SprintFile, completionHistory?: ScopeReopenRecord[]): KyroScopeEntry; export declare const SCOPE_LIFECYCLE_VERIFICATION_STATUS: { readonly CHECKPOINT_EXACT: "checkpoint_exact"; readonly LIFECYCLE_REPLAYED: "lifecycle_replayed"; readonly DIVERGED: "diverged"; readonly UNSUPPORTED: "unsupported"; }; export type ScopeLifecycleVerificationStatus = (typeof SCOPE_LIFECYCLE_VERIFICATION_STATUS)[keyof typeof SCOPE_LIFECYCLE_VERIFICATION_STATUS]; export declare const SCOPE_LIFECYCLE_VERIFICATION_REASON: { readonly CHECKPOINT_EXACT: "checkpoint_exact"; readonly LIFECYCLE_REPLAYED: "lifecycle_replayed"; readonly INVALID_INPUT: "invalid_input"; readonly SCOPE_MISMATCH: "scope_mismatch"; readonly HISTORY_PREFIX_MISMATCH: "history_prefix_mismatch"; readonly NOTHING_TO_REPLAY: "nothing_to_replay"; readonly COMPLETION_BINDING_MISMATCH: "completion_binding_mismatch"; readonly REOPEN_BINDING_MISMATCH: "reopen_binding_mismatch"; readonly ENTRY_BEFORE_BINDING_MISMATCH: "entry_before_binding_mismatch"; readonly ILLEGAL_TRANSITION: "illegal_transition"; readonly SPRINT_AFTER_MISMATCH: "sprint_after_mismatch"; readonly REGISTRY_AFTER_MISMATCH: "registry_after_mismatch"; }; export type ScopeLifecycleVerificationReason = (typeof SCOPE_LIFECYCLE_VERIFICATION_REASON)[keyof typeof SCOPE_LIFECYCLE_VERIFICATION_REASON]; export declare const SCOPE_LIFECYCLE_ACTOR_ASSURANCE: { readonly NOT_APPLICABLE: "not_applicable"; readonly UNVERIFIED: "unverified"; }; export type ScopeLifecycleActorAssurance = (typeof SCOPE_LIFECYCLE_ACTOR_ASSURANCE)[keyof typeof SCOPE_LIFECYCLE_ACTOR_ASSURANCE]; /** * One atomic verdict over both durable lifecycle layers. Public hashes bind the claimed transition * to its content and prior registry state, but cannot authenticate which process or actor wrote it. */ export interface ScopeLifecycleVerification { status: ScopeLifecycleVerificationStatus; reason: ScopeLifecycleVerificationReason; sprint: SprintFile | null; entry: KyroScopeEntry | null; appliedOperations: number; actorAssurance: ScopeLifecycleActorAssurance; } /** * Rebuild the state a close checkpoint's after-image would reach by replaying exactly the lifecycle * transitions the live records claim *after* that image was sealed. * * Two properties make this a structural verification rather than a restatement of the records: * * 1. **Prefix exactness.** The checkpoint's own `completionHistory` is already materialized in its * after-image, so only the suffix the live state adds may be replayed. Re-applying the sealed * prefix would double every earlier completion/reopen and turn a lawful multi-cycle scope * (complete → reopen → plan → close → complete) into a false `DIVERGED`. A live history that is * not an exact extension of the sealed prefix is truncation or rewriting, and replaying it is * refused outright. * 2. **Bound suffix.** Every replayed record must carry the public digests the writer normally * records, and each must re-derive from the record's own content and prior registry state. Missing, * stale, or misbound records fail closed. Because these values are public and deterministic, this * proves consistency rather than writer or actor identity. Records already sealed in the immutable * after-image are historical evidence and are not re-verified here. * * Sprint and registry are projected in lockstep and receive one verdict. Callers must not accept a * sprint-only replay and independently guess whether the registry transition was lawful. */ export declare function verifyScopeLifecycleEvolution(afterImage: unknown, afterEntry: KyroScopeEntry | null | undefined, live: unknown, liveEntry: KyroScopeEntry | null | undefined): ScopeLifecycleVerification; //# sourceMappingURL=lifecycle-state.d.ts.map