codex-orchestrator 0.1.47 → 0.1.48

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 (156) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/src/config/schema.d.ts +5 -1
  3. package/dist/src/config/schema.d.ts.map +1 -1
  4. package/dist/src/config/schema.js +16 -0
  5. package/dist/src/config/schema.js.map +1 -1
  6. package/dist/src/runner/command-utils.d.ts.map +1 -1
  7. package/dist/src/runner/command-utils.js +1 -0
  8. package/dist/src/runner/command-utils.js.map +1 -1
  9. package/dist/src/runner/local-execution-session.d.ts.map +1 -1
  10. package/dist/src/runner/local-execution-session.js +5 -2
  11. package/dist/src/runner/local-execution-session.js.map +1 -1
  12. package/dist/src/runner/mission-activation.d.ts +29 -0
  13. package/dist/src/runner/mission-activation.d.ts.map +1 -0
  14. package/dist/src/runner/mission-activation.js +54 -0
  15. package/dist/src/runner/mission-activation.js.map +1 -0
  16. package/dist/src/runner/mission-agent-broker.d.ts +53 -0
  17. package/dist/src/runner/mission-agent-broker.d.ts.map +1 -0
  18. package/dist/src/runner/mission-agent-broker.js +182 -0
  19. package/dist/src/runner/mission-agent-broker.js.map +1 -0
  20. package/dist/src/runner/mission-cancellation.d.ts +77 -0
  21. package/dist/src/runner/mission-cancellation.d.ts.map +1 -0
  22. package/dist/src/runner/mission-cancellation.js +180 -0
  23. package/dist/src/runner/mission-cancellation.js.map +1 -0
  24. package/dist/src/runner/mission-canonical-path.d.ts +34 -0
  25. package/dist/src/runner/mission-canonical-path.d.ts.map +1 -0
  26. package/dist/src/runner/mission-canonical-path.js +121 -0
  27. package/dist/src/runner/mission-canonical-path.js.map +1 -0
  28. package/dist/src/runner/mission-capability-kernel.d.ts +34 -0
  29. package/dist/src/runner/mission-capability-kernel.d.ts.map +1 -0
  30. package/dist/src/runner/mission-capability-kernel.js +158 -0
  31. package/dist/src/runner/mission-capability-kernel.js.map +1 -0
  32. package/dist/src/runner/mission-check-policy.d.ts +17 -0
  33. package/dist/src/runner/mission-check-policy.d.ts.map +1 -0
  34. package/dist/src/runner/mission-check-policy.js +31 -0
  35. package/dist/src/runner/mission-check-policy.js.map +1 -0
  36. package/dist/src/runner/mission-coordinator-lock.d.ts +16 -0
  37. package/dist/src/runner/mission-coordinator-lock.d.ts.map +1 -0
  38. package/dist/src/runner/mission-coordinator-lock.js +170 -0
  39. package/dist/src/runner/mission-coordinator-lock.js.map +1 -0
  40. package/dist/src/runner/mission-deployment.d.ts +21 -0
  41. package/dist/src/runner/mission-deployment.d.ts.map +1 -0
  42. package/dist/src/runner/mission-deployment.js +108 -0
  43. package/dist/src/runner/mission-deployment.js.map +1 -0
  44. package/dist/src/runner/mission-evaluation.d.ts +61 -0
  45. package/dist/src/runner/mission-evaluation.d.ts.map +1 -0
  46. package/dist/src/runner/mission-evaluation.js +183 -0
  47. package/dist/src/runner/mission-evaluation.js.map +1 -0
  48. package/dist/src/runner/mission-executor-probe.d.ts +10 -0
  49. package/dist/src/runner/mission-executor-probe.d.ts.map +1 -0
  50. package/dist/src/runner/mission-executor-probe.js +180 -0
  51. package/dist/src/runner/mission-executor-probe.js.map +1 -0
  52. package/dist/src/runner/mission-git-contracts.d.ts +75 -0
  53. package/dist/src/runner/mission-git-contracts.d.ts.map +1 -0
  54. package/dist/src/runner/mission-git-contracts.js +201 -0
  55. package/dist/src/runner/mission-git-contracts.js.map +1 -0
  56. package/dist/src/runner/mission-git-runtime-owner-ref.d.ts +13 -0
  57. package/dist/src/runner/mission-git-runtime-owner-ref.d.ts.map +1 -0
  58. package/dist/src/runner/mission-git-runtime-owner-ref.js +111 -0
  59. package/dist/src/runner/mission-git-runtime-owner-ref.js.map +1 -0
  60. package/dist/src/runner/mission-git-transaction.d.ts +97 -0
  61. package/dist/src/runner/mission-git-transaction.d.ts.map +1 -0
  62. package/dist/src/runner/mission-git-transaction.js +1009 -0
  63. package/dist/src/runner/mission-git-transaction.js.map +1 -0
  64. package/dist/src/runner/mission-identifiers.d.ts +31 -0
  65. package/dist/src/runner/mission-identifiers.d.ts.map +1 -0
  66. package/dist/src/runner/mission-identifiers.js +75 -0
  67. package/dist/src/runner/mission-identifiers.js.map +1 -0
  68. package/dist/src/runner/mission-input-snapshot.d.ts +21 -0
  69. package/dist/src/runner/mission-input-snapshot.d.ts.map +1 -0
  70. package/dist/src/runner/mission-input-snapshot.js +63 -0
  71. package/dist/src/runner/mission-input-snapshot.js.map +1 -0
  72. package/dist/src/runner/mission-ownership.d.ts +38 -0
  73. package/dist/src/runner/mission-ownership.d.ts.map +1 -0
  74. package/dist/src/runner/mission-ownership.js +88 -0
  75. package/dist/src/runner/mission-ownership.js.map +1 -0
  76. package/dist/src/runner/mission-patch-audit.d.ts +21 -0
  77. package/dist/src/runner/mission-patch-audit.d.ts.map +1 -0
  78. package/dist/src/runner/mission-patch-audit.js +186 -0
  79. package/dist/src/runner/mission-patch-audit.js.map +1 -0
  80. package/dist/src/runner/mission-path-language.d.ts +6 -0
  81. package/dist/src/runner/mission-path-language.d.ts.map +1 -0
  82. package/dist/src/runner/mission-path-language.js +106 -0
  83. package/dist/src/runner/mission-path-language.js.map +1 -0
  84. package/dist/src/runner/mission-permit-authority.d.ts +26 -0
  85. package/dist/src/runner/mission-permit-authority.d.ts.map +1 -0
  86. package/dist/src/runner/mission-permit-authority.js +145 -0
  87. package/dist/src/runner/mission-permit-authority.js.map +1 -0
  88. package/dist/src/runner/mission-plan-parent-coordinator.d.ts +87 -0
  89. package/dist/src/runner/mission-plan-parent-coordinator.d.ts.map +1 -0
  90. package/dist/src/runner/mission-plan-parent-coordinator.js +412 -0
  91. package/dist/src/runner/mission-plan-parent-coordinator.js.map +1 -0
  92. package/dist/src/runner/mission-plan-parent.d.ts +154 -0
  93. package/dist/src/runner/mission-plan-parent.d.ts.map +1 -0
  94. package/dist/src/runner/mission-plan-parent.js +583 -0
  95. package/dist/src/runner/mission-plan-parent.js.map +1 -0
  96. package/dist/src/runner/mission-process-executor.d.ts +25 -0
  97. package/dist/src/runner/mission-process-executor.d.ts.map +1 -0
  98. package/dist/src/runner/mission-process-executor.js +182 -0
  99. package/dist/src/runner/mission-process-executor.js.map +1 -0
  100. package/dist/src/runner/mission-quarantine-patch-executor.d.ts +29 -0
  101. package/dist/src/runner/mission-quarantine-patch-executor.d.ts.map +1 -0
  102. package/dist/src/runner/mission-quarantine-patch-executor.js +121 -0
  103. package/dist/src/runner/mission-quarantine-patch-executor.js.map +1 -0
  104. package/dist/src/runner/mission-repository-executor.d.ts +54 -0
  105. package/dist/src/runner/mission-repository-executor.d.ts.map +1 -0
  106. package/dist/src/runner/mission-repository-executor.js +192 -0
  107. package/dist/src/runner/mission-repository-executor.js.map +1 -0
  108. package/dist/src/runner/mission-repository-observer.d.ts +8 -0
  109. package/dist/src/runner/mission-repository-observer.d.ts.map +1 -0
  110. package/dist/src/runner/mission-repository-observer.js +24 -0
  111. package/dist/src/runner/mission-repository-observer.js.map +1 -0
  112. package/dist/src/runner/mission-reservations.d.ts +15 -0
  113. package/dist/src/runner/mission-reservations.d.ts.map +1 -0
  114. package/dist/src/runner/mission-reservations.js +116 -0
  115. package/dist/src/runner/mission-reservations.js.map +1 -0
  116. package/dist/src/runner/mission-resolution-loop.d.ts +172 -0
  117. package/dist/src/runner/mission-resolution-loop.d.ts.map +1 -0
  118. package/dist/src/runner/mission-resolution-loop.js +318 -0
  119. package/dist/src/runner/mission-resolution-loop.js.map +1 -0
  120. package/dist/src/runner/mission-runtime-owner.d.ts +36 -0
  121. package/dist/src/runner/mission-runtime-owner.d.ts.map +1 -0
  122. package/dist/src/runner/mission-runtime-owner.js +174 -0
  123. package/dist/src/runner/mission-runtime-owner.js.map +1 -0
  124. package/dist/src/runner/mission-safe-executor.d.ts +96 -0
  125. package/dist/src/runner/mission-safe-executor.d.ts.map +1 -0
  126. package/dist/src/runner/mission-safe-executor.js +288 -0
  127. package/dist/src/runner/mission-safe-executor.js.map +1 -0
  128. package/dist/src/runner/mission-sandbox.d.ts +16 -0
  129. package/dist/src/runner/mission-sandbox.d.ts.map +1 -0
  130. package/dist/src/runner/mission-sandbox.js +91 -0
  131. package/dist/src/runner/mission-sandbox.js.map +1 -0
  132. package/dist/src/runner/mission-scheduler.d.ts +57 -0
  133. package/dist/src/runner/mission-scheduler.d.ts.map +1 -0
  134. package/dist/src/runner/mission-scheduler.js +205 -0
  135. package/dist/src/runner/mission-scheduler.js.map +1 -0
  136. package/dist/src/runner/mission-scope-expansion.d.ts +47 -0
  137. package/dist/src/runner/mission-scope-expansion.d.ts.map +1 -0
  138. package/dist/src/runner/mission-scope-expansion.js +147 -0
  139. package/dist/src/runner/mission-scope-expansion.js.map +1 -0
  140. package/dist/src/runner/mission-state-machine.d.ts +118 -0
  141. package/dist/src/runner/mission-state-machine.d.ts.map +1 -0
  142. package/dist/src/runner/mission-state-machine.js +316 -0
  143. package/dist/src/runner/mission-state-machine.js.map +1 -0
  144. package/dist/src/runner/mission-state-store.d.ts +70 -0
  145. package/dist/src/runner/mission-state-store.d.ts.map +1 -0
  146. package/dist/src/runner/mission-state-store.js +856 -0
  147. package/dist/src/runner/mission-state-store.js.map +1 -0
  148. package/dist/src/runner/rework-policy.d.ts +2 -1
  149. package/dist/src/runner/rework-policy.d.ts.map +1 -1
  150. package/dist/src/runner/rework-policy.js +3 -0
  151. package/dist/src/runner/rework-policy.js.map +1 -1
  152. package/dist/src/setup/project-config.d.ts.map +1 -1
  153. package/dist/src/setup/project-config.js +5 -0
  154. package/dist/src/setup/project-config.js.map +1 -1
  155. package/docs/deep-dive.md +25 -16
  156. package/package.json +1 -1
