@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,418 @@
1
+ import { type Int64 } from "../../core/int64";
2
+ import { type AuthenticatedFenceContext, type BrokerFence, type BrokerFenceInput } from "../../contracts/fence";
3
+ import type { IdempotentExecutor } from "../checkpoint/idempotency";
4
+ import { type ProviderStepExecutor } from "../persistence/contracts";
5
+ import { type CheckpointSealReceipt, type FenceAuthorityPort } from "../checkpoint/service";
6
+ import { type PassingVerificationReceipt, type VerificationReceiptCryptographyPort, type VerificationReceiptFinalTrustAuthorityPort } from "../checkpoint/verifier";
7
+ import type { VersionedReadbackReceipt } from "../checkpoint/store";
8
+ export interface DecisionIdempotencyTuple {
9
+ authenticatedPrincipal: string;
10
+ delegationChainSha256: string;
11
+ sourceNamespace: string;
12
+ projectId: string;
13
+ repositoryId: string;
14
+ resourceId: string;
15
+ routeAuthorityReferenceSha256: string;
16
+ command: "approval_decide";
17
+ key: string;
18
+ requestSha256: string;
19
+ }
20
+ export interface PromotionApprovalReceipt {
21
+ schemaVersion: "infinity.promotion-approval-consumption/v1";
22
+ grantType: "human_webauthn_promotion";
23
+ issuer: string;
24
+ audience: "git-promotion-broker";
25
+ jti: string;
26
+ issuedAt: string;
27
+ notBefore: string;
28
+ approvalId: string;
29
+ approvalRevision: number;
30
+ decisionVerb: "approve" | "deny";
31
+ decisionOperationId: string;
32
+ decisionIdempotency: DecisionIdempotencyTuple;
33
+ approvedProposalSha256: string;
34
+ decisionReceiptSha256: string;
35
+ consumptionTransactionId: string;
36
+ consumedAt: string;
37
+ approverPrincipal: string;
38
+ expiresAt: string;
39
+ webauthnChallengeSha256: string;
40
+ webauthnRpId: string;
41
+ webauthnOrigin: string;
42
+ signingKeyId: string;
43
+ signatureAlgorithm: "ecdsa-p256-sha256";
44
+ signedEnvelopeSha256: string;
45
+ signatureBase64: string;
46
+ signatureSha256: string;
47
+ }
48
+ export interface GitPromotionIntentInput {
49
+ fence: BrokerFenceInput;
50
+ checkpoint: CheckpointSealReceipt;
51
+ verification: PassingVerificationReceipt;
52
+ approval: PromotionApprovalReceipt;
53
+ installationId: string;
54
+ appPrincipal: string;
55
+ repositoryId: string;
56
+ targetRef: string;
57
+ branchRef: string;
58
+ prTitleDigest: string;
59
+ prBodyDigest: string;
60
+ automationPolicySha256: string;
61
+ scannerPolicySha256: string;
62
+ }
63
+ export type GitPromotionProposalInput = Omit<GitPromotionIntentInput, "approval">;
64
+ export interface GitPromotionIntent extends Omit<Readonly<GitPromotionIntentInput>, "fence" | "approval"> {
65
+ readonly fence: BrokerFence;
66
+ readonly approval: Readonly<PromotionApprovalReceipt & {
67
+ decisionIdempotency: Readonly<DecisionIdempotencyTuple>;
68
+ }>;
69
+ }
70
+ export interface GitRefReadReceipt {
71
+ readonly repositoryId: string;
72
+ readonly ref: string;
73
+ readonly oid: string | null;
74
+ readonly providerRequestId: string;
75
+ }
76
+ export interface GitCandidateObjectSource {
77
+ readonly checkpointId: string;
78
+ readonly checkpointSealSha256: string;
79
+ readonly verificationReceiptSha256: string;
80
+ readonly objectFormat: "sha1" | "sha256";
81
+ readonly expectedBaseOid: string;
82
+ readonly candidateOid: string;
83
+ readonly bundleSha256: string;
84
+ readonly bundleObject: VersionedReadbackReceipt;
85
+ }
86
+ export type PromotionStepAction = "read_target_precondition" | "anchor_branch" | "cas_candidate" | "read_ref_postconditions" | "create_draft_pr" | "read_draft_pr_postcondition";
87
+ export interface PromotionFenceAuthorityPort extends FenceAuthorityPort {
88
+ authorizePromotionStep(input: {
89
+ action: PromotionStepAction;
90
+ fence: BrokerFence;
91
+ nextResourceLifecycleGeneration: Int64;
92
+ proposalSha256: string;
93
+ approvalConsumptionReceiptSha256: string;
94
+ }): Promise<{
95
+ fence: BrokerFence;
96
+ databaseTime: Date;
97
+ }>;
98
+ }
99
+ export interface PromotionApprovalAuthorityPort {
100
+ verifyConsumed(input: {
101
+ approval: PromotionApprovalReceipt;
102
+ proposalSha256: string;
103
+ fence: BrokerFence;
104
+ }): Promise<PromotionApprovalConsumptionVerification>;
105
+ }
106
+ export interface PromotionApprovalConsumptionVerification {
107
+ fence: BrokerFence;
108
+ proposalSha256: string;
109
+ consumptionReceiptSha256: string;
110
+ approvalId: string;
111
+ approvalRevision: number;
112
+ decisionReceiptSha256: string;
113
+ consumptionTransactionId: string;
114
+ consumedAt: string;
115
+ }
116
+ export interface FreshPromotionSecretScanReceipt {
117
+ readonly schemaVersion: "infinity.promotion-secret-scan/v1";
118
+ readonly verdict: "pass";
119
+ readonly fence: BrokerFence;
120
+ readonly checkpointSealSha256: string;
121
+ readonly verificationReceiptSha256: string;
122
+ readonly candidateOid: string;
123
+ readonly scannerPolicySha256: string;
124
+ readonly proposalSha256: string;
125
+ readonly approvalConsumptionReceiptSha256: string;
126
+ readonly stagedDiffScanned: true;
127
+ readonly allIntroducedBlobsScanned: true;
128
+ readonly findingCount: 0;
129
+ readonly completedAt: string;
130
+ readonly receiptSha256: string;
131
+ }
132
+ export interface PromotionSecretScannerPort {
133
+ scan(input: {
134
+ fence: BrokerFence;
135
+ checkpoint: CheckpointSealReceipt;
136
+ verification: PassingVerificationReceipt;
137
+ proposalSha256: string;
138
+ approvalConsumptionReceiptSha256: string;
139
+ }): Promise<FreshPromotionSecretScanReceipt>;
140
+ }
141
+ export type GitBranchCreateReceipt = Readonly<{
142
+ status: "created";
143
+ oid: string;
144
+ providerRequestId: string;
145
+ reconciliationProviderRequestId: string | null;
146
+ resourceGenerationBefore: Int64;
147
+ resourceGenerationAfter: Int64;
148
+ }> | Readonly<{
149
+ status: "conflict";
150
+ existingOid: string;
151
+ providerRequestId: string;
152
+ reconciliationProviderRequestId: string | null;
153
+ resourceGenerationBefore: Int64;
154
+ resourceGenerationAfter: Int64;
155
+ }> | Readonly<{
156
+ status: "ambiguous";
157
+ providerRequestId: string;
158
+ reconciliationProviderRequestId: string;
159
+ resourceGenerationBefore: Int64;
160
+ possibleResourceGenerationAfter: Int64;
161
+ }>;
162
+ export type GitBranchCasReceipt = Readonly<{
163
+ status: "updated";
164
+ previousOid: string;
165
+ oid: string;
166
+ providerRequestId: string;
167
+ reconciliationProviderRequestId: string | null;
168
+ resourceGenerationBefore: Int64;
169
+ resourceGenerationAfter: Int64;
170
+ }> | Readonly<{
171
+ status: "conflict";
172
+ existingOid: string | null;
173
+ providerRequestId: string;
174
+ reconciliationProviderRequestId: string | null;
175
+ resourceGenerationBefore: Int64;
176
+ resourceGenerationAfter: Int64;
177
+ }> | Readonly<{
178
+ status: "ambiguous";
179
+ providerRequestId: string;
180
+ reconciliationProviderRequestId: string;
181
+ resourceGenerationBefore: Int64;
182
+ possibleResourceGenerationAfter: Int64;
183
+ }>;
184
+ export interface GitPullRequestRecord {
185
+ readonly providerPullRequestId: string;
186
+ readonly number: number;
187
+ readonly repositoryId: string;
188
+ readonly installationId: string;
189
+ readonly baseRef: string;
190
+ readonly baseOid: string;
191
+ readonly headRef: string;
192
+ readonly headOid: string;
193
+ readonly marker: string;
194
+ readonly titleDigest: string;
195
+ readonly bodyDigest: string;
196
+ readonly state: "open";
197
+ readonly draft: true;
198
+ readonly authorPrincipal: string;
199
+ readonly providerRequestId: string;
200
+ }
201
+ export type GitPullRequestCreateReceipt = Readonly<{
202
+ status: "created";
203
+ pullRequest: GitPullRequestRecord;
204
+ reconciliationProviderRequestId: string | null;
205
+ resourceGenerationBefore: Int64;
206
+ resourceGenerationAfter: Int64;
207
+ }> | Readonly<{
208
+ status: "ambiguous";
209
+ providerRequestId: string;
210
+ reconciliationProviderRequestId: string;
211
+ resourceGenerationBefore: Int64;
212
+ possibleResourceGenerationAfter: Int64;
213
+ }>;
214
+ export interface GitPullRequestReadReceipt {
215
+ readonly pullRequest: GitPullRequestRecord | null;
216
+ readonly providerRequestId: string;
217
+ }
218
+ export interface ExpectedBaseGitPort {
219
+ /**
220
+ * Implementations must revalidate the full fence and authorization deadline
221
+ * at the last asynchronous boundary before every external provider request,
222
+ * including ambiguity reconciliation requests.
223
+ */
224
+ withOperation<T>(input: {
225
+ fence: BrokerFence;
226
+ authorizationExpiresAt: string;
227
+ }, effect: () => Promise<T>): Promise<T>;
228
+ readRef(input: {
229
+ repositoryId: string;
230
+ ref: string;
231
+ fence: BrokerFence;
232
+ }): Promise<GitRefReadReceipt>;
233
+ compareAndCreateBranch(input: {
234
+ repositoryId: string;
235
+ ref: string;
236
+ oid: string;
237
+ operationId: string;
238
+ operationDigest: string;
239
+ resourceGenerationBefore: Int64;
240
+ resourceGenerationAfter: Int64;
241
+ fence: BrokerFence;
242
+ }): Promise<GitBranchCreateReceipt>;
243
+ compareAndSwapBranch(input: {
244
+ repositoryId: string;
245
+ ref: string;
246
+ expectedOid: string;
247
+ candidateOid: string;
248
+ candidateSource: GitCandidateObjectSource;
249
+ operationId: string;
250
+ operationDigest: string;
251
+ resourceGenerationBefore: Int64;
252
+ resourceGenerationAfter: Int64;
253
+ fence: BrokerFence;
254
+ }): Promise<GitBranchCasReceipt>;
255
+ createDraftPullRequest(input: {
256
+ repositoryId: string;
257
+ installationId: string;
258
+ appPrincipal: string;
259
+ baseRef: string;
260
+ baseOid: string;
261
+ headRef: string;
262
+ headOid: string;
263
+ marker: string;
264
+ titleDigest: string;
265
+ bodyDigest: string;
266
+ operationId: string;
267
+ operationDigest: string;
268
+ resourceGenerationBefore: Int64;
269
+ resourceGenerationAfter: Int64;
270
+ fence: BrokerFence;
271
+ }): Promise<GitPullRequestCreateReceipt>;
272
+ readPullRequest(input: {
273
+ repositoryId: string;
274
+ providerPullRequestId: string;
275
+ fence: BrokerFence;
276
+ }): Promise<GitPullRequestReadReceipt>;
277
+ }
278
+ export type GitPromotionStatus = "complete" | "base_drifted" | "branch_conflict" | "unknown_requires_review";
279
+ export interface GitPromotionReceiptCore {
280
+ readonly schemaVersion: "infinity.git-promotion-receipt/v1";
281
+ readonly status: GitPromotionStatus;
282
+ readonly fence: BrokerFence;
283
+ readonly operationDigest: string;
284
+ readonly proposalSha256: string;
285
+ readonly approvalConsumptionReceiptSha256: string;
286
+ readonly checkpointSealSha256: string;
287
+ readonly verificationReceiptSha256: string;
288
+ readonly approvalDecisionReceiptSha256: string;
289
+ readonly freshSecretScanReceiptSha256: string;
290
+ readonly installationId: string;
291
+ readonly appPrincipal: string;
292
+ readonly repositoryId: string;
293
+ readonly targetRef: string;
294
+ readonly branchRef: string;
295
+ readonly expectedBaseOid: string;
296
+ readonly candidateOid: string;
297
+ readonly candidateTreeOid: string;
298
+ readonly resourceGenerationBefore: Int64;
299
+ readonly resourceGenerationAfter: Int64 | null;
300
+ readonly possibleResourceGenerationAfter: Int64;
301
+ readonly targetOidBefore: string | null;
302
+ readonly targetOidAfter: string | null;
303
+ readonly branchOid: string | null;
304
+ readonly pullRequest: GitPullRequestRecord | null;
305
+ readonly providerRequestIds: readonly string[];
306
+ readonly recordedAt: string;
307
+ }
308
+ export interface GitPromotionResultAuthorityCommit {
309
+ readonly schemaVersion: "infinity.git-promotion-authority-commit/v1";
310
+ readonly operationId: string;
311
+ readonly operationDigest: string;
312
+ readonly resultCoreSha256: string;
313
+ readonly proposalSha256: string;
314
+ readonly approvalConsumptionReceiptSha256: string;
315
+ readonly effectJournalFrontierSha256: string;
316
+ readonly authorityWitnessReceiptSha256: string;
317
+ readonly cancellationWitnessReceiptSha256: string;
318
+ readonly authorityTransactionId: string;
319
+ readonly authorityEventId: string;
320
+ readonly committedAt: string;
321
+ readonly signingKeyId: string;
322
+ readonly signatureSha256: string;
323
+ readonly receiptSha256: string;
324
+ }
325
+ export interface GitPromotionReceipt extends GitPromotionReceiptCore {
326
+ readonly authorityCommit: GitPromotionResultAuthorityCommit;
327
+ }
328
+ export interface PromotionResultAuthorityPort {
329
+ /**
330
+ * Rechecks independent authority/cancellation witnesses, then durably commits
331
+ * and verifies the signed external effect-journal frontier for this result.
332
+ */
333
+ commitAndVerifyPromotionResult(input: {
334
+ core: GitPromotionReceiptCore;
335
+ coreDigest: string;
336
+ proposalSha256: string;
337
+ approvalConsumptionReceiptSha256: string;
338
+ }): Promise<GitPromotionResultAuthorityCommit>;
339
+ verifyPromotionResult(input: {
340
+ core: GitPromotionReceiptCore;
341
+ coreDigest: string;
342
+ authorityCommit: GitPromotionResultAuthorityCommit;
343
+ }): Promise<GitPromotionResultAuthorityCommit>;
344
+ }
345
+ export declare function promotionProposalDigest(input: GitPromotionProposalInput): string;
346
+ export type PromotionApprovalChallengeInput = Pick<PromotionApprovalReceipt, "schemaVersion" | "grantType" | "issuer" | "audience" | "jti" | "issuedAt" | "notBefore" | "approvalId" | "approvalRevision" | "decisionVerb" | "decisionOperationId" | "decisionIdempotency" | "approvedProposalSha256" | "approverPrincipal" | "expiresAt" | "webauthnRpId" | "webauthnOrigin">;
347
+ export declare function promotionApprovalWebauthnChallengeDigest(input: PromotionApprovalChallengeInput): string;
348
+ export type PromotionApprovalSignedEnvelope = Omit<PromotionApprovalReceipt, "signedEnvelopeSha256" | "signatureBase64" | "signatureSha256">;
349
+ export declare function promotionApprovalSignedEnvelopeDigest(input: PromotionApprovalSignedEnvelope): string;
350
+ export declare function promotionApprovalConsumptionReceiptDigest(input: PromotionApprovalReceipt): string;
351
+ export declare function promotionOperationDigest(input: GitPromotionIntentInput): string;
352
+ export declare function createGitPromotionIntent(input: GitPromotionIntentInput, currentFence: BrokerFence, authenticated: AuthenticatedFenceContext): GitPromotionIntent;
353
+ export declare class GitPromotionBroker {
354
+ private readonly dependencies;
355
+ constructor(dependencies: {
356
+ authority: PromotionFenceAuthorityPort;
357
+ git: ExpectedBaseGitPort;
358
+ secretScanner: PromotionSecretScannerPort;
359
+ approvalAuthority: PromotionApprovalAuthorityPort;
360
+ resultAuthority: PromotionResultAuthorityPort;
361
+ verificationReceiptCryptography: VerificationReceiptCryptographyPort;
362
+ verificationReceiptFinalTrustAuthority: VerificationReceiptFinalTrustAuthorityPort;
363
+ ledger: IdempotentExecutor<GitPromotionReceipt>;
364
+ providerSteps: ProviderStepExecutor;
365
+ });
366
+ promote(intentInput: GitPromotionIntentInput, authenticated: AuthenticatedFenceContext): Promise<GitPromotionReceipt>;
367
+ private executePromotion;
368
+ private providerStep;
369
+ private authorizeStep;
370
+ }
371
+ export declare function parseGitPromotionReceipt(value: unknown): GitPromotionReceipt;
372
+ export declare function derivePromotionBranchRef(fence: BrokerFenceInput | BrokerFence): string;
373
+ export interface InMemoryExpectedBaseGitPortOptions {
374
+ repositoryId?: string;
375
+ targetRef?: string;
376
+ targetOid?: string;
377
+ driftTargetAfterCasTo?: string;
378
+ ambiguousPullRequest?: boolean;
379
+ preexistingBranchOid?: string;
380
+ }
381
+ export declare class InMemoryExpectedBaseGitPort implements ExpectedBaseGitPort {
382
+ private readonly options;
383
+ readRefCalls: number;
384
+ createBranchCalls: number;
385
+ casBranchCalls: number;
386
+ createPullRequestCalls: number;
387
+ readPullRequestCalls: number;
388
+ readonly observedFenceGenerations: Int64[];
389
+ readonly observedAuthorizationExpiries: string[];
390
+ private requestSequence;
391
+ private pullRequestSequence;
392
+ private readonly refs;
393
+ private readonly pullRequests;
394
+ private resourceGeneration;
395
+ private readonly repositoryId;
396
+ private readonly targetRef;
397
+ constructor(options?: InMemoryExpectedBaseGitPortOptions);
398
+ withOperation<T>(input: Parameters<ExpectedBaseGitPort["withOperation"]>[0], effect: () => Promise<T>): Promise<T>;
399
+ readRef(input: {
400
+ repositoryId: string;
401
+ ref: string;
402
+ fence: BrokerFence;
403
+ }): Promise<GitRefReadReceipt>;
404
+ compareAndCreateBranch(input: Parameters<ExpectedBaseGitPort["compareAndCreateBranch"]>[0]): Promise<GitBranchCreateReceipt>;
405
+ compareAndSwapBranch(input: Parameters<ExpectedBaseGitPort["compareAndSwapBranch"]>[0]): Promise<GitBranchCasReceipt>;
406
+ createDraftPullRequest(input: Parameters<ExpectedBaseGitPort["createDraftPullRequest"]>[0]): Promise<GitPullRequestCreateReceipt>;
407
+ readPullRequest(input: {
408
+ repositoryId: string;
409
+ providerPullRequestId: string;
410
+ fence: BrokerFence;
411
+ }): Promise<GitPullRequestReadReceipt>;
412
+ private initializeGeneration;
413
+ private advanceGeneration;
414
+ private assertRepository;
415
+ private assertOperation;
416
+ private observeFence;
417
+ private nextRequestId;
418
+ }
@@ -0,0 +1,77 @@
1
+ import type { BrokerFence } from "../../contracts/fence";
2
+ import type { Int64 } from "../../core/int64";
3
+ export declare class ProviderNoEffectError extends Error {
4
+ constructor(message?: string, options?: {
5
+ cause?: unknown;
6
+ });
7
+ }
8
+ export interface CanonicalCodec<T> {
9
+ encode(value: T): string;
10
+ decode(canonical: string): T;
11
+ }
12
+ export declare function canonicalCodec<T>(validate: (value: unknown) => T): CanonicalCodec<T>;
13
+ export interface ProviderStepExecutionInput {
14
+ operationId: string;
15
+ operationDigest: string;
16
+ stepKey: string;
17
+ action: string;
18
+ fence: BrokerFence;
19
+ request: unknown;
20
+ resourceGenerationBefore: Int64;
21
+ resourceGenerationAfter: Int64;
22
+ providerClientTokenFingerprint?: string;
23
+ /**
24
+ * Optional independent authorization deadline. Implementations must treat it
25
+ * as an upper bound on provider dispatch, never as an extension of the fence.
26
+ */
27
+ dispatchExpiresAt?: string;
28
+ executionLeaseMs?: number;
29
+ }
30
+ export interface ProviderEffectJournalAnchorInput {
31
+ operationId: string;
32
+ operationDigest: string;
33
+ stepKey: string;
34
+ stepDigest: string;
35
+ action: string;
36
+ fence: BrokerFence;
37
+ requestSha256: string;
38
+ resourceGenerationBefore: Int64;
39
+ resourceGenerationAfter: Int64;
40
+ providerClientTokenFingerprint: string | null;
41
+ dispatchExpiresAt: string;
42
+ }
43
+ export interface VerifiedProviderEffectJournalAnchor {
44
+ schemaVersion: "infinity.provider-effect-journal-anchor/v1";
45
+ anchorId: string;
46
+ authorityEventId: string;
47
+ operationId: string;
48
+ operationDigest: string;
49
+ stepKey: string;
50
+ stepDigest: string;
51
+ action: string;
52
+ fenceSha256: string;
53
+ requestSha256: string;
54
+ resourceGenerationBefore: Int64;
55
+ resourceGenerationAfter: Int64;
56
+ providerClientTokenFingerprint: string | null;
57
+ dispatchExpiresAt: string;
58
+ anchorCoreSha256: string;
59
+ authorityWitnessReceiptSha256: string;
60
+ cancellationWitnessReceiptSha256: string;
61
+ committedAt: string;
62
+ signingKeyId: string;
63
+ signatureSha256: string;
64
+ receiptSha256: string;
65
+ }
66
+ /**
67
+ * Authority boundary for the external inbox/outbox journal. Implementations must
68
+ * re-read the independent current authority-epoch and cancellation witnesses,
69
+ * then durably commit and cryptographically verify the exact anchor before
70
+ * returning. Witness unavailability or cancellation must fail closed.
71
+ */
72
+ export interface ProviderEffectJournalAuthorityPort {
73
+ commitAndVerifyDispatchAnchor(input: ProviderEffectJournalAnchorInput): Promise<VerifiedProviderEffectJournalAnchor>;
74
+ }
75
+ export interface ProviderStepExecutor {
76
+ execute<T>(input: ProviderStepExecutionInput, effect: () => Promise<T>, codec: CanonicalCodec<T>, providerRequestId: (result: T) => string | null, classifyResult?: (result: T) => "succeeded" | "unknown_requires_review"): Promise<T>;
77
+ }
@@ -0,0 +1,5 @@
1
+ import type { CanonicalCodec, ProviderStepExecutionInput, ProviderStepExecutor } from "./contracts";
2
+ export declare class InMemoryProviderStepLedger implements ProviderStepExecutor {
3
+ private readonly steps;
4
+ execute<T>(input: ProviderStepExecutionInput, effect: () => Promise<T>, codec: CanonicalCodec<T>, providerRequestId: (result: T) => string | null, classifyResult?: (result: T) => "succeeded" | "unknown_requires_review"): Promise<T>;
5
+ }
@@ -0,0 +1,6 @@
1
+ export declare const CHECKPOINT_BROKER_MIGRATION_ID = "20260710_checkpoint_broker_v1";
2
+ export declare const CHECKPOINT_BROKER_MIGRATION_V1: string;
3
+ export declare const CHECKPOINT_TRUST_MIGRATION_ID = "20260711_checkpoint_trust_v2";
4
+ export declare const CHECKPOINT_TRUST_MIGRATION_V2: string;
5
+ export declare const CHECKPOINT_BROKER_MIGRATION_V2_ID = "20260711_verifier_cleanup_v2";
6
+ export declare const CHECKPOINT_BROKER_MIGRATION_V2: string;
@@ -0,0 +1,74 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { SQL, type TransactionSQL } from "bun";
3
+ import { type BrokerFence } from "../../contracts/fence";
4
+ import type { IdempotentExecutionContext, IdempotentExecutor } from "../checkpoint/idempotency";
5
+ import type { CanonicalCodec, ProviderEffectJournalAnchorInput, ProviderEffectJournalAuthorityPort, ProviderStepExecutionInput, ProviderStepExecutor } from "./contracts";
6
+ export type SqlParameter = string | number | bigint | boolean | Date | null;
7
+ export interface SqlExecutor {
8
+ query<Row extends Record<string, unknown>>(statement: string, parameters?: readonly SqlParameter[]): Promise<readonly Row[]>;
9
+ transaction<T>(effect: (transaction: SqlExecutor) => Promise<T>): Promise<T>;
10
+ }
11
+ interface SqlSerializationState {
12
+ tail: Promise<void>;
13
+ readonly transactionOwner: AsyncLocalStorage<{
14
+ active: boolean;
15
+ }>;
16
+ readonly reentrantScope: AsyncLocalStorage<{
17
+ active: boolean;
18
+ }>;
19
+ }
20
+ export declare class BunPostgresExecutor implements SqlExecutor {
21
+ private readonly sql;
22
+ private readonly inTransaction;
23
+ private readonly serialization;
24
+ constructor(sql: SQL | TransactionSQL, inTransaction?: boolean, serialization?: SqlSerializationState);
25
+ query<Row extends Record<string, unknown>>(statement: string, parameters?: readonly SqlParameter[]): Promise<readonly Row[]>;
26
+ transaction<T>(effect: (transaction: SqlExecutor) => Promise<T>): Promise<T>;
27
+ runConcurrentWithinSerializedTransaction<T>(effect: () => Promise<T>): Promise<T>;
28
+ private serialize;
29
+ }
30
+ export declare function runConcurrentWithinSerializedSqlTransaction<T>(executor: SqlExecutor, effect: () => Promise<T>): Promise<T>;
31
+ export declare function applyCheckpointBrokerMigration(executor: SqlExecutor): Promise<"applied" | "already_applied">;
32
+ export { canonicalCodec } from "./contracts";
33
+ export type { CanonicalCodec, ProviderEffectJournalAnchorInput, ProviderEffectJournalAuthorityPort, ProviderStepExecutionInput, ProviderStepExecutor, VerifiedProviderEffectJournalAnchor, } from "./contracts";
34
+ export { ProviderNoEffectError } from "./contracts";
35
+ export interface PostgresLedgerOptions {
36
+ executionLeaseMs?: number;
37
+ pollIntervalMs?: number;
38
+ maxPolls?: number;
39
+ }
40
+ export declare class PostgresOperationLedger<T> implements IdempotentExecutor<T> {
41
+ private readonly executor;
42
+ private readonly codec;
43
+ private readonly executionLeaseMs;
44
+ private readonly pollIntervalMs;
45
+ private readonly maxPolls;
46
+ constructor(executor: SqlExecutor, codec: CanonicalCodec<T>, options?: PostgresLedgerOptions);
47
+ execute(operationIdInput: string, operationDigestInput: string, effect: () => Promise<T>, context?: IdempotentExecutionContext, classifyResult?: (result: T) => "committed" | "unknown_requires_review"): Promise<T>;
48
+ resolve(operationIdInput: string, operationDigestInput: string, fenceInput: BrokerFence): Promise<T | null>;
49
+ adoptReconciledResult(operationIdInput: string, operationDigestInput: string, fenceInput: BrokerFence, result: T, reconciliationEvidenceSha256Input: string): Promise<T>;
50
+ private join;
51
+ private load;
52
+ private resolveRow;
53
+ }
54
+ export type ProviderStepResolution<T> = Readonly<{
55
+ state: "missing";
56
+ } | {
57
+ state: "prepared" | "dispatched" | "failed_no_effect";
58
+ } | {
59
+ state: "unknown_requires_review";
60
+ result?: T;
61
+ } | {
62
+ state: "succeeded";
63
+ result: T;
64
+ }>;
65
+ export declare class PostgresProviderStepLedger implements ProviderStepExecutor {
66
+ private readonly executor;
67
+ private readonly effectJournal;
68
+ private readonly options;
69
+ constructor(executor: SqlExecutor, effectJournal: ProviderEffectJournalAuthorityPort, options?: PostgresLedgerOptions);
70
+ execute<T>(input: ProviderStepExecutionInput, effect: () => Promise<T>, codec: CanonicalCodec<T>, providerRequestId: (result: T) => string | null, classifyResult?: (result: T) => "succeeded" | "unknown_requires_review"): Promise<T>;
71
+ resolve<T>(input: ProviderStepExecutionInput, codec: CanonicalCodec<T>): Promise<ProviderStepResolution<T>>;
72
+ adoptReconciledResult<T>(input: ProviderStepExecutionInput, result: T, codec: CanonicalCodec<T>, providerRequestId: (result: T) => string | null, reconciliationProviderRequestIdInput: string, reconciliationEvidenceSha256Input: string): Promise<T>;
73
+ }
74
+ export declare function providerEffectJournalAnchorCoreDigest(input: ProviderEffectJournalAnchorInput): string;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ export declare const LOCAL_OPERATOR_ENDPOINT: "http://127.0.0.1:18787";
@@ -0,0 +1,47 @@
1
+ import type { Clock } from "../core/clock";
2
+ import type { IdFactory } from "../core/ids";
3
+ import type { OperatorEnvelope } from "../client/operator-client";
4
+ import { type PublicMutationResultExpectation } from "../contracts/operations";
5
+ export interface CliOperationIntent {
6
+ command: string;
7
+ idempotencyKey: string;
8
+ scope: Readonly<Record<string, unknown>>;
9
+ request: Readonly<Record<string, unknown>>;
10
+ authorityRequestHash: string;
11
+ resultExpectation: Readonly<PublicMutationResultExpectation>;
12
+ }
13
+ export interface PreparedCliOperation {
14
+ operationId: string;
15
+ command: string;
16
+ idempotencyKey: string;
17
+ scopeDigest: string;
18
+ requestDigest: string;
19
+ authorityRequestHash: string;
20
+ resultExpectation: Readonly<PublicMutationResultExpectation>;
21
+ replayed: boolean;
22
+ }
23
+ export interface CliOperationJournal {
24
+ prepare(intent: CliOperationIntent): Promise<PreparedCliOperation>;
25
+ recordResponse(operationId: string, envelope: OperatorEnvelope): Promise<void>;
26
+ read(operationId: string): PreparedCliOperation & {
27
+ state: "prepared" | "responded";
28
+ responseDigest: string | null;
29
+ };
30
+ }
31
+ export declare function defaultCliOperationJournalPath(): string;
32
+ export declare class DurableCliOperationJournal implements CliOperationJournal {
33
+ private readonly path;
34
+ private readonly ids;
35
+ private readonly clock;
36
+ private database;
37
+ constructor(path: string, ids: IdFactory, clock: Clock);
38
+ prepare(value: CliOperationIntent): Promise<PreparedCliOperation>;
39
+ recordResponse(operationIdInput: string, envelope: OperatorEnvelope): Promise<void>;
40
+ read(operationIdInput: string): PreparedCliOperation & {
41
+ state: "prepared" | "responded";
42
+ responseDigest: string | null;
43
+ };
44
+ close(): void;
45
+ private open;
46
+ }
47
+ export declare function successfulMutationConsequenceDigest(command: string, operationId: string, value: unknown, expectation: PublicMutationResultExpectation): string;
@@ -0,0 +1,15 @@
1
+ import { type OperatorClient, type OperatorEnvelope } from "../client/operator-client";
2
+ import { type CliOperationJournal } from "./operation-journal";
3
+ export interface CliRuntime {
4
+ client: OperatorClient;
5
+ readInput(selector: string): Promise<string>;
6
+ writeStdout(value: string): void;
7
+ writeStderr(value: string): void;
8
+ operationJournal: CliOperationJournal;
9
+ now(): Date;
10
+ }
11
+ export declare function runCli(argv: string[], runtime: CliRuntime): Promise<number>;
12
+ export declare class CliUsageError extends Error {
13
+ constructor(message: string);
14
+ }
15
+ export declare function localFailure(error: unknown, now: Date): OperatorEnvelope;