Skip to content

refactor(guard): replace shell regex parser with zero-regex structural guard - #8

Merged
caelaxie merged 3 commits into
mainfrom
feat/zero-regex-guard
Nov 15, 2026
Merged

caelaxie merged 3 commits into
mainfrom
feat/zero-regex-guard

Conversation

@caelaxie

Copy link
Copy Markdown
Contributor

Why

Remove all shell, Python, and Node regex static analysis from hooks/guard.mjs without introducing OS sandboxing. The previous 7,106-line heuristic parser blocked valid read-only inspection commands, missed simple interpreter workarounds, and hijacked casual chats into coordinator mode.

What changed

  • Rewrote hooks/guard.mjs (1,831 lines, 0 regexes, 0 OS sandbox wrappers) around classifyLeadingSlash, per-conversation capsules/<id>.json state, realpathSync confinement on edit_file and write_file, quote-aware git and gh argv gates, image-generator subagent allowance, and in-process PSTACK_PLUGIN_ROOT import() delegation.
  • Added a Stop hook handler in hooks.json and handleStop in hooks/guard.mjs that diffs git status --porcelain against the turn baseline for ro-* and sicko-* workers.
  • Rewrote hooks/guard.test.mjs with static zero-regex and zero-sandbox scanner checks and aligned roles/*.md, skills/, README.md, and docs/guide/*.md.

Scope

  • Covers hooks.json, hooks/guard.mjs, hooks/guard.test.mjs, role capsules, setup-pstack and pstack skill docs, README.md, and guide chapters.
  • Leaves skills/pstack/scripts/watch-pr and unrelated skill workflows unchanged for separate PRs.

Tradeoffs

  • Skips sandbox-exec and bwrap wrappers so test runners, browsers, and compilers never hit OS sandbox denials, relying on realpathSync file-tool gates, git and gh argv checks, and the turn-end Stop cleanliness check instead of pre-execution shell prediction.

Blast Radius

  • Affects SessionStart, PreInvocation, PreToolUse, and Stop lifecycle hooks for installed and global pstack-swarm-guard registrations 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.mjs passed 14 of 14 tests (879.58 ms, down from 51,103 ms) and confirmed 0 regex literals, 0 RegExp references, and 0 sandbox wrappers in hooks/guard.mjs.
  • Clean HOME agy plugin validate --strict ., agy plugin install ., installed plugin validation, ./skills/pstack/scripts/watch-pr --help, and npm --prefix skills/statechart/scripts test (267 pass, 0 fail) all exited 0.
  • PSTACK_PLUGIN_ROOT delegation median latency dropped from 73.4 ms to 27.1 ms across 15 benchmark runs.

…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
caelaxie merged commit 1662dab into main Nov 15, 2026
1 check passed
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).
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