@@ -0,0 +1,318 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { evaluate, } from './mission-evaluation.js';
3
+ export async function runResolutionMission(input, dependencies) {
4
+ assertInput(input);
5
+ let snapshot = structuredClone(input.snapshot);
6
+ let scope = unique(input.scope);
7
+ let validationReceiptIds = unique(input.validationReceiptIds);
8
+ let acceptanceCoverage = unique(input.acceptanceCoverage);
9
+ const history = structuredClone(input.history ?? []);
10
+ let alternatives = latestAlternatives(history);
11
+ let resume = input.resume ? structuredClone(input.resume) : undefined;
12
+ for (let step = 0; step < input.maxSteps; step += 1) {
13
+ const evaluation = evaluate(snapshot);
14
+ const direct = directEvaluationOutcome(evaluation, history);
15
+ if (direct)
16
+ return direct;
17
+ if (evaluation.blockingDisposition === 'none') {
18
+ return {
19
+ kind: 'candidate-ready',
20
+ snapshot,
21
+ evaluation,
22
+ history,
23
+ scope,
24
+ validationReceiptIds,
25
+ acceptanceCoverage,
26
+ };
27
+ }
28
+ let proposal;
29
+ let strategyFingerprint;
30
+ let actionKey;
31
+ if (resume) {
32
+ ({ proposal, strategyFingerprint, actionKey } = resume);
33
+ }
34
+ else {
35
+ const suppressed = suppressedFingerprints(history);
36
+ proposal = await dependencies.diagnose({
37
+ missionId: input.missionId,
38
+ snapshot: structuredClone(snapshot),
39
+ evaluation: structuredClone(evaluation),
40
+ alternatives: [...alternatives],
41
+ suppressedStrategyFingerprints: suppressed,
42
+ history: structuredClone(history),
43
+ });
44
+ strategyFingerprint = missionStrategyFingerprint(proposal);
45
+ actionKey = missionActionKey(input.missionId, snapshot, strategyFingerprint);
46
+ if (suppressed.includes(strategyFingerprint)) {
47
+ history.push({
48
+ actionKey,
49
+ strategyFingerprint,
50
+ outcome: 'proposal-suppressed',
51
+ reason: 'strategy-already-completed-without-progress',
52
+ alternatives: ['choose a materially different strategy'],
53
+ });
54
+ alternatives = ['choose a materially different strategy'];
55
+ continue;
56
+ }
57
+ }
58
+ if (resume && (strategyFingerprint !== missionStrategyFingerprint(proposal)
59
+ || actionKey !== missionActionKey(input.missionId, snapshot, strategyFingerprint))) {
60
+ return safety([actionKey], 'stale-resolution-resume', history);
61
+ }
62
+ let permit = resume?.permit;
63
+ if (!resume || resume.stage === 'authorizing') {
64
+ const authorization = await dependencies.authorize({
65
+ missionId: input.missionId,
66
+ snapshot: structuredClone(snapshot),
67
+ evaluation: structuredClone(evaluation),
68
+ proposal: structuredClone(proposal),
69
+ actionKey,
70
+ strategyFingerprint,
71
+ });
72
+ if (authorization.kind === 'rejected-recoverable') {
73
+ alternatives = unique(authorization.alternatives);
74
+ history.push({
75
+ actionKey,
76
+ strategyFingerprint,
77
+ outcome: 'authorization-rejected',
78
+ reason: authorization.reason,
79
+ alternatives,
80
+ });
81
+ resume = undefined;
82
+ continue;
83
+ }
84
+ if (authorization.kind === 'temporary') {
85
+ return resumable('authorizing', authorization.reason, authorization.nextEligibleAt, history, {
86
+ stage: 'authorizing', actionKey, strategyFingerprint, proposal,
87
+ });
88
+ }
89
+ if (authorization.kind === 'external-input-required') {
90
+ return external(authorization.evidence, authorization.resumePredicate, history);
91
+ }
92
+ if (authorization.kind === 'safety-stop') {
93
+ return safety(authorization.evidence, authorization.invariant, history);
94
+ }
95
+ if (proposal.kind === 'external-input' || proposal.kind === 'safety-stop') {
96
+ return safety([
97
+ `proposal:${proposal.kind}`,
98
+ `authorization:${authorization.kind}`,
99
+ ], 'terminal-boundary-not-runner-verified', history);
100
+ }
101
+ requireText(authorization.permit.id, 'permit.id');
102
+ permit = {
103
+ ...structuredClone(authorization.permit),
104
+ actionKey,
105
+ strategyFingerprint,
106
+ proposal: structuredClone(proposal),
107
+ };
108
+ }
109
+ if (!permit)
110
+ throw new Error('Mission resolution authorization produced no permit.');
111
+ let receipt = resume?.receipt;
112
+ if (!resume || resume.stage !== 'reconciling') {
113
+ const execution = await dependencies.execute({
114
+ missionId: input.missionId,
115
+ actionKey,
116
+ strategyFingerprint,
117
+ proposal: structuredClone(proposal),
118
+ permit: structuredClone(permit),
119
+ });
120
+ if (execution.kind === 'transient') {
121
+ return resumable('executing', execution.reason, execution.nextEligibleAt, history, {
122
+ stage: 'executing', actionKey, strategyFingerprint, proposal, permit,
123
+ });
124
+ }
125
+ if (execution.kind === 'deterministic-failure') {
126
+ alternatives = unique(execution.alternatives);
127
+ history.push({
128
+ actionKey,
129
+ strategyFingerprint,
130
+ outcome: 'deterministic-failure',
131
+ reason: execution.reason,
132
+ alternatives,
133
+ });
134
+ resume = undefined;
135
+ continue;
136
+ }
137
+ receipt = structuredClone(execution.receipt);
138
+ requireText(receipt.id, 'receipt.id');
139
+ if (receipt.actionKey !== actionKey) {
140
+ return safety([`expected:${actionKey}`, `received:${receipt.actionKey}`], 'execution-receipt-action-mismatch', history);
141
+ }
142
+ }
143
+ if (!receipt)
144
+ throw new Error('Mission resolution execution produced no receipt.');
145
+ const before = progressVector({
146
+ snapshot,
147
+ evaluation,
148
+ scope,
149
+ validationReceiptIds,
150
+ acceptanceCoverage,
151
+ strategyFingerprint,
152
+ });
153
+ const reconciliation = await dependencies.reconcile({
154
+ missionId: input.missionId,
155
+ snapshot: structuredClone(snapshot),
156
+ proposal: structuredClone(proposal),
157
+ permit: structuredClone(permit),
158
+ receipt: structuredClone(receipt),
159
+ });
160
+ if (reconciliation.kind === 'transient') {
161
+ return resumable('reconciling', reconciliation.reason, reconciliation.nextEligibleAt, history, {
162
+ stage: 'reconciling', actionKey, strategyFingerprint, proposal, permit, receipt,
163
+ });
164
+ }
165
+ if (reconciliation.kind === 'external-input-required') {
166
+ return external(reconciliation.evidence, reconciliation.resumePredicate, history);
167
+ }
168
+ if (reconciliation.kind === 'safety-stop') {
169
+ return safety(reconciliation.evidence, reconciliation.invariant, history);
170
+ }
171
+ if (reconciliation.snapshot.issueNumber !== snapshot.issueNumber
172
+ || reconciliation.snapshot.baseSha !== snapshot.baseSha
173
+ || reconciliation.snapshot.configHash !== snapshot.configHash) {
174
+ return safety([
175
+ `expected:${snapshot.issueNumber}:${snapshot.baseSha}:${snapshot.configHash}`,
176
+ `received:${reconciliation.snapshot.issueNumber}:${reconciliation.snapshot.baseSha}:${reconciliation.snapshot.configHash}`,
177
+ ], 'reconciliation-snapshot-identity-mismatch', history);
178
+ }
179
+ snapshot = structuredClone(reconciliation.snapshot);
180
+ scope = unique(reconciliation.scope);
181
+ validationReceiptIds = unique(reconciliation.validationReceiptIds);
182
+ acceptanceCoverage = unique(reconciliation.acceptanceCoverage);
183
+ const reevaluation = evaluate(snapshot);
184
+ const after = progressVector({
185
+ snapshot,
186
+ evaluation: reevaluation,
187
+ scope,
188
+ validationReceiptIds,
189
+ acceptanceCoverage,
190
+ strategyFingerprint,
191
+ });
192
+ history.push({
193
+ actionKey,
194
+ strategyFingerprint,
195
+ outcome: before === after ? 'strategy-stagnated' : 'progress',
196
+ ...(before === after ? {
197
+ reason: 'deterministic-action-left-progress-vector-unchanged',
198
+ alternatives: ['choose a materially different strategy'],
199
+ } : {}),
200
+ });
201
+ alternatives = before === after ? ['choose a materially different strategy'] : [];
202
+ resume = undefined;
203
+ }
204
+ return {
205
+ kind: 'resumable',
206
+ resumeTarget: 'diagnosing',
207
+ reason: 'resolution-step-budget-exhausted',
208
+ nextEligibleAt: dependencies.nextEligibleAt('resolution-step-budget-exhausted'),
209
+ history,
210
+ };
211
+ }
212
+ export function missionStrategyFingerprint(proposal) {
213
+ return digest(['mission-strategy-v1', canonicalize(proposal)]);
214
+ }
215
+ function missionActionKey(missionId, snapshot, strategyFingerprint) {
216
+ return `action:v1:${digest([missionId, progressSnapshotIdentity(snapshot), strategyFingerprint]).slice(7)}`;
217
+ }
218
+ function progressVector(input) {
219
+ return canonicalize({
220
+ findingIds: input.evaluation.findings.map((finding) => `${finding.disposition}:${finding.id}`),
221
+ candidate: normalizedCandidateIdentity(input.snapshot.candidateIdentity),
222
+ scope: unique(input.scope),
223
+ validationReceiptIds: unique(input.validationReceiptIds),
224
+ acceptanceCoverage: unique(input.acceptanceCoverage),
225
+ strategyFingerprint: input.strategyFingerprint,
226
+ });
227
+ }
228
+ function progressSnapshotIdentity(snapshot) {
229
+ return digest([
230
+ snapshot.issueNumber,
231
+ snapshot.baseSha,
232
+ snapshot.configHash,
233
+ normalizedCandidateIdentity(snapshot.candidateIdentity),
234
+ ]);
235
+ }
236
+ function directEvaluationOutcome(evaluation, history) {
237
+ if (evaluation.blockingDisposition === 'safety-stop') {
238
+ const findings = evaluation.findings.filter((finding) => finding.disposition === 'safety-stop');
239
+ return safety(findings.flatMap((finding) => [finding.id, ...finding.evidenceRefs]), findings.map((finding) => finding.key).join(',') || 'evaluation-safety-stop', history);
240
+ }
241
+ if (evaluation.blockingDisposition === 'external-input') {
242
+ const findings = evaluation.findings.filter((finding) => finding.disposition === 'external-input');
243
+ return external(findings.flatMap((finding) => [finding.id, ...finding.evidenceRefs]), findings.map((finding) => finding.reason).join('\n'), history);
244
+ }
245
+ return undefined;
246
+ }
247
+ function resumable(resumeTarget, reason, nextEligibleAt, history, resume) {
248
+ return { kind: 'resumable', resumeTarget, reason, nextEligibleAt, resume, history };
249
+ }
250
+ function external(evidence, resumePredicate, history) {
251
+ assertEvidence(evidence, 'external-input');
252
+ requireText(resumePredicate, 'resumePredicate');
253
+ return {
254
+ kind: 'external-input-required',
255
+ evidence: unique(evidence),
256
+ resumePredicate,
257
+ history,
258
+ };
259
+ }
260
+ function safety(evidence, invariant, history) {
261
+ assertEvidence(evidence, 'safety-stop');
262
+ requireText(invariant, 'invariant');
263
+ return { kind: 'safety-stop', evidence: unique(evidence), invariant, history };
264
+ }
265
+ function latestAlternatives(history) {
266
+ return unique(history.at(-1)?.alternatives ?? []);
267
+ }
268
+ function suppressedFingerprints(history) {
269
+ return unique(history
270
+ .filter((entry) => entry.outcome === 'authorization-rejected'
271
+ || entry.outcome === 'deterministic-failure'
272
+ || entry.outcome === 'strategy-stagnated'
273
+ || entry.outcome === 'proposal-suppressed')
274
+ .map((entry) => entry.strategyFingerprint));
275
+ }
276
+ function canonicalize(value) {
277
+ if (Array.isArray(value))
278
+ return `[${value.map(canonicalize).join(',')}]`;
279
+ if (value && typeof value === 'object') {
280
+ return `{${Object.entries(value)
281
+ .filter(([, item]) => item !== undefined)
282
+ .sort(([left], [right]) => compareCodeUnits(left, right))
283
+ .map(([key, item]) => `${JSON.stringify(key)}:${canonicalize(item)}`)
284
+ .join(',')}}`;
285
+ }
286
+ return JSON.stringify(value);
287
+ }
288
+ function digest(value) {
289
+ return `sha256:${createHash('sha256').update(canonicalize(value)).digest('hex')}`;
290
+ }
291
+ function normalizedCandidateIdentity(candidate) {
292
+ return candidate.kind === 'legacy-unobserved'
293
+ ? { ...candidate }
294
+ : { ...candidate, changedFiles: unique(candidate.changedFiles) };
295
+ }
296
+ function compareCodeUnits(left, right) {
297
+ return left < right ? -1 : left > right ? 1 : 0;
298
+ }
299
+ function unique(values) {
300
+ return Array.from(new Set(values.map((value) => value.trim()).filter(Boolean))).sort();
301
+ }
302
+ function assertInput(input) {
303
+ requireText(input.missionId, 'missionId');
304
+ if (!Number.isSafeInteger(input.maxSteps) || input.maxSteps <= 0) {
305
+ throw new Error('Mission resolution maxSteps must be a positive integer.');
306
+ }
307
+ }
308
+ function assertEvidence(evidence, kind) {
309
+ if (unique(evidence).length === 0) {
310
+ throw new Error(`Mission resolution ${kind} requires evidence.`);
311
+ }
312
+ }
313
+ function requireText(value, field) {
314
+ if (value.trim().length === 0) {
315
+ throw new Error(`Mission resolution ${field} must be non-empty.`);
316
+ }
317
+ }
318
+ //# sourceMappingURL=mission-resolution-loop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-resolution-loop.js","sourceRoot":"","sources":["../../../src/runner/mission-resolution-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,QAAQ,GAGT,MAAM,yBAAyB,CAAC;AAkKjC,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAA6B,EAC7B,YAA2C;IAE3C,WAAW,CAAC,KAAK,CAAC,CAAC;IACnB,IAAI,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,oBAAoB,GAAG,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC9D,IAAI,kBAAkB,GAAG,MAAM,C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,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,qBAAqB,CAAC,CAAC;IACpE,CAAC;AACH,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { MissionDeploymentRecord } from './mission-deployment.js';
2
+ export interface RuntimeOwnerRecord {
3
+ version: 1;
4
+ repository: string;
5
+ deploymentId: string;
6
+ githubAppInstallationId: string;
7
+ credentialGeneration: string;
8
+ compatibilityEpoch: number;
9
+ deploymentRecordHash: string;
10
+ approvedByCommit: string;
11
+ fencingEpoch: number;
12
+ }
13
+ export interface RuntimeOwnerObservation {
14
+ sha: string;
15
+ record: RuntimeOwnerRecord;
16
+ }
17
+ export interface RuntimeOwnerRefAdapter {
18
+ read(): Promise<RuntimeOwnerObservation | undefined>;
19
+ compareAndSwap(expectedSha: string | undefined, record: RuntimeOwnerRecord): Promise<RuntimeOwnerObservation>;
20
+ }
21
+ export declare function canonicalRuntimeOwnerRecord(record: RuntimeOwnerRecord): string;
22
+ export declare function parseRuntimeOwnerRecord(content: string): RuntimeOwnerRecord;
23
+ export declare function assertRuntimeOwnerRecord(value: unknown): asserts value is RuntimeOwnerRecord;
24
+ export declare class RuntimeOwnerConflictError extends Error {
25
+ constructor(message: string);
26
+ }
27
+ export declare class MissionRuntimeOwnership {
28
+ private readonly adapter;
29
+ constructor(adapter: RuntimeOwnerRefAdapter);
30
+ acquireInitial(deployment: MissionDeploymentRecord): Promise<RuntimeOwnerObservation>;
31
+ transfer(deployment: MissionDeploymentRecord, githubServerTime: string): Promise<RuntimeOwnerObservation>;
32
+ assertMutationFence(deployment: MissionDeploymentRecord, expectedFencingEpoch: number): Promise<RuntimeOwnerObservation>;
33
+ runFencedMutation<T>(deployment: MissionDeploymentRecord, expectedFencingEpoch: number, mutation: (fence: RuntimeOwnerObservation) => Promise<T>): Promise<T>;
34
+ }
35
+ export declare function ownerRecord(deployment: MissionDeploymentRecord, fencingEpoch: number): RuntimeOwnerRecord;
36
+ //# sourceMappingURL=mission-runtime-owner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-runtime-owner.d.ts","sourceRoot":"","sources":["../../../src/runner/mission-runtime-owner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGvE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,IAAI,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC;IACrD,cAAc,CACZ,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACrC;AAcD,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAG9E;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAY3E;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,kBAAkB,CAwC5F;AAED,qBAAa,yBAA0B,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAInC;AAED,qBAAa,uBAAuB;IACf,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,sBAAsB;IAEtD,cAAc,CAAC,UAAU,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAQrF,QAAQ,CACnB,UAAU,EAAE,uBAAuB,EACnC,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,uBAAuB,CAAC;IA+BtB,mBAAmB,CAC9B,UAAU,EAAE,uBAAuB,EACnC,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAAC,uBAAuB,CAAC;IA8BtB,iBAAiB,CAAC,CAAC,EAC9B,UAAU,EAAE,uBAAuB,EACnC,oBAAoB,EAAE,MAAM,EAC5B,QAAQ,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,OAAO,CAAC,CAAC,CAAC,GACvD,OAAO,CAAC,CAAC,CAAC;CAId;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,uBAAuB,EACnC,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAepB"}
@@ -0,0 +1,174 @@
1
+ import { missionDeploymentRecordHash } from './mission-deployment.js';
2
+ const runtimeOwnerFields = [
3
+ 'version',
4
+ 'repository',
5
+ 'deploymentId',
6
+ 'githubAppInstallationId',
7
+ 'credentialGeneration',
8
+ 'compatibilityEpoch',
9
+ 'deploymentRecordHash',
10
+ 'approvedByCommit',
11
+ 'fencingEpoch',
12
+ ];
13
+ export function canonicalRuntimeOwnerRecord(record) {
14
+ assertRuntimeOwnerRecord(record);
15
+ return JSON.stringify(Object.fromEntries(runtimeOwnerFields.map((field) => [field, record[field]])));
16
+ }
17
+ export function parseRuntimeOwnerRecord(content) {
18
+ let parsed;
19
+ try {
20
+ parsed = JSON.parse(content);
21
+ }
22
+ catch {
23
+ throw new Error('Invalid Mission runtime owner record: expected JSON.');
24
+ }
25
+ assertRuntimeOwnerRecord(parsed);
26
+ if (content !== canonicalRuntimeOwnerRecord(parsed)) {
27
+ throw new Error('Invalid Mission runtime owner record: expected canonical JSON.');
28
+ }
29
+ return parsed;
30
+ }
31
+ export function assertRuntimeOwnerRecord(value) {
32
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
33
+ throw new Error('Invalid Mission runtime owner record: root must be an object.');
34
+ }
35
+ const record = value;
36
+ const allowed = new Set(runtimeOwnerFields);
37
+ for (const key of Object.keys(record)) {
38
+ if (!allowed.has(key)) {
39
+ throw new Error(`Invalid Mission runtime owner record: unexpected field ${key}.`);
40
+ }
41
+ }
42
+ if (Object.keys(record).length !== runtimeOwnerFields.length
43
+ || runtimeOwnerFields.some((field) => !(field in record))) {
44
+ throw new Error('Invalid Mission runtime owner record: exact fields are required.');
45
+ }
46
+ if (record.version !== 1) {
47
+ throw new Error('Invalid Mission runtime owner record: version must be 1.');
48
+ }
49
+ for (const field of [
50
+ 'repository',
51
+ 'deploymentId',
52
+ 'githubAppInstallationId',
53
+ 'credentialGeneration',
54
+ ]) {
55
+ if (typeof record[field] !== 'string' || record[field].trim().length === 0) {
56
+ throw new Error(`Invalid Mission runtime owner record: ${field} must be non-empty.`);
57
+ }
58
+ }
59
+ if (!Number.isSafeInteger(record.compatibilityEpoch) || record.compatibilityEpoch <= 0
60
+ || !Number.isSafeInteger(record.fencingEpoch) || record.fencingEpoch <= 0) {
61
+ throw new Error('Invalid Mission runtime owner record: epochs must be positive integers.');
62
+ }
63
+ if (typeof record.deploymentRecordHash !== 'string'
64
+ || !/^sha256:[a-f0-9]{64}$/u.test(record.deploymentRecordHash)) {
65
+ throw new Error('Invalid Mission runtime owner record: deploymentRecordHash must be SHA-256.');
66
+ }
67
+ if (typeof record.approvedByCommit !== 'string'
68
+ || !/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u.test(record.approvedByCommit)) {
69
+ throw new Error('Invalid Mission runtime owner record: approvedByCommit must be a Git object ID.');
70
+ }
71
+ }
72
+ export class RuntimeOwnerConflictError extends Error {
73
+ constructor(message) {
74
+ super(`Mission runtime owner conflict: ${message}`);
75
+ this.name = 'RuntimeOwnerConflictError';
76
+ }
77
+ }
78
+ export class MissionRuntimeOwnership {
79
+ adapter;
80
+ constructor(adapter) {
81
+ this.adapter = adapter;
82
+ }
83
+ async acquireInitial(deployment) {
84
+ const observed = await this.adapter.read();
85
+ if (observed) {
86
+ throw new RuntimeOwnerConflictError(`already owned by ${observed.record.deploymentId}`);
87
+ }
88
+ return this.adapter.compareAndSwap(undefined, ownerRecord(deployment, 1));
89
+ }
90
+ async transfer(deployment, githubServerTime) {
91
+ const observed = await this.adapter.read();
92
+ if (!observed) {
93
+ throw new RuntimeOwnerConflictError('cannot transfer an absent owner; use initial acquisition');
94
+ }
95
+ if (deployment.repository !== observed.record.repository) {
96
+ throw new RuntimeOwnerConflictError('repository does not match current owner');
97
+ }
98
+ if (deployment.deploymentId === observed.record.deploymentId) {
99
+ throw new RuntimeOwnerConflictError('transfer requires a different deployment ID');
100
+ }
101
+ const now = exactTimestamp(githubServerTime, 'GitHub server time');
102
+ const notBefore = exactTimestamp(deployment.takeoverNotBefore, 'takeoverNotBefore');
103
+ if (now < notBefore) {
104
+ throw new RuntimeOwnerConflictError(`takeoverNotBefore is ${deployment.takeoverNotBefore}`);
105
+ }
106
+ if (exactTimestamp(deployment.priorCredentialRevokedAt, 'priorCredentialRevokedAt') > now) {
107
+ throw new RuntimeOwnerConflictError('prior credential revocation is not yet observed');
108
+ }
109
+ if (deployment.credentialGeneration === observed.record.credentialGeneration) {
110
+ throw new RuntimeOwnerConflictError('transfer requires a new credential generation');
111
+ }
112
+ if (deployment.compatibilityEpoch < observed.record.compatibilityEpoch) {
113
+ throw new RuntimeOwnerConflictError('compatibility epoch cannot move backward');
114
+ }
115
+ return this.adapter.compareAndSwap(observed.sha, ownerRecord(deployment, observed.record.fencingEpoch + 1));
116
+ }
117
+ async assertMutationFence(deployment, expectedFencingEpoch) {
118
+ if (!Number.isSafeInteger(expectedFencingEpoch) || expectedFencingEpoch <= 0) {
119
+ throw new RuntimeOwnerConflictError('fencing epoch must be a positive integer');
120
+ }
121
+ const observed = await this.adapter.read();
122
+ if (!observed) {
123
+ throw new RuntimeOwnerConflictError('owner ref is absent');
124
+ }
125
+ const expected = ownerRecord(deployment, expectedFencingEpoch);
126
+ if (observed.record.credentialGeneration !== expected.credentialGeneration) {
127
+ throw new RuntimeOwnerConflictError('credential generation does not match current owner');
128
+ }
129
+ for (const field of [
130
+ 'repository',
131
+ 'deploymentId',
132
+ 'githubAppInstallationId',
133
+ 'compatibilityEpoch',
134
+ 'deploymentRecordHash',
135
+ 'approvedByCommit',
136
+ ]) {
137
+ if (observed.record[field] !== expected[field]) {
138
+ throw new RuntimeOwnerConflictError(`${field} does not match the protected deployment record`);
139
+ }
140
+ }
141
+ if (observed.record.fencingEpoch !== expectedFencingEpoch) {
142
+ throw new RuntimeOwnerConflictError('fencing epoch does not match current owner');
143
+ }
144
+ return observed;
145
+ }
146
+ async runFencedMutation(deployment, expectedFencingEpoch, mutation) {
147
+ const fence = await this.assertMutationFence(deployment, expectedFencingEpoch);
148
+ return mutation(fence);
149
+ }
150
+ }
151
+ export function ownerRecord(deployment, fencingEpoch) {
152
+ if (!Number.isSafeInteger(fencingEpoch) || fencingEpoch <= 0) {
153
+ throw new Error('Mission runtime owner fencingEpoch must be a positive integer.');
154
+ }
155
+ return {
156
+ version: 1,
157
+ repository: deployment.repository,
158
+ deploymentId: deployment.deploymentId,
159
+ githubAppInstallationId: deployment.githubAppInstallationId,
160
+ credentialGeneration: deployment.credentialGeneration,
161
+ compatibilityEpoch: deployment.compatibilityEpoch,
162
+ deploymentRecordHash: missionDeploymentRecordHash(deployment),
163
+ approvedByCommit: deployment.approvedByCommit,
164
+ fencingEpoch,
165
+ };
166
+ }
167
+ function exactTimestamp(value, field) {
168
+ const parsed = Date.parse(value);
169
+ if (!Number.isFinite(parsed) || new Date(parsed).toISOString() !== value) {
170
+ throw new RuntimeOwnerConflictError(`${field} is not an exact UTC ISO timestamp`);
171
+ }
172
+ return parsed;
173
+ }
174
+ //# sourceMappingURL=mission-runtime-owner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-runtime-owner.js","sourceRoot":"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AmB,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;QAC/E,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CACzB,UAAmC,EACnC,YAAoB;IAEpB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,uBAAuB,EAAE,UAAU,CAAC,uBAAuB;QAC3D,oBAAoB,EAAE,UAAU,CAAC,oBAAoB;QACrD,kBAAkB,EAAE,UAAU,CAAC,kBAAkB;QACjD,oBAAoB,EAAE,2BAA2B,CAAC,UAAU,CAAC;QAC7D,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;QAC7C,YAAY;KACb,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,KAAa;IAClD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE,CAAC;QACzE,MAAM,IAAI,yBAAyB,CAAC,GAAG,KAAK,oCAAoC,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { type MissionExecutorProbeResult } from './mission-executor-probe.js';
2
+ import { type MissionProcessInput, type MissionProcessResult } from './mission-process-executor.js';
3
+ import type { MissionSandboxBackend } from './mission-capability-kernel.js';
4
+ export declare const missionSafeExecutorKinds: readonly ["completion-report-repair", "review-evidence-repair", "acceptance-proof-repair", "configured-check"];
5
+ export type MissionSafeExecutorKind = (typeof missionSafeExecutorKinds)[number];
6
+ export interface MissionSafeExecutorDescriptor {
7
+ id: string;
8
+ kind: MissionSafeExecutorKind;
9
+ executable: string;
10
+ args: string[];
11
+ readPaths: string[];
12
+ writePaths: string[];
13
+ network: 'deny';
14
+ idempotency: 'repeat-safe' | 'reconcile';
15
+ }
16
+ export interface MissionSafeExecutorPermit extends MissionSafeExecutorDescriptor {
17
+ missionId: string;
18
+ actionKey: string;
19
+ executorId: string;
20
+ grantedPaths: string[];
21
+ inputSnapshot: string;
22
+ fencingEpoch: number;
23
+ expiresAt: string;
24
+ descriptorFingerprint: string;
25
+ }
26
+ export interface MissionSafeExecutorAuthorizationRequest {
27
+ missionId: string;
28
+ actionKey: string;
29
+ executorId: string;
30
+ grantedPaths: string[];
31
+ inputSnapshot: string;
32
+ fencingEpoch: number;
33
+ expiresAt: string;
34
+ }
35
+ export type MissionSafeExecutorClassification = {
36
+ kind: 'safe-executor';
37
+ descriptor: MissionSafeExecutorDescriptor;
38
+ } | {
39
+ kind: 'external-input-required';
40
+ reason: 'legacy-shell-executor-unavailable-in-mission-mode';
41
+ migration: 'register an exact argv Mission safe executor';
42
+ };
43
+ export interface MissionSafeExecutorOptions {
44
+ backend: MissionSandboxBackend;
45
+ workspaceRoot: string;
46
+ quarantineRoot: string;
47
+ deniedReadPaths: string[];
48
+ sourceEnv: NodeJS.ProcessEnv;
49
+ allowedEnvKeys: string[];
50
+ timeoutMs: number;
51
+ capabilityProof: MissionExecutorProbeResult;
52
+ }
53
+ export interface MissionSafeExecutorReceipt {
54
+ version: 1;
55
+ missionId: string;
56
+ actionKey: string;
57
+ executorId: string;
58
+ descriptorFingerprint: string;
59
+ exitCode: number;
60
+ termination: MissionProcessResult['termination'];
61
+ stdoutSha256: string;
62
+ stderrSha256: string;
63
+ outputs: Array<{
64
+ path: string;
65
+ size: number;
66
+ sha256: string;
67
+ }>;
68
+ }
69
+ export interface MissionSafeExecutorResult {
70
+ process: MissionProcessResult;
71
+ receipt: MissionSafeExecutorReceipt;
72
+ }
73
+ export interface MissionSafeExecutorDependencies {
74
+ runProcess?: (input: MissionProcessInput) => Promise<MissionProcessResult>;
75
+ now?: () => Date;
76
+ }
77
+ export declare class MissionSafeExecutorRegistry {
78
+ private readonly descriptors;
79
+ constructor(descriptors: MissionSafeExecutorDescriptor[]);
80
+ authorize(request: MissionSafeExecutorAuthorizationRequest): MissionSafeExecutorPermit;
81
+ classify(input: string | {
82
+ executorId: string;
83
+ }): MissionSafeExecutorClassification;
84
+ kinds(): MissionSafeExecutorKind[];
85
+ validatePermit(permit: MissionSafeExecutorPermit, now: Date): MissionSafeExecutorPermit;
86
+ }
87
+ export declare class MissionSafeExecutor {
88
+ private readonly registry;
89
+ private readonly options;
90
+ private readonly runProcess;
91
+ private readonly now;
92
+ constructor(registry: MissionSafeExecutorRegistry, options: MissionSafeExecutorOptions, dependencies?: MissionSafeExecutorDependencies);
93
+ execute(permit: MissionSafeExecutorPermit): Promise<MissionSafeExecutorResult>;
94
+ }
95
+ export declare function missionSafeExecutorPermitFingerprint(permit: MissionSafeExecutorPermit): string;
96
+ //# sourceMappingURL=mission-safe-executor.d.ts.map