oxe-cc 0.9.2 → 1.0.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-retro.md +2 -2
- package/.cursor/commands/oxe-spec.md +2 -2
- package/.github/prompts/oxe-retro.prompt.md +2 -2
- package/.github/prompts/oxe-spec.prompt.md +2 -2
- package/README.md +1 -1
- package/bin/banner.txt +1 -1
- package/bin/lib/oxe-context-engine.cjs +1 -0
- package/bin/lib/oxe-dashboard.cjs +9 -7
- package/bin/lib/oxe-operational.cjs +569 -4
- package/bin/oxe-cc.js +141 -57
- package/commands/oxe/retro.md +2 -2
- package/commands/oxe/spec.md +2 -2
- 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 +36 -0
- package/lib/runtime/context/context-pack-builder.js +136 -0
- package/lib/runtime/context/index.d.ts +1 -0
- package/lib/runtime/context/index.js +17 -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 +3 -0
- package/lib/runtime/delivery/index.js +19 -0
- package/lib/runtime/delivery/pr-manager.d.ts +30 -0
- package/lib/runtime/delivery/pr-manager.js +82 -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 +16 -0
- package/lib/runtime/index.js +40 -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/index.d.ts +2 -0
- package/lib/runtime/plugins/index.js +18 -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-registry.d.ts +21 -0
- package/lib/runtime/plugins/plugin-registry.js +114 -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 +40 -0
- package/lib/runtime/policy/policy-engine.js +80 -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 +20 -0
- package/lib/runtime/reducers/run-state-reducer.js +110 -0
- package/lib/runtime/scheduler/index.d.ts +1 -0
- package/lib/runtime/scheduler/index.js +17 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.d.ts +34 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.js +166 -0
- package/lib/runtime/scheduler/scheduler.d.ts +39 -0
- package/lib/runtime/scheduler/scheduler.js +196 -0
- package/lib/runtime/verification/index.d.ts +1 -0
- package/lib/runtime/verification/index.js +17 -0
- package/lib/runtime/verification/verification-compiler.d.ts +56 -0
- package/lib/runtime/verification/verification-compiler.js +147 -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/templates/LESSONS-METRICS.template.json +13 -0
- package/oxe/workflows/references/robustness-elevation.md +295 -0
- package/oxe/workflows/references/workflow-runtime-contracts.json +32 -4
- package/oxe/workflows/retro.md +21 -0
- package/oxe/workflows/spec.md +50 -26
- package/oxe/workflows/verify.md +36 -0
- package/package.json +9 -3
- package/packages/runtime/package.json +17 -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 +193 -0
- package/packages/runtime/src/context/index.ts +1 -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 +3 -0
- package/packages/runtime/src/delivery/pr-manager.ts +112 -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 +32 -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/index.ts +2 -0
- package/packages/runtime/src/plugins/plugin-abi.ts +95 -0
- package/packages/runtime/src/plugins/plugin-registry.ts +119 -0
- package/packages/runtime/src/policy/index.ts +1 -0
- package/packages/runtime/src/policy/policy-engine.ts +113 -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 +127 -0
- package/packages/runtime/src/scheduler/index.ts +1 -0
- package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +231 -0
- package/packages/runtime/src/scheduler/scheduler.ts +281 -0
- package/packages/runtime/src/verification/index.ts +1 -0
- package/packages/runtime/src/verification/verification-compiler.ts +225 -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-1.0.0.vsix +0 -0
- package/vscode-extension/package.json +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scheduler = void 0;
|
|
4
|
+
const bus_1 = require("../events/bus");
|
|
5
|
+
class Scheduler {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.cancelled = false;
|
|
8
|
+
this.paused = false;
|
|
9
|
+
}
|
|
10
|
+
async run(graph, ctx) {
|
|
11
|
+
this.cancelled = false;
|
|
12
|
+
this.paused = false;
|
|
13
|
+
const status = new Map();
|
|
14
|
+
for (const id of graph.nodes.keys())
|
|
15
|
+
status.set(id, 'pending');
|
|
16
|
+
const completed = [];
|
|
17
|
+
const failed = [];
|
|
18
|
+
const blocked = [];
|
|
19
|
+
this.emit(ctx, { type: 'RunStarted', payload: { run_id: ctx.runId } });
|
|
20
|
+
for (const wave of graph.waves) {
|
|
21
|
+
if (this.cancelled)
|
|
22
|
+
break;
|
|
23
|
+
const waveFailed = await this.runWave(wave.node_ids, graph, ctx, status, completed, failed, blocked);
|
|
24
|
+
if (waveFailed)
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
// Any remaining pending nodes become blocked
|
|
28
|
+
for (const [id, s] of status) {
|
|
29
|
+
if (s === 'pending') {
|
|
30
|
+
status.set(id, 'blocked');
|
|
31
|
+
blocked.push(id);
|
|
32
|
+
this.emit(ctx, {
|
|
33
|
+
type: 'WorkItemBlocked',
|
|
34
|
+
work_item_id: id,
|
|
35
|
+
payload: { reason: 'upstream_wave_failed' },
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const finalStatus = this.cancelled
|
|
40
|
+
? 'cancelled'
|
|
41
|
+
: failed.length > 0
|
|
42
|
+
? 'failed'
|
|
43
|
+
: 'completed';
|
|
44
|
+
this.emit(ctx, {
|
|
45
|
+
type: 'RunCompleted',
|
|
46
|
+
payload: { run_id: ctx.runId, status: finalStatus },
|
|
47
|
+
});
|
|
48
|
+
return { run_id: ctx.runId, status: finalStatus, completed, failed, blocked };
|
|
49
|
+
}
|
|
50
|
+
async runWave(nodeIds, graph, ctx, status, completed, failed, blocked) {
|
|
51
|
+
// Partition: eligible vs blocked-by-dep
|
|
52
|
+
const eligible = [];
|
|
53
|
+
const depsNotMet = [];
|
|
54
|
+
for (const id of nodeIds) {
|
|
55
|
+
const node = graph.nodes.get(id);
|
|
56
|
+
const depsMet = node.depends_on.every((dep) => status.get(dep) === 'completed');
|
|
57
|
+
if (depsMet) {
|
|
58
|
+
eligible.push(id);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
depsNotMet.push(id);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Nodes whose deps weren't met in this wave → blocked
|
|
65
|
+
for (const id of depsNotMet) {
|
|
66
|
+
status.set(id, 'blocked');
|
|
67
|
+
blocked.push(id);
|
|
68
|
+
this.emit(ctx, {
|
|
69
|
+
type: 'WorkItemBlocked',
|
|
70
|
+
work_item_id: id,
|
|
71
|
+
payload: { reason: 'dependency_not_met' },
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Separate read-only (no mutation_scope) from mutation nodes
|
|
75
|
+
const readOnly = eligible.filter((id) => {
|
|
76
|
+
const node = graph.nodes.get(id);
|
|
77
|
+
return node.mutation_scope.length === 0;
|
|
78
|
+
});
|
|
79
|
+
const mutations = eligible.filter((id) => !readOnly.includes(id));
|
|
80
|
+
// Run read-only nodes in parallel
|
|
81
|
+
if (readOnly.length > 0) {
|
|
82
|
+
await Promise.all(readOnly.map((id) => this.runNode(id, graph, ctx, status, completed, failed)));
|
|
83
|
+
}
|
|
84
|
+
// Run mutation nodes sequentially to avoid scope conflicts
|
|
85
|
+
for (const id of mutations) {
|
|
86
|
+
if (this.cancelled)
|
|
87
|
+
break;
|
|
88
|
+
await this.runNode(id, graph, ctx, status, completed, failed);
|
|
89
|
+
}
|
|
90
|
+
return failed.length > 0;
|
|
91
|
+
}
|
|
92
|
+
async runNode(nodeId, graph, ctx, status, completed, failed) {
|
|
93
|
+
const node = graph.nodes.get(nodeId);
|
|
94
|
+
status.set(nodeId, 'running');
|
|
95
|
+
this.emit(ctx, {
|
|
96
|
+
type: 'WorkItemReady',
|
|
97
|
+
work_item_id: nodeId,
|
|
98
|
+
payload: { title: node.title, wave: node.wave },
|
|
99
|
+
});
|
|
100
|
+
let lease = null;
|
|
101
|
+
let lastResult = null;
|
|
102
|
+
const maxAttempts = node.policy.max_retries + 1;
|
|
103
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
104
|
+
const attemptId = `${nodeId}-a${attempt}`;
|
|
105
|
+
this.emit(ctx, {
|
|
106
|
+
type: 'AttemptStarted',
|
|
107
|
+
work_item_id: nodeId,
|
|
108
|
+
attempt_id: attemptId,
|
|
109
|
+
payload: { attempt_number: attempt },
|
|
110
|
+
});
|
|
111
|
+
try {
|
|
112
|
+
const wsReq = {
|
|
113
|
+
work_item_id: nodeId,
|
|
114
|
+
attempt_number: attempt,
|
|
115
|
+
strategy: node.workspace_strategy,
|
|
116
|
+
mutation_scope: node.mutation_scope,
|
|
117
|
+
};
|
|
118
|
+
lease = await ctx.workspaceManager.allocate(wsReq);
|
|
119
|
+
this.emit(ctx, {
|
|
120
|
+
type: 'WorkspaceAllocated',
|
|
121
|
+
work_item_id: nodeId,
|
|
122
|
+
attempt_id: attemptId,
|
|
123
|
+
payload: { workspace_id: lease.workspace_id, strategy: lease.strategy },
|
|
124
|
+
});
|
|
125
|
+
lastResult = await ctx.executor.execute(node, lease, ctx.runId, attempt);
|
|
126
|
+
if (lastResult.success) {
|
|
127
|
+
this.emit(ctx, {
|
|
128
|
+
type: 'WorkItemCompleted',
|
|
129
|
+
work_item_id: nodeId,
|
|
130
|
+
attempt_id: attemptId,
|
|
131
|
+
payload: { attempt_number: attempt, evidence: lastResult.evidence },
|
|
132
|
+
});
|
|
133
|
+
status.set(nodeId, 'completed');
|
|
134
|
+
completed.push(nodeId);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// Policy failures never retry
|
|
138
|
+
if (lastResult.failure_class === 'policy')
|
|
139
|
+
break;
|
|
140
|
+
if (attempt < maxAttempts) {
|
|
141
|
+
this.emit(ctx, {
|
|
142
|
+
type: 'RetryScheduled',
|
|
143
|
+
work_item_id: nodeId,
|
|
144
|
+
payload: { next_attempt: attempt + 1, reason: lastResult.failure_class },
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
lastResult = {
|
|
150
|
+
success: false,
|
|
151
|
+
failure_class: 'env',
|
|
152
|
+
evidence: [],
|
|
153
|
+
output: String(err),
|
|
154
|
+
};
|
|
155
|
+
if (attempt < maxAttempts) {
|
|
156
|
+
this.emit(ctx, {
|
|
157
|
+
type: 'RetryScheduled',
|
|
158
|
+
work_item_id: nodeId,
|
|
159
|
+
payload: { next_attempt: attempt + 1, reason: 'env' },
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
if (lease) {
|
|
165
|
+
await ctx.workspaceManager.dispose(lease.workspace_id).catch(() => { });
|
|
166
|
+
lease = null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// All attempts exhausted
|
|
171
|
+
this.emit(ctx, {
|
|
172
|
+
type: 'WorkItemBlocked',
|
|
173
|
+
work_item_id: nodeId,
|
|
174
|
+
payload: { failure_class: lastResult?.failure_class ?? 'env', max_attempts: maxAttempts },
|
|
175
|
+
});
|
|
176
|
+
status.set(nodeId, 'failed');
|
|
177
|
+
failed.push(nodeId);
|
|
178
|
+
}
|
|
179
|
+
pause() {
|
|
180
|
+
this.paused = true;
|
|
181
|
+
}
|
|
182
|
+
resume() {
|
|
183
|
+
this.paused = false;
|
|
184
|
+
}
|
|
185
|
+
cancel() {
|
|
186
|
+
this.cancelled = true;
|
|
187
|
+
}
|
|
188
|
+
emit(ctx, input) {
|
|
189
|
+
const event = (0, bus_1.appendEvent)(ctx.projectRoot, ctx.sessionId, {
|
|
190
|
+
run_id: ctx.runId,
|
|
191
|
+
...input,
|
|
192
|
+
});
|
|
193
|
+
ctx.onEvent?.(event);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.Scheduler = Scheduler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './verification-compiler';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./verification-compiler"), exports);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { EvidenceType } from '../models/evidence';
|
|
2
|
+
import type { VerificationStatus } from '../models/verification-result';
|
|
3
|
+
export type CheckType = 'unit' | 'integration' | 'contract' | 'smoke' | 'policy' | 'security' | 'ux_snapshot' | 'performance_baseline' | 'custom';
|
|
4
|
+
export interface AcceptanceCheck {
|
|
5
|
+
id: string;
|
|
6
|
+
type: CheckType;
|
|
7
|
+
command: string | null;
|
|
8
|
+
evidence_type_expected: EvidenceType;
|
|
9
|
+
acceptance_ref: string | null;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AcceptanceCheckSuite {
|
|
13
|
+
checks: AcceptanceCheck[];
|
|
14
|
+
compiled_at: string;
|
|
15
|
+
spec_hash: string;
|
|
16
|
+
plan_hash: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CheckResult {
|
|
19
|
+
check_id: string;
|
|
20
|
+
acceptance_ref: string | null;
|
|
21
|
+
status: VerificationStatus;
|
|
22
|
+
stdout: string;
|
|
23
|
+
stderr: string;
|
|
24
|
+
exit_code: number | null;
|
|
25
|
+
duration_ms: number;
|
|
26
|
+
error: string | null;
|
|
27
|
+
}
|
|
28
|
+
interface Criterion {
|
|
29
|
+
id: string;
|
|
30
|
+
criterion: string;
|
|
31
|
+
howToVerify: string;
|
|
32
|
+
}
|
|
33
|
+
interface ParsedSpecLike {
|
|
34
|
+
objective: string | null;
|
|
35
|
+
criteria: Criterion[];
|
|
36
|
+
}
|
|
37
|
+
interface ParsedTaskLike {
|
|
38
|
+
id: string;
|
|
39
|
+
verifyCommand: string | null;
|
|
40
|
+
aceite: string[];
|
|
41
|
+
}
|
|
42
|
+
interface ParsedPlanLike {
|
|
43
|
+
tasks: ParsedTaskLike[];
|
|
44
|
+
}
|
|
45
|
+
export declare function compile(spec: ParsedSpecLike, plan: ParsedPlanLike): AcceptanceCheckSuite;
|
|
46
|
+
export declare function runCheck(check: AcceptanceCheck, cwd: string, timeoutMs?: number): Promise<CheckResult>;
|
|
47
|
+
export declare function runSuite(suite: AcceptanceCheckSuite, cwd: string, timeoutMs?: number): Promise<CheckResult[]>;
|
|
48
|
+
export declare function summarizeSuite(results: CheckResult[]): {
|
|
49
|
+
total: number;
|
|
50
|
+
pass: number;
|
|
51
|
+
fail: number;
|
|
52
|
+
skip: number;
|
|
53
|
+
error: number;
|
|
54
|
+
allPassed: boolean;
|
|
55
|
+
};
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
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.compile = compile;
|
|
7
|
+
exports.runCheck = runCheck;
|
|
8
|
+
exports.runSuite = runSuite;
|
|
9
|
+
exports.summarizeSuite = summarizeSuite;
|
|
10
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
+
const child_process_1 = require("child_process");
|
|
12
|
+
function inferCheckType(howToVerify) {
|
|
13
|
+
const v = howToVerify.toLowerCase();
|
|
14
|
+
if (v.includes('npm test') || v.includes('jest') || v.includes('vitest') || v.includes('node --test'))
|
|
15
|
+
return 'unit';
|
|
16
|
+
if (v.includes('postman') || v.includes('newman') || v.includes('integration'))
|
|
17
|
+
return 'integration';
|
|
18
|
+
if (v.includes('smoke') || v.includes('curl'))
|
|
19
|
+
return 'smoke';
|
|
20
|
+
if (v.includes('eslint') || v.includes('lint') || v.includes('oxe-policy'))
|
|
21
|
+
return 'policy';
|
|
22
|
+
if (v.includes('security') || v.includes('audit') || v.includes('trivy'))
|
|
23
|
+
return 'security';
|
|
24
|
+
return 'custom';
|
|
25
|
+
}
|
|
26
|
+
function inferEvidenceType(checkType) {
|
|
27
|
+
switch (checkType) {
|
|
28
|
+
case 'unit': return 'junit_xml';
|
|
29
|
+
case 'integration': return 'api_output';
|
|
30
|
+
case 'security': return 'security_report';
|
|
31
|
+
case 'policy': return 'log';
|
|
32
|
+
default: return 'stdout';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function compile(spec, plan) {
|
|
36
|
+
const checks = [];
|
|
37
|
+
const seenRefs = new Set();
|
|
38
|
+
// Generate checks from spec criteria
|
|
39
|
+
for (const criterion of spec.criteria) {
|
|
40
|
+
// Find the verify command from the task that references this criterion
|
|
41
|
+
const task = plan.tasks.find((t) => t.aceite.includes(criterion.id));
|
|
42
|
+
const command = task?.verifyCommand ?? null;
|
|
43
|
+
const type = inferCheckType(criterion.howToVerify);
|
|
44
|
+
checks.push({
|
|
45
|
+
id: `check-${criterion.id.toLowerCase()}`,
|
|
46
|
+
type,
|
|
47
|
+
command: command ?? (criterion.howToVerify.startsWith('#') ? null : criterion.howToVerify),
|
|
48
|
+
evidence_type_expected: inferEvidenceType(type),
|
|
49
|
+
acceptance_ref: criterion.id,
|
|
50
|
+
description: criterion.criterion,
|
|
51
|
+
});
|
|
52
|
+
seenRefs.add(criterion.id);
|
|
53
|
+
}
|
|
54
|
+
// Add checks for task verify commands not already covered
|
|
55
|
+
for (const task of plan.tasks) {
|
|
56
|
+
if (!task.verifyCommand)
|
|
57
|
+
continue;
|
|
58
|
+
const uncovered = task.aceite.filter((ref) => !seenRefs.has(ref));
|
|
59
|
+
if (uncovered.length === 0 && checks.some((c) => c.command === task.verifyCommand))
|
|
60
|
+
continue;
|
|
61
|
+
checks.push({
|
|
62
|
+
id: `check-task-${task.id.toLowerCase()}`,
|
|
63
|
+
type: inferCheckType(task.verifyCommand),
|
|
64
|
+
command: task.verifyCommand,
|
|
65
|
+
evidence_type_expected: 'stdout',
|
|
66
|
+
acceptance_ref: uncovered[0] ?? null,
|
|
67
|
+
description: `Verify command for task ${task.id}`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
checks,
|
|
72
|
+
compiled_at: new Date().toISOString(),
|
|
73
|
+
spec_hash: hashObject(spec),
|
|
74
|
+
plan_hash: hashObject(plan),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async function runCheck(check, cwd, timeoutMs = 60000) {
|
|
78
|
+
if (!check.command) {
|
|
79
|
+
return {
|
|
80
|
+
check_id: check.id,
|
|
81
|
+
acceptance_ref: check.acceptance_ref,
|
|
82
|
+
status: 'skip',
|
|
83
|
+
stdout: '',
|
|
84
|
+
stderr: '',
|
|
85
|
+
exit_code: null,
|
|
86
|
+
duration_ms: 0,
|
|
87
|
+
error: null,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const start = Date.now();
|
|
91
|
+
try {
|
|
92
|
+
// Split command into program + args (simple split; no shell expansion)
|
|
93
|
+
const parts = check.command.split(/\s+/);
|
|
94
|
+
const prog = parts[0];
|
|
95
|
+
const args = parts.slice(1);
|
|
96
|
+
const result = (0, child_process_1.spawnSync)(prog, args, {
|
|
97
|
+
cwd,
|
|
98
|
+
encoding: 'utf8',
|
|
99
|
+
timeout: timeoutMs,
|
|
100
|
+
maxBuffer: 2 * 1024 * 1024,
|
|
101
|
+
});
|
|
102
|
+
const duration_ms = Date.now() - start;
|
|
103
|
+
const status = result.status === 0 ? 'pass' : 'fail';
|
|
104
|
+
return {
|
|
105
|
+
check_id: check.id,
|
|
106
|
+
acceptance_ref: check.acceptance_ref,
|
|
107
|
+
status,
|
|
108
|
+
stdout: result.stdout ?? '',
|
|
109
|
+
stderr: result.stderr ?? '',
|
|
110
|
+
exit_code: result.status ?? null,
|
|
111
|
+
duration_ms,
|
|
112
|
+
error: result.error ? String(result.error) : null,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
return {
|
|
117
|
+
check_id: check.id,
|
|
118
|
+
acceptance_ref: check.acceptance_ref,
|
|
119
|
+
status: 'error',
|
|
120
|
+
stdout: '',
|
|
121
|
+
stderr: '',
|
|
122
|
+
exit_code: null,
|
|
123
|
+
duration_ms: Date.now() - start,
|
|
124
|
+
error: String(err),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function runSuite(suite, cwd, timeoutMs = 60000) {
|
|
129
|
+
const results = [];
|
|
130
|
+
for (const check of suite.checks) {
|
|
131
|
+
results.push(await runCheck(check, cwd, timeoutMs));
|
|
132
|
+
}
|
|
133
|
+
return results;
|
|
134
|
+
}
|
|
135
|
+
function summarizeSuite(results) {
|
|
136
|
+
const counts = { total: results.length, pass: 0, fail: 0, skip: 0, error: 0 };
|
|
137
|
+
for (const r of results)
|
|
138
|
+
counts[r.status]++;
|
|
139
|
+
return { ...counts, allPassed: counts.fail === 0 && counts.error === 0 };
|
|
140
|
+
}
|
|
141
|
+
function hashObject(obj) {
|
|
142
|
+
return crypto_1.default
|
|
143
|
+
.createHash('sha256')
|
|
144
|
+
.update(JSON.stringify(obj))
|
|
145
|
+
.digest('hex')
|
|
146
|
+
.slice(0, 12);
|
|
147
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './workspace-manager';
|
|
2
|
+
export { InplaceWorkspaceManager } from './strategies/inplace';
|
|
3
|
+
export { GitWorktreeManager } from './strategies/git-worktree';
|
|
4
|
+
export { EphemeralContainerManager } from './strategies/ephemeral-container';
|
|
5
|
+
export type { ContainerOptions } from './strategies/ephemeral-container';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.EphemeralContainerManager = exports.GitWorktreeManager = exports.InplaceWorkspaceManager = void 0;
|
|
18
|
+
__exportStar(require("./workspace-manager"), exports);
|
|
19
|
+
var inplace_1 = require("./strategies/inplace");
|
|
20
|
+
Object.defineProperty(exports, "InplaceWorkspaceManager", { enumerable: true, get: function () { return inplace_1.InplaceWorkspaceManager; } });
|
|
21
|
+
var git_worktree_1 = require("./strategies/git-worktree");
|
|
22
|
+
Object.defineProperty(exports, "GitWorktreeManager", { enumerable: true, get: function () { return git_worktree_1.GitWorktreeManager; } });
|
|
23
|
+
var ephemeral_container_1 = require("./strategies/ephemeral-container");
|
|
24
|
+
Object.defineProperty(exports, "EphemeralContainerManager", { enumerable: true, get: function () { return ephemeral_container_1.EphemeralContainerManager; } });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { WorkspaceManager, WorkspaceRequest } from '../workspace-manager';
|
|
2
|
+
import type { WorkspaceLease, SnapshotRef } from '../../models/workspace';
|
|
3
|
+
export interface ContainerOptions {
|
|
4
|
+
image: string;
|
|
5
|
+
mountPath: string;
|
|
6
|
+
extraEnv?: Record<string, string>;
|
|
7
|
+
/** Gracefully fall back to git_worktree if Docker is unavailable */
|
|
8
|
+
fallback?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class EphemeralContainerManager implements WorkspaceManager {
|
|
11
|
+
private readonly projectRoot;
|
|
12
|
+
private readonly opts;
|
|
13
|
+
private readonly fallbackManager;
|
|
14
|
+
private containerIds;
|
|
15
|
+
private useFallback;
|
|
16
|
+
constructor(projectRoot: string, opts?: ContainerOptions);
|
|
17
|
+
get usingFallback(): boolean;
|
|
18
|
+
allocate(req: WorkspaceRequest): Promise<WorkspaceLease>;
|
|
19
|
+
snapshot(id: string): Promise<SnapshotRef>;
|
|
20
|
+
reset(id: string, snapRef: SnapshotRef): Promise<void>;
|
|
21
|
+
dispose(id: string): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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.EphemeralContainerManager = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const git_worktree_1 = require("./git-worktree");
|
|
10
|
+
function isDockerAvailable() {
|
|
11
|
+
const result = (0, child_process_1.spawnSync)('docker', ['version', '--format', '{{.Server.Version}}'], {
|
|
12
|
+
encoding: 'utf8',
|
|
13
|
+
timeout: 5000,
|
|
14
|
+
});
|
|
15
|
+
return result.status === 0;
|
|
16
|
+
}
|
|
17
|
+
class EphemeralContainerManager {
|
|
18
|
+
constructor(projectRoot, opts = { image: 'node:20-alpine', mountPath: '/workspace', fallback: true }) {
|
|
19
|
+
this.projectRoot = projectRoot;
|
|
20
|
+
this.opts = opts;
|
|
21
|
+
this.containerIds = new Map();
|
|
22
|
+
this.useFallback = false;
|
|
23
|
+
this.fallbackManager = new git_worktree_1.GitWorktreeManager(projectRoot);
|
|
24
|
+
if (!isDockerAvailable()) {
|
|
25
|
+
if (opts.fallback !== false) {
|
|
26
|
+
this.useFallback = true;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error('Docker is not available and fallback is disabled');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
get usingFallback() { return this.useFallback; }
|
|
34
|
+
async allocate(req) {
|
|
35
|
+
if (this.useFallback)
|
|
36
|
+
return this.fallbackManager.allocate(req);
|
|
37
|
+
const wsId = `ws-container-${req.work_item_id}-a${req.attempt_number}`;
|
|
38
|
+
const envArgs = Object.entries(this.opts.extraEnv ?? {}).flatMap(([k, v]) => ['-e', `${k}=${v}`]);
|
|
39
|
+
const result = (0, child_process_1.spawnSync)('docker', [
|
|
40
|
+
'run', '-d',
|
|
41
|
+
'-v', `${this.projectRoot}:${this.opts.mountPath}`,
|
|
42
|
+
'-w', this.opts.mountPath,
|
|
43
|
+
...envArgs,
|
|
44
|
+
this.opts.image,
|
|
45
|
+
'sleep', '3600',
|
|
46
|
+
], { encoding: 'utf8' });
|
|
47
|
+
if (result.status !== 0) {
|
|
48
|
+
if (this.opts.fallback !== false) {
|
|
49
|
+
this.useFallback = true;
|
|
50
|
+
return this.fallbackManager.allocate(req);
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`docker run failed: ${result.stderr}`);
|
|
53
|
+
}
|
|
54
|
+
const containerId = result.stdout.trim().slice(0, 12);
|
|
55
|
+
this.containerIds.set(wsId, containerId);
|
|
56
|
+
return {
|
|
57
|
+
workspace_id: wsId,
|
|
58
|
+
strategy: 'ephemeral_container',
|
|
59
|
+
branch: null,
|
|
60
|
+
base_commit: null,
|
|
61
|
+
root_path: `docker:${containerId}:${this.opts.mountPath}`,
|
|
62
|
+
ttl_minutes: 60,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async snapshot(id) {
|
|
66
|
+
if (this.useFallback)
|
|
67
|
+
return this.fallbackManager.snapshot(id);
|
|
68
|
+
const containerId = this.containerIds.get(id);
|
|
69
|
+
if (!containerId)
|
|
70
|
+
throw new Error(`Container for workspace ${id} not found`);
|
|
71
|
+
const tag = `oxe-snap-${crypto_1.default.randomBytes(4).toString('hex')}`;
|
|
72
|
+
(0, child_process_1.execFileSync)('docker', ['commit', containerId, tag]);
|
|
73
|
+
return {
|
|
74
|
+
snapshot_id: tag,
|
|
75
|
+
workspace_id: id,
|
|
76
|
+
commit: tag,
|
|
77
|
+
created_at: new Date().toISOString(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async reset(id, snapRef) {
|
|
81
|
+
if (this.useFallback)
|
|
82
|
+
return this.fallbackManager.reset(id, snapRef);
|
|
83
|
+
const containerId = this.containerIds.get(id);
|
|
84
|
+
if (!containerId)
|
|
85
|
+
return;
|
|
86
|
+
// Stop current container and start from snapshot
|
|
87
|
+
(0, child_process_1.spawnSync)('docker', ['stop', containerId]);
|
|
88
|
+
(0, child_process_1.spawnSync)('docker', ['rm', containerId]);
|
|
89
|
+
const result = (0, child_process_1.spawnSync)('docker', [
|
|
90
|
+
'run', '-d',
|
|
91
|
+
'-v', `${this.projectRoot}:${this.opts.mountPath}`,
|
|
92
|
+
snapRef.commit,
|
|
93
|
+
'sleep', '3600',
|
|
94
|
+
], { encoding: 'utf8' });
|
|
95
|
+
const newId = result.stdout.trim().slice(0, 12);
|
|
96
|
+
this.containerIds.set(id, newId);
|
|
97
|
+
}
|
|
98
|
+
async dispose(id) {
|
|
99
|
+
if (this.useFallback)
|
|
100
|
+
return this.fallbackManager.dispose(id);
|
|
101
|
+
const containerId = this.containerIds.get(id);
|
|
102
|
+
if (!containerId)
|
|
103
|
+
return;
|
|
104
|
+
(0, child_process_1.spawnSync)('docker', ['stop', containerId], { encoding: 'utf8' });
|
|
105
|
+
(0, child_process_1.spawnSync)('docker', ['rm', containerId], { encoding: 'utf8' });
|
|
106
|
+
this.containerIds.delete(id);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.EphemeralContainerManager = EphemeralContainerManager;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WorkspaceManager, WorkspaceRequest } from '../workspace-manager';
|
|
2
|
+
import type { WorkspaceLease, SnapshotRef } from '../../models/workspace';
|
|
3
|
+
export declare class GitWorktreeManager implements WorkspaceManager {
|
|
4
|
+
private readonly projectRoot;
|
|
5
|
+
private leases;
|
|
6
|
+
constructor(projectRoot: string);
|
|
7
|
+
allocate(req: WorkspaceRequest): Promise<WorkspaceLease>;
|
|
8
|
+
snapshot(id: string): Promise<SnapshotRef>;
|
|
9
|
+
reset(id: string, snapRef: SnapshotRef): Promise<void>;
|
|
10
|
+
dispose(id: string): Promise<void>;
|
|
11
|
+
private git;
|
|
12
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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.GitWorktreeManager = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
+
class GitWorktreeManager {
|
|
12
|
+
constructor(projectRoot) {
|
|
13
|
+
this.projectRoot = projectRoot;
|
|
14
|
+
this.leases = new Map();
|
|
15
|
+
}
|
|
16
|
+
async allocate(req) {
|
|
17
|
+
const wsId = `ws-${req.work_item_id}-a${req.attempt_number}`;
|
|
18
|
+
const branch = `oxe/${req.work_item_id}-attempt${req.attempt_number}`;
|
|
19
|
+
const worktreePath = path_1.default.join(this.projectRoot, '.oxe', 'workspaces', wsId);
|
|
20
|
+
const baseCommit = this.git(['rev-parse', 'HEAD']).trim();
|
|
21
|
+
fs_1.default.mkdirSync(path_1.default.dirname(worktreePath), { recursive: true });
|
|
22
|
+
// Create worktree on a new branch starting from HEAD
|
|
23
|
+
this.git(['worktree', 'add', worktreePath, '-b', branch]);
|
|
24
|
+
const lease = {
|
|
25
|
+
workspace_id: wsId,
|
|
26
|
+
strategy: 'git_worktree',
|
|
27
|
+
branch,
|
|
28
|
+
base_commit: baseCommit,
|
|
29
|
+
root_path: worktreePath,
|
|
30
|
+
ttl_minutes: 45,
|
|
31
|
+
};
|
|
32
|
+
this.leases.set(wsId, lease);
|
|
33
|
+
return lease;
|
|
34
|
+
}
|
|
35
|
+
async snapshot(id) {
|
|
36
|
+
const lease = this.leases.get(id);
|
|
37
|
+
if (!lease || !lease.root_path)
|
|
38
|
+
throw new Error(`Workspace ${id} not found`);
|
|
39
|
+
const commit = this.git(['rev-parse', 'HEAD'], lease.root_path).trim();
|
|
40
|
+
return {
|
|
41
|
+
snapshot_id: `snap-${crypto_1.default.randomBytes(4).toString('hex')}`,
|
|
42
|
+
workspace_id: id,
|
|
43
|
+
commit,
|
|
44
|
+
created_at: new Date().toISOString(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async reset(id, snapRef) {
|
|
48
|
+
const lease = this.leases.get(id);
|
|
49
|
+
if (!lease)
|
|
50
|
+
return;
|
|
51
|
+
this.git(['reset', '--hard', snapRef.commit], lease.root_path);
|
|
52
|
+
}
|
|
53
|
+
async dispose(id) {
|
|
54
|
+
const lease = this.leases.get(id);
|
|
55
|
+
if (!lease)
|
|
56
|
+
return;
|
|
57
|
+
try {
|
|
58
|
+
this.git(['worktree', 'remove', lease.root_path, '--force']);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// worktree may already be gone
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
if (lease.branch)
|
|
65
|
+
this.git(['branch', '-D', lease.branch]);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// branch may already be deleted
|
|
69
|
+
}
|
|
70
|
+
this.leases.delete(id);
|
|
71
|
+
}
|
|
72
|
+
git(args, cwd) {
|
|
73
|
+
return (0, child_process_1.execFileSync)('git', args, {
|
|
74
|
+
cwd: cwd ?? this.projectRoot,
|
|
75
|
+
encoding: 'utf8',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.GitWorktreeManager = GitWorktreeManager;
|