Skip to content

fix(hooks): scope stop-drift-guard to the toolkit repo via intrinsic marker - #918

Merged
notque merged 2 commits into
mainfrom
fix/drift-guard-scope-to-toolkit
Aug 21, 2026
Merged

fix(hooks): scope stop-drift-guard to the toolkit repo via intrinsic marker#918
notque merged 2 commits into
mainfrom
fix/drift-guard-scope-to-toolkit

Conversation

@notque

@notque notque commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Problem

The stop-drift-guard.py Stop-event hook is registered at user scope
(~/.claude/settings.json), so it fires in every repo the user opens. Two of
its three checks (smoke-test-hooks, validate-doc-counts) ran against the
session'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 review advisory rewake seen in e.g. the Hermez OpenStack repo (? / actual
? placeholders).

Fix

Gate handle_stop on repo identity: run only when cwd/pyproject.toml
declares name = "vexjoy-agent". Non-toolkit repos exit 0 before any check
runs.

The marker is intrinsic and committed, so it travels with any clone regardless
of checkout path, git remote, or machine:

Candidate marker Clone-portable?
Absolute path No — breaks on clone elsewhere
Git remote No — breaks on fork/mirror
Per-machine env var No — not in the clone
pyproject.toml [project].name Yes

Python 3.10 has no tomllib; the name is read with a MULTILINE regex line
scan, fail-open on any OSError. The VEXJOY_DRIFT_GUARD_DISABLE kill switch,
async_rewake advisory/never-block behavior, and fail-open contracts are
unchanged. Hook version 1.0.0 -> 1.1.0.

Behavioral proof

cwd _is_toolkit_repo
vexjoy-agent True (guard runs)
hermez False (silent no-op)
/tmp, None, "" False

Tests

+12 tests (TestIsToolkitRepo, TestToolkitRepoGate including the
false-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 /tmp path tests) fail
identically on main and touch neither changed file.

notque added 2 commits August 21, 2026 15:09
…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.
@notque
notque merged commit e54461d into main Aug 21, 2026
11 checks passed
@notque
notque deleted the fix/drift-guard-scope-to-toolkit branch August 21, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant