oxe-cc 1.16.0 → 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/.github/copilot-instructions.md +177 -177
  2. package/.github/dependabot.yml +31 -31
  3. package/.github/workflows/ci.yml +159 -138
  4. package/.github/workflows/release.yml +107 -106
  5. package/AGENTS.md +97 -97
  6. package/CHANGELOG.md +1032 -856
  7. package/README.md +673 -600
  8. package/assets/readme-banner.svg +19 -19
  9. package/bin/banner.txt +13 -13
  10. package/bin/lib/oxe-agent-install.cjs +650 -650
  11. package/bin/lib/oxe-artifact-catalog.cjs +376 -376
  12. package/bin/lib/oxe-azure.cjs +1445 -1445
  13. package/bin/lib/oxe-budget.cjs +117 -0
  14. package/bin/lib/oxe-change.cjs +230 -0
  15. package/bin/lib/oxe-command-registry.cjs +31 -31
  16. package/bin/lib/oxe-commit-convention.cjs +85 -0
  17. package/bin/lib/oxe-context-engine.cjs +874 -874
  18. package/bin/lib/oxe-core-command-handlers.cjs +82 -82
  19. package/bin/lib/oxe-criterion-coverage.cjs +58 -0
  20. package/bin/lib/oxe-dashboard.cjs +737 -737
  21. package/bin/lib/oxe-dossier.cjs +281 -0
  22. package/bin/lib/oxe-install-resolve.cjs +134 -106
  23. package/bin/lib/oxe-manifest.cjs +124 -124
  24. package/bin/lib/oxe-npm-version.cjs +66 -66
  25. package/bin/lib/oxe-operational.cjs +4484 -2676
  26. package/bin/lib/oxe-phase-gates.cjs +280 -0
  27. package/bin/lib/oxe-plan-json.cjs +433 -0
  28. package/bin/lib/oxe-plugin-cli.cjs +95 -95
  29. package/bin/lib/oxe-plugins.cjs +432 -432
  30. package/bin/lib/oxe-process.cjs +56 -56
  31. package/bin/lib/oxe-program.cjs +205 -0
  32. package/bin/lib/oxe-project-env.cjs +178 -0
  33. package/bin/lib/oxe-project-health.cjs +2962 -2846
  34. package/bin/lib/oxe-rationality.cjs +73 -49
  35. package/bin/lib/oxe-release.cjs +42 -0
  36. package/bin/lib/oxe-repo-rules.cjs +108 -0
  37. package/bin/lib/oxe-runtime-semantics.cjs +514 -514
  38. package/bin/lib/oxe-scorecard.cjs +164 -0
  39. package/bin/lib/oxe-security.cjs +289 -289
  40. package/bin/lib/oxe-spike.cjs +98 -0
  41. package/bin/lib/oxe-verify-dryrun.cjs +152 -0
  42. package/bin/lib/oxe-workflows.cjs +145 -145
  43. package/bin/oxe-cc.js +6281 -5829
  44. package/docs/INTEGRATION.md +182 -182
  45. package/docs/QUALITY-GATES.md +46 -46
  46. package/docs/RELEASE-READINESS.md +87 -86
  47. package/docs/RUNTIME-SMOKE-MATRIX.md +137 -137
  48. package/docs/oxespace-1.5/BACKLOG.md +273 -0
  49. package/docs/oxevoice/BACKLOG.md +244 -0
  50. package/lib/runtime/compiler/graph-compiler.d.ts +13 -0
  51. package/lib/runtime/compiler/graph-compiler.js +40 -3
  52. package/lib/runtime/delivery/promotion-pipeline.js +6 -2
  53. package/lib/runtime/events/catalog.d.ts +1 -1
  54. package/lib/runtime/events/catalog.js +11 -0
  55. package/lib/runtime/executor/adapters/claude-cli.d.ts +63 -0
  56. package/lib/runtime/executor/adapters/claude-cli.js +250 -0
  57. package/lib/runtime/executor/adapters/http-openai.d.ts +9 -0
  58. package/lib/runtime/executor/adapters/http-openai.js +18 -0
  59. package/lib/runtime/executor/adapters/registry.d.ts +13 -0
  60. package/lib/runtime/executor/adapters/registry.js +29 -0
  61. package/lib/runtime/executor/adapters/types.d.ts +21 -0
  62. package/lib/runtime/executor/adapters/types.js +2 -0
  63. package/lib/runtime/executor/built-in-tools.d.ts +8 -0
  64. package/lib/runtime/executor/built-in-tools.js +40 -9
  65. package/lib/runtime/executor/index.d.ts +12 -2
  66. package/lib/runtime/executor/index.js +28 -1
  67. package/lib/runtime/executor/llm-task-executor.d.ts +35 -2
  68. package/lib/runtime/executor/llm-task-executor.js +97 -21
  69. package/lib/runtime/executor/node-context.d.ts +83 -0
  70. package/lib/runtime/executor/node-context.js +116 -0
  71. package/lib/runtime/executor/node-prompt-builder.d.ts +2 -0
  72. package/lib/runtime/executor/node-prompt-builder.js +2 -0
  73. package/lib/runtime/executor/shell-argv.d.ts +30 -0
  74. package/lib/runtime/executor/shell-argv.js +57 -0
  75. package/lib/runtime/executor/stream-completion.d.ts +11 -0
  76. package/lib/runtime/executor/stream-completion.js +10 -1
  77. package/lib/runtime/index.d.ts +5 -2
  78. package/lib/runtime/index.js +8 -1
  79. package/lib/runtime/program/index.d.ts +1 -0
  80. package/lib/runtime/program/index.js +17 -0
  81. package/lib/runtime/program/program-model.d.ts +74 -0
  82. package/lib/runtime/program/program-model.js +195 -0
  83. package/lib/runtime/projection/projection-engine.d.ts +10 -1
  84. package/lib/runtime/projection/projection-engine.js +25 -1
  85. package/lib/runtime/reducers/run-state-reducer.js +5 -0
  86. package/lib/runtime/scheduler/run-journal.d.ts +19 -1
  87. package/lib/runtime/scheduler/run-journal.js +40 -1
  88. package/lib/runtime/scheduler/scheduler.d.ts +30 -0
  89. package/lib/runtime/scheduler/scheduler.js +195 -19
  90. package/lib/runtime/verification/contract-exports.d.ts +24 -0
  91. package/lib/runtime/verification/contract-exports.js +201 -0
  92. package/lib/runtime/verification/index.d.ts +1 -0
  93. package/lib/runtime/verification/index.js +1 -0
  94. package/lib/runtime/verification/test-report-parsers.d.ts +37 -0
  95. package/lib/runtime/verification/test-report-parsers.js +180 -0
  96. package/lib/runtime/verification/verification-compiler.d.ts +67 -1
  97. package/lib/runtime/verification/verification-compiler.js +302 -25
  98. package/lib/runtime/verification/verification-manifest.d.ts +10 -0
  99. package/lib/runtime/verification/verification-manifest.js +18 -3
  100. package/lib/runtime/workspace/strategies/git-worktree.d.ts +9 -0
  101. package/lib/runtime/workspace/strategies/git-worktree.js +81 -0
  102. package/lib/sdk/README.md +61 -61
  103. package/lib/sdk/index.cjs +815 -810
  104. package/lib/sdk/index.d.ts +982 -982
  105. package/lib/sdk/index.types.ts +933 -933
  106. package/oxe/schemas/plan-agents.schema.json +122 -122
  107. package/oxe/schemas/plan.schema.json +85 -0
  108. package/oxe/templates/ACTIVE-RUN.template.json +32 -32
  109. package/oxe/templates/CAPABILITIES.template.md +7 -7
  110. package/oxe/templates/CAPABILITY.template.md +45 -45
  111. package/oxe/templates/CHECKPOINT.template.md +37 -37
  112. package/oxe/templates/CHECKPOINTS.template.md +7 -7
  113. package/oxe/templates/CODEBASE-DELTA.template.md +33 -33
  114. package/oxe/templates/CONFIG.md +105 -105
  115. package/oxe/templates/DISCUSS.template.md +44 -44
  116. package/oxe/templates/DOCS_BROWNFIELD_LAYOUT.md +55 -55
  117. package/oxe/templates/EXECUTION-RUNTIME.template.md +68 -68
  118. package/oxe/templates/FIXTURE-PACK.template.json +23 -23
  119. package/oxe/templates/FIXTURE-PACK.template.md +11 -11
  120. package/oxe/templates/GIT_HOOKS_OXE.md +52 -52
  121. package/oxe/templates/HYPOTHESES.template.md +33 -33
  122. package/oxe/templates/IMPLEMENTATION-PACK.template.json +42 -42
  123. package/oxe/templates/IMPLEMENTATION-PACK.template.md +16 -16
  124. package/oxe/templates/INVESTIGATION.template.md +38 -38
  125. package/oxe/templates/LESSONS-METRICS.template.json +13 -13
  126. package/oxe/templates/LESSONS.template.md +43 -43
  127. package/oxe/templates/MEMORY.template.md +49 -49
  128. package/oxe/templates/MILESTONES.template.md +17 -17
  129. package/oxe/templates/NOTES.template.md +16 -16
  130. package/oxe/templates/OBSERVATIONS.template.md +18 -18
  131. package/oxe/templates/PLAN-REVIEW.template.md +31 -31
  132. package/oxe/templates/PLAN.template.md +66 -66
  133. package/oxe/templates/PLUGINS.md +108 -108
  134. package/oxe/templates/REFERENCE-ANCHORS.template.md +9 -9
  135. package/oxe/templates/RESEARCH.template.md +57 -57
  136. package/oxe/templates/RESUME.template.md +49 -49
  137. package/oxe/templates/ROADMAP.template.md +44 -44
  138. package/oxe/templates/SECURITY.template.md +72 -72
  139. package/oxe/templates/SESSION.template.md +34 -34
  140. package/oxe/templates/SKILL.template.md +26 -26
  141. package/oxe/templates/SPEC.template.md +54 -54
  142. package/oxe/templates/STATE-REFERENCE.md +125 -125
  143. package/oxe/templates/STATE.md +30 -30
  144. package/oxe/templates/WORKFLOW_AUTHORING.md +93 -93
  145. package/oxe/templates/config.template.json +38 -38
  146. package/oxe/templates/plan-agent-messages-README.template.md +9 -9
  147. package/oxe/templates/plan-agents.template.json +30 -30
  148. package/oxe/templates/quick-agents.template.json +24 -24
  149. package/oxe/workflows/ask.md +96 -96
  150. package/oxe/workflows/capabilities.md +25 -25
  151. package/oxe/workflows/checkpoint.md +37 -37
  152. package/oxe/workflows/compact.md +44 -44
  153. package/oxe/workflows/dashboard.md +33 -33
  154. package/oxe/workflows/debug.md +34 -34
  155. package/oxe/workflows/discuss.md +86 -86
  156. package/oxe/workflows/execute.md +255 -255
  157. package/oxe/workflows/forensics.md +48 -48
  158. package/oxe/workflows/help.md +355 -355
  159. package/oxe/workflows/loop.md +67 -67
  160. package/oxe/workflows/milestone.md +95 -95
  161. package/oxe/workflows/next.md +45 -45
  162. package/oxe/workflows/obs.md +167 -167
  163. package/oxe/workflows/oxe.md +150 -149
  164. package/oxe/workflows/plan-agent.md +143 -143
  165. package/oxe/workflows/plan.md +525 -523
  166. package/oxe/workflows/project.md +55 -55
  167. package/oxe/workflows/quick.md +185 -185
  168. package/oxe/workflows/references/adaptive-discovery.md +27 -27
  169. package/oxe/workflows/references/flow-robustness-contract.md +80 -80
  170. package/oxe/workflows/references/legacy-brownfield.md +136 -136
  171. package/oxe/workflows/references/plan-agent-chat-protocol.md +99 -99
  172. package/oxe/workflows/references/plan-json-acceptance-program.md +143 -0
  173. package/oxe/workflows/references/reasoning-discovery.md +28 -28
  174. package/oxe/workflows/references/reasoning-execution.md +29 -29
  175. package/oxe/workflows/references/reasoning-planning.md +32 -32
  176. package/oxe/workflows/references/reasoning-review.md +29 -29
  177. package/oxe/workflows/references/reasoning-status.md +24 -24
  178. package/oxe/workflows/references/robustness-elevation.md +295 -295
  179. package/oxe/workflows/references/session-path-resolution.md +71 -71
  180. package/oxe/workflows/research.md +66 -66
  181. package/oxe/workflows/retro.md +117 -117
  182. package/oxe/workflows/review-pr.md +53 -53
  183. package/oxe/workflows/route.md +32 -32
  184. package/oxe/workflows/security.md +67 -67
  185. package/oxe/workflows/session.md +213 -213
  186. package/oxe/workflows/ship.md +142 -142
  187. package/oxe/workflows/skill.md +44 -44
  188. package/oxe/workflows/spec.md +569 -566
  189. package/oxe/workflows/ui-review.md +32 -32
  190. package/oxe/workflows/ui-spec.md +25 -25
  191. package/oxe/workflows/update.md +35 -35
  192. package/oxe/workflows/validate-gaps.md +45 -45
  193. package/oxe/workflows/verify-audit.md +73 -73
  194. package/oxe/workflows/verify.md +247 -244
  195. package/oxe/workflows/workflow-authoring.md +34 -34
  196. package/oxe/workflows/workstream.md +97 -97
  197. package/package.json +132 -129
  198. package/packages/runtime/package.json +18 -18
  199. package/packages/runtime/src/audit/audit-trail.ts +243 -243
  200. package/packages/runtime/src/audit/index.ts +2 -2
  201. package/packages/runtime/src/audit/policy-pack.ts +62 -62
  202. package/packages/runtime/src/compiler/graph-compiler.ts +336 -285
  203. package/packages/runtime/src/compiler/index.ts +1 -1
  204. package/packages/runtime/src/context/context-pack-builder.ts +339 -339
  205. package/packages/runtime/src/context/context-pack-store.ts +197 -197
  206. package/packages/runtime/src/context/context-profiles.ts +60 -60
  207. package/packages/runtime/src/context/index.ts +3 -3
  208. package/packages/runtime/src/decision/decision-engine.ts +174 -174
  209. package/packages/runtime/src/decision/decision-memo.ts +211 -211
  210. package/packages/runtime/src/decision/index.ts +2 -2
  211. package/packages/runtime/src/delivery/branch-manager.ts +91 -91
  212. package/packages/runtime/src/delivery/ci-checks.ts +285 -285
  213. package/packages/runtime/src/delivery/delivery-records.ts +75 -75
  214. package/packages/runtime/src/delivery/index.ts +5 -5
  215. package/packages/runtime/src/delivery/pr-manager.ts +112 -112
  216. package/packages/runtime/src/delivery/promotion-pipeline.ts +342 -334
  217. package/packages/runtime/src/events/bus.ts +92 -92
  218. package/packages/runtime/src/events/catalog.ts +45 -34
  219. package/packages/runtime/src/events/envelope.ts +14 -14
  220. package/packages/runtime/src/events/index.ts +3 -3
  221. package/packages/runtime/src/evidence/evidence-store.ts +130 -130
  222. package/packages/runtime/src/evidence/index.ts +1 -1
  223. package/packages/runtime/src/executor/adapters/claude-cli.ts +285 -0
  224. package/packages/runtime/src/executor/adapters/http-openai.ts +16 -0
  225. package/packages/runtime/src/executor/adapters/registry.ts +33 -0
  226. package/packages/runtime/src/executor/adapters/types.ts +24 -0
  227. package/packages/runtime/src/executor/built-in-tools.ts +36 -8
  228. package/packages/runtime/src/executor/index.ts +12 -2
  229. package/packages/runtime/src/executor/llm-task-executor.ts +125 -25
  230. package/packages/runtime/src/executor/node-context.ts +210 -0
  231. package/packages/runtime/src/executor/node-prompt-builder.ts +5 -0
  232. package/packages/runtime/src/executor/shell-argv.ts +66 -0
  233. package/packages/runtime/src/executor/stream-completion.ts +16 -1
  234. package/packages/runtime/src/gate/gate-manager.ts +289 -289
  235. package/packages/runtime/src/gate/index.ts +1 -1
  236. package/packages/runtime/src/index.ts +54 -44
  237. package/packages/runtime/src/models/attempt.ts +19 -19
  238. package/packages/runtime/src/models/evidence.ts +21 -21
  239. package/packages/runtime/src/models/gate-decision.ts +25 -25
  240. package/packages/runtime/src/models/index.ts +8 -8
  241. package/packages/runtime/src/models/run.ts +24 -24
  242. package/packages/runtime/src/models/session.ts +11 -11
  243. package/packages/runtime/src/models/verification-result.ts +10 -10
  244. package/packages/runtime/src/models/work-item.ts +25 -25
  245. package/packages/runtime/src/models/workspace.ts +31 -31
  246. package/packages/runtime/src/plugins/capability-adapter.ts +313 -313
  247. package/packages/runtime/src/plugins/capability-matrix.ts +126 -126
  248. package/packages/runtime/src/plugins/index.ts +5 -5
  249. package/packages/runtime/src/plugins/plugin-abi.ts +106 -106
  250. package/packages/runtime/src/plugins/plugin-manifest.ts +118 -118
  251. package/packages/runtime/src/plugins/plugin-registry.ts +241 -241
  252. package/packages/runtime/src/policy/index.ts +1 -1
  253. package/packages/runtime/src/policy/policy-engine.ts +330 -330
  254. package/packages/runtime/src/program/index.ts +1 -0
  255. package/packages/runtime/src/program/program-model.ts +233 -0
  256. package/packages/runtime/src/projection/index.ts +1 -1
  257. package/packages/runtime/src/projection/projection-engine.ts +361 -328
  258. package/packages/runtime/src/reducers/debug-reducer.ts +36 -36
  259. package/packages/runtime/src/reducers/index.ts +2 -2
  260. package/packages/runtime/src/reducers/run-state-reducer.ts +329 -326
  261. package/packages/runtime/src/scheduler/agent-registry.ts +132 -132
  262. package/packages/runtime/src/scheduler/agent-roles.ts +109 -109
  263. package/packages/runtime/src/scheduler/index.ts +4 -4
  264. package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +1017 -1017
  265. package/packages/runtime/src/scheduler/run-journal.ts +105 -62
  266. package/packages/runtime/src/scheduler/scheduler.ts +1144 -938
  267. package/packages/runtime/src/verification/contract-exports.ts +203 -0
  268. package/packages/runtime/src/verification/index.ts +3 -2
  269. package/packages/runtime/src/verification/test-report-parsers.ts +198 -0
  270. package/packages/runtime/src/verification/verification-compiler.ts +766 -438
  271. package/packages/runtime/src/verification/verification-manifest.ts +281 -256
  272. package/packages/runtime/src/workspace/index.ts +5 -5
  273. package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +126 -126
  274. package/packages/runtime/src/workspace/strategies/git-worktree.ts +150 -87
  275. package/packages/runtime/src/workspace/strategies/inplace.ts +38 -38
  276. package/packages/runtime/src/workspace/workspace-manager.ts +16 -16
  277. package/packages/runtime/tsconfig.json +23 -23
  278. package/vscode-extension/.vscodeignore +9 -9
  279. package/vscode-extension/package.json +193 -193
  280. package/vscode-extension/src/extension.js +320 -320
  281. package/vscode-extension/src/shared/contextLoader.js +137 -137
  282. package/vscode-extension/src/shared/contractBuilder.js +159 -159
  283. package/vscode-extension/src/shared/stateReader.js +101 -101
  284. package/docs/oxe-artifact-map.html +0 -1172
