@sabaiway/agent-workflow-kit 20.1.0 → 21.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +7 -5
- package/SKILL.md +1 -1
- package/bin/install.mjs +10 -11
- package/capability.json +1 -1
- package/launchers/windsurf-workflow.md +3 -1
- package/package.json +5 -2
- package/references/contracts.md +9 -9
- package/references/modes/bootstrap.md +3 -3
- package/references/modes/commit-guard.md +1 -1
- package/references/modes/gates.md +1 -1
- package/references/modes/recommendations.md +2 -2
- package/references/modes/upgrade.md +4 -4
- package/references/scripts/{archive-caps.mjs → archives/archive-caps.mjs} +1 -1
- package/references/scripts/{archive-changelog.mjs → archives/archive-changelog.mjs} +7 -9
- package/references/scripts/{archive-decisions.mjs → archives/archive-decisions.mjs} +13 -10
- package/references/scripts/{archive-issues.mjs → archives/archive-issues.mjs} +7 -8
- package/references/scripts/{check-docs-size.mjs → docs-size/check-docs-size.mjs} +3 -4
- package/references/scripts/docs-size/index.mjs +2 -0
- package/references/scripts/family.json +43 -0
- package/references/scripts/family.mjs +90 -0
- package/references/scripts/gates/kit-command-gates.mjs +117 -0
- package/references/scripts/{migrate-gates.mjs → gates/migrate-gates.mjs} +30 -13
- package/references/scripts/{install-git-hooks.mjs → git-hooks/install-git-hooks.mjs} +50 -38
- package/references/scripts/run.mjs +74 -0
- package/references/scripts/shared/index.mjs +3 -0
- package/references/scripts/shared/project-root.mjs +11 -0
- package/references/scripts/spec-schema/index.mjs +2 -0
- package/references/shared/composition-handoff.md +1 -1
- package/references/shared/deploy-tail.md +2 -2
- package/references/templates/SPEC_TEMPLATE.md +1 -1
- package/references/templates/adr-record.md +3 -3
- package/tools/apply-danger-check.mjs +9 -5
- package/tools/atomic-write.mjs +3 -1
- package/tools/checker-gates-read.mjs +4 -1
- package/tools/direct-run.mjs +2 -0
- package/tools/distribution-files/retired.mjs +99 -0
- package/tools/distribution-files/scripts.mjs +67 -52
- package/tools/ensure-configs.mjs +21 -21
- package/tools/ensure-ops.mjs +60 -18
- package/tools/ensure-specs.mjs +82 -47
- package/tools/ensure-vocabulary.mjs +4 -4
- package/tools/epic-shape-cli.mjs +1 -1
- package/tools/epic-shape-ledger.mjs +1 -1
- package/tools/epic-shape.mjs +1 -1
- package/tools/family-registry.mjs +3 -1
- package/tools/feedback-record-cli.mjs +1 -1
- package/tools/fold-scope.mjs +2 -2
- package/tools/gates-declaration.mjs +8 -4
- package/tools/git-hooks.mjs +90 -65
- package/tools/jev-connect.mjs +1 -1
- package/tools/jev-guide.mjs +1 -1
- package/tools/jev-skill.mjs +1 -1
- package/tools/known-footprint.mjs +7 -29
- package/tools/node-evidence.mjs +29 -15
- package/tools/now-cli.mjs +1 -1
- package/tools/payload-prune.mjs +53 -58
- package/tools/plan-shape-cli.mjs +1 -1
- package/tools/plan-shape.mjs +1 -1
- package/tools/project-rules/rules-record.mjs +1 -1
- package/tools/queue-audit-cli.mjs +1 -1
- package/tools/queue-audit.mjs +2 -2
- package/tools/queue-purge-archive.mjs +1 -1
- package/tools/queue-purge-cli.mjs +1 -1
- package/tools/queue-purge.mjs +1 -1
- package/tools/recommendations.mjs +22 -19
- package/tools/script-priors.mjs +31 -3
- package/tools/source-size/piles.mjs +1 -1
- package/tools/spec-adoption.mjs +1 -1
- package/tools/spec-check-ops.mjs +2 -2
- package/tools/spec-check.mjs +2 -2
- package/tools/spec-coverage.mjs +1 -1
- package/tools/tier-guide.mjs +1 -1
- package/tools/transition/index.mjs +1 -1
- package/tools/upgrade-runlist.mjs +1 -1
- package/tools/write-lanes.mjs +2 -2
- package/references/scripts/_expect-shim.mjs +0 -41
- package/references/scripts/archive-caps.test.mjs +0 -321
- package/references/scripts/archive-changelog.test.mjs +0 -560
- package/references/scripts/archive-conservation.test.mjs +0 -466
- package/references/scripts/archive-decisions.test.mjs +0 -1503
- package/references/scripts/archive-issues.test.mjs +0 -825
- package/references/scripts/archiver-structure.test.mjs +0 -84
- package/references/scripts/check-docs-size-cli.test.mjs +0 -325
- package/references/scripts/check-docs-size-ensure.test.mjs +0 -360
- package/references/scripts/check-docs-size.test.mjs +0 -395
- package/references/scripts/install-git-hooks-repo-exec.test.mjs +0 -185
- package/references/scripts/install-git-hooks.test.mjs +0 -241
- package/references/scripts/markdown-blocks.test.mjs +0 -310
- package/references/scripts/migrate-gates-branches.test.mjs +0 -302
- package/references/scripts/migrate-gates.test.mjs +0 -517
- package/references/scripts/spec-schema.test.mjs +0 -352
- /package/references/scripts/{markdown-blocks.mjs → shared/markdown-blocks.mjs} +0 -0
- /package/references/scripts/{spec-schema.mjs → spec-schema/spec-schema.mjs} +0 -0
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
// migrate-gates-branches.test.mjs — the refusal/no-op branch pins the main spec file leaves
|
|
2
|
-
// unexercised (colocated so the D3(d) changed-line check reads real executions, not intentions):
|
|
3
|
-
// the --help arm, the missing-declaration no-op, the invalid-shape STOP, the honest no-op split
|
|
4
|
-
// on final-run-capability, the mid-write parent-verification failure (fail closed + tmp cleanup),
|
|
5
|
-
// and the loud-but-non-fatal retired-store cleanup error.
|
|
6
|
-
|
|
7
|
-
import { describe, it } from 'node:test';
|
|
8
|
-
import assert from 'node:assert/strict';
|
|
9
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, readdirSync, lstatSync, rmSync, symlinkSync } from 'node:fs';
|
|
10
|
-
import { tmpdir } from 'node:os';
|
|
11
|
-
import { join } from 'node:path';
|
|
12
|
-
import { spawnSync } from 'node:child_process';
|
|
13
|
-
import { CHECKER_CLAIM, UNIT_TESTS_COVERAGE_FLAGS, RETIRED_STORE_BASENAMES, checkerClaimTool, classifyCheckerClaim, main } from './migrate-gates.mjs';
|
|
14
|
-
|
|
15
|
-
// Both core checks exist as real files — canonicity is a realpath anchor, so a check whose file is
|
|
16
|
-
// absent resolves to nothing and is no claim at all (the fail-closed answer run-gates gives too).
|
|
17
|
-
const KIT_TOOLS = mkdtempSync(join(tmpdir(), 'migrate-branches-kit-'));
|
|
18
|
-
writeFileSync(join(KIT_TOOLS, 'coverage-check.mjs'), '// the installed checker the migration points at\n');
|
|
19
|
-
writeFileSync(join(KIT_TOOLS, 'review-state.mjs'), '// the installed review-state check\n');
|
|
20
|
-
|
|
21
|
-
const mkProject = (gates) => {
|
|
22
|
-
const root = mkdtempSync(join(tmpdir(), 'migrate-branches-'));
|
|
23
|
-
mkdirSync(join(root, 'docs', 'ai'), { recursive: true });
|
|
24
|
-
if (gates !== undefined) {
|
|
25
|
-
writeFileSync(join(root, 'docs', 'ai', 'gates.json'), typeof gates === 'string' ? gates : `${JSON.stringify({ gates }, null, 2)}\n`);
|
|
26
|
-
}
|
|
27
|
-
return root;
|
|
28
|
-
};
|
|
29
|
-
const quiet = () => {
|
|
30
|
-
const out = [];
|
|
31
|
-
const err = [];
|
|
32
|
-
return { log: (l) => out.push(String(l)), error: (l) => err.push(String(l)), out, err };
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const UNIT_DONE = { id: 'unit-tests', title: 'U', cmd: `node --test ${UNIT_TESTS_COVERAGE_FLAGS} tools/*.test.mjs` };
|
|
36
|
-
const CHECKER = { id: 'coverage-check', title: 'CC', cmd: `node "${join(KIT_TOOLS, 'coverage-check.mjs')}" --check` };
|
|
37
|
-
const REVIEW_STATE = { id: 'review-state', title: 'RS', cmd: `node "${join(KIT_TOOLS, 'review-state.mjs')}" --check` };
|
|
38
|
-
const LEGACY = { id: 'review-ledger', title: 'L', cmd: 'node "/kit/tools/review-ledger.mjs" --check' };
|
|
39
|
-
const UNIT = { id: 'unit-tests', title: 'U', cmd: 'node --test tools/*.test.mjs' };
|
|
40
|
-
// A suite the closed producer world cannot express, declaring itself with the optional marker.
|
|
41
|
-
const MARKED_SUITE = { id: 'suite', title: 'S', cmd: 'pnpm vitest run --coverage', lcovProducer: true };
|
|
42
|
-
|
|
43
|
-
describe('migrate-gates — refusal and no-op branches', () => {
|
|
44
|
-
it('--help prints the contract and exits 0', () => {
|
|
45
|
-
const io = quiet();
|
|
46
|
-
assert.equal(main(['--help'], io), 0);
|
|
47
|
-
assert.match(io.out.join('\n'), /Usage:/);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('the no-op split is HONEST about final-run-capability (capable names it; incapable never does)', () => {
|
|
51
|
-
const capable = mkProject([UNIT_DONE, REVIEW_STATE, CHECKER]);
|
|
52
|
-
const io = quiet();
|
|
53
|
-
assert.equal(main(['--cwd', capable, '--kit-tools', KIT_TOOLS], io), 0);
|
|
54
|
-
assert.match(io.out.join('\n'), /already final-run-capable/);
|
|
55
|
-
rmSync(capable, { recursive: true, force: true });
|
|
56
|
-
|
|
57
|
-
const incapable = mkProject([UNIT_DONE, CHECKER]);
|
|
58
|
-
const io2 = quiet();
|
|
59
|
-
assert.equal(main(['--cwd', incapable, '--kit-tools', KIT_TOOLS], io2), 0);
|
|
60
|
-
const text = io2.out.join('\n');
|
|
61
|
-
assert.match(text, /nothing to migrate mechanically/);
|
|
62
|
-
assert.match(text, /NOT final-run-capable/);
|
|
63
|
-
assert.doesNotMatch(text, /already final-run-capable/);
|
|
64
|
-
rmSync(incapable, { recursive: true, force: true });
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('docs/ai WITHOUT a gates.json (and no stores) is a stated no-op, never a crash', () => {
|
|
68
|
-
const root = mkProject(undefined);
|
|
69
|
-
const io = quiet();
|
|
70
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0);
|
|
71
|
-
assert.match(io.out.join('\n'), /nothing to migrate/);
|
|
72
|
-
rmSync(root, { recursive: true, force: true });
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('a parseable-but-invalid declaration ({ gates: <non-array> }) is a loud STOP', () => {
|
|
76
|
-
const root = mkProject('{ "gates": 5 }\n');
|
|
77
|
-
const io = quiet();
|
|
78
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 1);
|
|
79
|
-
assert.match(io.err.join('\n'), /not a \{ gates/);
|
|
80
|
-
rmSync(root, { recursive: true, force: true });
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('an lstat failure DURING the write fails CLOSED — nothing written, the tmp cleaned', () => {
|
|
84
|
-
const root = mkProject([LEGACY, UNIT]);
|
|
85
|
-
const before = readFileSync(join(root, 'docs', 'ai', 'gates.json'), 'utf8');
|
|
86
|
-
const tmpExists = () => readdirSync(join(root, 'docs', 'ai')).some((f) => f.endsWith('.tmp'));
|
|
87
|
-
const io = {
|
|
88
|
-
...quiet(),
|
|
89
|
-
// Fail the parent verification the moment the tmp file exists — that is exactly the
|
|
90
|
-
// PRE-RENAME re-check, whatever the lstat call count is (count-anchored injection went
|
|
91
|
-
// silently stale once loadDeclaration became an lstat consumer too).
|
|
92
|
-
lstat: (p) => {
|
|
93
|
-
if (tmpExists()) throw Object.assign(new Error('injected EACCES'), { code: 'EACCES' });
|
|
94
|
-
return lstatSync(p);
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 1);
|
|
98
|
-
assert.match(io.err.join('\n'), /cannot verify the declaration parent/);
|
|
99
|
-
assert.equal(readFileSync(join(root, 'docs', 'ai', 'gates.json'), 'utf8'), before, 'the declaration is untouched');
|
|
100
|
-
assert.deepEqual(readdirSync(join(root, 'docs', 'ai')).filter((f) => f.endsWith('.tmp')), [], 'no tmp litter survives (the writer catch cleaned it)');
|
|
101
|
-
rmSync(root, { recursive: true, force: true });
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('a NON-canonical entry squatting the checker id is a loud STOP on preview AND apply (never a duplicate row)', () => {
|
|
105
|
-
const squatter = { id: 'coverage-check', title: 'C', cmd: 'node scripts/coverage-check.mjs --check' };
|
|
106
|
-
const root = mkProject([squatter, UNIT]);
|
|
107
|
-
for (const argv of [['--cwd', root, '--kit-tools', KIT_TOOLS], ['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply']]) {
|
|
108
|
-
const io = quiet();
|
|
109
|
-
assert.equal(main(argv, io), 1, `must STOP: ${argv.join(' ')}`);
|
|
110
|
-
assert.match(io.err.join('\n'), /id collision/);
|
|
111
|
-
}
|
|
112
|
-
const after = JSON.parse(readFileSync(join(root, 'docs', 'ai', 'gates.json'), 'utf8')).gates;
|
|
113
|
-
assert.equal(after.filter((g) => g.id === 'coverage-check').length, 1, 'nothing was written');
|
|
114
|
-
rmSync(root, { recursive: true, force: true });
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('a canonical checker addressed THROUGH A SYMLINKED kit dir is recognized (realpath, never lexical)', () => {
|
|
118
|
-
const linked = join(tmpdir(), `migrate-branches-link-${process.pid}`);
|
|
119
|
-
rmSync(linked, { force: true });
|
|
120
|
-
symlinkSync(KIT_TOOLS, linked);
|
|
121
|
-
const throughLink = { id: 'coverage-check', title: 'CC', cmd: `node "${join(linked, 'coverage-check.mjs')}" --check` };
|
|
122
|
-
const root = mkProject([throughLink, UNIT]);
|
|
123
|
-
const io = quiet();
|
|
124
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0, io.err.join('\n'));
|
|
125
|
-
const text = io.out.join('\n');
|
|
126
|
-
assert.doesNotMatch(text, /id collision/, 'the symlinked canonical checker is never a collision');
|
|
127
|
-
assert.doesNotMatch(text, /ADD coverage-check/, 'no duplicate checker is added');
|
|
128
|
-
rmSync(linked, { force: true });
|
|
129
|
-
rmSync(root, { recursive: true, force: true });
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('a NON-ENOENT lstat failure on the gates.json LEAF is a loud STOP — never read as "missing"', () => {
|
|
133
|
-
const root = mkProject([LEGACY, UNIT]);
|
|
134
|
-
spawnSync('git', ['init', '-q'], { cwd: root, encoding: 'utf8' });
|
|
135
|
-
writeFileSync(join(root, '.git', RETIRED_STORE_BASENAMES[0]), '{"dead":1}\n');
|
|
136
|
-
const io = {
|
|
137
|
-
...quiet(),
|
|
138
|
-
lstat: (p) => {
|
|
139
|
-
if (p.endsWith('gates.json')) throw Object.assign(new Error('injected EACCES'), { code: 'EACCES' });
|
|
140
|
-
return lstatSync(p);
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 1, 'an unreadable declaration must STOP the apply');
|
|
144
|
-
assert.match(io.err.join('\n'), /EACCES/);
|
|
145
|
-
assert.ok(lstatSync(join(root, '.git', RETIRED_STORE_BASENAMES[0])).isFile(), 'the retired store is untouched on the STOP');
|
|
146
|
-
rmSync(root, { recursive: true, force: true });
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('a marker-carrying entry survives an apply UNCHANGED — the loader is lenient, the writer opaque', () => {
|
|
150
|
-
// The declaration this tool rewrites may carry keys it knows nothing about. The loader accepts
|
|
151
|
-
// any `{ gates: [...] }` shape and the writer re-serializes the ENTRY, not a reconstruction of
|
|
152
|
-
// it, so an upgrade over a marker-carrying deployment never silently drops the claim.
|
|
153
|
-
const root = mkProject([LEGACY, MARKED_SUITE, REVIEW_STATE]);
|
|
154
|
-
const io = quiet();
|
|
155
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 0, io.err.join('\n'));
|
|
156
|
-
const raw = readFileSync(join(root, 'docs', 'ai', 'gates.json'), 'utf8');
|
|
157
|
-
const written = JSON.parse(raw).gates;
|
|
158
|
-
assert.deepEqual(written.map((g) => g.id), ['suite', 'review-state', 'coverage-check'], 'the checker is ADDED over a marker-claimed producer');
|
|
159
|
-
assert.deepEqual(written[0], MARKED_SUITE, 'the marked entry round-trips key for key');
|
|
160
|
-
assert.match(raw, /"lcovProducer": true/, 'and the marker is really in the written bytes');
|
|
161
|
-
assert.doesNotMatch(io.out.join('\n'), /WARNING/, 'nothing is withheld over a declared producer');
|
|
162
|
-
rmSync(root, { recursive: true, force: true });
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('a marker on the CHECKER ITSELF never self-pairs — the declared pair stays INERT', () => {
|
|
166
|
-
// The producer question is POSITIONAL: the checker always ends up last, so it can never be its
|
|
167
|
-
// own producer. Asking it over the whole kept set would let this declaration certify itself
|
|
168
|
-
// into final-run-capability with nothing writing the lcov.
|
|
169
|
-
const root = mkProject([{ id: 'lint', title: 'L', cmd: 'eslint .' }, REVIEW_STATE, { ...CHECKER, lcovProducer: true }]);
|
|
170
|
-
const io = quiet();
|
|
171
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0, io.err.join('\n'));
|
|
172
|
-
const text = io.out.join('\n');
|
|
173
|
-
assert.match(text, /INERT/, 'the dead pair is named');
|
|
174
|
-
assert.doesNotMatch(text, /already final-run-capable/, 'and never claimed capable');
|
|
175
|
-
rmSync(root, { recursive: true, force: true });
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('a MARKED unit-tests entry is a zero-diff keep — never extended, never reported customized', () => {
|
|
179
|
-
// Both arms the marker settles at once: `npm test` is a cmd this tool cannot verify (customized
|
|
180
|
-
// without the marker), and rewriting a cmd whose owner declared it the producer would change
|
|
181
|
-
// bytes the byte-exact hook approval binds.
|
|
182
|
-
const marked = { id: 'unit-tests', title: 'U', cmd: 'npm test', lcovProducer: true };
|
|
183
|
-
const root = mkProject([marked, REVIEW_STATE]);
|
|
184
|
-
const io = quiet();
|
|
185
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0, io.err.join('\n'));
|
|
186
|
-
const text = io.out.join('\n');
|
|
187
|
-
assert.match(text, /ADD coverage-check/, 'the claimed producer unlocks the checker');
|
|
188
|
-
assert.doesNotMatch(text, /EXTEND unit-tests/, 'a claimed producer cmd is never rewritten');
|
|
189
|
-
assert.doesNotMatch(text, /CUSTOMIZED/, 'nor reported as a cmd the tool cannot verify');
|
|
190
|
-
rmSync(root, { recursive: true, force: true });
|
|
191
|
-
|
|
192
|
-
// The SAME entry unmarked is the customized/withheld path — the marker is what settles it.
|
|
193
|
-
const bare = mkProject([{ id: 'unit-tests', title: 'U', cmd: 'npm test' }, REVIEW_STATE]);
|
|
194
|
-
const io2 = quiet();
|
|
195
|
-
assert.equal(main(['--cwd', bare, '--kit-tools', KIT_TOOLS], io2), 0, io2.err.join('\n'));
|
|
196
|
-
const text2 = io2.out.join('\n');
|
|
197
|
-
assert.match(text2, /CUSTOMIZED/);
|
|
198
|
-
assert.doesNotMatch(text2, /ADD coverage-check/, 'the checker stays withheld with no producer');
|
|
199
|
-
rmSync(bare, { recursive: true, force: true });
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('a marker over an UNRUNNABLE cmd never unlocks the checker — the lenient loader has no validator', () => {
|
|
203
|
-
// This tool accepts any `{ gates: [...] }` shape, so an entry the strict validator would refuse
|
|
204
|
-
// reaches the plan builder intact. A marker on such an entry must not make the migration ADD the
|
|
205
|
-
// canonical checker: the result would be the dead pair the withhold exists to prevent, and the
|
|
206
|
-
// written declaration would then fail run-gates outright.
|
|
207
|
-
for (const cmd of [' ', 'echo a\nrm -rf b']) {
|
|
208
|
-
const root = mkProject([{ id: 'suite', title: 'S', cmd, lcovProducer: true }, REVIEW_STATE]);
|
|
209
|
-
const io = quiet();
|
|
210
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0, io.err.join('\n'));
|
|
211
|
-
const text = io.out.join('\n');
|
|
212
|
-
assert.doesNotMatch(text, /ADD coverage-check/, `an unrunnable cmd must not unlock the checker: ${JSON.stringify(cmd)}`);
|
|
213
|
-
assert.match(text, /WARNING: the canonical coverage-check gate was NOT added/, 'and the withhold is stated');
|
|
214
|
-
rmSync(root, { recursive: true, force: true });
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('a marker on a DUPLICATE canonical checker never produces for the other — nor claims capability', () => {
|
|
219
|
-
// `--final` accepts exactly ONE canonical checker, and a checker cannot write the lcov it reads.
|
|
220
|
-
// Excluding only the LAST checker row from the producer search let a marker on the first one pair
|
|
221
|
-
// with the second, and the preview then called the result final-run-capable over a declaration
|
|
222
|
-
// --final rejects outright, with nothing writing the file.
|
|
223
|
-
const root = mkProject([{ ...CHECKER, id: 'coverage-check', lcovProducer: true }, REVIEW_STATE, { ...CHECKER, id: 'coverage-check-2' }]);
|
|
224
|
-
const io = quiet();
|
|
225
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0, io.err.join('\n'));
|
|
226
|
-
const text = io.out.join('\n');
|
|
227
|
-
assert.doesNotMatch(text, /already final-run-capable/, 'two checkers are never a final-run-capable result');
|
|
228
|
-
assert.match(text, /2 declared gates are the canonical coverage checker/, 'the duplication is NAMED');
|
|
229
|
-
assert.match(text, /INERT/, 'and the pair is still reported inert — nothing writes the lcov');
|
|
230
|
-
rmSync(root, { recursive: true, force: true });
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it('the tool-claim twin RUNS in this module — three outcomes, fail-closed on the unresolvable', () => {
|
|
234
|
-
// The text drift guard (beside the kit's own copy) proves the two owners are byte-equal; it
|
|
235
|
-
// cannot prove this copy WORKS, because the region is byte-equal inside a DIFFERENT host with
|
|
236
|
-
// different imports. Executing it here is what proves the twin resolves everything it uses.
|
|
237
|
-
const canonical = join(KIT_TOOLS, 'coverage-check.mjs');
|
|
238
|
-
const root = mkProject([]);
|
|
239
|
-
try {
|
|
240
|
-
const elsewhere = join(root, 'vendor-coverage-check.mjs');
|
|
241
|
-
writeFileSync(elsewhere, '// a vendored copy\n');
|
|
242
|
-
const tool = checkerClaimTool('coverage-check.mjs', canonical);
|
|
243
|
-
assert.equal(classifyCheckerClaim(tool, `node "${canonical}" --check`, KIT_TOOLS), CHECKER_CLAIM.CANONICAL);
|
|
244
|
-
const vendored = checkerClaimTool('vendor-coverage-check.mjs', canonical);
|
|
245
|
-
assert.equal(classifyCheckerClaim(vendored, `node "${elsewhere}" --check`, KIT_TOOLS), CHECKER_CLAIM.ELSEWHERE);
|
|
246
|
-
assert.equal(classifyCheckerClaim(tool, `node "${canonical}" --check || true`, KIT_TOOLS), CHECKER_CLAIM.NOT_THE_TOOL, 'a masked form is no claim');
|
|
247
|
-
assert.equal(classifyCheckerClaim(tool, `node "${join(KIT_TOOLS, 'nowhere', 'coverage-check.mjs')}" --check`, KIT_TOOLS), CHECKER_CLAIM.NOT_THE_TOOL, 'unresolvable fails closed');
|
|
248
|
-
assert.equal(classifyCheckerClaim(tool, 'node $(pwd)/coverage-check.mjs --check', KIT_TOOLS), CHECKER_CLAIM.NOT_THE_TOOL, 'a shell-active bare token is no claim');
|
|
249
|
-
} finally {
|
|
250
|
-
rmSync(root, { recursive: true, force: true }); // every other case here cleans up; this one held its root only for a path
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('a VENDORED deployment previews at exit 0 and its --apply writes ZERO bytes', () => {
|
|
255
|
-
// The upgrade path this fixes: every preview AND every apply over a deployment that declared the
|
|
256
|
-
// checker through its own vendored copy used to exit 1 on an id collision, so such a deployment
|
|
257
|
-
// could not be upgraded at all.
|
|
258
|
-
const vendoredTools = mkdtempSync(join(tmpdir(), 'migrate-branches-vendored-'));
|
|
259
|
-
writeFileSync(join(vendoredTools, 'coverage-check.mjs'), '// a vendored copy of the checker\n');
|
|
260
|
-
const vendored = { id: 'coverage-check', title: 'CC', cmd: `node "${join(vendoredTools, 'coverage-check.mjs')}" --check` };
|
|
261
|
-
const root = mkProject([UNIT_DONE, REVIEW_STATE, vendored]);
|
|
262
|
-
const before = readFileSync(join(root, 'docs', 'ai', 'gates.json'), 'utf8');
|
|
263
|
-
|
|
264
|
-
const io = quiet();
|
|
265
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0, io.err.join('\n'));
|
|
266
|
-
const preview = io.out.join('\n');
|
|
267
|
-
assert.match(preview, /VERIFY \(preserved exactly as declared\): coverage-check/);
|
|
268
|
-
assert.doesNotMatch(preview, /ADD coverage-check/, 'nothing is added over a checker that is already declared');
|
|
269
|
-
assert.doesNotMatch(io.err.join('\n'), /id collision/, 'a vendored copy is not a squatter');
|
|
270
|
-
|
|
271
|
-
const io2 = quiet();
|
|
272
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io2), 0, io2.err.join('\n'));
|
|
273
|
-
assert.equal(readFileSync(join(root, 'docs', 'ai', 'gates.json'), 'utf8'), before, 'the apply is a ZERO-DIFF write');
|
|
274
|
-
assert.match(io2.out.join('\n'), /NOT final-run-capable/, 'and the withheld claim survives the no-op apply');
|
|
275
|
-
rmSync(vendoredTools, { recursive: true, force: true });
|
|
276
|
-
rmSync(root, { recursive: true, force: true });
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it('a vendored copy named by a RELATIVE path resolves against the PROJECT root, as the runner resolves it', () => {
|
|
280
|
-
const root = mkProject([UNIT_DONE, REVIEW_STATE, { id: 'coverage-check', title: 'CC', cmd: 'node "vendor/coverage-check.mjs" --check' }]);
|
|
281
|
-
mkdirSync(join(root, 'vendor'), { recursive: true });
|
|
282
|
-
writeFileSync(join(root, 'vendor', 'coverage-check.mjs'), '// a vendored copy inside the project\n');
|
|
283
|
-
const io = quiet();
|
|
284
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0, io.err.join('\n'));
|
|
285
|
-
assert.match(io.out.join('\n'), /VERIFY \(preserved exactly as declared\): coverage-check/, 'a relative token is resolved, not dismissed');
|
|
286
|
-
rmSync(root, { recursive: true, force: true });
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
it('an un-unlinkable retired store is reported LOUDLY and never fails the migration', () => {
|
|
290
|
-
const root = mkProject([LEGACY, UNIT]);
|
|
291
|
-
spawnSync('git', ['init', '-q'], { cwd: root, encoding: 'utf8' });
|
|
292
|
-
// A DIRECTORY at the store path: existsSync sees it, unlink refuses (EISDIR/EPERM) — the
|
|
293
|
-
// deterministic un-unlinkable shape (permission bits vary by runner; a dir does not).
|
|
294
|
-
mkdirSync(join(root, '.git', RETIRED_STORE_BASENAMES[0]), { recursive: true });
|
|
295
|
-
const io = quiet();
|
|
296
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 0);
|
|
297
|
-
const text = io.out.join('\n');
|
|
298
|
-
assert.match(text, /could not clean .*review-ledger\.jsonl/, 'the cleanup failure is named');
|
|
299
|
-
assert.match(text, /migrated .*gates\.json/, 'the migration itself still landed');
|
|
300
|
-
rmSync(root, { recursive: true, force: true });
|
|
301
|
-
});
|
|
302
|
-
});
|