open-multi-agent-kit 0.98.5 → 0.99.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 (163) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +3 -2
  3. package/dist/cli/help.d.ts.map +1 -1
  4. package/dist/cli/help.js +1 -0
  5. package/dist/cli/help.js.map +1 -1
  6. package/dist/commands/verified-run-cli.d.ts.map +1 -1
  7. package/dist/commands/verified-run-cli.js +2 -2
  8. package/dist/commands/verified-run-cli.js.map +1 -1
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +19 -2
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/devin-harness-dispatch.d.ts +12 -0
  13. package/dist/core/devin-harness-dispatch.d.ts.map +1 -0
  14. package/dist/core/devin-harness-dispatch.js +12 -0
  15. package/dist/core/devin-harness-dispatch.js.map +1 -0
  16. package/dist/core/devin-harness.d.ts +53 -0
  17. package/dist/core/devin-harness.d.ts.map +1 -0
  18. package/dist/core/devin-harness.js +112 -0
  19. package/dist/core/devin-harness.js.map +1 -0
  20. package/dist/core/domain-dispatch.d.ts +4 -1
  21. package/dist/core/domain-dispatch.d.ts.map +1 -1
  22. package/dist/core/domain-dispatch.js +5 -0
  23. package/dist/core/domain-dispatch.js.map +1 -1
  24. package/dist/core/domain-loadouts-provider-harness.d.ts +12 -0
  25. package/dist/core/domain-loadouts-provider-harness.d.ts.map +1 -0
  26. package/dist/core/domain-loadouts-provider-harness.js +122 -0
  27. package/dist/core/domain-loadouts-provider-harness.js.map +1 -0
  28. package/dist/core/domain-loadouts.d.ts +2 -33
  29. package/dist/core/domain-loadouts.d.ts.map +1 -1
  30. package/dist/core/domain-loadouts.js +3 -56
  31. package/dist/core/domain-loadouts.js.map +1 -1
  32. package/dist/core/domain-profile.d.ts +40 -0
  33. package/dist/core/domain-profile.d.ts.map +1 -0
  34. package/dist/core/domain-profile.js +7 -0
  35. package/dist/core/domain-profile.js.map +1 -0
  36. package/dist/core/grok-harness-dispatch.d.ts +6 -20
  37. package/dist/core/grok-harness-dispatch.d.ts.map +1 -1
  38. package/dist/core/grok-harness-dispatch.js +6 -55
  39. package/dist/core/grok-harness-dispatch.js.map +1 -1
  40. package/dist/core/grok-harness.d.ts +7 -9
  41. package/dist/core/grok-harness.d.ts.map +1 -1
  42. package/dist/core/grok-harness.js +9 -23
  43. package/dist/core/grok-harness.js.map +1 -1
  44. package/dist/core/harness-skills.d.ts +20 -0
  45. package/dist/core/harness-skills.d.ts.map +1 -0
  46. package/dist/core/harness-skills.js +36 -0
  47. package/dist/core/harness-skills.js.map +1 -0
  48. package/dist/core/loadout-runtime-state.d.ts +25 -0
  49. package/dist/core/loadout-runtime-state.d.ts.map +1 -0
  50. package/dist/core/loadout-runtime-state.js +39 -0
  51. package/dist/core/loadout-runtime-state.js.map +1 -0
  52. package/dist/core/loadout-runtime.d.ts +2 -12
  53. package/dist/core/loadout-runtime.d.ts.map +1 -1
  54. package/dist/core/loadout-runtime.js +6 -13
  55. package/dist/core/loadout-runtime.js.map +1 -1
  56. package/dist/core/model-resolver.d.ts +1 -41
  57. package/dist/core/model-resolver.d.ts.map +1 -1
  58. package/dist/core/model-resolver.js +2 -49
  59. package/dist/core/model-resolver.js.map +1 -1
  60. package/dist/core/provider-default-models.d.ts +42 -0
  61. package/dist/core/provider-default-models.d.ts.map +1 -0
  62. package/dist/core/provider-default-models.js +50 -0
  63. package/dist/core/provider-default-models.js.map +1 -0
  64. package/dist/core/provider-display-names.d.ts.map +1 -1
  65. package/dist/core/provider-display-names.js +1 -0
  66. package/dist/core/provider-display-names.js.map +1 -1
  67. package/dist/core/provider-harness-dispatch.d.ts +63 -0
  68. package/dist/core/provider-harness-dispatch.d.ts.map +1 -0
  69. package/dist/core/provider-harness-dispatch.js +60 -0
  70. package/dist/core/provider-harness-dispatch.js.map +1 -0
  71. package/dist/core/provider-usage-devin.d.ts +16 -0
  72. package/dist/core/provider-usage-devin.d.ts.map +1 -0
  73. package/dist/core/provider-usage-devin.js +61 -0
  74. package/dist/core/provider-usage-devin.js.map +1 -0
  75. package/dist/core/provider-usage-text.d.ts +5 -0
  76. package/dist/core/provider-usage-text.d.ts.map +1 -0
  77. package/dist/core/provider-usage-text.js +15 -0
  78. package/dist/core/provider-usage-text.js.map +1 -0
  79. package/dist/core/provider-usage-types.d.ts +2 -1
  80. package/dist/core/provider-usage-types.d.ts.map +1 -1
  81. package/dist/core/provider-usage-types.js.map +1 -1
  82. package/dist/core/provider-usage.d.ts +1 -2
  83. package/dist/core/provider-usage.d.ts.map +1 -1
  84. package/dist/core/provider-usage.js +12 -7
  85. package/dist/core/provider-usage.js.map +1 -1
  86. package/dist/core/run-execution-api.d.ts +1 -1
  87. package/dist/core/run-execution-api.d.ts.map +1 -1
  88. package/dist/core/run-execution-api.js.map +1 -1
  89. package/dist/core/sdk.d.ts.map +1 -1
  90. package/dist/core/sdk.js +23 -18
  91. package/dist/core/sdk.js.map +1 -1
  92. package/dist/core/verified-run/dag-phase.d.ts +1 -1
  93. package/dist/core/verified-run/dag-phase.d.ts.map +1 -1
  94. package/dist/core/verified-run/dag-phase.js +46 -8
  95. package/dist/core/verified-run/dag-phase.js.map +1 -1
  96. package/dist/core/verified-run/dag-projection.d.ts.map +1 -1
  97. package/dist/core/verified-run/dag-projection.js +25 -12
  98. package/dist/core/verified-run/dag-projection.js.map +1 -1
  99. package/dist/core/verified-run/dag-types.d.ts +11 -0
  100. package/dist/core/verified-run/dag-types.d.ts.map +1 -1
  101. package/dist/core/verified-run/dag-types.js.map +1 -1
  102. package/dist/core/verified-run/event-parser.d.ts.map +1 -1
  103. package/dist/core/verified-run/event-parser.js +1 -0
  104. package/dist/core/verified-run/event-parser.js.map +1 -1
  105. package/dist/core/verified-run/owned-execution.d.ts +1 -0
  106. package/dist/core/verified-run/owned-execution.d.ts.map +1 -1
  107. package/dist/core/verified-run/owned-execution.js +7 -1
  108. package/dist/core/verified-run/owned-execution.js.map +1 -1
  109. package/dist/core/verified-run/process-projection.d.ts +13 -0
  110. package/dist/core/verified-run/process-projection.d.ts.map +1 -0
  111. package/dist/core/verified-run/process-projection.js +82 -0
  112. package/dist/core/verified-run/process-projection.js.map +1 -0
  113. package/dist/core/verified-run/projection.d.ts.map +1 -1
  114. package/dist/core/verified-run/projection.js +11 -55
  115. package/dist/core/verified-run/projection.js.map +1 -1
  116. package/dist/core/verified-run/run-types.d.ts +1 -0
  117. package/dist/core/verified-run/run-types.d.ts.map +1 -1
  118. package/dist/core/verified-run/run-types.js.map +1 -1
  119. package/dist/core/verified-run/task-execution.d.ts +9 -0
  120. package/dist/core/verified-run/task-execution.d.ts.map +1 -0
  121. package/dist/core/verified-run/task-execution.js +29 -0
  122. package/dist/core/verified-run/task-execution.js.map +1 -0
  123. package/dist/core/verified-run/writer-projection.d.ts.map +1 -1
  124. package/dist/core/verified-run/writer-projection.js +6 -5
  125. package/dist/core/verified-run/writer-projection.js.map +1 -1
  126. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  127. package/dist/modes/interactive/interactive-mode.js +2 -5
  128. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  129. package/dist/modes/interactive/resource-description.d.ts +3 -0
  130. package/dist/modes/interactive/resource-description.d.ts.map +1 -0
  131. package/dist/modes/interactive/resource-description.js +15 -0
  132. package/dist/modes/interactive/resource-description.js.map +1 -0
  133. package/docs/devin-harness.md +121 -0
  134. package/docs/docs.json +4 -0
  135. package/docs/environment-variables.md +2 -1
  136. package/docs/index.md +1 -0
  137. package/docs/loadout-domains/README.md +2 -1
  138. package/docs/loadout-domains/devin-harness.md +72 -0
  139. package/docs/metrics.md +57 -16
  140. package/docs/providers.md +76 -0
  141. package/docs/release-audit-0.98.5.md +17 -0
  142. package/docs/release-audit-0.99.0.md +68 -0
  143. package/docs/run-protocol.md +4 -3
  144. package/docs/runtime-algorithms.md +4 -1
  145. package/docs/sdk.md +9 -5
  146. package/docs/settings.md +1 -1
  147. package/docs/startup-resource-labels-testing.md +47 -0
  148. package/docs/tb21-audit.md +18 -4
  149. package/docs/usage.md +5 -0
  150. package/docs/verified-run-remaining-design.md +881 -0
  151. package/docs/verified-run-testing.md +91 -0
  152. package/docs/verified-run.md +30 -9
  153. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  154. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  155. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  156. package/examples/extensions/gondolin/package-lock.json +2 -2
  157. package/examples/extensions/gondolin/package.json +1 -1
  158. package/examples/extensions/sandbox/package-lock.json +2 -2
  159. package/examples/extensions/sandbox/package.json +1 -1
  160. package/examples/extensions/with-deps/package-lock.json +2 -2
  161. package/examples/extensions/with-deps/package.json +1 -1
  162. package/npm-shrinkwrap.json +18 -18
  163. package/package.json +6 -6