@@ -4,6 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Scheduler = void 0;
7
+ exports.tailLines = tailLines;
8
+ exports.describeVerifyFailure = describeVerifyFailure;
9
+ exports.verifyFailureSignature = verifyFailureSignature;
7
10
  const path_1 = __importDefault(require("path"));
8
11
  const fs_1 = __importDefault(require("fs"));
9
12
  const bus_1 = require("../events/bus");
@@ -99,13 +102,11 @@ class Scheduler {
99
102
  break;
100
103
  // Global run timeout
101
104
  if (Date.now() - this.runStartMs > maxRunMs) {
102
- this.emit(ctx, { type: 'RunAborted', payload: { reason: 'global_timeout' } });
103
- return { run_id: ctx.runId, status: 'aborted', completed: [], failed: [], blocked: [], reason: 'global_timeout' };
105
+ return this.abortRun(ctx, 'global_timeout', completed, failed, blocked);
104
106
  }
105
107
  // Stale progress timeout (no task completed in staleMs)
106
108
  if (Date.now() - this.lastProgressMs > staleMs) {
107
- this.emit(ctx, { type: 'RunAborted', payload: { reason: 'no_progress_timeout' } });
108
- return { run_id: ctx.runId, status: 'aborted', completed: [], failed: [], blocked: [], reason: 'no_progress_timeout' };
109
+ return this.abortRun(ctx, 'no_progress_timeout', completed, failed, blocked);
109
110
  }
110
111
  // Respect pause: persist journal and return paused result
111
112
  if (this.paused) {
@@ -173,7 +174,11 @@ class Scheduler {
173
174
  pending_gates: this.journal.pending_gates.slice(),
174
175
  },
175
176
  });
