fix(hooks): scope stop-drift-guard to the toolkit repo via intrinsic marker - #918
Merged
Conversation
…marker The Stop-event drift guard is registered at user scope, so it fired in every repo. Two of its three checks (smoke, doc-counts) ran against the session's own repo, emitting false-positive doc-count drift in unrelated repos (the "Toolkit drift guard found drift to review" rewake in e.g. Hermez). Gate handle_stop on repo identity: run only when cwd/pyproject.toml declares name = "vexjoy-agent". This marker is intrinsic and committed, so it travels with any clone regardless of path, remote, or machine — unlike an absolute path, git remote, or per-machine env var. Non-toolkit repos exit 0 before any check runs. Python 3.10 has no tomllib; read the name with a MULTILINE regex line scan, fail-open on any OSError. Kill switch, async_rewake advisory/never-block, and fail-open contracts unchanged. Hook 1.0.0 -> 1.1.0. Tests: +12 (TestIsToolkitRepo, TestToolkitRepoGate incl. the false-positive regression); 40 pass.
The stop-drift-guard case in the Codex runtime-compat suite stages a synthetic toolkit checkout (fake hooks/, scripts/, a drifting hook) but never wrote a pyproject.toml. With the 1.1.0 toolkit-repo identity gate, the guard now no-ops in a repo without name = "vexjoy-agent", so the fixture no longer exercised the drift path. Stamp the marker so the adapted Stop case reaches the rewake.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
stop-drift-guard.pyStop-event hook is registered at user scope(
~/.claude/settings.json), so it fires in every repo the user opens. Two ofits three checks (
smoke-test-hooks,validate-doc-counts) ran against thesession's own repo, so in unrelated repos they found no toolkit doc-count
claims and emitted false-positive drift — the
Toolkit drift guard found drift to reviewadvisory rewake seen in e.g. the Hermez OpenStack repo (?/ actual?placeholders).Fix
Gate
handle_stopon repo identity: run only whencwd/pyproject.tomldeclares
name = "vexjoy-agent". Non-toolkit repos exit 0 before any checkruns.
The marker is intrinsic and committed, so it travels with any clone regardless
of checkout path, git remote, or machine:
pyproject.toml [project].namePython 3.10 has no
tomllib; the name is read with aMULTILINEregex linescan, fail-open on any
OSError. TheVEXJOY_DRIFT_GUARD_DISABLEkill switch,async_rewakeadvisory/never-block behavior, and fail-open contracts areunchanged. Hook version
1.0.0->1.1.0.Behavioral proof
_is_toolkit_repoTests
+12 tests (
TestIsToolkitRepo,TestToolkitRepoGateincluding thefalse-positive regression test). Target suite: 40 pass.
ruff check+ruff format --check: clean.Note: 3 unrelated pre-existing failures in
test_sync_to_user_claude.py/test_posttool_bash_injection_scan.py(env-specific/tmppath tests) failidentically on
mainand touch neither changed file.