refactor(cleanup): simplify pass on the R-a diff
engine-compare imports the coordinator's title limit and trim instead of a copy whose reason went with Arm B; the autonomy gate exports one parser and its test runs in-process with two CLI runs; one import scanner in lib-imports; the fenced-section walker shared from tests/helpers/md-section.mjs instead of six copies; plan-gate hash in-process; living-paths scans once; routing drops the orchestrator filter whose files are gone; small leftovers removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
029e83117c
commit
efe981f7bc
18 changed files with 161 additions and 358 deletions
|
|
@ -721,16 +721,12 @@ const snapDir = dir => join(dir, '.git', 'voyage', 'plan-snapshots');
|
|||
const snaps = dir => (existsSync(snapDir(dir)) ? readdirSync(snapDir(dir)).sort() : []);
|
||||
const sha256 = s => createHash('sha256').update(s).digest('hex');
|
||||
|
||||
function hashOf(dir, p) {
|
||||
const r = gate(dir, ['--hash', p]);
|
||||
assert.equal(r.code, 0, r.out + r.err);
|
||||
assert.match(r.out.trim(), /^[0-9a-f]{64}$/);
|
||||
return r.out.trim();
|
||||
}
|
||||
// What the CLI's --hash prints for the plan at `p`, computed in-process.
|
||||
const hashOf = p => planHash(readFileSync(p, 'utf-8'));
|
||||
|
||||
/** One round as Phase 9 runs it: --hash, then --record with the payloads through the real dedup. */
|
||||
/** One round as Phase 9 runs it: the --hash value, then --record with the payloads through the real dedup. */
|
||||
function cliRound(dir, p, payload = {}, extra = []) {
|
||||
const reviewed = hashOf(dir, p);
|
||||
const reviewed = hashOf(p);
|
||||
const r = gate(dir, ['--record', p, '--reviewed', reviewed, ...extra], JSON.stringify(dd(payload)));
|
||||
const lines = r.out.split('\n').filter(l => l !== '');
|
||||
return { ...r, reviewed, lines, j: lines.length ? JSON.parse(lines[lines.length - 1]) : null };
|
||||
|
|
@ -805,7 +801,7 @@ test('20 (CLI): a refused round writes nothing: exit 2 on a stale --reviewed, ex
|
|||
assert.deepEqual(snaps(dir), [`${r1.reviewed}.md`]);
|
||||
|
||||
// exit 2: the plan changed after --hash
|
||||
const stale = hashOf(dir, p);
|
||||
const stale = hashOf(p);
|
||||
const t2 = editA(readPlan(p));
|
||||
writeFileSync(p, t2);
|
||||
const s = gate(dir, ['--record', p, '--reviewed', stale], JSON.stringify(dd()));
|
||||
|
|
@ -938,9 +934,9 @@ test('23 (CLI): --record on a plan outside any git repo keeps no snapshot anywhe
|
|||
// CLI's --stdin, its stdout into the gate's --record (no in-process dedup).
|
||||
const DEDUP = join(ROOT, 'lib', 'review', 'plan-review-dedup.mjs');
|
||||
|
||||
/** One round through the two CLIs: --hash, dedup --stdin on `payload`, then --record on its output. */
|
||||
/** One round through the two CLIs: the --hash value, dedup --stdin on `payload`, then --record on its output. */
|
||||
function pipeRound(dir, p, payload) {
|
||||
const reviewed = hashOf(dir, p);
|
||||
const reviewed = hashOf(p);
|
||||
const d = spawnSync(process.execPath, [DEDUP, '--stdin'], { cwd: dir, input: JSON.stringify(payload), encoding: 'utf-8', env: childEnv(GIT_CLEAN) });
|
||||
assert.equal(d.status, 0, `plan-review-dedup --stdin: ${d.stdout}${d.stderr}`);
|
||||
const r = gate(dir, ['--record', p, '--reviewed', reviewed], d.stdout);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue