oxe-cc 0.9.3 → 1.2.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/.cursor/commands/oxe-ask.md +1 -1
- package/.cursor/commands/oxe-capabilities.md +1 -1
- package/.cursor/commands/oxe-checkpoint.md +1 -1
- package/.cursor/commands/oxe-compact.md +1 -1
- package/.cursor/commands/oxe-dashboard.md +1 -1
- package/.cursor/commands/oxe-debug.md +1 -1
- package/.cursor/commands/oxe-discuss.md +1 -1
- package/.cursor/commands/oxe-execute.md +2 -2
- package/.cursor/commands/oxe-forensics.md +1 -1
- package/.cursor/commands/oxe-help.md +1 -1
- package/.cursor/commands/oxe-loop.md +1 -1
- package/.cursor/commands/oxe-milestone.md +1 -1
- package/.cursor/commands/oxe-next.md +1 -1
- package/.cursor/commands/oxe-obs.md +1 -1
- package/.cursor/commands/oxe-plan-agent.md +1 -1
- package/.cursor/commands/oxe-plan.md +1 -1
- package/.cursor/commands/oxe-project.md +1 -1
- package/.cursor/commands/oxe-quick.md +1 -1
- package/.cursor/commands/oxe-research.md +1 -1
- package/.cursor/commands/oxe-retro.md +1 -1
- package/.cursor/commands/oxe-review-pr.md +1 -1
- package/.cursor/commands/oxe-route.md +1 -1
- package/.cursor/commands/oxe-scan.md +1 -1
- package/.cursor/commands/oxe-security.md +1 -1
- package/.cursor/commands/oxe-session.md +2 -2
- package/.cursor/commands/oxe-ship.md +45 -0
- package/.cursor/commands/oxe-skill.md +1 -1
- package/.cursor/commands/oxe-spec.md +1 -1
- package/.cursor/commands/oxe-ui-review.md +1 -1
- package/.cursor/commands/oxe-ui-spec.md +1 -1
- package/.cursor/commands/oxe-update.md +1 -1
- package/.cursor/commands/oxe-validate-gaps.md +1 -1
- package/.cursor/commands/oxe-verify.md +1 -1
- package/.cursor/commands/oxe-workstream.md +1 -1
- package/.cursor/commands/oxe.md +4 -4
- package/.github/copilot-instructions.md +91 -1
- package/.github/prompts/oxe-ask.prompt.md +1 -1
- package/.github/prompts/oxe-capabilities.prompt.md +1 -1
- package/.github/prompts/oxe-checkpoint.prompt.md +1 -1
- package/.github/prompts/oxe-compact.prompt.md +1 -1
- package/.github/prompts/oxe-dashboard.prompt.md +1 -1
- package/.github/prompts/oxe-debug.prompt.md +1 -1
- package/.github/prompts/oxe-discuss.prompt.md +1 -1
- package/.github/prompts/oxe-execute.prompt.md +2 -2
- package/.github/prompts/oxe-forensics.prompt.md +1 -1
- package/.github/prompts/oxe-help.prompt.md +1 -1
- package/.github/prompts/oxe-loop.prompt.md +1 -1
- package/.github/prompts/oxe-milestone.prompt.md +1 -1
- package/.github/prompts/oxe-next.prompt.md +1 -1
- package/.github/prompts/oxe-obs.prompt.md +1 -1
- package/.github/prompts/oxe-plan-agent.prompt.md +1 -1
- package/.github/prompts/oxe-plan.prompt.md +1 -1
- package/.github/prompts/oxe-project.prompt.md +1 -1
- package/.github/prompts/oxe-quick.prompt.md +1 -1
- package/.github/prompts/oxe-research.prompt.md +1 -1
- package/.github/prompts/oxe-retro.prompt.md +1 -1
- package/.github/prompts/oxe-review-pr.prompt.md +1 -1
- package/.github/prompts/oxe-route.prompt.md +1 -1
- package/.github/prompts/oxe-scan.prompt.md +1 -1
- package/.github/prompts/oxe-security.prompt.md +1 -1
- package/.github/prompts/oxe-session.prompt.md +2 -2
- package/.github/prompts/oxe-ship.prompt.md +45 -0
- package/.github/prompts/oxe-skill.prompt.md +1 -1
- package/.github/prompts/oxe-spec.prompt.md +1 -1
- package/.github/prompts/oxe-ui-review.prompt.md +1 -1
- package/.github/prompts/oxe-ui-spec.prompt.md +1 -1
- package/.github/prompts/oxe-update.prompt.md +1 -1
- package/.github/prompts/oxe-validate-gaps.prompt.md +1 -1
- package/.github/prompts/oxe-verify.prompt.md +1 -1
- package/.github/prompts/oxe-workstream.prompt.md +1 -1
- package/.github/prompts/oxe.prompt.md +3 -3
- package/AGENTS.md +43 -28
- package/CHANGELOG.md +158 -0
- package/README.md +72 -50
- package/bin/banner.txt +1 -1
- package/bin/lib/oxe-dashboard.cjs +9 -7
- package/bin/lib/oxe-operational.cjs +569 -4
- package/bin/lib/oxe-project-health.cjs +1 -1
- package/bin/oxe-cc.js +141 -57
- package/commands/oxe/ask.md +5 -1
- package/commands/oxe/checkpoint.md +1 -1
- package/commands/oxe/compact.md +1 -1
- package/commands/oxe/debug.md +1 -1
- package/commands/oxe/execute.md +2 -2
- package/commands/oxe/forensics.md +1 -1
- package/commands/oxe/loop.md +1 -1
- package/commands/oxe/milestone.md +1 -1
- package/commands/oxe/next.md +1 -1
- package/commands/oxe/obs.md +1 -1
- package/commands/oxe/oxe.md +3 -3
- package/commands/oxe/project.md +1 -1
- package/commands/oxe/research.md +1 -1
- package/commands/oxe/retro.md +1 -1
- package/commands/oxe/review-pr.md +1 -1
- package/commands/oxe/route.md +1 -1
- package/commands/oxe/scan.md +1 -1
- package/commands/oxe/security.md +1 -1
- package/commands/oxe/session.md +2 -2
- package/commands/oxe/ship.md +49 -0
- package/commands/oxe/spec.md +2 -2
- package/commands/oxe/ui-review.md +1 -1
- package/commands/oxe/ui-spec.md +1 -1
- package/commands/oxe/validate-gaps.md +1 -1
- package/commands/oxe/verify.md +2 -2
- package/commands/oxe/workstream.md +1 -1
- 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/compiler/graph-compiler.d.ts +83 -0
- package/lib/runtime/compiler/graph-compiler.js +135 -0
- package/lib/runtime/compiler/index.d.ts +1 -0
- package/lib/runtime/compiler/index.js +17 -0
- package/lib/runtime/context/context-pack-builder.d.ts +51 -0
- package/lib/runtime/context/context-pack-builder.js +178 -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 +3 -0
- package/lib/runtime/context/index.js +19 -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 +19 -0
- package/lib/runtime/delivery/branch-manager.js +78 -0
- package/lib/runtime/delivery/ci-checks.d.ts +34 -0
- package/lib/runtime/delivery/ci-checks.js +209 -0
- package/lib/runtime/delivery/index.d.ts +4 -0
- package/lib/runtime/delivery/index.js +20 -0
- package/lib/runtime/delivery/pr-manager.d.ts +30 -0
- package/lib/runtime/delivery/pr-manager.js +82 -0
- package/lib/runtime/delivery/promotion-pipeline.d.ts +39 -0
- package/lib/runtime/delivery/promotion-pipeline.js +127 -0
- package/lib/runtime/events/bus.d.ts +9 -0
- package/lib/runtime/events/bus.js +63 -0
- package/lib/runtime/events/catalog.d.ts +3 -0
- package/lib/runtime/events/catalog.js +30 -0
- package/lib/runtime/events/envelope.d.ts +13 -0
- package/lib/runtime/events/envelope.js +2 -0
- package/lib/runtime/events/index.d.ts +3 -0
- package/lib/runtime/events/index.js +19 -0
- package/lib/runtime/evidence/evidence-store.d.ts +22 -0
- package/lib/runtime/evidence/evidence-store.js +106 -0
- package/lib/runtime/evidence/index.d.ts +1 -0
- package/lib/runtime/evidence/index.js +17 -0
- package/lib/runtime/gate/gate-manager.d.ts +39 -0
- package/lib/runtime/gate/gate-manager.js +104 -0
- package/lib/runtime/gate/index.d.ts +1 -0
- package/lib/runtime/gate/index.js +17 -0
- package/lib/runtime/index.d.ts +19 -0
- package/lib/runtime/index.js +44 -0
- package/lib/runtime/models/attempt.d.ts +12 -0
- package/lib/runtime/models/attempt.js +2 -0
- package/lib/runtime/models/evidence.d.ts +9 -0
- package/lib/runtime/models/evidence.js +2 -0
- package/lib/runtime/models/gate-decision.d.ts +10 -0
- package/lib/runtime/models/gate-decision.js +2 -0
- package/lib/runtime/models/index.d.ts +8 -0
- package/lib/runtime/models/index.js +24 -0
- package/lib/runtime/models/run.d.ts +13 -0
- package/lib/runtime/models/run.js +2 -0
- package/lib/runtime/models/session.d.ts +10 -0
- package/lib/runtime/models/session.js +2 -0
- package/lib/runtime/models/verification-result.d.ts +9 -0
- package/lib/runtime/models/verification-result.js +2 -0
- package/lib/runtime/models/work-item.d.ts +15 -0
- package/lib/runtime/models/work-item.js +2 -0
- package/lib/runtime/models/workspace.d.ts +25 -0
- package/lib/runtime/models/workspace.js +2 -0
- package/lib/runtime/plugins/capability-matrix.d.ts +20 -0
- package/lib/runtime/plugins/capability-matrix.js +59 -0
- package/lib/runtime/plugins/index.d.ts +4 -0
- package/lib/runtime/plugins/index.js +20 -0
- package/lib/runtime/plugins/plugin-abi.d.ts +76 -0
- package/lib/runtime/plugins/plugin-abi.js +2 -0
- package/lib/runtime/plugins/plugin-manifest.d.ts +22 -0
- package/lib/runtime/plugins/plugin-manifest.js +91 -0
- package/lib/runtime/plugins/plugin-registry.d.ts +21 -0
- package/lib/runtime/plugins/plugin-registry.js +119 -0
- package/lib/runtime/policy/index.d.ts +1 -0
- package/lib/runtime/policy/index.js +17 -0
- package/lib/runtime/policy/policy-engine.d.ts +67 -0
- package/lib/runtime/policy/policy-engine.js +171 -0
- package/lib/runtime/projection/index.d.ts +1 -0
- package/lib/runtime/projection/index.js +17 -0
- package/lib/runtime/projection/projection-engine.d.ts +11 -0
- package/lib/runtime/projection/projection-engine.js +218 -0
- package/lib/runtime/reducers/debug-reducer.d.ts +10 -0
- package/lib/runtime/reducers/debug-reducer.js +30 -0
- package/lib/runtime/reducers/index.d.ts +2 -0
- package/lib/runtime/reducers/index.js +18 -0
- package/lib/runtime/reducers/run-state-reducer.d.ts +46 -0
- package/lib/runtime/reducers/run-state-reducer.js +226 -0
- 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 +4 -0
- package/lib/runtime/scheduler/index.js +20 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.d.ts +36 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.js +253 -0
- 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 +49 -0
- package/lib/runtime/scheduler/scheduler.js +324 -0
- package/lib/runtime/verification/index.d.ts +2 -0
- package/lib/runtime/verification/index.js +18 -0
- package/lib/runtime/verification/verification-compiler.d.ts +56 -0
- package/lib/runtime/verification/verification-compiler.js +147 -0
- package/lib/runtime/verification/verification-manifest.d.ts +58 -0
- package/lib/runtime/verification/verification-manifest.js +129 -0
- package/lib/runtime/workspace/index.d.ts +5 -0
- package/lib/runtime/workspace/index.js +24 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.d.ts +22 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.js +109 -0
- package/lib/runtime/workspace/strategies/git-worktree.d.ts +12 -0
- package/lib/runtime/workspace/strategies/git-worktree.js +79 -0
- package/lib/runtime/workspace/strategies/inplace.d.ts +10 -0
- package/lib/runtime/workspace/strategies/inplace.js +37 -0
- package/lib/runtime/workspace/workspace-manager.d.ts +13 -0
- package/lib/runtime/workspace/workspace-manager.js +2 -0
- package/lib/sdk/index.cjs +24 -7
- package/lib/sdk/index.d.ts +17 -7
- package/oxe/workflows/ask.md +4 -0
- package/oxe/workflows/checkpoint.md +14 -10
- package/oxe/workflows/debug.md +19 -15
- package/oxe/workflows/execute.md +30 -2
- package/oxe/workflows/forensics.md +13 -9
- package/oxe/workflows/help.md +97 -49
- package/oxe/workflows/loop.md +17 -13
- package/oxe/workflows/obs.md +4 -0
- package/oxe/workflows/oxe.md +64 -31
- package/oxe/workflows/project.md +6 -1
- package/oxe/workflows/references/workflow-runtime-contracts.json +23 -0
- 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/scan.md +4 -0
- package/oxe/workflows/security.md +14 -10
- package/oxe/workflows/session.md +17 -1
- package/oxe/workflows/ship.md +142 -0
- 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.md +42 -3
- package/package.json +9 -3
- package/packages/runtime/package.json +17 -0
- 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 -0
- package/packages/runtime/src/compiler/index.ts +1 -0
- package/packages/runtime/src/context/context-pack-builder.ts +259 -0
- 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 -0
- 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 +84 -0
- package/packages/runtime/src/delivery/ci-checks.ts +252 -0
- package/packages/runtime/src/delivery/index.ts +4 -0
- package/packages/runtime/src/delivery/pr-manager.ts +112 -0
- package/packages/runtime/src/delivery/promotion-pipeline.ts +180 -0
- package/packages/runtime/src/events/bus.ts +92 -0
- package/packages/runtime/src/events/catalog.ts +29 -0
- package/packages/runtime/src/events/envelope.ts +14 -0
- package/packages/runtime/src/events/index.ts +3 -0
- package/packages/runtime/src/evidence/evidence-store.ts +130 -0
- package/packages/runtime/src/evidence/index.ts +1 -0
- package/packages/runtime/src/gate/gate-manager.ts +137 -0
- package/packages/runtime/src/gate/index.ts +1 -0
- package/packages/runtime/src/index.ts +37 -0
- package/packages/runtime/src/models/attempt.ts +19 -0
- package/packages/runtime/src/models/evidence.ts +21 -0
- package/packages/runtime/src/models/gate-decision.ts +21 -0
- package/packages/runtime/src/models/index.ts +8 -0
- package/packages/runtime/src/models/run.ts +24 -0
- package/packages/runtime/src/models/session.ts +11 -0
- package/packages/runtime/src/models/verification-result.ts +10 -0
- package/packages/runtime/src/models/work-item.ts +25 -0
- package/packages/runtime/src/models/workspace.ts +28 -0
- package/packages/runtime/src/plugins/capability-matrix.ts +83 -0
- package/packages/runtime/src/plugins/index.ts +4 -0
- package/packages/runtime/src/plugins/plugin-abi.ts +95 -0
- package/packages/runtime/src/plugins/plugin-manifest.ts +113 -0
- package/packages/runtime/src/plugins/plugin-registry.ts +124 -0
- package/packages/runtime/src/policy/index.ts +1 -0
- package/packages/runtime/src/policy/policy-engine.ts +244 -0
- package/packages/runtime/src/projection/index.ts +1 -0
- package/packages/runtime/src/projection/projection-engine.ts +249 -0
- package/packages/runtime/src/reducers/debug-reducer.ts +36 -0
- package/packages/runtime/src/reducers/index.ts +2 -0
- package/packages/runtime/src/reducers/run-state-reducer.ts +269 -0
- 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 -0
- package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +333 -0
- package/packages/runtime/src/scheduler/run-journal.ts +62 -0
- package/packages/runtime/src/scheduler/scheduler.ts +441 -0
- package/packages/runtime/src/verification/index.ts +2 -0
- package/packages/runtime/src/verification/verification-compiler.ts +225 -0
- package/packages/runtime/src/verification/verification-manifest.ts +192 -0
- package/packages/runtime/src/workspace/index.ts +5 -0
- package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +121 -0
- package/packages/runtime/src/workspace/strategies/git-worktree.ts +77 -0
- package/packages/runtime/src/workspace/strategies/inplace.ts +35 -0
- package/packages/runtime/src/workspace/workspace-manager.ts +15 -0
- package/packages/runtime/tsconfig.json +17 -0
- package/vscode-extension/oxe-agents-0.9.2.vsix +0 -0
- package/vscode-extension/oxe-agents-1.0.0.vsix +0 -0
- package/vscode-extension/package.json +1 -1
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import { appendEvent } from '../events/bus';
|
|
2
|
+
import type { OxeEvent } from '../events/envelope';
|
|
3
|
+
import type { EventInput } from '../events/bus';
|
|
4
|
+
import type { ExecutionGraph, GraphNode } from '../compiler/graph-compiler';
|
|
5
|
+
import type { WorkspaceManager, WorkspaceRequest } from '../workspace/workspace-manager';
|
|
6
|
+
import type { WorkspaceLease } from '../models/workspace';
|
|
7
|
+
import {
|
|
8
|
+
saveJournal,
|
|
9
|
+
loadJournal,
|
|
10
|
+
deleteJournal,
|
|
11
|
+
createJournal,
|
|
12
|
+
} from './run-journal';
|
|
13
|
+
import type { RunJournal } from './run-journal';
|
|
14
|
+
|
|
15
|
+
export interface TaskResult {
|
|
16
|
+
success: boolean;
|
|
17
|
+
failure_class: 'env' | 'policy' | 'test' | 'timeout' | null;
|
|
18
|
+
evidence: string[];
|
|
19
|
+
output: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface TaskExecutor {
|
|
23
|
+
execute(
|
|
24
|
+
node: GraphNode,
|
|
25
|
+
lease: WorkspaceLease,
|
|
26
|
+
runId: string,
|
|
27
|
+
attemptNumber: number
|
|
28
|
+
): Promise<TaskResult>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SchedulerContext {
|
|
32
|
+
projectRoot: string;
|
|
33
|
+
sessionId: string | null;
|
|
34
|
+
runId: string;
|
|
35
|
+
executor: TaskExecutor;
|
|
36
|
+
workspaceManager: WorkspaceManager;
|
|
37
|
+
onEvent?: (event: OxeEvent) => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface RunResult {
|
|
41
|
+
run_id: string;
|
|
42
|
+
status: 'completed' | 'failed' | 'cancelled' | 'paused';
|
|
43
|
+
completed: string[];
|
|
44
|
+
failed: string[];
|
|
45
|
+
blocked: string[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type NodeStatus = 'pending' | 'ready' | 'running' | 'completed' | 'failed' | 'blocked';
|
|
49
|
+
|
|
50
|
+
export class Scheduler {
|
|
51
|
+
private cancelled = false;
|
|
52
|
+
private paused = false;
|
|
53
|
+
private journal: RunJournal | null = null;
|
|
54
|
+
private ctx: SchedulerContext | null = null;
|
|
55
|
+
|
|
56
|
+
async run(graph: ExecutionGraph, ctx: SchedulerContext): Promise<RunResult> {
|
|
57
|
+
this.cancelled = false;
|
|
58
|
+
this.paused = false;
|
|
59
|
+
this.ctx = ctx;
|
|
60
|
+
|
|
61
|
+
const status = new Map<string, NodeStatus>();
|
|
62
|
+
for (const id of graph.nodes.keys()) status.set(id, 'pending');
|
|
63
|
+
|
|
64
|
+
const completed: string[] = [];
|
|
65
|
+
const failed: string[] = [];
|
|
66
|
+
const blocked: string[] = [];
|
|
67
|
+
|
|
68
|
+
this.journal = createJournal(ctx.runId);
|
|
69
|
+
saveJournal(ctx.projectRoot, ctx.runId, this.journal);
|
|
70
|
+
|
|
71
|
+
this.emit(ctx, { type: 'RunStarted', payload: { run_id: ctx.runId } });
|
|
72
|
+
|
|
73
|
+
for (const wave of graph.waves) {
|
|
74
|
+
if (this.cancelled) break;
|
|
75
|
+
|
|
76
|
+
// Respect pause: persist journal and return paused result
|
|
77
|
+
if (this.paused) {
|
|
78
|
+
this.journal.scheduler_state = 'paused';
|
|
79
|
+
this.journal.paused_at = new Date().toISOString();
|
|
80
|
+
this.journal.completed_work_items = completed.slice();
|
|
81
|
+
this.journal.failed_work_items = failed.slice();
|
|
82
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
83
|
+
this.journal.partial_result = { run_id: ctx.runId, completed, failed, blocked };
|
|
84
|
+
saveJournal(ctx.projectRoot, ctx.runId, this.journal);
|
|
85
|
+
return { run_id: ctx.runId, status: 'paused', completed, failed, blocked };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const waveFailed = await this.runWave(
|
|
89
|
+
wave.node_ids,
|
|
90
|
+
graph,
|
|
91
|
+
ctx,
|
|
92
|
+
status,
|
|
93
|
+
completed,
|
|
94
|
+
failed,
|
|
95
|
+
blocked
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// Sync journal after each wave
|
|
99
|
+
this.journal.completed_work_items = completed.slice();
|
|
100
|
+
this.journal.failed_work_items = failed.slice();
|
|
101
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
102
|
+
saveJournal(ctx.projectRoot, ctx.runId, this.journal);
|
|
103
|
+
|
|
104
|
+
if (waveFailed) break;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Any remaining pending nodes become blocked
|
|
108
|
+
for (const [id, s] of status) {
|
|
109
|
+
if (s === 'pending') {
|
|
110
|
+
status.set(id, 'blocked');
|
|
111
|
+
blocked.push(id);
|
|
112
|
+
this.emit(ctx, {
|
|
113
|
+
type: 'WorkItemBlocked',
|
|
114
|
+
work_item_id: id,
|
|
115
|
+
payload: { reason: 'upstream_wave_failed' },
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const finalStatus: RunResult['status'] = this.cancelled
|
|
121
|
+
? 'cancelled'
|
|
122
|
+
: failed.length > 0
|
|
123
|
+
? 'failed'
|
|
124
|
+
: 'completed';
|
|
125
|
+
|
|
126
|
+
this.emit(ctx, {
|
|
127
|
+
type: 'RunCompleted',
|
|
128
|
+
payload: { run_id: ctx.runId, status: finalStatus },
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
this.journal.scheduler_state = this.cancelled ? 'cancelled' : 'completed';
|
|
132
|
+
this.journal.completed_work_items = completed.slice();
|
|
133
|
+
this.journal.failed_work_items = failed.slice();
|
|
134
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
135
|
+
saveJournal(ctx.projectRoot, ctx.runId, this.journal);
|
|
136
|
+
|
|
137
|
+
return { run_id: ctx.runId, status: finalStatus, completed, failed, blocked };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Recover a previously paused run by loading its journal and re-running
|
|
142
|
+
* only the work items that haven't completed yet.
|
|
143
|
+
*/
|
|
144
|
+
async recover(runId: string, ctx: SchedulerContext, graph: ExecutionGraph): Promise<RunResult | null> {
|
|
145
|
+
const journal = loadJournal(ctx.projectRoot, runId);
|
|
146
|
+
if (!journal || journal.scheduler_state !== 'paused') return null;
|
|
147
|
+
|
|
148
|
+
// Restore state from journal
|
|
149
|
+
this.cancelled = false;
|
|
150
|
+
this.paused = false;
|
|
151
|
+
this.ctx = ctx;
|
|
152
|
+
this.journal = { ...journal, scheduler_state: 'running', paused_at: null };
|
|
153
|
+
|
|
154
|
+
const restoredCompleted = new Set(journal.completed_work_items);
|
|
155
|
+
const restoredFailed = new Set(journal.failed_work_items);
|
|
156
|
+
const restoredBlocked = new Set(journal.blocked_work_items);
|
|
157
|
+
|
|
158
|
+
const status = new Map<string, NodeStatus>();
|
|
159
|
+
for (const id of graph.nodes.keys()) {
|
|
160
|
+
if (restoredCompleted.has(id)) status.set(id, 'completed');
|
|
161
|
+
else if (restoredFailed.has(id)) status.set(id, 'failed');
|
|
162
|
+
else if (restoredBlocked.has(id)) status.set(id, 'blocked');
|
|
163
|
+
else status.set(id, 'pending');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const completed = [...restoredCompleted];
|
|
167
|
+
const failed = [...restoredFailed];
|
|
168
|
+
const blocked = [...restoredBlocked];
|
|
169
|
+
|
|
170
|
+
saveJournal(ctx.projectRoot, runId, this.journal);
|
|
171
|
+
|
|
172
|
+
this.emit(ctx, { type: 'RunStarted', payload: { run_id: ctx.runId, recovered: true } });
|
|
173
|
+
|
|
174
|
+
for (const wave of graph.waves) {
|
|
175
|
+
if (this.cancelled) break;
|
|
176
|
+
if (this.paused) {
|
|
177
|
+
this.journal.scheduler_state = 'paused';
|
|
178
|
+
this.journal.paused_at = new Date().toISOString();
|
|
179
|
+
this.journal.completed_work_items = completed.slice();
|
|
180
|
+
this.journal.failed_work_items = failed.slice();
|
|
181
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
182
|
+
this.journal.partial_result = { run_id: ctx.runId, completed, failed, blocked };
|
|
183
|
+
saveJournal(ctx.projectRoot, ctx.runId, this.journal);
|
|
184
|
+
return { run_id: ctx.runId, status: 'paused', completed, failed, blocked };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Skip waves fully completed
|
|
188
|
+
const allDone = wave.node_ids.every(
|
|
189
|
+
(id) => restoredCompleted.has(id) || restoredFailed.has(id) || restoredBlocked.has(id)
|
|
190
|
+
);
|
|
191
|
+
if (allDone) continue;
|
|
192
|
+
|
|
193
|
+
const waveFailed = await this.runWave(
|
|
194
|
+
wave.node_ids,
|
|
195
|
+
graph,
|
|
196
|
+
ctx,
|
|
197
|
+
status,
|
|
198
|
+
completed,
|
|
199
|
+
failed,
|
|
200
|
+
blocked
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
this.journal.completed_work_items = completed.slice();
|
|
204
|
+
this.journal.failed_work_items = failed.slice();
|
|
205
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
206
|
+
saveJournal(ctx.projectRoot, ctx.runId, this.journal);
|
|
207
|
+
|
|
208
|
+
if (waveFailed) break;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
for (const [id, s] of status) {
|
|
212
|
+
if (s === 'pending') {
|
|
213
|
+
status.set(id, 'blocked');
|
|
214
|
+
blocked.push(id);
|
|
215
|
+
this.emit(ctx, {
|
|
216
|
+
type: 'WorkItemBlocked',
|
|
217
|
+
work_item_id: id,
|
|
218
|
+
payload: { reason: 'upstream_wave_failed' },
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const finalStatus: RunResult['status'] = this.cancelled
|
|
224
|
+
? 'cancelled'
|
|
225
|
+
: failed.length > 0
|
|
226
|
+
? 'failed'
|
|
227
|
+
: 'completed';
|
|
228
|
+
|
|
229
|
+
this.emit(ctx, {
|
|
230
|
+
type: 'RunCompleted',
|
|
231
|
+
payload: { run_id: ctx.runId, status: finalStatus, recovered: true },
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
this.journal.scheduler_state = this.cancelled ? 'cancelled' : 'completed';
|
|
235
|
+
this.journal.completed_work_items = completed.slice();
|
|
236
|
+
this.journal.failed_work_items = failed.slice();
|
|
237
|
+
this.journal.blocked_work_items = blocked.slice();
|
|
238
|
+
saveJournal(ctx.projectRoot, ctx.runId, this.journal);
|
|
239
|
+
deleteJournal(ctx.projectRoot, ctx.runId);
|
|
240
|
+
|
|
241
|
+
return { run_id: ctx.runId, status: finalStatus, completed, failed, blocked };
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private async runWave(
|
|
245
|
+
nodeIds: string[],
|
|
246
|
+
graph: ExecutionGraph,
|
|
247
|
+
ctx: SchedulerContext,
|
|
248
|
+
status: Map<string, NodeStatus>,
|
|
249
|
+
completed: string[],
|
|
250
|
+
failed: string[],
|
|
251
|
+
blocked: string[]
|
|
252
|
+
): Promise<boolean> {
|
|
253
|
+
const eligible: string[] = [];
|
|
254
|
+
const depsNotMet: string[] = [];
|
|
255
|
+
|
|
256
|
+
for (const id of nodeIds) {
|
|
257
|
+
if (status.get(id) === 'completed') continue; // already done in recovery
|
|
258
|
+
const node = graph.nodes.get(id)!;
|
|
259
|
+
const depsMet = node.depends_on.every((dep) => status.get(dep) === 'completed');
|
|
260
|
+
if (depsMet) {
|
|
261
|
+
eligible.push(id);
|
|
262
|
+
} else {
|
|
263
|
+
depsNotMet.push(id);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
for (const id of depsNotMet) {
|
|
268
|
+
status.set(id, 'blocked');
|
|
269
|
+
blocked.push(id);
|
|
270
|
+
this.emit(ctx, {
|
|
271
|
+
type: 'WorkItemBlocked',
|
|
272
|
+
work_item_id: id,
|
|
273
|
+
payload: { reason: 'dependency_not_met' },
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const readOnly = eligible.filter((id) => {
|
|
278
|
+
const node = graph.nodes.get(id)!;
|
|
279
|
+
return node.mutation_scope.length === 0;
|
|
280
|
+
});
|
|
281
|
+
const mutations = eligible.filter((id) => !readOnly.includes(id));
|
|
282
|
+
|
|
283
|
+
if (readOnly.length > 0) {
|
|
284
|
+
await Promise.all(
|
|
285
|
+
readOnly.map((id) => this.runNode(id, graph, ctx, status, completed, failed))
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
for (const id of mutations) {
|
|
290
|
+
if (this.cancelled) break;
|
|
291
|
+
await this.runNode(id, graph, ctx, status, completed, failed);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return failed.length > 0;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
private async runNode(
|
|
298
|
+
nodeId: string,
|
|
299
|
+
graph: ExecutionGraph,
|
|
300
|
+
ctx: SchedulerContext,
|
|
301
|
+
status: Map<string, NodeStatus>,
|
|
302
|
+
completed: string[],
|
|
303
|
+
failed: string[]
|
|
304
|
+
): Promise<void> {
|
|
305
|
+
const node = graph.nodes.get(nodeId)!;
|
|
306
|
+
status.set(nodeId, 'running');
|
|
307
|
+
this.emit(ctx, {
|
|
308
|
+
type: 'WorkItemReady',
|
|
309
|
+
work_item_id: nodeId,
|
|
310
|
+
payload: { title: node.title, wave: node.wave },
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
let lease: WorkspaceLease | null = null;
|
|
314
|
+
let lastResult: TaskResult | null = null;
|
|
315
|
+
const maxAttempts = node.policy.max_retries + 1;
|
|
316
|
+
|
|
317
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
318
|
+
const attemptId = `${nodeId}-a${attempt}`;
|
|
319
|
+
|
|
320
|
+
this.emit(ctx, {
|
|
321
|
+
type: 'AttemptStarted',
|
|
322
|
+
work_item_id: nodeId,
|
|
323
|
+
attempt_id: attemptId,
|
|
324
|
+
payload: { attempt_number: attempt },
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
try {
|
|
328
|
+
const wsReq: WorkspaceRequest = {
|
|
329
|
+
work_item_id: nodeId,
|
|
330
|
+
attempt_number: attempt,
|
|
331
|
+
strategy: node.workspace_strategy,
|
|
332
|
+
mutation_scope: node.mutation_scope,
|
|
333
|
+
};
|
|
334
|
+
lease = await ctx.workspaceManager.allocate(wsReq);
|
|
335
|
+
this.emit(ctx, {
|
|
336
|
+
type: 'WorkspaceAllocated',
|
|
337
|
+
work_item_id: nodeId,
|
|
338
|
+
attempt_id: attemptId,
|
|
339
|
+
payload: { workspace_id: lease.workspace_id, strategy: lease.strategy },
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
lastResult = await ctx.executor.execute(node, lease, ctx.runId, attempt);
|
|
343
|
+
|
|
344
|
+
if (lastResult.success) {
|
|
345
|
+
this.emit(ctx, {
|
|
346
|
+
type: 'WorkItemCompleted',
|
|
347
|
+
work_item_id: nodeId,
|
|
348
|
+
attempt_id: attemptId,
|
|
349
|
+
payload: { attempt_number: attempt, evidence: lastResult.evidence },
|
|
350
|
+
});
|
|
351
|
+
status.set(nodeId, 'completed');
|
|
352
|
+
completed.push(nodeId);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (lastResult.failure_class === 'policy') break;
|
|
357
|
+
|
|
358
|
+
if (attempt < maxAttempts) {
|
|
359
|
+
this.emit(ctx, {
|
|
360
|
+
type: 'RetryScheduled',
|
|
361
|
+
work_item_id: nodeId,
|
|
362
|
+
payload: { next_attempt: attempt + 1, reason: lastResult.failure_class },
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
} catch (err) {
|
|
366
|
+
lastResult = {
|
|
367
|
+
success: false,
|
|
368
|
+
failure_class: 'env',
|
|
369
|
+
evidence: [],
|
|
370
|
+
output: String(err),
|
|
371
|
+
};
|
|
372
|
+
if (attempt < maxAttempts) {
|
|
373
|
+
this.emit(ctx, {
|
|
374
|
+
type: 'RetryScheduled',
|
|
375
|
+
work_item_id: nodeId,
|
|
376
|
+
payload: { next_attempt: attempt + 1, reason: 'env' },
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
} finally {
|
|
380
|
+
if (lease) {
|
|
381
|
+
await ctx.workspaceManager.dispose(lease.workspace_id).catch(() => {});
|
|
382
|
+
lease = null;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
this.emit(ctx, {
|
|
388
|
+
type: 'WorkItemBlocked',
|
|
389
|
+
work_item_id: nodeId,
|
|
390
|
+
payload: { failure_class: lastResult?.failure_class ?? 'env', max_attempts: maxAttempts },
|
|
391
|
+
});
|
|
392
|
+
status.set(nodeId, 'failed');
|
|
393
|
+
failed.push(nodeId);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
pause(): void {
|
|
397
|
+
this.paused = true;
|
|
398
|
+
if (this.journal && this.ctx) {
|
|
399
|
+
this.journal.scheduler_state = 'paused';
|
|
400
|
+
this.journal.paused_at = new Date().toISOString();
|
|
401
|
+
saveJournal(this.ctx.projectRoot, this.ctx.runId, this.journal);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
resume(): void {
|
|
406
|
+
this.paused = false;
|
|
407
|
+
if (this.journal && this.ctx) {
|
|
408
|
+
this.journal.scheduler_state = 'running';
|
|
409
|
+
this.journal.paused_at = null;
|
|
410
|
+
saveJournal(this.ctx.projectRoot, this.ctx.runId, this.journal);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
cancel(): void {
|
|
415
|
+
this.cancelled = true;
|
|
416
|
+
if (this.journal && this.ctx) {
|
|
417
|
+
this.journal.cancelled = true;
|
|
418
|
+
this.journal.scheduler_state = 'cancelled';
|
|
419
|
+
saveJournal(this.ctx.projectRoot, this.ctx.runId, this.journal);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
getJournal(): RunJournal | null {
|
|
424
|
+
return this.journal;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
static loadJournal(projectRoot: string, runId: string): RunJournal | null {
|
|
428
|
+
return loadJournal(projectRoot, runId);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
private emit(
|
|
432
|
+
ctx: SchedulerContext,
|
|
433
|
+
input: EventInput
|
|
434
|
+
): void {
|
|
435
|
+
const event = appendEvent(ctx.projectRoot, ctx.sessionId, {
|
|
436
|
+
run_id: ctx.runId,
|
|
437
|
+
...input,
|
|
438
|
+
});
|
|
439
|
+
ctx.onEvent?.(event);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
import { spawnSync } from 'child_process';
|
|
3
|
+
import type { EvidenceType } from '../models/evidence';
|
|
4
|
+
import type { VerificationStatus } from '../models/verification-result';
|
|
5
|
+
|
|
6
|
+
export type CheckType =
|
|
7
|
+
| 'unit'
|
|
8
|
+
| 'integration'
|
|
9
|
+
| 'contract'
|
|
10
|
+
| 'smoke'
|
|
11
|
+
| 'policy'
|
|
12
|
+
| 'security'
|
|
13
|
+
| 'ux_snapshot'
|
|
14
|
+
| 'performance_baseline'
|
|
15
|
+
| 'custom';
|
|
16
|
+
|
|
17
|
+
export interface AcceptanceCheck {
|
|
18
|
+
id: string;
|
|
19
|
+
type: CheckType;
|
|
20
|
+
command: string | null;
|
|
21
|
+
evidence_type_expected: EvidenceType;
|
|
22
|
+
acceptance_ref: string | null;
|
|
23
|
+
description: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface AcceptanceCheckSuite {
|
|
27
|
+
checks: AcceptanceCheck[];
|
|
28
|
+
compiled_at: string;
|
|
29
|
+
spec_hash: string;
|
|
30
|
+
plan_hash: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CheckResult {
|
|
34
|
+
check_id: string;
|
|
35
|
+
acceptance_ref: string | null;
|
|
36
|
+
status: VerificationStatus;
|
|
37
|
+
stdout: string;
|
|
38
|
+
stderr: string;
|
|
39
|
+
exit_code: number | null;
|
|
40
|
+
duration_ms: number;
|
|
41
|
+
error: string | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Mirror of ParsedSpec/ParsedPlan (same as in graph-compiler to avoid circular deps)
|
|
45
|
+
interface Criterion {
|
|
46
|
+
id: string;
|
|
47
|
+
criterion: string;
|
|
48
|
+
howToVerify: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface ParsedSpecLike {
|
|
52
|
+
objective: string | null;
|
|
53
|
+
criteria: Criterion[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface ParsedTaskLike {
|
|
57
|
+
id: string;
|
|
58
|
+
verifyCommand: string | null;
|
|
59
|
+
aceite: string[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface ParsedPlanLike {
|
|
63
|
+
tasks: ParsedTaskLike[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function inferCheckType(howToVerify: string): CheckType {
|
|
67
|
+
const v = howToVerify.toLowerCase();
|
|
68
|
+
if (v.includes('npm test') || v.includes('jest') || v.includes('vitest') || v.includes('node --test')) return 'unit';
|
|
69
|
+
if (v.includes('postman') || v.includes('newman') || v.includes('integration')) return 'integration';
|
|
70
|
+
if (v.includes('smoke') || v.includes('curl')) return 'smoke';
|
|
71
|
+
if (v.includes('eslint') || v.includes('lint') || v.includes('oxe-policy')) return 'policy';
|
|
72
|
+
if (v.includes('security') || v.includes('audit') || v.includes('trivy')) return 'security';
|
|
73
|
+
return 'custom';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function inferEvidenceType(checkType: CheckType): EvidenceType {
|
|
77
|
+
switch (checkType) {
|
|
78
|
+
case 'unit': return 'junit_xml';
|
|
79
|
+
case 'integration': return 'api_output';
|
|
80
|
+
case 'security': return 'security_report';
|
|
81
|
+
case 'policy': return 'log';
|
|
82
|
+
default: return 'stdout';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function compile(
|
|
87
|
+
spec: ParsedSpecLike,
|
|
88
|
+
plan: ParsedPlanLike
|
|
89
|
+
): AcceptanceCheckSuite {
|
|
90
|
+
const checks: AcceptanceCheck[] = [];
|
|
91
|
+
const seenRefs = new Set<string>();
|
|
92
|
+
|
|
93
|
+
// Generate checks from spec criteria
|
|
94
|
+
for (const criterion of spec.criteria) {
|
|
95
|
+
// Find the verify command from the task that references this criterion
|
|
96
|
+
const task = plan.tasks.find((t) => t.aceite.includes(criterion.id));
|
|
97
|
+
const command = task?.verifyCommand ?? null;
|
|
98
|
+
const type = inferCheckType(criterion.howToVerify);
|
|
99
|
+
|
|
100
|
+
checks.push({
|
|
101
|
+
id: `check-${criterion.id.toLowerCase()}`,
|
|
102
|
+
type,
|
|
103
|
+
command: command ?? (criterion.howToVerify.startsWith('#') ? null : criterion.howToVerify),
|
|
104
|
+
evidence_type_expected: inferEvidenceType(type),
|
|
105
|
+
acceptance_ref: criterion.id,
|
|
106
|
+
description: criterion.criterion,
|
|
107
|
+
});
|
|
108
|
+
seenRefs.add(criterion.id);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Add checks for task verify commands not already covered
|
|
112
|
+
for (const task of plan.tasks) {
|
|
113
|
+
if (!task.verifyCommand) continue;
|
|
114
|
+
const uncovered = task.aceite.filter((ref) => !seenRefs.has(ref));
|
|
115
|
+
if (uncovered.length === 0 && checks.some((c) => c.command === task.verifyCommand)) continue;
|
|
116
|
+
|
|
117
|
+
checks.push({
|
|
118
|
+
id: `check-task-${task.id.toLowerCase()}`,
|
|
119
|
+
type: inferCheckType(task.verifyCommand),
|
|
120
|
+
command: task.verifyCommand,
|
|
121
|
+
evidence_type_expected: 'stdout',
|
|
122
|
+
acceptance_ref: uncovered[0] ?? null,
|
|
123
|
+
description: `Verify command for task ${task.id}`,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
checks,
|
|
129
|
+
compiled_at: new Date().toISOString(),
|
|
130
|
+
spec_hash: hashObject(spec),
|
|
131
|
+
plan_hash: hashObject(plan),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function runCheck(
|
|
136
|
+
check: AcceptanceCheck,
|
|
137
|
+
cwd: string,
|
|
138
|
+
timeoutMs = 60_000
|
|
139
|
+
): Promise<CheckResult> {
|
|
140
|
+
if (!check.command) {
|
|
141
|
+
return {
|
|
142
|
+
check_id: check.id,
|
|
143
|
+
acceptance_ref: check.acceptance_ref,
|
|
144
|
+
status: 'skip',
|
|
145
|
+
stdout: '',
|
|
146
|
+
stderr: '',
|
|
147
|
+
exit_code: null,
|
|
148
|
+
duration_ms: 0,
|
|
149
|
+
error: null,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const start = Date.now();
|
|
154
|
+
try {
|
|
155
|
+
// Split command into program + args (simple split; no shell expansion)
|
|
156
|
+
const parts = check.command.split(/\s+/);
|
|
157
|
+
const prog = parts[0];
|
|
158
|
+
const args = parts.slice(1);
|
|
159
|
+
|
|
160
|
+
const result = spawnSync(prog, args, {
|
|
161
|
+
cwd,
|
|
162
|
+
encoding: 'utf8',
|
|
163
|
+
timeout: timeoutMs,
|
|
164
|
+
maxBuffer: 2 * 1024 * 1024,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const duration_ms = Date.now() - start;
|
|
168
|
+
const status: VerificationStatus = result.status === 0 ? 'pass' : 'fail';
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
check_id: check.id,
|
|
172
|
+
acceptance_ref: check.acceptance_ref,
|
|
173
|
+
status,
|
|
174
|
+
stdout: result.stdout ?? '',
|
|
175
|
+
stderr: result.stderr ?? '',
|
|
176
|
+
exit_code: result.status ?? null,
|
|
177
|
+
duration_ms,
|
|
178
|
+
error: result.error ? String(result.error) : null,
|
|
179
|
+
};
|
|
180
|
+
} catch (err) {
|
|
181
|
+
return {
|
|
182
|
+
check_id: check.id,
|
|
183
|
+
acceptance_ref: check.acceptance_ref,
|
|
184
|
+
status: 'error',
|
|
185
|
+
stdout: '',
|
|
186
|
+
stderr: '',
|
|
187
|
+
exit_code: null,
|
|
188
|
+
duration_ms: Date.now() - start,
|
|
189
|
+
error: String(err),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export async function runSuite(
|
|
195
|
+
suite: AcceptanceCheckSuite,
|
|
196
|
+
cwd: string,
|
|
197
|
+
timeoutMs = 60_000
|
|
198
|
+
): Promise<CheckResult[]> {
|
|
199
|
+
const results: CheckResult[] = [];
|
|
200
|
+
for (const check of suite.checks) {
|
|
201
|
+
results.push(await runCheck(check, cwd, timeoutMs));
|
|
202
|
+
}
|
|
203
|
+
return results;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function summarizeSuite(results: CheckResult[]): {
|
|
207
|
+
total: number;
|
|
208
|
+
pass: number;
|
|
209
|
+
fail: number;
|
|
210
|
+
skip: number;
|
|
211
|
+
error: number;
|
|
212
|
+
allPassed: boolean;
|
|
213
|
+
} {
|
|
214
|
+
const counts = { total: results.length, pass: 0, fail: 0, skip: 0, error: 0 };
|
|
215
|
+
for (const r of results) counts[r.status]++;
|
|
216
|
+
return { ...counts, allPassed: counts.fail === 0 && counts.error === 0 };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function hashObject(obj: unknown): string {
|
|
220
|
+
return crypto
|
|
221
|
+
.createHash('sha256')
|
|
222
|
+
.update(JSON.stringify(obj))
|
|
223
|
+
.digest('hex')
|
|
224
|
+
.slice(0, 12);
|
|
225
|
+
}
|