Repository navigation
refactor(guard): replace shell regex parser with zero-regex structural guard - #8
Merged
Merged
Conversation
…l checks Drop shell, Python, and Node regex static analysis from hooks/guard.mjs without adding OS sandboxing. Gate session activation on leading swarm slash commands, store capsule state per conversation, allow invoke_subagent for image-generator, confine edit_file and write_file with realpathSync, check git and gh footguns via quote-aware argv tokens, and verify turn-end git status cleanliness in a Stop hook.
caelaxie
added a commit
that referenced
this pull request
Nov 16, 2026
…pt tests, and trim kernel (#9) ## Why Eliminate post-PR #8 upgrade drift, sticky `coordinator` locks after swarm completion, `monitor` and `read_board` turn overhead, unmanaged transcript re-parsing, duplicated coordinator prompt text, and missing script test suites across `agy-pstack-next` `2.1.0`. ## What changed - Added `skills/setup-pstack/scripts/sync-hooks.mjs`, coordinator `SessionStart` global `hooks.json` drift detection, finished-swarm `coordinator` lock release, `unforkedRoot` state caching, dual-hook `PLUGIN_ROOT` short-circuiting, and legacy cache cleanup in `hooks/guard.mjs` (`0` regexes, `0` sandboxing) and bumped `.antigravity-plugin/plugin.json` to `2.1.0`. - Switched `skills/pstack/scripts/watch-pr` CLI flag parsing to strict `util.parseArgs`, ported `watch-pr.test.mjs`, `check-plan.mjs`, `check-plan.test.mjs`, `worktree-audit.sh`, and `decision-log.sh`, and wired `skills/statechart/scripts/bun.lock` plus cached `TLA2TOOLS` in `.github/workflows/ci.yml`. - Trimmed `skills/pstack/SKILL.md` from `20,139` bytes to `8,961` bytes, added `monitor` fast-tier model defaults and `seqs`/`$PWD` worker rules, scoped goal preambles to new tasks, set `disable-model-invocation` on `setup-pstack`, `reflect`, and `verify-gen`, and restored `image-generator` visuals, fade warnings, and blind `crucible` judging. ## Scope - Covers improvements 1, 2, 3, 4, 5, and 7 across `hooks/`, `skills/`, `roles/`, `docs/guide/`, `README.md`, `.antigravity-plugin/plugin.json`, and `.github/workflows/ci.yml`. - Intentionally leaves item 6 (`RO_BLOCKED_GIT_SUBCOMMANDS`, `GH_MUTATING_ACTIONS`, `--delete` refspecs, underscored MCP server names, and `member-map.json` eviction) unchanged per request. ## Blast Radius - Updates lifecycle hook caching and deduplication for root and worker sessions, `watch-pr` CLI validation (`--flag=false` now exits `64`), CI test execution, and skill frontmatter visibility for the three operator maintenance skills. ## Verification - `node --test hooks/guard.test.mjs skills/pstack/scripts/watch-pr.test.mjs skills/pstack/scripts/check-plan.test.mjs` passed `85` of `85` tests across `17` suites with `0` regexes and `0` OS sandbox calls. - Clean `HOME` `agy plugin validate --strict .`, `agy plugin install .`, installed-copy strict validation, `bash -n` on both `.sh` scripts, `sync-hooks.mjs --check` probes, and a `296`-link scan across `93` markdown files all exited `0`. - `bun install --frozen-lockfile && bun run test` in `skills/statechart/scripts` passed `267` of `267` local tests (`0` failures).
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.
Why
Remove all shell, Python, and Node regex static analysis from
hooks/guard.mjswithout introducing OS sandboxing. The previous7,106-line heuristic parser blocked valid read-only inspection commands, missed simple interpreter workarounds, and hijacked casual chats intocoordinatormode.What changed
hooks/guard.mjs(1,831lines,0regexes,0OS sandbox wrappers) aroundclassifyLeadingSlash, per-conversationcapsules/<id>.jsonstate,realpathSyncconfinement onedit_fileandwrite_file, quote-awaregitandghargv gates,image-generatorsubagent allowance, and in-processPSTACK_PLUGIN_ROOTimport()delegation.Stophook handler inhooks.jsonandhandleStopinhooks/guard.mjsthat diffsgit status --porcelainagainst the turn baseline forro-*andsicko-*workers.hooks/guard.test.mjswith static zero-regex and zero-sandbox scanner checks and alignedroles/*.md,skills/,README.md, anddocs/guide/*.md.Scope
hooks.json,hooks/guard.mjs,hooks/guard.test.mjs, role capsules,setup-pstackandpstackskill docs,README.md, and guide chapters.skills/pstack/scripts/watch-prand unrelated skill workflows unchanged for separate PRs.Tradeoffs
sandbox-execandbwrapwrappers so test runners, browsers, and compilers never hit OS sandbox denials, relying onrealpathSyncfile-tool gates,gitandghargv checks, and the turn-endStopcleanliness check instead of pre-execution shell prediction.Blast Radius
SessionStart,PreInvocation,PreToolUse, andStoplifecycle hooks for installed and globalpstack-swarm-guardregistrations while keeping standalone inline skills (/bro,/technical-writing,/statechart,/setup-pstack,/control-ui,/control-cli,/make-bot-ui, and/ketchup --plain) unmanaged.Verification
node --test hooks/guard.test.mjspassed14of14tests (879.58ms, down from51,103ms) and confirmed0regex literals,0RegExpreferences, and0sandbox wrappers inhooks/guard.mjs.HOMEagy plugin validate --strict .,agy plugin install ., installed plugin validation,./skills/pstack/scripts/watch-pr --help, andnpm --prefix skills/statechart/scripts test(267pass,0fail) all exited0.PSTACK_PLUGIN_ROOTdelegation median latency dropped from73.4ms to27.1ms across15benchmark runs.