Repository navigation
Description
Summary
The disk-hygiene destructive_guard.py engine gate denies Bash invocations of the plugin's own test file, test_hygiene.py, because the engine marker is matched as a bare substring. _ENGINE_MARKER = "hygiene.py" is a substring of test_hygiene.py, so a different file trips the gate.
Found incidentally while babysitting #1588 — the exact command the Codex reviewer recommended in its review comment there is denied by this plugin's own hook.
Reproduction
Verified on this machine with disk-hygiene 0.9.7 installed and enabled.
Denied (marker-bearing path + an interpreter token parses as an engine invocation):
cd <repo> && python3 -m unittest -v plugins/disk-hygiene/skills/clean/scripts/test_hygiene.pyDisk-hygiene fails closed: Bash is restricted to exact bundled scan, preview, handoff-verify,
and apply invocations using the hook's absolute Python interpreter "...python.exe". Bare
python/python3 commands are denied because shell functions and aliases can replace them.
Allowed (dotted-module form carries no .py, so the marker is absent and the gate defers):
cd <repo>/plugins/disk-hygiene/skills/clean/scripts && python3 -m unittest test_hygiene.GuardTests.<method>Both invoke the same tests. The only difference is whether the literal string hygiene.py appears in the command.
Why the existing mitigation does not catch this
_engine_gate_relevant's docstring states that a word resolving to an existing file other than the bundled hygiene.py "is not this engine and defers", implemented via os.path.samefile(word, bundled). That check cannot help here:
samefileresolves the word relative to the hook process's working directory, which is not the user's shell CWD, so a repo-relative path likeplugins/disk-hygiene/.../test_hygiene.pydoes not resolve and raisesOSError._samefilereturnsFalseonOSError, and an unresolvable marker-bearing word deliberately "stays in play" — so the gate proceeds,classify_exact_engine_commandcannot match a unittest invocation, and the command is denied.
Impact
Bounded but real, and it is a dogfooding defect: in any consumer session with disk-hygiene enabled, a contributor (human or agent) cannot run this plugin's test suite through Bash using the natural file-path form. The dotted-module form is an undocumented workaround. It also means the gate's substring match will deny unrelated third-party files whose names merely end in hygiene.py (e.g. a consumer's own test_hygiene.py) whenever the path cannot be resolved from the hook's CWD.
No security weakening — this is over-blocking, which is the correct direction for a fail-closed guard to err. The cost is usability and contributor friction, not exposure.
Suggested direction (not prescriptive)
Match the marker on a filename boundary rather than as a bare substring: treat a word as marker-bearing only when its Path(word).name casefolds to exactly hygiene.py, instead of testing _ENGINE_MARKER in lowered over the whole command string. That keeps every current gating shape (including python3 -B .../hygiene.py and linked aliases invoked by path) while letting test_hygiene.py — a genuinely different filename — defer without depending on CWD-sensitive samefile resolution.
Worth confirming against the gate's own test suite before changing anything; the substring form may be load-bearing for a copy-evasion case I have not identified.
Activity
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during triage.
Triage: verified
Reproduced live in this session against
origin/main, with disk-hygiene enabled and the plugin-level engine gate active:.pysuffix anywhere in the command) run to completion — 86 tests,OK (skipped=2).git show … | grepinspection command was denied for the same reason, purely because a marker-suffixed filename appeared in it.The reported mitigation analysis holds. The "provably a DIFFERENT existing file" escape resolves the word against the hook process's working directory, not the user's shell CWD, so a path that is valid in the user's shell does not resolve for the hook; an unresolvable marker-bearing word deliberately stays in play, the gate proceeds, the exact-invocation classifier cannot match a unittest command, and the belt denies.
Also checked: no bundled gate test asserts that a filename merely containing the marker must gate. Every existing gate test uses the exact engine filename (bare, absolute, wrapper-launched, compound-payload) or the same-file identity path. The reporter's own caution — "the substring form may be load-bearing for a copy-evasion case I have not identified" — did not survive that check.
Category: bug (over-blocking usability defect in a fail-closed guard; no security weakening in the reported direction).
Agent Brief
Type: Bug
Summary: The plugin-level engine gate treats the engine's filename marker as a bare substring, so a genuinely different file whose name merely ends with that marker is routed into the fail-closed belt and denied.
Current behavior:
Marker relevance is decided by a substring test over the whole command string and, in the compound/unparsable branches, over individual tokens. A filename such as the plugin's own test module contains the engine marker as a suffix, so it is treated as marker-bearing. The differencing escape hatch depends on resolving the word to an existing file from the hook's working directory; when that resolution fails the word stays in play and the command is denied. Contributors must use an undocumented dotted-module workaround to run this plugin's test suite through Bash. Third-party files whose names end with the same marker are denied the same way whenever they cannot be resolved from the hook's CWD.
Desired behavior:
A word is marker-bearing only when its filename component equals the engine marker exactly (casefolded). A different filename that merely ends with the marker is not the engine and defers, with no dependence on CWD-sensitive path resolution. Every shape that gates today continues to gate.
Key interfaces:
_engine_gate_relevant()— the relevance predicate; its whole-command early bailout, its unparsable/compound token branches, and its literal-word loop must all agree on one boundary-aware marker test._ENGINE_MARKER— the marker constant; its comparison semantics change from substring-containment to filename-component equality._script_path_key()/_same_file_as_bundled()— the identity path; it must remain the mechanism that catches a link to the bundled engine under any other name, including a marker-suffixed one.classify_exact_engine_command()— unchanged; it stays the authority once the gate decides a command is relevant.Acceptance criteria:
Out of scope:
Labels applied
Bug(native issue type),priority: medium,agent-ready,status: ready;priority: needs-triagecleared. Reporter did not self-label a severity; impact is contributor friction, not exposure, so the assessed default tier applies. Theautomatedlabel is retained.Role-label resolution warning: this repository's
.work-item-tracker.jsoncarries noconfig.role_labelsentry, so the canonical roles fell back to their documented defaults (agent-ready/needs-human). Both strings exist as labels in this repository, so the fallback is correct here — but it is a fallback, not a binding.kyle-sexton commentedon Jul 26, 2026
This was generated by AI during triage.
Decision defaulted: match the engine marker on a filename boundary (filename component equals the marker, casefolded) rather than as a bare substring — veto before merge.
Grounding: triage verification found no bundled gate test that depends on substring-only matching — every existing gate test uses the exact engine filename or the same-file identity path — and link/alias coverage survives the change, because a marker-suffixed link to the bundled engine falls through to the marker-absent scan, which identity-checks every separator-carrying word. That closes the reporter's own open question ("the substring form may be load-bearing for a copy-evasion case I have not identified").
The maintainer-vetoable alternative: keep the substring form and special-case the plugin's own test module. Reversible, but narrower — it leaves every third-party filename ending in the same marker over-blocked whenever it cannot be resolved from the hook's working directory.
Flagged for veto rather than shipped silently because it relaxes the matching of a fail-closed guard. The direction of the relaxation is over-blocking → correctly-scoped blocking, and the identity path is unchanged, but a security-posture edit in a kill-switch guard deserves a maintainer's eyes before merge.
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during triage.
Admission gate: carries
agent-readybut nowork-class:label and no body-recorded class trailer — unclassified → fail-closed human-gated per the work-loop lane's admission table (a role label alone is not classification evidence). Routed to human-gated; not dispatched. (Recurring pattern, tracked at #1288.)kyle-sexton commentedon Jul 26, 2026
🤖 Released by autonomous babysit lane (fable-autopilot) at session wind-down. Not fixed. Parked for a successor.
PR #1625 carries the work:
do-not-mergeapplied, HEADb401bd08, all four commits pushed, CI green, one review thread left unresolved because the finding it records is genuinely unaddressed.Codex reviewed six times and found five real defects; four were fail-opens the change itself introduced. Four are fixed with reproduction evidence in their threads. Two remain, and both are regressions this branch introduced, so neither is legitimately deferrable — each must be fixed or the branch reverted:
hygiene.py.executes the bundled engine (verifiedsamefile: Trueon a Windows host) while the gate defers. A fail-open.~,+, or@is over-gated. fix(disk-hygiene): engine gate over-gates a consumer's own engine-named script when its absolute path holds a non-keep-class character #1640 is annotated to say it should be closed by whatever resolves fix(disk-hygiene): match the engine marker on a filename boundary #1625 rather than scheduled separately.I earlier deferred both under a fix-round cap. That cap was retracted as contradicting org policy — round count is never a stopping criterion — so that reasoning is withdrawn and recorded as withdrawn on the PR.
The substantive question for a successor is not "handle trailing dots". All five defects share one root: the change makes the filename authoritative, and there turned out to be many ways to spell a filename; each fix passed a differential matrix before the next spelling appeared. The direction recorded in the PR's final thread — make identity authoritative (
basename matchesorthe token resolves to the bundled engine) — is a hypothesis, not a tested result. Reverting is an equally legitimate outcome.mainis unchanged and still carries the original over-gate this issue reports.kyle-sexton commentedon Jul 27, 2026
🤖 Agent-authored (autonomous babysit lane orchestrator, wind-down disposition). PR #1625 is parked (do-not-merge, escalated) after its author's pre-committed stop rule fired: four self-introduced fail-opens across six review rounds, terminal one being the Windows trailing-dot normalization bypass (verified:
os.path.samefile('hygiene.py.', 'hygiene.py')is True on Win32).Orchestrator disposition, concurring with the author's recommendation: re-scope to the identity-based predicate (basename equality OR token resolves to the bundled engine — identity is ground truth; subsumes spelling variants without enumeration), implemented from a FRESH context (the enumerative-verification blind spot is documented on the PR), run through the full adversarial review chain with the six threads of preserved evidence as its test corpus. An independent plugin-quality audit of this session separately confirmed the root cause is unfixed at origin/main and the false-positive class reproduces live — the two findings converge on the same re-scope.
Incidental live reproduction while posting this very comment: the gate blocked a
gh issue commentinvocation because the comment body mentioned the engine filename and a bare interpreter name — argument-string matching gating a tracker write. Recorded in the audit packet as fresh evidence for the false-positive class.Do not merge #1625 as-is (live fail-open on the fleet's primary platform). Related: #1640 (over-gate on legal path characters).
fix(disk-hygiene): deny the different-file escape to this plugin's ow…
fix(disk-hygiene): treat engine names in PowerShell string data as me…