176
- this.journal.scheduler_state = this.cancelled ? 'cancelled' : finalStatus === 'blocked' ? 'blocked' : 'completed';
177
+ this.journal.scheduler_state = this.cancelled
178
+ ? 'cancelled'
179
+ : finalStatus === 'blocked' || finalStatus === 'failed'
180
+ ? finalStatus
181
+ : 'completed';
177
182
  this.journal.completed_work_items = completed.slice();
178
183
  this.journal.failed_work_items = failed.slice();
179
184
  this.journal.blocked_work_items = blocked.slice();
@@ -193,7 +198,9 @@ class Scheduler {
193
198
  */
194
199
  async recover(runId, ctx, graph) {
195
200
  const journal = (0, run_journal_1.loadJournal)(ctx.projectRoot, runId);
196
- if (!journal || journal.scheduler_state !== 'paused')
201
+ // Paused, blocked (gates since approved), aborted (timeout) and failed runs can all be resumed;
202
+ // only completed/cancelled runs have nothing left to do.
203
+ if (!journal || !RECOVERABLE_JOURNAL_STATES.has(journal.scheduler_state))
197
204
  return null;
198
205
  // Restore state from journal
199
206
  this.cancelled = false;
@@ -280,7 +287,11 @@ class Scheduler {
280
287
  pending_gates: this.journal.pending_gates.slice(),
281
288
  },
282
289
  });
