oxe-cc 1.0.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/commands/oxe-ask.md +3 -3
- package/.cursor/commands/oxe-capabilities.md +3 -3
- package/.cursor/commands/oxe-checkpoint.md +3 -3
- package/.cursor/commands/oxe-compact.md +3 -3
- package/.cursor/commands/oxe-dashboard.md +3 -3
- package/.cursor/commands/oxe-debug.md +3 -3
- package/.cursor/commands/oxe-discuss.md +3 -3
- package/.cursor/commands/oxe-execute.md +7 -4
- package/.cursor/commands/oxe-forensics.md +3 -3
- package/.cursor/commands/oxe-help.md +3 -3
- package/.cursor/commands/oxe-loop.md +3 -3
- package/.cursor/commands/oxe-milestone.md +3 -3
- package/.cursor/commands/oxe-next.md +3 -3
- package/.cursor/commands/oxe-obs.md +3 -3
- package/.cursor/commands/oxe-plan-agent.md +3 -3
- package/.cursor/commands/oxe-plan.md +3 -3
- package/.cursor/commands/oxe-project.md +3 -3
- package/.cursor/commands/oxe-quick.md +3 -3
- package/.cursor/commands/oxe-research.md +3 -3
- package/.cursor/commands/oxe-retro.md +3 -3
- package/.cursor/commands/oxe-review-pr.md +3 -3
- package/.cursor/commands/oxe-route.md +3 -3
- package/.cursor/commands/oxe-scan.md +3 -3
- package/.cursor/commands/oxe-security.md +3 -3
- package/.cursor/commands/oxe-session.md +4 -4
- package/.cursor/commands/oxe-ship.md +45 -0
- package/.cursor/commands/oxe-skill.md +3 -3
- package/.cursor/commands/oxe-spec.md +3 -3
- package/.cursor/commands/oxe-ui-review.md +3 -3
- package/.cursor/commands/oxe-ui-spec.md +3 -3
- package/.cursor/commands/oxe-update.md +3 -3
- package/.cursor/commands/oxe-validate-gaps.md +3 -3
- package/.cursor/commands/oxe-verify.md +6 -3
- package/.cursor/commands/oxe-workstream.md +3 -3
- package/.cursor/commands/oxe.md +6 -6
- package/.github/copilot-instructions.md +94 -4
- package/.github/prompts/oxe-ask.prompt.md +3 -3
- package/.github/prompts/oxe-capabilities.prompt.md +3 -3
- package/.github/prompts/oxe-checkpoint.prompt.md +3 -3
- package/.github/prompts/oxe-compact.prompt.md +3 -3
- package/.github/prompts/oxe-dashboard.prompt.md +3 -3
- package/.github/prompts/oxe-debug.prompt.md +3 -3
- package/.github/prompts/oxe-discuss.prompt.md +3 -3
- package/.github/prompts/oxe-execute.prompt.md +7 -4
- package/.github/prompts/oxe-forensics.prompt.md +3 -3
- package/.github/prompts/oxe-help.prompt.md +3 -3
- package/.github/prompts/oxe-loop.prompt.md +3 -3
- package/.github/prompts/oxe-milestone.prompt.md +3 -3
- package/.github/prompts/oxe-next.prompt.md +3 -3
- package/.github/prompts/oxe-obs.prompt.md +3 -3
- package/.github/prompts/oxe-plan-agent.prompt.md +3 -3
- package/.github/prompts/oxe-plan.prompt.md +3 -3
- package/.github/prompts/oxe-project.prompt.md +3 -3
- package/.github/prompts/oxe-quick.prompt.md +3 -3
- package/.github/prompts/oxe-research.prompt.md +3 -3
- package/.github/prompts/oxe-retro.prompt.md +3 -3
- package/.github/prompts/oxe-review-pr.prompt.md +3 -3
- package/.github/prompts/oxe-route.prompt.md +3 -3
- package/.github/prompts/oxe-scan.prompt.md +3 -3
- package/.github/prompts/oxe-security.prompt.md +3 -3
- package/.github/prompts/oxe-session.prompt.md +4 -4
- package/.github/prompts/oxe-ship.prompt.md +45 -0
- package/.github/prompts/oxe-skill.prompt.md +3 -3
- package/.github/prompts/oxe-spec.prompt.md +3 -3
- package/.github/prompts/oxe-ui-review.prompt.md +3 -3
- package/.github/prompts/oxe-ui-spec.prompt.md +3 -3
- package/.github/prompts/oxe-update.prompt.md +3 -3
- package/.github/prompts/oxe-validate-gaps.prompt.md +3 -3
- package/.github/prompts/oxe-verify.prompt.md +6 -3
- package/.github/prompts/oxe-workstream.prompt.md +3 -3
- package/.github/prompts/oxe.prompt.md +5 -5
- package/AGENTS.md +43 -28
- package/CHANGELOG.md +193 -0
- package/README.md +610 -529
- package/bin/banner.txt +1 -1
- package/bin/lib/oxe-agent-install.cjs +69 -69
- package/bin/lib/oxe-azure.cjs +1445 -1445
- package/bin/lib/oxe-context-engine.cjs +867 -867
- package/bin/lib/oxe-dashboard.cjs +76 -28
- package/bin/lib/oxe-operational.cjs +2144 -1340
- package/bin/lib/oxe-project-health.cjs +483 -1
- package/bin/lib/oxe-runtime-semantics.cjs +12 -0
- package/bin/oxe-cc.js +554 -152
- package/commands/oxe/ask.md +7 -3
- package/commands/oxe/capabilities.md +2 -2
- package/commands/oxe/checkpoint.md +3 -3
- package/commands/oxe/compact.md +3 -3
- package/commands/oxe/dashboard.md +2 -2
- package/commands/oxe/debug.md +3 -3
- package/commands/oxe/discuss.md +2 -2
- package/commands/oxe/execute.md +7 -4
- package/commands/oxe/forensics.md +3 -3
- package/commands/oxe/help.md +2 -2
- package/commands/oxe/loop.md +3 -3
- package/commands/oxe/milestone.md +3 -3
- package/commands/oxe/next.md +3 -3
- package/commands/oxe/obs.md +3 -3
- package/commands/oxe/oxe.md +5 -5
- package/commands/oxe/plan-agent.md +2 -2
- package/commands/oxe/plan.md +2 -2
- package/commands/oxe/project.md +3 -3
- package/commands/oxe/quick.md +2 -2
- package/commands/oxe/research.md +3 -3
- package/commands/oxe/retro.md +3 -3
- package/commands/oxe/review-pr.md +3 -3
- package/commands/oxe/route.md +3 -3
- package/commands/oxe/scan.md +3 -3
- package/commands/oxe/security.md +3 -3
- package/commands/oxe/session.md +4 -4
- package/commands/oxe/ship.md +49 -0
- package/commands/oxe/skill.md +2 -2
- package/commands/oxe/spec.md +4 -4
- package/commands/oxe/ui-review.md +3 -3
- package/commands/oxe/ui-spec.md +3 -3
- package/commands/oxe/update.md +2 -2
- package/commands/oxe/validate-gaps.md +3 -3
- package/commands/oxe/verify.md +7 -4
- package/commands/oxe/workstream.md +3 -3
- package/lib/runtime/audit/audit-trail.d.ts +71 -0
- package/lib/runtime/audit/audit-trail.js +154 -0
- package/lib/runtime/audit/index.d.ts +2 -0
- package/lib/runtime/audit/index.js +18 -0
- package/lib/runtime/audit/policy-pack.d.ts +15 -0
- package/lib/runtime/audit/policy-pack.js +57 -0
- package/lib/runtime/context/context-pack-builder.d.ts +15 -0
- package/lib/runtime/context/context-pack-builder.js +42 -0
- package/lib/runtime/context/context-pack-store.d.ts +38 -0
- package/lib/runtime/context/context-pack-store.js +142 -0
- package/lib/runtime/context/context-profiles.d.ts +11 -0
- package/lib/runtime/context/context-profiles.js +51 -0
- package/lib/runtime/context/index.d.ts +2 -0
- package/lib/runtime/context/index.js +2 -0
- package/lib/runtime/decision/decision-engine.d.ts +43 -0
- package/lib/runtime/decision/decision-engine.js +127 -0
- package/lib/runtime/decision/decision-memo.d.ts +53 -0
- package/lib/runtime/decision/decision-memo.js +173 -0
- package/lib/runtime/decision/index.d.ts +2 -0
- package/lib/runtime/decision/index.js +18 -0
- package/lib/runtime/delivery/branch-manager.d.ts +1 -0
- package/lib/runtime/delivery/branch-manager.js +7 -0
- package/lib/runtime/delivery/ci-checks.js +34 -1
- package/lib/runtime/delivery/delivery-records.d.ts +34 -0
- package/lib/runtime/delivery/delivery-records.js +48 -0
- package/lib/runtime/delivery/index.d.ts +2 -0
- package/lib/runtime/delivery/index.js +2 -0
- package/lib/runtime/delivery/promotion-pipeline.d.ts +63 -0
- package/lib/runtime/delivery/promotion-pipeline.js +224 -0
- package/lib/runtime/gate/gate-manager.d.ts +41 -0
- package/lib/runtime/gate/gate-manager.js +108 -1
- package/lib/runtime/index.d.ts +5 -2
- package/lib/runtime/index.js +7 -1
- package/lib/runtime/models/gate-decision.d.ts +4 -1
- package/lib/runtime/models/workspace.d.ts +3 -0
- package/lib/runtime/plugins/capability-adapter.d.ts +12 -0
- package/lib/runtime/plugins/capability-adapter.js +204 -0
- package/lib/runtime/plugins/capability-matrix.d.ts +25 -0
- package/lib/runtime/plugins/capability-matrix.js +90 -0
- package/lib/runtime/plugins/index.d.ts +3 -0
- package/lib/runtime/plugins/index.js +3 -0
- package/lib/runtime/plugins/plugin-abi.d.ts +2 -0
- package/lib/runtime/plugins/plugin-manifest.d.ts +22 -0
- package/lib/runtime/plugins/plugin-manifest.js +95 -0
- package/lib/runtime/plugins/plugin-registry.d.ts +46 -0
- package/lib/runtime/plugins/plugin-registry.js +84 -2
- package/lib/runtime/policy/policy-engine.d.ts +47 -1
- package/lib/runtime/policy/policy-engine.js +172 -9
- package/lib/runtime/projection/projection-engine.d.ts +9 -1
- package/lib/runtime/projection/projection-engine.js +73 -3
- package/lib/runtime/reducers/run-state-reducer.d.ts +26 -0
- package/lib/runtime/reducers/run-state-reducer.js +117 -1
- package/lib/runtime/scheduler/agent-registry.d.ts +44 -0
- package/lib/runtime/scheduler/agent-registry.js +96 -0
- package/lib/runtime/scheduler/agent-roles.d.ts +54 -0
- package/lib/runtime/scheduler/agent-roles.js +62 -0
- package/lib/runtime/scheduler/index.d.ts +3 -0
- package/lib/runtime/scheduler/index.js +3 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.d.ts +45 -1
- package/lib/runtime/scheduler/multi-agent-coordinator.js +234 -35
- package/lib/runtime/scheduler/run-journal.d.ts +18 -0
- package/lib/runtime/scheduler/run-journal.js +54 -0
- package/lib/runtime/scheduler/scheduler.d.ts +29 -1
- package/lib/runtime/scheduler/scheduler.js +387 -14
- package/lib/runtime/verification/index.d.ts +1 -0
- package/lib/runtime/verification/index.js +1 -0
- package/lib/runtime/verification/verification-compiler.d.ts +43 -0
- package/lib/runtime/verification/verification-compiler.js +137 -0
- package/lib/runtime/verification/verification-manifest.d.ts +67 -0
- package/lib/runtime/verification/verification-manifest.js +179 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.d.ts +1 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.js +4 -0
- package/lib/runtime/workspace/strategies/git-worktree.d.ts +1 -0
- package/lib/runtime/workspace/strategies/git-worktree.js +2 -0
- package/lib/runtime/workspace/strategies/inplace.d.ts +1 -0
- package/lib/runtime/workspace/strategies/inplace.js +2 -0
- package/lib/runtime/workspace/workspace-manager.d.ts +2 -1
- package/lib/sdk/README.md +9 -9
- package/lib/sdk/index.cjs +33 -24
- package/lib/sdk/index.d.ts +149 -14
- 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/CHECKPOINTS.template.md +7 -7
- package/oxe/templates/EXECUTION-RUNTIME.template.md +68 -68
- package/oxe/templates/HYPOTHESES.template.md +33 -33
- package/oxe/templates/LESSONS-METRICS.template.json +13 -13
- package/oxe/templates/NOTES.template.md +16 -16
- package/oxe/templates/PLAN-REVIEW.template.md +31 -31
- package/oxe/templates/SESSION.template.md +34 -34
- package/oxe/templates/SKILL.template.md +26 -26
- package/oxe/templates/STATE.md +55 -55
- package/oxe/templates/WORKFLOW_AUTHORING.md +18 -18
- package/oxe/workflows/ask.md +96 -92
- package/oxe/workflows/capabilities.md +25 -25
- package/oxe/workflows/checkpoint.md +14 -10
- package/oxe/workflows/dashboard.md +33 -33
- package/oxe/workflows/debug.md +19 -15
- package/oxe/workflows/discuss.md +12 -12
- package/oxe/workflows/execute.md +44 -2
- package/oxe/workflows/forensics.md +13 -9
- package/oxe/workflows/help.md +352 -304
- package/oxe/workflows/loop.md +17 -13
- package/oxe/workflows/next.md +22 -22
- package/oxe/workflows/obs.md +4 -0
- package/oxe/workflows/oxe.md +64 -31
- package/oxe/workflows/plan-agent.md +9 -9
- package/oxe/workflows/project.md +6 -1
- package/oxe/workflows/quick.md +10 -10
- 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/workflow-runtime-contracts.json +952 -907
- package/oxe/workflows/research.md +32 -28
- package/oxe/workflows/retro.md +4 -0
- package/oxe/workflows/review-pr.md +15 -11
- package/oxe/workflows/route.md +16 -16
- package/oxe/workflows/scan.md +4 -0
- package/oxe/workflows/security.md +14 -10
- package/oxe/workflows/session.md +213 -197
- package/oxe/workflows/ship.md +142 -0
- package/oxe/workflows/skill.md +44 -44
- package/oxe/workflows/spec.md +15 -0
- package/oxe/workflows/ui-review.md +20 -16
- package/oxe/workflows/ui-spec.md +7 -3
- package/oxe/workflows/validate-gaps.md +13 -9
- package/oxe/workflows/verify-audit.md +73 -73
- package/oxe/workflows/verify.md +52 -3
- package/package.json +92 -92
- package/packages/runtime/package.json +17 -17
- package/packages/runtime/src/audit/audit-trail.ts +243 -0
- package/packages/runtime/src/audit/index.ts +2 -0
- package/packages/runtime/src/audit/policy-pack.ts +62 -0
- package/packages/runtime/src/compiler/graph-compiler.ts +245 -245
- package/packages/runtime/src/compiler/index.ts +1 -1
- package/packages/runtime/src/context/context-pack-builder.ts +259 -193
- package/packages/runtime/src/context/context-pack-store.ts +197 -0
- package/packages/runtime/src/context/context-profiles.ts +60 -0
- package/packages/runtime/src/context/index.ts +3 -1
- package/packages/runtime/src/decision/decision-engine.ts +174 -0
- package/packages/runtime/src/decision/decision-memo.ts +211 -0
- package/packages/runtime/src/decision/index.ts +2 -0
- package/packages/runtime/src/delivery/branch-manager.ts +91 -84
- package/packages/runtime/src/delivery/ci-checks.ts +285 -252
- package/packages/runtime/src/delivery/delivery-records.ts +75 -0
- package/packages/runtime/src/delivery/index.ts +5 -3
- package/packages/runtime/src/delivery/pr-manager.ts +112 -112
- package/packages/runtime/src/delivery/promotion-pipeline.ts +334 -0
- package/packages/runtime/src/events/bus.ts +92 -92
- package/packages/runtime/src/events/catalog.ts +29 -29
- 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/gate/gate-manager.ts +289 -137
- package/packages/runtime/src/gate/index.ts +1 -1
- package/packages/runtime/src/index.ts +41 -32
- 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 -21
- 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 -28
- package/packages/runtime/src/plugins/capability-adapter.ts +206 -0
- package/packages/runtime/src/plugins/capability-matrix.ts +126 -0
- package/packages/runtime/src/plugins/index.ts +5 -2
- package/packages/runtime/src/plugins/plugin-abi.ts +97 -95
- package/packages/runtime/src/plugins/plugin-manifest.ts +118 -0
- package/packages/runtime/src/plugins/plugin-registry.ts +232 -119
- package/packages/runtime/src/policy/index.ts +1 -1
- package/packages/runtime/src/policy/policy-engine.ts +330 -113
- package/packages/runtime/src/projection/index.ts +1 -1
- package/packages/runtime/src/projection/projection-engine.ts +328 -249
- 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 +269 -127
- package/packages/runtime/src/scheduler/agent-registry.ts +132 -0
- package/packages/runtime/src/scheduler/agent-roles.ts +109 -0
- package/packages/runtime/src/scheduler/index.ts +4 -1
- package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +521 -231
- package/packages/runtime/src/scheduler/run-journal.ts +62 -0
- package/packages/runtime/src/scheduler/scheduler.ts +722 -281
- package/packages/runtime/src/verification/index.ts +2 -1
- package/packages/runtime/src/verification/verification-compiler.ts +436 -225
- package/packages/runtime/src/verification/verification-manifest.ts +252 -0
- package/packages/runtime/src/workspace/index.ts +5 -5
- package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +126 -121
- package/packages/runtime/src/workspace/strategies/git-worktree.ts +79 -77
- package/packages/runtime/src/workspace/strategies/inplace.ts +38 -35
- package/packages/runtime/src/workspace/workspace-manager.ts +16 -15
- package/packages/runtime/tsconfig.json +17 -17
- package/vscode-extension/.vscodeignore +7 -7
- package/vscode-extension/oxe-agents-1.0.0.vsix +0 -0
- package/vscode-extension/package.json +185 -185
- package/vscode-extension/src/extension.js +310 -310
- 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
|
@@ -2,25 +2,57 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Scheduler = void 0;
|
|
4
4
|
const bus_1 = require("../events/bus");
|
|
5
|
+
const policy_engine_1 = require("../policy/policy-engine");
|
|
6
|
+
const audit_trail_1 = require("../audit/audit-trail");
|
|
7
|
+
const run_journal_1 = require("./run-journal");
|
|
5
8
|
class Scheduler {
|
|
6
9
|
constructor() {
|
|
7
10
|
this.cancelled = false;
|
|
8
11
|
this.paused = false;
|
|
12
|
+
this.journal = null;
|
|
13
|
+
this.ctx = null;
|
|
9
14
|
}
|
|
10
15
|
async run(graph, ctx) {
|
|
11
16
|
this.cancelled = false;
|
|
12
17
|
this.paused = false;
|
|
18
|
+
this.ctx = ctx;
|
|
13
19
|
const status = new Map();
|
|
14
20
|
for (const id of graph.nodes.keys())
|
|
15
21
|
status.set(id, 'pending');
|
|
16
22
|
const completed = [];
|
|
17
23
|
const failed = [];
|
|
18
24
|
const blocked = [];
|
|
25
|
+
this.journal = (0, run_journal_1.createJournal)(ctx.runId);
|
|
26
|
+
(0, run_journal_1.saveJournal)(ctx.projectRoot, ctx.runId, this.journal);
|
|
19
27
|
this.emit(ctx, { type: 'RunStarted', payload: { run_id: ctx.runId } });
|
|
28
|
+
ctx.auditTrail?.record('run_started', ctx.policyActor ?? 'runtime', {
|
|
29
|
+
runId: ctx.runId,
|
|
30
|
+
detail: { session_id: ctx.sessionId ?? null },
|
|
31
|
+
});
|
|
20
32
|
for (const wave of graph.waves) {
|
|
21
33
|
if (this.cancelled)
|
|
22
34
|
break;
|
|
35
|
+
// Respect pause: persist journal and return paused result
|
|
36
|
+
if (this.paused) {
|
|
37
|
+
this.journal.scheduler_state = 'paused';
|
|
38
|
+
this.journal.paused_at = new Date().toISOString();
|
|
39
|
+
this.journal.completed_work_items = completed.slice();
|
|
40
|
+
this.journal.failed_work_items = failed.slice();
|
|
41
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
42
|
+
this.journal.partial_result = { run_id: ctx.runId, completed, failed, blocked };
|
|
43
|
+
(0, run_journal_1.saveJournal)(ctx.projectRoot, ctx.runId, this.journal);
|
|
44
|
+
ctx.auditTrail?.record('run_paused', ctx.policyActor ?? 'runtime', {
|
|
45
|
+
runId: ctx.runId,
|
|
46
|
+
detail: { completed, failed, blocked },
|
|
47
|
+
});
|
|
48
|
+
return { run_id: ctx.runId, status: 'paused', completed, failed, blocked, pending_gates: this.journal.pending_gates.slice() };
|
|
49
|
+
}
|
|
23
50
|
const waveFailed = await this.runWave(wave.node_ids, graph, ctx, status, completed, failed, blocked);
|
|
51
|
+
// Sync journal after each wave
|
|
52
|
+
this.journal.completed_work_items = completed.slice();
|
|
53
|
+
this.journal.failed_work_items = failed.slice();
|
|
54
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
55
|
+
(0, run_journal_1.saveJournal)(ctx.projectRoot, ctx.runId, this.journal);
|
|
24
56
|
if (waveFailed)
|
|
25
57
|
break;
|
|
26
58
|
}
|
|
@@ -40,18 +72,151 @@ class Scheduler {
|
|
|
40
72
|
? 'cancelled'
|
|
41
73
|
: failed.length > 0
|
|
42
74
|
? 'failed'
|
|
43
|
-
:
|
|
75
|
+
: blocked.length > 0
|
|
76
|
+
? 'blocked'
|
|
77
|
+
: 'completed';
|
|
44
78
|
this.emit(ctx, {
|
|
45
79
|
type: 'RunCompleted',
|
|
46
80
|
payload: { run_id: ctx.runId, status: finalStatus },
|
|
47
81
|
});
|
|
48
|
-
|
|
82
|
+
ctx.auditTrail?.record('run_completed', ctx.policyActor ?? 'runtime', {
|
|
83
|
+
runId: ctx.runId,
|
|
84
|
+
detail: {
|
|
85
|
+
status: finalStatus,
|
|
86
|
+
completed: completed.length,
|
|
87
|
+
failed: failed.length,
|
|
88
|
+
blocked: blocked.length,
|
|
89
|
+
pending_gates: this.journal.pending_gates.slice(),
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
this.journal.scheduler_state = this.cancelled ? 'cancelled' : finalStatus === 'blocked' ? 'blocked' : 'completed';
|
|
93
|
+
this.journal.completed_work_items = completed.slice();
|
|
94
|
+
this.journal.failed_work_items = failed.slice();
|
|
95
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
96
|
+
(0, run_journal_1.saveJournal)(ctx.projectRoot, ctx.runId, this.journal);
|
|
97
|
+
return {
|
|
98
|
+
run_id: ctx.runId,
|
|
99
|
+
status: finalStatus,
|
|
100
|
+
completed,
|
|
101
|
+
failed,
|
|
102
|
+
blocked,
|
|
103
|
+
pending_gates: this.journal.pending_gates.slice(),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Recover a previously paused run by loading its journal and re-running
|
|
108
|
+
* only the work items that haven't completed yet.
|
|
109
|
+
*/
|
|
110
|
+
async recover(runId, ctx, graph) {
|
|
111
|
+
const journal = (0, run_journal_1.loadJournal)(ctx.projectRoot, runId);
|
|
112
|
+
if (!journal || journal.scheduler_state !== 'paused')
|
|
113
|
+
return null;
|
|
114
|
+
// Restore state from journal
|
|
115
|
+
this.cancelled = false;
|
|
116
|
+
this.paused = false;
|
|
117
|
+
this.ctx = ctx;
|
|
118
|
+
this.journal = { ...journal, scheduler_state: 'running', paused_at: null };
|
|
119
|
+
const restoredCompleted = new Set(journal.completed_work_items);
|
|
120
|
+
const restoredFailed = new Set(journal.failed_work_items);
|
|
121
|
+
const restoredBlocked = new Set(journal.blocked_work_items);
|
|
122
|
+
const status = new Map();
|
|
123
|
+
for (const id of graph.nodes.keys()) {
|
|
124
|
+
if (restoredCompleted.has(id))
|
|
125
|
+
status.set(id, 'completed');
|
|
126
|
+
else if (restoredFailed.has(id))
|
|
127
|
+
status.set(id, 'failed');
|
|
128
|
+
else if (restoredBlocked.has(id))
|
|
129
|
+
status.set(id, 'blocked');
|
|
130
|
+
else
|
|
131
|
+
status.set(id, 'pending');
|
|
132
|
+
}
|
|
133
|
+
const completed = [...restoredCompleted];
|
|
134
|
+
const failed = [...restoredFailed];
|
|
135
|
+
const blocked = [...restoredBlocked];
|
|
136
|
+
(0, run_journal_1.saveJournal)(ctx.projectRoot, runId, this.journal);
|
|
137
|
+
this.emit(ctx, { type: 'RunStarted', payload: { run_id: ctx.runId, recovered: true } });
|
|
138
|
+
for (const wave of graph.waves) {
|
|
139
|
+
if (this.cancelled)
|
|
140
|
+
break;
|
|
141
|
+
if (this.paused) {
|
|
142
|
+
this.journal.scheduler_state = 'paused';
|
|
143
|
+
this.journal.paused_at = new Date().toISOString();
|
|
144
|
+
this.journal.completed_work_items = completed.slice();
|
|
145
|
+
this.journal.failed_work_items = failed.slice();
|
|
146
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
147
|
+
this.journal.partial_result = { run_id: ctx.runId, completed, failed, blocked };
|
|
148
|
+
(0, run_journal_1.saveJournal)(ctx.projectRoot, ctx.runId, this.journal);
|
|
149
|
+
ctx.auditTrail?.record('run_paused', ctx.policyActor ?? 'runtime', {
|
|
150
|
+
runId: ctx.runId,
|
|
151
|
+
detail: { recovered: true, completed, failed, blocked },
|
|
152
|
+
});
|
|
153
|
+
return { run_id: ctx.runId, status: 'paused', completed, failed, blocked, pending_gates: this.journal.pending_gates.slice() };
|
|
154
|
+
}
|
|
155
|
+
// Skip waves fully completed
|
|
156
|
+
const allDone = wave.node_ids.every((id) => restoredCompleted.has(id) || restoredFailed.has(id) || restoredBlocked.has(id));
|
|
157
|
+
if (allDone)
|
|
158
|
+
continue;
|
|
159
|
+
const waveFailed = await this.runWave(wave.node_ids, graph, ctx, status, completed, failed, blocked);
|
|
160
|
+
this.journal.completed_work_items = completed.slice();
|
|
161
|
+
this.journal.failed_work_items = failed.slice();
|
|
162
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
163
|
+
(0, run_journal_1.saveJournal)(ctx.projectRoot, ctx.runId, this.journal);
|
|
164
|
+
if (waveFailed)
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
for (const [id, s] of status) {
|
|
168
|
+
if (s === 'pending') {
|
|
169
|
+
status.set(id, 'blocked');
|
|
170
|
+
blocked.push(id);
|
|
171
|
+
this.emit(ctx, {
|
|
172
|
+
type: 'WorkItemBlocked',
|
|
173
|
+
work_item_id: id,
|
|
174
|
+
payload: { reason: 'upstream_wave_failed' },
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const finalStatus = this.cancelled
|
|
179
|
+
? 'cancelled'
|
|
180
|
+
: failed.length > 0
|
|
181
|
+
? 'failed'
|
|
182
|
+
: blocked.length > 0
|
|
183
|
+
? 'blocked'
|
|
184
|
+
: 'completed';
|
|
185
|
+
this.emit(ctx, {
|
|
186
|
+
type: 'RunCompleted',
|
|
187
|
+
payload: { run_id: ctx.runId, status: finalStatus, recovered: true },
|
|
188
|
+
});
|
|
189
|
+
ctx.auditTrail?.record('run_recovered', ctx.policyActor ?? 'runtime', {
|
|
190
|
+
runId: ctx.runId,
|
|
191
|
+
detail: {
|
|
192
|
+
status: finalStatus,
|
|
193
|
+
completed: completed.length,
|
|
194
|
+
failed: failed.length,
|
|
195
|
+
blocked: blocked.length,
|
|
196
|
+
pending_gates: this.journal.pending_gates.slice(),
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
this.journal.scheduler_state = this.cancelled ? 'cancelled' : finalStatus === 'blocked' ? 'blocked' : 'completed';
|
|
200
|
+
this.journal.completed_work_items = completed.slice();
|
|
201
|
+
this.journal.failed_work_items = failed.slice();
|
|
202
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
203
|
+
(0, run_journal_1.saveJournal)(ctx.projectRoot, ctx.runId, this.journal);
|
|
204
|
+
(0, run_journal_1.deleteJournal)(ctx.projectRoot, ctx.runId);
|
|
205
|
+
return {
|
|
206
|
+
run_id: ctx.runId,
|
|
207
|
+
status: finalStatus,
|
|
208
|
+
completed,
|
|
209
|
+
failed,
|
|
210
|
+
blocked,
|
|
211
|
+
pending_gates: this.journal.pending_gates.slice(),
|
|
212
|
+
};
|
|
49
213
|
}
|
|
50
214
|
async runWave(nodeIds, graph, ctx, status, completed, failed, blocked) {
|
|
51
|
-
// Partition: eligible vs blocked-by-dep
|
|
52
215
|
const eligible = [];
|
|
53
216
|
const depsNotMet = [];
|
|
54
217
|
for (const id of nodeIds) {
|
|
218
|
+
if (status.get(id) === 'completed')
|
|
219
|
+
continue; // already done in recovery
|
|
55
220
|
const node = graph.nodes.get(id);
|
|
56
221
|
const depsMet = node.depends_on.every((dep) => status.get(dep) === 'completed');
|
|
57
222
|
if (depsMet) {
|
|
@@ -61,7 +226,6 @@ class Scheduler {
|
|
|
61
226
|
depsNotMet.push(id);
|
|
62
227
|
}
|
|
63
228
|
}
|
|
64
|
-
// Nodes whose deps weren't met in this wave → blocked
|
|
65
229
|
for (const id of depsNotMet) {
|
|
66
230
|
status.set(id, 'blocked');
|
|
67
231
|
blocked.push(id);
|
|
@@ -71,25 +235,22 @@ class Scheduler {
|
|
|
71
235
|
payload: { reason: 'dependency_not_met' },
|
|
72
236
|
});
|
|
73
237
|
}
|
|
74
|
-
// Separate read-only (no mutation_scope) from mutation nodes
|
|
75
238
|
const readOnly = eligible.filter((id) => {
|
|
76
239
|
const node = graph.nodes.get(id);
|
|
77
240
|
return node.mutation_scope.length === 0;
|
|
78
241
|
});
|
|
79
242
|
const mutations = eligible.filter((id) => !readOnly.includes(id));
|
|
80
|
-
// Run read-only nodes in parallel
|
|
81
243
|
if (readOnly.length > 0) {
|
|
82
|
-
await Promise.all(readOnly.map((id) => this.runNode(id, graph, ctx, status, completed, failed)));
|
|
244
|
+
await Promise.all(readOnly.map((id) => this.runNode(id, graph, ctx, status, completed, failed, blocked)));
|
|
83
245
|
}
|
|
84
|
-
// Run mutation nodes sequentially to avoid scope conflicts
|
|
85
246
|
for (const id of mutations) {
|
|
86
247
|
if (this.cancelled)
|
|
87
248
|
break;
|
|
88
|
-
await this.runNode(id, graph, ctx, status, completed, failed);
|
|
249
|
+
await this.runNode(id, graph, ctx, status, completed, failed, blocked);
|
|
89
250
|
}
|
|
90
251
|
return failed.length > 0;
|
|
91
252
|
}
|
|
92
|
-
async runNode(nodeId, graph, ctx, status, completed, failed) {
|
|
253
|
+
async runNode(nodeId, graph, ctx, status, completed, failed, blocked) {
|
|
93
254
|
const node = graph.nodes.get(nodeId);
|
|
94
255
|
status.set(nodeId, 'running');
|
|
95
256
|
this.emit(ctx, {
|
|
@@ -100,6 +261,11 @@ class Scheduler {
|
|
|
100
261
|
let lease = null;
|
|
101
262
|
let lastResult = null;
|
|
102
263
|
const maxAttempts = node.policy.max_retries + 1;
|
|
264
|
+
const quotaBlocked = this.consumeQuotaForNode(ctx, node);
|
|
265
|
+
if (quotaBlocked) {
|
|
266
|
+
this.blockNode(nodeId, ctx, status, blocked, 'quota_exceeded', quotaBlocked);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
103
269
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
104
270
|
const attemptId = `${nodeId}-a${attempt}`;
|
|
105
271
|
this.emit(ctx, {
|
|
@@ -109,20 +275,50 @@ class Scheduler {
|
|
|
109
275
|
payload: { attempt_number: attempt },
|
|
110
276
|
});
|
|
111
277
|
try {
|
|
278
|
+
const policyDecision = this.evaluatePolicyForNode(node, ctx);
|
|
279
|
+
if (policyDecision && !policyDecision.allowed) {
|
|
280
|
+
this.emit(ctx, {
|
|
281
|
+
type: 'PolicyEvaluated',
|
|
282
|
+
work_item_id: nodeId,
|
|
283
|
+
attempt_id: attemptId,
|
|
284
|
+
payload: { ...policyDecision },
|
|
285
|
+
});
|
|
286
|
+
ctx.auditTrail?.record('policy_denied', ctx.policyActor ?? 'runtime', {
|
|
287
|
+
runId: ctx.runId,
|
|
288
|
+
workItemId: nodeId,
|
|
289
|
+
detail: { reason: policyDecision.reason, rule_id: policyDecision.rule_id },
|
|
290
|
+
});
|
|
291
|
+
this.blockNode(nodeId, ctx, status, blocked, 'policy_denied', policyDecision.reason);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (policyDecision) {
|
|
295
|
+
this.emit(ctx, {
|
|
296
|
+
type: 'PolicyEvaluated',
|
|
297
|
+
work_item_id: nodeId,
|
|
298
|
+
attempt_id: attemptId,
|
|
299
|
+
payload: { ...policyDecision },
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
if (policyDecision?.gate_required || node.policy.requires_human_approval) {
|
|
303
|
+
const gateId = await this.requestGateForNode(node, ctx, policyDecision);
|
|
304
|
+
this.blockNode(nodeId, ctx, status, blocked, 'pending_gate', gateId);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
112
307
|
const wsReq = {
|
|
113
308
|
work_item_id: nodeId,
|
|
114
309
|
attempt_number: attempt,
|
|
115
310
|
strategy: node.workspace_strategy,
|
|
116
311
|
mutation_scope: node.mutation_scope,
|
|
117
312
|
};
|
|
118
|
-
|
|
313
|
+
const workspaceManager = ctx.pluginRegistry?.workspaceProviderFor(node.workspace_strategy) ?? ctx.workspaceManager;
|
|
314
|
+
lease = await workspaceManager.allocate(wsReq);
|
|
119
315
|
this.emit(ctx, {
|
|
120
316
|
type: 'WorkspaceAllocated',
|
|
121
317
|
work_item_id: nodeId,
|
|
122
318
|
attempt_id: attemptId,
|
|
123
319
|
payload: { workspace_id: lease.workspace_id, strategy: lease.strategy },
|
|
124
320
|
});
|
|
125
|
-
lastResult = await
|
|
321
|
+
lastResult = await this.executeNode(node, lease, ctx, attempt, attemptId);
|
|
126
322
|
if (lastResult.success) {
|
|
127
323
|
this.emit(ctx, {
|
|
128
324
|
type: 'WorkItemCompleted',
|
|
@@ -134,10 +330,14 @@ class Scheduler {
|
|
|
134
330
|
completed.push(nodeId);
|
|
135
331
|
return;
|
|
136
332
|
}
|
|
137
|
-
// Policy failures never retry
|
|
138
333
|
if (lastResult.failure_class === 'policy')
|
|
139
334
|
break;
|
|
140
335
|
if (attempt < maxAttempts) {
|
|
336
|
+
const retryBlocked = this.consumeRetryQuota(ctx);
|
|
337
|
+
if (retryBlocked) {
|
|
338
|
+
this.blockNode(nodeId, ctx, status, blocked, 'quota_exceeded', retryBlocked);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
141
341
|
this.emit(ctx, {
|
|
142
342
|
type: 'RetryScheduled',
|
|
143
343
|
work_item_id: nodeId,
|
|
@@ -167,7 +367,6 @@ class Scheduler {
|
|
|
167
367
|
}
|
|
168
368
|
}
|
|
169
369
|
}
|
|
170
|
-
// All attempts exhausted
|
|
171
370
|
this.emit(ctx, {
|
|
172
371
|
type: 'WorkItemBlocked',
|
|
173
372
|
work_item_id: nodeId,
|
|
@@ -178,12 +377,163 @@ class Scheduler {
|
|
|
178
377
|
}
|
|
179
378
|
pause() {
|
|
180
379
|
this.paused = true;
|
|
380
|
+
if (this.journal && this.ctx) {
|
|
381
|
+
this.journal.scheduler_state = 'paused';
|
|
382
|
+
this.journal.paused_at = new Date().toISOString();
|
|
383
|
+
(0, run_journal_1.saveJournal)(this.ctx.projectRoot, this.ctx.runId, this.journal);
|
|
384
|
+
}
|
|
181
385
|
}
|
|
182
386
|
resume() {
|
|
183
387
|
this.paused = false;
|
|
388
|
+
if (this.journal && this.ctx) {
|
|
389
|
+
this.journal.scheduler_state = 'running';
|
|
390
|
+
this.journal.paused_at = null;
|
|
391
|
+
(0, run_journal_1.saveJournal)(this.ctx.projectRoot, this.ctx.runId, this.journal);
|
|
392
|
+
}
|
|
184
393
|
}
|
|
185
394
|
cancel() {
|
|
186
395
|
this.cancelled = true;
|
|
396
|
+
if (this.journal && this.ctx) {
|
|
397
|
+
this.journal.cancelled = true;
|
|
398
|
+
this.journal.scheduler_state = 'cancelled';
|
|
399
|
+
(0, run_journal_1.saveJournal)(this.ctx.projectRoot, this.ctx.runId, this.journal);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
getJournal() {
|
|
403
|
+
return this.journal;
|
|
404
|
+
}
|
|
405
|
+
static loadJournal(projectRoot, runId) {
|
|
406
|
+
return (0, run_journal_1.loadJournal)(projectRoot, runId);
|
|
407
|
+
}
|
|
408
|
+
async executeNode(node, lease, ctx, attempt, attemptId) {
|
|
409
|
+
const primaryAction = pickPrimaryAction(node, ctx.pluginRegistry);
|
|
410
|
+
const provider = primaryAction ? ctx.pluginRegistry?.toolProviderFor(primaryAction.type) : null;
|
|
411
|
+
if (!provider || !primaryAction) {
|
|
412
|
+
return ctx.executor.execute(node, lease, ctx.runId, attempt);
|
|
413
|
+
}
|
|
414
|
+
ctx.auditTrail?.record('plugin_invoked', ctx.policyActor ?? 'runtime', {
|
|
415
|
+
runId: ctx.runId,
|
|
416
|
+
workItemId: node.id,
|
|
417
|
+
resource: provider.name,
|
|
418
|
+
detail: { action_type: primaryAction.type, attempt_id: attemptId },
|
|
419
|
+
});
|
|
420
|
+
this.emit(ctx, {
|
|
421
|
+
type: 'ToolInvoked',
|
|
422
|
+
work_item_id: node.id,
|
|
423
|
+
attempt_id: attemptId,
|
|
424
|
+
payload: { provider: provider.name, action_type: primaryAction.type },
|
|
425
|
+
});
|
|
426
|
+
const result = await provider.invoke({
|
|
427
|
+
action_type: primaryAction.type,
|
|
428
|
+
work_item_id: node.id,
|
|
429
|
+
run_id: ctx.runId,
|
|
430
|
+
attempt_id: attemptId,
|
|
431
|
+
params: {
|
|
432
|
+
command: primaryAction.command ?? null,
|
|
433
|
+
targets: primaryAction.targets ?? [],
|
|
434
|
+
},
|
|
435
|
+
workspace_root: lease.root_path,
|
|
436
|
+
});
|
|
437
|
+
this.emit(ctx, {
|
|
438
|
+
type: result.success ? 'ToolCompleted' : 'ToolFailed',
|
|
439
|
+
work_item_id: node.id,
|
|
440
|
+
attempt_id: attemptId,
|
|
441
|
+
payload: {
|
|
442
|
+
provider: provider.name,
|
|
443
|
+
action_type: primaryAction.type,
|
|
444
|
+
evidence_paths: result.evidence_paths,
|
|
445
|
+
side_effects_applied: result.side_effects_applied,
|
|
446
|
+
error: result.error ?? null,
|
|
447
|
+
},
|
|
448
|
+
});
|
|
449
|
+
return {
|
|
450
|
+
success: result.success,
|
|
451
|
+
failure_class: result.success ? null : provider.kind === 'external_operation' ? 'policy' : 'env',
|
|
452
|
+
evidence: result.evidence_paths,
|
|
453
|
+
output: result.output,
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
evaluatePolicyForNode(node, ctx) {
|
|
457
|
+
if (!ctx.policyEngine)
|
|
458
|
+
return null;
|
|
459
|
+
const primaryAction = pickPrimaryAction(node, ctx.pluginRegistry);
|
|
460
|
+
const decisionContext = {
|
|
461
|
+
tool: primaryAction?.type ?? 'custom',
|
|
462
|
+
kind: node.workspace_strategy,
|
|
463
|
+
mutation_scope: node.mutation_scope,
|
|
464
|
+
affected_paths: node.mutation_scope,
|
|
465
|
+
side_effect_class: inferSideEffectClass(node),
|
|
466
|
+
mutation_count: node.mutation_scope.length,
|
|
467
|
+
node_policy: {
|
|
468
|
+
max_retries: node.policy.max_retries,
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
const evaluated = ctx.policyEngine.evaluate(decisionContext);
|
|
472
|
+
const persisted = {
|
|
473
|
+
...evaluated,
|
|
474
|
+
run_id: ctx.runId,
|
|
475
|
+
work_item_id: node.id,
|
|
476
|
+
action: primaryAction?.type ?? 'custom',
|
|
477
|
+
actor: ctx.policyActor ?? 'runtime',
|
|
478
|
+
override: false,
|
|
479
|
+
rationale: null,
|
|
480
|
+
context: decisionContext,
|
|
481
|
+
};
|
|
482
|
+
(0, policy_engine_1.savePolicyDecision)(ctx.projectRoot, persisted);
|
|
483
|
+
return persisted;
|
|
484
|
+
}
|
|
485
|
+
async requestGateForNode(node, ctx, decision) {
|
|
486
|
+
if (!ctx.gateManager)
|
|
487
|
+
return 'gate-missing-manager';
|
|
488
|
+
const scope = inferGateScope(node);
|
|
489
|
+
const primaryAction = pickPrimaryAction(node, ctx.pluginRegistry);
|
|
490
|
+
const gate = await ctx.gateManager.request(scope, {
|
|
491
|
+
run_id: ctx.runId,
|
|
492
|
+
work_item_id: node.id,
|
|
493
|
+
action: primaryAction?.type ?? 'custom',
|
|
494
|
+
description: `Gate required before executing ${node.id}`,
|
|
495
|
+
evidence_refs: [],
|
|
496
|
+
risks: [decision?.reason ?? 'human approval required'],
|
|
497
|
+
rationale: decision?.reason ?? 'node policy requires approval',
|
|
498
|
+
policy_decision_id: decision?.decision_id ?? null,
|
|
499
|
+
});
|
|
500
|
+
if (this.journal && !this.journal.pending_gates.includes(gate.gate_id)) {
|
|
501
|
+
this.journal.pending_gates.push(gate.gate_id);
|
|
502
|
+
}
|
|
503
|
+
ctx.auditTrail?.record('gate_requested', ctx.policyActor ?? 'runtime', {
|
|
504
|
+
runId: ctx.runId,
|
|
505
|
+
workItemId: node.id,
|
|
506
|
+
detail: { gate_id: gate.gate_id, scope: gate.scope, action: gate.action },
|
|
507
|
+
});
|
|
508
|
+
return gate.gate_id;
|
|
509
|
+
}
|
|
510
|
+
blockNode(nodeId, ctx, status, blocked, reason, detail = null) {
|
|
511
|
+
this.emit(ctx, {
|
|
512
|
+
type: 'WorkItemBlocked',
|
|
513
|
+
work_item_id: nodeId,
|
|
514
|
+
payload: { reason, detail },
|
|
515
|
+
});
|
|
516
|
+
status.set(nodeId, 'blocked');
|
|
517
|
+
if (!blocked.includes(nodeId))
|
|
518
|
+
blocked.push(nodeId);
|
|
519
|
+
}
|
|
520
|
+
consumeQuotaForNode(ctx, node) {
|
|
521
|
+
if (!ctx.quota)
|
|
522
|
+
return null;
|
|
523
|
+
let quota = (0, audit_trail_1.consumeQuota)(ctx.quota, 'work_items', 1);
|
|
524
|
+
if (node.mutation_scope.length > 0) {
|
|
525
|
+
quota = (0, audit_trail_1.consumeQuota)(quota, 'mutations', 1);
|
|
526
|
+
}
|
|
527
|
+
const violation = (0, audit_trail_1.checkQuota)(quota);
|
|
528
|
+
ctx.quota = quota;
|
|
529
|
+
return violation ? `${violation.quota_type}:${violation.consumed}/${violation.limit}` : null;
|
|
530
|
+
}
|
|
531
|
+
consumeRetryQuota(ctx) {
|
|
532
|
+
if (!ctx.quota)
|
|
533
|
+
return null;
|
|
534
|
+
ctx.quota = (0, audit_trail_1.consumeQuota)(ctx.quota, 'retries', 1);
|
|
535
|
+
const violation = (0, audit_trail_1.checkQuota)(ctx.quota);
|
|
536
|
+
return violation ? `${violation.quota_type}:${violation.consumed}/${violation.limit}` : null;
|
|
187
537
|
}
|
|
188
538
|
emit(ctx, input) {
|
|
189
539
|
const event = (0, bus_1.appendEvent)(ctx.projectRoot, ctx.sessionId, {
|
|
@@ -194,3 +544,26 @@ class Scheduler {
|
|
|
194
544
|
}
|
|
195
545
|
}
|
|
196
546
|
exports.Scheduler = Scheduler;
|
|
547
|
+
function inferSideEffectClass(node) {
|
|
548
|
+
if (node.mutation_scope.length > 0)
|
|
549
|
+
return 'write_fs';
|
|
550
|
+
if (node.actions.some((action) => action.type === 'run_tests' || action.type === 'run_lint'))
|
|
551
|
+
return 'spawn_process';
|
|
552
|
+
return 'read_fs';
|
|
553
|
+
}
|
|
554
|
+
function pickPrimaryAction(node, pluginRegistry) {
|
|
555
|
+
const candidateActions = node.actions.filter((action) => action.type !== 'collect_evidence');
|
|
556
|
+
const preferredMutation = candidateActions.find((action) => action.type === 'generate_patch')
|
|
557
|
+
|| candidateActions.find((action) => action.type === 'run_tests')
|
|
558
|
+
|| candidateActions[0];
|
|
559
|
+
if (!pluginRegistry)
|
|
560
|
+
return preferredMutation;
|
|
561
|
+
return candidateActions.find((action) => pluginRegistry.toolProviderFor(action.type)) || preferredMutation;
|
|
562
|
+
}
|
|
563
|
+
function inferGateScope(node) {
|
|
564
|
+
if (node.mutation_scope.length > 0)
|
|
565
|
+
return 'critical_mutation';
|
|
566
|
+
if (node.actions.some((action) => action.type === 'collect_evidence'))
|
|
567
|
+
return 'security';
|
|
568
|
+
return 'plan_approval';
|
|
569
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { EvidenceType } from '../models/evidence';
|
|
2
2
|
import type { VerificationStatus } from '../models/verification-result';
|
|
3
|
+
import type { VerificationResult } from '../models/verification-result';
|
|
4
|
+
import type { EvidenceStore } from '../evidence/evidence-store';
|
|
5
|
+
import type { PluginRegistry } from '../plugins/plugin-registry';
|
|
6
|
+
import { type EvidenceCoverageSummary, type ResidualRiskLedger, type VerificationManifest } from './verification-manifest';
|
|
3
7
|
export type CheckType = 'unit' | 'integration' | 'contract' | 'smoke' | 'policy' | 'security' | 'ux_snapshot' | 'performance_baseline' | 'custom';
|
|
4
8
|
export interface AcceptanceCheck {
|
|
5
9
|
id: string;
|
|
@@ -24,6 +28,26 @@ export interface CheckResult {
|
|
|
24
28
|
exit_code: number | null;
|
|
25
29
|
duration_ms: number;
|
|
26
30
|
error: string | null;
|
|
31
|
+
evidence_refs?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface ExecutedVerificationSuite {
|
|
34
|
+
results: CheckResult[];
|
|
35
|
+
verification_results: VerificationResult[];
|
|
36
|
+
evidence_refs: Map<string, string[]>;
|
|
37
|
+
manifest: VerificationManifest;
|
|
38
|
+
risk_ledger: ResidualRiskLedger;
|
|
39
|
+
evidence_coverage: EvidenceCoverageSummary;
|
|
40
|
+
}
|
|
41
|
+
export interface VerifyRunResult {
|
|
42
|
+
status: 'passed' | 'failed' | 'partial';
|
|
43
|
+
suite: AcceptanceCheckSuite;
|
|
44
|
+
executed: ExecutedVerificationSuite | null;
|
|
45
|
+
gaps: string[];
|
|
46
|
+
verification_results: VerificationResult[];
|
|
47
|
+
check_results: CheckResult[];
|
|
48
|
+
manifest: VerificationManifest | null;
|
|
49
|
+
risk_ledger: ResidualRiskLedger | null;
|
|
50
|
+
evidence_coverage: EvidenceCoverageSummary | null;
|
|
27
51
|
}
|
|
28
52
|
interface Criterion {
|
|
29
53
|
id: string;
|
|
@@ -45,6 +69,14 @@ interface ParsedPlanLike {
|
|
|
45
69
|
export declare function compile(spec: ParsedSpecLike, plan: ParsedPlanLike): AcceptanceCheckSuite;
|
|
46
70
|
export declare function runCheck(check: AcceptanceCheck, cwd: string, timeoutMs?: number): Promise<CheckResult>;
|
|
47
71
|
export declare function runSuite(suite: AcceptanceCheckSuite, cwd: string, timeoutMs?: number): Promise<CheckResult[]>;
|
|
72
|
+
export declare function executeSuite(suite: AcceptanceCheckSuite, cwd: string, options: {
|
|
73
|
+
timeoutMs?: number;
|
|
74
|
+
runId: string;
|
|
75
|
+
workItemId: string;
|
|
76
|
+
attemptNumber?: number;
|
|
77
|
+
evidenceStore?: EvidenceStore;
|
|
78
|
+
pluginRegistry?: PluginRegistry;
|
|
79
|
+
}): Promise<ExecutedVerificationSuite>;
|
|
48
80
|
export declare function summarizeSuite(results: CheckResult[]): {
|
|
49
81
|
total: number;
|
|
50
82
|
pass: number;
|
|
@@ -53,4 +85,15 @@ export declare function summarizeSuite(results: CheckResult[]): {
|
|
|
53
85
|
error: number;
|
|
54
86
|
allPassed: boolean;
|
|
55
87
|
};
|
|
88
|
+
export declare function verifyRun(input: {
|
|
89
|
+
projectRoot: string;
|
|
90
|
+
runId: string;
|
|
91
|
+
workItemId: string;
|
|
92
|
+
cwd: string;
|
|
93
|
+
suite: AcceptanceCheckSuite;
|
|
94
|
+
pluginRegistry?: PluginRegistry;
|
|
95
|
+
evidenceStore?: EvidenceStore;
|
|
96
|
+
attemptNumber?: number;
|
|
97
|
+
timeoutMs?: number;
|
|
98
|
+
}): Promise<VerifyRunResult>;
|
|
56
99
|
export {};
|