Context
Part of the review-stack architecture audit (parent epic). scripts/check-engine-parity.ts is the
repo's existing mechanism for keeping src/** and its published-package mirror
packages/gittensory-engine/src/** in sync — but discoverEngineParityPairs
(check-engine-parity.ts:104-131) does a non-recursive readdirSync on
src/{review,settings,signals} and pairs files with identical filenames at the top level only.
Anything nested one directory deeper, or logically duplicated but living inside a bigger file under a
different name, is invisible to it — even though npm run engine-parity:drift-check currently reports
"18 pairs agree" and looks comprehensive.
Finding 1 — already-drifted, live bug
At least 3 independent copies of diffFilePriority exist: src/review/review-diff.ts:22-28 and
src/review/review-grounding.ts:118-124 (byte-identical to each other), and
packages/gittensory-engine/src/review/diff-file-priority.ts:3 (imported by
packages/gittensory-engine/src/signals/predicted-gate-engine.ts:24, used in sharesMeaningfulFile at
line 928-933 — itself a near-duplicate of src/signals/engine.ts:5431-5436's sharesMeaningfulFile).
The two host copies correctly match cartfile\.resolved (Carthage's real lockfile filename); the
engine-package copy matches cartfile\.lock (not a real filename) — a one-character-class typo that
means the engine-package's predicted-gate collision-check will never correctly deprioritize a touched
Cartfile.resolved, while the host's equivalent check does. Silent behavioral inconsistency between the
host predicted-gate and the published engine package's predicted-gate for Carthage/iOS repos. Not caught
because neither host copy is a file named diff-file-priority.ts.
Finding 2 — not-yet-drifted, but structurally invisible
safe-url.ts — src/review/content-lane/safe-url.ts (117 lines) vs
packages/gittensory-engine/src/review/safe-url.ts (117 lines) are currently byte-identical (verified
diff, exit 0), but this is luck, not enforcement: the host copy lives in content-lane/ so
listDir("src/review") never sees it. One more independent edit to either side drifts it with zero CI
signal — exactly what already happened to diffFilePriority and the secrets-scan trio.
Fix
- Fix the one-line
cartfile\.lock → cartfile\.resolved regression in
packages/gittensory-engine/src/review/diff-file-priority.ts:3 immediately.
- Add explicit named pairs (reusing the existing
GATE_DECISION_TWIN_PAIR escape hatch already built
for exactly this situation) for safe-url.ts and for the diffFilePriority/sharesMeaningfulFile
functions, since the function, not the file, is what needs parity here.
- Make
discoverEngineParityPairs's listDir recursive (with the existing shim/stub filters) so future
nested duplicates aren't invisible by construction.
Acceptance criteria
Context
Part of the review-stack architecture audit (parent epic).
scripts/check-engine-parity.tsis therepo's existing mechanism for keeping
src/**and its published-package mirrorpackages/gittensory-engine/src/**in sync — butdiscoverEngineParityPairs(
check-engine-parity.ts:104-131) does a non-recursivereaddirSynconsrc/{review,settings,signals}and pairs files with identical filenames at the top level only.Anything nested one directory deeper, or logically duplicated but living inside a bigger file under a
different name, is invisible to it — even though
npm run engine-parity:drift-checkcurrently reports"18 pairs agree" and looks comprehensive.
Finding 1 — already-drifted, live bug
At least 3 independent copies of
diffFilePriorityexist:src/review/review-diff.ts:22-28andsrc/review/review-grounding.ts:118-124(byte-identical to each other), andpackages/gittensory-engine/src/review/diff-file-priority.ts:3(imported bypackages/gittensory-engine/src/signals/predicted-gate-engine.ts:24, used insharesMeaningfulFileatline 928-933 — itself a near-duplicate of
src/signals/engine.ts:5431-5436'ssharesMeaningfulFile).The two host copies correctly match
cartfile\.resolved(Carthage's real lockfile filename); theengine-package copy matches
cartfile\.lock(not a real filename) — a one-character-class typo thatmeans the engine-package's predicted-gate collision-check will never correctly deprioritize a touched
Cartfile.resolved, while the host's equivalent check does. Silent behavioral inconsistency between thehost predicted-gate and the published engine package's predicted-gate for Carthage/iOS repos. Not caught
because neither host copy is a file named
diff-file-priority.ts.Finding 2 — not-yet-drifted, but structurally invisible
safe-url.ts—src/review/content-lane/safe-url.ts(117 lines) vspackages/gittensory-engine/src/review/safe-url.ts(117 lines) are currently byte-identical (verifieddiff, exit 0), but this is luck, not enforcement: the host copy lives incontent-lane/solistDir("src/review")never sees it. One more independent edit to either side drifts it with zero CIsignal — exactly what already happened to
diffFilePriorityand the secrets-scan trio.Fix
cartfile\.lock→cartfile\.resolvedregression inpackages/gittensory-engine/src/review/diff-file-priority.ts:3immediately.GATE_DECISION_TWIN_PAIRescape hatch already builtfor exactly this situation) for
safe-url.tsand for thediffFilePriority/sharesMeaningfulFilefunctions, since the function, not the file, is what needs parity here.
discoverEngineParityPairs'slistDirrecursive (with the existing shim/stub filters) so futurenested duplicates aren't invisible by construction.
Acceptance criteria
src/signals/engine.tsandpackages/gittensory-engine/src/signals/predicted-gate-engine.ts.safe-url.tsanddiffFilePriority/sharesMeaningfulFileare covered by the parity drift-check.engine-parity:drift-checkdiscovers nested-directory duplicates, not just top-level filenamematches.