@hasna/infinity 0.1.0

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.
Files changed (112) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +331 -0
  3. package/dist/cli.js +2965 -0
  4. package/dist/http-api.js +6448 -0
  5. package/dist/index.js +28536 -0
  6. package/dist/migrate.js +346 -0
  7. package/dist/self-hosted-migrate.js +2064 -0
  8. package/dist/self-hosted.js +13180 -0
  9. package/dist/types/authcapsules/codewith-local.d.ts +109 -0
  10. package/dist/types/authcapsules/infinity-agent-policy.d.ts +57 -0
  11. package/dist/types/authcapsules/os-isolated-runner.d.ts +87 -0
  12. package/dist/types/authority/authority.d.ts +342 -0
  13. package/dist/types/authority/effect-journal.d.ts +205 -0
  14. package/dist/types/authority/mutation-journal.d.ts +163 -0
  15. package/dist/types/authority/mutation-tuple.d.ts +26 -0
  16. package/dist/types/authority/state.d.ts +75 -0
  17. package/dist/types/authority/store.d.ts +15 -0
  18. package/dist/types/brokers/checkpoint/archive.d.ts +21 -0
  19. package/dist/types/brokers/checkpoint/bundle.d.ts +22 -0
  20. package/dist/types/brokers/checkpoint/bytes.d.ts +4 -0
  21. package/dist/types/brokers/checkpoint/clean-verifier-finalization.d.ts +62 -0
  22. package/dist/types/brokers/checkpoint/clean-verifier.d.ts +145 -0
  23. package/dist/types/brokers/checkpoint/final-trust-authority.d.ts +55 -0
  24. package/dist/types/brokers/checkpoint/idempotency.d.ts +25 -0
  25. package/dist/types/brokers/checkpoint/journaled-store.d.ts +9 -0
  26. package/dist/types/brokers/checkpoint/manifest-signature.d.ts +135 -0
  27. package/dist/types/brokers/checkpoint/manifest.d.ts +57 -0
  28. package/dist/types/brokers/checkpoint/s3-store.d.ts +215 -0
  29. package/dist/types/brokers/checkpoint/seal-authority.d.ts +86 -0
  30. package/dist/types/brokers/checkpoint/service.d.ts +198 -0
  31. package/dist/types/brokers/checkpoint/signing-message.d.ts +22 -0
  32. package/dist/types/brokers/checkpoint/store.d.ts +76 -0
  33. package/dist/types/brokers/checkpoint/verifier-cleanup-authority.d.ts +108 -0
  34. package/dist/types/brokers/checkpoint/verifier-cleanup.d.ts +391 -0
  35. package/dist/types/brokers/checkpoint/verifier.d.ts +225 -0
  36. package/dist/types/brokers/composition.d.ts +86 -0
  37. package/dist/types/brokers/git/github-app.d.ts +216 -0
  38. package/dist/types/brokers/git/promotion.d.ts +418 -0
  39. package/dist/types/brokers/persistence/contracts.d.ts +77 -0
  40. package/dist/types/brokers/persistence/memory.d.ts +5 -0
  41. package/dist/types/brokers/persistence/migration.d.ts +6 -0
  42. package/dist/types/brokers/persistence/postgres.d.ts +74 -0
  43. package/dist/types/cli/main.d.ts +2 -0
  44. package/dist/types/cli/operation-journal.d.ts +47 -0
  45. package/dist/types/cli/run.d.ts +15 -0
  46. package/dist/types/client/operator-client.d.ts +100 -0
  47. package/dist/types/contracts/dtos.d.ts +198 -0
  48. package/dist/types/contracts/events.d.ts +45 -0
  49. package/dist/types/contracts/fence.d.ts +39 -0
  50. package/dist/types/contracts/operations.d.ts +91 -0
  51. package/dist/types/contracts/runspec.d.ts +75 -0
  52. package/dist/types/contracts/validators.d.ts +8 -0
  53. package/dist/types/core/clock.d.ts +12 -0
  54. package/dist/types/core/errors.d.ts +18 -0
  55. package/dist/types/core/ids.d.ts +10 -0
  56. package/dist/types/core/int64.d.ts +7 -0
  57. package/dist/types/core/strict-json.d.ts +8 -0
  58. package/dist/types/core/validation.d.ts +25 -0
  59. package/dist/types/golden/disposable-task.d.ts +108 -0
  60. package/dist/types/golden/source-pins.d.ts +77 -0
  61. package/dist/types/http/api.d.ts +52 -0
  62. package/dist/types/http/bearer-auth.d.ts +8 -0
  63. package/dist/types/http/main.d.ts +3 -0
  64. package/dist/types/http/self-hosted-main.d.ts +17 -0
  65. package/dist/types/index.d.ts +65 -0
  66. package/dist/types/mcp/schema.d.ts +7 -0
  67. package/dist/types/node-agent/agent.d.ts +174 -0
  68. package/dist/types/node-agent/contracts.d.ts +119 -0
  69. package/dist/types/node-agent/macos-service.d.ts +33 -0
  70. package/dist/types/node-agent/service-cli.d.ts +26 -0
  71. package/dist/types/persistence/composition.d.ts +49 -0
  72. package/dist/types/persistence/migrate-main.d.ts +2 -0
  73. package/dist/types/persistence/migrations.d.ts +30 -0
  74. package/dist/types/persistence/postgres-accounts-operation.d.ts +26 -0
  75. package/dist/types/persistence/postgres-authority.d.ts +69 -0
  76. package/dist/types/persistence/postgres-external-mutation-journal.d.ts +22 -0
  77. package/dist/types/persistence/postgres-json.d.ts +1 -0
  78. package/dist/types/persistence/postgres-mutation-journal.d.ts +31 -0
  79. package/dist/types/persistence/postgres-reconciler.d.ts +34 -0
  80. package/dist/types/persistence/postgres-sandbox-dispatch-authority.d.ts +9 -0
  81. package/dist/types/persistence/self-hosted-migrate-main.d.ts +2 -0
  82. package/dist/types/ports/accounts-operation.d.ts +336 -0
  83. package/dist/types/ports/accounts.d.ts +293 -0
  84. package/dist/types/ports/sandbox-dispatch-authority.d.ts +154 -0
  85. package/dist/types/ports/sandboxes.d.ts +40 -0
  86. package/dist/types/providers/sandbox-dispatch.d.ts +143 -0
  87. package/dist/types/runtime/config.d.ts +61 -0
  88. package/dist/types/runtime/postgres.d.ts +18 -0
  89. package/dist/types/runtime/provider-activation.d.ts +45 -0
  90. package/dist/types/runtime/server.d.ts +68 -0
  91. package/dist/types/testing/accounts-fake.d.ts +31 -0
  92. package/dist/types/testing/fakes.d.ts +2 -0
  93. package/dist/types/testing/node-control-plane-fake.d.ts +20 -0
  94. package/dist/types/testing/reference.d.ts +27 -0
  95. package/dist/types/testing/sandboxes-fake.d.ts +22 -0
  96. package/evidence/provider-live-daytona-v3.json +1 -0
  97. package/evidence/provider-live-e2b-v3.json +1 -0
  98. package/evidence/provider-production-route-daytona-v1.json +1 -0
  99. package/evidence/provider-production-route-e2b-v1.json +1 -0
  100. package/migrations/0001_authority.sql +689 -0
  101. package/migrations/0002_effect_step_global_owner.sql +2 -0
  102. package/migrations/0003_effect_journal_observed_head.sql +34 -0
  103. package/migrations/0004_authority_mutation_journal_binding.sql +15 -0
  104. package/migrations/20260710_checkpoint_broker_v1.sql +163 -0
  105. package/migrations/20260711_accounts_operation_v1.sql +137 -0
  106. package/migrations/20260711_checkpoint_trust_v2.sql +17 -0
  107. package/migrations/20260711_verifier_cleanup_v2.sql +169 -0
  108. package/migrations/20260711_z_accounts_claim_authority_v2.sql +172 -0
  109. package/migrations/20260711_zz_sandbox_dispatch_authority_v1.sql +143 -0
  110. package/migrations/20260712_sandbox_dispatch_authority_v2.sql +58 -0
  111. package/migrations/external-journal/0001_external_authority_mutation_journal.sql +175 -0
  112. package/package.json +47 -0
