/** * Durable private store for Workflow v3 parameter-distillation proposals. * * The model-authored suggestion never reaches this module. `proposal.json` * contains only the host-compiled, parsed proposal body. Immutable proposal * material and mutable lifecycle state are deliberately separate so a state * transition can never rewrite the object the user reviewed. * * Lock order is always identity-index -> proposal state. The durable * `replacing` index entry makes supersession recoverable without ever leaving * two proposals eligible for approval. */ import { V3_DISTILLATION_COMPILER_VERSION, type V3DistillationCompiledBodyV1 } from './distillation-schema.js'; declare const PREPARED_SCHEMA_VERSION: 1; declare const PROPOSAL_SCHEMA_VERSION: 1; declare const STATE_SCHEMA_VERSION: 1; export declare const V3_DISTILLATION_PROPOSAL_ID_RE: RegExp; export type V3DistillationStoreErrorCode = 'INVALID_ARGUMENT' | 'PROPOSAL_NOT_FOUND' | 'STORE_CORRUPT' | 'CONTENT_CONFLICT' | 'STATE_CONFLICT' | 'IDENTITY_BUSY' | 'STALE_PROPOSAL'; /** Fixed-message error: private paths, values, and parser output are never reflected. */ export declare class V3DistillationStoreError extends Error { readonly code: V3DistillationStoreErrorCode; constructor(code: V3DistillationStoreErrorCode); } export interface V3DistillationSourceIdentityV1 { runId: string; runEnvelopeSha256: string; dagSha256: string; specSha256: string; botSnapshotsSha256: string; baselineRevisionSha256: string; ownerOpenId: string; larkAppId: string; chatId: string; } export interface V3DistillationPreparedBodyV1 { schemaVersion: typeof PREPARED_SCHEMA_VERSION; proposalId: string; requestKey: string; liveKey: string; compilerVersion: typeof V3_DISTILLATION_COMPILER_VERSION; sourceIdentity: V3DistillationSourceIdentityV1; replyTarget: V3DistillationReplyTargetV1; displayName: string; } export type V3DistillationReplyTargetV1 = { kind: 'chat'; chatId: string; } | { kind: 'thread'; rootMessageId: string; }; export interface V3DistillationProposalBodyV1 { schemaVersion: typeof PROPOSAL_SCHEMA_VERSION; proposalId: string; proposalHash: string; liveKey: string; compilerVersion: typeof V3_DISTILLATION_COMPILER_VERSION; sourceIdentity: V3DistillationSourceIdentityV1; displayName: string; createdAt: string; compiled: V3DistillationCompiledBodyV1; } export interface V3DistillationApprovalV1 { operatorOpenId: string; larkAppId: string; chatId: string; acceptedAt: string; } export interface V3DistillationRejectionV1 { operatorOpenId: string; larkAppId: string; chatId: string; rejectedAt: string; } export interface V3DistillationCommitAllocationV1 { workflowId: string; createdAt: string; startedAt: string; } export interface V3DistillationCommitResultV1 { workflowId: string; revisionId: string; revisionContentHash?: string; committedAt: string; } interface StateBase { schemaVersion: typeof STATE_SCHEMA_VERSION; proposalId: string; liveKey: string; preparedAt: string; updatedAt: string; } export type V3DistillationProposalStateV1 = (StateBase & { state: 'prepared'; }) | (StateBase & { state: 'proposed'; proposalHash: string; proposedAt: string; }) | (StateBase & { state: 'accepted'; proposalHash: string; proposedAt: string; approval: V3DistillationApprovalV1; }) | (StateBase & { state: 'committing'; proposalHash: string; proposedAt: string; approval: V3DistillationApprovalV1; commit: V3DistillationCommitAllocationV1; }) | (StateBase & { state: 'committed'; proposalHash: string; proposedAt: string; approval: V3DistillationApprovalV1; commit: V3DistillationCommitAllocationV1; result: V3DistillationCommitResultV1; }) | (StateBase & { state: 'rejected'; proposalHash: string; proposedAt: string; rejection: V3DistillationRejectionV1; }) | (StateBase & { state: 'superseded'; proposalHash: string; proposedAt: string; supersededByProposalId: string; supersededAt: string; }); export interface LoadedV3DistillationProposal { prepared: V3DistillationPreparedBodyV1; proposal?: V3DistillationProposalBodyV1; state: V3DistillationProposalStateV1; } export interface PrepareV3DistillationProposalInput { /** Stable per inbound Lark event/message; duplicate delivery reuses the allocation. */ requestKey: string; sourceIdentity: V3DistillationSourceIdentityV1; replyTarget: V3DistillationReplyTargetV1; displayName: string; compilerVersion: typeof V3_DISTILLATION_COMPILER_VERSION; now?: Date; } export interface PublishV3DistillationProposalInput { compiled: V3DistillationCompiledBodyV1; now?: Date; } export interface ActOnV3DistillationProposalInput { proposalHash: string; operatorOpenId: string; larkAppId: string; chatId: string; now?: Date; } export interface BeginV3DistillationCommitInput { proposalHash: string; workflowId: string; /** Timestamp frozen into the final Saved Workflow revision allocation. */ createdAt: string; now?: Date; } export interface MarkV3DistillationCommittedInput { proposalHash: string; workflowId: string; revisionId: string; revisionContentHash?: string; now?: Date; } export declare function computeV3DistillationLiveKey(sourceIdentity: V3DistillationSourceIdentityV1, compilerVersion: typeof V3_DISTILLATION_COMPILER_VERSION): string; export declare function v3DistillationStoreRoot(dataDir: string): string; export declare function v3DistillationProposalDir(dataDir: string, proposalId: string): string; /** Prepare or idempotently recover a per-request proposal allocation. */ export declare function prepareProposal(dataDir: string, input: PrepareV3DistillationProposalInput): LoadedV3DistillationProposal; /** Publish the immutable host-compiled proposal and enter `proposed`. */ export declare function publishProposal(dataDir: string, proposalId: string, input: PublishV3DistillationProposalInput): LoadedV3DistillationProposal; export declare function acceptProposal(dataDir: string, proposalId: string, input: ActOnV3DistillationProposalInput): LoadedV3DistillationProposal; export declare function rejectProposal(dataDir: string, proposalId: string, input: ActOnV3DistillationProposalInput): LoadedV3DistillationProposal; export declare function beginCommit(dataDir: string, proposalId: string, input: BeginV3DistillationCommitInput): LoadedV3DistillationProposal; export declare function markCommitted(dataDir: string, proposalId: string, input: MarkV3DistillationCommittedInput): LoadedV3DistillationProposal; export declare function loadProposal(dataDir: string, proposalId: string): LoadedV3DistillationProposal; /** Strict startup inventory for crash recovery. Unknown entries fail closed. */ export declare function listV3DistillationProposals(dataDir: string): LoadedV3DistillationProposal[]; /** Current active allocations only; used by daemon cold recovery. */ export declare function listActiveV3DistillationProposals(dataDir: string): LoadedV3DistillationProposal[]; export {}; //# sourceMappingURL=distillation-store.d.ts.map