Skip to content

fix(hooks): live-probe gate fires under subdir project dir + surfaces WARN to agents (v4.4.32)#996

Closed
michael-wojcik wants to merge 5 commits into
Synaptic-Labs-AI:mainfrom
michael-wojcik:fix/live-probe-gate-efficacy
Closed

fix(hooks): live-probe gate fires under subdir project dir + surfaces WARN to agents (v4.4.32)#996
michael-wojcik wants to merge 5 commits into
Synaptic-Labs-AI:mainfrom
michael-wojcik:fix/live-probe-gate-efficacy

Conversation

@michael-wojcik

Copy link
Copy Markdown
Collaborator

Summary

Fixes the two efficacy defects in the live-probe gate (pact-plugin/hooks/live_probe_gate.py) surfaced by the #924 tmux dogfood. Implements the #932 code fixes (Finding A + Finding B); closure of #932 and #924 is pending the tmux re-probe per pact-plugin/tests/runbooks/924-locus-b-dogfood-probe.md — that requires a real tmux teammate-mode session and is out of scope for this in-process change.

What landed

Finding A — gate self-disabled under a subdir CLAUDE_PROJECT_DIR.
_resolve_repo_root returned CLAUDE_PROJECT_DIR unconditionally, so a process whose CLAUDE_PROJECT_DIR is the pact-plugin subdir resolved a doubled pact-plugin/pact-plugin marker path, found no plugin marker, and silently self-disabled — shadowing the correct git-common-dir fallback. The early return is now guarded on the plugin marker actually resolving at that root; otherwise it falls through to the existing git-common-dir-parent path, then cwd. One guarded branch — the repo-root and unset cases are behaviorally unchanged.

Finding B — WARN advisory invisible to agent operators.
_emit_warn printed its advisory to stderr on exit 0, which PreToolUse does not surface to an agent (only an exit-2 deny's stderr surfaces). The advisory now emits on stdout as hookSpecificOutput.additionalContext (hookEventName: "PreToolUse"), mirroring the verified sibling task_claim_gate.py. Advisory prose is byte-unchanged and the gate still always exits 0 (non-blocking). No suppressOutput co-emit on the WARN path (it would re-hide the advisory).

Tests

  • Comprehensive resolver matrix (repo-root / subdir / unset) + edge cases (marker-bearing dir trusted regardless of depth; cwd third-tier fallback) + an end-to-end main()-WARNs-under-subdir integration test (proves the gate reconnects, not just the resolver unit).
  • Finding B: surfacing-shape assertions, advisory-prose byte-equivalence, and the silent-vs-WARN suppressOutput asymmetry negative control.
  • Non-vacuity established by a source-only revert with clean per-finding failure attribution.
  • Full hook suite: 9247 passed, 0 failed, 0 errors (rtk proxy, explicit errors-token scan).

Why

The gate exists to remind an operator to run the post-merge live-probe before closing a hook-infra issue. Both defects let it silently no-op for the dominant agent-driven-merge case — defeating its purpose. These fixes restore the intended advisory behavior.

Version: PATCH 4.4.31 → 4.4.32.

Not closing yet

This PR does not close #932 or #924. Their closure is gated on a clean tmux re-probe per 924-locus-b-dogfood-probe.md (which logs a satisfied both-mode row) — a real tmux teammate-mode session, sequenced post-merge.

… WARN to agents

_resolve_repo_root returned CLAUDE_PROJECT_DIR unconditionally, so a process whose CLAUDE_PROJECT_DIR is the pact-plugin subdir resolved a doubled pact-plugin/pact-plugin marker path, found no plugin marker, and silently self-disabled — shadowing the git-common-dir fallback. The early return is now guarded on the plugin marker resolving at that root; otherwise it falls through to the existing git-common-dir-parent path, then cwd. The repo-root and unset cases are unchanged.

_emit_warn printed its advisory to stderr on exit 0, which PreToolUse does not surface to an agent operator (only exit-2 deny stderr surfaces). The advisory now emits on stdout as hookSpecificOutput.additionalContext (hookEventName PreToolUse), reaching agent-driven merges. Advisory text unchanged; the gate still always exits 0 (non-blocking).

Adds resolver-matrix and surfacing-shape verification tests; re-points the dogfood-probe runbook VERIFY procedure to the new channel.
Adds the both-project-dir resolver matrix (repo-root / subdir / unset) plus edge cases — a marker-bearing project dir trusted regardless of depth, the cwd third-tier fallback when the marker is absent and git is unresolvable, and an end-to-end check that main() WARNs rather than silently self-disabling under a subdir project dir.

Adds the WARN-path surfacing-shape assertions, advisory-prose byte-equivalence, and the silent-vs-WARN suppressOutput asymmetry negative control. Non-vacuity is established by a source-only revert with clean per-finding failure attribution; full hook suite 9247 passed, 0 failed, 0 errors.

Test-only; source byte-identical to the prior commit.
…verage

Folds in review findings: the silent-when-satisfied test now spies on _has_satisfied_row to assert it is called with the resolved repo root (isolating the fall-through instead of passing green-both-trees); the byte-equivalence test docstring is reframed as an accurate green-tree drift-detector; and a new end-to-end test drives main() through the waiver_ok=True path. Non-vacuity re-proven by source-only revert.
Inline comments folding in reviewer findings: the WARN rests solely on the additionalContext channel (no backstop — acceptable for a non-blocking advisory; runtime delivery confirmed by the post-merge re-probe); the git-common-dir fallback intentionally resolves to the main checkout, not a worktree; and the repo-root-case second marker read is intentional. Comments only, no logic change.
@michael-wojcik

Copy link
Copy Markdown
Collaborator Author

Superseded by #997. The hook-audit this session confirmed live_probe_gate.py is maintainer-internal dev-tooling that leaked into the shipped plugin (1 of 25 hooks — the other 24 are genuinely consumer-facing). The right fix is to REMOVE the gate from the shipped plugin and replace the runtime-verification need with non-mocked seam-integration-tests — not the #932 efficacy fix this PR contained (which would have polished, and via Finding B made more visible, a hook we're deleting). Closing in favor of the removal tracked in #997.

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.

locus-b live-probe gate (v4.4.14): two efficacy defects surfaced by the #924 tmux dogfood

1 participant