@@ -0,0 +1,205 @@
1
+ import { type Int64 } from "../core/int64";
2
+ import { type AuthenticatedFenceContext, type BrokerFence, type BrokerFenceInput } from "../contracts/fence";
3
+ export declare const OPERATION_STEP_SCHEMA_VERSION: "infinity.operation-step/v1";
4
+ export declare const EFFECT_JOURNAL_RECORD_SCHEMA_VERSION: "infinity.effect-journal-record/v1";
5
+ export declare const EFFECT_JOURNAL_OUTCOME_SCHEMA_VERSION: "infinity.effect-journal-outcome/v1";
6
+ export declare const EFFECT_JOURNAL_ANCHOR_SCHEMA_VERSION: "infinity.effect-journal-anchor/v1";
7
+ export declare const EFFECT_JOURNAL_RANGE_SCHEMA_VERSION: "infinity.effect-journal-range/v1";
8
+ export declare const EFFECT_JOURNAL_HEAD_SCHEMA_VERSION: "infinity.effect-journal-head/v1";
9
+ export declare const EFFECT_JOURNAL_PROTECTION_SCHEMA_VERSION: "infinity.effect-journal-protection/v1";
10
+ export declare const EFFECT_JOURNAL_OUTCOME_KINDS: readonly ["succeeded", "failed_effect", "failed_no_effect", "reconciliation_blocked"];
11
+ export type EffectJournalOutcomeKind = typeof EFFECT_JOURNAL_OUTCOME_KINDS[number];
12
+ export type EffectJournalRecordKind = "DISPATCHED" | "OUTCOME";
13
+ export declare const EFFECT_JOURNAL_OUTCOME_SCHEMA: {
14
+ schema_version: "infinity.effect-journal-outcome/v1";
15
+ record_kind: string;
16
+ outcome_kinds: ("succeeded" | "failed_effect" | "failed_no_effect" | "reconciliation_blocked")[];
17
+ ambiguity_outcome: string;
18
+ unknown_representation: string;
19
+ };
20
+ export declare const EFFECT_JOURNAL_OUTCOME_SCHEMA_DIGEST: string;
21
+ export interface OperationStepInput {
22
+ schema_version: typeof OPERATION_STEP_SCHEMA_VERSION;
23
+ operation_id: string;
24
+ operation_step_id: string;
25
+ step_ordinal: number;
26
+ operation_digest: string;
27
+ request_digest: string;
28
+ target_digest: string;
29
+ resource_id: string;
30
+ resource_lifecycle_generation: Int64;
31
+ predecessor_receipt_digest: string | null;
32
+ provider_idempotency_token: string;
33
+ }
34
+ export type OperationStep = Readonly<OperationStepInput>;
35
+ export interface EffectJournalRecordInput {
36
+ schema_version: typeof EFFECT_JOURNAL_RECORD_SCHEMA_VERSION;
37
+ operation_id: string;
38
+ operation_step_id: string;
39
+ operation_execution_epoch: Int64;
40
+ record_kind: EffectJournalRecordKind;
41
+ outcome_kind: EffectJournalOutcomeKind | null;
42
+ outcome_schema_version: typeof EFFECT_JOURNAL_OUTCOME_SCHEMA_VERSION;
43
+ outcome_schema_digest: string;
44
+ operation_digest: string;
45
+ operation_step_digest: string;
46
+ request_digest: string;
47
+ target_digest: string;
48
+ resource_id: string;
49
+ resource_lifecycle_generation: Int64;
50
+ predecessor_receipt_digest: string | null;
51
+ provider_idempotency_token: string;
52
+ fence: BrokerFenceInput;
53
+ outcome_receipt_digest: string | null;
54
+ }
55
+ export interface EffectJournalRecord extends Omit<EffectJournalRecordInput, "fence"> {
56
+ fence: BrokerFence;
57
+ }
58
+ export interface StoredEffectJournalRecord {
59
+ anchor_schema_version: typeof EFFECT_JOURNAL_ANCHOR_SCHEMA_VERSION;
60
+ journal_sequence: Int64;
61
+ prior_frontier_digest: string | null;
62
+ record_digest: string;
63
+ frontier_digest: string;
64
+ signer_principal: string;
65
+ signing_key_id: string;
66
+ signature: string;
67
+ operation_step: OperationStep;
68
+ record: Readonly<EffectJournalRecord>;
69
+ }
70
+ export interface EffectJournalProtection {
71
+ protection_schema_version: typeof EFFECT_JOURNAL_PROTECTION_SCHEMA_VERSION;
72
+ restore_domain_id: string;
73
+ encrypted_at_rest: boolean;
74
+ }
75
+ export interface EffectJournalHeadReceipt {
76
+ head_schema_version: typeof EFFECT_JOURNAL_HEAD_SCHEMA_VERSION;
77
+ challenge: string;
78
+ journal_sequence: Int64;
79
+ frontier_digest: string | null;
80
+ restore_domain_id: string;
81
+ encrypted_at_rest: true;
82
+ observed_at: string;
83
+ signer_principal: string;
84
+ signing_key_id: string;
85
+ signature: string;
86
+ }
87
+ export interface EffectJournalRange {
88
+ range_schema_version: typeof EFFECT_JOURNAL_RANGE_SCHEMA_VERSION;
89
+ from_sequence: Int64;
90
+ through_sequence: Int64;
91
+ prior_frontier_digest: string | null;
92
+ anchors: Readonly<StoredEffectJournalRecord>[];
93
+ head: Readonly<EffectJournalHeadReceipt>;
94
+ signer_principal: string;
95
+ signing_key_id: string;
96
+ signature: string;
97
+ }
98
+ export interface EffectJournalPort {
99
+ describe(): Readonly<EffectJournalProtection> | Promise<Readonly<EffectJournalProtection>>;
100
+ readRange(fromSequence: Int64, limit: number, challenge: string): Readonly<EffectJournalRange> | Promise<Readonly<EffectJournalRange>>;
101
+ head(challenge: string): Readonly<EffectJournalHeadReceipt> | Promise<Readonly<EffectJournalHeadReceipt>>;
102
+ }
103
+ export interface SynchronousEffectJournalPort extends EffectJournalPort {
104
+ describe(): Readonly<EffectJournalProtection>;
105
+ readRange(fromSequence: Int64, limit: number, challenge: string): Readonly<EffectJournalRange>;
106
+ head(challenge: string): Readonly<EffectJournalHeadReceipt>;
107
+ }
108
+ export interface EffectJournalReceiptVerifier {
109
+ verifyStoredAnchor(value: unknown): Readonly<StoredEffectJournalRecord>;
110
+ verifyHead(value: unknown): Readonly<EffectJournalHeadReceipt>;
111
+ verifyRange(value: unknown): Readonly<EffectJournalRange>;
112
+ }
113
+ export interface EffectJournalSigner {
114
+ readonly signerPrincipal: string;
115
+ readonly signingKeyId: string;
116
+ sign(canonicalPayload: string): string;
117
+ verify(canonicalPayload: string, signature: string): boolean;
118
+ }
119
+ export declare class Ed25519EffectJournalSigner implements EffectJournalSigner {
120
+ private readonly privateKey;
121
+ private readonly publicKey;
122
+ readonly signerPrincipal: string;
123
+ readonly signingKeyId: string;
124
+ private constructor();
125
+ static generate(signerPrincipal: string, signingKeyId: string): Ed25519EffectJournalSigner;
126
+ publicKeySpki(): string;
127
+ sign(canonicalPayload: string): string;
128
+ verify(canonicalPayload: string, signature: string): boolean;
129
+ }
130
+ export declare class Ed25519EffectJournalVerifier {
131
+ readonly signerPrincipal: string;
132
+ readonly signingKeyId: string;
133
+ private readonly publicKey;
134
+ private constructor();
135
+ static fromSpki(signerPrincipal: string, signingKeyId: string, publicKeySpki: string): Ed25519EffectJournalVerifier;
136
+ verifyStoredAnchor(value: unknown): Readonly<StoredEffectJournalRecord>;
137
+ verifyHead(value: unknown): Readonly<EffectJournalHeadReceipt>;
138
+ verifyRange(value: unknown): Readonly<EffectJournalRange>;
139
+ }
140
+ export interface EffectJournalAppendAuthorization {
141
+ readonly currentFence: BrokerFenceInput;
142
+ readonly authenticated: AuthenticatedFenceContext;
143
+ readonly verifiedOutcomeReceiptDigest: string | null;
144
+ }
145
+ export interface EffectJournalAppendAuthorizer {
146
+ /**
147
+ * Trusted boundary hook. Implementations authenticate transport identity,
148
+ * read the current fence independently, and verify typed outcome evidence.
149
+ */
150
+ authorize(record: Readonly<EffectJournalRecord>): EffectJournalAppendAuthorization;
151
+ }
152
+ export declare const RECONCILIATION_BLOCKED_MAPPING_FIXTURE: {
153
+ readonly mapping_schema_version: "infinity.effect-outcome-mapping/v1";
154
+ readonly source_outcome_schema_version: "infinity.effect-journal-outcome/v1";
155
+ readonly source_outcome_schema_digest: string;
156
+ readonly external_outcome_kind: "reconciliation_blocked";
157
+ readonly infinity_operation_state: "quarantined";
158
+ readonly infinity_resource_state: "quarantined";
159
+ };
160
+ export declare function parseOperationStep(value: unknown): OperationStep;
161
+ export declare function operationStepDigest(step: OperationStep): string;
162
+ export declare function auditEffectJournalTransitions(stepsInput: readonly OperationStep[], anchorsInput: readonly Readonly<StoredEffectJournalRecord>[]): void;
163
+ export declare function parseEffectJournalRecord(value: unknown): Readonly<EffectJournalRecord>;
164
+ export declare class InMemoryEffectJournal implements SynchronousEffectJournalPort, EffectJournalReceiptVerifier {
165
+ private readonly signer;
166
+ private readonly authorizer;
167
+ private readonly steps;
168
+ private readonly stepOwners;
169
+ private readonly stepOrdinals;
170
+ private readonly records;
171
+ private readonly recordsBySequence;
172
+ private readonly latestExecutionEpoch;
173
+ private journalFrontier;
174
+ private journalFrontierDigest;
175
+ private available;
176
+ private readonly protection;
177
+ constructor(signer: EffectJournalSigner, authorizer: EffectJournalAppendAuthorizer, protection: {
178
+ restore_domain_id: string;
179
+ encrypted_at_rest: boolean;
180
+ });
181
+ setAvailable(available: boolean): void;
182
+ describe(): Readonly<EffectJournalProtection>;
183
+ registerStep(value: unknown): OperationStep;
184
+ append(value: unknown): Readonly<StoredEffectJournalRecord>;
185
+ frontier(): Int64;
186
+ frontierDigest(): string | null;
187
+ verifyAnchor(value: unknown): Readonly<StoredEffectJournalRecord>;
188
+ verifyStoredAnchor(value: unknown): Readonly<StoredEffectJournalRecord>;
189
+ verifyHead(value: unknown): Readonly<EffectJournalHeadReceipt>;
190
+ verifyRange(value: unknown): Readonly<EffectJournalRange>;
191
+ readRange(fromSequenceInput: Int64, limitInput: number, challengeInput: string): Readonly<EffectJournalRange>;
192
+ head(challengeInput: string): Readonly<EffectJournalHeadReceipt>;
193
+ verifyContiguousFrontier(): void;
194
+ mapAuthenticatedReconciliationBlocked(value: unknown, currentFence: BrokerFence, authenticated: AuthenticatedFenceContext): typeof RECONCILIATION_BLOCKED_MAPPING_FIXTURE;
195
+ execution(operationId: string, operationStepId: string, executionEpoch: Int64): {
196
+ state: "unresolved" | "resolved";
197
+ dispatched: Readonly<StoredEffectJournalRecord>;
198
+ outcome: Readonly<StoredEffectJournalRecord> | null;
199
+ };
200
+ private assertAppendAuthorized;
201
+ private verifyStoredMembership;
202
+ private assertDispatchEpoch;
203
+ private requireAvailable;
204
+ }
205
+ export declare function assertEffectJournalSeparated(authorityRestoreDomainIdInput: string, protectionInput: EffectJournalProtection): Readonly<EffectJournalProtection>;
@@ -0,0 +1,163 @@
1
+ import { type Int64 } from "../core/int64";
2
+ import { type JsonValue } from "../core/strict-json";
3
+ export declare const AUTHORITY_MUTATION_ENVELOPE_SCHEMA_VERSION: "infinity.authority-mutation-reconstruction/v1";
4
+ export declare const AUTHORITY_MUTATION_ANCHOR_SCHEMA_VERSION: "infinity.authority-mutation-journal-anchor/v1";
5
+ export declare const AUTHORITY_MUTATION_ACK_SCHEMA_VERSION: "infinity.authority-mutation-journal-ack/v1";
6
+ export declare const AUTHORITY_MUTATION_RANGE_SCHEMA_VERSION: "infinity.authority-mutation-journal-range/v1";
7
+ export declare const AUTHORITY_MUTATION_PROTECTION_SCHEMA_VERSION: "infinity.authority-mutation-journal-protection/v1";
8
+ export type AuthorityMutationKind = "INSERT" | "UPDATE" | "DELETE";
9
+ export interface AuthorityMutationChange {
10
+ change_ordinal: number;
11
+ table_name: string;
12
+ mutation_kind: AuthorityMutationKind;
13
+ row_digest: string;
14
+ row: Readonly<Record<string, JsonValue>>;
15
+ }
16
+ export interface AuthorityMutationEnvelope {
17
+ schema_version: typeof AUTHORITY_MUTATION_ENVELOPE_SCHEMA_VERSION;
18
+ storage_schema_version: string;
19
+ authority_epoch: Int64;
20
+ commit_sequence: Int64;
21
+ operation_id: string;
22
+ operation_digest: string;
23
+ command: string;
24
+ actor_principal: string;
25
+ database_time: string;
26
+ changes: AuthorityMutationChange[];
27
+ }
28
+ export interface StoredAuthorityMutationAnchor {
29
+ anchor_schema_version: typeof AUTHORITY_MUTATION_ANCHOR_SCHEMA_VERSION;
30
+ journal_sequence: Int64;
31
+ prior_frontier_digest: string | null;
32
+ record_digest: string;
33
+ frontier_digest: string;
34
+ signer_principal: string;
35
+ signing_key_id: string;
36
+ signature: string;
37
+ record: Readonly<AuthorityMutationEnvelope>;
38
+ }
39
+ export interface AuthorityMutationJournalAcknowledgement {
40
+ ack_schema_version: typeof AUTHORITY_MUTATION_ACK_SCHEMA_VERSION;
41
+ acknowledged_through: Int64;
42
+ frontier_digest: string;
43
+ journal_id: string;
44
+ protection_digest: string;
45
+ restore_domain_id: string;
46
+ encrypted_at_rest: true;
47
+ signer_principal: string;
48
+ signing_key_id: string;
49
+ signature: string;
50
+ }
51
+ export interface AuthorityMutationAppendReceipt {
52
+ anchor: Readonly<StoredAuthorityMutationAnchor>;
53
+ ack: Readonly<AuthorityMutationJournalAcknowledgement>;
54
+ }
55
+ export interface AuthorityMutationJournalProtection {
56
+ protection_schema_version: typeof AUTHORITY_MUTATION_PROTECTION_SCHEMA_VERSION;
57
+ journal_id: string;
58
+ restore_domain_id: string;
59
+ encrypted_at_rest: boolean;
60
+ durability: "durable" | "transient";
61
+ signer_principal: string;
62
+ signing_key_id: string;
63
+ protection_digest: string;
64
+ }
65
+ export interface AuthorityMutationJournalRange {
66
+ range_schema_version: typeof AUTHORITY_MUTATION_RANGE_SCHEMA_VERSION;
67
+ from_sequence: Int64;
68
+ through_sequence: Int64;
69
+ prior_frontier_digest: string | null;
70
+ receipts: Readonly<AuthorityMutationAppendReceipt>[];
71
+ head: Readonly<AuthorityMutationJournalAcknowledgement> | null;
72
+ journal_id: string;
73
+ protection_digest: string;
74
+ signer_principal: string;
75
+ signing_key_id: string;
76
+ signature: string;
77
+ }
78
+ export interface AuthorityMutationJournalPort {
79
+ describe(): AuthorityMutationJournalProtection | Promise<AuthorityMutationJournalProtection>;
80
+ append(envelope: unknown): Readonly<AuthorityMutationAppendReceipt> | Promise<Readonly<AuthorityMutationAppendReceipt>>;
81
+ readRange(fromSequence: Int64, limit: number): Readonly<AuthorityMutationJournalRange> | Promise<Readonly<AuthorityMutationJournalRange>>;
82
+ head(): Readonly<AuthorityMutationJournalAcknowledgement> | null | Promise<Readonly<AuthorityMutationJournalAcknowledgement> | null>;
83
+ }
84
+ export interface SynchronousAuthorityMutationJournalPort extends AuthorityMutationJournalPort {
85
+ describe(): AuthorityMutationJournalProtection;
86
+ append(envelope: unknown): Readonly<AuthorityMutationAppendReceipt>;
87
+ readRange(fromSequence: Int64, limit: number): Readonly<AuthorityMutationJournalRange>;
88
+ head(): Readonly<AuthorityMutationJournalAcknowledgement> | null;
89
+ }
90
+ export interface AuthorityMutationJournalSigner {
91
+ readonly signerPrincipal: string;
92
+ readonly signingKeyId: string;
93
+ sign(canonicalPayload: string): string;
94
+ verify(canonicalPayload: string, signature: string): boolean;
95
+ }
96
+ export interface AuthorityMutationJournalReceiptVerifier {
97
+ readonly signerPrincipal: string;
98
+ readonly signingKeyId: string;
99
+ readonly verificationKeyDigest: string;
100
+ verifyAppendReceipt(value: unknown): Readonly<AuthorityMutationAppendReceipt>;
101
+ verifyAcknowledgement(value: unknown): Readonly<AuthorityMutationJournalAcknowledgement>;
102
+ verifyRange(value: unknown): Readonly<AuthorityMutationJournalRange>;
103
+ }
104
+ export declare class Ed25519AuthorityMutationJournalSigner implements AuthorityMutationJournalSigner {
105
+ private readonly privateKey;
106
+ private readonly publicKey;
107
+ readonly signerPrincipal: string;
108
+ readonly signingKeyId: string;
109
+ private constructor();
110
+ static generate(signerPrincipal: string, signingKeyId: string): Ed25519AuthorityMutationJournalSigner;
111
+ publicKeySpki(): string;
112
+ sign(canonicalPayload: string): string;
113
+ verify(canonicalPayload: string, signature: string): boolean;
114
+ }
115
+ export declare class Ed25519AuthorityMutationJournalVerifier implements AuthorityMutationJournalReceiptVerifier {
116
+ readonly signerPrincipal: string;
117
+ readonly signingKeyId: string;
118
+ private readonly publicKey;
119
+ readonly verificationKeyDigest: string;
120
+ private constructor();
121
+ static fromSpki(signerPrincipal: string, signingKeyId: string, publicKeySpki: string): Ed25519AuthorityMutationJournalVerifier;
122
+ verifyAnchor(value: unknown): Readonly<StoredAuthorityMutationAnchor>;
123
+ verifyAcknowledgement(value: unknown): Readonly<AuthorityMutationJournalAcknowledgement>;
124
+ verifyAppendReceipt(value: unknown): Readonly<AuthorityMutationAppendReceipt>;
125
+ verifyRange(value: unknown): Readonly<AuthorityMutationJournalRange>;
126
+ }
127
+ export declare class InMemoryAuthorityMutationJournal implements SynchronousAuthorityMutationJournalPort {
128
+ private readonly signer;
129
+ private readonly verifier;
130
+ private readonly receipts;
131
+ private frontier;
132
+ private frontierDigest;
133
+ private available;
134
+ private readonly protection;
135
+ constructor(signer: Ed25519AuthorityMutationJournalSigner, protection: {
136
+ restore_domain_id: string;
137
+ encrypted_at_rest: boolean;
138
+ });
139
+ setAvailable(available: boolean): void;
140
+ describe(): AuthorityMutationJournalProtection;
141
+ protected journalProtection(): AuthorityMutationJournalProtection;
142
+ append(value: unknown): Readonly<AuthorityMutationAppendReceipt>;
143
+ readRange(fromSequenceInput: Int64, limitInput: number): Readonly<AuthorityMutationJournalRange>;
144
+ head(): Readonly<AuthorityMutationJournalAcknowledgement> | null;
145
+ verifyStoredReceipt(value: unknown): Readonly<AuthorityMutationAppendReceipt>;
146
+ verifyAppendReceipt(value: unknown): Readonly<AuthorityMutationAppendReceipt>;
147
+ verifyAcknowledgement(value: unknown): Readonly<AuthorityMutationJournalAcknowledgement>;
148
+ verifyRange(value: unknown): Readonly<AuthorityMutationJournalRange>;
149
+ verifyContiguousFrontier(): void;
150
+ private requireAvailable;
151
+ }
152
+ export declare function parseAuthorityMutationEnvelope(value: unknown): Readonly<AuthorityMutationEnvelope>;
153
+ export declare function assertMutationResultMatchesReconstructionEnvelope(envelopeInput: unknown, expected: {
154
+ operationId: string;
155
+ command: string;
156
+ requestHash: string;
157
+ actorPrincipal: string;
158
+ scopeDigest: string;
159
+ idempotencyKey: string;
160
+ result: unknown;
161
+ }): Readonly<AuthorityMutationEnvelope>;
162
+ export declare function assertAuthorityMutationJournalSeparated(authorityRestoreDomainIdInput: string, protectionInput: AuthorityMutationJournalProtection): Readonly<AuthorityMutationJournalProtection>;
163
+ export declare function authorityMutationJournalProtectionDigest(protection: Omit<AuthorityMutationJournalProtection, "protection_digest">): string;
@@ -0,0 +1,26 @@
1
+ import type { Int64 } from "../core/int64";
2
+ import { type RunSpec } from "../contracts/runspec";
3
+ export interface SubmitRunMutationTuple {
4
+ readonly scope: {
5
+ readonly route_lineage_id: string;
6
+ readonly logical_work_key: string;
7
+ };
8
+ readonly request: {
9
+ readonly run_spec_digest: string;
10
+ readonly route_id: string;
11
+ readonly route_epoch: Int64;
12
+ };
13
+ }
14
+ export declare function submitRunMutationTuple(input: {
15
+ readonly spec: RunSpec;
16
+ readonly routeLineageId: string;
17
+ readonly routeId: string;
18
+ readonly routeEpoch: Int64;
19
+ }): SubmitRunMutationTuple;
20
+ export declare function mutationRequestHash(input: {
21
+ command: string;
22
+ scope: Readonly<Record<string, unknown>>;
23
+ request: Readonly<Record<string, unknown>>;
24
+ authorityEpoch: Int64;
25
+ idempotencyKey: string;
26
+ }): string;
@@ -0,0 +1,75 @@
1
+ import type { AdmissionKeyRecord, ApprovalRequestRecord, AttemptLeaseEvent, AttemptLeaseGrant, AttemptRecord, AuthorizationUseRecord, BudgetState, CheckpointRecord, IdempotencyRecord, LaneReservation, LaneSlot, QueueEntry, RunRecord, RunSpecRecord } from "../contracts/dtos";
2
+ import type { AuthorityEvent, OutboxRow } from "../contracts/events";
3
+ import type { Int64 } from "../core/int64";
4
+ import type { AuthorityMutationEnvelope } from "./mutation-journal";
5
+ import type { AccountsModelCallEffectJournalRecord, AccountsModelCallOperationRecord, AccountsOperationSignerHistoryPin, AccountsSerializationDomainState } from "../ports/accounts-operation";
6
+ export interface BudgetReservation {
7
+ run_id: string;
8
+ ceiling_units: number;
9
+ charged_units: number;
10
+ state: "reserved" | "settled" | "released";
11
+ }
12
+ export interface RouteRecord {
13
+ route_lineage_id: string;
14
+ route_id: string;
15
+ route_epoch: Int64;
16
+ state: "active" | "draining" | "inactive";
17
+ }
18
+ export interface AuthorityState {
19
+ authorityEpoch: Int64;
20
+ routes: Record<string, RouteRecord>;
21
+ runSpecs: Record<string, RunSpecRecord>;
22
+ runs: Record<string, RunRecord>;
23
+ attempts: Record<string, AttemptRecord>;
24
+ attemptLeaseGrants: Record<string, AttemptLeaseGrant>;
25
+ attemptLeaseEvents: AttemptLeaseEvent[];
26
+ queueEntries: Record<string, QueueEntry>;
27
+ laneSlots: Record<string, LaneSlot>;
28
+ laneReservations: Record<string, LaneReservation>;
29
+ laneFairnessCursor: Record<string, string | null>;
30
+ admissionKeys: Record<string, AdmissionKeyRecord>;
31
+ idempotencyByOperation: Record<string, IdempotencyRecord>;
32
+ idempotencyScopeIndex: Record<string, string>;
33
+ approvals: Record<string, ApprovalRequestRecord>;
34
+ authorizationUses: Record<string, AuthorizationUseRecord>;
35
+ checkpoints: Record<string, CheckpointRecord>;
36
+ events: AuthorityEvent[];
37
+ eventHeads: Record<string, {
38
+ sequence: number;
39
+ digest: string;
40
+ }>;
41
+ outbox: OutboxRow[];
42
+ budget: BudgetState;
43
+ budgetReservations: Record<string, BudgetReservation>;
44
+ nextQueueSequence: number;
45
+ nextAuthorityCommitSequence: number;
46
+ journalAcknowledgedThrough: number;
47
+ journalAcknowledgedFrontierDigest: string | null;
48
+ mutationJournalEnvelopes: Record<string, AuthorityMutationEnvelope>;
49
+ accountsModelCallOperations: Record<string, AccountsModelCallOperationRecord>;
50
+ accountsModelCallEffectJournal: AccountsModelCallEffectJournalRecord[];
51
+ accountsSerializationDomains: Record<string, AccountsSerializationDomainState>;
52
+ accountsOperationSignerHistoryPin: AccountsOperationSignerHistoryPin | null;
53
+ }
54
+ export interface AuthoritySnapshot {
55
+ authority_epoch: Int64;
56
+ routes: RouteRecord[];
57
+ run_specs: RunSpecRecord[];
58
+ runs: RunRecord[];
59
+ attempts: AttemptRecord[];
60
+ attempt_lease_grants: AttemptLeaseGrant[];
61
+ attempt_lease_events: AttemptLeaseEvent[];
62
+ queue_entries: QueueEntry[];
63
+ lane_slots: LaneSlot[];
64
+ lane_reservations: LaneReservation[];
65
+ live_lane_reservations: LaneReservation[];
66
+ admission_keys: AdmissionKeyRecord[];
67
+ idempotency_records: IdempotencyRecord[];
68
+ approvals: ApprovalRequestRecord[];
69
+ authorization_uses: AuthorizationUseRecord[];
70
+ checkpoints: CheckpointRecord[];
71
+ events: AuthorityEvent[];
72
+ outbox: OutboxRow[];
73
+ budget: BudgetState;
74
+ }
75
+ export declare function initialAuthorityState(authorityEpoch?: Int64): AuthorityState;
@@ -0,0 +1,15 @@
1
+ import { type AuthoritySnapshot, type AuthorityState } from "./state";
2
+ export type CrashStage = "before_commit" | "after_commit";
3
+ export declare class DeterministicFaultInjector {
4
+ private armedStage;
5
+ arm(stage: CrashStage): void;
6
+ hit(stage: CrashStage): void;
7
+ }
8
+ export declare class InMemoryAuthorityStore {
9
+ private readonly faults;
10
+ private state;
11
+ constructor(initial?: AuthorityState, faults?: DeterministicFaultInjector);
12
+ read<T>(reader: (state: Readonly<AuthorityState>) => T): T;
13
+ transaction<T>(mutation: (draft: AuthorityState) => T): T;
14
+ snapshot(): AuthoritySnapshot;
15
+ }
@@ -0,0 +1,21 @@
1
+ export type ArchiveEntryKind = "file" | "directory" | "symlink" | "hardlink" | "device" | "fifo" | "socket";
2
+ export interface ArchiveEntry {
3
+ path: string;
4
+ kind: ArchiveEntryKind;
5
+ byteLength: number;
6
+ compressedByteLength: number;
7
+ linkTarget?: string;
8
+ }
9
+ export interface ArchivePolicy {
10
+ maxEntries: number;
11
+ maxEntryBytes: number;
12
+ maxTotalBytes: number;
13
+ maxCompressionRatio: number;
14
+ }
15
+ export interface ArchiveIndexReceipt {
16
+ readonly entryCount: number;
17
+ readonly totalBytes: number;
18
+ readonly totalCompressedBytes: number;
19
+ }
20
+ export declare function archiveIndexDigest(entries: readonly ArchiveEntry[]): string;
21
+ export declare function validateArchiveIndex(entries: readonly ArchiveEntry[], policy: ArchivePolicy): ArchiveIndexReceipt;
@@ -0,0 +1,22 @@
1
+ import { type BinarySource } from "./bytes";
2
+ export interface GitBundleInspectionPolicy {
3
+ objectFormat: "sha1" | "sha256";
4
+ expectedBaseOid: string;
5
+ expectedCandidateOid: string;
6
+ maxBytes: number;
7
+ maxHeaderBytes: number;
8
+ maxPackObjects: number;
9
+ }
10
+ export interface GitBundleInspection {
11
+ readonly byteLength: number;
12
+ readonly sha256: string;
13
+ readonly prerequisiteOid: string;
14
+ readonly candidateOid: string;
15
+ readonly candidateRef: "refs/infinity/candidate";
16
+ readonly bundleVersion: 2 | 3;
17
+ readonly packVersion: 2 | 3;
18
+ readonly packObjectCount: number;
19
+ readonly verificationLevel: "bounded_header_only_requires_clean_verifier";
20
+ copyBytes(): Uint8Array;
21
+ }
22
+ export declare function inspectGitBundle(source: BinarySource, policy: GitBundleInspectionPolicy): Promise<GitBundleInspection>;
@@ -0,0 +1,4 @@
1
+ export type BinarySource = Uint8Array | AsyncIterable<Uint8Array>;
2
+ export declare function readBoundedBytes(source: BinarySource, maximumBytes: number): Promise<Uint8Array>;
3
+ export declare function sha256Bytes(bytes: Uint8Array): string;
4
+ export declare function bytesEqual(left: Uint8Array, right: Uint8Array): boolean;
@@ -0,0 +1,62 @@
1
+ import { type SqlExecutor } from "../persistence/postgres";
2
+ import { type CheckpointManifestSigningTrustHead } from "./manifest-signature";
3
+ import { type CleanVerifierHandoff, type PassingVerificationReceipt, type PassingVerificationReceiptCore, type VerificationReceiptCryptographyPort, type VerificationReceiptFinalTrustAuthorityPort } from "./verifier";
4
+ import { type SandboxesVerifierCleanupReceiptVerifierPort, type VerifierCleanupAuthorityPort, type VerifiedVerifierCleanupEvidence } from "./verifier-cleanup";
5
+ export interface CleanVerifierFinalizationAuthorityPort {
6
+ prepare(input: {
7
+ handoff: CleanVerifierHandoff;
8
+ completion: CleanVerifierCompletionPreparation;
9
+ }): Promise<void>;
10
+ resume(handoff: CleanVerifierHandoff): Promise<PassingVerificationReceipt | null>;
11
+ finalize(input: {
12
+ handoff: CleanVerifierHandoff;
13
+ core: PassingVerificationReceiptCore;
14
+ cleanupEvidence: VerifiedVerifierCleanupEvidence;
15
+ }): Promise<PassingVerificationReceipt>;
16
+ }
17
+ export interface CleanVerifierCompletionPreparation {
18
+ testReceiptSha256: string;
19
+ secretScanReceiptSha256: string;
20
+ verifierResultAttestationSha256: string;
21
+ verifierResultSha256: string;
22
+ resourceLimitsSha256: string;
23
+ testCommandsSha256: string;
24
+ expectedCurrentSigningTrustHead: CheckpointManifestSigningTrustHead;
25
+ }
26
+ export declare class InMemoryCleanVerifierFinalizationAuthority implements CleanVerifierFinalizationAuthorityPort {
27
+ private readonly cryptography;
28
+ private readonly finalTrustAuthority;
29
+ private readonly receipts;
30
+ private readonly preparations;
31
+ constructor(cryptography: VerificationReceiptCryptographyPort, finalTrustAuthority: VerificationReceiptFinalTrustAuthorityPort);
32
+ prepare(input: {
33
+ handoff: CleanVerifierHandoff;
34
+ completion: CleanVerifierCompletionPreparation;
35
+ }): Promise<void>;
36
+ resume(handoff: CleanVerifierHandoff): Promise<PassingVerificationReceipt | null>;
37
+ finalize(input: {
38
+ handoff: CleanVerifierHandoff;
39
+ core: PassingVerificationReceiptCore;
40
+ cleanupEvidence: VerifiedVerifierCleanupEvidence;
41
+ }): Promise<PassingVerificationReceipt>;
42
+ }
43
+ export declare class PostgresCleanVerifierFinalizationAuthority implements CleanVerifierFinalizationAuthorityPort {
44
+ private readonly dependencies;
45
+ constructor(dependencies: {
46
+ sql: SqlExecutor;
47
+ cryptography: VerificationReceiptCryptographyPort;
48
+ finalTrustAuthority: VerificationReceiptFinalTrustAuthorityPort;
49
+ cleanupAuthority: VerifierCleanupAuthorityPort;
50
+ cleanupReceiptVerifier: SandboxesVerifierCleanupReceiptVerifierPort;
51
+ });
52
+ prepare(input: {
53
+ handoff: CleanVerifierHandoff;
54
+ completion: CleanVerifierCompletionPreparation;
55
+ }): Promise<void>;
56
+ resume(handoff: CleanVerifierHandoff): Promise<PassingVerificationReceipt | null>;
57
+ finalize(input: {
58
+ handoff: CleanVerifierHandoff;
59
+ core: PassingVerificationReceiptCore;
60
+ cleanupEvidence: VerifiedVerifierCleanupEvidence;
61
+ }): Promise<PassingVerificationReceipt>;
62
+ }