@@ -1,7 +1,8 @@
1
1
  import { reduceDagEvent } from "./dag-projection.js";
2
+ import { reduceProcessEvent } from "./process-projection.js";
2
3
  import { reduceRecoveryEvent } from "./recovery-projection.js";
3
4
  import { VerifiedRunError } from "./storage.js";
4
- import { acceptWriterDispatch, reduceWriterEvent } from "./writer-projection.js";
5
+ import { reduceWriterEvent } from "./writer-projection.js";
5
6
  /** Deterministic replay only. Recovery observations are supplied by the trusted host adapter. */
6
7
  export function projectRun(events) {
7
8
  const first = events[0];
@@ -48,10 +49,8 @@ export function projectRun(events) {
48
49
  processes: [],
49
50
  },
50
51
  };
51
- const dispatched = new Set();
52
- const checked = new Set();
52
+ const progress = { dispatched: new Set(), checked: new Set(), activeRole: "writer" };
53
53
  const commands = new Set([first.command.commandId]);
54
- let activeRole = "writer";
55
54
  for (const event of events.slice(1)) {
56
55
  const state = context.state;
57
56
  if (state.execution === "failed" || state.receiptDigest)
@@ -94,57 +93,10 @@ export function projectRun(events) {
94
93
  case "writer_closed":
95
94
  reduceWriterEvent(context, event);
96
95
  break;
97
- case "dispatch": {
98
- if (state.failure || state.activeExecutionIds.length || dispatched.has(event.executionId))
99
- throw new VerifiedRunError("integrity");
100
- if (event.role === "writer") {
101
- acceptWriterDispatch(context, event);
102
- }
103
- else {
104
- if (!context.writerFinished ||
105
- state.writerOpen ||
106
- !state.candidateDigest ||
107
- event.claimId === null ||
108
- !first.contract.checks.some((check) => check.claimId === event.claimId) ||
109
- checked.has(event.claimId))
110
- throw new VerifiedRunError("integrity");
111
- checked.add(event.claimId);
112
- }
113
- dispatched.add(event.executionId);
114
- activeRole = event.role;
115
- context.state = {
116
- ...state,
117
- execution: "running",
118
- settlement: "draining",
119
- activeExecutionIds: [event.executionId],
120
- };
121
- break;
122
- }
96
+ case "dispatch":
123
97
  case "process_ready":
124
- if (!state.budget ||
125
- state.activeExecutionIds[0] !== event.executionId ||
126
- event.identity.bootId !== state.budget.bootId ||
127
- state.processes.some((item) => item.executionId === event.executionId))
128
- throw new VerifiedRunError("integrity");
129
- context.state = {
130
- ...state,
131
- processes: [...state.processes, { executionId: event.executionId, identity: event.identity }],
132
- };
133
- break;
134
98
  case "exited":
135
- if (state.activeExecutionIds[0] !== event.executionId ||
136
- (state.budget &&
137
- event.failure === null &&
138
- !state.processes.some((item) => item.executionId === event.executionId)))
139
- throw new VerifiedRunError("integrity");
140
- if (activeRole === "writer")
141
- context.writerFinished = event.failure === null;
142
- context.state = {
143
- ...state,
144
- settlement: state.writerOpen ? "open" : "settled",
145
- activeExecutionIds: [],
146
- failure: event.failure,
147
- };
99
+ reduceProcessEvent(context, event, progress);
148
100
  break;
149
101
  case "candidate": {
150
102
  if (!context.writerFinished ||
@@ -176,13 +128,17 @@ export function projectRun(events) {
176
128
  case "resumed":
177
129
  case "tasks_retried":
178
130
  case "writer_restarted":
179
- reduceRecoveryEvent(context, event, { commands, checked, activeRole });
131
+ reduceRecoveryEvent(context, event, {
132
+ commands,
133
+ checked: progress.checked,
134
+ activeRole: progress.activeRole,
135
+ });
180
136
  break;
181
137
  case "evaluated":
182
138
  if (!state.candidateDigest ||
183
139
  state.writerOpen ||
184
140
  state.activeExecutionIds.length ||
185
- checked.size !== first.contract.checks.length ||
141
+ progress.checked.size !== first.contract.checks.length ||
186
142
  (event.verified && state.failure))
187
143
  throw new VerifiedRunError("integrity");
188
144
  context.state = {
@@ -1 +1 @@
1
- {"version":3,"file":"projection.js","sourceRoot":"","sources":["../../../src/core/verified-run/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,MAA2B,EAAiB;IACtE,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,KAAK,EAAE,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK;QAC5E,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,OAAO,GAAoB;QAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,CAAC;QACjB,eAAe,EAAE,CAAC;QAClB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,KAAK,EAAE;YACN,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK;YAC3B,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE,CAAC;YACb,SAAS,EAAE,OAAO;YAClB,UAAU,EAAE,MAAM;YAClB,YAAY,EAAE,eAAe;YAC7B,WAAW,EAAE,eAAe;YAC5B,eAAe,EAAE,IAAI;YACrB,WAAW,EAAE,IAAI;YACjB,aAAa,EAAE,IAAI;Y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AE,GAAG,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;IACpE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,GAAG,OAAO,CAAC,KAAK;QAChB,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACxE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;KAC5E,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { reduceDagEvent } from \"./dag-projection.ts\";\nimport type { RunTaskProjection } from \"./dag-types.ts\";\nimport { reduceRecoveryEvent } from \"./recovery-projection.ts\";\nimport type { RunEvent, RunProjection, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { acceptWriterDispatch, reduceWriterEvent } from \"./writer-projection.ts\";\n\n/** Deterministic replay only. Recovery observations are supplied by the trusted host adapter. */\nexport function projectRun(events: readonly RunEvent[]): RunProjection {\n\tconst first = events[0];\n\tif (first?.kind !== \"created\" || first.contract.runId !== first.command.runId)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tconst context: WriterReduction = {\n\t\tcontract: first.contract,\n\t\twriterFinished: false,\n\t\twriterStarted: false,\n\t\tproducerStarted: false,\n\t\twriterCommands: 0,\n\t\trequestBaseline: 0,\n\t\trequests: new Set(),\n\t\tstate: {\n\t\t\trunId: first.contract.runId,\n\t\t\trevision: 1,\n\t\t\tgeneration: 1,\n\t\t\texecution: \"ready\",\n\t\t\tsettlement: \"open\",\n\t\t\tverification: \"not_requested\",\n\t\t\tapplication: \"not_requested\",\n\t\t\tcandidateDigest: null,\n\t\t\tinputDigest: null,\n\t\t\treceiptDigest: null,\n\t\t\tfailure: null,\n\t\t\tactiveExecutionIds: [],\n\t\t\twriterOpen: false,\n\t\t\tmodelRequests: 0,\n\t\t\ttasks:\n\t\t\t\tfirst.contract.profile === \"linux-command-dag-v1\"\n\t\t\t\t\t? first.contract.writer.tasks.map(\n\t\t\t\t\t\t\t(task): RunTaskProjection => ({\n\t\t\t\t\t\t\t\ttaskId: task.id,\n\t\t\t\t\t\t\t\tattempt: 0,\n\t\t\t\t\t\t\t\tgeneration: 1,\n\t\t\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\t\t\tinputDigest: null,\n\t\t\t\t\t\t\t\toutputDigest: null,\n\t\t\t\t\t\t\t\tfailure: null,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: [],\n\t\t\tbudget: null,\n\t\t\tenvironmentDigest: null,\n\t\t\tverificationDeadlineMs: null,\n\t\t\tlastClockMs: null,\n\t\t\tprocesses: [],\n\t\t},\n\t};\n\tconst dispatched = new Set<string>();\n\tconst checked = new Set<string>();\n\tconst commands = new Set([first.command.commandId]);\n\tlet activeRole: \"writer\" | \"verifier\" = \"writer\";\n\tfor (const event of events.slice(1)) {\n\t\tconst state = context.state;\n\t\tif (state.execution === \"failed\" || state.receiptDigest) throw new VerifiedRunError(\"integrity\");\n\t\tswitch (event.kind) {\n\t\t\tcase \"created\":\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcase \"budget_anchored\": {\n\t\t\t\tconst budget = event.budget;\n\t\t\t\tconst limits = first.contract.budget;\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 1 ||\n\t\t\t\t\tstate.budget ||\n\t\t\t\t\tbudget.workDeadlineMs - budget.startedMs !== limits.workMs ||\n\t\t\t\t\tbudget.verifyCapMs - budget.workDeadlineMs !== limits.verifyMs ||\n\t\t\t\t\tbudget.cleanupDeadlineMs - budget.verifyCapMs !== limits.cleanupMs\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tbudget,\n\t\t\t\t\tenvironmentDigest: event.environmentDigest,\n\t\t\t\t\tlastClockMs: budget.startedMs,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"input_checkpoint\":\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 2 ||\n\t\t\t\t\t!state.budget ||\n\t\t\t\t\tstate.inputDigest ||\n\t\t\t\t\tevent.digest !== first.contract.workspace.baseDigest\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = { ...state, inputDigest: event.digest };\n\t\t\t\tbreak;\n\t\t\tcase \"task_started\":\n\t\t\tcase \"task_finished\":\n\t\t\tcase \"tasks_paused\":\n\t\t\t\treduceDagEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"writer_opened\":\n\t\t\tcase \"model_request\":\n\t\t\tcase \"writer_closed\":\n\t\t\t\treduceWriterEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"dispatch\": {\n\t\t\t\tif (state.failure || state.activeExecutionIds.length || dispatched.has(event.executionId))\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tif (event.role === \"writer\") {\n\t\t\t\t\tacceptWriterDispatch(context, event);\n\t\t\t\t} else {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!context.writerFinished ||\n\t\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\t\t!state.candidateDigest ||\n\t\t\t\t\t\tevent.claimId === null ||\n\t\t\t\t\t\t!first.contract.checks.some((check) => check.claimId === event.claimId) ||\n\t\t\t\t\t\tchecked.has(event.claimId)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\t\tchecked.add(event.claimId);\n\t\t\t\t}\n\t\t\t\tdispatched.add(event.executionId);\n\t\t\t\tactiveRole = event.role;\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\texecution: \"running\",\n\t\t\t\t\tsettlement: \"draining\",\n\t\t\t\t\tactiveExecutionIds: [event.executionId],\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"process_ready\":\n\t\t\t\tif (\n\t\t\t\t\t!state.budget ||\n\t\t\t\t\tstate.activeExecutionIds[0] !== event.executionId ||\n\t\t\t\t\tevent.identity.bootId !== state.budget.bootId ||\n\t\t\t\t\tstate.processes.some((item) => item.executionId === event.executionId)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tprocesses: [...state.processes, { executionId: event.executionId, identity: event.identity }],\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"exited\":\n\t\t\t\tif (\n\t\t\t\t\tstate.activeExecutionIds[0] !== event.executionId ||\n\t\t\t\t\t(state.budget &&\n\t\t\t\t\t\tevent.failure === null &&\n\t\t\t\t\t\t!state.processes.some((item) => item.executionId === event.executionId))\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tif (activeRole === \"writer\") context.writerFinished = event.failure === null;\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tsettlement: state.writerOpen ? \"open\" : \"settled\",\n\t\t\t\t\tactiveExecutionIds: [],\n\t\t\t\t\tfailure: event.failure,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"candidate\": {\n\t\t\t\tif (\n\t\t\t\t\t!context.writerFinished ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.failure ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tstate.candidateDigest ||\n\t\t\t\t\tstate.tasks.some((task) => task.status !== \"succeeded\" || task.generation !== state.generation)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tif (state.budget) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.observedMs === undefined ||\n\t\t\t\t\t\tevent.verificationDeadlineMs === undefined ||\n\t\t\t\t\t\tevent.observedMs < state.budget.startedMs ||\n\t\t\t\t\t\tevent.observedMs > state.budget.workDeadlineMs ||\n\t\t\t\t\t\tevent.verificationDeadlineMs !==\n\t\t\t\t\t\t\tMath.min(event.observedMs + first.contract.budget.verifyMs, state.budget.verifyCapMs)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\t} else if (event.observedMs !== undefined || event.verificationDeadlineMs !== undefined)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tcandidateDigest: event.digest,\n\t\t\t\t\tverificationDeadlineMs: event.verificationDeadlineMs ?? null,\n\t\t\t\t\tlastClockMs: event.observedMs ?? null,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"resumed\":\n\t\t\tcase \"tasks_retried\":\n\t\t\tcase \"writer_restarted\":\n\t\t\t\treduceRecoveryEvent(context, event, { commands, checked, activeRole });\n\t\t\t\tbreak;\n\t\t\tcase \"evaluated\":\n\t\t\t\tif (\n\t\t\t\t\t!state.candidateDigest ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tchecked.size !== first.contract.checks.length ||\n\t\t\t\t\t(event.verified && state.failure)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\treceiptDigest: event.receiptDigest,\n\t\t\t\t\texecution: \"succeeded\",\n\t\t\t\t\tverification: event.verified ? \"verified\" : \"violated\",\n\t\t\t\t\tapplication: event.verified ? \"candidate_ready\" : \"not_requested\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"failed\":\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\texecution: \"failed\",\n\t\t\t\t\tfailure: event.code,\n\t\t\t\t\tverification: \"inconclusive\",\n\t\t\t\t\tsettlement: state.activeExecutionIds.length || state.writerOpen ? \"quarantined\" : \"settled\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tconst exhaustive: never = event;\n\t\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t\t}\n\t\t}\n\t\tcontext.state = { ...context.state, revision: state.revision + 1 };\n\t}\n\treturn Object.freeze({\n\t\t...context.state,\n\t\tactiveExecutionIds: Object.freeze([...context.state.activeExecutionIds]),\n\t\tprocesses: Object.freeze(context.state.processes.map((item) => Object.freeze(item))),\n\t\ttasks: Object.freeze(context.state.tasks.map((task) => Object.freeze(task))),\n\t});\n}\n"]}
1
+ {"version":3,"file":"projection.js","sourceRoot":"","sources":["../../../src/core/verified-run/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAyB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,MAA2B,EAAiB;IACtE,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,KAAK,EAAE,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,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CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;KAC5E,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { reduceDagEvent } from \"./dag-projection.ts\";\nimport type { RunTaskProjection } from \"./dag-types.ts\";\nimport { type ProcessReduction, reduceProcessEvent } from \"./process-projection.ts\";\nimport { reduceRecoveryEvent } from \"./recovery-projection.ts\";\nimport type { RunEvent, RunProjection, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { reduceWriterEvent } from \"./writer-projection.ts\";\n\n/** Deterministic replay only. Recovery observations are supplied by the trusted host adapter. */\nexport function projectRun(events: readonly RunEvent[]): RunProjection {\n\tconst first = events[0];\n\tif (first?.kind !== \"created\" || first.contract.runId !== first.command.runId)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tconst context: WriterReduction = {\n\t\tcontract: first.contract,\n\t\twriterFinished: false,\n\t\twriterStarted: false,\n\t\tproducerStarted: false,\n\t\twriterCommands: 0,\n\t\trequestBaseline: 0,\n\t\trequests: new Set(),\n\t\tstate: {\n\t\t\trunId: first.contract.runId,\n\t\t\trevision: 1,\n\t\t\tgeneration: 1,\n\t\t\texecution: \"ready\",\n\t\t\tsettlement: \"open\",\n\t\t\tverification: \"not_requested\",\n\t\t\tapplication: \"not_requested\",\n\t\t\tcandidateDigest: null,\n\t\t\tinputDigest: null,\n\t\t\treceiptDigest: null,\n\t\t\tfailure: null,\n\t\t\tactiveExecutionIds: [],\n\t\t\twriterOpen: false,\n\t\t\tmodelRequests: 0,\n\t\t\ttasks:\n\t\t\t\tfirst.contract.profile === \"linux-command-dag-v1\"\n\t\t\t\t\t? first.contract.writer.tasks.map(\n\t\t\t\t\t\t\t(task): RunTaskProjection => ({\n\t\t\t\t\t\t\t\ttaskId: task.id,\n\t\t\t\t\t\t\t\tattempt: 0,\n\t\t\t\t\t\t\t\tgeneration: 1,\n\t\t\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\t\t\tinputDigest: null,\n\t\t\t\t\t\t\t\toutputDigest: null,\n\t\t\t\t\t\t\t\tfailure: null,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: [],\n\t\t\tbudget: null,\n\t\t\tenvironmentDigest: null,\n\t\t\tverificationDeadlineMs: null,\n\t\t\tlastClockMs: null,\n\t\t\tprocesses: [],\n\t\t},\n\t};\n\tconst progress: ProcessReduction = { dispatched: new Set(), checked: new Set(), activeRole: \"writer\" };\n\tconst commands = new Set([first.command.commandId]);\n\tfor (const event of events.slice(1)) {\n\t\tconst state = context.state;\n\t\tif (state.execution === \"failed\" || state.receiptDigest) throw new VerifiedRunError(\"integrity\");\n\t\tswitch (event.kind) {\n\t\t\tcase \"created\":\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcase \"budget_anchored\": {\n\t\t\t\tconst budget = event.budget;\n\t\t\t\tconst limits = first.contract.budget;\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 1 ||\n\t\t\t\t\tstate.budget ||\n\t\t\t\t\tbudget.workDeadlineMs - budget.startedMs !== limits.workMs ||\n\t\t\t\t\tbudget.verifyCapMs - budget.workDeadlineMs !== limits.verifyMs ||\n\t\t\t\t\tbudget.cleanupDeadlineMs - budget.verifyCapMs !== limits.cleanupMs\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tbudget,\n\t\t\t\t\tenvironmentDigest: event.environmentDigest,\n\t\t\t\t\tlastClockMs: budget.startedMs,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"input_checkpoint\":\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 2 ||\n\t\t\t\t\t!state.budget ||\n\t\t\t\t\tstate.inputDigest ||\n\t\t\t\t\tevent.digest !== first.contract.workspace.baseDigest\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = { ...state, inputDigest: event.digest };\n\t\t\t\tbreak;\n\t\t\tcase \"task_started\":\n\t\t\tcase \"task_finished\":\n\t\t\tcase \"tasks_paused\":\n\t\t\t\treduceDagEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"writer_opened\":\n\t\t\tcase \"model_request\":\n\t\t\tcase \"writer_closed\":\n\t\t\t\treduceWriterEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"dispatch\":\n\t\t\tcase \"process_ready\":\n\t\t\tcase \"exited\":\n\t\t\t\treduceProcessEvent(context, event, progress);\n\t\t\t\tbreak;\n\t\t\tcase \"candidate\": {\n\t\t\t\tif (\n\t\t\t\t\t!context.writerFinished ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.failure ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tstate.candidateDigest ||\n\t\t\t\t\tstate.tasks.some((task) => task.status !== \"succeeded\" || task.generation !== state.generation)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tif (state.budget) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.observedMs === undefined ||\n\t\t\t\t\t\tevent.verificationDeadlineMs === undefined ||\n\t\t\t\t\t\tevent.observedMs < state.budget.startedMs ||\n\t\t\t\t\t\tevent.observedMs > state.budget.workDeadlineMs ||\n\t\t\t\t\t\tevent.verificationDeadlineMs !==\n\t\t\t\t\t\t\tMath.min(event.observedMs + first.contract.budget.verifyMs, state.budget.verifyCapMs)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\t} else if (event.observedMs !== undefined || event.verificationDeadlineMs !== undefined)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tcandidateDigest: event.digest,\n\t\t\t\t\tverificationDeadlineMs: event.verificationDeadlineMs ?? null,\n\t\t\t\t\tlastClockMs: event.observedMs ?? null,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"resumed\":\n\t\t\tcase \"tasks_retried\":\n\t\t\tcase \"writer_restarted\":\n\t\t\t\treduceRecoveryEvent(context, event, {\n\t\t\t\t\tcommands,\n\t\t\t\t\tchecked: progress.checked,\n\t\t\t\t\tactiveRole: progress.activeRole,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"evaluated\":\n\t\t\t\tif (\n\t\t\t\t\t!state.candidateDigest ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tprogress.checked.size !== first.contract.checks.length ||\n\t\t\t\t\t(event.verified && state.failure)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\treceiptDigest: event.receiptDigest,\n\t\t\t\t\texecution: \"succeeded\",\n\t\t\t\t\tverification: event.verified ? \"verified\" : \"violated\",\n\t\t\t\t\tapplication: event.verified ? \"candidate_ready\" : \"not_requested\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"failed\":\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\texecution: \"failed\",\n\t\t\t\t\tfailure: event.code,\n\t\t\t\t\tverification: \"inconclusive\",\n\t\t\t\t\tsettlement: state.activeExecutionIds.length || state.writerOpen ? \"quarantined\" : \"settled\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tconst exhaustive: never = event;\n\t\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t\t}\n\t\t}\n\t\tcontext.state = { ...context.state, revision: state.revision + 1 };\n\t}\n\treturn Object.freeze({\n\t\t...context.state,\n\t\tactiveExecutionIds: Object.freeze([...context.state.activeExecutionIds]),\n\t\tprocesses: Object.freeze(context.state.processes.map((item) => Object.freeze(item))),\n\t\ttasks: Object.freeze(context.state.tasks.map((task) => Object.freeze(task))),\n\t});\n}\n"]}
@@ -16,6 +16,7 @@ export type RunEvent = DagEvent | {
16
16
  readonly executionId: string;
17
17
  readonly role: "writer" | "verifier";
18
18
  readonly claimId: string | null;
19
+ readonly taskId?: string;
19
20
  } | {
20
21
  readonly kind: "input_checkpoint";
21
22
  readonly digest: string;
@@ -1 +1 @@
1
- {"version":3,"file":"run-types.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/run-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,MAAM,QAAQ,GACjB,QAAQ,GACR;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,GAC/F;IACA,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,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ommand,\n\tRunStartCommand,\n\tRunTaskRetryCommand,\n\tRunWriterRestartCommand,\n} from \"omk-protocol\";\nimport type { DagEvent, RunTaskCheckpoint, RunTaskProjection } from \"./dag-types.ts\";\nimport type { NamespaceIdentity } from \"./namespace-identity.ts\";\nimport type { RecoveryBudget } from \"./recovery-clock.ts\";\n\nexport type RunEvent =\n\t| DagEvent\n\t| { readonly kind: \"created\"; readonly contract: RunContract; readonly command: RunStartCommand }\n\t| {\n\t\t\treadonly kind: \"budget_anchored\";\n\t\t\treadonly budget: RecoveryBudget;\n\t\t\treadonly environmentDigest: string;\n\t\t\treadonly driver: \"linux-pidns-gate-v1\";\n\t }\n\t| {\n\t\t\treadonly kind: \"dispatch\";\n\t\t\treadonly executionId: string;\n\t\t\treadonly role: \"writer\" | \"verifier\";\n\t\t\treadonly claimId: string | null;\n\t }\n\t| { readonly kind: \"input_checkpoint\"; readonly digest: string }\n\t| { readonly kind: \"process_ready\"; readonly executionId: string; readonly identity: NamespaceIdentity }\n\t| { readonly kind: \"writer_opened\" }\n\t| { readonly kind: \"model_request\"; readonly requestId: string }\n\t| { readonly kind: \"writer_closed\"; readonly completed: boolean }\n\t| { readonly kind: \"exited\"; readonly executionId: string; readonly failure: string | null }\n\t| {\n\t\t\treadonly kind: \"candidate\";\n\t\t\treadonly digest: string;\n\t\t\treadonly observedMs?: number;\n\t\t\treadonly verificationDeadlineMs?: number;\n\t }\n\t| {\n\t\t\treadonly kind: \"resumed\";\n\t\t\treadonly command: RunResumeCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t }\n\t| {\n\t\t\treadonly kind: \"writer_restarted\";\n\t\t\treadonly command: RunWriterRestartCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t }\n\t| {\n\t\t\treadonly kind: \"tasks_retried\";\n\t\t\treadonly command: RunTaskRetryCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t\t\treadonly adopted: readonly RunTaskCheckpoint[];\n\t }\n\t| { readonly kind: \"evaluated\"; readonly receiptDigest: string; readonly verified: boolean }\n\t| { readonly kind: \"failed\"; readonly code: string };\n\nexport interface RunProjection {\n\treadonly runId: string;\n\treadonly revision: number;\n\treadonly generation: number;\n\treadonly execution: \"ready\" | \"running\" | \"paused\" | \"succeeded\" | \"failed\";\n\treadonly settlement: \"open\" | \"draining\" | \"settled\" | \"quarantined\";\n\treadonly verification: \"not_requested\" | \"verified\" | \"violated\" | \"inconclusive\";\n\treadonly application: \"not_requested\" | \"candidate_ready\";\n\treadonly candidateDigest: string | null;\n\treadonly inputDigest: string | null;\n\treadonly receiptDigest: string | null;\n\treadonly failure: string | null;\n\treadonly activeExecutionIds: readonly string[];\n\treadonly writerOpen: boolean;\n\treadonly modelRequests: number;\n\treadonly tasks: readonly RunTaskProjection[];\n\treadonly budget: RecoveryBudget | null;\n\treadonly environmentDigest: string | null;\n\treadonly verificationDeadlineMs: number | null;\n\treadonly lastClockMs: number | null;\n\treadonly processes: readonly { readonly executionId: string; readonly identity: NamespaceIdentity }[];\n}\n\n/** Mutable reduction bookkeeping, confined to one replay call. */\nexport interface WriterReduction {\n\treadonly contract: RunContract;\n\tstate: RunProjection;\n\twriterFinished: boolean;\n\twriterStarted: boolean;\n\tproducerStarted: boolean;\n\twriterCommands: number;\n\trequestBaseline: number;\n\treadonly requests: Set<string>;\n}\n"]}
1
+ {"version":3,"file":"run-types.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/run-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CA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C,QAAQ,EAAE,iBAAiB,CAAA;KAAE,EAAE,CAAC;CACtG;AAED,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,KAAK,EAAE,aAAa,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC/B","sourcesContent":["import type {\n\tRunContract,\n\tRunResumeCommand,\n\tRunStartCommand,\n\tRunTaskRetryCommand,\n\tRunWriterRestartCommand,\n} from \"omk-protocol\";\nimport type { DagEvent, RunTaskCheckpoint, RunTaskProjection } from \"./dag-types.ts\";\nimport type { NamespaceIdentity } from \"./namespace-identity.ts\";\nimport type { RecoveryBudget } from \"./recovery-clock.ts\";\n\nexport type RunEvent =\n\t| DagEvent\n\t| { readonly kind: \"created\"; readonly contract: RunContract; readonly command: RunStartCommand }\n\t| {\n\t\t\treadonly kind: \"budget_anchored\";\n\t\t\treadonly budget: RecoveryBudget;\n\t\t\treadonly environmentDigest: string;\n\t\t\treadonly driver: \"linux-pidns-gate-v1\";\n\t }\n\t| {\n\t\t\treadonly kind: \"dispatch\";\n\t\t\treadonly executionId: string;\n\t\t\treadonly role: \"writer\" | \"verifier\";\n\t\t\treadonly claimId: string | null;\n\t\t\treadonly taskId?: string;\n\t }\n\t| { readonly kind: \"input_checkpoint\"; readonly digest: string }\n\t| { readonly kind: \"process_ready\"; readonly executionId: string; readonly identity: NamespaceIdentity }\n\t| { readonly kind: \"writer_opened\" }\n\t| { readonly kind: \"model_request\"; readonly requestId: string }\n\t| { readonly kind: \"writer_closed\"; readonly completed: boolean }\n\t| { readonly kind: \"exited\"; readonly executionId: string; readonly failure: string | null }\n\t| {\n\t\t\treadonly kind: \"candidate\";\n\t\t\treadonly digest: string;\n\t\t\treadonly observedMs?: number;\n\t\t\treadonly verificationDeadlineMs?: number;\n\t }\n\t| {\n\t\t\treadonly kind: \"resumed\";\n\t\t\treadonly command: RunResumeCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t }\n\t| {\n\t\t\treadonly kind: \"writer_restarted\";\n\t\t\treadonly command: RunWriterRestartCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t }\n\t| {\n\t\t\treadonly kind: \"tasks_retried\";\n\t\t\treadonly command: RunTaskRetryCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t\t\treadonly adopted: readonly RunTaskCheckpoint[];\n\t }\n\t| { readonly kind: \"evaluated\"; readonly receiptDigest: string; readonly verified: boolean }\n\t| { readonly kind: \"failed\"; readonly code: string };\n\nexport interface RunProjection {\n\treadonly runId: string;\n\treadonly revision: number;\n\treadonly generation: number;\n\treadonly execution: \"ready\" | \"running\" | \"paused\" | \"succeeded\" | \"failed\";\n\treadonly settlement: \"open\" | \"draining\" | \"settled\" | \"quarantined\";\n\treadonly verification: \"not_requested\" | \"verified\" | \"violated\" | \"inconclusive\";\n\treadonly application: \"not_requested\" | \"candidate_ready\";\n\treadonly candidateDigest: string | null;\n\treadonly inputDigest: string | null;\n\treadonly receiptDigest: string | null;\n\treadonly failure: string | null;\n\treadonly activeExecutionIds: readonly string[];\n\treadonly writerOpen: boolean;\n\treadonly modelRequests: number;\n\treadonly tasks: readonly RunTaskProjection[];\n\treadonly budget: RecoveryBudget | null;\n\treadonly environmentDigest: string | null;\n\treadonly verificationDeadlineMs: number | null;\n\treadonly lastClockMs: number | null;\n\treadonly processes: readonly { readonly executionId: string; readonly identity: NamespaceIdentity }[];\n}\n\n/** Mutable reduction bookkeeping, confined to one replay call. */\nexport interface WriterReduction {\n\treadonly contract: RunContract;\n\tstate: RunProjection;\n\twriterFinished: boolean;\n\twriterStarted: boolean;\n\tproducerStarted: boolean;\n\twriterCommands: number;\n\trequestBaseline: number;\n\treadonly requests: Set<string>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"run-types.js","sourceRoot":"","sources":["../../../src/core/verified-run/run-types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n\tRunContract,\n\tRunResumeCommand,\n\tRunStartCommand,\n\tRunTaskRetryCommand,\n\tRunWriterRestartCommand,\n} from \"omk-protocol\";\nimport type { DagEvent, RunTaskCheckpoint, RunTaskProjection } from \"./dag-types.ts\";\nimport type { NamespaceIdentity } from \"./namespace-identity.ts\";\nimport type { RecoveryBudget } from \"./recovery-clock.ts\";\n\nexport type RunEvent =\n\t| DagEvent\n\t| { readonly kind: \"created\"; readonly contract: RunContract; readonly command: RunStartCommand }\n\t| {\n\t\t\treadonly kind: \"budget_anchored\";\n\t\t\treadonly budget: RecoveryBudget;\n\t\t\treadonly environmentDigest: string;\n\t\t\treadonly driver: \"linux-pidns-gate-v1\";\n\t }\n\t| {\n\t\t\treadonly kind: \"dispatch\";\n\t\t\treadonly executionId: string;\n\t\t\treadonly role: \"writer\" | \"verifier\";\n\t\t\treadonly claimId: string | null;\n\t }\n\t| { readonly kind: \"input_checkpoint\"; readonly digest: string }\n\t| { readonly kind: \"process_ready\"; readonly executionId: string; readonly identity: NamespaceIdentity }\n\t| { readonly kind: \"writer_opened\" }\n\t| { readonly kind: \"model_request\"; readonly requestId: string }\n\t| { readonly kind: \"writer_closed\"; readonly completed: boolean }\n\t| { readonly kind: \"exited\"; readonly executionId: string; readonly failure: string | null }\n\t| {\n\t\t\treadonly kind: \"candidate\";\n\t\t\treadonly digest: string;\n\t\t\treadonly observedMs?: number;\n\t\t\treadonly verificationDeadlineMs?: number;\n\t }\n\t| {\n\t\t\treadonly kind: \"resumed\";\n\t\t\treadonly command: RunResumeCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t }\n\t| {\n\t\t\treadonly kind: \"writer_restarted\";\n\t\t\treadonly command: RunWriterRestartCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t }\n\t| {\n\t\t\treadonly kind: \"tasks_retried\";\n\t\t\treadonly command: RunTaskRetryCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t\t\treadonly adopted: readonly RunTaskCheckpoint[];\n\t }\n\t| { readonly kind: \"evaluated\"; readonly receiptDigest: string; readonly verified: boolean }\n\t| { readonly kind: \"failed\"; readonly code: string };\n\nexport interface RunProjection {\n\treadonly runId: string;\n\treadonly revision: number;\n\treadonly generation: number;\n\treadonly execution: \"ready\" | \"running\" | \"paused\" | \"succeeded\" | \"failed\";\n\treadonly settlement: \"open\" | \"draining\" | \"settled\" | \"quarantined\";\n\treadonly verification: \"not_requested\" | \"verified\" | \"violated\" | \"inconclusive\";\n\treadonly application: \"not_requested\" | \"candidate_ready\";\n\treadonly candidateDigest: string | null;\n\treadonly inputDigest: string | null;\n\treadonly receiptDigest: string | null;\n\treadonly failure: string | null;\n\treadonly activeExecutionIds: readonly string[];\n\treadonly writerOpen: boolean;\n\treadonly modelRequests: number;\n\treadonly tasks: readonly RunTaskProjection[];\n\treadonly budget: RecoveryBudget | null;\n\treadonly environmentDigest: string | null;\n\treadonly verificationDeadlineMs: number | null;\n\treadonly lastClockMs: number | null;\n\treadonly processes: readonly { readonly executionId: string; readonly identity: NamespaceIdentity }[];\n}\n\n/** Mutable reduction bookkeeping, confined to one replay call. */\nexport interface WriterReduction {\n\treadonly contract: RunContract;\n\tstate: RunProjection;\n\twriterFinished: boolean;\n\twriterStarted: boolean;\n\tproducerStarted: boolean;\n\twriterCommands: number;\n\trequestBaseline: number;\n\treadonly requests: Set<string>;\n}\n"]}
1
+ {"version":3,"file":"run-types.js","sourceRoot":"","sources":["../../../src/core/verified-run/run-types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n\tRunContract,\n\tRunResumeCommand,\n\tRunStartCommand,\n\tRunTaskRetryCommand,\n\tRunWriterRestartCommand,\n} from \"omk-protocol\";\nimport type { DagEvent, RunTaskCheckpoint, RunTaskProjection } from \"./dag-types.ts\";\nimport type { NamespaceIdentity } from \"./namespace-identity.ts\";\nimport type { RecoveryBudget } from \"./recovery-clock.ts\";\n\nexport type RunEvent =\n\t| DagEvent\n\t| { readonly kind: \"created\"; readonly contract: RunContract; readonly command: RunStartCommand }\n\t| {\n\t\t\treadonly kind: \"budget_anchored\";\n\t\t\treadonly budget: RecoveryBudget;\n\t\t\treadonly environmentDigest: string;\n\t\t\treadonly driver: \"linux-pidns-gate-v1\";\n\t }\n\t| {\n\t\t\treadonly kind: \"dispatch\";\n\t\t\treadonly executionId: string;\n\t\t\treadonly role: \"writer\" | \"verifier\";\n\t\t\treadonly claimId: string | null;\n\t\t\treadonly taskId?: string;\n\t }\n\t| { readonly kind: \"input_checkpoint\"; readonly digest: string }\n\t| { readonly kind: \"process_ready\"; readonly executionId: string; readonly identity: NamespaceIdentity }\n\t| { readonly kind: \"writer_opened\" }\n\t| { readonly kind: \"model_request\"; readonly requestId: string }\n\t| { readonly kind: \"writer_closed\"; readonly completed: boolean }\n\t| { readonly kind: \"exited\"; readonly executionId: string; readonly failure: string | null }\n\t| {\n\t\t\treadonly kind: \"candidate\";\n\t\t\treadonly digest: string;\n\t\t\treadonly observedMs?: number;\n\t\t\treadonly verificationDeadlineMs?: number;\n\t }\n\t| {\n\t\t\treadonly kind: \"resumed\";\n\t\t\treadonly command: RunResumeCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t }\n\t| {\n\t\t\treadonly kind: \"writer_restarted\";\n\t\t\treadonly command: RunWriterRestartCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t }\n\t| {\n\t\t\treadonly kind: \"tasks_retried\";\n\t\t\treadonly command: RunTaskRetryCommand;\n\t\t\treadonly observedMs: number;\n\t\t\treadonly reconciledExecutionIds: readonly string[];\n\t\t\treadonly adopted: readonly RunTaskCheckpoint[];\n\t }\n\t| { readonly kind: \"evaluated\"; readonly receiptDigest: string; readonly verified: boolean }\n\t| { readonly kind: \"failed\"; readonly code: string };\n\nexport interface RunProjection {\n\treadonly runId: string;\n\treadonly revision: number;\n\treadonly generation: number;\n\treadonly execution: \"ready\" | \"running\" | \"paused\" | \"succeeded\" | \"failed\";\n\treadonly settlement: \"open\" | \"draining\" | \"settled\" | \"quarantined\";\n\treadonly verification: \"not_requested\" | \"verified\" | \"violated\" | \"inconclusive\";\n\treadonly application: \"not_requested\" | \"candidate_ready\";\n\treadonly candidateDigest: string | null;\n\treadonly inputDigest: string | null;\n\treadonly receiptDigest: string | null;\n\treadonly failure: string | null;\n\treadonly activeExecutionIds: readonly string[];\n\treadonly writerOpen: boolean;\n\treadonly modelRequests: number;\n\treadonly tasks: readonly RunTaskProjection[];\n\treadonly budget: RecoveryBudget | null;\n\treadonly environmentDigest: string | null;\n\treadonly verificationDeadlineMs: number | null;\n\treadonly lastClockMs: number | null;\n\treadonly processes: readonly { readonly executionId: string; readonly identity: NamespaceIdentity }[];\n}\n\n/** Mutable reduction bookkeeping, confined to one replay call. */\nexport interface WriterReduction {\n\treadonly contract: RunContract;\n\tstate: RunProjection;\n\twriterFinished: boolean;\n\twriterStarted: boolean;\n\tproducerStarted: boolean;\n\twriterCommands: number;\n\trequestBaseline: number;\n\treadonly requests: Set<string>;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { RunEvent, WriterReduction } from "./run-types.ts";
2
+ /** Associate a process with exactly one current attempt, including old serial journals without taskId. */
3
+ export declare function bindTaskExecution(context: WriterReduction, event: Extract<RunEvent, {
4
+ kind: "dispatch";
5
+ }>): void;
6
+ export declare function endTaskExecution(context: WriterReduction, event: Extract<RunEvent, {
7
+ kind: "exited";
8
+ }>): void;
9
+ //# sourceMappingURL=task-execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-execution.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/task-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGhE,0GAA0G;AAC1G,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GAAG,IAAI,CAWhH;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,IAAI,CAc7G","sourcesContent":["import type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\n/** Associate a process with exactly one current attempt, including old serial journals without taskId. */\nexport function bindTaskExecution(context: WriterReduction, event: Extract<RunEvent, { kind: \"dispatch\" }>): void {\n\tconst { contract, state } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"integrity\");\n\tconst running = state.tasks.filter((task) => task.status === \"running\");\n\tif (event.taskId === undefined && ((contract.writer.maxConcurrentTasks ?? 1) !== 1 || running.length !== 1))\n\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\tconst task = event.taskId === undefined ? running[0] : running.find((task) => task.taskId === event.taskId);\n\tif (!task || task.status !== \"running\" || task.generation !== state.generation || task.execution.kind !== \"ready\")\n\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\tconst next = { ...task, execution: Object.freeze({ kind: \"running\" as const, executionId: event.executionId }) };\n\tcontext.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };\n}\n\nexport function endTaskExecution(context: WriterReduction, event: Extract<RunEvent, { kind: \"exited\" }>): void {\n\tconst state = context.state;\n\tconst task = state.tasks.find(\n\t\t(task) =>\n\t\t\ttask.status === \"running\" &&\n\t\t\ttask.execution.kind === \"running\" &&\n\t\t\ttask.execution.executionId === event.executionId,\n\t);\n\tif (!task || task.status !== \"running\") throw new VerifiedRunError(\"integrity\");\n\tconst next = {\n\t\t...task,\n\t\texecution: Object.freeze({ kind: \"exited\" as const, executionId: event.executionId, failure: event.failure }),\n\t};\n\tcontext.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import { VerifiedRunError } from "./storage.js";
2
+ /** Associate a process with exactly one current attempt, including old serial journals without taskId. */
3
+ export function bindTaskExecution(context, event) {
4
+ const { contract, state } = context;
5
+ if (contract.profile !== "linux-command-dag-v1")
6
+ throw new VerifiedRunError("integrity");
7
+ const running = state.tasks.filter((task) => task.status === "running");
8
+ if (event.taskId === undefined && ((contract.writer.maxConcurrentTasks ?? 1) !== 1 || running.length !== 1))
9
+ throw new VerifiedRunError("task_not_ready");
10
+ const task = event.taskId === undefined ? running[0] : running.find((task) => task.taskId === event.taskId);
11
+ if (!task || task.status !== "running" || task.generation !== state.generation || task.execution.kind !== "ready")
12
+ throw new VerifiedRunError("task_not_ready");
13
+ const next = { ...task, execution: Object.freeze({ kind: "running", executionId: event.executionId }) };
14
+ context.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };
15
+ }
16
+ export function endTaskExecution(context, event) {
17
+ const state = context.state;
18
+ const task = state.tasks.find((task) => task.status === "running" &&
19
+ task.execution.kind === "running" &&
20
+ task.execution.executionId === event.executionId);
21
+ if (!task || task.status !== "running")
22
+ throw new VerifiedRunError("integrity");
23
+ const next = {
24
+ ...task,
25
+ execution: Object.freeze({ kind: "exited", executionId: event.executionId, failure: event.failure }),
26
+ };
27
+ context.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };
28
+ }
29
+ //# sourceMappingURL=task-execution.js.map
@@ -0,0 +1 @@
1
+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CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;AAAA,CAC5G","sourcesContent":["import type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\n/** Associate a process with exactly one current attempt, including old serial journals without taskId. */\nexport function bindTaskExecution(context: WriterReduction, event: Extract<RunEvent, { kind: \"dispatch\" }>): void {\n\tconst { contract, state } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"integrity\");\n\tconst running = state.tasks.filter((task) => task.status === \"running\");\n\tif (event.taskId === undefined && ((contract.writer.maxConcurrentTasks ?? 1) !== 1 || running.length !== 1))\n\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\tconst task = event.taskId === undefined ? running[0] : running.find((task) => task.taskId === event.taskId);\n\tif (!task || task.status !== \"running\" || task.generation !== state.generation || task.execution.kind !== \"ready\")\n\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\tconst next = { ...task, execution: Object.freeze({ kind: \"running\" as const, executionId: event.executionId }) };\n\tcontext.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };\n}\n\nexport function endTaskExecution(context: WriterReduction, event: Extract<RunEvent, { kind: \"exited\" }>): void {\n\tconst state = context.state;\n\tconst task = state.tasks.find(\n\t\t(task) =>\n\t\t\ttask.status === \"running\" &&\n\t\t\ttask.execution.kind === \"running\" &&\n\t\t\ttask.execution.executionId === event.executionId,\n\t);\n\tif (!task || task.status !== \"running\") throw new VerifiedRunError(\"integrity\");\n\tconst next = {\n\t\t...task,\n\t\texecution: Object.freeze({ kind: \"exited\" as const, executionId: event.executionId, failure: event.failure }),\n\t};\n\tcontext.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"writer-projection.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/writer-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGhE,KAAK,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,eAAe,GAAG,eAAe,GAAG,eAAe,CAAA;CAAE,CAAC,CAAC;AAEpG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GAAG,IAAI,CA6BnH;AAED,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CA0CpF","sourcesContent":["import type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\ntype WriterEvent = Extract<RunEvent, { kind: \"writer_opened\" | \"model_request\" | \"writer_closed\" }>;\n\nexport function acceptWriterDispatch(context: WriterReduction, event: Extract<RunEvent, { kind: \"dispatch\" }>): void {\n\tconst { state, contract } = context;\n\tif (event.claimId !== null || state.candidateDigest) throw new VerifiedRunError(\"integrity\");\n\tswitch (contract.profile) {\n\t\tcase \"linux-command-v1\":\n\t\t\tif (context.writerStarted) throw new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-scripted-agent-v1\":\n\t\t\tif (\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.writerCommands >= contract.writer.steps.length ||\n\t\t\t\tstate.modelRequests - context.requestBaseline <= context.writerCommands\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-command-dag-v1\":\n\t\t\tif (\n\t\t\t\tcontext.writerStarted ||\n\t\t\t\t!state.tasks.some((task) => task.status === \"running\" && task.generation === state.generation)\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\t\t\tbreak;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = contract;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n\tcontext.writerStarted = true;\n\tcontext.writerCommands += 1;\n}\n\n/** Mutates only the private replay accumulator; no work, clocks, or caller data are consulted. */\nexport function reduceWriterEvent(context: WriterReduction, event: WriterEvent): void {\n\tconst state = context.state;\n\tconst scripted = context.contract.profile === \"linux-scripted-agent-v1\" ? context.contract.writer : undefined;\n\tswitch (event.kind) {\n\t\tcase \"writer_opened\":\n\t\t\tif (!scripted || context.producerStarted || context.writerStarted || state.candidateDigest)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.producerStarted = true;\n\t\t\tcontext.state = { ...state, writerOpen: true, execution: \"running\", settlement: \"open\" };\n\t\t\treturn;\n\t\tcase \"model_request\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.requests.has(event.requestId) ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\tstate.modelRequests >= scripted.maxRequests\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"model_request_limit\");\n\t\t\tcontext.requests.add(event.requestId);\n\t\t\tcontext.state = { ...state, modelRequests: state.modelRequests + 1 };\n\t\t\treturn;\n\t\tcase \"writer_closed\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t(event.completed &&\n\t\t\t\t\t(!context.writerFinished ||\n\t\t\t\t\t\tstate.failure ||\n\t\t\t\t\t\tcontext.writerCommands !== scripted.steps.length ||\n\t\t\t\t\t\tstate.modelRequests - context.requestBaseline < scripted.steps.length + 1))\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.writerFinished = event.completed;\n\t\t\tcontext.state = { ...state, writerOpen: false, settlement: \"settled\" };\n\t\t\treturn;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = event;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"writer-projection.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/writer-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAIhE,KAAK,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,eAAe,GAAG,eAAe,GAAG,eAAe,CAAA;CAAE,CAAC,CAAC;AAEpG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GAAG,IAAI,CA8BnH;AAED,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CA0CpF","sourcesContent":["import type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { bindTaskExecution } from \"./task-execution.ts\";\n\ntype WriterEvent = Extract<RunEvent, { kind: \"writer_opened\" | \"model_request\" | \"writer_closed\" }>;\n\nexport function acceptWriterDispatch(context: WriterReduction, event: Extract<RunEvent, { kind: \"dispatch\" }>): void {\n\tconst { state, contract } = context;\n\tif (\n\t\tevent.claimId !== null ||\n\t\tstate.candidateDigest ||\n\t\t(event.taskId !== undefined && contract.profile !== \"linux-command-dag-v1\")\n\t)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tswitch (contract.profile) {\n\t\tcase \"linux-command-v1\":\n\t\t\tif (context.writerStarted) throw new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-scripted-agent-v1\":\n\t\t\tif (\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.writerCommands >= contract.writer.steps.length ||\n\t\t\t\tstate.modelRequests - context.requestBaseline <= context.writerCommands\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-command-dag-v1\":\n\t\t\tbindTaskExecution(context, event);\n\t\t\treturn;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = contract;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n\tcontext.writerStarted = true;\n\tcontext.writerCommands += 1;\n}\n\n/** Mutates only the private replay accumulator; no work, clocks, or caller data are consulted. */\nexport function reduceWriterEvent(context: WriterReduction, event: WriterEvent): void {\n\tconst state = context.state;\n\tconst scripted = context.contract.profile === \"linux-scripted-agent-v1\" ? context.contract.writer : undefined;\n\tswitch (event.kind) {\n\t\tcase \"writer_opened\":\n\t\t\tif (!scripted || context.producerStarted || context.writerStarted || state.candidateDigest)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.producerStarted = true;\n\t\t\tcontext.state = { ...state, writerOpen: true, execution: \"running\", settlement: \"open\" };\n\t\t\treturn;\n\t\tcase \"model_request\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.requests.has(event.requestId) ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\tstate.modelRequests >= scripted.maxRequests\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"model_request_limit\");\n\t\t\tcontext.requests.add(event.requestId);\n\t\t\tcontext.state = { ...state, modelRequests: state.modelRequests + 1 };\n\t\t\treturn;\n\t\tcase \"writer_closed\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t(event.completed &&\n\t\t\t\t\t(!context.writerFinished ||\n\t\t\t\t\t\tstate.failure ||\n\t\t\t\t\t\tcontext.writerCommands !== scripted.steps.length ||\n\t\t\t\t\t\tstate.modelRequests - context.requestBaseline < scripted.steps.length + 1))\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.writerFinished = event.completed;\n\t\t\tcontext.state = { ...state, writerOpen: false, settlement: \"settled\" };\n\t\t\treturn;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = event;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n}\n"]}
@@ -1,7 +1,10 @@
1
1
  import { VerifiedRunError } from "./storage.js";
2
+ import { bindTaskExecution } from "./task-execution.js";
2
3
  export function acceptWriterDispatch(context, event) {
3
4
  const { state, contract } = context;
4
- if (event.claimId !== null || state.candidateDigest)
5
+ if (event.claimId !== null ||
6
+ state.candidateDigest ||
7
+ (event.taskId !== undefined && contract.profile !== "linux-command-dag-v1"))
5
8
  throw new VerifiedRunError("integrity");
6
9
  switch (contract.profile) {
7
10
  case "linux-command-v1":
@@ -15,10 +18,8 @@ export function acceptWriterDispatch(context, event) {
15
18
  throw new VerifiedRunError("integrity");
16
19
  break;
17
20
  case "linux-command-dag-v1":
18
- if (context.writerStarted ||
19
- !state.tasks.some((task) => task.status === "running" && task.generation === state.generation))
20
- throw new VerifiedRunError("task_not_ready");
21
- break;
21
+ bindTaskExecution(context, event);
22
+ return;
22
23
  default: {
23
24
  const exhaustive = contract;
24
25
  throw new VerifiedRunError(String(exhaustive));
@@ -1 +1 @@
1
- {"version":3,"file":"writer-projection.js","sourceRoot":"","sources":["../../../src/core/verified-run/writer-projection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,MAAM,UAAU,oBAAoB,CAAC,OAAwB,EAAE,KAA8C,EAAQ;IACpH,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACpC,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,KAAK,CAAC,eAAe;QAAE,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC7F,QAAQ,QAAQ,CAAC,OAAO,EAAE,CAAC;QAC1B,KAAK,kBAAkB;YACtB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ACzC,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,SAAS,CAAC;YACzC,OAAO,CAAC,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;YACvE,OAAO;QACR,SAAS,CAAC;YACT,MAAM,UAAU,GAAU,KAAK,CAAC;YAChC,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;QAChD,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["import type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\ntype WriterEvent = Extract<RunEvent, { kind: \"writer_opened\" | \"model_request\" | \"writer_closed\" }>;\n\nexport function acceptWriterDispatch(context: WriterReduction, event: Extract<RunEvent, { kind: \"dispatch\" }>): void {\n\tconst { state, contract } = context;\n\tif (event.claimId !== null || state.candidateDigest) throw new VerifiedRunError(\"integrity\");\n\tswitch (contract.profile) {\n\t\tcase \"linux-command-v1\":\n\t\t\tif (context.writerStarted) throw new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-scripted-agent-v1\":\n\t\t\tif (\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.writerCommands >= contract.writer.steps.length ||\n\t\t\t\tstate.modelRequests - context.requestBaseline <= context.writerCommands\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-command-dag-v1\":\n\t\t\tif (\n\t\t\t\tcontext.writerStarted ||\n\t\t\t\t!state.tasks.some((task) => task.status === \"running\" && task.generation === state.generation)\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\t\t\tbreak;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = contract;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n\tcontext.writerStarted = true;\n\tcontext.writerCommands += 1;\n}\n\n/** Mutates only the private replay accumulator; no work, clocks, or caller data are consulted. */\nexport function reduceWriterEvent(context: WriterReduction, event: WriterEvent): void {\n\tconst state = context.state;\n\tconst scripted = context.contract.profile === \"linux-scripted-agent-v1\" ? context.contract.writer : undefined;\n\tswitch (event.kind) {\n\t\tcase \"writer_opened\":\n\t\t\tif (!scripted || context.producerStarted || context.writerStarted || state.candidateDigest)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.producerStarted = true;\n\t\t\tcontext.state = { ...state, writerOpen: true, execution: \"running\", settlement: \"open\" };\n\t\t\treturn;\n\t\tcase \"model_request\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.requests.has(event.requestId) ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\tstate.modelRequests >= scripted.maxRequests\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"model_request_limit\");\n\t\t\tcontext.requests.add(event.requestId);\n\t\t\tcontext.state = { ...state, modelRequests: state.modelRequests + 1 };\n\t\t\treturn;\n\t\tcase \"writer_closed\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t(event.completed &&\n\t\t\t\t\t(!context.writerFinished ||\n\t\t\t\t\t\tstate.failure ||\n\t\t\t\t\t\tcontext.writerCommands !== scripted.steps.length ||\n\t\t\t\t\t\tstate.modelRequests - context.requestBaseline < scripted.steps.length + 1))\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.writerFinished = event.completed;\n\t\t\tcontext.state = { ...state, writerOpen: false, settlement: \"settled\" };\n\t\t\treturn;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = event;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"writer-projection.js","sourceRoot":"","sources":["../../../src/core/verified-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AC,MAAM;gBAC/B,CAAC,KAAK,CAAC,SAAS;oBACf,CAAC,CAAC,OAAO,CAAC,cAAc;wBACvB,KAAK,CAAC,OAAO;wBACb,OAAO,CAAC,cAAc,KAAK,QAAQ,CAAC,KAAK,CAAC,MAAM;wBAChD,KAAK,CAAC,aAAa,GAAG,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAE7E,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;YACzC,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,SAAS,CAAC;YACzC,OAAO,CAAC,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;YACvE,OAAO;QACR,SAAS,CAAC;YACT,MAAM,UAAU,GAAU,KAAK,CAAC;YAChC,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;QAChD,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["import type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { bindTaskExecution } from \"./task-execution.ts\";\n\ntype WriterEvent = Extract<RunEvent, { kind: \"writer_opened\" | \"model_request\" | \"writer_closed\" }>;\n\nexport function acceptWriterDispatch(context: WriterReduction, event: Extract<RunEvent, { kind: \"dispatch\" }>): void {\n\tconst { state, contract } = context;\n\tif (\n\t\tevent.claimId !== null ||\n\t\tstate.candidateDigest ||\n\t\t(event.taskId !== undefined && contract.profile !== \"linux-command-dag-v1\")\n\t)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tswitch (contract.profile) {\n\t\tcase \"linux-command-v1\":\n\t\t\tif (context.writerStarted) throw new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-scripted-agent-v1\":\n\t\t\tif (\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.writerCommands >= contract.writer.steps.length ||\n\t\t\t\tstate.modelRequests - context.requestBaseline <= context.writerCommands\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-command-dag-v1\":\n\t\t\tbindTaskExecution(context, event);\n\t\t\treturn;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = contract;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n\tcontext.writerStarted = true;\n\tcontext.writerCommands += 1;\n}\n\n/** Mutates only the private replay accumulator; no work, clocks, or caller data are consulted. */\nexport function reduceWriterEvent(context: WriterReduction, event: WriterEvent): void {\n\tconst state = context.state;\n\tconst scripted = context.contract.profile === \"linux-scripted-agent-v1\" ? context.contract.writer : undefined;\n\tswitch (event.kind) {\n\t\tcase \"writer_opened\":\n\t\t\tif (!scripted || context.producerStarted || context.writerStarted || state.candidateDigest)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.producerStarted = true;\n\t\t\tcontext.state = { ...state, writerOpen: true, execution: \"running\", settlement: \"open\" };\n\t\t\treturn;\n\t\tcase \"model_request\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.requests.has(event.requestId) ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\tstate.modelRequests >= scripted.maxRequests\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"model_request_limit\");\n\t\t\tcontext.requests.add(event.requestId);\n\t\t\tcontext.state = { ...state, modelRequests: state.modelRequests + 1 };\n\t\t\treturn;\n\t\tcase \"writer_closed\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t(event.completed &&\n\t\t\t\t\t(!context.writerFinished ||\n\t\t\t\t\t\tstate.failure ||\n\t\t\t\t\t\tcontext.writerCommands !== scripted.steps.length ||\n\t\t\t\t\t\tstate.modelRequests - context.requestBaseline < scripted.steps.length + 1))\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.writerFinished = event.completed;\n\t\t\tcontext.state = { ...state, writerOpen: false, settlement: \"settled\" };\n\t\t\treturn;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = event;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n}\n"]}