Closes the ~150 false drifts that prevented strict mode. The old regex
`\b(Name)\s+v(\d+\.\d+)` swept the whole file head and matched every
historical version mention, plus the FROM-side of arrow transitions
("v1.30→v1.31"). Real current-vs-header drift in the repo: zero.
Two-tier detection:
- Primary LINK_REF_RE: a markdown-link to a normative file followed by
the first bold version — "[..](docs/Tooling_v8_3.md) (**Прил. Н
v2.17**". Link anchor makes it immune to history-block noise. This is
how CLAUDE.md §0 cross-refs table is written, so CLAUDE.md is fully
validated. Runs on the whole file.
- Fallback CROSS_REF_RE: plain "Name vX.Y" mention, scoped to the text
*before* the first history block. Pravila/Tooling/PSR_v1 have no
markdown-link cross-refs, so the fallback covers them — but their
shapki list past releases, so the scan stops at the first history
marker (`**vN.M наследие**` / `**Что изменилось в vN.M относительно**`
/ `**vN.M** — `). dedupe-by-target keeps the first ref per target.
Regex hardening:
- `\b` after the version forbids backtracking to a partial capture
(so "v1.30→" never collapses to a spurious "v1.3" match).
- `(?!\s*→)` negative lookahead drops the FROM-side of transitions.
TDD: 8 new tests (link-based, "Прил. Н" prefix, multi-file table,
dedupe, two arrow shapes, three history-marker shapes, link-beats-
fallback). 18/18 GREEN.
Smoke: node tools/cross-ref-checker.mjs -> exit 0, "OK — 0 drift in
4 files" (Pravila/CLAUDE.md/Tooling/PSR_v1; MEMORY.md is outside the
repo by design — existsSync-skipped).
Refs: ADR-011 brain governance §6.2 (C2 cross-ref consistency detector).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pure regex/JSON, 0 LLM calls. 5 Vitest tests GREEN (23/23 total).
Per ADR-011 + spec §6.2.
Smoke run on real repo surfaces ~150 «drifts» — these are
**historical 'наследие' entries** in headers (CLAUDE.md / Pravila /
Tooling / PSR_v1), not actual current cross-ref mismatches. Each
of these 4 files has a multi-line «v2.X наследие:» / «v1.Y наследие:»
chain in its top header describing past sub-versions; my 50-line
scan picks them all up.
CONCERN: mechanism is correct (test fixtures pass), but real-world
needs refinement before lefthook wiring (C5). Options for follow-up:
- Scope match to explicit «§0 cross-refs» table marker.
- Distinguish «current cross-ref» from «historical наследие mention»
by surrounding markup.
- Restrict regex to cross-ref tables (markdown | columns) only.
Until refined: C2 will be wired in C5 with caveat (WARN-only, or
disabled) to avoid blocking every commit on pre-existing 'наследие'
entries.
Extracted Tooling Прил. Н version via **Версия:** pattern (file-level
v8.3 wrapper at line 1 was misleading — Прил. Н is v2.17 at line 4).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>