@fro.bot/systematic 3.2.8 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,14 @@
14
14
  * but is not reflected in the type declarations for this Zod 4 minor.
15
15
  */
16
16
  import { z } from 'zod';
17
+ export declare const WorkflowGuardSchema: z.ZodDefault<z.ZodObject<{
18
+ mode: z.ZodDefault<z.ZodEnum<{
19
+ observe: "observe";
20
+ protected: "protected";
21
+ disabled: "disabled";
22
+ }>>;
23
+ debug: z.ZodDefault<z.ZodBoolean>;
24
+ }, z.core.$strict>>;
17
25
  export declare const AgentOverlaySchema: z.ZodObject<{
18
26
  model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
27
  variant: z.ZodOptional<z.ZodString>;
@@ -2,6 +2,11 @@ export interface BootstrapConfig {
2
2
  enabled: boolean;
3
3
  file?: string;
4
4
  }
5
+ export type WorkflowGuardMode = 'observe' | 'protected' | 'disabled';
6
+ export interface WorkflowGuardConfig {
7
+ mode: WorkflowGuardMode;
8
+ debug: boolean;
9
+ }
5
10
  export type OverlayConfig = Record<string, unknown>;
6
11
  export type OverlayConfigMap = Record<string, OverlayConfig>;
7
12
  export interface SourcedOverlayConfig {
@@ -22,6 +27,7 @@ export interface SystematicConfig {
22
27
  disabled_agents: string[];
23
28
  disabled_commands: string[];
24
29
  bootstrap: BootstrapConfig;
30
+ workflow_guard: WorkflowGuardConfig;
25
31
  agents?: OverlayConfigMap;
26
32
  categories?: OverlayConfigMap;
27
33
  skills_as_commands: boolean;
@@ -0,0 +1,79 @@
1
+ export type OperationObserverReasonCode = 'target-unavailable' | 'command-failed' | 'command-timeout' | 'command-output-limit' | 'file-limit' | 'file-output-limit' | 'file-read-failed' | 'remote-command-failed' | 'remote-command-output-limit' | 'remote-invalid-json' | 'remote-missing-field' | 'remote-item-limit' | 'remote-not-advanced' | 'commit-not-closed';
2
+ export type RemoteOperation = 'push' | 'pr-creation' | 'check-readback' | 'review-readback';
3
+ export type RemoteReadbackPhase = 'before' | 'after';
4
+ export interface OperationObserverSnapshot {
5
+ readonly targetDigest: string;
6
+ readonly repositoryRevisionDigest: string;
7
+ readonly worktreeRevisionDigest: string;
8
+ readonly commitClosure?: boolean;
9
+ }
10
+ export type OperationObserverResult = {
11
+ readonly status: 'available';
12
+ readonly snapshot: OperationObserverSnapshot;
13
+ } | {
14
+ readonly status: 'unavailable';
15
+ readonly reasonCode: OperationObserverReasonCode;
16
+ };
17
+ export interface OperationObserverCommandResult {
18
+ readonly status: number;
19
+ readonly stdout: string;
20
+ readonly stderr: string;
21
+ readonly timedOut?: boolean;
22
+ }
23
+ export interface OperationObserverRemoteCommandResult {
24
+ readonly status: number;
25
+ readonly stdout: string;
26
+ readonly stderr: string;
27
+ readonly timedOut?: boolean;
28
+ }
29
+ export type OperationObserverCommandRunner = (args: readonly string[], cwd: string, maxOutputBytes: number, timeoutMs: number) => OperationObserverCommandResult;
30
+ export type OperationObserverRemoteCommandRunner = (executable: 'git' | 'gh', args: readonly string[], cwd: string, maxOutputBytes: number, timeoutMs: number) => OperationObserverRemoteCommandResult;
31
+ export interface OperationObserverRemoteSnapshot {
32
+ readonly resourceIdentity: string;
33
+ readonly resourceRevisionIdentity: string;
34
+ readonly pullRequest?: {
35
+ readonly identity: string;
36
+ readonly state: 'open' | 'closed' | 'merged';
37
+ };
38
+ readonly checkState?: 'completed-success' | 'completed-failure' | 'pending';
39
+ readonly reviewDecision?: 'approved' | 'changes-requested' | 'commented' | 'pending';
40
+ }
41
+ export type OperationObserverRemoteResult = {
42
+ readonly status: 'available';
43
+ readonly snapshot: OperationObserverRemoteSnapshot;
44
+ } | {
45
+ readonly status: 'missing-resource';
46
+ } | {
47
+ readonly status: 'unavailable';
48
+ readonly reasonCode: OperationObserverReasonCode;
49
+ };
50
+ export interface OperationObserverLimits {
51
+ readonly maxCommandOutputBytes?: number;
52
+ readonly maxCommandTimeoutMs?: number;
53
+ readonly maxFiles?: number;
54
+ readonly maxTotalFileBytes?: number;
55
+ readonly maxPathBytes?: number;
56
+ }
57
+ export interface OperationObserverFileStat {
58
+ readonly isFile: boolean;
59
+ readonly isSymbolicLink: boolean;
60
+ readonly isDirectory: boolean;
61
+ readonly mode: number;
62
+ readonly size: number;
63
+ }
64
+ export interface OpencodeOperationObserverOptions {
65
+ readonly targetDirectory: string;
66
+ readonly commandRunner?: OperationObserverCommandRunner;
67
+ readonly remoteCommandRunner?: OperationObserverRemoteCommandRunner;
68
+ readonly fileReader?: (filePath: string) => Uint8Array;
69
+ readonly symlinkReader?: (filePath: string) => string;
70
+ readonly statReader?: (filePath: string) => OperationObserverFileStat;
71
+ readonly realPath?: (filePath: string) => string;
72
+ readonly limits?: OperationObserverLimits;
73
+ }
74
+ export interface OpencodeOperationObserver {
75
+ readonly targetDigest: string;
76
+ snapshot(): Promise<OperationObserverResult>;
77
+ remoteSnapshot?(operation: RemoteOperation, phase: RemoteReadbackPhase): Promise<OperationObserverRemoteResult>;
78
+ }
79
+ export declare function createOpencodeOperationObserver(options: OpencodeOperationObserverOptions): OpencodeOperationObserver;
@@ -0,0 +1,54 @@
1
+ import type { ToolDefinition } from '@opencode-ai/plugin';
2
+ import type { OpencodeOperationObserver } from './opencode-operation-observer.js';
3
+ import type { ReceiptClassifier } from './receipt-classifier.js';
4
+ import { type ReceiptLedger, type ReceiptOperation } from './receipt-ledger.js';
5
+ import { type EvidenceObservationResult, type RuntimeUnitPolicy, type TransitionPrepareResult, type WorkflowReasonCode, type WorkflowStatus } from './workflow-guard.js';
6
+ export declare const SYSTEMATIC_WORKFLOW_RECEIPT_METADATA_KEY = "systematic_workflow_receipt";
7
+ export interface OpencodeWorkflowGuardConfig {
8
+ mode: 'observe' | 'protected' | 'disabled';
9
+ debug: boolean;
10
+ }
11
+ declare const WORKFLOW_GUARD_BLOCKED_ERROR_CODE = "workflow-guard-blocked";
12
+ export type WorkflowGuardBlockedError = Error & {
13
+ readonly code: typeof WORKFLOW_GUARD_BLOCKED_ERROR_CODE;
14
+ readonly reasonCode: WorkflowReasonCode;
15
+ };
16
+ export declare function createWorkflowGuardBlockedError(reasonCode: WorkflowReasonCode): WorkflowGuardBlockedError;
17
+ export declare function isWorkflowGuardBlockedError(value: unknown): value is WorkflowGuardBlockedError;
18
+ export interface OpencodeWorkflowGuardOptions {
19
+ config: OpencodeWorkflowGuardConfig;
20
+ workspaceIdentity: string;
21
+ repositoryIdentity?: string;
22
+ worktreeIdentity?: string;
23
+ observer?: OpencodeOperationObserver;
24
+ classifier?: ReceiptClassifier;
25
+ runtimeRequiredOperations?: readonly ReceiptOperation[];
26
+ hostReadback?: OpencodeWorkflowHostReadback;
27
+ readonly registrationIdentity?: string;
28
+ readonly sessionSalt?: Uint8Array;
29
+ }
30
+ export interface OpencodeWorkflowChildSession {
31
+ readonly sessionId: string;
32
+ readonly parentID?: string;
33
+ }
34
+ export interface OpencodeWorkflowHostReadback {
35
+ readSessionParts(sessionID: string): Promise<ReadonlyArray<unknown>>;
36
+ listChildren(sessionID: string): Promise<ReadonlyArray<OpencodeWorkflowChildSession>>;
37
+ }
38
+ export interface OpencodeWorkflowGuardHooks {
39
+ 'tool.execute.before': (input: unknown, output: unknown) => Promise<void>;
40
+ 'tool.execute.after': (input: unknown, output: unknown) => Promise<void>;
41
+ event: (input: unknown) => Promise<void>;
42
+ 'experimental.chat.system.transform': (input: unknown, output: unknown) => Promise<void>;
43
+ }
44
+ export interface OpencodeWorkflowGuard {
45
+ readonly tools: Readonly<Record<string, ToolDefinition>>;
46
+ readonly hooks: OpencodeWorkflowGuardHooks;
47
+ status(sessionID: unknown): WorkflowStatus;
48
+ ledger(sessionID: unknown): ReceiptLedger | undefined;
49
+ observeReceipt(sessionID: unknown, input: unknown): EvidenceObservationResult;
50
+ prepareTransition(sessionID: unknown, input: unknown): TransitionPrepareResult;
51
+ startUnit(sessionID: unknown, input: unknown, policy?: RuntimeUnitPolicy): unknown;
52
+ }
53
+ export declare function createOpencodeWorkflowGuard(options: OpencodeWorkflowGuardOptions): OpencodeWorkflowGuard;
54
+ export {};
@@ -0,0 +1,94 @@
1
+ export declare const CANONICAL_QUESTION_WORDING: "Confirm the requested guarded transition.";
2
+ export type QuestionPurpose = 'transition' | 'session-disablement';
3
+ export type QuestionAnswerClassification = 'affirmative' | 'non-affirmative';
4
+ export type QuestionAttestationReasonCode = 'already-bound' | 'already-consumed' | 'already-disabled' | 'call-session-mismatch' | 'challenge-expired' | 'challenge-consumed' | 'invalid-input' | 'no-attestation' | 'non-affirmative' | 'rejected' | 'replay' | 'scope-mismatch' | 'substitution' | 'unknown-challenge' | 'unknown-request';
5
+ export interface QuestionAttestationOptions {
6
+ clock?: () => number;
7
+ maxChallengeAgeMs?: number;
8
+ }
9
+ export interface QuestionChallengeRecord {
10
+ readonly challengeId: string;
11
+ readonly sessionId: string;
12
+ readonly resourceDigest: string;
13
+ readonly transitionKey: string;
14
+ readonly purpose: QuestionPurpose;
15
+ readonly createdAt: number;
16
+ readonly question: {
17
+ readonly wording: typeof CANONICAL_QUESTION_WORDING;
18
+ readonly args: {
19
+ readonly challengeId: string;
20
+ readonly purpose: QuestionPurpose;
21
+ readonly resourceDigest: string;
22
+ readonly transitionKey: string;
23
+ };
24
+ };
25
+ }
26
+ export interface QuestionAttestation {
27
+ readonly purpose: QuestionPurpose;
28
+ readonly sessionId: string;
29
+ readonly resourceDigest: string;
30
+ readonly transitionKey: string;
31
+ readonly requestId: string;
32
+ readonly answer: 'affirmed';
33
+ readonly timestamp: number;
34
+ readonly consumption: 'available' | 'consumed';
35
+ }
36
+ export type ChallengeResult = {
37
+ readonly status: 'pending';
38
+ readonly challenge: QuestionChallengeRecord;
39
+ } | RejectedResult;
40
+ export type BindAskedResult = {
41
+ readonly status: 'bound';
42
+ readonly challengeId: string;
43
+ readonly requestId: string;
44
+ } | RejectedResult;
45
+ export type ObserveReplyResult = {
46
+ readonly status: 'accepted';
47
+ readonly attestation: QuestionAttestation;
48
+ } | RejectedResult;
49
+ export type ObserveRejectResult = {
50
+ readonly status: 'rejected';
51
+ readonly reasonCode: 'rejected';
52
+ } | RejectedResult;
53
+ export type ConsumeAttestationResult = {
54
+ readonly status: 'consumed';
55
+ readonly projection: 'attested' | 'disabled';
56
+ readonly attestation: QuestionAttestation;
57
+ } | RejectedResult;
58
+ export type QuestionAttestationProjection = KnownQuestionAttestationProjection | {
59
+ readonly status: 'unknown';
60
+ readonly reasonCode: QuestionAttestationReasonCode;
61
+ };
62
+ interface KnownQuestionAttestationProjection {
63
+ readonly status: 'pending' | 'bound' | 'attested' | 'denied' | 'disabled';
64
+ readonly challengeId: string;
65
+ readonly purpose: QuestionPurpose;
66
+ readonly sessionId: string;
67
+ readonly resourceDigest: string;
68
+ readonly transitionKey: string;
69
+ readonly requestId?: string;
70
+ readonly consumption?: 'available' | 'consumed';
71
+ }
72
+ export type SessionDisablementProjection = {
73
+ readonly status: 'enabled' | 'pending' | 'bound' | 'disabled';
74
+ readonly sessionId: string;
75
+ } | {
76
+ readonly status: 'unknown';
77
+ readonly reasonCode: QuestionAttestationReasonCode;
78
+ };
79
+ export interface QuestionAttestationMachine {
80
+ challenge(input: unknown): ChallengeResult;
81
+ bindAsked(input: unknown): BindAskedResult;
82
+ observeReply(input: unknown): ObserveReplyResult;
83
+ observeReject(input: unknown): ObserveRejectResult;
84
+ consumeAttestation(input: unknown): ConsumeAttestationResult;
85
+ status(input: unknown): QuestionAttestationProjection;
86
+ sessionStatus(input: unknown): SessionDisablementProjection;
87
+ }
88
+ interface RejectedResult {
89
+ readonly status: 'rejected';
90
+ readonly reasonCode: QuestionAttestationReasonCode;
91
+ }
92
+ export declare function classifyQuestionAnswer(answer: unknown): QuestionAnswerClassification;
93
+ export declare function createQuestionAttestation(options?: QuestionAttestationOptions): QuestionAttestationMachine;
94
+ export {};
@@ -0,0 +1,44 @@
1
+ import type { ReceiptClassification, ReceiptContext, ReceiptObservationAfter, ReceiptOperation, TerminalObservation } from './receipt-ledger.js';
2
+ export interface ReceiptClassificationInput {
3
+ command: string;
4
+ terminal: TerminalObservation;
5
+ }
6
+ export interface ReceiptClassifierOptions {
7
+ treeSitterWasmPath?: string;
8
+ bashWasmPath?: string;
9
+ }
10
+ export interface ReceiptClassifier {
11
+ classify(input: unknown): Promise<ReceiptClassification>;
12
+ classifyOperation?(input: unknown): Promise<ReceiptClassification>;
13
+ close(): Promise<void>;
14
+ }
15
+ export type ReceiptOperationTool = 'edit' | 'write' | 'apply-patch' | 'apply_patch' | 'bash' | 'git' | 'gh' | 'bun' | 'npm';
16
+ export type PullRequestObservationState = 'open' | 'closed' | 'merged';
17
+ export type CheckObservationState = 'completed-success' | 'completed-failure' | 'pending';
18
+ export type ReviewObservationDecision = 'approved' | 'changes-requested' | 'commented' | 'pending';
19
+ export interface ReceiptOperationContext extends ReceiptContext {
20
+ resourceRevisionIdentity?: string;
21
+ }
22
+ export interface ReceiptOperationAfter extends ReceiptObservationAfter {
23
+ commitClosure?: boolean;
24
+ pullRequest?: {
25
+ identity: string;
26
+ state: PullRequestObservationState;
27
+ };
28
+ resourceRevisionIdentity?: string;
29
+ checkState?: CheckObservationState;
30
+ reviewDecision?: ReviewObservationDecision;
31
+ }
32
+ export interface ReceiptOperationObservation {
33
+ callId: string;
34
+ operation: ReceiptOperation;
35
+ tool: ReceiptOperationTool;
36
+ command?: string;
37
+ context: ReceiptOperationContext;
38
+ after?: ReceiptOperationAfter;
39
+ terminal: TerminalObservation;
40
+ }
41
+ export declare function parseReceiptOperationAfter(input: unknown): ReceiptOperationAfter | undefined;
42
+ export declare function parseReceiptOperationObservation(input: unknown): ReceiptOperationObservation | undefined;
43
+ export declare function createReceiptClassifier(options?: ReceiptClassifierOptions): ReceiptClassifier;
44
+ export type { ReceiptOperation };
@@ -0,0 +1,139 @@
1
+ import type { ReceiptDigestDomain, ReceiptReadbackFailureCategory, ReceiptReadbackProgression } from './receipt-readback.js';
2
+ export declare const RECEIPT_SCHEMA_VERSION: 1;
3
+ export declare const RECEIPT_PROTOCOL_VERSION: 1;
4
+ export type ReceiptOperation = 'implementation' | 'verification' | 'commit' | 'push' | 'pr-creation' | 'check-readback' | 'review-readback';
5
+ export type ReceiptClassificationOutcome = 'accepted' | 'rejected' | 'unavailable';
6
+ export type ReceiptAttribution = 'runtime-verified' | 'unattributed';
7
+ export type ReceiptResult = 'success' | 'failure' | 'unknown';
8
+ export type ReceiptSideEffect = 'required' | 'not-required';
9
+ export type TerminalStatus = 'success' | 'failure' | 'cancelled' | 'running' | 'unknown';
10
+ export type TerminalOutput = 'empty' | 'non-empty' | 'unknown';
11
+ export type DigestDomain = ReceiptDigestDomain;
12
+ export type ReceiptReasonCode = 'already-consumed' | 'abandoned-observation' | 'ambiguous-attribution' | 'classification-rejected' | 'classification-unavailable' | 'call-context-conflict' | 'classifier-closed' | 'cross-registration-disputed' | 'capability-mismatch' | 'duplicate-finalization' | 'empty-result' | 'epoch-mismatch' | 'forbidden-field' | 'grammar-incompatible' | 'incomplete-envelope' | 'invalid-observation' | 'invalid-receipt' | 'invalid-terminal-result' | 'no-op-resource' | 'parser-asset-unavailable' | 'parser-failure' | 'prohibited-shell-shape' | 'successful-no-op' | 'terminal-failure' | 'terminal-cancelled' | 'terminal-running' | 'terminal-unknown' | 'unknown-envelope' | 'unknown-receipt' | 'unit-mismatch' | 'unchanged-worktree' | 'unchanged-worktree' | 'unsupported-command' | 'workspace-mismatch' | 'recognized-command';
13
+ export interface ReceiptClassification {
14
+ outcome: ReceiptClassificationOutcome;
15
+ category: ReceiptOperation | null;
16
+ attribution: ReceiptAttribution;
17
+ result: ReceiptResult;
18
+ sideEffect: ReceiptSideEffect;
19
+ reasonCode: ReceiptReasonCode;
20
+ }
21
+ export interface ReceiptContext {
22
+ epochId: string;
23
+ unitId: string;
24
+ workspaceIdentity: string;
25
+ repositoryIdentity?: string;
26
+ worktreeIdentity?: string;
27
+ resourceIdentity?: string;
28
+ }
29
+ export interface ReceiptObservationAfter {
30
+ workspaceIdentity: string;
31
+ repositoryIdentity?: string;
32
+ worktreeIdentity?: string;
33
+ resourceIdentity?: string;
34
+ }
35
+ export interface TerminalObservation {
36
+ status: TerminalStatus;
37
+ output: TerminalOutput;
38
+ noOp: boolean;
39
+ }
40
+ export interface ReceiptLedgerOptions {
41
+ registrationIdentity?: string;
42
+ capabilityFlags?: readonly string[];
43
+ sessionSalt?: Uint8Array;
44
+ }
45
+ export interface ReceiptLedgerMetadata {
46
+ schemaVersion: typeof RECEIPT_SCHEMA_VERSION;
47
+ protocolVersion: typeof RECEIPT_PROTOCOL_VERSION;
48
+ registrationDigest: string;
49
+ capabilityFlags: readonly string[];
50
+ }
51
+ export interface CanonicalReceiptFields {
52
+ receiptId: string;
53
+ registrationDigest: string;
54
+ callDigest: string;
55
+ epochDigest: string;
56
+ unitDigest: string;
57
+ workspaceDigest: string;
58
+ repositoryDigest?: string;
59
+ worktreeDigest?: string;
60
+ resourceDigest?: string;
61
+ operation: ReceiptOperation;
62
+ result: 'success';
63
+ source: 'runtime-verified';
64
+ consumption: 'available' | 'consumed';
65
+ timestamp: number;
66
+ }
67
+ export interface ReceiptEnvelope {
68
+ schemaVersion: typeof RECEIPT_SCHEMA_VERSION;
69
+ protocolVersion: typeof RECEIPT_PROTOCOL_VERSION;
70
+ registrationDigest: string;
71
+ capabilityFlags: readonly string[];
72
+ compatibility: 'compatible';
73
+ canonical: CanonicalReceiptFields;
74
+ }
75
+ export type PrepareObservationResult = {
76
+ status: 'prepared';
77
+ preparationId: string;
78
+ } | {
79
+ status: 'duplicate' | 'rejected';
80
+ reasonCode: ReceiptReasonCode;
81
+ };
82
+ export type FinalizeObservationResult = {
83
+ status: 'finalized';
84
+ receipt: ReceiptEnvelope;
85
+ } | {
86
+ status: 'rejected';
87
+ reasonCode: ReceiptReasonCode;
88
+ };
89
+ export type AbandonObservationResult = {
90
+ status: 'abandoned';
91
+ } | {
92
+ status: 'rejected';
93
+ reasonCode: ReceiptReasonCode;
94
+ };
95
+ export type ConsumeReceiptResult = {
96
+ status: 'consumed';
97
+ receipt: ReceiptEnvelope;
98
+ } | {
99
+ status: 'rejected';
100
+ reasonCode: ReceiptReasonCode;
101
+ };
102
+ export type RecoverReceiptResult = {
103
+ status: 'recovered' | 'duplicate';
104
+ receipt: ReceiptEnvelope;
105
+ } | {
106
+ status: 'rejected';
107
+ category: ReceiptReadbackFailureCategory;
108
+ };
109
+ export type RecoverReadbackResult = {
110
+ status: 'recovered' | 'duplicate';
111
+ receipts: readonly ReceiptEnvelope[];
112
+ progression: ReceiptReadbackProgression;
113
+ } | {
114
+ status: 'rejected';
115
+ category: ReceiptReadbackFailureCategory;
116
+ };
117
+ export type EnvelopeValidationResult = {
118
+ compatibility: 'compatible';
119
+ envelope: ReceiptEnvelope;
120
+ } | {
121
+ compatibility: 'unavailable' | 'rejected';
122
+ reasonCode: ReceiptReasonCode;
123
+ };
124
+ export interface ReceiptLedger {
125
+ readonly metadata: ReceiptLedgerMetadata;
126
+ digestIdentity(domain: DigestDomain, identity: string): string;
127
+ prepareObservation(input: unknown): PrepareObservationResult;
128
+ finalizeObservation(input: unknown): FinalizeObservationResult;
129
+ abandonObservation(input: unknown): AbandonObservationResult;
130
+ consumeReceipt(receiptId: unknown, context: unknown): ConsumeReceiptResult;
131
+ recoverReceipt(input: unknown): RecoverReceiptResult;
132
+ recoverReadback(input: readonly unknown[]): RecoverReadbackResult;
133
+ getProgressionState(): ReceiptReadbackProgression;
134
+ validateEnvelope(input: unknown): EnvelopeValidationResult;
135
+ getEnvelope(receiptId: unknown): ReceiptEnvelope | undefined;
136
+ listReceipts(): readonly ReceiptEnvelope[];
137
+ getSessionSalt(): Uint8Array;
138
+ }
139
+ export declare function createReceiptLedger(options?: ReceiptLedgerOptions): ReceiptLedger;
@@ -0,0 +1,164 @@
1
+ import type { ReceiptEnvelope, ReceiptLedgerMetadata, ReceiptOperation } from './receipt-ledger.js';
2
+ export declare const RECEIPT_READBACK_SCHEMA_VERSION: 1;
3
+ export declare const RECEIPT_READBACK_PROTOCOL_VERSION: 1;
4
+ export type ReceiptDigestDomain = 'repository' | 'worktree' | 'resource' | 'workspace' | 'epoch' | 'unit' | 'call' | 'registration';
5
+ export type ReceiptProgressionStateName = 'started' | 'completed';
6
+ export type ReceiptEpochFamily = 'work' | 'shipping';
7
+ export interface ReceiptResourceScope {
8
+ readonly operation: ReceiptOperation;
9
+ readonly resourceIdentity: string;
10
+ }
11
+ export type ReceiptReadbackFailureCategory = 'malformed' | 'forbidden-field' | 'unknown-kind' | 'unknown-schema' | 'unknown-protocol' | 'unknown-capability' | 'integrity-mismatch' | 'missing-mint' | 'control-before-mint' | 'conflicting-marker' | 'out-of-order' | 'cross-registration' | 'capability-mismatch' | 'salt-mismatch' | 'receipt-mismatch' | 'progression-mismatch' | 'inconsistent-evidence' | 'missing-internal-id' | 'identity-digest-mismatch' | 'conflicting-seed' | 'missing-seed';
12
+ export interface ReceiptMintMarker {
13
+ readonly kind: 'mint';
14
+ readonly schemaVersion: typeof RECEIPT_READBACK_SCHEMA_VERSION;
15
+ readonly protocolVersion: typeof RECEIPT_READBACK_PROTOCOL_VERSION;
16
+ readonly envelope: ReceiptEnvelope;
17
+ readonly sessionSalt: string;
18
+ readonly integrity: string;
19
+ }
20
+ export interface ReceiptConsumeMarker {
21
+ readonly kind: 'control';
22
+ readonly schemaVersion: typeof RECEIPT_READBACK_SCHEMA_VERSION;
23
+ readonly protocolVersion: typeof RECEIPT_READBACK_PROTOCOL_VERSION;
24
+ readonly registrationDigest: string;
25
+ readonly capabilityFlags: readonly string[];
26
+ readonly control: 'consume';
27
+ readonly receiptId: string;
28
+ readonly transitionDigest: string;
29
+ readonly timestamp: number;
30
+ readonly integrity: string;
31
+ }
32
+ export interface ReceiptEpochProgressionMarker {
33
+ readonly kind: 'control';
34
+ readonly schemaVersion: typeof RECEIPT_READBACK_SCHEMA_VERSION;
35
+ readonly protocolVersion: typeof RECEIPT_READBACK_PROTOCOL_VERSION;
36
+ readonly registrationDigest: string;
37
+ readonly capabilityFlags: readonly string[];
38
+ readonly control: 'progression';
39
+ readonly target: 'epoch';
40
+ readonly epochId: string;
41
+ readonly epochDigest: string;
42
+ readonly family: ReceiptEpochFamily;
43
+ readonly state: ReceiptProgressionStateName;
44
+ readonly transitionDigest: string;
45
+ readonly timestamp: number;
46
+ readonly sessionSalt: string;
47
+ readonly integrity: string;
48
+ }
49
+ export interface ReceiptUnitProgressionMarker {
50
+ readonly kind: 'control';
51
+ readonly schemaVersion: typeof RECEIPT_READBACK_SCHEMA_VERSION;
52
+ readonly protocolVersion: typeof RECEIPT_READBACK_PROTOCOL_VERSION;
53
+ readonly registrationDigest: string;
54
+ readonly capabilityFlags: readonly string[];
55
+ readonly control: 'progression';
56
+ readonly target: 'unit';
57
+ readonly epochId: string;
58
+ readonly epochDigest: string;
59
+ readonly unitId: string;
60
+ readonly unitDigest: string;
61
+ readonly family: ReceiptEpochFamily;
62
+ readonly requiredOperations: readonly ReceiptOperation[];
63
+ readonly resourceScopes: readonly ReceiptResourceScope[];
64
+ readonly state: ReceiptProgressionStateName;
65
+ readonly transitionDigest: string;
66
+ readonly timestamp: number;
67
+ readonly sessionSalt: string;
68
+ readonly integrity: string;
69
+ }
70
+ export type ReceiptProgressionMarker = ReceiptEpochProgressionMarker | ReceiptUnitProgressionMarker;
71
+ export type ReceiptControlMarker = ReceiptConsumeMarker | ReceiptProgressionMarker;
72
+ export type ReceiptMarker = ReceiptMintMarker | ReceiptControlMarker;
73
+ export type ReceiptProgressionMarkerInput = {
74
+ readonly target: 'epoch';
75
+ readonly state: ReceiptProgressionStateName;
76
+ readonly epochId: string;
77
+ readonly family: ReceiptEpochFamily;
78
+ readonly transitionDigest: string;
79
+ readonly timestamp?: number;
80
+ } | {
81
+ readonly target: 'unit';
82
+ readonly state: ReceiptProgressionStateName;
83
+ readonly epochId: string;
84
+ readonly unitId: string;
85
+ readonly family: ReceiptEpochFamily;
86
+ readonly requiredOperations: readonly ReceiptOperation[];
87
+ readonly resourceScopes: readonly ReceiptResourceScope[];
88
+ readonly transitionDigest: string;
89
+ readonly timestamp?: number;
90
+ };
91
+ export interface ReceiptProgressionProjectionSource {
92
+ readonly metadata: ReceiptLedgerMetadata | (() => ReceiptLedgerMetadata);
93
+ readonly getSessionSalt: () => Uint8Array;
94
+ readonly digestIdentity: (domain: ReceiptDigestDomain, identity: string) => string;
95
+ }
96
+ export interface ReceiptReadbackExpectation {
97
+ readonly registrationDigest: string;
98
+ readonly capabilityFlags: readonly string[];
99
+ readonly sessionSalt: Uint8Array;
100
+ readonly source?: 'runtime-verified';
101
+ }
102
+ export type ReceiptEpochProgressionSnapshot = {
103
+ readonly target: 'epoch';
104
+ readonly state: ReceiptProgressionStateName;
105
+ readonly epochId: string;
106
+ readonly epochDigest: string;
107
+ readonly family: ReceiptEpochFamily;
108
+ readonly transitionDigest: string;
109
+ };
110
+ export type ReceiptUnitProgressionSnapshot = {
111
+ readonly target: 'unit';
112
+ readonly state: ReceiptProgressionStateName;
113
+ readonly epochId: string;
114
+ readonly epochDigest: string;
115
+ readonly unitId: string;
116
+ readonly unitDigest: string;
117
+ readonly family: ReceiptEpochFamily;
118
+ readonly requiredOperations: readonly ReceiptOperation[];
119
+ readonly resourceScopes: readonly ReceiptResourceScope[];
120
+ readonly transitionDigest: string;
121
+ };
122
+ export type ReceiptProgressionSnapshot = ReceiptEpochProgressionSnapshot | ReceiptUnitProgressionSnapshot;
123
+ export interface ReceiptReadbackProgression {
124
+ readonly epoch: ReceiptEpochProgressionSnapshot | null;
125
+ readonly unit: ReceiptUnitProgressionSnapshot | null;
126
+ }
127
+ export interface ReceiptReadbackState {
128
+ readonly registrationDigest: string;
129
+ readonly receipts: readonly ReceiptEnvelope[];
130
+ readonly progression: ReceiptReadbackProgression;
131
+ }
132
+ export type ReceiptMarkerValidation = {
133
+ readonly status: 'valid';
134
+ readonly marker: ReceiptMarker;
135
+ } | {
136
+ readonly status: 'rejected';
137
+ readonly category: ReceiptReadbackFailureCategory;
138
+ };
139
+ export type ReceiptReadbackResult = {
140
+ readonly status: 'reconstructed';
141
+ readonly state: ReceiptReadbackState;
142
+ } | {
143
+ readonly status: 'rejected';
144
+ readonly category: ReceiptReadbackFailureCategory;
145
+ };
146
+ export type ReceiptReadbackSeedResult = {
147
+ readonly status: 'empty';
148
+ } | {
149
+ readonly status: 'ready';
150
+ readonly sessionSalt: Uint8Array;
151
+ readonly registrationDigest: string;
152
+ readonly capabilityFlags: readonly string[];
153
+ } | {
154
+ readonly status: 'repair-required';
155
+ readonly category: ReceiptReadbackFailureCategory;
156
+ };
157
+ export declare function digestReceiptIdentity(domain: ReceiptDigestDomain, identity: string, sessionSalt: Uint8Array): string;
158
+ export declare function validateReceiptMarker(input: unknown): ReceiptMarkerValidation;
159
+ export declare function extractReceiptReadbackSeed(inputs: readonly unknown[]): ReceiptReadbackSeedResult;
160
+ export declare function projectReceiptMintMarker(receipt: unknown, sessionSalt: Uint8Array): ReceiptMintMarker | undefined;
161
+ export declare function projectReceiptConsumptionMarker(receipt: unknown, transitionDigest: string, timestamp?: number): ReceiptConsumeMarker | undefined;
162
+ export declare function projectReceiptProgressionMarker(source: ReceiptProgressionProjectionSource, input: ReceiptProgressionMarkerInput): ReceiptProgressionMarker | undefined;
163
+ export declare function foldReceiptReadback(inputs: readonly unknown[], expectation: ReceiptReadbackExpectation): ReceiptReadbackResult;
164
+ export declare function receiptReadbackExpectationFromMetadata(metadata: ReceiptLedgerMetadata, sessionSalt: Uint8Array): ReceiptReadbackExpectation;