Repository navigation
chore: add pre-commit research validation - #222
Conversation
|
Review: changes required before merge. The hook chooses checks from the staged paths but executes them against the working tree. With a partially staged file, it can validate an unstaged fix while the committed version still fails. Validate a snapshot of the index (or explicitly reject relevant staged/unstaged divergence). Also, any staged source/README change currently triggers every active primitive metric test, including unrelated primitives; this conflicts with the current targeted-test guidance. Select affected metric checks and keep broad runs opt-in. Evidence: Reviewed commit: |
|
Review of The hook still chooses checks from the index but runs them on the working tree, so a partially staged file can commit a failing version while an unstaged fix passes validation. Validate an index snapshot or reject relevant staged/unstaged divergence. Also replace the unconditional full Holding this version for the concrete change above. Validation scope: source/diff and existing CI review; no new full-repository or field-arithmetic test run was requested. |
|
Addressed in 67723a6, integrated with main at e9d5a66. Reproduced the original bug in a temporary Git repository: the hook allowed a commit containing staged-bad bytes while its checker read working-tree-good bytes. The hook now rejects tracked index/checkout differences and every non-ignored untracked file before invoking checkout-wide checks. It leaves the index and tracked contents intact. This is the conservative divergence-rejection option; ignored files are explicitly outside the guard. Removed automatic full-suite metric selection. The full primitive_metrics suite now requires RUN_PRIMITIVE_METRICS=1; CONTRIBUTING.md and the PR description reflect that opt-in. Added nine real-Git contract scenarios, including the original defect, fixed partial-stage rejection, valid changes with spaces/deletions, unstaged dependencies, untracked sources, restored deletions, validator failure propagation/state preservation, metric opt-in, and a linked worktree. A unittest wrapper includes this harness in existing CI discovery. Checker stubs inspect fixture content and verify orchestration; they do not substitute for real Rust validation. The actual hook passed on the fully staged integrated tree with metrics disabled: KB validation (101 records/256 configurations) and Rust formatting passed. The contract harness, shell syntax, and whitespace checks also passed. No broad repository, full metric, or field-arithmetic suite was run for this revision. |
Summary
Add an opt-in Git pre-commit hook for knowledge validation and Rust formatting. Before checking the checkout, the hook rejects tracked differences from the index and every non-ignored untracked file, preventing an unstaged fix from validating different staged bytes. Ignored files are outside this guard.
The full primitive metric suite runs only when explicitly requested with
RUN_PRIMITIVE_METRICS=1 git commit. CONTRIBUTING.md documents installation and this behavior.Validation
A nine-scenario temporary-Git contract harness covers the original partial-stage defect, fixed rejection, valid staging with spaces/deletions, unstaged dependencies, untracked files, validator failures, preservation of staged state, metric opt-in, and a linked worktree. It is included in normal Python unittest discovery. Checker stubs inspect fixture content; these tests do not claim to execute the real metric suite.
The actual hook passed on the fully staged integrated tree: KB validation and Rust formatting succeeded. Shell syntax and whitespace checks also passed. The broad metric and field-arithmetic suites were not run for this revision.