harness-everything 0.53.0 → 0.54.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +3 -1
- package/CHANGELOG.md +18 -0
- package/bin/cli.js +1 -0
- package/ci/invariant-routing.test.js +22 -3
- package/ci/mechanism-2al-codex-hooks-compat.test.js +56 -2
- package/ci/mechanism-349-ci-change-scope.test.js +78 -57
- package/ci/mechanism-397-cycle-import.test.js +18 -3
- package/ci/mechanism-check-packet-write-set.test.js +232 -0
- package/ci/mechanism-codex-prompt-pass-through.test.js +8 -4
- package/ci/mechanism-error-handling-map.test.js +219 -0
- package/ci/mechanism-report-writer.test.js +335 -0
- package/ci/router-workflow-plan.test.js +50 -7
- package/docs/architecture.md +4 -3
- package/docs/error-handling/README.md +250 -0
- package/docs/error-handling/actions/c1-action-map.md +89 -0
- package/docs/error-handling/actions/c2-action-map.md +22 -0
- package/docs/error-handling/actions/c3-action-map.md +26 -0
- package/docs/error-handling/actions/c5-action-map.md +31 -0
- package/docs/error-handling/actions/c6-action-map.md +37 -0
- package/docs/error-handling/actions/c7-action-map.md +18 -0
- package/docs/error-handling/actions/e0002-action-map.md +101 -0
- package/docs/error-handling/activity.puml +84 -0
- package/docs/error-handling/details/c1-authority-conformance.md +93 -0
- package/docs/error-handling/details/c2-test-root-containment.md +35 -0
- package/docs/error-handling/details/c3-mode-ownership.md +50 -0
- package/docs/error-handling/details/c5-host-replay-contract.md +40 -0
- package/docs/error-handling/details/c6-packet-briefing.md +65 -0
- package/docs/error-handling/details/c7-write-set-check.md +54 -0
- package/docs/error-handling/details/e0002-capture-evidence.md +93 -0
- package/docs/error-handling/details/e0002-report-writer.md +116 -0
- package/docs/error-handling/nodes.yaml +44 -0
- package/docs/error-handling/registry.md +59 -0
- package/docs/error-handling/templates/packet-briefing.md +45 -0
- package/docs/platform-capabilities.md +3 -1
- package/hooks/scripts/codex-user-prompt.js +2 -3
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +2 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/codex-user-prompt.js +2 -3
- package/plugins/harness-everything/plugin.json +1 -1
- package/sbom.cdx.json +7 -7
- package/scripts/check-packet-write-set.js +155 -0
- package/scripts/codex-hooks-compat.js +46 -5
- package/scripts/error-handling-map.js +288 -0
- package/scripts/report-writer.js +261 -0
|
@@ -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.54.0",
|
|
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.54.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Miya Daniel"
|
|
7
7
|
},
|
package/AGENTS.md
CHANGED
|
@@ -92,7 +92,9 @@ flowchart LR
|
|
|
92
92
|
V -. optional .-> N["-- --node22<br/>(Node 22 smoke lane)"]
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
- `npm run verify:all` runs
|
|
95
|
+
- `npm run verify:all` runs a local subset of the hosted `ci.yml` gates and prints paste-ready PASS/FAIL/UNCHECKED evidence: 12 rows in the full plan, 4 with `--fast` (`npm test`, `test:mutations`, `test:consistency`, `test:portability`).
|
|
96
|
+
- Full rows: `npm test`, `test:mutations`, `test:consistency`, `test:references`, `test:release`, `test:collision`, `test:routing:skills`, `test:routing:invariants`, `test:plugin:openai`, `test:plugin:submission`, `test:platform:compatibility`, `test:portability`. `test:mechanism` runs inside `npm test`; `test:repo-contract` and `test:docs:capabilities` run inside `test:consistency`. Hosted CI runs the two `test:routing:*` rows inside `self-regression`.
|
|
97
|
+
- Hosted `ci.yml` jobs it does not run: `pilot-offline-evidence`, both System One Windows runtime-pin jobs, `release-semantics` (`test:release:semantics`), `skill-quality` (waza per-skill checks; only the optional `waza:check` row runs, and only when waza is installed), `installer-e2e` (`ci/installer-roundtrip.test.js`) and `npm ci` under Node 22 in `runtime-floor`. Local rows also run on one OS, where hosted `self-regression` and `consistency` run three.
|
|
96
98
|
- With waza (`~/bin/waza`): `waza check <skill-dir>`, `waza spec verify <skill> evals/<skill>/eval.yaml --fail --threshold 1`, `waza tokens check`.
|
|
97
99
|
- CI runs Node.js 24 on Ubuntu/Windows/macOS plus a Node.js 22 floor lane ([repository-contract.md](docs/repository-contract.md)). Node 22 install compatibility stays UNCHECKED locally.
|
|
98
100
|
- Never report "it works" from code reading. Name the evidence layer: package, deterministic mechanism, live host or behavior.
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.54.0](https://github.com/dyphn1/Harness-everything/compare/v0.53.0...v0.54.0) (2026-11-19)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **scripts:** add a read-only write-set check for packet slices ([5953f34](https://github.com/dyphn1/Harness-everything/commit/5953f34e04cc0722f74f716ab0e53559dd1ff5ad)), closes [#402](https://github.com/dyphn1/Harness-everything/issues/402)
|
|
10
|
+
* **scripts:** add a report writer that owns the terminal status line ([54beeee](https://github.com/dyphn1/Harness-everything/commit/54beeee19f8eb95d90aa40b91228376493039968)), closes [#402](https://github.com/dyphn1/Harness-everything/issues/402) [#441](https://github.com/dyphn1/Harness-everything/issues/441)
|
|
11
|
+
* **scripts:** add new, set-status and check for the error handling map ([4f9afe2](https://github.com/dyphn1/Harness-everything/commit/4f9afe27de01ca1390a5f1b333831913f0df6a9e)), closes [#437](https://github.com/dyphn1/Harness-everything/issues/437) [#402](https://github.com/dyphn1/Harness-everything/issues/402) [#437](https://github.com/dyphn1/Harness-everything/issues/437)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **codex:** migrate stale tier-router prompt hooks ([d6aa9a7](https://github.com/dyphn1/Harness-everything/commit/d6aa9a711fac5007dc68ccf25732d67da8c448a5))
|
|
16
|
+
* **scripts:** check the write-set of the repository the command runs in ([bcf3c57](https://github.com/dyphn1/Harness-everything/commit/bcf3c577e32a4d6061298059d14caf05eaae210a)), closes [#402](https://github.com/dyphn1/Harness-everything/issues/402)
|
|
17
|
+
* **scripts:** let the cli status complete raw codex output without status ([b61ebea](https://github.com/dyphn1/Harness-everything/commit/b61ebea855fc265feaa0f63715f9500e1ee96f4b)), closes [#402](https://github.com/dyphn1/Harness-everything/issues/402)
|
|
18
|
+
|
|
5
19
|
## [0.53.0](https://github.com/dyphn1/Harness-everything/compare/v0.52.0...v0.53.0) (2026-11-18)
|
|
6
20
|
|
|
7
21
|
### Features
|
|
@@ -74,6 +88,10 @@ All notable changes to this project are documented in this file.
|
|
|
74
88
|
* **CI:** Skip the three-platform Node 24 self-regression matrix for pull requests limited to approved documentation, benchmark results, error ledger, or changelog paths.
|
|
75
89
|
* **doc-reconciliation:** credit only correlated, bounded workflow-state operations for the approved row-17 outline cycle
|
|
76
90
|
|
|
91
|
+
### Bug Fixes
|
|
92
|
+
|
|
93
|
+
* **codex:** report stale npx tier-router prompt hooks and let users migrate them to the JSON adapter (#457).
|
|
94
|
+
|
|
77
95
|
## [0.50.0](https://github.com/dyphn1/Harness-everything/compare/v0.49.0...v0.50.0) (2026-11-09)
|
|
78
96
|
|
|
79
97
|
### Features
|
package/bin/cli.js
CHANGED
|
@@ -112,6 +112,7 @@ Commands:
|
|
|
112
112
|
that fail to mount enabled plugin-bundled hooks.
|
|
113
113
|
Usage: harness codex-hooks <install|status|uninstall>
|
|
114
114
|
[--codex-home <path>] [--allow-unreleased-source]
|
|
115
|
+
Install option: --remove-legacy-tier-router
|
|
115
116
|
Does not trust hooks or modify Codex config.toml.
|
|
116
117
|
plugin-sync Install or update the native Harness plugin on Claude Code
|
|
117
118
|
and Codex. Existing installations always take the update
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
|
-
const fs=require('fs'),path=require('path'),{spawnSync}=require('child_process');
|
|
3
|
+
const fs=require('fs'),path=require('path'),{spawnSync:spawnNodeSync}=require('child_process');
|
|
4
|
+
function spawnSync(command,args,options={}){
|
|
5
|
+
const {systemOneMode='off',...spawnOptions}=options;
|
|
6
|
+
return spawnNodeSync(command,args,{...spawnOptions,env:{...process.env,...(spawnOptions.env||{}),HARNESS_SYSTEM_ONE_MODE:systemOneMode}});
|
|
7
|
+
}
|
|
4
8
|
const ROOT=path.resolve(__dirname,'..');let failed=0;
|
|
5
9
|
function check(c,m){if(c)console.log(' PASS '+m);else{console.error(' FAIL '+m);failed++;}}
|
|
6
10
|
function read(p){return fs.readFileSync(path.join(ROOT,p),'utf8');}
|
|
7
11
|
console.log('=== Semantic Contract-Strength Routing Contract ===');
|
|
8
12
|
const kernel=path.join(ROOT,'harness-everything/scripts/kernel-router.js');
|
|
9
|
-
|
|
13
|
+
function runKernel(prompt, {systemOneMode='off'}={}){
|
|
14
|
+
return spawnSync(process.execPath,[kernel,prompt],{cwd:ROOT,encoding:'utf8',systemOneMode});
|
|
15
|
+
}
|
|
16
|
+
const priorMode=process.env.HARNESS_SYSTEM_ONE_MODE;
|
|
17
|
+
let inheritedLive;
|
|
18
|
+
try{
|
|
19
|
+
process.env.HARNESS_SYSTEM_ONE_MODE='live';
|
|
20
|
+
inheritedLive=runKernel('add a login endpoint with tests and update the implementation');
|
|
21
|
+
}finally{
|
|
22
|
+
if(priorMode===undefined)delete process.env.HARNESS_SYSTEM_ONE_MODE;
|
|
23
|
+
else process.env.HARNESS_SYSTEM_ONE_MODE=priorMode;
|
|
24
|
+
}
|
|
25
|
+
check(inheritedLive.status===0&&!inheritedLive.stdout.includes('SYSTEM ONE REFERENCE CONFIDENCE'),'kernel routing fixture ignores inherited live mode unless explicitly selected');
|
|
26
|
+
const explicitLive=runKernel('add a login endpoint with tests and update the implementation',{systemOneMode:'live'});
|
|
27
|
+
check(explicitLive.status===0&&explicitLive.stdout.includes('SYSTEM ONE REFERENCE CONFIDENCE'),'kernel routing fixture retains an explicit live-mode control');
|
|
28
|
+
const tier2=runKernel('add a login endpoint with tests and update the implementation');
|
|
10
29
|
check(tier2.status===0,'kernel router exits successfully');
|
|
11
30
|
check(/RECOMMENDED TIER:\s*Tier 2/i.test(tier2.stdout),'classifier result is preserved');
|
|
12
31
|
check(tier2.stdout.includes('"strategy":"iterative-single"'),'Tier 2 selects iterative-single workflow');
|
|
@@ -30,7 +49,7 @@ check(!tier2.stdout.includes('HARNESS ROUTING CHECKPOINT (REQUIRED VISIBLE STATE
|
|
|
30
49
|
check(tier2.stdout.includes('nested bullets when there are multiple items'),'kernel tells agents to split dense evidence into nested bullets');
|
|
31
50
|
check(tier2.stdout.includes('semantic communication MUST, not a hard execution lock'),'kernel separates semantic MUST from mechanical blocking');
|
|
32
51
|
|
|
33
|
-
const tier3=
|
|
52
|
+
const tier3=runKernel('audit the entire repository architecture and coordinate multiple modules');
|
|
34
53
|
check(tier3.status===0,'Tier 3 routing exits successfully');
|
|
35
54
|
check(/RECOMMENDED TIER:\s*Tier 3/i.test(tier3.stdout),'macro task remains Tier 3');
|
|
36
55
|
check(tier3.stdout.includes('isolated-worktree-before-mutation'),'Tier 3 keeps the worktree isolation invariant');
|
|
@@ -5,6 +5,7 @@ const assert = require('assert');
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const os = require('os');
|
|
7
7
|
const path = require('path');
|
|
8
|
+
const { spawnSync } = require('child_process');
|
|
8
9
|
|
|
9
10
|
const compat = require('../scripts/codex-hooks-compat');
|
|
10
11
|
|
|
@@ -62,6 +63,11 @@ const original = {
|
|
|
62
63
|
fs.writeFileSync(hooksFile, JSON.stringify(original, null, 4) + '\n', 'utf8');
|
|
63
64
|
fs.writeFileSync(configFile, 'model = "test"\n# user trust/config state\n', 'utf8');
|
|
64
65
|
const configBefore = fs.readFileSync(configFile, 'utf8');
|
|
66
|
+
const npxRouterPath = '_npx/9abc123def/node_modules/harness-everything/harness-everything/scripts/tier-router.js';
|
|
67
|
+
const legacyWindows = {
|
|
68
|
+
type: 'command',
|
|
69
|
+
commandWindows: 'node "C:\\Cache Dir\\' + npxRouterPath.replace(/\//g, '\\') + '"',
|
|
70
|
+
};
|
|
65
71
|
|
|
66
72
|
try {
|
|
67
73
|
const installed = compat.install({ allowUnreleasedSource: true, codexHome });
|
|
@@ -215,6 +221,52 @@ try {
|
|
|
215
221
|
fs.readFileSync(path.join(preexistingHome, 'hooks.json'), 'utf8') === preexistingBefore,
|
|
216
222
|
'uninstall preserves byte-identical hooks that predated compatibility install');
|
|
217
223
|
|
|
224
|
+
const legacyHome = path.join(root, 'legacy-codex');
|
|
225
|
+
fs.mkdirSync(legacyHome);
|
|
226
|
+
const legacyFile = path.join(legacyHome, 'hooks.json');
|
|
227
|
+
const legacyConfigFile = path.join(legacyHome, 'config.toml');
|
|
228
|
+
const direct = { type: 'command', command: 'node "/cache dir/' + npxRouterPath + '"' };
|
|
229
|
+
const customized = { ...direct, commandWindows: 'node "C:\\user\\my-prompt-hook.js"' };
|
|
230
|
+
const chained = { ...direct, command: direct.command + ' && echo custom' };
|
|
231
|
+
const localRouter = { ...direct, command: 'node "/user/scripts/tier-router.js"' };
|
|
232
|
+
const preserved = { matcher: '.*', hooks: [customized, chained, localRouter] };
|
|
233
|
+
const otherEvent = { hooks: [direct] };
|
|
234
|
+
fs.writeFileSync(legacyConfigFile, configBefore);
|
|
235
|
+
fs.writeFileSync(legacyFile, JSON.stringify({ hooks: {
|
|
236
|
+
UserPromptSubmit: [{ ...preserved, hooks: [direct, ...preserved.hooks] }, { hooks: [legacyWindows, direct] }],
|
|
237
|
+
Stop: [otherEvent],
|
|
238
|
+
} }));
|
|
239
|
+
const beforeLegacyStatus = fs.readFileSync(legacyFile, 'utf8');
|
|
240
|
+
const legacyStatus = compat.status({ codexHome: legacyHome });
|
|
241
|
+
assert.strictEqual(legacyStatus.installed, false);
|
|
242
|
+
assert.deepStrictEqual(legacyStatus.legacyTierRouterHooks, [direct, legacyWindows, direct]);
|
|
243
|
+
assert.strictEqual(fs.readFileSync(legacyFile, 'utf8'), beforeLegacyStatus);
|
|
244
|
+
|
|
245
|
+
const legacyInstall = compat.install({ allowUnreleasedSource: true, codexHome: legacyHome });
|
|
246
|
+
assert.deepStrictEqual(legacyInstall.legacyTierRouterHooks, legacyStatus.legacyTierRouterHooks);
|
|
247
|
+
assert.deepStrictEqual(compat.status({ codexHome: legacyHome }).legacyTierRouterHooks, legacyStatus.legacyTierRouterHooks);
|
|
248
|
+
|
|
249
|
+
const migration = spawnSync(process.execPath, [
|
|
250
|
+
path.join(__dirname, '..', 'bin', 'cli.js'), 'codex-hooks', 'install',
|
|
251
|
+
'--codex-home', legacyHome, '--allow-unreleased-source', '--remove-legacy-tier-router',
|
|
252
|
+
], { encoding: 'utf8', timeout: 30000 });
|
|
253
|
+
assert.strictEqual(migration.status, 0, migration.stderr || String(migration.error));
|
|
254
|
+
assert.strictEqual(JSON.parse(migration.stdout).removedLegacyTierRouterHooks, 3);
|
|
255
|
+
const migrated = read(legacyFile);
|
|
256
|
+
assert.deepStrictEqual(migrated.hooks.UserPromptSubmit[0], preserved);
|
|
257
|
+
assert.deepStrictEqual(migrated.hooks.Stop[0], otherEvent);
|
|
258
|
+
const promptCommands = migrated.hooks.UserPromptSubmit.slice(1).flatMap(group => group.hooks);
|
|
259
|
+
assert.deepStrictEqual(promptCommands.map(hook => path.posix.basename(hook.command).replace(/"$/, '')),
|
|
260
|
+
['codex-user-prompt.js', 'observation-hook.js']);
|
|
261
|
+
assert.strictEqual(fs.readFileSync(legacyConfigFile, 'utf8'), configBefore);
|
|
262
|
+
const migratedStatus = compat.status({ codexHome: legacyHome });
|
|
263
|
+
assert.strictEqual(migratedStatus.healthy, true);
|
|
264
|
+
assert.deepStrictEqual(migratedStatus.legacyTierRouterHooks, []);
|
|
265
|
+
const retried = compat.install({ allowUnreleasedSource: true, codexHome: legacyHome, removeLegacyTierRouter: true });
|
|
266
|
+
assert.strictEqual(retried.removedLegacyTierRouterHooks, 0);
|
|
267
|
+
assert.deepStrictEqual(read(legacyFile), migrated);
|
|
268
|
+
console.log(' PASS opt-in migration removes only legacy prompt handlers, installs one adapter, and is idempotent (#457)');
|
|
269
|
+
|
|
218
270
|
const forgedManifestHome = path.join(root, 'forged-manifest-codex');
|
|
219
271
|
fs.mkdirSync(forgedManifestHome, { recursive: true });
|
|
220
272
|
fs.writeFileSync(path.join(forgedManifestHome, 'hooks.json'),
|
|
@@ -241,7 +293,9 @@ try {
|
|
|
241
293
|
fs.mkdirSync(failedInstallHome, { recursive: true });
|
|
242
294
|
const failedInstallHooks = path.join(failedInstallHome, 'hooks.json');
|
|
243
295
|
fs.writeFileSync(failedInstallHooks,
|
|
244
|
-
JSON.stringify({ description: 'must survive', hooks: {
|
|
296
|
+
JSON.stringify({ description: 'must survive', hooks: {
|
|
297
|
+
PreToolUse: [userHook], UserPromptSubmit: [{ hooks: [legacyWindows] }],
|
|
298
|
+
} }, null, 4) + '\n',
|
|
245
299
|
'utf8');
|
|
246
300
|
const failedInstallBefore = fs.readFileSync(failedInstallHooks, 'utf8');
|
|
247
301
|
const failedManifestPath = path.join(
|
|
@@ -254,7 +308,7 @@ try {
|
|
|
254
308
|
}
|
|
255
309
|
return realRenameSync(source, destination);
|
|
256
310
|
};
|
|
257
|
-
try { compat.install({ allowUnreleasedSource: true, codexHome: failedInstallHome }); }
|
|
311
|
+
try { compat.install({ allowUnreleasedSource: true, codexHome: failedInstallHome, removeLegacyTierRouter: true }); }
|
|
258
312
|
catch (error) { failedInstallRefused = /injected manifest commit failure/.test(error.message); }
|
|
259
313
|
finally { fs.renameSync = realRenameSync; }
|
|
260
314
|
check(failedInstallRefused &&
|
|
@@ -11,7 +11,6 @@ const { classifyPaths, classifyChangeSet } = require('../scripts/ci-change-scope
|
|
|
11
11
|
|
|
12
12
|
const ROOT = path.resolve(__dirname, '..');
|
|
13
13
|
const SCRIPT = path.join(ROOT, 'scripts', 'ci-change-scope.js');
|
|
14
|
-
const BASELINE_SHA = '71a8706061f2fdec657b1c2b348571aa6c40e877';
|
|
15
14
|
const CHANGE_SCOPE_JOB = 'ci-change-scope';
|
|
16
15
|
const SELF_REGRESSION_IF = "${{ !cancelled() && (needs.ci-change-scope.result != 'success' || needs.ci-change-scope.outputs.scope != 'docs-only') }}";
|
|
17
16
|
|
|
@@ -42,16 +41,79 @@ function runClassifier(event, base, head, cwd = ROOT) {
|
|
|
42
41
|
return result.stdout.trim();
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
function baselineFile(file) {
|
|
46
|
-
// Pin the pre-change tree; GitHub's pull_request HEAD is the candidate merge ref.
|
|
47
|
-
return execFileSync('git', ['show', `${BASELINE_SHA}:${file}`], { cwd: ROOT, encoding: 'utf8' });
|
|
48
|
-
}
|
|
49
|
-
|
|
50
44
|
// This models the condition's truth table, not GitHub's scheduler.
|
|
51
45
|
function shouldRunSelfRegression(workflowCancelled, result, scope) {
|
|
52
46
|
return !workflowCancelled && (result !== 'success' || scope !== 'docs-only');
|
|
53
47
|
}
|
|
54
48
|
|
|
49
|
+
// Assert the intended scope-gating invariants against parsed workflow documents.
|
|
50
|
+
// Taking documents (not git history or whole-file text) keeps unrelated CI edits
|
|
51
|
+
// green and lets the oracle be replayed against mutated copies of the YAML.
|
|
52
|
+
function assertScopeGating({ ci, release, governance }) {
|
|
53
|
+
const jobs = ci.jobs;
|
|
54
|
+
const classifier = jobs[CHANGE_SCOPE_JOB];
|
|
55
|
+
const selfRegression = jobs['self-regression'];
|
|
56
|
+
assert.ok(classifier, 'the ci-change-scope job exists');
|
|
57
|
+
assert.ok(selfRegression, 'the self-regression job exists');
|
|
58
|
+
|
|
59
|
+
// Only self-regression may be gated by the classifier. Other jobs, their
|
|
60
|
+
// steps and later added ungated jobs are deliberately left unpinned.
|
|
61
|
+
for (const [jobId, job] of Object.entries(jobs)) {
|
|
62
|
+
if (jobId === CHANGE_SCOPE_JOB || jobId === 'self-regression') continue;
|
|
63
|
+
assert.ok(!Object.hasOwn(job, 'if'), `${jobId} must not be gated`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// The classifier runs only on pull requests and wires its scope output.
|
|
67
|
+
assert.equal(classifier.if, "${{ github.event_name == 'pull_request' }}");
|
|
68
|
+
assert.deepEqual(classifier.outputs, { scope: '${{ steps.scope.outputs.scope }}' });
|
|
69
|
+
const checkout = classifier.steps.find(step => step.uses === 'actions/checkout@v7');
|
|
70
|
+
assert.ok(checkout, 'the classifier checks out the repository');
|
|
71
|
+
assert.equal(checkout.with['fetch-depth'], 0, 'the classifier has complete Git history');
|
|
72
|
+
const node = classifier.steps.find(step => step.uses === 'actions/setup-node@v7');
|
|
73
|
+
assert.ok(node, 'the classifier sets up Node');
|
|
74
|
+
assert.equal(node.with['node-version'], 24);
|
|
75
|
+
const scope = classifier.steps.find(step => step.id === 'scope');
|
|
76
|
+
assert.ok(scope, 'the classifier produces the scope output');
|
|
77
|
+
assert.equal(scope.env.GITHUB_EVENT_NAME, undefined, 'the runner-provided GITHUB_EVENT_NAME is not overwritten');
|
|
78
|
+
assert.equal(scope.env.PR_BASE_SHA, '${{ github.event.pull_request.base.sha }}');
|
|
79
|
+
assert.equal(scope.env.PR_HEAD_SHA, '${{ github.event.pull_request.head.sha }}');
|
|
80
|
+
assert.match(scope.run, /node scripts\/ci-change-scope\.js "\$GITHUB_EVENT_NAME" "\$PR_BASE_SHA" "\$PR_HEAD_SHA"/);
|
|
81
|
+
assert.match(scope.run, /printf 'scope=%s\\n' "\$scope" >> "\$GITHUB_OUTPUT"/);
|
|
82
|
+
|
|
83
|
+
// Self-regression depends on the classifier and keeps the exact predicate.
|
|
84
|
+
assert.deepEqual(selfRegression.needs, [CHANGE_SCOPE_JOB]);
|
|
85
|
+
assert.equal(selfRegression.if, SELF_REGRESSION_IF, 'the full fallback predicate stays exact');
|
|
86
|
+
assert.ok(selfRegression.if.includes('!cancelled()'), 'workflow cancellation must disable self-regression');
|
|
87
|
+
assert.ok(!selfRegression.if.includes('always()'), 'always() keeps self-regression eligible during cancellation');
|
|
88
|
+
|
|
89
|
+
// The three-OS matrix stays complete.
|
|
90
|
+
assert.equal(selfRegression.strategy['fail-fast'], false);
|
|
91
|
+
assert.deepEqual(selfRegression.strategy.matrix.os, ['ubuntu-latest', 'windows-latest', 'macos-latest']);
|
|
92
|
+
|
|
93
|
+
// No workflow-level path filter may narrow what the classifier sees.
|
|
94
|
+
assert.ok(ci.on && Object.hasOwn(ci.on, 'push') && Object.hasOwn(ci.on, 'pull_request') &&
|
|
95
|
+
Object.hasOwn(ci.on, 'workflow_call'), 'push, pull_request and workflow_call triggers stay present');
|
|
96
|
+
const events = [ci.on, ci.on.push];
|
|
97
|
+
if (ci.on.pull_request && typeof ci.on.pull_request === 'object') events.push(ci.on.pull_request);
|
|
98
|
+
for (const event of events) {
|
|
99
|
+
assert.ok(!Object.hasOwn(event, 'paths'), 'no workflow-level paths filter');
|
|
100
|
+
assert.ok(!Object.hasOwn(event, 'paths-ignore'), 'no workflow-level paths-ignore filter');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// The reusable callers stay ungated, including any job added later.
|
|
104
|
+
assert.deepEqual(release.on.push.branches, ['main']);
|
|
105
|
+
assert.ok(Object.hasOwn(release.on, 'workflow_dispatch'));
|
|
106
|
+
assert.equal(release.jobs.gate.uses, './.github/workflows/ci.yml');
|
|
107
|
+
for (const [label, doc] of [['release.yml', release], ['doc-governance.yml', governance]]) {
|
|
108
|
+
assert.ok(doc && doc.jobs, `${label} declares jobs`);
|
|
109
|
+
for (const [jobId, job] of Object.entries(doc.jobs)) {
|
|
110
|
+
assert.ok(!Object.hasOwn(job, 'if'), `${label} job ${jobId} must not be gated`);
|
|
111
|
+
const needs = Array.isArray(job.needs) ? job.needs : job.needs ? [job.needs] : [];
|
|
112
|
+
assert.ok(!needs.includes(CHANGE_SCOPE_JOB), `${label} job ${jobId} must not depend on the classifier`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
55
117
|
test('each owner-approved path class and their combination classify as docs-only', () => {
|
|
56
118
|
for (const file of [
|
|
57
119
|
'docs/guide.md',
|
|
@@ -183,49 +245,12 @@ test('real Git merge-base diff includes earlier code, deletions, both rename end
|
|
|
183
245
|
});
|
|
184
246
|
|
|
185
247
|
test('the workflow gates only self-regression and fails open on every uncertain dependency/output state', () => {
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
assert.equal(workflow.name, before.name);
|
|
193
|
-
assert.deepEqual(workflow.on, before.on, 'push, pull_request, and reusable-workflow triggers stay unchanged');
|
|
194
|
-
assert.deepEqual(workflow.permissions, before.permissions);
|
|
195
|
-
assert.deepEqual(workflow.concurrency, before.concurrency);
|
|
196
|
-
assert.deepEqual(
|
|
197
|
-
Object.keys(workflow.jobs).sort(),
|
|
198
|
-
[...Object.keys(before.jobs), CHANGE_SCOPE_JOB].sort(),
|
|
199
|
-
'only the classifier job is added; existing job ids remain present',
|
|
200
|
-
);
|
|
201
|
-
for (const [jobId, original] of Object.entries(before.jobs)) {
|
|
202
|
-
const current = workflow.jobs[jobId];
|
|
203
|
-
if (jobId === 'self-regression') {
|
|
204
|
-
const { if: _condition, needs: _needs, ...unchanged } = current;
|
|
205
|
-
assert.deepEqual(unchanged, original, 'self-regression name, matrix, steps, and runtime stay unchanged');
|
|
206
|
-
} else {
|
|
207
|
-
assert.deepEqual(current, original, `${jobId} stays unchanged`);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const classifier = workflow.jobs[CHANGE_SCOPE_JOB];
|
|
212
|
-
assert.equal(classifier.if, "${{ github.event_name == 'pull_request' }}");
|
|
213
|
-
assert.deepEqual(classifier.outputs, { scope: '${{ steps.scope.outputs.scope }}' });
|
|
214
|
-
const checkout = classifier.steps.find(step => step.uses === 'actions/checkout@v7');
|
|
215
|
-
assert.equal(checkout.with['fetch-depth'], 0, 'the classifier has complete Git history');
|
|
216
|
-
const node = classifier.steps.find(step => step.uses === 'actions/setup-node@v7');
|
|
217
|
-
assert.equal(node.with['node-version'], 24);
|
|
218
|
-
const scope = classifier.steps.find(step => step.id === 'scope');
|
|
219
|
-
assert.equal(scope.env.GITHUB_EVENT_NAME, undefined, 'the runner-provided GITHUB_EVENT_NAME is not overwritten');
|
|
220
|
-
assert.equal(scope.env.PR_BASE_SHA, '${{ github.event.pull_request.base.sha }}');
|
|
221
|
-
assert.equal(scope.env.PR_HEAD_SHA, '${{ github.event.pull_request.head.sha }}');
|
|
222
|
-
assert.match(scope.run, /node scripts\/ci-change-scope\.js "\$GITHUB_EVENT_NAME" "\$PR_BASE_SHA" "\$PR_HEAD_SHA"/);
|
|
223
|
-
assert.match(scope.run, /printf 'scope=%s\\n' "\$scope" >> "\$GITHUB_OUTPUT"/);
|
|
224
|
-
const selfRegressionIf = workflow.jobs['self-regression'].if;
|
|
225
|
-
assert.ok(selfRegressionIf.includes('!cancelled()'), 'workflow cancellation must disable self-regression');
|
|
226
|
-
assert.ok(!selfRegressionIf.includes('always()'), 'always() keeps self-regression eligible during cancellation');
|
|
227
|
-
assert.equal(selfRegressionIf, SELF_REGRESSION_IF, 'the full fallback predicate stays exact');
|
|
228
|
-
assert.deepEqual(workflow.jobs['self-regression'].needs, [CHANGE_SCOPE_JOB]);
|
|
248
|
+
const readWorkflow = file => yaml.load(fs.readFileSync(path.join(ROOT, file), 'utf8'));
|
|
249
|
+
assertScopeGating({
|
|
250
|
+
ci: readWorkflow('.github/workflows/ci.yml'),
|
|
251
|
+
release: readWorkflow('.github/workflows/release.yml'),
|
|
252
|
+
governance: readWorkflow('.github/workflows/doc-governance.yml'),
|
|
253
|
+
});
|
|
229
254
|
|
|
230
255
|
const gateCases = [
|
|
231
256
|
['successful docs-only classifier', false, 'success', 'docs-only', false],
|
|
@@ -244,17 +269,13 @@ test('the workflow gates only self-regression and fails open on every uncertain
|
|
|
244
269
|
assert.equal(shouldRunSelfRegression(workflowCancelled, result, output), expected, label);
|
|
245
270
|
}
|
|
246
271
|
|
|
247
|
-
const releaseFile = '.github/workflows/release.yml';
|
|
248
|
-
const governanceFile = '.github/workflows/doc-governance.yml';
|
|
249
|
-
assert.equal(fs.readFileSync(path.join(ROOT, releaseFile), 'utf8'), baselineFile(releaseFile));
|
|
250
|
-
assert.equal(fs.readFileSync(path.join(ROOT, governanceFile), 'utf8'), baselineFile(governanceFile));
|
|
251
|
-
const release = yaml.load(fs.readFileSync(path.join(ROOT, releaseFile), 'utf8'));
|
|
252
|
-
assert.deepEqual(release.on.push.branches, ['main']);
|
|
253
|
-
assert.ok(Object.hasOwn(release.on, 'workflow_dispatch'));
|
|
254
|
-
assert.equal(release.jobs.gate.uses, './.github/workflows/ci.yml');
|
|
255
272
|
assert.equal(classifyChangeSet('push', 'a'.repeat(40), 'b'.repeat(40), { runGit: unusedGitForWorkflow }), 'full');
|
|
256
273
|
});
|
|
257
274
|
|
|
258
275
|
function unusedGitForWorkflow() {
|
|
259
276
|
throw new Error('the release caller is a push/dispatch, so no PR diff may authorize a skip');
|
|
260
277
|
}
|
|
278
|
+
|
|
279
|
+
// Exported so the in-report mutant harness can replay the same oracle against
|
|
280
|
+
// parsed copies of the workflow documents without registering these tests.
|
|
281
|
+
module.exports = { assertScopeGating };
|
|
@@ -14,12 +14,27 @@ const ROOT = path.resolve(__dirname, '..');
|
|
|
14
14
|
const PLUGIN = path.join(ROOT, 'opencode-plugin', 'index.mjs');
|
|
15
15
|
function isOutside(root, dir, pathApi = path) {
|
|
16
16
|
const relative = pathApi.relative(root, dir);
|
|
17
|
-
return relative.startsWith(
|
|
17
|
+
return relative === '..' || relative.startsWith(`..${pathApi.sep}`) || pathApi.isAbsolute(relative);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const win32Root = 'D:\\a\\Harness-everything\\Harness-everything';
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
test('test-root containment handles Windows path boundaries', () => {
|
|
22
|
+
const win32Parent = path.win32.dirname(win32Root);
|
|
23
|
+
const win32Child = path.win32.join(win32Root, 'ci');
|
|
24
|
+
const win32DotChild = path.win32.join(win32Root, '..cache');
|
|
25
|
+
const win32Sibling = path.win32.join(win32Parent, `${path.win32.basename(win32Root)}-other`);
|
|
26
|
+
const win32CrossDrive = 'C:\\Users\\runner\\AppData\\Local\\Temp\\fixture';
|
|
27
|
+
const crossDriveRelative = path.win32.relative(win32Root, win32CrossDrive);
|
|
28
|
+
|
|
29
|
+
assert.equal(isOutside(win32Root, win32Child, path.win32), false, 'a root child is inside');
|
|
30
|
+
assert.equal(isOutside(win32Root, win32DotChild, path.win32), false, 'a child whose name starts with two dots is still inside');
|
|
31
|
+
assert.equal(win32Sibling.startsWith(win32Root), true, 'the sibling shares the root string prefix');
|
|
32
|
+
assert.equal(isOutside(win32Root, win32Sibling, path.win32), true, 'a similar-prefix sibling is outside');
|
|
33
|
+
assert.equal(isOutside(win32Root, win32Parent, path.win32), true, 'the parent escape is outside');
|
|
34
|
+
assert.equal(path.win32.isAbsolute(crossDriveRelative), true, 'cross-drive relative result is absolute');
|
|
35
|
+
assert.equal(crossDriveRelative.startsWith('..'), false, 'the old prefix-only check misses a cross-drive path');
|
|
36
|
+
assert.equal(isOutside(win32Root, win32CrossDrive, path.win32), true, 'a cross-drive temp path is outside');
|
|
37
|
+
});
|
|
23
38
|
|
|
24
39
|
const LABELS = [
|
|
25
40
|
'<!-- harness-label {"v":1,"validity":"actionable","tier":"tier2","intents":["fix"],"workflow":"iterative-single","skills":[]} -->',
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const crypto = require('node:crypto');
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const os = require('node:os');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const { execFileSync, spawnSync } = require('node:child_process');
|
|
9
|
+
const { test } = require('node:test');
|
|
10
|
+
|
|
11
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
12
|
+
const CHECKER_SOURCE = path.join(ROOT, 'scripts', 'check-packet-write-set.js');
|
|
13
|
+
const FIXED_DATE = '2000-01-01T00:00:00Z';
|
|
14
|
+
|
|
15
|
+
function isOutside(root, target, pathApi = path) {
|
|
16
|
+
const relative = pathApi.relative(root, target);
|
|
17
|
+
return relative.startsWith('..') || pathApi.isAbsolute(relative);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
assert.equal(isOutside('D:\\repo', 'C:\\tmp\\fixture', path.win32), true, 'cross-drive fixtures are outside');
|
|
21
|
+
assert.equal(isOutside('D:\\repo', path.win32.join('D:\\repo', 'fixture'), path.win32), false, 'same-drive children are inside');
|
|
22
|
+
|
|
23
|
+
function gitEnv(tempRoot) {
|
|
24
|
+
const env = { ...process.env };
|
|
25
|
+
for (const key of Object.keys(env)) {
|
|
26
|
+
if (key.startsWith('GIT_')) delete env[key];
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
...env,
|
|
30
|
+
GIT_CONFIG_NOSYSTEM: '1',
|
|
31
|
+
GIT_CONFIG_GLOBAL: path.join(tempRoot, 'empty-global-config'),
|
|
32
|
+
GIT_OPTIONAL_LOCKS: '0',
|
|
33
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
34
|
+
GIT_AUTHOR_NAME: 'Packet Fixture',
|
|
35
|
+
GIT_AUTHOR_EMAIL: 'packet-fixture@example.test',
|
|
36
|
+
GIT_COMMITTER_NAME: 'Packet Fixture',
|
|
37
|
+
GIT_COMMITTER_EMAIL: 'packet-fixture@example.test',
|
|
38
|
+
GIT_AUTHOR_DATE: FIXED_DATE,
|
|
39
|
+
GIT_COMMITTER_DATE: FIXED_DATE,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function runGit(repo, tempRoot, args) {
|
|
44
|
+
return execFileSync('git', ['-C', repo, ...args], { env: gitEnv(tempRoot) });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function gitText(repo, tempRoot, ...args) {
|
|
48
|
+
return runGit(repo, tempRoot, args).toString('utf8').trim();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function write(repo, relativePath, content) {
|
|
52
|
+
const file = path.join(repo, ...relativePath.split('/'));
|
|
53
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
54
|
+
fs.writeFileSync(file, content);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function commitAll(repo, tempRoot, message) {
|
|
58
|
+
runGit(repo, tempRoot, ['add', '--all']);
|
|
59
|
+
runGit(repo, tempRoot, ['commit', '--quiet', '-m', message]);
|
|
60
|
+
return gitText(repo, tempRoot, 'rev-parse', 'HEAD');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function makeRepo(t) {
|
|
64
|
+
assert.ok(fs.existsSync(CHECKER_SOURCE), 'checker entry point must be available to the fixture invocation');
|
|
65
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'packet write set fixture '));
|
|
66
|
+
assert.ok(isOutside(ROOT, tempRoot), 'throwaway git repository is outside the checkout');
|
|
67
|
+
const repo = path.join(tempRoot, 'repo with spaces');
|
|
68
|
+
fs.mkdirSync(repo, { recursive: true });
|
|
69
|
+
execFileSync('git', ['init', '--quiet', repo], { env: gitEnv(tempRoot) });
|
|
70
|
+
t.after(() => fs.rmSync(tempRoot, { recursive: true, force: true }));
|
|
71
|
+
return { repo, tempRoot };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function runChecker(repo, tempRoot, { base, head, allow = [], allowFile } = {}) {
|
|
75
|
+
const args = [CHECKER_SOURCE, '--base', base];
|
|
76
|
+
if (head) args.push('--head', head);
|
|
77
|
+
for (const pattern of allow) args.push('--allow', pattern);
|
|
78
|
+
if (allowFile) args.push('--allow-file', allowFile);
|
|
79
|
+
const result = spawnSync(process.execPath, args, {
|
|
80
|
+
cwd: repo,
|
|
81
|
+
encoding: 'utf8',
|
|
82
|
+
env: gitEnv(tempRoot),
|
|
83
|
+
});
|
|
84
|
+
assert.equal(result.error, undefined, result.error && result.error.message);
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function outOfSetPaths(result) {
|
|
89
|
+
return result.stdout.split(/\r?\n/).filter(line => line.startsWith('OUT_OF_SET '))
|
|
90
|
+
.map(line => JSON.parse(line.slice('OUT_OF_SET '.length)));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function snapshotTree(root) {
|
|
94
|
+
const files = {};
|
|
95
|
+
function visit(directory) {
|
|
96
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
97
|
+
const file = path.join(directory, entry.name);
|
|
98
|
+
const relative = path.relative(root, file).split(path.sep).join('/');
|
|
99
|
+
if (entry.isDirectory()) visit(file);
|
|
100
|
+
else if (entry.isSymbolicLink()) files[relative] = `link:${fs.readlinkSync(file)}`;
|
|
101
|
+
else files[relative] = crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
visit(root);
|
|
105
|
+
return files;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
test('allows matching globs and allow files without accepting similar prefixes', t => {
|
|
109
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
110
|
+
write(repo, 'docs/guide.md', 'before\n');
|
|
111
|
+
write(repo, 'docs-extra/guide.md', 'before\n');
|
|
112
|
+
const unusualPath = process.platform === 'win32' ? 'docs/space and [guide].md' : 'docs/space and\n[guide].md';
|
|
113
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
114
|
+
|
|
115
|
+
write(repo, 'docs/guide.md', 'after\n');
|
|
116
|
+
write(repo, unusualPath, 'new\n');
|
|
117
|
+
write(repo, 'docs-extra/guide.md', 'after\n');
|
|
118
|
+
const head = commitAll(repo, tempRoot, 'change docs');
|
|
119
|
+
|
|
120
|
+
const partial = runChecker(repo, tempRoot, { base, head, allow: ['docs/**'] });
|
|
121
|
+
assert.equal(partial.status, 1, partial.stderr);
|
|
122
|
+
assert.deepEqual(outOfSetPaths(partial), ['docs-extra/guide.md']);
|
|
123
|
+
|
|
124
|
+
const allowFile = path.join(tempRoot, 'allow patterns.txt');
|
|
125
|
+
fs.writeFileSync(allowFile, 'docs/**\r\ndocs-extra/guide.md\r\n');
|
|
126
|
+
const allowed = runChecker(repo, tempRoot, { base, head, allowFile });
|
|
127
|
+
assert.equal(allowed.status, 0, allowed.stderr);
|
|
128
|
+
assert.deepEqual(outOfSetPaths(allowed), []);
|
|
129
|
+
assert.ok(allowed.stdout.includes(`ALLOWED ${JSON.stringify(unusualPath)}`));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('rejects a deleted path unless the deleted endpoint is allowed', t => {
|
|
133
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
134
|
+
write(repo, 'docs/delete-me.md', 'before\n');
|
|
135
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
136
|
+
fs.rmSync(path.join(repo, 'docs', 'delete-me.md'));
|
|
137
|
+
const head = commitAll(repo, tempRoot, 'delete path');
|
|
138
|
+
|
|
139
|
+
const rejected = runChecker(repo, tempRoot, { base, head, allow: ['docs/other.md'] });
|
|
140
|
+
assert.equal(rejected.status, 1, rejected.stderr);
|
|
141
|
+
assert.deepEqual(outOfSetPaths(rejected), ['docs/delete-me.md']);
|
|
142
|
+
const allowed = runChecker(repo, tempRoot, { base, head, allow: ['docs/delete-me.md'] });
|
|
143
|
+
assert.equal(allowed.status, 0, allowed.stderr);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test('checks both endpoints of a committed rename across the write-set boundary', t => {
|
|
147
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
148
|
+
write(repo, 'approved/old.txt', 'content\n');
|
|
149
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
150
|
+
fs.mkdirSync(path.join(repo, 'outside'), { recursive: true });
|
|
151
|
+
runGit(repo, tempRoot, ['mv', 'approved/old.txt', 'outside/new.txt']);
|
|
152
|
+
const head = commitAll(repo, tempRoot, 'move across boundary');
|
|
153
|
+
|
|
154
|
+
const oldAllowed = runChecker(repo, tempRoot, { base, head, allow: ['approved/**'] });
|
|
155
|
+
assert.equal(oldAllowed.status, 1, oldAllowed.stderr);
|
|
156
|
+
assert.deepEqual(outOfSetPaths(oldAllowed), ['outside/new.txt']);
|
|
157
|
+
const newAllowed = runChecker(repo, tempRoot, { base, head, allow: ['outside/**'] });
|
|
158
|
+
assert.equal(newAllowed.status, 1, newAllowed.stderr);
|
|
159
|
+
assert.deepEqual(outOfSetPaths(newAllowed), ['approved/old.txt']);
|
|
160
|
+
const bothAllowed = runChecker(repo, tempRoot, { base, head, allow: ['approved/**', 'outside/**'] });
|
|
161
|
+
assert.equal(bothAllowed.status, 0, bothAllowed.stderr);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('checks staged, unstaged, untracked and staged-rename paths without mutating the worktree', t => {
|
|
165
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
166
|
+
write(repo, '.gitignore', 'ignored/**\n');
|
|
167
|
+
write(repo, 'tracked.txt', 'before\n');
|
|
168
|
+
write(repo, 'move/old.txt', 'content\n');
|
|
169
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
170
|
+
|
|
171
|
+
write(repo, 'tracked.txt', 'after\n');
|
|
172
|
+
write(repo, 'staged.txt', 'staged\n');
|
|
173
|
+
runGit(repo, tempRoot, ['add', '--', 'staged.txt']);
|
|
174
|
+
fs.mkdirSync(path.join(repo, 'generated'), { recursive: true });
|
|
175
|
+
runGit(repo, tempRoot, ['mv', 'move/old.txt', 'generated/moved.txt']);
|
|
176
|
+
write(repo, 'generated/untracked.json', '{"generated":true}\n');
|
|
177
|
+
write(repo, 'ignored/output.log', 'ignored\n');
|
|
178
|
+
const before = snapshotTree(repo);
|
|
179
|
+
|
|
180
|
+
const partial = runChecker(repo, tempRoot, { base, allow: ['staged.txt'] });
|
|
181
|
+
assert.equal(partial.status, 1, partial.stderr);
|
|
182
|
+
assert.deepEqual(outOfSetPaths(partial), [
|
|
183
|
+
'generated/moved.txt',
|
|
184
|
+
'generated/untracked.json',
|
|
185
|
+
'move/old.txt',
|
|
186
|
+
'tracked.txt',
|
|
187
|
+
]);
|
|
188
|
+
assert.ok(!partial.stdout.includes('ignored/output.log'), 'ignored untracked output is excluded');
|
|
189
|
+
|
|
190
|
+
const explicitHead = runChecker(repo, tempRoot, { base, head: 'HEAD', allow: ['staged.txt'] });
|
|
191
|
+
assert.equal(explicitHead.status, 1, explicitHead.stderr);
|
|
192
|
+
assert.deepEqual(outOfSetPaths(explicitHead), outOfSetPaths(partial));
|
|
193
|
+
|
|
194
|
+
const allAllowed = runChecker(repo, tempRoot, {
|
|
195
|
+
base,
|
|
196
|
+
allow: ['generated/**', 'move/**', 'staged.txt', 'tracked.txt'],
|
|
197
|
+
});
|
|
198
|
+
assert.equal(allAllowed.status, 0, allAllowed.stderr);
|
|
199
|
+
assert.deepEqual(snapshotTree(repo), before, 'checker leaves files and Git metadata byte-identical');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test('compares only the requested commits when --head is not the worktree HEAD', t => {
|
|
203
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
204
|
+
write(repo, 'base.txt', 'base\n');
|
|
205
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
206
|
+
write(repo, 'allowed.txt', 'in requested head\n');
|
|
207
|
+
const head = commitAll(repo, tempRoot, 'requested head');
|
|
208
|
+
write(repo, 'later.txt', 'after requested head\n');
|
|
209
|
+
commitAll(repo, tempRoot, 'worktree HEAD');
|
|
210
|
+
write(repo, 'dirty.txt', 'uncommitted\n');
|
|
211
|
+
|
|
212
|
+
const result = runChecker(repo, tempRoot, { base, head, allow: ['allowed.txt'] });
|
|
213
|
+
assert.equal(result.status, 0, result.stderr);
|
|
214
|
+
assert.deepEqual(outOfSetPaths(result), []);
|
|
215
|
+
assert.match(result.stdout, /commits only/i);
|
|
216
|
+
assert.doesNotMatch(result.stdout, /later\.txt|dirty\.txt/);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test('returns usage errors for an unknown base and a missing allow list', t => {
|
|
220
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
221
|
+
write(repo, 'tracked.txt', 'base\n');
|
|
222
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
223
|
+
|
|
224
|
+
const badBase = runChecker(repo, tempRoot, { base: 'missing-base', allow: ['tracked.txt'] });
|
|
225
|
+
assert.equal(badBase.status, 2);
|
|
226
|
+
assert.match(badBase.stderr, /base|commit|revision/i);
|
|
227
|
+
|
|
228
|
+
const missingAllow = spawnSync(process.execPath, [
|
|
229
|
+
CHECKER_SOURCE, '--base', base,
|
|
230
|
+
], { cwd: repo, encoding: 'utf8', env: gitEnv(tempRoot) });
|
|
231
|
+
assert.equal(missingAllow.status, 2);
|
|
232
|
+
});
|