Add agent spawn requirements schema + refactor hook #60
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/claude-custom!60
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "59-agent-spawn-requirements-schema"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replaces hardcoded regex validation in
check-agent-spawn.shwith a JSON-driven schema approach. Agent types and their required_patterns are now defined inschemas/agent-spawn-requirements.json. Adding a new agent type requires only a JSON entry change -- no bash editing needed.Changes
schemas/agent-spawn-requirements.json(new) -- Schema defining required_patterns, description, produces, and isolation for dev, qa, general-purpose, and Explore agent typeshooks/check-agent-spawn.sh(modified) -- Refactored to read schema, validate ALL required_patterns for the given subagent_type, and deny unknown types. 45 lines, bash + jq only.Test Plan
echo '{"tool_input":{"prompt":"Fix issue #100","subagent_type":"dev"}}' | bash hooks/check-agent-spawn.sh-- exits 0, no output (pass)echo '{"tool_input":{"prompt":"Review PR #101. Issue #100","subagent_type":"qa"}}' | bash hooks/check-agent-spawn.sh-- exits 0, no output (pass)echo '{"tool_input":{"prompt":"Update docs. plan-foo","subagent_type":"general-purpose"}}' | bash hooks/check-agent-spawn.sh-- exits 0, no output (pass)echo '{"tool_input":{"prompt":"Explore the codebase","subagent_type":"dev"}}' | bash hooks/check-agent-spawn.sh-- outputs deny JSON (missing issue ref)echo '{"tool_input":{"prompt":"Do stuff","subagent_type":"new-unknown-type"}}' | bash hooks/check-agent-spawn.sh-- outputs deny JSON (unknown type)Review Checklist
jq .)Related Notes
phase-7f-2-agent-spawn-schema-- phase noteagent-spawn-conventions-- convention to update after mergeRelated
plan-2026-02-26-tf-modularize-postgres(Phase 7f-2)PR #60 Review
BLOCKERS
1. QA required_pattern
prmatches common English substringsIn
schemas/agent-spawn-requirements.json, the QA type has:The lowercase
pralternative will match any prompt containing the substring "pr" anywhere -- "provide", "process", "prompt", "project", "production", etc. This makes the second pattern effectively always-pass, defeating the purpose of requiring a PR reference for QA agents.Suggested fix: Use a more specific pattern such as
PR #[0-9]+|[Pp]ull [Rr]equest|PR [0-9]+or add word boundaries if grep supports them (\bPR\b|\bpr\b|pull request). Note thatgrep -Edoes support\b.NITS
1. No
set -euo pipefailThe original script lacked it too, so this is inherited, but adding
set -euo pipefailwould guard against silent failures in the jq or grep calls. Non-blocking.2. Schema
$commentfieldUsing
$commentas a documentation key is fine but unconventional for a non-JSON-Schema file. A top-level"_comment"or just a README alongside the schema might be cleaner. Non-blocking.3.
producesandisolationfields are informational-onlyThe hook reads only
required_patterns. Theproducesandisolationfields are not consumed by any code in this PR. This is fine for future use, but worth noting they are currently dead metadata. Non-blocking.SOP COMPLIANCE
59-agent-spawn-requirements-schemareferences #59)plan-2026-02-26-tf-modularize-postgres)VERDICT: NOT APPROVED
One blocker: the QA
prpattern is too permissive and would effectively skip PR-reference validation for any prompt containing common English words. Fix the regex pattern specificity, and this is ready to merge.PR #60 Review (Re-review after fix commit
d625772)BLOCKERS
None. The previous blocker (broad QA regex matching "pr" substring in words like "prompt", "project") is resolved. The QA
required_patternsnow usesPR #[0-9]+|PR [0-9]+|[Pp]ull [Rr]equest|pulls/[0-9]+, which requires explicit PR references.NITS
Unused schema fields --
producesandisolationare defined in the schema but not read by the hook. Not harmful (they serve as documentation / future use), but worth noting they are dead data for now. Consider a comment in the schema indicating they are informational.set -euo pipefail+ jq pipeline -- Withset -e, ifjqfails to parse the input on lines 9-10 (e.g., non-JSON input piped to the hook), the script will exit immediately with a non-zero code rather than falling through to the allow path. This is the correct behavior (fail-closed), but worth being aware of -- a malformed hook input will block the spawn rather than silently allowing it.Schema path assumption -- The schema resolution
$(cd "$(dirname "$0")/.." && pwd)/schemas/assumes the hook lives one directory below the repo root. This is correct for the current layout (hooks/check-agent-spawn.sh->../schemas/), but if hooks are ever relocated, this will break silently (denied with "schema not found"). The fail-closed fallback is good here.SOP COMPLIANCE
59-agent-spawn-requirements-schemareferences issue #59plan-2026-02-26-tf-modularize-postgres(Phase 7f-2) referencedVERDICT: APPROVED
All three previous findings (1 blocker, 2 relevant nits) have been addressed:
set -euo pipefailadded$commentrenamed todescriptionin schemaThe schema-driven approach is clean. The hook is 45 lines, reads required_patterns from JSON, validates all patterns, and denies unknown types. Fail-closed on missing schema is the right default. Good to merge.