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.
- package/.github/copilot-instructions.md +177 -177
- package/.github/dependabot.yml +31 -31
- package/.github/workflows/ci.yml +159 -138
- package/.github/workflows/release.yml +107 -106
- package/AGENTS.md +97 -97
- package/CHANGELOG.md +1032 -856
- package/README.md +673 -600
- package/assets/readme-banner.svg +19 -19
- package/bin/banner.txt +13 -13
- package/bin/lib/oxe-agent-install.cjs +650 -650
- package/bin/lib/oxe-artifact-catalog.cjs +376 -376
- package/bin/lib/oxe-azure.cjs +1445 -1445
- package/bin/lib/oxe-budget.cjs +117 -0
- package/bin/lib/oxe-change.cjs +230 -0
- package/bin/lib/oxe-command-registry.cjs +31 -31
- package/bin/lib/oxe-commit-convention.cjs +85 -0
- package/bin/lib/oxe-context-engine.cjs +874 -874
- package/bin/lib/oxe-core-command-handlers.cjs +82 -82
- package/bin/lib/oxe-criterion-coverage.cjs +58 -0
- package/bin/lib/oxe-dashboard.cjs +737 -737
- package/bin/lib/oxe-dossier.cjs +281 -0
- package/bin/lib/oxe-install-resolve.cjs +134 -106
- package/bin/lib/oxe-manifest.cjs +124 -124
- package/bin/lib/oxe-npm-version.cjs +66 -66
- package/bin/lib/oxe-operational.cjs +4484 -2676
- package/bin/lib/oxe-phase-gates.cjs +280 -0
- package/bin/lib/oxe-plan-json.cjs +433 -0
- package/bin/lib/oxe-plugin-cli.cjs +95 -95
- package/bin/lib/oxe-plugins.cjs +432 -432
- package/bin/lib/oxe-process.cjs +56 -56
- package/bin/lib/oxe-program.cjs +205 -0
- package/bin/lib/oxe-project-env.cjs +178 -0
- package/bin/lib/oxe-project-health.cjs +2962 -2846
- package/bin/lib/oxe-rationality.cjs +73 -49
- package/bin/lib/oxe-release.cjs +42 -0
- package/bin/lib/oxe-repo-rules.cjs +108 -0
- package/bin/lib/oxe-runtime-semantics.cjs +514 -514
- package/bin/lib/oxe-scorecard.cjs +164 -0
- package/bin/lib/oxe-security.cjs +289 -289
- package/bin/lib/oxe-spike.cjs +98 -0
- package/bin/lib/oxe-verify-dryrun.cjs +152 -0
- package/bin/lib/oxe-workflows.cjs +145 -145
- package/bin/oxe-cc.js +6281 -5829
- package/docs/INTEGRATION.md +182 -182
- package/docs/QUALITY-GATES.md +46 -46
- package/docs/RELEASE-READINESS.md +87 -86
- package/docs/RUNTIME-SMOKE-MATRIX.md +137 -137
- package/docs/oxespace-1.5/BACKLOG.md +273 -0
- package/docs/oxevoice/BACKLOG.md +244 -0
- package/lib/runtime/compiler/graph-compiler.d.ts +13 -0
- package/lib/runtime/compiler/graph-compiler.js +40 -3
- package/lib/runtime/delivery/promotion-pipeline.js +6 -2
- package/lib/runtime/events/catalog.d.ts +1 -1
- package/lib/runtime/events/catalog.js +11 -0
- package/lib/runtime/executor/adapters/claude-cli.d.ts +63 -0
- package/lib/runtime/executor/adapters/claude-cli.js +250 -0
- package/lib/runtime/executor/adapters/http-openai.d.ts +9 -0
- package/lib/runtime/executor/adapters/http-openai.js +18 -0
- package/lib/runtime/executor/adapters/registry.d.ts +13 -0
- package/lib/runtime/executor/adapters/registry.js +29 -0
- package/lib/runtime/executor/adapters/types.d.ts +21 -0
- package/lib/runtime/executor/adapters/types.js +2 -0
- package/lib/runtime/executor/built-in-tools.d.ts +8 -0
- package/lib/runtime/executor/built-in-tools.js +40 -9
- package/lib/runtime/executor/index.d.ts +12 -2
- package/lib/runtime/executor/index.js +28 -1
- package/lib/runtime/executor/llm-task-executor.d.ts +35 -2
- package/lib/runtime/executor/llm-task-executor.js +97 -21
- package/lib/runtime/executor/node-context.d.ts +83 -0
- package/lib/runtime/executor/node-context.js +116 -0
- package/lib/runtime/executor/node-prompt-builder.d.ts +2 -0
- package/lib/runtime/executor/node-prompt-builder.js +2 -0
- package/lib/runtime/executor/shell-argv.d.ts +30 -0
- package/lib/runtime/executor/shell-argv.js +57 -0
- package/lib/runtime/executor/stream-completion.d.ts +11 -0
- package/lib/runtime/executor/stream-completion.js +10 -1
- package/lib/runtime/index.d.ts +5 -2
- package/lib/runtime/index.js +8 -1
- package/lib/runtime/program/index.d.ts +1 -0
- package/lib/runtime/program/index.js +17 -0
- package/lib/runtime/program/program-model.d.ts +74 -0
- package/lib/runtime/program/program-model.js +195 -0
- package/lib/runtime/projection/projection-engine.d.ts +10 -1
- package/lib/runtime/projection/projection-engine.js +25 -1
- package/lib/runtime/reducers/run-state-reducer.js +5 -0
- package/lib/runtime/scheduler/run-journal.d.ts +19 -1
- package/lib/runtime/scheduler/run-journal.js +40 -1
- package/lib/runtime/scheduler/scheduler.d.ts +30 -0
- package/lib/runtime/scheduler/scheduler.js +195 -19
- package/lib/runtime/verification/contract-exports.d.ts +24 -0
- package/lib/runtime/verification/contract-exports.js +201 -0
- package/lib/runtime/verification/index.d.ts +1 -0
- package/lib/runtime/verification/index.js +1 -0
- package/lib/runtime/verification/test-report-parsers.d.ts +37 -0
- package/lib/runtime/verification/test-report-parsers.js +180 -0
- package/lib/runtime/verification/verification-compiler.d.ts +67 -1
- package/lib/runtime/verification/verification-compiler.js +302 -25
- package/lib/runtime/verification/verification-manifest.d.ts +10 -0
- package/lib/runtime/verification/verification-manifest.js +18 -3
- package/lib/runtime/workspace/strategies/git-worktree.d.ts +9 -0
- package/lib/runtime/workspace/strategies/git-worktree.js +81 -0
- package/lib/sdk/README.md +61 -61
- package/lib/sdk/index.cjs +815 -810
- package/lib/sdk/index.d.ts +982 -982
- package/lib/sdk/index.types.ts +933 -933
- package/oxe/schemas/plan-agents.schema.json +122 -122
- package/oxe/schemas/plan.schema.json +85 -0
- package/oxe/templates/ACTIVE-RUN.template.json +32 -32
- package/oxe/templates/CAPABILITIES.template.md +7 -7
- package/oxe/templates/CAPABILITY.template.md +45 -45
- package/oxe/templates/CHECKPOINT.template.md +37 -37
- package/oxe/templates/CHECKPOINTS.template.md +7 -7
- package/oxe/templates/CODEBASE-DELTA.template.md +33 -33
- package/oxe/templates/CONFIG.md +105 -105
- package/oxe/templates/DISCUSS.template.md +44 -44
- package/oxe/templates/DOCS_BROWNFIELD_LAYOUT.md +55 -55
- package/oxe/templates/EXECUTION-RUNTIME.template.md +68 -68
- package/oxe/templates/FIXTURE-PACK.template.json +23 -23
- package/oxe/templates/FIXTURE-PACK.template.md +11 -11
- package/oxe/templates/GIT_HOOKS_OXE.md +52 -52
- package/oxe/templates/HYPOTHESES.template.md +33 -33
- package/oxe/templates/IMPLEMENTATION-PACK.template.json +42 -42
- package/oxe/templates/IMPLEMENTATION-PACK.template.md +16 -16
- package/oxe/templates/INVESTIGATION.template.md +38 -38
- package/oxe/templates/LESSONS-METRICS.template.json +13 -13
- package/oxe/templates/LESSONS.template.md +43 -43
- package/oxe/templates/MEMORY.template.md +49 -49
- package/oxe/templates/MILESTONES.template.md +17 -17
- package/oxe/templates/NOTES.template.md +16 -16
- package/oxe/templates/OBSERVATIONS.template.md +18 -18
- package/oxe/templates/PLAN-REVIEW.template.md +31 -31
- package/oxe/templates/PLAN.template.md +66 -66
- package/oxe/templates/PLUGINS.md +108 -108
- package/oxe/templates/REFERENCE-ANCHORS.template.md +9 -9
- package/oxe/templates/RESEARCH.template.md +57 -57
- package/oxe/templates/RESUME.template.md +49 -49
- package/oxe/templates/ROADMAP.template.md +44 -44
- package/oxe/templates/SECURITY.template.md +72 -72
- package/oxe/templates/SESSION.template.md +34 -34
- package/oxe/templates/SKILL.template.md +26 -26
- package/oxe/templates/SPEC.template.md +54 -54
- package/oxe/templates/STATE-REFERENCE.md +125 -125
- package/oxe/templates/STATE.md +30 -30
- package/oxe/templates/WORKFLOW_AUTHORING.md +93 -93
- package/oxe/templates/config.template.json +38 -38
- package/oxe/templates/plan-agent-messages-README.template.md +9 -9
- package/oxe/templates/plan-agents.template.json +30 -30
- package/oxe/templates/quick-agents.template.json +24 -24
- package/oxe/workflows/ask.md +96 -96
- package/oxe/workflows/capabilities.md +25 -25
- package/oxe/workflows/checkpoint.md +37 -37
- package/oxe/workflows/compact.md +44 -44
- package/oxe/workflows/dashboard.md +33 -33
- package/oxe/workflows/debug.md +34 -34
- package/oxe/workflows/discuss.md +86 -86
- package/oxe/workflows/execute.md +255 -255
- package/oxe/workflows/forensics.md +48 -48
- package/oxe/workflows/help.md +355 -355
- package/oxe/workflows/loop.md +67 -67
- package/oxe/workflows/milestone.md +95 -95
- package/oxe/workflows/next.md +45 -45
- package/oxe/workflows/obs.md +167 -167
- package/oxe/workflows/oxe.md +150 -149
- package/oxe/workflows/plan-agent.md +143 -143
- package/oxe/workflows/plan.md +525 -523
- package/oxe/workflows/project.md +55 -55
- package/oxe/workflows/quick.md +185 -185
- package/oxe/workflows/references/adaptive-discovery.md +27 -27
- package/oxe/workflows/references/flow-robustness-contract.md +80 -80
- package/oxe/workflows/references/legacy-brownfield.md +136 -136
- package/oxe/workflows/references/plan-agent-chat-protocol.md +99 -99
- package/oxe/workflows/references/plan-json-acceptance-program.md +143 -0
- package/oxe/workflows/references/reasoning-discovery.md +28 -28
- package/oxe/workflows/references/reasoning-execution.md +29 -29
- package/oxe/workflows/references/reasoning-planning.md +32 -32
- package/oxe/workflows/references/reasoning-review.md +29 -29
- package/oxe/workflows/references/reasoning-status.md +24 -24
- package/oxe/workflows/references/robustness-elevation.md +295 -295
- package/oxe/workflows/references/session-path-resolution.md +71 -71
- package/oxe/workflows/research.md +66 -66
- package/oxe/workflows/retro.md +117 -117
- package/oxe/workflows/review-pr.md +53 -53
- package/oxe/workflows/route.md +32 -32
- package/oxe/workflows/security.md +67 -67
- package/oxe/workflows/session.md +213 -213
- package/oxe/workflows/ship.md +142 -142
- package/oxe/workflows/skill.md +44 -44
- package/oxe/workflows/spec.md +569 -566
- package/oxe/workflows/ui-review.md +32 -32
- package/oxe/workflows/ui-spec.md +25 -25
- package/oxe/workflows/update.md +35 -35
- package/oxe/workflows/validate-gaps.md +45 -45
- package/oxe/workflows/verify-audit.md +73 -73
- package/oxe/workflows/verify.md +247 -244
- package/oxe/workflows/workflow-authoring.md +34 -34
- package/oxe/workflows/workstream.md +97 -97
- package/package.json +132 -129
- package/packages/runtime/package.json +18 -18
- package/packages/runtime/src/audit/audit-trail.ts +243 -243
- package/packages/runtime/src/audit/index.ts +2 -2
- package/packages/runtime/src/audit/policy-pack.ts +62 -62
- package/packages/runtime/src/compiler/graph-compiler.ts +336 -285
- package/packages/runtime/src/compiler/index.ts +1 -1
- package/packages/runtime/src/context/context-pack-builder.ts +339 -339
- package/packages/runtime/src/context/context-pack-store.ts +197 -197
- package/packages/runtime/src/context/context-profiles.ts +60 -60
- package/packages/runtime/src/context/index.ts +3 -3
- package/packages/runtime/src/decision/decision-engine.ts +174 -174
- package/packages/runtime/src/decision/decision-memo.ts +211 -211
- package/packages/runtime/src/decision/index.ts +2 -2
- package/packages/runtime/src/delivery/branch-manager.ts +91 -91
- package/packages/runtime/src/delivery/ci-checks.ts +285 -285
- package/packages/runtime/src/delivery/delivery-records.ts +75 -75
- package/packages/runtime/src/delivery/index.ts +5 -5
- package/packages/runtime/src/delivery/pr-manager.ts +112 -112
- package/packages/runtime/src/delivery/promotion-pipeline.ts +342 -334
- package/packages/runtime/src/events/bus.ts +92 -92
- package/packages/runtime/src/events/catalog.ts +45 -34
- package/packages/runtime/src/events/envelope.ts +14 -14
- package/packages/runtime/src/events/index.ts +3 -3
- package/packages/runtime/src/evidence/evidence-store.ts +130 -130
- package/packages/runtime/src/evidence/index.ts +1 -1
- package/packages/runtime/src/executor/adapters/claude-cli.ts +285 -0
- package/packages/runtime/src/executor/adapters/http-openai.ts +16 -0
- package/packages/runtime/src/executor/adapters/registry.ts +33 -0
- package/packages/runtime/src/executor/adapters/types.ts +24 -0
- package/packages/runtime/src/executor/built-in-tools.ts +36 -8
- package/packages/runtime/src/executor/index.ts +12 -2
- package/packages/runtime/src/executor/llm-task-executor.ts +125 -25
- package/packages/runtime/src/executor/node-context.ts +210 -0
- package/packages/runtime/src/executor/node-prompt-builder.ts +5 -0
- package/packages/runtime/src/executor/shell-argv.ts +66 -0
- package/packages/runtime/src/executor/stream-completion.ts +16 -1
- package/packages/runtime/src/gate/gate-manager.ts +289 -289
- package/packages/runtime/src/gate/index.ts +1 -1
- package/packages/runtime/src/index.ts +54 -44
- package/packages/runtime/src/models/attempt.ts +19 -19
- package/packages/runtime/src/models/evidence.ts +21 -21
- package/packages/runtime/src/models/gate-decision.ts +25 -25
- package/packages/runtime/src/models/index.ts +8 -8
- package/packages/runtime/src/models/run.ts +24 -24
- package/packages/runtime/src/models/session.ts +11 -11
- package/packages/runtime/src/models/verification-result.ts +10 -10
- package/packages/runtime/src/models/work-item.ts +25 -25
- package/packages/runtime/src/models/workspace.ts +31 -31
- package/packages/runtime/src/plugins/capability-adapter.ts +313 -313
- package/packages/runtime/src/plugins/capability-matrix.ts +126 -126
- package/packages/runtime/src/plugins/index.ts +5 -5
- package/packages/runtime/src/plugins/plugin-abi.ts +106 -106
- package/packages/runtime/src/plugins/plugin-manifest.ts +118 -118
- package/packages/runtime/src/plugins/plugin-registry.ts +241 -241
- package/packages/runtime/src/policy/index.ts +1 -1
- package/packages/runtime/src/policy/policy-engine.ts +330 -330
- package/packages/runtime/src/program/index.ts +1 -0
- package/packages/runtime/src/program/program-model.ts +233 -0
- package/packages/runtime/src/projection/index.ts +1 -1
- package/packages/runtime/src/projection/projection-engine.ts +361 -328
- package/packages/runtime/src/reducers/debug-reducer.ts +36 -36
- package/packages/runtime/src/reducers/index.ts +2 -2
- package/packages/runtime/src/reducers/run-state-reducer.ts +329 -326
- package/packages/runtime/src/scheduler/agent-registry.ts +132 -132
- package/packages/runtime/src/scheduler/agent-roles.ts +109 -109
- package/packages/runtime/src/scheduler/index.ts +4 -4
- package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +1017 -1017
- package/packages/runtime/src/scheduler/run-journal.ts +105 -62
- package/packages/runtime/src/scheduler/scheduler.ts +1144 -938
- package/packages/runtime/src/verification/contract-exports.ts +203 -0
- package/packages/runtime/src/verification/index.ts +3 -2
- package/packages/runtime/src/verification/test-report-parsers.ts +198 -0
- package/packages/runtime/src/verification/verification-compiler.ts +766 -438
- package/packages/runtime/src/verification/verification-manifest.ts +281 -256
- package/packages/runtime/src/workspace/index.ts +5 -5
- package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +126 -126
- package/packages/runtime/src/workspace/strategies/git-worktree.ts +150 -87
- package/packages/runtime/src/workspace/strategies/inplace.ts +38 -38
- package/packages/runtime/src/workspace/workspace-manager.ts +16 -16
- package/packages/runtime/tsconfig.json +23 -23
- package/vscode-extension/.vscodeignore +9 -9
- package/vscode-extension/package.json +193 -193
- package/vscode-extension/src/extension.js +320 -320
- package/vscode-extension/src/shared/contextLoader.js +137 -137
- package/vscode-extension/src/shared/contractBuilder.js +159 -159
- package/vscode-extension/src/shared/stateReader.js +101 -101
- 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.
|
|
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.
|
|
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
|
|
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
|
-
|
|
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
|
|
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, {
|
|
414
|
-
|
|
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:
|
|
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: {
|
|
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
|
+
}
|
|
@@ -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[];
|