mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-29 11:15:30 +00:00
The previous attempt on this branch silenced nine classes of genuinely missing
hook while its test suite stayed green, and its "zero false positives" claim
was falsified by this repository's own data. This revision keeps the fix and
removes both defects.
Hook commands are now split the way a shell splits them, quotes included:
- an interpreter's program body is skipped, so the
path.join('scripts/hooks/x.js') inside ECC's own node -e bootstrap is no
longer reported as a missing file. A shell's -c payload is a command line
and is rescanned; a node -e or python -c body is source in another
language and is not a path reference
- a quoted word is one argument, so "C:\Program Files\...\guard.py" is not
cut at the space, and a backslash only escapes whitespace, quotes and
metacharacters, so Windows paths and UNC prefixes survive intact
- a bare relative path is resolved under the project dir, the user home AND
the plugin root, and reported only if missing from all three
- containment applies only to a path a placeholder actually produced, so
/opt/hooks/x.py and ../shared/hook.py are still reported
On this repository's own 23 hook commands in hooks/hooks.json: 55 findings
before, 0 after.
The PreToolUse gate is removed rather than fixed. It was dead code under the
wiring this repo documents (matcher "Edit|Write", both in the audited set), and
CONFIG_HEALTH_AUDITED_TOOLS set to an empty value silently deafened the
monitor. Measured on the real 23 commands, interleaved A/B, median of 30
paired runs, Python 3.12 on Windows:
the wiring audit, in process 4.33 ms -> 3.83 ms
parse and compile this script 1.06 ms -> 3.00 ms
whole --pretool process 50.6 ms -> 54.7 ms
python -c pass 42.1 ms
The audit got cheaper; the cost is script size (10,749 -> 43,083 bytes), and a
script run as __main__ is never byte-cached. Net +4.1 ms on a 55 ms
invocation. The open question for review is whether --pretool should stay in the
recommended wiring at all; dropping it to --startup removes the per-call cost
and is a one-line doc change.
Also: $HOME/$USERPROFILE added to the allowlist, CONFIG_HEALTH_PLUGIN_ROOT to
pin the root when more than one plugin is installed, dedupe on the resolved
path rather than the spelling, single-quoted placeholders skipped, --check
discloses what it did not judge, a settings file that cannot be parsed reports
incomplete rather than healthy, and main() exits 0 on an unexpected exception.
Tests: 9 -> 67, all passing. A test reads this repository's real
hooks/hooks.json and asserts it audits clean, another greps the script to keep
the read-only contract enforced by the suite rather than by a promise in a
docstring, and another injects a fault into every mode to pin the exit-0
contract.
Verified with a 42-case edge battery, a 665,280-command fuzz run (0 crashes, 0
false warnings, 0 uncounted silent drops), and a mutation pass in which every
mutation of a load-bearing rule turns the suite red.