@sabaiway/agent-workflow-kit 20.2.0 → 22.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 +85 -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/migrations/3.0.0-hardened-core-loop.md +7 -6
- package/package.json +5 -2
- package/references/advisor-writers.md +1 -1
- package/references/contracts.md +11 -10
- package/references/modes/bootstrap.md +3 -3
- package/references/modes/commit-guard.md +1 -1
- package/references/modes/gates.md +2 -2
- package/references/modes/recommendations.md +3 -3
- package/references/modes/upgrade.md +6 -6
- 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 +45 -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} +263 -182
- package/references/scripts/{install-git-hooks.mjs → git-hooks/install-git-hooks.mjs} +50 -38
- package/references/scripts/run.mjs +90 -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/scripts/test-reporter/reporter.mjs +130 -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/coverage-producer.mjs +76 -41
- package/tools/direct-run.mjs +2 -0
- package/tools/distribution-files/retired.mjs +99 -0
- package/tools/distribution-files/scripts.mjs +68 -52
- package/tools/ensure-configs.mjs +21 -21
- package/tools/ensure-ops.mjs +60 -18
- package/tools/ensure-specs.mjs +85 -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 +22 -14
- package/tools/gates-init.mjs +33 -17
- 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 +37 -25
- 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 +3 -3
- 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,517 +0,0 @@
|
|
|
1
|
-
// migrate-gates.test.mjs — spec for the consented legacy gates.json migration (strip-the-kit D8).
|
|
2
|
-
// The migration is ATOMIC and COMPLETE: canonical legacy entries removed + the unit-tests cmd
|
|
3
|
-
// extended with the lcov reporters + the coverage-check gate added LAST; customized entries are
|
|
4
|
-
// NEVER auto-touched (loud report + recovery); preview writes NOTHING; apply is tmp+rename.
|
|
5
|
-
|
|
6
|
-
import { describe, it } from 'node:test';
|
|
7
|
-
import assert from 'node:assert/strict';
|
|
8
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, symlinkSync } from 'node:fs';
|
|
9
|
-
import { tmpdir } from 'node:os';
|
|
10
|
-
import { join } from 'node:path';
|
|
11
|
-
import { spawnSync } from 'node:child_process';
|
|
12
|
-
import {
|
|
13
|
-
LEGACY_FORMS,
|
|
14
|
-
UNIT_TESTS_COVERAGE_FLAGS,
|
|
15
|
-
KNOWN_COVERAGE_FLAG_SETS,
|
|
16
|
-
COVERAGE_PRODUCER_BODY,
|
|
17
|
-
RETIRED_STORE_BASENAMES,
|
|
18
|
-
findRetiredStores,
|
|
19
|
-
buildMigrationPlan,
|
|
20
|
-
resultingGates,
|
|
21
|
-
formatPreview,
|
|
22
|
-
main,
|
|
23
|
-
} from './migrate-gates.mjs';
|
|
24
|
-
|
|
25
|
-
// An INSTALLED kit tools dir carries both core checks as real files. That is a fixture
|
|
26
|
-
// requirement, not decoration: canonicity is a realpath anchor, so a core check whose file is not
|
|
27
|
-
// there resolves to nothing and is no claim at all — the same fail-closed answer run-gates gives.
|
|
28
|
-
const KIT_TOOLS = mkdtempSync(join(tmpdir(), 'migrate-gates-kit-'));
|
|
29
|
-
writeFileSync(join(KIT_TOOLS, 'coverage-check.mjs'), '// the installed checker the migration points at\n');
|
|
30
|
-
writeFileSync(join(KIT_TOOLS, 'review-state.mjs'), '// the installed review-state check\n');
|
|
31
|
-
// The project root the plan builder resolves declared RELATIVE tokens against — the same anchor
|
|
32
|
-
// run-gates uses. Empty on purpose for the pure-plan cases: a relative lookalike resolves to
|
|
33
|
-
// nothing there, which is exactly the "no claim can be made" outcome those rows assert. The
|
|
34
|
-
// vendored rows below build their own project and pass it explicitly.
|
|
35
|
-
const PROJECT = mkdtempSync(join(tmpdir(), 'migrate-gates-project-'));
|
|
36
|
-
|
|
37
|
-
const mkProject = (gates) => {
|
|
38
|
-
const root = mkdtempSync(join(tmpdir(), 'migrate-gates-'));
|
|
39
|
-
mkdirSync(join(root, 'docs', 'ai'), { recursive: true });
|
|
40
|
-
writeFileSync(join(root, 'docs', 'ai', 'gates.json'), `${JSON.stringify({ _README: 'mine', gates }, null, 2)}\n`);
|
|
41
|
-
return root;
|
|
42
|
-
};
|
|
43
|
-
const gatesOf = (root) => JSON.parse(readFileSync(join(root, 'docs', 'ai', 'gates.json'), 'utf8')).gates;
|
|
44
|
-
const quiet = () => {
|
|
45
|
-
const out = [];
|
|
46
|
-
const err = [];
|
|
47
|
-
return { log: (l) => out.push(String(l)), error: (l) => err.push(String(l)), out, err };
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// The FIRST flag set the kit ever emitted, frozen here as literal bytes — never read back out of
|
|
51
|
-
// KNOWN_COVERAGE_FLAG_SETS. Deployed declarations on disk carry exactly these bytes, so the
|
|
52
|
-
// append-only promise needs a checker that goes red if they are edited or dropped; deriving the
|
|
53
|
-
// "prior" from the set under test would keep this green while real deployments broke.
|
|
54
|
-
const PRIOR_FLAG_SET_V1 =
|
|
55
|
-
'--experimental-test-coverage --test-reporter=lcov --test-reporter-destination="$AW_GIT_DIR/agent-workflow-lcov.info" --test-reporter=spec --test-reporter-destination=stdout';
|
|
56
|
-
|
|
57
|
-
// A VENDORED deployment: the SAME tools, from a copy `--kit-tools` does not name. Recognition is a
|
|
58
|
-
// realpath anchor, so these are real files — a fake path would be the unresolvable case instead.
|
|
59
|
-
const VENDORED_TOOLS = mkdtempSync(join(tmpdir(), 'migrate-gates-vendored-'));
|
|
60
|
-
writeFileSync(join(VENDORED_TOOLS, 'coverage-check.mjs'), '// a vendored copy of the checker\n');
|
|
61
|
-
writeFileSync(join(VENDORED_TOOLS, 'review-state.mjs'), '// a vendored copy of the review-state check\n');
|
|
62
|
-
const vendoredCmd = (name) => `node "${join(VENDORED_TOOLS, `${name}.mjs`)}" --check`;
|
|
63
|
-
const installedCmd = (name) => `node "${join(KIT_TOOLS, `${name}.mjs`)}" --check`;
|
|
64
|
-
|
|
65
|
-
const LEGACY_LEDGER = { id: 'review-ledger', title: 'L', cmd: 'node "/kit/tools/review-ledger.mjs" --check' };
|
|
66
|
-
const LEGACY_FOLD = { id: 'fold-completeness', title: 'F', cmd: 'node /kit/tools/fold-completeness.mjs --check' };
|
|
67
|
-
const UNIT = { id: 'unit-tests', title: 'U', cmd: 'node --test tools/*.test.mjs' };
|
|
68
|
-
const CUSTOM = { id: 'my-ledger-wrap', title: 'C', cmd: 'node scripts/wrap.mjs && node /kit/tools/review-ledger.mjs --check' };
|
|
69
|
-
|
|
70
|
-
describe('migrate-gates — the pure migration plan', () => {
|
|
71
|
-
it('matches BOTH documented legacy forms (quoted and bare paths) and removes them', () => {
|
|
72
|
-
for (const form of LEGACY_FORMS) assert.ok(form.re instanceof RegExp);
|
|
73
|
-
const { plan } = buildMigrationPlan([LEGACY_LEDGER, LEGACY_FOLD], KIT_TOOLS, PROJECT);
|
|
74
|
-
assert.deepEqual(plan.filter((r) => r.action === 'remove').map((r) => r.entry.id), ['review-ledger', 'fold-completeness']);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('extends the canonical unit-tests cmd with the lcov reporters (flags inserted after `node --test`)', () => {
|
|
78
|
-
const { plan, unitTestsExtended } = buildMigrationPlan([UNIT], KIT_TOOLS, PROJECT);
|
|
79
|
-
assert.ok(unitTestsExtended);
|
|
80
|
-
const extended = plan.find((r) => r.action === 'extend').entry;
|
|
81
|
-
assert.equal(extended.cmd, `node --test ${UNIT_TESTS_COVERAGE_FLAGS} tools/*.test.mjs`);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('an already-extended unit-tests cmd is left alone (idempotent)', () => {
|
|
85
|
-
const done = { id: 'unit-tests', title: 'U', cmd: `node --test ${UNIT_TESTS_COVERAGE_FLAGS} tools/*.test.mjs` };
|
|
86
|
-
const { plan } = buildMigrationPlan([done], KIT_TOOLS, PROJECT);
|
|
87
|
-
assert.equal(plan.find((r) => r.entry.id === 'unit-tests').action, 'keep');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('a declaration carrying a PRIOR emitted flag set reads as already-configured — keep, zero diff, no warning', () => {
|
|
91
|
-
// The canonical flag set moved (the destination became a required-parameter expansion). A
|
|
92
|
-
// deployment written by the earlier kit must not suddenly read as customized: that would send
|
|
93
|
-
// the maintainer to hand-fix a gate which already produces the lcov the checker reads.
|
|
94
|
-
assert.notEqual(PRIOR_FLAG_SET_V1, UNIT_TESTS_COVERAGE_FLAGS, 'the v1 bytes are a form the kit no longer emits');
|
|
95
|
-
assert.ok(KNOWN_COVERAGE_FLAG_SETS.includes(PRIOR_FLAG_SET_V1), 'and the append-only set still carries them');
|
|
96
|
-
const deployed = [
|
|
97
|
-
{ id: 'unit-tests', title: 'U', cmd: `node --test ${PRIOR_FLAG_SET_V1} tools/*.test.mjs` },
|
|
98
|
-
{ id: 'review-state', title: 'RS', cmd: `node "${join(KIT_TOOLS, 'review-state.mjs')}" --check` },
|
|
99
|
-
{ id: 'coverage-check', title: 'CC', cmd: `node "${join(KIT_TOOLS, 'coverage-check.mjs')}" --check` },
|
|
100
|
-
];
|
|
101
|
-
const analysis = buildMigrationPlan(deployed, KIT_TOOLS, PROJECT);
|
|
102
|
-
assert.equal(analysis.plan.find((r) => r.entry.id === 'unit-tests').action, 'keep');
|
|
103
|
-
assert.deepEqual(analysis.customized, [], 'a prior emitted form is never reported customized');
|
|
104
|
-
assert.equal(analysis.hasProducer, true, 'it still counts as the producer the checker reads');
|
|
105
|
-
assert.equal(analysis.checkerInert, false);
|
|
106
|
-
assert.equal(analysis.finalCapable, true);
|
|
107
|
-
assert.deepEqual(resultingGates(analysis.plan), deployed, 'zero diff — nothing is rewritten');
|
|
108
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
109
|
-
assert.match(preview, /nothing to migrate/, 'the preview says there is nothing to do');
|
|
110
|
-
assert.doesNotMatch(preview, /CUSTOMIZED|INERT|WARNING/, 'and warns about nothing');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('a unit-tests entry that merely CONTAINS the prior bytes is CUSTOMIZED, never a silent keep', () => {
|
|
114
|
-
// The already-configured decision runs through the closed producer predicate. A substring probe
|
|
115
|
-
// would call `echo <prior flags>` already configured and say nothing, leaving the maintainer
|
|
116
|
-
// with an entry the tool cannot verify and no recovery line.
|
|
117
|
-
const nearMiss = { id: 'unit-tests', title: 'U', cmd: `echo ${PRIOR_FLAG_SET_V1}` };
|
|
118
|
-
const analysis = buildMigrationPlan([nearMiss], KIT_TOOLS, PROJECT);
|
|
119
|
-
assert.equal(analysis.plan.find((r) => r.entry.id === 'unit-tests').action, 'keep', 'nothing is rewritten');
|
|
120
|
-
assert.deepEqual(analysis.customized.map((g) => g.id), ['unit-tests'], 'but it IS reported customized');
|
|
121
|
-
assert.equal(analysis.hasProducer, false, 'and it never counts as the producer the checker would read');
|
|
122
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
123
|
-
assert.match(preview, /CUSTOMIZED \(untouched\): unit-tests/);
|
|
124
|
-
assert.match(preview, /declare the canonical suite gate by hand/, 'the paste-ready recovery rides along');
|
|
125
|
-
assert.match(preview, /recovery \(apply by hand[^\n]*"lcovProducer": true/, 'the recovery names the marker as the other lane');
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('adds the coverage-check gate LAST with the RESOLVED quoted path; never a second one', () => {
|
|
129
|
-
const { plan } = buildMigrationPlan([UNIT], KIT_TOOLS, PROJECT);
|
|
130
|
-
const result = resultingGates(plan);
|
|
131
|
-
const last = result[result.length - 1];
|
|
132
|
-
assert.equal(last.id, 'coverage-check');
|
|
133
|
-
assert.equal(last.cmd, `node "${join(KIT_TOOLS, 'coverage-check.mjs')}" --check`);
|
|
134
|
-
const again = buildMigrationPlan(result, KIT_TOOLS, PROJECT);
|
|
135
|
-
assert.ok(!again.plan.some((r) => r.action === 'add'), 'a declaration already carrying the checker gains no duplicate');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('a declaration with NO producer never GAINS the checker — the pair is declared together or not at all', () => {
|
|
139
|
-
const npmSuite = { id: 'suite', title: 'S', cmd: 'npm test' };
|
|
140
|
-
const analysis = buildMigrationPlan([LEGACY_LEDGER, npmSuite], KIT_TOOLS, PROJECT);
|
|
141
|
-
assert.ok(!analysis.plan.some((r) => r.action === 'add'), 'no checker is added over a declaration that produces no lcov');
|
|
142
|
-
assert.deepEqual(resultingGates(analysis.plan).map((g) => g.id), ['suite'], 'the legacy entry still goes, nothing dead arrives');
|
|
143
|
-
assert.equal(analysis.finalCapable, false, 'a declaration with no checker is not final-run-capable');
|
|
144
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
145
|
-
assert.match(preview, /coverage-check/, 'the withheld checker is named');
|
|
146
|
-
assert.match(preview, /produce/i, 'the preview says WHY — no gate produces the lcov it would read');
|
|
147
|
-
assert.match(preview, /WARNING: the canonical coverage-check gate was NOT added[^\n]*\n[^\n]*\n[^\n]*"lcovProducer": true/, 'the withheld block names the marker as the other lane');
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('an ALREADY-declared checker over no producer is reported INERT, is never removed, and is not final-run-capable', () => {
|
|
151
|
-
const checker = { id: 'coverage-check', title: 'CC', cmd: `node "${join(KIT_TOOLS, 'coverage-check.mjs')}" --check` };
|
|
152
|
-
const reviewState = { id: 'review-state', title: 'RS', cmd: `node "${join(KIT_TOOLS, 'review-state.mjs')}" --check` };
|
|
153
|
-
const analysis = buildMigrationPlan([{ id: 'suite', title: 'S', cmd: 'npm test' }, reviewState, checker], KIT_TOOLS, PROJECT);
|
|
154
|
-
assert.equal(analysis.finalCapable, false, 'a review-state present must NOT make an inert pair read as final-run-capable');
|
|
155
|
-
assert.ok(resultingGates(analysis.plan).some((g) => g.id === 'coverage-check'), 'the declared checker is never removed');
|
|
156
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
157
|
-
assert.match(preview, /INERT/, 'the inert pair is named');
|
|
158
|
-
assert.match(preview, /--experimental-test-coverage/, 'the paste-ready suite cmd is carried');
|
|
159
|
-
assert.match(preview, /WARNING: the DECLARED coverage-check gate is INERT[^\n]*\n[^\n]*\n[^\n]*"lcovProducer": true/, 'the inert block names the marker as the other lane');
|
|
160
|
-
assert.doesNotMatch(preview, /already final-run-capable/);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('a gates-init-shaped producer (the exec-wrapped offer form) is recognized — the checker IS added over it', () => {
|
|
164
|
-
const offered = {
|
|
165
|
-
id: 'test',
|
|
166
|
-
title: 'T',
|
|
167
|
-
cmd: `COREPACK_ENABLE_NETWORK=0 npm exec --offline --script-shell /bin/sh -- ${COVERAGE_PRODUCER_BODY}`,
|
|
168
|
-
};
|
|
169
|
-
const analysis = buildMigrationPlan([offered], KIT_TOOLS, PROJECT);
|
|
170
|
-
assert.deepEqual(resultingGates(analysis.plan).map((g) => g.id), ['test', 'coverage-check']);
|
|
171
|
-
// The `no canonical unit-tests entry` advice is keyed on the ID, but a producer is recognized
|
|
172
|
-
// under ANY id — repeating the advice over a working producer sends the user to fix nothing.
|
|
173
|
-
assert.doesNotMatch(formatPreview(analysis, 'APPLY'), /declare your suite gate with the lcov reporters by hand/);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('a CUSTOMIZED dead-tool reference (compound form) is kept untouched and reported', () => {
|
|
177
|
-
const analysis = buildMigrationPlan([CUSTOM], KIT_TOOLS, PROJECT);
|
|
178
|
-
assert.equal(analysis.plan.find((r) => r.entry.id === 'my-ledger-wrap').action, 'keep');
|
|
179
|
-
assert.deepEqual(analysis.customized.map((g) => g.id), ['my-ledger-wrap']);
|
|
180
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
181
|
-
assert.match(preview, /CUSTOMIZED \(untouched\): my-ledger-wrap/);
|
|
182
|
-
assert.match(preview, /do NOT install the commit guard/);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
describe('migrate-gates — the canonical anchor + final-capability validation (round-1 folds)', () => {
|
|
187
|
-
it('a canonical checker NOT in the last position is MOVED last (never left mid-list)', () => {
|
|
188
|
-
const canonical = { id: 'coverage-check', title: 'CC', cmd: `node "${join(KIT_TOOLS, 'coverage-check.mjs')}" --check` };
|
|
189
|
-
const { plan } = buildMigrationPlan([canonical, UNIT], KIT_TOOLS, PROJECT);
|
|
190
|
-
const result = resultingGates(plan);
|
|
191
|
-
assert.equal(result[result.length - 1].id, 'coverage-check', 'the canonical checker ends up LAST');
|
|
192
|
-
assert.ok(plan.some((r) => r.action === 'move' && r.entry.id === 'coverage-check'), 'the reorder is an explicit move action');
|
|
193
|
-
assert.ok(!plan.some((r) => r.action === 'add'), 'no duplicate checker is added');
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('a LOOKALIKE checker cmd is CUSTOMIZED (never counted canonical) and the canonical one is still added', () => {
|
|
197
|
-
const lookalike = { id: 'cov', title: 'C', cmd: 'node scripts/coverage-check.mjs --check' };
|
|
198
|
-
const analysis = buildMigrationPlan([lookalike, UNIT], KIT_TOOLS, PROJECT);
|
|
199
|
-
assert.ok(analysis.customized.some((g) => g.id === 'cov'), 'the lookalike is reported customized');
|
|
200
|
-
const result = resultingGates(analysis.plan);
|
|
201
|
-
assert.equal(result[result.length - 1].id, 'coverage-check', 'the REAL canonical checker is added last');
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('the result is judged final-capable ONLY with a canonical review-state present; missing → a LOUD warning with the candidate line, never "final-run-capable"', () => {
|
|
205
|
-
const analysis = buildMigrationPlan([UNIT], KIT_TOOLS, PROJECT);
|
|
206
|
-
assert.equal(analysis.finalCapable, false, 'no review-state → not final-capable');
|
|
207
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
208
|
-
assert.match(preview, /review-state/, 'the warning names the missing core check');
|
|
209
|
-
assert.match(preview, /"id": "review-state"|review-state\.mjs/, 'the paste-ready candidate is carried');
|
|
210
|
-
assert.doesNotMatch(preview, /already final-run-capable/);
|
|
211
|
-
const withRs = buildMigrationPlan(
|
|
212
|
-
[UNIT, { id: 'review-state', title: 'RS', cmd: `node "${join(KIT_TOOLS, 'review-state.mjs')}" --check` }],
|
|
213
|
-
KIT_TOOLS,
|
|
214
|
-
PROJECT,
|
|
215
|
-
);
|
|
216
|
-
assert.equal(withRs.finalCapable, true);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('a NON-canonical unit-tests cmd (npm test / wrapper) is CUSTOMIZED with the full flag set as the recovery', () => {
|
|
220
|
-
const npmTest = { id: 'unit-tests', title: 'U', cmd: 'npm test' };
|
|
221
|
-
const analysis = buildMigrationPlan([npmTest], KIT_TOOLS, PROJECT);
|
|
222
|
-
assert.equal(analysis.plan.find((r) => r.entry.id === 'unit-tests').action, 'keep');
|
|
223
|
-
assert.ok(analysis.customized.some((g) => g.id === 'unit-tests'), 'a non-canonical suite cmd is customized');
|
|
224
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
225
|
-
assert.match(preview, /--experimental-test-coverage/, 'the recovery carries the full flag set');
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('a PARTIALLY-flagged unit-tests cmd is CUSTOMIZED (a lone coverage flag never reads as configured)', () => {
|
|
229
|
-
const partial = { id: 'unit-tests', title: 'U', cmd: 'node --test --experimental-test-coverage tools/*.test.mjs' };
|
|
230
|
-
const analysis = buildMigrationPlan([partial], KIT_TOOLS, PROJECT);
|
|
231
|
-
assert.equal(analysis.plan.find((r) => r.entry.id === 'unit-tests').action, 'keep');
|
|
232
|
-
assert.ok(analysis.customized.some((g) => g.id === 'unit-tests'), 'the half-wired cmd is customized, never silently left');
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('a kitTools path with DQ-unsafe characters is a loud STOP before any write', () => {
|
|
236
|
-
const root = mkProject([UNIT]);
|
|
237
|
-
const evil = mkdtempSync(join(tmpdir(), 'migrate-gates-$evil-'));
|
|
238
|
-
writeFileSync(join(evil, 'coverage-check.mjs'), '// lookalike\n');
|
|
239
|
-
const io = quiet();
|
|
240
|
-
assert.equal(main(['--cwd', root, '--kit-tools', evil, '--apply'], io), 1);
|
|
241
|
-
assert.match(io.err.join('\n'), /double-quot|shell metacharacter/i);
|
|
242
|
-
rmSync(evil, { recursive: true, force: true });
|
|
243
|
-
rmSync(root, { recursive: true, force: true });
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('CUSTOMIZED warnings + the guard warning print even when apply has nothing else to do', () => {
|
|
247
|
-
const root = mkProject([CUSTOM]);
|
|
248
|
-
const io = quiet();
|
|
249
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 0);
|
|
250
|
-
const text = io.out.join('\n');
|
|
251
|
-
assert.match(text, /CUSTOMIZED \(untouched\): my-ledger-wrap/, 'the customized row survives the no-op path');
|
|
252
|
-
assert.match(text, /do NOT install the commit guard/i, 'the guard warning survives the no-op path');
|
|
253
|
-
rmSync(root, { recursive: true, force: true });
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('a SYMLINKED docs (or docs/ai) PARENT is a STOP on preview AND apply (never written through)', () => {
|
|
257
|
-
const outside = mkdtempSync(join(tmpdir(), 'migrate-gates-target-'));
|
|
258
|
-
mkdirSync(join(outside, 'ai'), { recursive: true });
|
|
259
|
-
writeFileSync(join(outside, 'ai', 'gates.json'), `${JSON.stringify({ gates: [UNIT] })}\n`);
|
|
260
|
-
const root = mkdtempSync(join(tmpdir(), 'migrate-gates-symparent-'));
|
|
261
|
-
symlinkSync(outside, join(root, 'docs'));
|
|
262
|
-
for (const argv of [['--cwd', root, '--kit-tools', KIT_TOOLS], ['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply']]) {
|
|
263
|
-
const io = quiet();
|
|
264
|
-
assert.equal(main(argv, io), 1, `must STOP: ${argv.join(' ')}`);
|
|
265
|
-
assert.match(io.err.join('\n'), /symlink/i);
|
|
266
|
-
}
|
|
267
|
-
rmSync(root, { recursive: true, force: true });
|
|
268
|
-
rmSync(outside, { recursive: true, force: true });
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
describe('migrate-gates — a VENDORED core check is the tool, from a copy --kit-tools does not name (D6)', () => {
|
|
273
|
-
const UNIT_DONE = { id: 'unit-tests', title: 'U', cmd: `${COVERAGE_PRODUCER_BODY} tools/*.test.mjs` };
|
|
274
|
-
const INSTALLED_REVIEW_STATE = { id: 'review-state', title: 'RS', cmd: installedCmd('review-state') };
|
|
275
|
-
|
|
276
|
-
it('a vendored coverage-check is PRESERVED exactly as declared — declared, never added over, never a collision', () => {
|
|
277
|
-
// Before the split this entry was a LOOKALIKE holding the checker's id, which made the whole
|
|
278
|
-
// upgrade a hard STOP: every preview and every apply over a vendored deployment failed.
|
|
279
|
-
const vendored = { id: 'coverage-check', title: 'CC', cmd: vendoredCmd('coverage-check') };
|
|
280
|
-
const declaration = [UNIT_DONE, INSTALLED_REVIEW_STATE, vendored];
|
|
281
|
-
const analysis = buildMigrationPlan(declaration, KIT_TOOLS, PROJECT);
|
|
282
|
-
assert.equal(analysis.collision, null, 'a vendored copy carries the tool\'s own id legitimately — it is no squatter');
|
|
283
|
-
assert.ok(!analysis.plan.some((r) => r.action === 'add'), 'the checker IS declared, so a second one is never added');
|
|
284
|
-
assert.deepEqual(analysis.plan.map((r) => r.action), ['keep', 'keep', 'keep'], 'nothing is rewritten or reordered');
|
|
285
|
-
assert.deepEqual(resultingGates(analysis.plan), declaration, 'the declaration comes out byte-for-byte as it went in');
|
|
286
|
-
assert.deepEqual(analysis.externalCoreChecks.map((c) => c.name), ['coverage-check']);
|
|
287
|
-
assert.deepEqual(analysis.customized, [], 'a real copy of the tool is not an entry the tool cannot verify');
|
|
288
|
-
assert.equal(analysis.finalCapable, false, '--final anchors on the INSTALLED copy, so the capability claim is withheld');
|
|
289
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
290
|
-
assert.match(preview, /VERIFY \(preserved exactly as declared\): coverage-check/, 'the outcome is NAMED');
|
|
291
|
-
assert.match(preview, /DIFFERENT copy of the tool/, 'and says what it actually found');
|
|
292
|
-
assert.match(preview, /NOT final-run-capable/);
|
|
293
|
-
assert.doesNotMatch(preview, /already final-run-capable/);
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it('a vendored review-state is preserved too — and is never advised to "add it" on top of itself', () => {
|
|
297
|
-
const vendored = { id: 'review-state', title: 'RS', cmd: vendoredCmd('review-state') };
|
|
298
|
-
const analysis = buildMigrationPlan([UNIT_DONE, vendored], KIT_TOOLS, PROJECT);
|
|
299
|
-
assert.deepEqual(analysis.externalCoreChecks.map((c) => c.name), ['review-state']);
|
|
300
|
-
assert.equal(analysis.hasReviewState, false, 'the INSTALLED review-state is still not declared');
|
|
301
|
-
assert.equal(analysis.finalCapable, false);
|
|
302
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
303
|
-
assert.match(preview, /VERIFY \(preserved exactly as declared\): review-state/);
|
|
304
|
-
assert.doesNotMatch(preview, /Add it \(paste-ready\)/, 'a second review-state entry is the ambiguity, not the remedy');
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it('a core check naming a path nothing resolves is NO claim — fail-closed exactly where --final is', () => {
|
|
308
|
-
// A lexical path compare called this canonical: the file need not exist to compare equal after
|
|
309
|
-
// resolve(). The migration then promised final-run-capability over a cmd --final cannot run.
|
|
310
|
-
const ghost = { id: 'review-state', title: 'RS', cmd: `node "${join(KIT_TOOLS, 'nowhere', 'review-state.mjs')}" --check` };
|
|
311
|
-
const analysis = buildMigrationPlan([UNIT_DONE, ghost], KIT_TOOLS, PROJECT);
|
|
312
|
-
assert.equal(analysis.hasReviewState, false, 'an unresolvable path is never the installed tool');
|
|
313
|
-
assert.deepEqual(analysis.externalCoreChecks, [], 'nor evidence that the tool lives somewhere else');
|
|
314
|
-
assert.ok(analysis.customized.some((g) => g.id === 'review-state'), 'it is reported as an entry the tool cannot verify');
|
|
315
|
-
assert.equal(analysis.finalCapable, false);
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it('a vendored checker never produces the lcov it reads — the declared pair stays INERT', () => {
|
|
319
|
-
const vendored = { id: 'coverage-check', title: 'CC', cmd: vendoredCmd('coverage-check'), lcovProducer: true };
|
|
320
|
-
const analysis = buildMigrationPlan(
|
|
321
|
-
[{ id: 'lint', title: 'L', cmd: 'eslint .' }, INSTALLED_REVIEW_STATE, vendored],
|
|
322
|
-
KIT_TOOLS,
|
|
323
|
-
PROJECT,
|
|
324
|
-
);
|
|
325
|
-
assert.equal(analysis.hasProducer, false, 'a marker on the checker itself never self-pairs, whichever copy it is');
|
|
326
|
-
assert.equal(analysis.checkerInert, true, 'a checker over nothing that writes the lcov passes verifying nothing');
|
|
327
|
-
assert.match(formatPreview(analysis, 'APPLY'), /INERT/);
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
it('producer-after-vendored-checker: a producer declared AFTER a vendored checker never covers it', () => {
|
|
331
|
-
// A canonical checker is always MOVED last, so "a producer exists" answers "a producer runs
|
|
332
|
-
// first" for it. A vendored checker is left where the deployment put it, so the position-blind
|
|
333
|
-
// answer reported a live pair over a checker that reads the lcov before anything writes one.
|
|
334
|
-
const vendored = { id: 'coverage-check', title: 'CC', cmd: vendoredCmd('coverage-check') };
|
|
335
|
-
const after = buildMigrationPlan([INSTALLED_REVIEW_STATE, vendored, UNIT_DONE], KIT_TOOLS, PROJECT);
|
|
336
|
-
assert.equal(after.hasProducer, true, 'a producer IS declared somewhere');
|
|
337
|
-
assert.equal(after.checkerInert, true, 'but not before the checker that reads what it writes');
|
|
338
|
-
assert.equal(after.finalCapable, false);
|
|
339
|
-
assert.match(formatPreview(after, 'APPLY'), /INERT/);
|
|
340
|
-
|
|
341
|
-
const before = buildMigrationPlan([UNIT_DONE, INSTALLED_REVIEW_STATE, vendored], KIT_TOOLS, PROJECT);
|
|
342
|
-
assert.equal(before.checkerInert, false, 'the same entries in producer-first order are a live pair');
|
|
343
|
-
assert.doesNotMatch(formatPreview(before, 'APPLY'), /INERT/);
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
it('the INERT warning names the edit the reader must actually make — order, not a missing gate', () => {
|
|
347
|
-
// The two ways to be inert need two sentences. Telling someone whose suite gate is already
|
|
348
|
-
// declared to declare it again sends them to fix nothing while the real defect stays.
|
|
349
|
-
const vendored = { id: 'coverage-check', title: 'CC', cmd: vendoredCmd('coverage-check') };
|
|
350
|
-
const misordered = formatPreview(buildMigrationPlan([INSTALLED_REVIEW_STATE, vendored, UNIT_DONE], KIT_TOOLS, PROJECT), 'APPLY');
|
|
351
|
-
assert.match(misordered, /runs AFTER this entry/, 'the ORDER is named as the defect, on the row it belongs to');
|
|
352
|
-
assert.match(misordered, /a checker belongs LAST, after its producer/, 'and the remedy is the reorder');
|
|
353
|
-
assert.doesNotMatch(misordered, /declare the suite gate/, 'never advise declaring a gate that is already there');
|
|
354
|
-
|
|
355
|
-
const absent = formatPreview(buildMigrationPlan([INSTALLED_REVIEW_STATE, vendored], KIT_TOOLS, PROJECT), 'APPLY');
|
|
356
|
-
assert.match(absent, /no declared gate PRODUCES the lcov/, 'with nothing producing, the old sentence still holds');
|
|
357
|
-
assert.match(absent, /declare the suite gate/);
|
|
358
|
-
assert.match(absent, /no declared gate PRODUCES the lcov[^\n]*"lcovProducer": true/, 'the INERT row names the marker as the other lane');
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it('a mixed declaration renders ONE edit, never a removal and a reorder at once', () => {
|
|
362
|
-
// The two folds met here: canonicalTwin asks for a removal, the inert arm asked for a reorder,
|
|
363
|
-
// and a preview carrying both leaves the reader with no unambiguous next step.
|
|
364
|
-
const canonical = { id: 'coverage-check', title: 'CC', cmd: installedCmd('coverage-check') };
|
|
365
|
-
const vendored = { id: 'coverage-check-vendor', title: 'CCV', cmd: vendoredCmd('coverage-check') };
|
|
366
|
-
const analysis = buildMigrationPlan([INSTALLED_REVIEW_STATE, vendored, UNIT_DONE, canonical], KIT_TOOLS, PROJECT);
|
|
367
|
-
assert.deepEqual(analysis.externalCoreChecks.map((c) => [c.canonicalTwin, c.inert]), [[true, true]]);
|
|
368
|
-
assert.equal(analysis.canonicalCheckerInert, false, 'the canonical checker ends up last, after the producer');
|
|
369
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
370
|
-
assert.match(preview, /Remove THIS entry by hand/);
|
|
371
|
-
assert.match(preview, /the ONE edit that resolves both/);
|
|
372
|
-
assert.doesNotMatch(preview, /belongs LAST, after its producer/, 'no second, contradictory edit');
|
|
373
|
-
assert.doesNotMatch(preview, /declare the suite gate/);
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
it('a canonical checker declared BESIDE the vendored one changes the recovery — remove, never repoint', () => {
|
|
377
|
-
// Repointing the vendored cmd at the installed copy would leave TWO canonical checkers, and
|
|
378
|
-
// --final accepts exactly one; a recovery that cannot converge is worse than none.
|
|
379
|
-
const canonical = { id: 'coverage-check', title: 'CC', cmd: installedCmd('coverage-check') };
|
|
380
|
-
const vendored = { id: 'coverage-check-vendor', title: 'CCV', cmd: vendoredCmd('coverage-check') };
|
|
381
|
-
const analysis = buildMigrationPlan([UNIT_DONE, INSTALLED_REVIEW_STATE, vendored, canonical], KIT_TOOLS, PROJECT);
|
|
382
|
-
assert.deepEqual(analysis.externalCoreChecks.map((c) => c.canonicalTwin), [true]);
|
|
383
|
-
const preview = formatPreview(analysis, 'APPLY');
|
|
384
|
-
assert.match(preview, /accepts exactly ONE canonical check/);
|
|
385
|
-
assert.match(preview, /Remove THIS entry by hand/);
|
|
386
|
-
assert.doesNotMatch(preview, /either repoint the cmd/, 'the non-convergent recovery is not offered here');
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
it('a vendored deployment carries the SAME commit-guard consequence a customized one does', () => {
|
|
390
|
-
// Both end in a declaration --final refuses, which mints no receipt, which makes the guard
|
|
391
|
-
// refuse every commit. Naming the consequence for one and not the other is a false asymmetry.
|
|
392
|
-
const vendored = { id: 'coverage-check', title: 'CC', cmd: vendoredCmd('coverage-check') };
|
|
393
|
-
const preview = formatPreview(buildMigrationPlan([UNIT_DONE, INSTALLED_REVIEW_STATE, vendored], KIT_TOOLS, PROJECT), 'APPLY');
|
|
394
|
-
assert.match(preview, /do NOT install the commit guard/);
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it('the plan builder REFUSES without the project root — a relative cmd cannot be resolved without it', () => {
|
|
398
|
-
assert.throws(() => buildMigrationPlan([UNIT_DONE], KIT_TOOLS), /project root/);
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
describe('migrate-gates — preview writes NOTHING; apply is atomic and complete', () => {
|
|
403
|
-
it('the dry-run default leaves gates.json byte-identical and prints the plan + the apply hint', () => {
|
|
404
|
-
const root = mkProject([LEGACY_LEDGER, UNIT]);
|
|
405
|
-
const before = readFileSync(join(root, 'docs', 'ai', 'gates.json'), 'utf8');
|
|
406
|
-
const io = quiet();
|
|
407
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0);
|
|
408
|
-
assert.equal(readFileSync(join(root, 'docs', 'ai', 'gates.json'), 'utf8'), before, 'dry-run must write nothing');
|
|
409
|
-
const text = io.out.join('\n');
|
|
410
|
-
assert.match(text, /REMOVE review-ledger/);
|
|
411
|
-
assert.match(text, /EXTEND unit-tests/);
|
|
412
|
-
assert.match(text, /ADD coverage-check/);
|
|
413
|
-
assert.match(text, /apply exactly this migration: node "\/[^"]*migrate-gates\.mjs" --kit-tools/, 'the apply hint is a REAL runnable path (never a file: URL)');
|
|
414
|
-
rmSync(root, { recursive: true, force: true });
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
it('--apply lands the full migration: legacy gone, unit-tests extended, coverage-check LAST', () => {
|
|
418
|
-
const root = mkProject([UNIT, LEGACY_LEDGER, LEGACY_FOLD]);
|
|
419
|
-
const io = quiet();
|
|
420
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 0);
|
|
421
|
-
const gates = gatesOf(root);
|
|
422
|
-
assert.deepEqual(gates.map((g) => g.id), ['unit-tests', 'coverage-check']);
|
|
423
|
-
assert.match(gates[0].cmd, /--experimental-test-coverage/);
|
|
424
|
-
assert.equal(gates[gates.length - 1].id, 'coverage-check');
|
|
425
|
-
rmSync(root, { recursive: true, force: true });
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
it('an ALREADY-migrated declaration is a stated no-op on apply', () => {
|
|
429
|
-
const root = mkProject([UNIT, LEGACY_LEDGER]);
|
|
430
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], quiet()), 0);
|
|
431
|
-
const io = quiet();
|
|
432
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 0);
|
|
433
|
-
assert.match(io.out.join('\n'), /nothing to migrate/);
|
|
434
|
-
rmSync(root, { recursive: true, force: true });
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
it('a MISSING gates.json is a stated no-op; a MALFORMED one is a loud STOP (never written over)', () => {
|
|
438
|
-
const empty = mkdtempSync(join(tmpdir(), 'migrate-gates-none-'));
|
|
439
|
-
const io = quiet();
|
|
440
|
-
assert.equal(main(['--cwd', empty, '--kit-tools', KIT_TOOLS], io), 0);
|
|
441
|
-
assert.match(io.out.join('\n'), /nothing to migrate/);
|
|
442
|
-
rmSync(empty, { recursive: true, force: true });
|
|
443
|
-
|
|
444
|
-
const root = mkProject([]);
|
|
445
|
-
writeFileSync(join(root, 'docs', 'ai', 'gates.json'), '{ not json');
|
|
446
|
-
const io2 = quiet();
|
|
447
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io2), 1);
|
|
448
|
-
assert.match(io2.err.join('\n'), /malformed JSON/);
|
|
449
|
-
rmSync(root, { recursive: true, force: true });
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
it('a SYMLINKED gates.json is a STOP on preview AND apply', () => {
|
|
453
|
-
const root = mkdtempSync(join(tmpdir(), 'migrate-gates-link-'));
|
|
454
|
-
mkdirSync(join(root, 'docs', 'ai'), { recursive: true });
|
|
455
|
-
writeFileSync(join(root, 'real.json'), '{"gates":[]}\n');
|
|
456
|
-
symlinkSync(join(root, 'real.json'), join(root, 'docs', 'ai', 'gates.json'));
|
|
457
|
-
for (const argv of [['--cwd', root, '--kit-tools', KIT_TOOLS], ['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply']]) {
|
|
458
|
-
const io = quiet();
|
|
459
|
-
assert.equal(main(argv, io), 1);
|
|
460
|
-
assert.match(io.err.join('\n'), /symlink/);
|
|
461
|
-
}
|
|
462
|
-
rmSync(root, { recursive: true, force: true });
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
it('retired git-dir stores: previewed as CLEAN rows (nothing deleted), unlinked on apply, ENOENT a no-op', () => {
|
|
466
|
-
const root = mkProject([LEGACY_LEDGER]);
|
|
467
|
-
const g = (...a) => spawnSync('git', a, { cwd: root, encoding: 'utf8' });
|
|
468
|
-
g('init', '-q');
|
|
469
|
-
for (const name of RETIRED_STORE_BASENAMES) writeFileSync(join(root, '.git', name), '{"dead":1}\n');
|
|
470
|
-
assert.equal(findRetiredStores(root).length, RETIRED_STORE_BASENAMES.length, 'all three retired basenames are found');
|
|
471
|
-
const io = quiet();
|
|
472
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS], io), 0);
|
|
473
|
-
assert.match(io.out.join('\n'), /CLEAN .*agent-workflow-review-ledger\.v5-orphans\.jsonl/, 'the v5-orphans archive is previewed too');
|
|
474
|
-
assert.equal(findRetiredStores(root).length, RETIRED_STORE_BASENAMES.length, 'the dry-run deleted NOTHING');
|
|
475
|
-
const io2 = quiet();
|
|
476
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io2), 0);
|
|
477
|
-
assert.deepEqual(findRetiredStores(root), [], 'apply unlinked every retired store');
|
|
478
|
-
assert.match(io2.out.join('\n'), /cleaned .*agent-workflow-fold-completeness\.jsonl/);
|
|
479
|
-
// A second apply: stores gone, declaration migrated — a stated no-op (ENOENT never errors).
|
|
480
|
-
const io3 = quiet();
|
|
481
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io3), 0);
|
|
482
|
-
assert.match(io3.out.join('\n'), /nothing to migrate/);
|
|
483
|
-
rmSync(root, { recursive: true, force: true });
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
it('stores alone (an already-migrated declaration) still get cleaned on apply', () => {
|
|
487
|
-
const root = mkProject([UNIT]);
|
|
488
|
-
const g = (...a) => spawnSync('git', a, { cwd: root, encoding: 'utf8' });
|
|
489
|
-
g('init', '-q');
|
|
490
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], quiet()), 0); // migrate first
|
|
491
|
-
writeFileSync(join(root, '.git', RETIRED_STORE_BASENAMES[0]), '{"dead":1}\n');
|
|
492
|
-
const io = quiet();
|
|
493
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 0);
|
|
494
|
-
assert.match(io.out.join('\n'), /cleaned .*agent-workflow-review-ledger\.jsonl/);
|
|
495
|
-
assert.deepEqual(findRetiredStores(root), []);
|
|
496
|
-
rmSync(root, { recursive: true, force: true });
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
it('outside a git tree the store cleanup is a silent no-op (no crash, gates.json still migrates)', () => {
|
|
500
|
-
const root = mkProject([LEGACY_LEDGER, UNIT]);
|
|
501
|
-
const io = quiet();
|
|
502
|
-
assert.equal(main(['--cwd', root, '--kit-tools', KIT_TOOLS, '--apply'], io), 0);
|
|
503
|
-
assert.deepEqual(gatesOf(root).map((g2) => g2.id), ['unit-tests', 'coverage-check']);
|
|
504
|
-
rmSync(root, { recursive: true, force: true });
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
it('--kit-tools is REQUIRED and must contain the checker (no runtime guessing)', () => {
|
|
508
|
-
const root = mkProject([UNIT]);
|
|
509
|
-
const io = quiet();
|
|
510
|
-
assert.equal(main(['--cwd', root], io), 2);
|
|
511
|
-
assert.match(io.err.join('\n'), /--kit-tools/);
|
|
512
|
-
const io2 = quiet();
|
|
513
|
-
assert.equal(main(['--cwd', root, '--kit-tools', root], io2), 1);
|
|
514
|
-
assert.match(io2.err.join('\n'), /coverage-check\.mjs/);
|
|
515
|
-
rmSync(root, { recursive: true, force: true });
|
|
516
|
-
});
|
|
517
|
-
});
|