oxe-cc 1.14.0 → 1.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +177 -177
- package/.github/dependabot.yml +31 -0
- package/.github/workflows/ci.yml +115 -9
- package/.github/workflows/release.yml +72 -46
- package/AGENTS.md +97 -97
- package/CHANGELOG.md +263 -0
- package/README.md +474 -537
- package/assets/readme-banner.svg +19 -19
- package/bin/banner.txt +13 -13
- package/bin/lib/oxe-agent-install.cjs +401 -386
- package/bin/lib/oxe-artifact-catalog.cjs +376 -0
- package/bin/lib/oxe-azure.cjs +1445 -1445
- package/bin/lib/oxe-budget.cjs +117 -0
- package/bin/lib/oxe-change.cjs +230 -0
- package/bin/lib/oxe-command-registry.cjs +31 -0
- package/bin/lib/oxe-commit-convention.cjs +85 -0
- package/bin/lib/oxe-context-engine.cjs +863 -863
- package/bin/lib/oxe-core-command-handlers.cjs +82 -0
- package/bin/lib/oxe-criterion-coverage.cjs +58 -0
- package/bin/lib/oxe-dashboard.cjs +597 -597
- package/bin/lib/oxe-dossier.cjs +281 -0
- package/bin/lib/oxe-install-resolve.cjs +134 -106
- package/bin/lib/oxe-manifest.cjs +104 -104
- package/bin/lib/oxe-npm-version.cjs +66 -64
- package/bin/lib/oxe-operational.cjs +4484 -2676
- package/bin/lib/oxe-phase-gates.cjs +280 -0
- package/bin/lib/oxe-plan-json.cjs +433 -0
- package/bin/lib/oxe-plugin-cli.cjs +95 -0
- package/bin/lib/oxe-plugins.cjs +432 -341
- package/bin/lib/oxe-process.cjs +67 -0
- package/bin/lib/oxe-program.cjs +205 -0
- package/bin/lib/oxe-project-env.cjs +178 -0
- package/bin/lib/oxe-project-health.cjs +127 -21
- package/bin/lib/oxe-rationality.cjs +73 -49
- package/bin/lib/oxe-release.cjs +42 -0
- package/bin/lib/oxe-repo-rules.cjs +108 -0
- package/bin/lib/oxe-runtime-semantics.cjs +446 -447
- package/bin/lib/oxe-scorecard.cjs +164 -0
- package/bin/lib/oxe-security.cjs +289 -289
- package/bin/lib/oxe-spike.cjs +98 -0
- package/bin/lib/oxe-verify-dryrun.cjs +152 -0
- package/bin/lib/oxe-workflows.cjs +145 -145
- package/bin/oxe-cc.js +6281 -5975
- package/docs/INTEGRATION.md +32 -2
- package/docs/QUALITY-GATES.md +46 -0
- package/docs/RELEASE-READINESS.md +31 -5
- package/docs/RUNTIME-SMOKE-MATRIX.md +2 -0
- package/docs/oxespace-1.5/BACKLOG.md +273 -0
- package/docs/oxevoice/BACKLOG.md +244 -0
- package/lib/runtime/compiler/graph-compiler.d.ts +13 -0
- package/lib/runtime/compiler/graph-compiler.js +40 -3
- package/lib/runtime/delivery/promotion-pipeline.js +6 -2
- package/lib/runtime/events/catalog.d.ts +1 -1
- package/lib/runtime/events/catalog.js +11 -0
- package/lib/runtime/executor/adapters/claude-cli.d.ts +63 -0
- package/lib/runtime/executor/adapters/claude-cli.js +250 -0
- package/lib/runtime/executor/adapters/http-openai.d.ts +9 -0
- package/lib/runtime/executor/adapters/http-openai.js +18 -0
- package/lib/runtime/executor/adapters/registry.d.ts +13 -0
- package/lib/runtime/executor/adapters/registry.js +29 -0
- package/lib/runtime/executor/adapters/types.d.ts +21 -0
- package/lib/runtime/executor/adapters/types.js +2 -0
- package/lib/runtime/executor/built-in-tools.d.ts +8 -0
- package/lib/runtime/executor/built-in-tools.js +40 -9
- package/lib/runtime/executor/index.d.ts +12 -2
- package/lib/runtime/executor/index.js +28 -1
- package/lib/runtime/executor/llm-task-executor.d.ts +35 -2
- package/lib/runtime/executor/llm-task-executor.js +97 -21
- package/lib/runtime/executor/node-context.d.ts +83 -0
- package/lib/runtime/executor/node-context.js +116 -0
- package/lib/runtime/executor/node-prompt-builder.d.ts +2 -0
- package/lib/runtime/executor/node-prompt-builder.js +2 -0
- package/lib/runtime/executor/shell-argv.d.ts +30 -0
- package/lib/runtime/executor/shell-argv.js +57 -0
- package/lib/runtime/executor/stream-completion.d.ts +11 -0
- package/lib/runtime/executor/stream-completion.js +10 -1
- package/lib/runtime/index.d.ts +5 -2
- package/lib/runtime/index.js +8 -1
- package/lib/runtime/program/index.d.ts +1 -0
- package/lib/runtime/program/index.js +17 -0
- package/lib/runtime/program/program-model.d.ts +74 -0
- package/lib/runtime/program/program-model.js +195 -0
- package/lib/runtime/projection/projection-engine.d.ts +10 -1
- package/lib/runtime/projection/projection-engine.js +25 -1
- package/lib/runtime/reducers/run-state-reducer.js +5 -0
- package/lib/runtime/scheduler/run-journal.d.ts +19 -1
- package/lib/runtime/scheduler/run-journal.js +40 -1
- package/lib/runtime/scheduler/scheduler.d.ts +30 -0
- package/lib/runtime/scheduler/scheduler.js +195 -19
- package/lib/runtime/verification/contract-exports.d.ts +24 -0
- package/lib/runtime/verification/contract-exports.js +201 -0
- package/lib/runtime/verification/index.d.ts +1 -0
- package/lib/runtime/verification/index.js +1 -0
- package/lib/runtime/verification/test-report-parsers.d.ts +37 -0
- package/lib/runtime/verification/test-report-parsers.js +180 -0
- package/lib/runtime/verification/verification-compiler.d.ts +67 -1
- package/lib/runtime/verification/verification-compiler.js +302 -25
- package/lib/runtime/verification/verification-manifest.d.ts +10 -0
- package/lib/runtime/verification/verification-manifest.js +18 -3
- package/lib/runtime/workspace/strategies/git-worktree.d.ts +9 -0
- package/lib/runtime/workspace/strategies/git-worktree.js +81 -0
- package/lib/sdk/README.md +61 -61
- package/lib/sdk/index.cjs +815 -792
- package/lib/sdk/index.d.ts +982 -913
- package/lib/sdk/index.types.ts +933 -0
- package/oxe/schemas/plan-agents.schema.json +122 -122
- package/oxe/schemas/plan.schema.json +85 -0
- package/oxe/templates/ACTIVE-RUN.template.json +32 -32
- package/oxe/templates/CAPABILITIES.template.md +7 -7
- package/oxe/templates/CAPABILITY.template.md +45 -45
- package/oxe/templates/CHECKPOINT.template.md +37 -37
- package/oxe/templates/CHECKPOINTS.template.md +7 -7
- package/oxe/templates/CODEBASE-DELTA.template.md +33 -33
- package/oxe/templates/CONFIG.md +105 -105
- package/oxe/templates/DISCUSS.template.md +44 -44
- package/oxe/templates/DOCS_BROWNFIELD_LAYOUT.md +55 -55
- package/oxe/templates/EXECUTION-RUNTIME.template.md +68 -68
- package/oxe/templates/FIXTURE-PACK.template.json +23 -23
- package/oxe/templates/FIXTURE-PACK.template.md +11 -11
- package/oxe/templates/GIT_HOOKS_OXE.md +52 -52
- package/oxe/templates/HYPOTHESES.template.md +33 -33
- package/oxe/templates/IMPLEMENTATION-PACK.template.json +42 -42
- package/oxe/templates/IMPLEMENTATION-PACK.template.md +16 -16
- package/oxe/templates/INVESTIGATION.template.md +38 -38
- package/oxe/templates/LESSONS-METRICS.template.json +13 -13
- package/oxe/templates/LESSONS.template.md +43 -43
- package/oxe/templates/MEMORY.template.md +49 -49
- package/oxe/templates/MILESTONES.template.md +17 -17
- package/oxe/templates/NOTES.template.md +16 -16
- package/oxe/templates/OBSERVATIONS.template.md +18 -18
- package/oxe/templates/PLAN-REVIEW.template.md +31 -31
- package/oxe/templates/PLAN.template.md +66 -66
- package/oxe/templates/PLUGINS.md +108 -101
- package/oxe/templates/REFERENCE-ANCHORS.template.md +9 -9
- package/oxe/templates/RESEARCH.template.md +57 -57
- package/oxe/templates/RESUME.template.md +49 -49
- package/oxe/templates/ROADMAP.template.md +44 -44
- package/oxe/templates/SECURITY.template.md +72 -72
- package/oxe/templates/SESSION.template.md +34 -34
- package/oxe/templates/SKILL.template.md +26 -26
- package/oxe/templates/SPEC.template.md +54 -54
- package/oxe/templates/STATE-REFERENCE.md +125 -0
- package/oxe/templates/STATE.md +30 -140
- package/oxe/templates/WORKFLOW_AUTHORING.md +93 -93
- package/oxe/templates/config.template.json +38 -38
- package/oxe/templates/plan-agent-messages-README.template.md +9 -9
- package/oxe/templates/plan-agents.template.json +30 -30
- package/oxe/templates/quick-agents.template.json +24 -24
- package/oxe/workflows/ask.md +96 -96
- package/oxe/workflows/capabilities.md +25 -25
- package/oxe/workflows/checkpoint.md +37 -37
- package/oxe/workflows/compact.md +44 -44
- package/oxe/workflows/dashboard.md +33 -33
- package/oxe/workflows/debug.md +34 -34
- package/oxe/workflows/discuss.md +86 -86
- package/oxe/workflows/execute.md +255 -255
- package/oxe/workflows/forensics.md +48 -48
- package/oxe/workflows/help.md +355 -353
- package/oxe/workflows/loop.md +67 -67
- package/oxe/workflows/milestone.md +95 -95
- package/oxe/workflows/next.md +45 -45
- package/oxe/workflows/obs.md +167 -167
- package/oxe/workflows/oxe.md +150 -149
- package/oxe/workflows/plan-agent.md +143 -143
- package/oxe/workflows/plan.md +525 -523
- package/oxe/workflows/project.md +55 -55
- package/oxe/workflows/quick.md +185 -185
- package/oxe/workflows/references/adaptive-discovery.md +27 -27
- package/oxe/workflows/references/flow-robustness-contract.md +80 -80
- package/oxe/workflows/references/legacy-brownfield.md +136 -136
- package/oxe/workflows/references/plan-agent-chat-protocol.md +99 -99
- package/oxe/workflows/references/plan-json-acceptance-program.md +143 -0
- package/oxe/workflows/references/reasoning-discovery.md +28 -28
- package/oxe/workflows/references/reasoning-execution.md +29 -29
- package/oxe/workflows/references/reasoning-planning.md +32 -32
- package/oxe/workflows/references/reasoning-review.md +29 -29
- package/oxe/workflows/references/reasoning-status.md +24 -24
- package/oxe/workflows/references/robustness-elevation.md +295 -295
- package/oxe/workflows/references/session-path-resolution.md +71 -71
- package/oxe/workflows/research.md +66 -66
- package/oxe/workflows/retro.md +117 -117
- package/oxe/workflows/review-pr.md +53 -53
- package/oxe/workflows/route.md +32 -32
- package/oxe/workflows/security.md +67 -67
- package/oxe/workflows/session.md +213 -213
- package/oxe/workflows/ship.md +142 -142
- package/oxe/workflows/skill.md +44 -44
- package/oxe/workflows/spec.md +569 -566
- package/oxe/workflows/ui-review.md +32 -32
- package/oxe/workflows/ui-spec.md +25 -25
- package/oxe/workflows/update.md +35 -35
- package/oxe/workflows/validate-gaps.md +45 -45
- package/oxe/workflows/verify-audit.md +73 -73
- package/oxe/workflows/verify.md +247 -244
- package/oxe/workflows/workflow-authoring.md +34 -34
- package/oxe/workflows/workstream.md +97 -97
- package/package.json +35 -11
- package/packages/runtime/package.json +1 -1
- package/packages/runtime/src/audit/audit-trail.ts +243 -243
- package/packages/runtime/src/audit/index.ts +2 -2
- package/packages/runtime/src/audit/policy-pack.ts +62 -62
- package/packages/runtime/src/compiler/graph-compiler.ts +336 -285
- package/packages/runtime/src/compiler/index.ts +1 -1
- package/packages/runtime/src/context/context-pack-builder.ts +339 -339
- package/packages/runtime/src/context/context-pack-store.ts +197 -197
- package/packages/runtime/src/context/context-profiles.ts +60 -60
- package/packages/runtime/src/context/index.ts +3 -3
- package/packages/runtime/src/decision/decision-engine.ts +174 -174
- package/packages/runtime/src/decision/decision-memo.ts +211 -211
- package/packages/runtime/src/decision/index.ts +2 -2
- package/packages/runtime/src/delivery/branch-manager.ts +91 -91
- package/packages/runtime/src/delivery/ci-checks.ts +285 -285
- package/packages/runtime/src/delivery/delivery-records.ts +75 -75
- package/packages/runtime/src/delivery/index.ts +5 -5
- package/packages/runtime/src/delivery/pr-manager.ts +112 -112
- package/packages/runtime/src/delivery/promotion-pipeline.ts +342 -334
- package/packages/runtime/src/events/bus.ts +92 -92
- package/packages/runtime/src/events/catalog.ts +45 -34
- package/packages/runtime/src/events/envelope.ts +14 -14
- package/packages/runtime/src/events/index.ts +3 -3
- package/packages/runtime/src/evidence/evidence-store.ts +128 -128
- package/packages/runtime/src/evidence/index.ts +1 -1
- package/packages/runtime/src/executor/adapters/claude-cli.ts +285 -0
- package/packages/runtime/src/executor/adapters/http-openai.ts +16 -0
- package/packages/runtime/src/executor/adapters/registry.ts +33 -0
- package/packages/runtime/src/executor/adapters/types.ts +24 -0
- package/packages/runtime/src/executor/built-in-tools.ts +36 -8
- package/packages/runtime/src/executor/index.ts +12 -2
- package/packages/runtime/src/executor/llm-task-executor.ts +125 -25
- package/packages/runtime/src/executor/node-context.ts +210 -0
- package/packages/runtime/src/executor/node-prompt-builder.ts +5 -0
- package/packages/runtime/src/executor/shell-argv.ts +66 -0
- package/packages/runtime/src/executor/stream-completion.ts +16 -1
- package/packages/runtime/src/gate/gate-manager.ts +289 -289
- package/packages/runtime/src/gate/index.ts +1 -1
- package/packages/runtime/src/index.ts +54 -44
- package/packages/runtime/src/models/attempt.ts +19 -19
- package/packages/runtime/src/models/evidence.ts +21 -21
- package/packages/runtime/src/models/gate-decision.ts +25 -25
- package/packages/runtime/src/models/index.ts +8 -8
- package/packages/runtime/src/models/run.ts +24 -24
- package/packages/runtime/src/models/session.ts +11 -11
- package/packages/runtime/src/models/verification-result.ts +10 -10
- package/packages/runtime/src/models/work-item.ts +25 -25
- package/packages/runtime/src/models/workspace.ts +31 -31
- package/packages/runtime/src/plugins/capability-adapter.ts +313 -313
- package/packages/runtime/src/plugins/capability-matrix.ts +126 -126
- package/packages/runtime/src/plugins/index.ts +5 -5
- package/packages/runtime/src/plugins/plugin-abi.ts +106 -106
- package/packages/runtime/src/plugins/plugin-manifest.ts +118 -118
- package/packages/runtime/src/plugins/plugin-registry.ts +241 -241
- package/packages/runtime/src/policy/index.ts +1 -1
- package/packages/runtime/src/policy/policy-engine.ts +330 -330
- package/packages/runtime/src/program/index.ts +1 -0
- package/packages/runtime/src/program/program-model.ts +233 -0
- package/packages/runtime/src/projection/index.ts +1 -1
- package/packages/runtime/src/projection/projection-engine.ts +361 -328
- package/packages/runtime/src/reducers/debug-reducer.ts +36 -36
- package/packages/runtime/src/reducers/index.ts +2 -2
- package/packages/runtime/src/reducers/run-state-reducer.ts +329 -326
- package/packages/runtime/src/scheduler/agent-registry.ts +132 -132
- package/packages/runtime/src/scheduler/agent-roles.ts +109 -109
- package/packages/runtime/src/scheduler/index.ts +4 -4
- package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +291 -291
- package/packages/runtime/src/scheduler/run-journal.ts +105 -62
- package/packages/runtime/src/scheduler/scheduler.ts +1144 -938
- package/packages/runtime/src/verification/contract-exports.ts +203 -0
- package/packages/runtime/src/verification/index.ts +3 -2
- package/packages/runtime/src/verification/test-report-parsers.ts +198 -0
- package/packages/runtime/src/verification/verification-compiler.ts +766 -438
- package/packages/runtime/src/verification/verification-manifest.ts +281 -256
- package/packages/runtime/src/workspace/index.ts +5 -5
- package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +126 -126
- package/packages/runtime/src/workspace/strategies/git-worktree.ts +126 -63
- package/packages/runtime/src/workspace/strategies/inplace.ts +38 -38
- package/packages/runtime/src/workspace/workspace-manager.ts +16 -16
- package/packages/runtime/tsconfig.json +23 -17
- package/vscode-extension/.vscodeignore +9 -7
- package/vscode-extension/package.json +10 -2
- package/vscode-extension/src/extension.js +320 -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
- package/docs/oxe-artifact-map.html +0 -1172
|
@@ -3,6 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VERIFICATION_COMPILER_VERSION = exports.SHELL_COMMAND_RE = void 0;
|
|
7
|
+
exports.sha256File = sha256File;
|
|
8
|
+
exports.stripQuotedArgs = stripQuotedArgs;
|
|
9
|
+
exports.looksLikeShellCommand = looksLikeShellCommand;
|
|
10
|
+
exports.extractCommandFromHowToVerify = extractCommandFromHowToVerify;
|
|
6
11
|
exports.compile = compile;
|
|
7
12
|
exports.runCheck = runCheck;
|
|
8
13
|
exports.runSuite = runSuite;
|
|
@@ -10,8 +15,28 @@ exports.executeSuite = executeSuite;
|
|
|
10
15
|
exports.summarizeSuite = summarizeSuite;
|
|
11
16
|
exports.verifyRun = verifyRun;
|
|
12
17
|
const crypto_1 = __importDefault(require("crypto"));
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
13
20
|
const child_process_1 = require("child_process");
|
|
21
|
+
const test_report_parsers_1 = require("./test-report-parsers");
|
|
22
|
+
const shell_argv_1 = require("../executor/shell-argv");
|
|
23
|
+
const contract_exports_1 = require("./contract-exports");
|
|
14
24
|
const verification_manifest_1 = require("./verification-manifest");
|
|
25
|
+
function sha256File(absPath) {
|
|
26
|
+
try {
|
|
27
|
+
return crypto_1.default.createHash('sha256').update(fs_1.default.readFileSync(absPath)).digest('hex');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Drop quoted arguments so only invoked programs are classified: `node -e "…'node --test'…"`
|
|
35
|
+
* checks package.json, it does not run a test runner.
|
|
36
|
+
*/
|
|
37
|
+
function stripQuotedArgs(command) {
|
|
38
|
+
return command.replace(/"(?:\\.|[^"\\])*"|'[^']*'/g, '""');
|
|
39
|
+
}
|
|
15
40
|
function inferCheckType(howToVerify) {
|
|
16
41
|
const v = howToVerify.toLowerCase();
|
|
17
42
|
if (v.includes('npm test') || v.includes('jest') || v.includes('vitest') || v.includes('node --test'))
|
|
@@ -35,6 +60,28 @@ function inferEvidenceType(checkType) {
|
|
|
35
60
|
default: return 'stdout';
|
|
36
61
|
}
|
|
37
62
|
}
|
|
63
|
+
exports.SHELL_COMMAND_RE = /^(npm|npx|pnpm|yarn|node|deno|bun|python3?|pytest|go|cargo|make|dotnet|mvn|gradle|bash|sh|curl|git|eslint|tsc|jest|vitest|mocha|oxe-cc|oxe|docker)(\s|$)/i;
|
|
64
|
+
function looksLikeShellCommand(text) {
|
|
65
|
+
return exports.SHELL_COMMAND_RE.test(String(text || '').trim());
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Turn a SPEC "Como verificar" cell into an executable command, or null when it is prose.
|
|
69
|
+
* Only backtick spans that look like commands count; path-like spans (`test/api.test.js`)
|
|
70
|
+
* and free text are never executed.
|
|
71
|
+
*/
|
|
72
|
+
function extractCommandFromHowToVerify(howToVerify) {
|
|
73
|
+
const text = String(howToVerify || '').trim();
|
|
74
|
+
if (!text || text.startsWith('#'))
|
|
75
|
+
return null;
|
|
76
|
+
const spans = [...text.matchAll(/`([^`]+)`/g)].map((m) => m[1].trim()).filter(Boolean);
|
|
77
|
+
if (spans.length > 0) {
|
|
78
|
+
const commands = [...new Set(spans.filter(looksLikeShellCommand))];
|
|
79
|
+
return commands.length ? commands.join(' && ') : null;
|
|
80
|
+
}
|
|
81
|
+
return looksLikeShellCommand(text) ? text : null;
|
|
82
|
+
}
|
|
83
|
+
/** Bump when the rules that turn SPEC/PLAN into checks change (invalidates persisted suites). */
|
|
84
|
+
exports.VERIFICATION_COMPILER_VERSION = '1.20.0';
|
|
38
85
|
function compile(spec, plan) {
|
|
39
86
|
const checks = [];
|
|
40
87
|
const seenRefs = new Set();
|
|
@@ -42,12 +89,19 @@ function compile(spec, plan) {
|
|
|
42
89
|
for (const criterion of spec.criteria) {
|
|
43
90
|
// Find the verify command from the task that references this criterion
|
|
44
91
|
const task = plan.tasks.find((t) => t.aceite.includes(criterion.id));
|
|
45
|
-
|
|
46
|
-
|
|
92
|
+
// A criterion the SPEC declares manual (UAT, manual check) is never "proven" by some task's verify command:
|
|
93
|
+
// OxeVoice F1's A8 (real dictation, UAT) passed on a doc-exists check of the task that wrote the UAT script.
|
|
94
|
+
const declaredManual = MANUAL_CRITERION_RE.test(String(criterion.howToVerify || ''))
|
|
95
|
+
&& !extractCommandFromHowToVerify(criterion.howToVerify);
|
|
96
|
+
const command = declaredManual ? null : (task?.verifyCommand ?? extractCommandFromHowToVerify(criterion.howToVerify));
|
|
97
|
+
// Prose that cannot be executed is a manual criterion, not a shell command. The type comes from
|
|
98
|
+
// the command that actually runs: prose saying "npm test" must not demand a test report from a
|
|
99
|
+
// task command that never runs tests (false red seen in the 1.17 linkly benchmark).
|
|
100
|
+
const type = command ? inferCheckType(stripQuotedArgs(command)) : 'manual';
|
|
47
101
|
checks.push({
|
|
48
102
|
id: `check-${criterion.id.toLowerCase()}`,
|
|
49
103
|
type,
|
|
50
|
-
command
|
|
104
|
+
command,
|
|
51
105
|
evidence_type_expected: inferEvidenceType(type),
|
|
52
106
|
acceptance_ref: criterion.id,
|
|
53
107
|
description: criterion.criterion,
|
|
@@ -63,21 +117,120 @@ function compile(spec, plan) {
|
|
|
63
117
|
continue;
|
|
64
118
|
checks.push({
|
|
65
119
|
id: `check-task-${task.id.toLowerCase()}`,
|
|
66
|
-
type: inferCheckType(task.verifyCommand),
|
|
120
|
+
type: inferCheckType(stripQuotedArgs(task.verifyCommand)),
|
|
67
121
|
command: task.verifyCommand,
|
|
68
122
|
evidence_type_expected: 'stdout',
|
|
69
123
|
acceptance_ref: uncovered[0] ?? null,
|
|
70
124
|
description: `Verify command for task ${task.id}`,
|
|
71
125
|
});
|
|
72
126
|
}
|
|
127
|
+
// The IMPLEMENTATION-PACK contract is checked, not just recorded: a task that skipped a contracted
|
|
128
|
+
// file must not pass because its own verify command happened to exit 0 (T3 in the 1.17 benchmark).
|
|
129
|
+
for (const task of plan.tasks) {
|
|
130
|
+
const files = [...new Set(task.filesExist ?? [])];
|
|
131
|
+
const exportsExpected = dedupeExports(task.exportsExpected ?? []);
|
|
132
|
+
if (files.length === 0 && exportsExpected.length === 0)
|
|
133
|
+
continue;
|
|
134
|
+
checks.push({
|
|
135
|
+
id: `check-pack-${task.id.toLowerCase()}`,
|
|
136
|
+
type: 'contract',
|
|
137
|
+
command: null,
|
|
138
|
+
evidence_type_expected: 'stdout',
|
|
139
|
+
acceptance_ref: null,
|
|
140
|
+
description: `Implementation pack contract for task ${task.id}`,
|
|
141
|
+
files_exist: files,
|
|
142
|
+
...(exportsExpected.length ? { exports_expected: exportsExpected } : {}),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// Plan-owned acceptance tests: the proof of A* is written before execution and frozen.
|
|
146
|
+
for (const entry of plan.acceptanceTests ?? []) {
|
|
147
|
+
if (!entry || !entry.command || !Array.isArray(entry.files) || entry.files.length === 0)
|
|
148
|
+
continue;
|
|
149
|
+
const type = inferCheckType(stripQuotedArgs(entry.command));
|
|
150
|
+
checks.push({
|
|
151
|
+
id: `check-accept-${String(entry.id || entry.criterion).toLowerCase()}`,
|
|
152
|
+
type,
|
|
153
|
+
command: entry.command,
|
|
154
|
+
evidence_type_expected: inferEvidenceType(type),
|
|
155
|
+
acceptance_ref: entry.criterion || null,
|
|
156
|
+
description: `Teste de aceite congelado de ${entry.criterion || entry.id}`,
|
|
157
|
+
frozen_files: entry.files.map((f) => ({ path: f.path, sha256: f.sha256 ?? null })),
|
|
158
|
+
...(Array.isArray(entry.proves) && entry.proves.length ? { proves: [...entry.proves] } : {}),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
73
161
|
return {
|
|
74
162
|
checks,
|
|
75
163
|
compiled_at: new Date().toISOString(),
|
|
76
164
|
spec_hash: hashObject(spec),
|
|
77
|
-
|
|
165
|
+
// OXB-011: the compiler's own version is part of the cache key — a suite compiled by older rules is stale.
|
|
166
|
+
plan_hash: hashObject({ plan, compiler: exports.VERIFICATION_COMPILER_VERSION }),
|
|
78
167
|
};
|
|
79
168
|
}
|
|
80
169
|
async function runCheck(check, cwd, timeoutMs = 60000) {
|
|
170
|
+
if (typeof check.timeout_ms === 'number' && check.timeout_ms > 0)
|
|
171
|
+
timeoutMs = check.timeout_ms;
|
|
172
|
+
const frozen = check.frozen_files ?? [];
|
|
173
|
+
if (frozen.length > 0) {
|
|
174
|
+
const missing = frozen.filter((f) => !fs_1.default.existsSync(path_1.default.resolve(cwd, f.path)));
|
|
175
|
+
const tampered = missing.length > 0
|
|
176
|
+
? []
|
|
177
|
+
: frozen.filter((f) => f.sha256 !== null && sha256File(path_1.default.resolve(cwd, f.path)) !== f.sha256);
|
|
178
|
+
const unlocked = frozen.filter((f) => f.sha256 === null);
|
|
179
|
+
if (missing.length > 0 || tampered.length > 0 || unlocked.length > 0) {
|
|
180
|
+
return {
|
|
181
|
+
check_id: check.id,
|
|
182
|
+
acceptance_ref: check.acceptance_ref,
|
|
183
|
+
status: 'fail',
|
|
184
|
+
stdout: '',
|
|
185
|
+
stderr: '',
|
|
186
|
+
exit_code: null,
|
|
187
|
+
duration_ms: 0,
|
|
188
|
+
error: missing.length > 0
|
|
189
|
+
? `acceptance_missing: ${missing.map((f) => f.path).join(', ')}`
|
|
190
|
+
: tampered.length > 0
|
|
191
|
+
? `acceptance_tampered: ${tampered.map((f) => f.path).join(', ')}`
|
|
192
|
+
: `acceptance_not_frozen: ${unlocked.map((f) => f.path).join(', ')} (não existia no compile)`,
|
|
193
|
+
tests_executed: null,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const contracted = check.files_exist ?? [];
|
|
198
|
+
const exportsExpected = check.exports_expected ?? [];
|
|
199
|
+
if (contracted.length > 0 || exportsExpected.length > 0) {
|
|
200
|
+
const absent = contracted.filter((file) => !fs_1.default.existsSync(path_1.default.resolve(cwd, file)));
|
|
201
|
+
const leaks = absent.length > 0 ? [] : contracted.filter((file) => referencesOxeInternals(path_1.default.resolve(cwd, file)));
|
|
202
|
+
const exportOutcome = absent.length > 0 || leaks.length > 0
|
|
203
|
+
? { missing: [], unsupported: [] }
|
|
204
|
+
: (0, contract_exports_1.checkExpectedExports)(cwd, exportsExpected);
|
|
205
|
+
const failed = absent.length > 0 || leaks.length > 0 || exportOutcome.missing.length > 0;
|
|
206
|
+
if (failed || !check.command) {
|
|
207
|
+
const okLines = [];
|
|
208
|
+
if (contracted.length)
|
|
209
|
+
okLines.push(`files_exist ok: ${contracted.join(', ')}`);
|
|
210
|
+
const checkedExports = exportsExpected.filter((e) => !exportOutcome.unsupported.includes(e.file));
|
|
211
|
+
if (checkedExports.length)
|
|
212
|
+
okLines.push(`exports ok: ${checkedExports.map((e) => `${e.file}#${e.name}`).join(', ')}`);
|
|
213
|
+
if (exportOutcome.unsupported.length)
|
|
214
|
+
okLines.push(`exports_unchecked (linguagem não suportada): ${exportOutcome.unsupported.join(', ')}`);
|
|
215
|
+
return {
|
|
216
|
+
check_id: check.id,
|
|
217
|
+
acceptance_ref: check.acceptance_ref,
|
|
218
|
+
status: failed ? 'fail' : 'pass',
|
|
219
|
+
stdout: failed ? '' : `${okLines.join('\n')}\n`,
|
|
220
|
+
stderr: '',
|
|
221
|
+
exit_code: null,
|
|
222
|
+
duration_ms: 0,
|
|
223
|
+
error: absent.length > 0
|
|
224
|
+
? `files_missing: ${absent.join(', ')}`
|
|
225
|
+
: leaks.length > 0
|
|
226
|
+
? `oxe_internal_reference: ${leaks.join(', ')}`
|
|
227
|
+
: exportOutcome.missing.length > 0
|
|
228
|
+
? `exports_missing: ${exportOutcome.missing.map((e) => `${e.file}#${e.name}`).join(', ')}`
|
|
229
|
+
: null,
|
|
230
|
+
tests_executed: null,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
81
234
|
if (!check.command) {
|
|
82
235
|
return {
|
|
83
236
|
check_id: check.id,
|
|
@@ -88,33 +241,78 @@ async function runCheck(check, cwd, timeoutMs = 60000) {
|
|
|
88
241
|
exit_code: null,
|
|
89
242
|
duration_ms: 0,
|
|
90
243
|
error: null,
|
|
244
|
+
skip_reason: check.type === 'manual' ? 'needs_structured_check' : 'no_command',
|
|
245
|
+
tests_executed: null,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
// A verify command that names a test file which does not exist cannot have verified it,
|
|
249
|
+
// whatever the runner's exit code says.
|
|
250
|
+
const missingFiles = (0, test_report_parsers_1.extractTestFileArgs)(check.command).filter((file) => !fs_1.default.existsSync(path_1.default.resolve(cwd, file)));
|
|
251
|
+
if (missingFiles.length > 0) {
|
|
252
|
+
return {
|
|
253
|
+
check_id: check.id,
|
|
254
|
+
acceptance_ref: check.acceptance_ref,
|
|
255
|
+
status: 'fail',
|
|
256
|
+
stdout: '',
|
|
257
|
+
stderr: '',
|
|
258
|
+
exit_code: null,
|
|
259
|
+
duration_ms: 0,
|
|
260
|
+
error: `test_file_missing: ${missingFiles.join(', ')}`,
|
|
261
|
+
tests_executed: 0,
|
|
91
262
|
};
|
|
92
263
|
}
|
|
93
264
|
const start = Date.now();
|
|
94
265
|
try {
|
|
95
|
-
// Use shell so the full command string is interpreted (handles quotes, &&, node -e "...")
|
|
96
|
-
|
|
97
|
-
const shell =
|
|
98
|
-
const
|
|
99
|
-
const result = (0, child_process_1.spawnSync)(shell, shellArgs, {
|
|
266
|
+
// Use a shell so the full command string is interpreted (handles quotes, &&, node -e "...").
|
|
267
|
+
// The child never inherits node:test context: it would emit a serialized protocol, not TAP.
|
|
268
|
+
const shell = (0, shell_argv_1.shellInvocation)(check.command);
|
|
269
|
+
const result = (0, child_process_1.spawnSync)(shell.file, shell.args, {
|
|
100
270
|
cwd,
|
|
271
|
+
env: (0, shell_argv_1.childProcessEnv)(),
|
|
101
272
|
encoding: 'utf8',
|
|
102
273
|
timeout: timeoutMs,
|
|
103
274
|
maxBuffer: 2 * 1024 * 1024,
|
|
104
|
-
|
|
105
|
-
windowsVerbatimArguments: isWin,
|
|
275
|
+
windowsVerbatimArguments: shell.windowsVerbatimArguments,
|
|
106
276
|
});
|
|
107
277
|
const duration_ms = Date.now() - start;
|
|
108
|
-
const
|
|
278
|
+
const stdout = result.stdout ?? '';
|
|
279
|
+
const stderr = result.stderr ?? '';
|
|
280
|
+
const report = (0, test_report_parsers_1.parseTestReport)(`${stdout}\n${stderr}`);
|
|
281
|
+
let status = result.status === 0 ? 'pass' : 'fail';
|
|
282
|
+
let error = result.error ? String(result.error) : null;
|
|
283
|
+
// Exit code 0 is not proof: `node --test` exits 0 when a listed file is missing, and a
|
|
284
|
+
// unit check that executed zero tests verified nothing.
|
|
285
|
+
if (status === 'pass' && report.missing_files.length > 0) {
|
|
286
|
+
status = 'fail';
|
|
287
|
+
error = `test_file_missing: ${report.missing_files.join(', ')}`;
|
|
288
|
+
}
|
|
289
|
+
else if (status === 'pass' && check.type === 'unit' && report.tests_executed === 0) {
|
|
290
|
+
status = 'fail';
|
|
291
|
+
error = 'no_tests_executed';
|
|
292
|
+
}
|
|
293
|
+
else if (status === 'pass' && check.type === 'unit' && report.tests_executed === null && !stdout.trim() && !stderr.trim()) {
|
|
294
|
+
// A unit check that printed nothing cannot have run a test runner.
|
|
295
|
+
status = 'fail';
|
|
296
|
+
error = 'no_test_report';
|
|
297
|
+
}
|
|
298
|
+
if (status === 'pass' && check.proves && check.proves.length > 0) {
|
|
299
|
+
const missing = (0, test_report_parsers_1.missingProofs)(check.proves, `${stdout}
|
|
300
|
+
${stderr}`);
|
|
301
|
+
if (missing.length > 0) {
|
|
302
|
+
status = 'fail';
|
|
303
|
+
error = `proof_not_executed: ${missing.join(' | ')}`;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
109
306
|
return {
|
|
110
307
|
check_id: check.id,
|
|
111
308
|
acceptance_ref: check.acceptance_ref,
|
|
112
309
|
status,
|
|
113
|
-
stdout
|
|
114
|
-
stderr
|
|
310
|
+
stdout,
|
|
311
|
+
stderr,
|
|
115
312
|
exit_code: result.status ?? null,
|
|
116
313
|
duration_ms,
|
|
117
|
-
error
|
|
314
|
+
error,
|
|
315
|
+
tests_executed: report.tests_executed,
|
|
118
316
|
};
|
|
119
317
|
}
|
|
120
318
|
catch (err) {
|
|
@@ -171,20 +369,21 @@ async function executeSuite(suite, cwd, options) {
|
|
|
171
369
|
}
|
|
172
370
|
else {
|
|
173
371
|
result = await runCheck(check, cwd, timeoutMs);
|
|
174
|
-
const
|
|
372
|
+
const collected = options.evidenceStore
|
|
175
373
|
? await collectCheckEvidence(options.evidenceStore, check, result, {
|
|
176
374
|
run_id: options.runId,
|
|
177
375
|
work_item_id: options.workItemId,
|
|
178
376
|
attempt_number: attemptNumber,
|
|
179
377
|
})
|
|
180
|
-
: [];
|
|
181
|
-
result.evidence_refs =
|
|
378
|
+
: { refs: [], summaryRef: null };
|
|
379
|
+
result.evidence_refs = collected.refs;
|
|
380
|
+
result.summary_evidence_ref = collected.summaryRef;
|
|
182
381
|
verificationResult = {
|
|
183
382
|
verification_id: `vr-${crypto_1.default.randomBytes(4).toString('hex')}`,
|
|
184
383
|
work_item_id: options.workItemId,
|
|
185
384
|
check_id: check.id,
|
|
186
385
|
status: result.status,
|
|
187
|
-
evidence_refs:
|
|
386
|
+
evidence_refs: collected.refs,
|
|
188
387
|
summary: result.error || result.stderr || result.stdout || null,
|
|
189
388
|
};
|
|
190
389
|
}
|
|
@@ -212,9 +411,13 @@ async function executeSuite(suite, cwd, options) {
|
|
|
212
411
|
}
|
|
213
412
|
function summarizeSuite(results) {
|
|
214
413
|
const counts = { total: results.length, pass: 0, fail: 0, skip: 0, error: 0 };
|
|
215
|
-
|
|
414
|
+
let manual = 0;
|
|
415
|
+
for (const r of results) {
|
|
216
416
|
counts[r.status]++;
|
|
217
|
-
|
|
417
|
+
if (r.status === 'skip' && r.skip_reason === 'needs_structured_check')
|
|
418
|
+
manual++;
|
|
419
|
+
}
|
|
420
|
+
return { ...counts, manual, allPassed: counts.fail === 0 && counts.error === 0 };
|
|
218
421
|
}
|
|
219
422
|
async function verifyRun(input) {
|
|
220
423
|
const gaps = [];
|
|
@@ -244,8 +447,21 @@ async function verifyRun(input) {
|
|
|
244
447
|
(0, verification_manifest_1.saveRiskLedger)(input.projectRoot, input.runId, executed.risk_ledger);
|
|
245
448
|
(0, verification_manifest_1.saveEvidenceCoverage)(input.projectRoot, input.runId, executed.evidence_coverage);
|
|
246
449
|
const summary = summarizeSuite(executed.results);
|
|
450
|
+
for (const r of executed.results) {
|
|
451
|
+
if (r.status === 'skip' && r.skip_reason === 'needs_structured_check') {
|
|
452
|
+
gaps.push(`Critério ${r.acceptance_ref ?? r.check_id}: "Como verificar" não é executável — informe um comando ou vincule a uma tarefa com verificação.`);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// Manual criteria leave the run `partial`: nothing failed, but nothing proved them either.
|
|
456
|
+
const status = summary.total === 0
|
|
457
|
+
? 'partial'
|
|
458
|
+
: !summary.allPassed
|
|
459
|
+
? 'failed'
|
|
460
|
+
: summary.manual > 0
|
|
461
|
+
? 'partial'
|
|
462
|
+
: 'passed';
|
|
247
463
|
return {
|
|
248
|
-
status
|
|
464
|
+
status,
|
|
249
465
|
suite: input.suite,
|
|
250
466
|
executed,
|
|
251
467
|
gaps,
|
|
@@ -256,6 +472,66 @@ async function verifyRun(input) {
|
|
|
256
472
|
evidence_coverage: executed.evidence_coverage,
|
|
257
473
|
};
|
|
258
474
|
}
|
|
475
|
+
const MANUAL_CRITERION_RE = /\b(manual|uat|homologa\w*|inspe[cç][aã]o visual|visual inspection)\b/i;
|
|
476
|
+
const CODE_FILE_RE = /\.(c|m)?[jt]sx?$|\.(py|go|rs|java|kt|rb|php|cs|json|ya?ml|sh)$/i;
|
|
477
|
+
const OXE_INTERNAL_REF_RE = /(^|[^\w.-])\.oxe[\\/]/;
|
|
478
|
+
/**
|
|
479
|
+
* Product code or tests that read `.oxe/` depend on OXE's local state, which is usually
|
|
480
|
+
* gitignored: they pass in the workspace and break on a clean clone or in CI. Seen in the 1.18
|
|
481
|
+
* benchmark (test/api.test.js loading `.oxe/investigations/fixtures/…`). Docs may mention `.oxe/`.
|
|
482
|
+
*/
|
|
483
|
+
function referencesOxeInternals(absPath) {
|
|
484
|
+
if (!CODE_FILE_RE.test(absPath))
|
|
485
|
+
return false;
|
|
486
|
+
try {
|
|
487
|
+
const stat = fs_1.default.statSync(absPath);
|
|
488
|
+
if (!stat.isFile() || stat.size > 1024 * 1024)
|
|
489
|
+
return false;
|
|
490
|
+
const current = fs_1.default.readFileSync(absPath, 'utf8');
|
|
491
|
+
const added = countOxeRefs(current);
|
|
492
|
+
if (added === 0)
|
|
493
|
+
return false;
|
|
494
|
+
// Only references the run introduced count: a product that legitimately talks about `.oxe/` (OXESpace hosts OXE)
|
|
495
|
+
// already had them at HEAD (false red seen in OxeVoice F1 on shared/mcp-coverage.ts).
|
|
496
|
+
const baseline = readCommittedVersion(absPath);
|
|
497
|
+
return baseline === null ? true : added > countOxeRefs(baseline);
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function countOxeRefs(text) {
|
|
504
|
+
return (text.match(new RegExp(OXE_INTERNAL_REF_RE.source, 'g')) || []).length;
|
|
505
|
+
}
|
|
506
|
+
/** The file as committed at HEAD, or null when it is untracked / there is no git. */
|
|
507
|
+
function readCommittedVersion(absPath) {
|
|
508
|
+
try {
|
|
509
|
+
const dir = path_1.default.dirname(absPath);
|
|
510
|
+
const top = (0, child_process_1.spawnSync)('git', ['rev-parse', '--show-toplevel'], { cwd: dir, encoding: 'utf8', windowsHide: true });
|
|
511
|
+
if (top.status !== 0)
|
|
512
|
+
return null;
|
|
513
|
+
const rel = path_1.default.relative(top.stdout.trim(), absPath).split(path_1.default.sep).join('/');
|
|
514
|
+
const shown = (0, child_process_1.spawnSync)('git', ['show', `HEAD:${rel}`], { cwd: dir, encoding: 'utf8', windowsHide: true, maxBuffer: 4 * 1024 * 1024 });
|
|
515
|
+
return shown.status === 0 ? shown.stdout : null;
|
|
516
|
+
}
|
|
517
|
+
catch {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function dedupeExports(list) {
|
|
522
|
+
const seen = new Set();
|
|
523
|
+
const out = [];
|
|
524
|
+
for (const entry of list) {
|
|
525
|
+
if (!entry || typeof entry.file !== 'string' || typeof entry.name !== 'string')
|
|
526
|
+
continue;
|
|
527
|
+
const key = `${entry.file}#${entry.name}`;
|
|
528
|
+
if (seen.has(key))
|
|
529
|
+
continue;
|
|
530
|
+
seen.add(key);
|
|
531
|
+
out.push({ file: entry.file, name: entry.name });
|
|
532
|
+
}
|
|
533
|
+
return out;
|
|
534
|
+
}
|
|
259
535
|
function hashObject(obj) {
|
|
260
536
|
return crypto_1.default
|
|
261
537
|
.createHash('sha256')
|
|
@@ -281,6 +557,7 @@ async function collectCheckEvidence(store, check, result, options) {
|
|
|
281
557
|
exit_code: result.exit_code,
|
|
282
558
|
duration_ms: result.duration_ms,
|
|
283
559
|
}, null, 2), options);
|
|
284
|
-
|
|
285
|
-
|
|
560
|
+
// The summary record is bookkeeping, not proof: it is stored but excluded from `evidence_refs`,
|
|
561
|
+
// otherwise every check (even a silent exit 0) counts as "covered".
|
|
562
|
+
return { refs, summaryRef: summaryEvidence.evidence_id };
|
|
286
563
|
}
|
|
@@ -13,6 +13,10 @@ export interface ManifestCheck {
|
|
|
13
13
|
failure_class: VerificationFailureClass | null;
|
|
14
14
|
evidence_refs: string[];
|
|
15
15
|
duration_ms: number;
|
|
16
|
+
skip_reason?: string | null;
|
|
17
|
+
tests_executed?: number | null;
|
|
18
|
+
/** Why a check did not pass (e.g. `no_tests_executed`, `test_file_missing: …`). */
|
|
19
|
+
error?: string | null;
|
|
16
20
|
}
|
|
17
21
|
export interface VerificationManifest {
|
|
18
22
|
manifest_id: string;
|
|
@@ -29,6 +33,8 @@ export interface VerificationManifest {
|
|
|
29
33
|
fail: number;
|
|
30
34
|
skip: number;
|
|
31
35
|
error: number;
|
|
36
|
+
/** Skipped checks whose criterion has no executable verification. */
|
|
37
|
+
manual?: number;
|
|
32
38
|
all_passed: boolean;
|
|
33
39
|
};
|
|
34
40
|
}
|
|
@@ -48,9 +54,13 @@ export interface ResidualRiskLedger {
|
|
|
48
54
|
}
|
|
49
55
|
export interface EvidenceCoverageSummary {
|
|
50
56
|
total_checks: number;
|
|
57
|
+
/** Checks that actually ran (status other than skip). */
|
|
58
|
+
executed_checks?: number;
|
|
51
59
|
checks_with_evidence: number;
|
|
52
60
|
total_evidence_refs: number;
|
|
53
61
|
coverage_percent: number;
|
|
62
|
+
/** Ids of checks that ran but produced no evidence — what the coverage gate is missing. */
|
|
63
|
+
checks_without_evidence?: string[];
|
|
54
64
|
}
|
|
55
65
|
export declare function classifyFailure(result: CheckResult): FailureClass | null;
|
|
56
66
|
export declare function buildManifest(runId: string, results: CheckResult[], options?: {
|
|
@@ -62,14 +62,20 @@ function buildManifest(runId, results, options = {}) {
|
|
|
62
62
|
failure_class: classifyFailure(r),
|
|
63
63
|
evidence_refs: evidenceRefs.get(r.check_id) ?? [],
|
|
64
64
|
duration_ms: r.duration_ms,
|
|
65
|
+
skip_reason: r.skip_reason ?? null,
|
|
66
|
+
tests_executed: r.tests_executed ?? null,
|
|
67
|
+
error: r.status === 'pass' ? null : r.error ? r.error.slice(0, 500) : null,
|
|
65
68
|
}));
|
|
69
|
+
const isManual = (c) => c.status === 'skip' && c.skip_reason === 'needs_structured_check';
|
|
66
70
|
const summary = {
|
|
67
71
|
total: checks.length,
|
|
68
72
|
pass: checks.filter((c) => c.status === 'pass').length,
|
|
69
73
|
fail: checks.filter((c) => c.status === 'fail').length,
|
|
70
74
|
skip: checks.filter((c) => c.status === 'skip').length,
|
|
71
75
|
error: checks.filter((c) => c.status === 'error').length,
|
|
72
|
-
|
|
76
|
+
manual: checks.filter(isManual).length,
|
|
77
|
+
// A deliberate skip still passes; a manual criterion (no executable verification) is not proof.
|
|
78
|
+
all_passed: checks.every((c) => c.status === 'pass' || (c.status === 'skip' && !isManual(c))),
|
|
73
79
|
};
|
|
74
80
|
return {
|
|
75
81
|
manifest_id: `vm-${crypto_1.default.randomBytes(4).toString('hex')}`,
|
|
@@ -115,14 +121,23 @@ function buildRiskLedger(runId, manifest) {
|
|
|
115
121
|
}
|
|
116
122
|
function summarizeEvidenceCoverage(manifest) {
|
|
117
123
|
const totalChecks = manifest.checks.length;
|
|
118
|
-
|
|
124
|
+
// Coverage is measured over checks that actually ran; skipped checks produce no evidence by definition.
|
|
125
|
+
const executed = manifest.checks.filter((check) => check.status !== 'skip');
|
|
126
|
+
const checksWithEvidence = executed.filter((check) => check.evidence_refs.length > 0).length;
|
|
127
|
+
const withoutEvidence = executed.filter((check) => check.evidence_refs.length === 0).map((check) => check.check_id);
|
|
119
128
|
const totalEvidenceRefs = manifest.checks.reduce((sum, check) => sum + check.evidence_refs.length, 0);
|
|
120
|
-
const coveragePercent = totalChecks === 0
|
|
129
|
+
const coveragePercent = totalChecks === 0
|
|
130
|
+
? 100
|
|
131
|
+
: executed.length === 0
|
|
132
|
+
? 0
|
|
133
|
+
: Math.round((checksWithEvidence / executed.length) * 100);
|
|
121
134
|
return {
|
|
122
135
|
total_checks: totalChecks,
|
|
136
|
+
executed_checks: executed.length,
|
|
123
137
|
checks_with_evidence: checksWithEvidence,
|
|
124
138
|
total_evidence_refs: totalEvidenceRefs,
|
|
125
139
|
coverage_percent: coveragePercent,
|
|
140
|
+
checks_without_evidence: withoutEvidence,
|
|
126
141
|
};
|
|
127
142
|
}
|
|
128
143
|
function saveManifest(projectRoot, runId, manifest) {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { WorkspaceManager, WorkspaceRequest } from '../workspace-manager';
|
|
2
2
|
import type { WorkspaceLease, SnapshotRef } from '../../models/workspace';
|
|
3
|
+
/**
|
|
4
|
+
* Removes (without following) every symlink/junction under `root` whose target is outside `root`. Walks real
|
|
5
|
+
* directories only (lstat), skips `.git`, and is bounded so a large installed node_modules cannot stall dispose.
|
|
6
|
+
* @returns the links removed (absolute paths)
|
|
7
|
+
*/
|
|
8
|
+
export declare function unlinkExternalLinks(root: string, limits?: {
|
|
9
|
+
maxDepth?: number;
|
|
10
|
+
maxEntries?: number;
|
|
11
|
+
}): string[];
|
|
3
12
|
export declare class GitWorktreeManager implements WorkspaceManager {
|
|
4
13
|
private readonly projectRoot;
|
|
5
14
|
readonly isolation_level: "isolated";
|
|
@@ -4,10 +4,86 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.GitWorktreeManager = void 0;
|
|
7
|
+
exports.unlinkExternalLinks = unlinkExternalLinks;
|
|
7
8
|
const child_process_1 = require("child_process");
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const fs_1 = __importDefault(require("fs"));
|
|
10
11
|
const crypto_1 = __importDefault(require("crypto"));
|
|
12
|
+
function isInside(root, target) {
|
|
13
|
+
const rel = path_1.default.relative(root, target);
|
|
14
|
+
return rel === '' || (!rel.startsWith('..') && !path_1.default.isAbsolute(rel));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Removes (without following) every symlink/junction under `root` whose target is outside `root`. Walks real
|
|
18
|
+
* directories only (lstat), skips `.git`, and is bounded so a large installed node_modules cannot stall dispose.
|
|
19
|
+
* @returns the links removed (absolute paths)
|
|
20
|
+
*/
|
|
21
|
+
function unlinkExternalLinks(root, limits = {}) {
|
|
22
|
+
const maxDepth = limits.maxDepth ?? 5;
|
|
23
|
+
const maxEntries = limits.maxEntries ?? 50000;
|
|
24
|
+
const removed = [];
|
|
25
|
+
const realRoot = (() => { try {
|
|
26
|
+
return fs_1.default.realpathSync(root);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return path_1.default.resolve(root);
|
|
30
|
+
} })();
|
|
31
|
+
let seen = 0;
|
|
32
|
+
const walk = (dir, depth) => {
|
|
33
|
+
if (depth > maxDepth || seen > maxEntries)
|
|
34
|
+
return;
|
|
35
|
+
let entries = [];
|
|
36
|
+
try {
|
|
37
|
+
entries = fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
seen += 1;
|
|
44
|
+
if (seen > maxEntries)
|
|
45
|
+
return;
|
|
46
|
+
if (entry.name === '.git')
|
|
47
|
+
continue;
|
|
48
|
+
const full = path_1.default.join(dir, entry.name);
|
|
49
|
+
let stat;
|
|
50
|
+
try {
|
|
51
|
+
stat = fs_1.default.lstatSync(full);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (stat.isSymbolicLink()) {
|
|
57
|
+
let target = '';
|
|
58
|
+
try {
|
|
59
|
+
target = path_1.default.resolve(path_1.default.dirname(full), fs_1.default.readlinkSync(full));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
target = '';
|
|
63
|
+
}
|
|
64
|
+
if (!target || !(isInside(realRoot, target) || isInside(path_1.default.resolve(root), target))) {
|
|
65
|
+
try {
|
|
66
|
+
fs_1.default.unlinkSync(full);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
try {
|
|
70
|
+
fs_1.default.rmdirSync(full);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
continue;
|
|
74
|
+
} // a Windows directory junction
|
|
75
|
+
}
|
|
76
|
+
removed.push(full);
|
|
77
|
+
}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (stat.isDirectory())
|
|
81
|
+
walk(full, depth + 1);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
walk(root, 0);
|
|
85
|
+
return removed;
|
|
86
|
+
}
|
|
11
87
|
class GitWorktreeManager {
|
|
12
88
|
constructor(projectRoot) {
|
|
13
89
|
this.projectRoot = projectRoot;
|
|
@@ -58,6 +134,11 @@ class GitWorktreeManager {
|
|
|
58
134
|
const lease = this.leases.get(id);
|
|
59
135
|
if (!lease)
|
|
60
136
|
return;
|
|
137
|
+
// A forced worktree remove follows links: a node_modules junction or a workspace link (@scope/pkg → the main
|
|
138
|
+
// repo's packages/) took the REAL directory with it. Links that leave the worktree are unlinked first, never
|
|
139
|
+
// followed, so only the worktree's own files are removed.
|
|
140
|
+
if (lease.root_path)
|
|
141
|
+
unlinkExternalLinks(lease.root_path);
|
|
61
142
|
try {
|
|
62
143
|
this.git(['worktree', 'remove', lease.root_path, '--force']);
|
|
63
144
|
}
|