283
- this.journal.scheduler_state = this.cancelled ? 'cancelled' : finalStatus === 'blocked' ? 'blocked' : 'completed';
290
+ this.journal.scheduler_state = this.cancelled
291
+ ? 'cancelled'
292
+ : finalStatus === 'blocked' || finalStatus === 'failed'
293
+ ? finalStatus
294
+ : 'completed';
284
295
  this.journal.completed_work_items = completed.slice();
285
296
  this.journal.failed_work_items = failed.slice();
286
297
  this.journal.blocked_work_items = blocked.slice();
@@ -299,6 +310,10 @@ class Scheduler {
299
310
  const node = graph.nodes.get(nodeId);
300
311
  if (node.mutation_scope.length > 0)
301
312
  return false;
313
+ // A node that may write files but declares no scope is not provably safe to run in parallel
314
+ // (an empty scope used to mean "run everything in parallel, in place").
315
+ if (nodeMayMutate(node))
316
+ return false;
302
317
  const primaryAction = pickPrimaryAction(node, ctx.pluginRegistry);
303
318
  if (!primaryAction)
304
319
  return true;
@@ -329,6 +344,19 @@ class Scheduler {
329
344
  payload: { reason: 'dependency_not_met' },
330
345
  });
331
346
  }
347
+ for (const id of eligible) {
348
+ const node = graph.nodes.get(id);
349
+ if (node.mutation_scope.length === 0 && nodeMayMutate(node)) {
350
+ this.emit(ctx, {
351
+ type: 'PolicyWarning',
352
+ work_item_id: id,
353
+ payload: {
354
+ reason: 'empty_mutation_scope',
355
+ detail: 'node may write files but declares no mutation_scope; running serially and without scope checks',
356
+ },
357
+ });
358
+ }
359
+ }
332
360
  const readOnly = eligible.filter((id) => this.isConcurrentSafe(id, graph, ctx));
333
361
  const mutations = eligible.filter((id) => !readOnly.includes(id));
334
362
  if (readOnly.length > 0) {
@@ -350,9 +378,21 @@ class Scheduler {
350
378
  payload: { title: node.title, wave: node.wave },
351
379
  });
352
380
  let lease = null;
381
+ // Dispose through the manager that allocated the lease (plugin provider or default).
382
+ let leaseManager = null;
353
383
  let lastResult = null;
354
384
  let lastError = null;
385
+ // 1.20c: the same verify failure twice (normalized output) = suspect ruler or stuck executor: stop paying retries.
386
+ let lastVerifySignature = null;
387
+ let verifySuspect = false;
355
388
  const maxAttempts = node.policy.max_retries + 1;
389
+ // 1.21.1 (OXB-047): work that arrives by another path never pays an agent and never becomes a human gate.
390
+ // An explicit human gate (PLAN.json `gate`) still comes first: the attempt loop requests it as before.
391
+ const humanGatePending = node.policy.requires_human_approval && !this.hasApprovedGate(node, ctx);
392
+ if (!humanGatePending && (node.policy.verify_only || (node.policy.external_dependency?.length ?? 0) > 0)) {
393
+ await this.runExternalNode(node, ctx, status, completed, failed, blocked);
394
+ return;
395
+ }
356
396
  const quotaBlocked = this.consumeQuotaForNode(ctx, node);
357
397
  if (quotaBlocked) {
358
398
  this.blockNode(nodeId, ctx, status, blocked, 'quota_exceeded', quotaBlocked);
@@ -391,11 +431,24 @@ class Scheduler {
391
431
  payload: { ...policyDecision },
392
432
  });
393
433
  }
