harness-everything 0.54.1 → 0.55.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +2 -1
- package/CHANGELOG.md +23 -0
- package/README.md +1 -0
- package/ci/mechanism-2ao-plugin-sync.test.js +18 -2
- package/ci/mechanism-349-ci-change-scope.test.js +68 -7
- package/ci/mechanism-check-packet-write-set.test.js +13 -3
- package/ci/mechanism-error-ledger-oracle.test.js +222 -0
- package/ci/mechanism-error-ledger-promote.test.js +520 -0
- package/ci/mechanism-error-ledger-scan.test.js +640 -0
- package/ci/mechanism-errors-sync-root.test.js +215 -0
- package/ci/openai-plugin-package.test.js +1 -1
- package/docs/error-handling/README.md +5 -5
- package/docs/error-handling/details/e0002-report-writer.md +25 -27
- package/docs/error-handling/registry.md +1 -1
- package/docs/workflows/error-ledger-bootstrap.md +23 -0
- package/error-ledger-bootstrap/SKILL.md +33 -0
- package/error-ledger-bootstrap/references/workflow.md +79 -0
- package/error-ledger-bootstrap/scripts/promote.js +613 -0
- package/error-ledger-bootstrap/scripts/scan.js +654 -0
- package/evals/error-ledger-bootstrap/eval.yaml +26 -0
- package/evals/error-ledger-bootstrap/tasks/negative-error-handling-map.yaml +16 -0
- package/evals/error-ledger-bootstrap/tasks/negative-trigger.yaml +16 -0
- package/evals/error-ledger-bootstrap/tasks/positive-trigger.yaml +15 -0
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/references/skill-registry.md +1 -0
- package/harness-everything/scripts/routing-keywords.json +11 -0
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/skills/error-ledger-bootstrap/SKILL.md +33 -0
- package/plugins/harness-everything/skills/error-ledger-bootstrap/references/workflow.md +79 -0
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/promote.js +613 -0
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/scan.js +654 -0
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +1 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +11 -0
- package/sbom.cdx.json +7 -7
- package/scripts/error-ledger-oracle.js +257 -0
- package/scripts/errors-sync.js +175 -12
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"name": "harness-everything",
|
|
11
11
|
"source": "./",
|
|
12
12
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.55.1",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Miya Daniel"
|
|
16
16
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harness-everything",
|
|
3
3
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.55.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Miya Daniel"
|
|
7
7
|
},
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"skills": [
|
|
25
25
|
"./multi-agent-workspace",
|
|
26
26
|
"./code-review",
|
|
27
|
+
"./error-ledger-bootstrap",
|
|
27
28
|
"./environment-detection",
|
|
28
29
|
"./eval-harness",
|
|
29
30
|
"./fable-discipline",
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.55.1](https://github.com/dyphn1/Harness-everything/compare/v0.55.0...v0.55.1) (2026-11-20)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* align first-stage report and verification contracts ([d6de493](https://github.com/dyphn1/Harness-everything/commit/d6de4938ddce7cd6139627ab567fbade526de6b7))
|
|
10
|
+
|
|
11
|
+
## [0.55.0](https://github.com/dyphn1/Harness-everything/compare/v0.54.1...v0.55.0) (2026-11-20)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **errors:** add a local scanner for ledger bootstrap candidates ([b34be38](https://github.com/dyphn1/Harness-everything/commit/b34be38145348176c63f0faf26fd071115e1485f)), closes [#479](https://github.com/dyphn1/Harness-everything/issues/479)
|
|
16
|
+
* **errors:** add the error-ledger-bootstrap skill with routing eval ([71e64c3](https://github.com/dyphn1/Harness-everything/commit/71e64c3ba691b2c5f3c8647976c46a27a9916445)), closes [#479](https://github.com/dyphn1/Harness-everything/issues/479)
|
|
17
|
+
* **errors:** promote an owner-approved candidate into a target ledger ([7c8b672](https://github.com/dyphn1/Harness-everything/commit/7c8b6723f0120559805fddf9e54ea8eb8e2e8a86)), closes [#479](https://github.com/dyphn1/Harness-everything/issues/479)
|
|
18
|
+
* **errors:** scan repeated doc fixes and offline tracker exports ([5e36882](https://github.com/dyphn1/Harness-everything/commit/5e368829464abe8f5f66129045fe685f31ae5950)), closes [#479](https://github.com/dyphn1/Harness-everything/issues/479)
|
|
19
|
+
* **errors:** sync the ledger index of a target repository with --root ([0973bec](https://github.com/dyphn1/Harness-everything/commit/0973bec75a0f45b4cd4de0c9ef158c75f0186ed5)), closes [#479](https://github.com/dyphn1/Harness-everything/issues/479)
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **errors:** close the pr 483 owner review findings ([7e35a65](https://github.com/dyphn1/Harness-everything/commit/7e35a6574bd450ebe67e866a555ad8bfd15c355d))
|
|
24
|
+
* **errors:** confine ledger index writes to the target ledger ([410231c](https://github.com/dyphn1/Harness-everything/commit/410231c88addb1ce8ce6666784aa05c926709d8e)), closes [#479](https://github.com/dyphn1/Harness-everything/issues/479)
|
|
25
|
+
* **errors:** keep private memory labels opaque in bootstrap reports ([c61f080](https://github.com/dyphn1/Harness-everything/commit/c61f08060193bb4030c21f310e197e5012b7800c)), closes [#479](https://github.com/dyphn1/Harness-everything/issues/479)
|
|
26
|
+
* **errors:** label the oracle unmatched share as a path-overlap proxy ([79cb92c](https://github.com/dyphn1/Harness-everything/commit/79cb92c81fae064a60c11c8bb2dc3b2868800be9)), closes [#479](https://github.com/dyphn1/Harness-everything/issues/479)
|
|
27
|
+
|
|
5
28
|
## [0.54.1](https://github.com/dyphn1/Harness-everything/compare/v0.54.0...v0.54.1) (2026-11-20)
|
|
6
29
|
|
|
7
30
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -239,6 +239,7 @@ This repo uses a flat layout (waza/agentskills.io convention). The table below m
|
|
|
239
239
|
| `references` | **Documentation** | Shared checklists (security, performance, definition-of-done) |
|
|
240
240
|
| `multi-agent-workspace` | **Skill (Tier 3)** | Scaffold a verified multi-agent workspace and select bounded specialists from an external catalog without vendoring the full roster |
|
|
241
241
|
| `code-review` | **Skill (Tier 2)** | Independent, evidence-tiered PR/diff code review (read-only by default) |
|
|
242
|
+
| `error-ledger-bootstrap` | **Skill (Tier 2)** | Inventory local lessons and promote owner-approved error-ledger entries |
|
|
242
243
|
| `environment-detection` | **Foundation** | Preflight: detect OS, shell, package manager |
|
|
243
244
|
| `eval-harness` | **Skill (Tier 2)** | Evaluate agent outputs against rubrics |
|
|
244
245
|
| `fable-discipline` | **Skill (Tier 3)** | Fable execution guardrails when Fable is selected |
|
|
@@ -18,14 +18,30 @@ const codexHooksCompat = require('../scripts/codex-hooks-compat');
|
|
|
18
18
|
// A fake host runner does not mock the compatibility installer's filesystem
|
|
19
19
|
// writes. Fail closed if any case forgets to pass its explicit temporary home.
|
|
20
20
|
const realInstall = codexHooksCompat.install;
|
|
21
|
+
function isInsideTempRoot(root, target, pathApi = path) {
|
|
22
|
+
const relative = pathApi.relative(root, target);
|
|
23
|
+
const outside = relative === '..' || relative.startsWith('..' + pathApi.sep) || pathApi.isAbsolute(relative);
|
|
24
|
+
return relative !== '' && !outside;
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
codexHooksCompat.install = options => {
|
|
22
28
|
assert(options && options.codexHome, 'tests must supply an explicit temporary Codex home');
|
|
23
|
-
|
|
24
|
-
assert(relative && !relative.startsWith('..') && !path.isAbsolute(relative),
|
|
29
|
+
assert(isInsideTempRoot(os.tmpdir(), path.resolve(options.codexHome)),
|
|
25
30
|
'test Codex home must be inside the temporary directory');
|
|
26
31
|
return realInstall(options);
|
|
27
32
|
};
|
|
28
33
|
|
|
34
|
+
for (const [target, inside] of [
|
|
35
|
+
['D:\\repo', false],
|
|
36
|
+
['D:\\repo\\..cache', true],
|
|
37
|
+
['D:\\repo\\child', true],
|
|
38
|
+
['D:\\other', false],
|
|
39
|
+
['D:\\', false],
|
|
40
|
+
['C:\\temp', false],
|
|
41
|
+
]) {
|
|
42
|
+
assert.strictEqual(isInsideTempRoot('D:\\repo', target, path.win32), inside, target);
|
|
43
|
+
}
|
|
44
|
+
|
|
29
45
|
|
|
30
46
|
function fakeHost({ claudeInstalled = false, codexInstalled = false, codexPluginSourcePath = path.join(ROOT, 'plugins', 'harness-everything'), codexPluginSourceType = 'local', codexAvailableOnly = false, claudeMarketplace = true, codexMarketplace = true, unknownClaudePluginState = false, unknownClaudeYesFlag = false, unknownClaudeJsonFlag = false, clapCodexJsonFlag = false, missingCodexPluginCommand = false, codexHooksError = null } = {}) {
|
|
31
47
|
const calls = [];
|
|
@@ -56,11 +56,21 @@ function assertScopeGating({ ci, release, governance }) {
|
|
|
56
56
|
assert.ok(classifier, 'the ci-change-scope job exists');
|
|
57
57
|
assert.ok(selfRegression, 'the self-regression job exists');
|
|
58
58
|
|
|
59
|
-
//
|
|
60
|
-
//
|
|
59
|
+
// Every dependency chain that could inherit the docs-only skip has a first
|
|
60
|
+
// job that needs the classifier or self-regression.
|
|
61
|
+
const scopeJobs = [CHANGE_SCOPE_JOB, 'self-regression'];
|
|
62
|
+
// Match needs.job and needs['job'] references while skipping quoted strings.
|
|
63
|
+
const needsReference = /'(?:[^']|'')*'|(?<![\w.-])needs\s*(?:\.\s*([\w-]+)|\[\s*'([\w-]+)'\s*\])/gi;
|
|
61
64
|
for (const [jobId, job] of Object.entries(jobs)) {
|
|
62
|
-
if (jobId
|
|
63
|
-
|
|
65
|
+
if (scopeJobs.includes(jobId)) continue;
|
|
66
|
+
const needs = Array.isArray(job.needs) ? job.needs : [job.needs];
|
|
67
|
+
for (const scopeJob of scopeJobs) {
|
|
68
|
+
assert.ok(!needs.includes(scopeJob), `${jobId} must not depend on ${scopeJob}`);
|
|
69
|
+
}
|
|
70
|
+
for (const [, dotJob, bracketJob] of String(job.if ?? '').matchAll(needsReference)) {
|
|
71
|
+
const dependency = dotJob ?? bracketJob;
|
|
72
|
+
assert.ok(!scopeJobs.includes(dependency?.toLowerCase()), `${jobId} must not reference scope-gated jobs in its condition`);
|
|
73
|
+
}
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
// The classifier runs only on pull requests and wires its scope output.
|
|
@@ -244,13 +254,17 @@ test('real Git merge-base diff includes earlier code, deletions, both rename end
|
|
|
244
254
|
}
|
|
245
255
|
});
|
|
246
256
|
|
|
247
|
-
|
|
257
|
+
function readScopeWorkflows() {
|
|
248
258
|
const readWorkflow = file => yaml.load(fs.readFileSync(path.join(ROOT, file), 'utf8'));
|
|
249
|
-
|
|
259
|
+
return {
|
|
250
260
|
ci: readWorkflow('.github/workflows/ci.yml'),
|
|
251
261
|
release: readWorkflow('.github/workflows/release.yml'),
|
|
252
262
|
governance: readWorkflow('.github/workflows/doc-governance.yml'),
|
|
253
|
-
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
test('the workflow gates only self-regression and fails open on every uncertain dependency/output state', () => {
|
|
267
|
+
assertScopeGating(readScopeWorkflows());
|
|
254
268
|
|
|
255
269
|
const gateCases = [
|
|
256
270
|
['successful docs-only classifier', false, 'success', 'docs-only', false],
|
|
@@ -272,6 +286,53 @@ test('the workflow gates only self-regression and fails open on every uncertain
|
|
|
272
286
|
assert.equal(classifyChangeSet('push', 'a'.repeat(40), 'b'.repeat(40), { runGit: unusedGitForWorkflow }), 'full');
|
|
273
287
|
});
|
|
274
288
|
|
|
289
|
+
test('the oracle accepts jobs with independent conditions and dependencies', () => {
|
|
290
|
+
const workflows = readScopeWorkflows();
|
|
291
|
+
const jobs = workflows.ci.jobs;
|
|
292
|
+
jobs['pilot-offline-evidence'].if = "${{ github.event_name == 'push' }}";
|
|
293
|
+
jobs['extra-check'] = {
|
|
294
|
+
'runs-on': 'ubuntu-latest',
|
|
295
|
+
steps: [{ run: 'echo check' }],
|
|
296
|
+
};
|
|
297
|
+
assertScopeGating(workflows);
|
|
298
|
+
|
|
299
|
+
jobs['extra-check'].needs = 'pilot-offline-evidence';
|
|
300
|
+
jobs['extra-check'].if = "${{ github.head_ref == 'docs-only' && contains(github.event.pull_request.body, 'needs.ci-change-scope') }}";
|
|
301
|
+
assertScopeGating(workflows);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
test('the oracle rejects additional jobs wired to scope gating', () => {
|
|
305
|
+
for (const [job, expected] of [
|
|
306
|
+
[{ needs: CHANGE_SCOPE_JOB }, /must not depend on ci-change-scope/],
|
|
307
|
+
[{ needs: ['self-regression'] }, /must not depend on self-regression/],
|
|
308
|
+
[{ if: "needs.ci-change-scope.outputs.scope != 'docs-only'" }, /must not reference scope-gated jobs/],
|
|
309
|
+
[{ if: "needs[ 'ci-change-scope' ].outputs.scope != 'docs-only'" }, /must not reference scope-gated jobs/],
|
|
310
|
+
]) {
|
|
311
|
+
const workflows = readScopeWorkflows();
|
|
312
|
+
workflows.ci.jobs['extra-check'] = job;
|
|
313
|
+
workflows.ci.jobs['downstream-check'] = { needs: 'extra-check' };
|
|
314
|
+
assert.throws(() => assertScopeGating(workflows), expected);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test('the oracle retains the existing scope-gating invariants', () => {
|
|
319
|
+
for (const [mutate, expected] of [
|
|
320
|
+
[({ ci }) => { delete ci.jobs['self-regression'].needs; }, /deep-equal/],
|
|
321
|
+
[({ ci }) => { ci.jobs['self-regression'].if = "${{ needs.ci-change-scope.outputs.scope != 'docs-only' }}"; }, /fallback predicate/],
|
|
322
|
+
[({ ci }) => { ci.jobs[CHANGE_SCOPE_JOB].outputs.scope = '${{ steps.wrong.outputs.scope }}'; }, /steps\.scope\.outputs\.scope/],
|
|
323
|
+
[({ ci }) => { ci.jobs[CHANGE_SCOPE_JOB].steps.find(step => step.id === 'scope').env.PR_BASE_SHA = ''; }, /base\.sha/],
|
|
324
|
+
[({ ci }) => { ci.jobs['self-regression'].strategy.matrix.os.pop(); }, /macos-latest/],
|
|
325
|
+
[({ ci }) => { ci.on.push['paths-ignore'] = ['docs/**']; }, /no workflow-level paths-ignore filter/],
|
|
326
|
+
[({ release }) => { release.jobs.gate.uses = './.github/workflows/other.yml'; }, /\.\/\.github\/workflows\/ci\.yml/],
|
|
327
|
+
[({ release }) => { release.jobs.gate.needs = CHANGE_SCOPE_JOB; }, /release\.yml job gate must not depend on the classifier/],
|
|
328
|
+
[({ governance }) => { Object.values(governance.jobs)[0].if = SELF_REGRESSION_IF; }, /doc-governance\.yml job .* must not be gated/],
|
|
329
|
+
]) {
|
|
330
|
+
const workflows = readScopeWorkflows();
|
|
331
|
+
mutate(workflows);
|
|
332
|
+
assert.throws(() => assertScopeGating(workflows), expected);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
275
336
|
function unusedGitForWorkflow() {
|
|
276
337
|
throw new Error('the release caller is a push/dispatch, so no PR diff may authorize a skip');
|
|
277
338
|
}
|
|
@@ -14,11 +14,21 @@ const FIXED_DATE = '2000-01-01T00:00:00Z';
|
|
|
14
14
|
|
|
15
15
|
function isOutside(root, target, pathApi = path) {
|
|
16
16
|
const relative = pathApi.relative(root, target);
|
|
17
|
-
return relative.startsWith('..') || pathApi.isAbsolute(relative);
|
|
17
|
+
return relative === '..' || relative.startsWith('..' + pathApi.sep) || pathApi.isAbsolute(relative);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
test('temporary fixture containment respects Windows path segments and drives', () => {
|
|
21
|
+
for (const [target, outside] of [
|
|
22
|
+
['D:\\repo', false],
|
|
23
|
+
['D:\\repo\\..cache', false],
|
|
24
|
+
['D:\\repo\\child', false],
|
|
25
|
+
['D:\\other', true],
|
|
26
|
+
['D:\\', true],
|
|
27
|
+
['C:\\temp', true],
|
|
28
|
+
]) {
|
|
29
|
+
assert.equal(isOutside('D:\\repo', target, path.win32), outside, target);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
22
32
|
|
|
23
33
|
function gitEnv(tempRoot) {
|
|
24
34
|
const env = { ...process.env };
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const childProcess = require('node:child_process');
|
|
5
|
+
const crypto = require('node:crypto');
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const os = require('node:os');
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
|
|
10
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
11
|
+
const SCRIPT = path.join(ROOT, 'scripts', 'error-ledger-oracle.js');
|
|
12
|
+
const TMP = fs.realpathSync.native(fs.mkdtempSync(path.join(os.tmpdir(), 'harness-error-ledger-oracle-')));
|
|
13
|
+
process.on('exit', () => fs.rmSync(TMP, { recursive: true, force: true }));
|
|
14
|
+
|
|
15
|
+
function write(file, value) {
|
|
16
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
17
|
+
fs.writeFileSync(file, value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function makeFixture(name, records, candidates) {
|
|
21
|
+
const root = path.join(TMP, name);
|
|
22
|
+
const ledger = path.join(root, 'errors');
|
|
23
|
+
const report = path.join(root, 'scan-report.json');
|
|
24
|
+
fs.mkdirSync(ledger, { recursive: true });
|
|
25
|
+
for (const record of records) {
|
|
26
|
+
const sites = record.sites.map(site => ` - ${JSON.stringify(site)}`).join('\n');
|
|
27
|
+
write(path.join(ledger, `${record.id}-fixture.md`), [
|
|
28
|
+
'---', `id: ${record.id}`, 'sites:', sites, '---',
|
|
29
|
+
'', record.lesson || `PRIVATE_RECORD_BODY_${record.id}`, ''
|
|
30
|
+
].join('\n'));
|
|
31
|
+
}
|
|
32
|
+
write(report, `${JSON.stringify({
|
|
33
|
+
schemaVersion: 1,
|
|
34
|
+
candidates: candidates.map(candidate => ({
|
|
35
|
+
kind: 'error-candidate',
|
|
36
|
+
id: candidate.id,
|
|
37
|
+
title: candidate.title || `PRIVATE_CANDIDATE_TITLE_${candidate.id}`,
|
|
38
|
+
sites: candidate.sites,
|
|
39
|
+
sources: [{ type: 'memory', title: 'PRIVATE_MEMORY_SOURCE_TITLE' }]
|
|
40
|
+
}))
|
|
41
|
+
}, null, 2)}\n`);
|
|
42
|
+
return { root, ledger, report };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function snapshot(dir) {
|
|
46
|
+
const entries = [];
|
|
47
|
+
function visit(current, relative = '') {
|
|
48
|
+
for (const entry of fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
49
|
+
const child = path.join(current, entry.name);
|
|
50
|
+
const childRelative = path.join(relative, entry.name);
|
|
51
|
+
if (entry.isDirectory()) visit(child, childRelative);
|
|
52
|
+
else entries.push([childRelative, crypto.createHash('sha256').update(fs.readFileSync(child)).digest('hex')]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
visit(dir);
|
|
56
|
+
return entries;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function run(fixture, options = []) {
|
|
60
|
+
const env = { ...process.env, HOME: TMP, USERPROFILE: TMP };
|
|
61
|
+
delete env.HARNESS_SYSTEM_ONE_MODE;
|
|
62
|
+
const result = childProcess.spawnSync(process.execPath, [
|
|
63
|
+
SCRIPT, '--report', fixture.report, '--ledger', fixture.ledger, ...options
|
|
64
|
+
], { cwd: ROOT, encoding: 'utf8', env });
|
|
65
|
+
assert.ifError(result.error);
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function jsonResult(result, expectedStatus = 0) {
|
|
70
|
+
assert.strictEqual(result.status, expectedStatus,
|
|
71
|
+
`oracle exit ${result.status}; expected ${expectedStatus}; stderr: ${result.stderr}`);
|
|
72
|
+
if (expectedStatus === 0) assert.strictEqual(result.stderr, '', 'successful oracle runs do not write stderr');
|
|
73
|
+
return expectedStatus === 0 ? JSON.parse(result.stdout) : null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const fixture = makeFixture('main', [
|
|
77
|
+
{ id: 'E-0001', sites: ['parser/parser.js (PR #448 branch; not on main at bd986013)'] },
|
|
78
|
+
{ id: 'E-0002', sites: ['dir-only'] },
|
|
79
|
+
{ id: 'E-0003', sites: ['boundary/a/bc.js'] },
|
|
80
|
+
{ id: 'E-0004', sites: ['/private/absolute.js (PR #448)', 'C:\\private\\absolute.js', '../outside.js', 'https://example.invalid/a/path'] },
|
|
81
|
+
{ id: 'E-0005', sites: ['shared/file.js'] },
|
|
82
|
+
{ id: 'E-0006', sites: ['shared/file.js'] },
|
|
83
|
+
{ id: 'E-0007', sites: ['other/never.js'] },
|
|
84
|
+
{ id: 'E-0008', sites: ['parent/child.js'] }
|
|
85
|
+
], [
|
|
86
|
+
{ id: 'candidate-exact', sites: ['./parser\\parser.js'] },
|
|
87
|
+
{ id: 'candidate-child', sites: ['dir-only/sub/module.js'] },
|
|
88
|
+
{ id: 'candidate-boundary', sites: ['boundary/a/b'] },
|
|
89
|
+
{ id: 'candidate-shared', sites: ['shared/file.js'] },
|
|
90
|
+
{ id: 'candidate-parent', sites: ['parent'] }
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
const ledgerBefore = snapshot(fixture.ledger);
|
|
94
|
+
const reportBefore = fs.readFileSync(fixture.report);
|
|
95
|
+
const result = run(fixture, ['--json']);
|
|
96
|
+
const payload = jsonResult(result);
|
|
97
|
+
|
|
98
|
+
assert.deepStrictEqual(Object.keys(payload).sort(),
|
|
99
|
+
['counts', 'rates', 'metricNote', 'nonComparable', 'linked', 'unlinked', 'sharedPathHits'].sort());
|
|
100
|
+
assert.deepStrictEqual(payload.counts, {
|
|
101
|
+
records: 8,
|
|
102
|
+
comparableRecords: 7,
|
|
103
|
+
linkedRecords: 5,
|
|
104
|
+
candidates: 5,
|
|
105
|
+
unmatchedCandidates: 1
|
|
106
|
+
});
|
|
107
|
+
assert.deepStrictEqual(payload.rates, { recallAll: 5 / 8, recallComparable: 5 / 7, unmatchedShare: 1 / 5 });
|
|
108
|
+
assert.match(payload.metricNote, /path overlap is a proxy and may link distinct lessons/i);
|
|
109
|
+
assert.match(payload.metricNote, /recall \(all\) = linked records \/ all records/i);
|
|
110
|
+
assert.match(payload.metricNote, /recall \(comparable\) = linked records \/ comparable records/i);
|
|
111
|
+
assert.deepStrictEqual(payload.nonComparable, ['E-0004']);
|
|
112
|
+
assert.deepStrictEqual(payload.linked, [
|
|
113
|
+
{ id: 'E-0001', candidateIds: ['candidate-exact'] },
|
|
114
|
+
{ id: 'E-0002', candidateIds: ['candidate-child'] },
|
|
115
|
+
{ id: 'E-0005', candidateIds: ['candidate-shared'] },
|
|
116
|
+
{ id: 'E-0006', candidateIds: ['candidate-shared'] },
|
|
117
|
+
{ id: 'E-0008', candidateIds: ['candidate-parent'] }
|
|
118
|
+
]);
|
|
119
|
+
assert.deepStrictEqual(payload.unlinked, ['E-0003', 'E-0004', 'E-0007'],
|
|
120
|
+
'a/bc.js does not match the directory a/b at a segment boundary');
|
|
121
|
+
assert.deepStrictEqual(payload.sharedPathHits, [{
|
|
122
|
+
site: 'shared/file.js',
|
|
123
|
+
recordIds: ['E-0005', 'E-0006'],
|
|
124
|
+
candidateIds: ['candidate-shared']
|
|
125
|
+
}]);
|
|
126
|
+
assert.ok(!result.stdout.includes('PRIVATE_RECORD_BODY_') && !result.stdout.includes('PRIVATE_CANDIDATE_TITLE_') &&
|
|
127
|
+
!result.stdout.includes('PRIVATE_MEMORY_SOURCE_TITLE'), 'output contains ids and counts, not record bodies or memory titles');
|
|
128
|
+
assert.deepStrictEqual(snapshot(fixture.ledger), ledgerBefore, 'the fixture ledger is byte-identical after a run');
|
|
129
|
+
assert.deepStrictEqual(fs.readFileSync(fixture.report), reportBefore, 'the scan report is byte-identical after a run');
|
|
130
|
+
|
|
131
|
+
const markdown = run(fixture);
|
|
132
|
+
assert.strictEqual(markdown.status, 0, `Markdown output failed: ${markdown.stderr}`);
|
|
133
|
+
assert.match(markdown.stdout, /^Path overlap is a proxy/i);
|
|
134
|
+
assert.match(markdown.stdout, /\n\n\| Metric \| Value \|/);
|
|
135
|
+
assert.ok(markdown.stdout.includes('recall (all)') &&
|
|
136
|
+
markdown.stdout.includes('unmatched candidate share (path overlap)'));
|
|
137
|
+
assert.match(markdown.stdout, /path overlap is a proxy and may link distinct lessons/i);
|
|
138
|
+
assert.match(markdown.stdout, /recall \(all\) = linked records \/ all records/i);
|
|
139
|
+
assert.match(markdown.stdout, /recall \(comparable\) = linked records \/ comparable records/i);
|
|
140
|
+
|
|
141
|
+
const saved = path.join(fixture.root, 'oracle.json');
|
|
142
|
+
const savedResult = run(fixture, ['--json', '--out', saved]);
|
|
143
|
+
jsonResult(savedResult);
|
|
144
|
+
assert.deepStrictEqual(JSON.parse(fs.readFileSync(saved, 'utf8')), payload, '--out saves the JSON output');
|
|
145
|
+
|
|
146
|
+
const blocked = run(fixture, ['--json', '--out', path.join(fixture.ledger, 'forbidden.json')]);
|
|
147
|
+
assert.strictEqual(blocked.status, 2, 'an output path inside the ledger is rejected');
|
|
148
|
+
assert.match(blocked.stderr, /inside the ledger directory/);
|
|
149
|
+
assert.deepStrictEqual(snapshot(fixture.ledger), ledgerBefore, 'a rejected output path leaves every ledger byte unchanged');
|
|
150
|
+
const reportOverwrite = run(fixture, ['--json', '--out', fixture.report]);
|
|
151
|
+
assert.strictEqual(reportOverwrite.status, 2, 'the scan report cannot be used as an output path');
|
|
152
|
+
assert.deepStrictEqual(fs.readFileSync(fixture.report), reportBefore, 'a rejected output path leaves the scan report unchanged');
|
|
153
|
+
const reportHardlink = path.join(fixture.root, 'report-hardlink.json');
|
|
154
|
+
try {
|
|
155
|
+
fs.linkSync(fixture.report, reportHardlink);
|
|
156
|
+
const hardlinkOverwrite = run(fixture, ['--json', '--out', reportHardlink]);
|
|
157
|
+
assert.strictEqual(hardlinkOverwrite.status, 2, 'a hard link to the scan report cannot be used as output');
|
|
158
|
+
assert.deepStrictEqual(fs.readFileSync(fixture.report), reportBefore, 'a rejected hard link leaves the scan report unchanged');
|
|
159
|
+
} catch (error) {
|
|
160
|
+
if (!['EPERM', 'EACCES', 'ENOTSUP', 'ENOSYS', 'EINVAL'].includes(error.code)) throw error;
|
|
161
|
+
}
|
|
162
|
+
const ledgerAlias = path.join(fixture.root, 'errors-alias');
|
|
163
|
+
try {
|
|
164
|
+
fs.symlinkSync(fixture.ledger, ledgerAlias, 'dir');
|
|
165
|
+
const aliasOutput = run(fixture, ['--json', '--out', path.join(ledgerAlias, 'forbidden.json')]);
|
|
166
|
+
assert.strictEqual(aliasOutput.status, 2, 'a symlinked path into the ledger is rejected');
|
|
167
|
+
assert.deepStrictEqual(snapshot(fixture.ledger), ledgerBefore, 'a symlinked output cannot write into the ledger');
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (!['EPERM', 'EACCES', 'ENOTSUP', 'ENOSYS', 'EINVAL'].includes(error.code)) throw error;
|
|
170
|
+
}
|
|
171
|
+
const danglingAlias = path.join(fixture.root, 'dangling-output');
|
|
172
|
+
try {
|
|
173
|
+
fs.symlinkSync(path.join(fixture.ledger, 'new-record.md'), danglingAlias);
|
|
174
|
+
const danglingOutput = run(fixture, ['--json', '--out', danglingAlias]);
|
|
175
|
+
assert.strictEqual(danglingOutput.status, 2, 'a dangling symlink into the ledger is rejected');
|
|
176
|
+
assert.deepStrictEqual(snapshot(fixture.ledger), ledgerBefore, 'a dangling symlink cannot create a ledger file');
|
|
177
|
+
} catch (error) {
|
|
178
|
+
if (!['EPERM', 'EACCES', 'ENOTSUP', 'ENOSYS', 'EINVAL'].includes(error.code)) throw error;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const zero = makeFixture('zero-candidates', [
|
|
182
|
+
{ id: 'E-0009', sites: ['src/never-linked.js'] }
|
|
183
|
+
], []);
|
|
184
|
+
const zeroPayload = jsonResult(run(zero, ['--json']));
|
|
185
|
+
assert.strictEqual(zeroPayload.rates.unmatchedShare, null, 'unmatched share is null when there are no candidates');
|
|
186
|
+
assert.strictEqual(zeroPayload.counts.unmatchedCandidates, 0);
|
|
187
|
+
const zeroMarkdown = run(zero);
|
|
188
|
+
assert.strictEqual(zeroMarkdown.status, 0, `zero-candidate Markdown output failed: ${zeroMarkdown.stderr}`);
|
|
189
|
+
assert.match(zeroMarkdown.stdout, /\| unmatched candidate share \(path overlap\) \| n\/a \|/);
|
|
190
|
+
|
|
191
|
+
const differentLessons = makeFixture('same-path-different-lessons', [
|
|
192
|
+
{ id: 'E-0012', sites: ['shared/ambiguous.js'], lesson: 'Database deadlock handling' }
|
|
193
|
+
], [
|
|
194
|
+
{ id: 'candidate-different-lesson', sites: ['shared/ambiguous.js'], title: 'CSS formatting only' }
|
|
195
|
+
]);
|
|
196
|
+
const differentLessonPayload = jsonResult(run(differentLessons, ['--json']));
|
|
197
|
+
assert.deepStrictEqual(differentLessonPayload.linked, [
|
|
198
|
+
{ id: 'E-0012', candidateIds: ['candidate-different-lesson'] }
|
|
199
|
+
], 'same-file candidates link even when their lesson text differs');
|
|
200
|
+
assert.strictEqual(differentLessonPayload.rates.unmatchedShare, 0,
|
|
201
|
+
'path overlap alone cannot identify a semantically unrelated candidate');
|
|
202
|
+
assert.match(differentLessonPayload.metricNote, /may link distinct lessons/i);
|
|
203
|
+
|
|
204
|
+
const windows = makeFixture('windows', [
|
|
205
|
+
{ id: 'E-0010', sites: ['Src\\Parser.JS'] },
|
|
206
|
+
{ id: 'E-0011', sites: ['C:\\repo\\src'] }
|
|
207
|
+
], [
|
|
208
|
+
{ id: 'candidate-win-case', sites: ['src/parser.js'] },
|
|
209
|
+
{ id: 'candidate-other-drive', sites: ['D:/repo/src/file.js'] }
|
|
210
|
+
]);
|
|
211
|
+
const windowsPayload = jsonResult(run(windows, ['--json', '--platform', 'win32']));
|
|
212
|
+
assert.deepStrictEqual(windowsPayload.linked, [
|
|
213
|
+
{ id: 'E-0010', candidateIds: ['candidate-win-case'] }
|
|
214
|
+
], 'win32 matching ignores case and never treats C: and D: paths as contained');
|
|
215
|
+
assert.deepStrictEqual(windowsPayload.nonComparable, ['E-0011']);
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
fs.rmSync(TMP, { recursive: true, force: true });
|
|
219
|
+
} catch (error) {
|
|
220
|
+
process.stderr.write(`temporary fixture cleanup failed: ${error.message}\n`);
|
|
221
|
+
process.exitCode = 1;
|
|
222
|
+
}
|