✨ feat(pariksha): a commit checks identifiers and the names it removes

Merged
AT
1d ago
+542-79

pariksha doc-references --staged now catches at commit what --base catches at push for the staged change: DOC-DRIFT-04 identifiers, and docs naming an identifier, script or --flag the index removes against HEAD. It is the pariksha part of Decision: 1C and 2A on https://github.com/athya-hq/athya_mono/issues/4007#issuecomment-7201240025.

What a commit reads now

  • Every check by default, DOC-DRIFT-04 included (cli.ts). --checks 01,02 gives today's run.
  • Beside the deleted or renamed paths and removed scripts it read before: docs naming an identifier or --flag the commit removes that no code in the index still holds. A name still defined elsewhere pulls in no doc, so a commit stays seconds. The push still re-checks those, and name:line citations.
  • In a doc pulled in only for a removal, a finding HEAD already had is not the commit's, as a push excuses what its merge base had. A staged doc, or a doc whose baseline entry the commit edits, is still held to its count. (Excusing those too would let a commit drop a baseline entry whose finding remains; the existing test caught it.)
  • Mid-merge, what the merge took unchanged removes nothing (withoutFiles).
  • codeWords reads the index's code once for both questions (what the commit removed, then what its docs name).
  • Push too: a legacy look-up at the base runs only the checks that failed. A DOC-DRIFT-04 failure no longer materialises the base tree for lychee. Same result, since a legacy finding matches by check.

The W-37.2 commit is refused at commit now. Replayed on athya_mono: HEAD 932685be5, index ed96f2f95 (51 files, 7,217 lines removed). Before, --staged passed (19 docs checked). Now it refuses with the line the push refused with, after 2 minutes, on 2026-11-26:

pariksha doc-references: docs/standards/best-practices/code-hygiene/shell-scripting.md:44: [DOC-DRIFT-04] scrub_git_env(): `scrub_git_env` occurs nowhere in the code — renamed, removed, or never written

Cost at commit, on athya_mono (5,475 files), on an 18-core Mac. Variants ran interleaved, each round in turn. Wall and CPU (user+sys, children included) are medians. The load is the 1-minute load average while it ran.

Staged changeLoadOld wall / CPUNew wall / CPUDocs checked, old → new
W-37.2 ed96f2f95, 7,217 lines removed, refused64–752.40 / 0.83 s8.06 / 2.34 s19 → 22
W-59.2 3191adf6b, 18,508 lines removed14–151.30 / 1.38 s2.65 / 2.81 s37 → 38
W-67 b766c95b2, 12,563 lines removed140.81 / 0.87 s2.14 / 2.23 s14 → 26
W-69 d4b5bd682, 123 files140.81 / 0.85 s1.62 / 1.71 s38 → 38
K-05 06d9e0ab9, 3 code files13–140.35 / 0.37 s1.16 / 1.18 s1 → 1
d4879ca49, 1 test file130.28 / 0.32 s1.11 / 1.10 s0 → 0
K-06 216edcee5, 2 code files140.29 / 0.32 s0.32 / 0.35 s1 → 1
9b6ecd267, 1 script's comment130.32 / 0.34 s0.33 / 0.37 s1 → 1
125e24009, 2 docs41–420.41 / 0.41 s0.93 / 0.67 s2 → 2

W-37.2 ran 5 rounds and the others 3, through .tmp/ scripts that replay each commit into a scratch worktree. The replay read main's athya-rules doc-references.json through a node_modules symlink. A commit that removes a camelCase word or a flag from code now reads and tokenises all the index's code once, about 0.8 s here. A commit that removes none costs what it did. The W-37.2 row ran at load 64–75 from other sessions' mutation runs, so its wall is inflated; the CPU column is the steadier figure.

Push on the same change (--base 932685be5 --head ed96f2f95, 3 rounds, load 56–88): old 31.1 s wall / 12.1 s CPU, new 33.1 s / 9.3 s, with the same refusal. The push checks 128 docs there, because its removed flags (--staged, --help …) are not narrowed. That is unchanged here.

DOC-DRIFT-04 on athya_mono main: --all --checks 04 passes over all 1,589 reference files. Pinning this version refuses no commit to a doc that is already at its count.

Checks run here

  • pnpm test in packages/pariksha: 4,663 tests, 0 failed. Coverage: all files 99.97% lines, 99.44% branches, 99.95% functions; doc-identifiers.ts 100%; doc-references-gate.ts 100% lines and branches, 98.51% functions.
  • eslint on the changed files: clean.
  • The mutation lane has not run to the end here. I stopped agnipariksha --lane pariksha on doc-identifiers.ts and doc-references-gate.ts (1,257 mutants) after 43 minutes, at the coordinating session's request: the machine's load was 63–87, and another push's Android gate needs it under 18. The required Mutation check judges the lane here. Three guards that looked like equivalent mutants were restructured before the push: wordsGoneFromCode, withoutFiles, and one legacy value.
  • veda's git hooks did not run, because this branch was built in a clone where kavach refuses setting core.hooksPath. I ran their stages by hand instead. dvara records --base origin/main passed (8 files, 2 legacy held), dvara frozen passed, pnpm guards passed, and pariksha smoke passed. niyam's pre-push is left to the Guard check.

The version stays at 0.8.12. The release comes in its own PR after this merges, after dvara's v0.8.14.

Approved: Alok's 👍 on https://github.com/veda-hq/veda/issues/640#issuecomment-7201526152.

Slice: #640

🤖 Generated with Claude Code