394
- if (policyDecision?.gate_required || node.policy.requires_human_approval) {
434
+ if ((policyDecision?.gate_required || node.policy.requires_human_approval) && !this.hasApprovedGate(node, ctx)) {
395
435
  const gateId = await this.requestGateForNode(node, ctx, policyDecision);
396
436
  this.blockNode(nodeId, ctx, status, blocked, 'pending_gate', gateId);
397
437
  return;
398
438
  }
439
+ // OXB-023: the run's turn/cost ceiling is checked before every attempt, never in the middle of one.
440
+ const budgetReason = ctx.budget?.exhausted() ?? null;
441
+ if (budgetReason) {
442
+ this.emit(ctx, {
443
+ type: 'BudgetExhausted',
444
+ work_item_id: nodeId,
445
+ attempt_id: attemptId,
446
+ payload: { reason: budgetReason, attempt_number: attempt },
447
+ });
448
+ this.blockNode(nodeId, ctx, status, blocked, 'budget_exhausted', budgetReason);
449
+ return;
450
+ }
451
+ const turnsLeft = ctx.budget?.remainingTurns() ?? null;
399
452
  const wsReq = {
400
453
  work_item_id: nodeId,
401
454
  attempt_number: attempt,
@@ -403,6 +456,7 @@ class Scheduler {
403
456
  mutation_scope: node.mutation_scope,
404
457
  };
405
458
  const workspaceManager = ctx.pluginRegistry?.workspaceProviderFor(node.workspace_strategy) ?? ctx.workspaceManager;
459
+ leaseManager = workspaceManager;
406
460
  lease = await workspaceManager.allocate(wsReq);
407
461
  this.emit(ctx, {
408
462
  type: 'WorkspaceAllocated',
@@ -410,23 +464,55 @@ class Scheduler {
410
464
  attempt_id: attemptId,
411
465
  payload: { workspace_id: lease.workspace_id, strategy: lease.strategy },
412
466
  });
413
- lastResult = await this.executeNode(node, lease, ctx, attempt, attemptId, { previousError: lastError });
414
- if (lastResult.success) {
467
+ lastResult = await this.executeNode(node, lease, ctx, attempt, attemptId, {
468
+ previousError: lastError,
469
+ ...(turnsLeft != null ? { maxTurns: turnsLeft } : {}),
470
+ });
471
+ // OXB-026: the verify judges the work, not the end of the LLM conversation. An attempt that ran out of turns
472
+ // after writing in its scope is verified before it is classified: green completes the task, red goes to the
473
+ // informed retry. Discarding it unverified paid a whole second attempt for finished work.
474
+ const turnLimitWithWork = !lastResult.success
475
+ && lastResult.completed_by === 'turn_limit_exhausted'
476
+ && Boolean(node.verify?.command)
477
+ && (lastResult.evidence?.length ?? 0) > 0;
478
+ if (lastResult.success || turnLimitWithWork) {
415
479
  const verifyResult = await this.verifyNode(node, lease, ctx, attemptId, attempt);
416
480
  if (verifyResult && verifyResult.status === 'failed') {
481
+ // Informed retry: the next attempt sees the command, the reason and the output — not just "failed".
417
482
  lastResult = {
418
483
  success: false,
419
484
  failure_class: 'verify',
420
485
  evidence: lastResult.evidence,
421
- output: `Verification failed: ${(verifyResult.gaps || []).join('; ') || 'checks did not pass'}`,
486
+ output: describeVerifyFailure(node.verify.command, verifyResult.check, verifyResult.gaps),
422
487
  };
488
+ const signature = verifyFailureSignature(verifyResult.check);
489
+ if (signature && signature === lastVerifySignature) {
490
+ verifySuspect = true;
491
+ this.emit(ctx, {
492
+ type: 'VerifyCommandSuspect',
493
+ work_item_id: nodeId,
494
+ attempt_id: attemptId,
495
+ payload: {
496
+ attempt_number: attempt,
497
+ command: node.verify.command,
498
+ excerpt: tailLines(`${verifyResult.check?.error ?? ''}\n${verifyResult.check?.stderr ?? ''}\n${verifyResult.check?.stdout ?? ''}`, 12),
499
+ reason: 'identical_verify_failure',
500
+ },
501
+ });
502
+ break;
503
+ }
504
+ lastVerifySignature = signature;
423
505
  }
424
506
  else {
425
507
  this.emit(ctx, {
426
508
  type: 'WorkItemCompleted',
427
509
  work_item_id: nodeId,
428
510
  attempt_id: attemptId,
429
- payload: { attempt_number: attempt, evidence: lastResult.evidence },
511
+ payload: {
512
+ attempt_number: attempt,
513
+ evidence: lastResult.evidence,
514
+ ...(turnLimitWithWork ? { completed_by: 'verify_after_turn_limit' } : {}),
515
+ },
430
516
  });
431
517
  status.set(nodeId, 'completed');
432
518
  completed.push(nodeId);
@@ -449,7 +535,7 @@ class Scheduler {
449
535
  this.emit(ctx, {
450
536
  type: 'RetryScheduled',
451
537
  work_item_id: nodeId,
452
- payload: { next_attempt: attempt + 1, reason: lastResult.failure_class, backoff_ms: backoffMs },
538
+ payload: { next_attempt: attempt + 1, reason: lastResult.failure_class, backoff_ms: backoffMs, output_tail: tailLines(lastResult.output || '', 60) },
453
539
  });
454
540
  }
455
541
  }
@@ -475,25 +561,39 @@ class Scheduler {
475
561
  this.emit(ctx, {
476
562
  type: 'RetryScheduled',
477
563
  work_item_id: nodeId,
478
- payload: { next_attempt: attempt + 1, reason: 'env', backoff_ms: backoffMs },
564
+ payload: { next_attempt: attempt + 1, reason: 'env', backoff_ms: backoffMs, output_tail: tailLines(lastResult.output || '', 60) },
479
565
  });
480
566
  }
481
567
  }
482
568
  finally {
483
569
  if (lease) {
484
- await ctx.workspaceManager.dispose(lease.workspace_id).catch((e) => this.emit(ctx, { type: 'WorkspaceDisposeFailed', payload: { workspace_id: lease?.workspace_id, error: String(e) } }));
570
+ await (leaseManager ?? ctx.workspaceManager).dispose(lease.workspace_id).catch((e) => this.emit(ctx, { type: 'WorkspaceDisposeFailed', payload: { workspace_id: lease?.workspace_id, error: String(e) } }));
485
571
  lease = null;
572
+ leaseManager = null;
486
573
  }
487
574
  }
488
575
  }
489
576
  this.emit(ctx, {
490
577
  type: 'WorkItemBlocked',
491
578
  work_item_id: nodeId,
492
- payload: { failure_class: lastResult?.failure_class ?? 'env', max_attempts: maxAttempts },
579
+ payload: { failure_class: verifySuspect ? 'verify_suspect' : lastResult?.failure_class ?? 'env', max_attempts: maxAttempts, output_tail: tailLines(lastResult?.output || '', 60) },
493
580
  });
494
581
  status.set(nodeId, 'failed');
495
582
  failed.push(nodeId);
496
583
  }
584
+ /** Abort keeps the progress made so far: an aborted run is recoverable, not a blank slate. */
585
+ abortRun(ctx, reason, completed, failed, blocked) {
586
+ this.emit(ctx, { type: 'RunAborted', payload: { reason, completed: completed.slice(), failed: failed.slice(), blocked: blocked.slice() } });
587
+ if (this.journal) {
588
+ this.journal.scheduler_state = 'aborted';
589
+ this.journal.completed_work_items = completed.slice();
590
+ this.journal.failed_work_items = failed.slice();
591
+ this.journal.blocked_work_items = blocked.slice();
592
+ this.journal.partial_result = { run_id: ctx.runId, completed, failed, blocked };
593
+ (0, run_journal_1.saveJournal)(ctx.projectRoot, ctx.runId, this.journal);
594
+ }
595
+ return { run_id: ctx.runId, status: 'aborted', completed, failed, blocked, reason };
596
+ }
497
597
  pause() {
498
598
  this.paused = true;
499
599
  if (this.journal && this.ctx) {
@@ -637,7 +737,7 @@ class Scheduler {
637
737
  attempt_id: attemptId,
638
738
  payload: { status: result.status },
639
739
  });
640
- return result;
740
+ return { status: result.status, gaps: result.gaps, check: result.check_results?.[0] };
641
741
  }
642
742
  evaluatePolicyForNode(node, ctx) {
643
743
  if (!ctx.policyEngine)
@@ -668,6 +768,14 @@ class Scheduler {
668
768
  (0, policy_engine_1.savePolicyDecision)(ctx.projectRoot, persisted);
669
769
  return persisted;
670
770
  }
771
+ /** An approval already granted for this node in this run must not be requested again on re-execution. */
772
+ hasApprovedGate(node, ctx) {
773
+ if (!ctx.gateManager)
774
+ return false;
775
+ return ctx.gateManager
776
+ .listResolved()
777
+ .some((gate) => gate.work_item_id === node.id && gate.decision === 'approved' && (gate.run_id == null || gate.run_id === ctx.runId));
778
+ }
671
779
  async requestGateForNode(node, ctx, decision) {
672
780
  if (!ctx.gateManager) {
673
781
  console.warn('[scheduler] ctx.gateManager not configured — gates will not be persisted');
@@ -681,8 +789,8 @@ class Scheduler {
681
789
  action: primaryAction?.type ?? 'custom',
682
790
  description: `Gate required before executing ${node.id}`,
683
791
  evidence_refs: [],
684
- risks: [decision?.reason ?? 'human approval required'],
685
- rationale: decision?.reason ?? 'node policy requires approval',
792
+ risks: [decision?.reason ?? node.policy.gate_reason ?? 'human approval required'],
793
+ rationale: decision?.reason ?? node.policy.gate_reason ?? 'node policy requires approval',
686
794
  policy_decision_id: decision?.decision_id ?? null,
687
795
  });
688
796
  if (this.journal && !this.journal.pending_gates.includes(gate.gate_id)) {
@@ -695,6 +803,39 @@ class Scheduler {
695
803
  });
696
804
  return gate.gate_id;
697
805
  }
806
+ /**
807
+ * A node delivered by another path (`verify_only`) or waiting on external work (`external_dependency`): no agent.
808
+ * verify_only runs only the node's verify — green completes it; red (or no verify) leaves it waiting. A node with an
809
+ * external dependency and no verify_only waits without a gate, so the rest of the run (and the next preflight) goes on.
810
+ */
811
+ async runExternalNode(node, ctx, status, completed, failed, blocked) {
812
+ const deps = node.policy.external_dependency ?? [];
813
+ if (node.policy.verify_only && node.verify?.command) {
814
+ const attemptId = `${node.id}-verify-only`;
815
+ const workspaceManager = ctx.pluginRegistry?.workspaceProviderFor(node.workspace_strategy) ?? ctx.workspaceManager;
816
+ const lease = await workspaceManager.allocate({ work_item_id: node.id, attempt_number: 1, strategy: node.workspace_strategy, mutation_scope: node.mutation_scope });
817
+ try {
818
+ const verdict = await this.verifyNode(node, lease, ctx, attemptId, 1);
819
+ if (verdict && verdict.status !== 'failed') {
820
+ this.emit(ctx, {
821
+ type: 'WorkItemCompleted',
822
+ work_item_id: node.id,
823
+ attempt_id: attemptId,
824
+ payload: { attempt_number: 1, evidence: [], completed_by: 'verify_only', external_dependency: deps },
825
+ });
826
+ status.set(node.id, 'completed');
827
+ completed.push(node.id);
828
+ this.recordProgress();
829
+ return;
830
+ }
831
+ }
832
+ finally {
833
+ await workspaceManager.dispose(lease.workspace_id).catch(() => undefined);
834
+ }
835
+ }
836
+ this.blockNode(node.id, ctx, status, blocked, 'external_dependency', deps.length ? deps.join(', ') : 'verify_only: entrega externa ainda não verificada');
837
+ void failed;
838
+ }
698
839
  blockNode(nodeId, ctx, status, blocked, reason, detail = null) {
699
840
  this.emit(ctx, {
700
841
  type: 'WorkItemBlocked',
@@ -732,6 +873,11 @@ class Scheduler {
732
873
  }
733
874
  }
734
875
  exports.Scheduler = Scheduler;
876
+ const RECOVERABLE_JOURNAL_STATES = new Set(['paused', 'interrupted', 'blocked', 'aborted', 'failed']);
877
+ /** Nodes whose actions may write to the workspace (anything beyond reading and collecting evidence). */
878
+ function nodeMayMutate(node) {
879
+ return node.actions.some((action) => action.type !== 'read_code' && action.type !== 'collect_evidence');
880
+ }
735
881
  function inferSideEffectClass(node) {
736
882
  if (node.mutation_scope.length > 0)
737
883
  return 'write_fs';
@@ -755,3 +901,33 @@ function inferGateScope(node) {
755
901
  return 'security';
756
902
  return 'plan_approval';
757
903
  }
904
+ /** Last `n` non-empty lines of a text. */
905
+ function tailLines(text, n) {
906
+ return String(text || '').split(/\r?\n/).map((l) => l.trimEnd()).filter((l) => l.trim()).slice(-n).join('\n');
907
+ }
908
+ /** What the next attempt needs to know about a failed task verify (1.20c informed retry). */
909
+ function describeVerifyFailure(command, check, gaps) {
910
+ const reason = check?.error || (check?.exit_code != null ? `exit code ${check.exit_code}` : (gaps || []).join('; ') || 'checks did not pass');
911
+ const output = tailLines(`${check?.stdout ?? ''}\n${check?.stderr ?? ''}`, 40);
912
+ return [
913
+ 'Verification failed after your previous attempt.',
914
+ `Command: ${command ?? '(none)'}`,
915
+ `Reason: ${reason}`,
916
+ output ? `Output (last lines):\n${output.slice(-4000)}` : 'Output: (empty)',
917
+ 'Fix the code so this exact command passes. If you are certain the command itself is wrong (not the code), stop and call finish_task explaining why — do not work around it.',
918
+ ].join('\n');
919
+ }
920
+ /** Normalized failure fingerprint: timings, timestamps, hashes and temp paths removed. */
921
+ function verifyFailureSignature(check) {
922
+ if (!check)
923
+ return null;
924
+ const raw = `${check.error ?? ''}\n${check.stderr ?? ''}\n${check.stdout ?? ''}`;
925
+ const normalized = raw
926
+ .replace(/\d{4}-\d{2}-\d{2}T[\d:.]+Z?/g, '<ts>')
927
+ .replace(/\b\d+(\.\d+)?\s?(ms|s)\b/g, '<t>')
928
+ .replace(/\b[0-9a-f]{7,64}\b/gi, '<hash>')
929
+ .replace(/[A-Za-z]:\\[^\s'"]*|\/tmp\/[^\s'"]*/g, '<path>')
930
+ .replace(/\s+/g, ' ')
931
+ .trim();
932
+ return normalized ? normalized.slice(-1200) : null;
933
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Static export surface of JS/TS modules (1.19). A contracted symbol from the IMPLEMENTATION-PACK
3
+ * must be exported by its file, otherwise the next phase consumes an interface that does not exist.
4
+ * Regex/brace scanning only — no parser dependency — so it errs towards finding exports, and files
5
+ * in other languages are reported as unsupported rather than failed.
6
+ */
7
+ export interface ExportedSymbol {
8
+ name: string;
9
+ /** `(a, b)` for functions, `class` for classes, null when unknown. */
10
+ signature: string | null;
11
+ }
12
+ export interface ExpectedExport {
13
+ file: string;
14
+ name: string;
15
+ }
16
+ export interface ExportCheckOutcome {
17
+ missing: ExpectedExport[];
18
+ /** Files whose language is not scanned (warning, never a failure). */
19
+ unsupported: string[];
20
+ }
21
+ export declare function isScannableModule(file: string): boolean;
22
+ export declare function extractExports(source: string): ExportedSymbol[];
23
+ export declare function readModuleExports(absPath: string): ExportedSymbol[] | null;
24
+ export declare function checkExpectedExports(cwd: string, expected: ExpectedExport[]): ExportCheckOutcome;
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isScannableModule = isScannableModule;
7
+ exports.extractExports = extractExports;
8
+ exports.readModuleExports = readModuleExports;
9
+ exports.checkExpectedExports = checkExpectedExports;
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const JS_TS_RE = /\.(c|m)?[jt]sx?$/i;
13
+ function isScannableModule(file) {
14
+ return JS_TS_RE.test(file);
15
+ }
16
+ /** Strip comments and string contents so braces/commas inside them do not confuse the scanner. */
17
+ function stripNoise(source) {
18
+ return source
19
+ .replace(/\/\*[\s\S]*?\*\//g, ' ')
20
+ .replace(/(^|[^:\\])\/\/[^\n]*/g, '$1')
21
+ .replace(/`(?:\\.|[^`\\])*`/g, '``')
22
+ .replace(/"(?:\\.|[^"\\\n])*"/g, '""')
23
+ .replace(/'(?:\\.|[^'\\\n])*'/g, "''");
24
+ }
25
+ function balancedBlock(text, openIndex) {
26
+ let depth = 0;
27
+ for (let i = openIndex; i < text.length; i++) {
28
+ const ch = text[i];
29
+ if (ch === '{' || ch === '(' || ch === '[')
30
+ depth++;
31
+ else if (ch === '}' || ch === ')' || ch === ']') {
32
+ depth--;
33
+ if (depth === 0)
34
+ return text.slice(openIndex + 1, i);
35
+ }
36
+ }
37
+ return null;
38
+ }
39
+ function splitTopLevel(body) {
40
+ const parts = [];
41
+ let depth = 0;
42
+ let current = '';
43
+ for (const ch of body) {
44
+ if (ch === '{' || ch === '(' || ch === '[')
45
+ depth++;
46
+ else if (ch === '}' || ch === ')' || ch === ']')
47
+ depth--;
48
+ if (ch === ',' && depth === 0) {
49
+ parts.push(current);
50
+ current = '';
51
+ }
52
+ else {
53
+ current += ch;
54
+ }
55
+ }
56
+ if (current.trim())
57
+ parts.push(current);
58
+ return parts.map((p) => p.trim()).filter(Boolean);
59
+ }
60
+ function compactParams(params) {
61
+ return `(${params.replace(/\s+/g, ' ').trim()})`;
62
+ }
63
+ /** Signature of a locally declared function/class/arrow named `name`, if declared in `text`. */
64
+ function localSignature(text, name) {
65
+ const esc = name.replace(/[$]/g, '\\$');
66
+ const fn = new RegExp(`(?:^|[^\\w$.])(?:async\\s+)?function\\s*\\*?\\s*${esc}\\s*\\(`).exec(text);
67
+ if (fn) {
68
+ const params = balancedBlock(text, fn.index + fn[0].length - 1);
69
+ return params === null ? null : compactParams(params);
70
+ }
71
+ if (new RegExp(`(?:^|[^\\w$.])class\\s+${esc}\\b`).test(text))
72
+ return 'class';
73
+ const arrow = new RegExp(`(?:^|[^\\w$.])(?:const|let|var)\\s+${esc}\\s*=\\s*(?:async\\s*)?\\(`).exec(text);
74
+ if (arrow) {
75
+ const params = balancedBlock(text, arrow.index + arrow[0].length - 1);
76
+ return params === null ? null : compactParams(params);
77
+ }
78
+ return null;
79
+ }
80
+ function extractExports(source) {
81
+ const text = stripNoise(source);
82
+ const found = new Map();
83
+ const add = (name, signature) => {
84
+ if (!name || !/^[A-Za-z_$][\w$]*$/.test(name))
85
+ return;
86
+ if (!found.has(name) || (found.get(name) === null && signature !== null))
87
+ found.set(name, signature);
88
+ };
89
+ // CommonJS: module.exports = { a, b: x, c() {} } | = function name() | = name
90
+ for (const m of text.matchAll(/module\.exports\s*=\s*/g)) {
91
+ const rest = text.slice(m.index + m[0].length);
92
+ if (rest.startsWith('{')) {
93
+ const body = balancedBlock(rest, 0);
94
+ if (body === null)
95
+ continue;
96
+ for (const part of splitTopLevel(body)) {
97
+ if (part.startsWith('...'))
98
+ continue;
99
+ const method = /^(?:async\s+)?\*?\s*([A-Za-z_$][\w$]*)\s*\(/.exec(part);
100
+ if (method && !part.includes(':')) {
101
+ const params = balancedBlock(part, part.indexOf('('));
102
+ add(method[1], params === null ? null : compactParams(params));
103
+ continue;
104
+ }
105
+ const keyed = /^([A-Za-z_$][\w$]*)\s*(?::\s*([\s\S]*))?$/.exec(part);
106
+ if (!keyed)
107
+ continue;
108
+ const valueIdent = keyed[2] ? /^([A-Za-z_$][\w$]*)\s*$/.exec(keyed[2].trim()) : null;
109
+ const inline = keyed[2] ? /^(?:async\s+)?(?:function\b[^(]*)?\(/.exec(keyed[2].trim()) : null;
110
+ let signature = null;
111
+ if (inline) {
112
+ const value = keyed[2].trim();
113
+ const params = balancedBlock(value, value.indexOf('('));
114
+ signature = params === null ? null : compactParams(params);
115
+ }
116
+ else {
117
+ signature = localSignature(text, valueIdent ? valueIdent[1] : keyed[1]);
118
+ }
119
+ add(keyed[1], signature);
120
+ }
121
+ }
122
+ else {
123
+ const named = /^(?:async\s+)?(?:function\s*\*?\s*([A-Za-z_$][\w$]*)|class\s+([A-Za-z_$][\w$]*)|([A-Za-z_$][\w$]*)\s*;?)/.exec(rest);
124
+ const name = named ? named[1] || named[2] || named[3] : null;
125
+ add('default', name ? localSignature(text, name) : null);
126
+ if (name)
127
+ add(name, localSignature(text, name));
128
+ }
129
+ }
130
+ for (const m of text.matchAll(/(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=\s*([^;\n]*)/g)) {
131
+ const value = m[2].trim();
132
+ const ident = /^([A-Za-z_$][\w$]*)$/.exec(value);
133
+ let signature = ident ? localSignature(text, ident[1]) : null;
134
+ if (!signature && /^(?:async\s+)?(?:function\b[^(]*)?\(/.test(value)) {
135
+ const params = balancedBlock(value, value.indexOf('('));
136
+ signature = params === null ? null : compactParams(params);
137
+ }
138
+ add(m[1], signature);
139
+ }
140
+ // ESM / TS
141
+ for (const m of text.matchAll(/export\s+(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)\s*(?:<[^>]*>)?\s*\(/g)) {
142
+ const params = balancedBlock(text, m.index + m[0].length - 1);
143
+ add(m[1], params === null ? null : compactParams(params));
144
+ }
145
+ for (const m of text.matchAll(/export\s+(?:declare\s+)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/g))
146
+ add(m[1], 'class');
147
+ for (const m of text.matchAll(/export\s+(?:declare\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g))
148
+ add(m[1], localSignature(text, m[1]));
149
+ for (const m of text.matchAll(/export\s+(?:declare\s+)?(?:interface|type|enum)\s+([A-Za-z_$][\w$]*)/g))
150
+ add(m[1], null);
151
+ for (const m of text.matchAll(/export\s+default\s+(?:async\s+)?(?:function\s*\*?\s*([A-Za-z_$][\w$]*)?|class\s+([A-Za-z_$][\w$]*)?)?/g)) {
152
+ add('default', null);
153
+ if (m[1])
154
+ add(m[1], localSignature(text, m[1]));
155
+ if (m[2])
156
+ add(m[2], 'class');
157
+ }
158
+ for (const m of text.matchAll(/export\s*(?:type\s*)?\{([^}]*)\}/g)) {
159
+ for (const part of m[1].split(',')) {
160
+ const spec = part.trim().replace(/^type\s+/, '');
161
+ if (!spec)
162
+ continue;
163
+ const alias = /^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/.exec(spec);
164
+ if (alias)
165
+ add(alias[2] || alias[1], localSignature(text, alias[1]));
166
+ }
167
+ }
168
+ return [...found.entries()].map(([name, signature]) => ({ name, signature }));
169
+ }
170
+ function readModuleExports(absPath) {
171
+ if (!isScannableModule(absPath))
172
+ return null;
173
+ try {
174
+ const stat = fs_1.default.statSync(absPath);
175
+ if (!stat.isFile() || stat.size > 1024 * 1024)
176
+ return null;
177
+ return extractExports(fs_1.default.readFileSync(absPath, 'utf8'));
178
+ }
179
+ catch {
180
+ return null;
181
+ }
182
+ }
183
+ function checkExpectedExports(cwd, expected) {
184
+ const missing = [];
185
+ const unsupported = new Set();
186
+ const cache = new Map();
187
+ for (const entry of expected) {
188
+ if (!isScannableModule(entry.file)) {
189
+ unsupported.add(entry.file);
190
+ continue;
191
+ }
192
+ if (!cache.has(entry.file)) {
193
+ const exports = readModuleExports(path_1.default.resolve(cwd, entry.file));
194
+ cache.set(entry.file, exports ? new Set(exports.map((e) => e.name)) : null);
195
+ }
196
+ const names = cache.get(entry.file);
197
+ if (!names || !names.has(entry.name))
198
+ missing.push(entry);
199
+ }
200
+ return { missing, unsupported: [...unsupported] };
201
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './verification-compiler';
2
2
  export * from './verification-manifest';
3
+ export * from './contract-exports';
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./verification-compiler"), exports);
18
18
  __exportStar(require("./verification-manifest"), exports);
19
+ __exportStar(require("./contract-exports"), exports);
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Parsers that turn raw test-runner output into a structured summary.
3
+ *
4
+ * Exit code 0 is not proof that anything was verified: `node --test a.js missing.js`
5
+ * exits 0 and only prints "Could not find 'missing.js'", and a command that executed
6
+ * zero tests verified nothing. These helpers give the verification compiler the signal
7
+ * it needs to refuse that kind of false green.
8
+ */
9
+ export type TestReportFormat = 'tap' | 'jest' | 'vitest' | 'mocha' | 'pytest' | 'junit';
10
+ export interface TestReportSummary {
11
+ format: TestReportFormat | null;
12
+ /** Number of test cases the runner reported, or null when no report was recognized. */
13
+ tests_executed: number | null;
14
+ passed: number | null;
15
+ failed: number | null;
16
+ /** Test files a runner reported as missing (node --test: "Could not find '<file>'"). */
17
+ missing_files: string[];
18
+ }
19
+ export declare function parseTestReport(output: string): TestReportSummary;
20
+ /**
21
+ * Explicit test-file arguments of a verify command (e.g. `node --test test/a.test.js`).
22
+ * Globs are left to the runner; inline scripts (`-e`) are ignored entirely.
23
+ */
24
+ export declare function extractTestFileArgs(command: string): string[];
25
+ export interface TestResultNames {
26
+ passed: string[];
27
+ failed: string[];
28
+ }
29
+ /**
30
+ * Names of the tests a runner reported as passed / failed (1.20 "executed proof"). Supported outputs: TAP
31
+ * (`node --test`, `ok 1 - name`), vitest `--reporter=verbose` (`✓ file > suite > name 5ms`), jest `--verbose`
32
+ * and mocha (`✓ name`), pytest `-v` (`path::name PASSED`) and JUnit XML `<testcase name=…>`.
33
+ * Default (non-verbose) vitest/jest output lists no passed names: the plan must use a verbose reporter.
34
+ */
35
+ export declare function extractTestResults(output: string): TestResultNames;
36
+ /** Expected proofs (test names, or `file › name`) that do not appear among the passed tests. */
37
+ export declare function missingProofs(expected: string[], output: string): string[];