Skip to content

fix: remove TaskCreate mode-check hook that contradicts admiral exception (#112)#116

Merged
harrymunro merged 1 commit into
mainfrom
fix/issue-112-taskcreate-hook-removal
May 8, 2026
Merged

fix: remove TaskCreate mode-check hook that contradicts admiral exception (#112)#116
harrymunro merged 1 commit into
mainfrom
fix/issue-112-taskcreate-hook-removal

Conversation

@harrymunro
Copy link
Copy Markdown
Collaborator

Summary

  • Removes the PreToolUse:TaskCreate mode-check hook that blanket-rejected TaskCreate whenever mode ≠ agent-team, blocking the admiral from creating its own Ctrl+T visibility task list in subagents mode (the dominant Nelson mode).
  • The hook payload provides no field to distinguish admiral from captain, so it could not honor the documented admiral exception in references/tool-mapping.md and references/standing-orders/wrong-ensign.md. Result: a hook directly contradicting the docs, as reported in Bug: PreToolUse:TaskCreate hook and tool-mapping.md at odds #112.
  • Relaxes enforcement to match the docs: keep the admiral exception, rely on the SKILL.md convention for captain discipline (captain TaskCreate in an isolated subagent context never reaches the admiral's Ctrl+T view, so misuse is harmless).

Changes

  • hooks/hooks.json — drop the TaskCreate matcher block.
  • hooks/nelson_hooks.py — delete cmd_mode_check, its subparser, its dispatch entry, and the mode-check line from the module docstring.
  • hooks/test_nelson_hooks.py — delete the TestModeCheck class and the cmd_mode_check import; update the docstring.
  • README.md — drop the now-stale row from the enforcement-hooks table.

settings.json is intentionally left untouched: its Agent|TeamCreate|TaskCreate matcher invokes nelson-phase.py validate-tool, not nelson_hooks.py mode-check, and is out of scope.

Out of scope

  • Adding admiral-detection machinery (transcript_path comparison, session markers) — rejected as over-engineering for a documented soft convention.
  • Re-enforcing captain discipline via a different mechanism — captain TaskCreate in an isolated subagent context is harmless; SKILL.md guidance is sufficient.

Test plan

  • pytest hooks/test_nelson_hooks.py -q — 48 passed (was 52; 4 TestModeCheck cases removed)
  • pytest skills/nelson/scripts -q — 278 passed (no regression)
  • bash scripts/check-references.sh — OK, no broken cross-refs
  • Smoke: echo '{...}' | python3 hooks/nelson_hooks.py mode-check now exits with invalid choice: 'mode-check' (dispatch entry confirmed gone)
  • Manual: in a real subagents-mode mission, confirm the admiral can TaskCreate for visibility without surfacing Standing order violation (wrong-ensign)

Closes #112.

…tion (#112)

The PreToolUse hook on TaskCreate blanket-rejected the call whenever mode
was not agent-team. The hook payload provides no field to distinguish the
admiral from a captain, so the admiral itself was blocked from creating
its own Ctrl+T visibility task list in subagents mode — directly
contradicting the documented admiral exception in
references/tool-mapping.md and references/standing-orders/wrong-ensign.md.

Relax the hook: drop the over-enforcement, keep the admiral exception,
and rely on the SKILL.md convention for captain discipline (captain
TaskCreate in an isolated subagent context is harmless — its task list
never reaches the admiral's Ctrl+T view).

- Remove the TaskCreate matcher from hooks/hooks.json
- Delete cmd_mode_check, its subparser, dispatch entry, and docstring
  line from hooks/nelson_hooks.py
- Delete TestModeCheck and the cmd_mode_check import from
  hooks/test_nelson_hooks.py
- Update the README enforcement-hooks table to drop the removed row

settings.json is left untouched: its Agent|TeamCreate|TaskCreate matcher
runs nelson-phase.py validate-tool, not nelson_hooks.py mode-check, and
is out of scope.
@harrymunro harrymunro merged commit 82e1d83 into main May 8, 2026
6 checks passed
harrymunro added a commit that referenced this pull request May 8, 2026
…on marker

PR #116 removed the PreToolUse:TaskCreate mode-check hook because it
blanket-rejected the admiral's own Ctrl+T visibility tracking. This
reinstates enforcement properly by discriminating admiral from captain
via the hook payload's transcript_path (each subagent gets its own).

- session-init (SessionStart): records admiral transcript_path to
  .nelson/admiral.session
- session-check (PreToolUse:TaskCreate): rejects with wrong-ensign only
  when mode is subagents/single-session and the payload transcript_path
  does not match the recorded admiral marker
- preflight: opportunistically backfills the marker if init ran after
  SessionStart fired
- stand-down: best-effort marker cleanup
- All paths fail-open on uncertainty (missing marker, empty transcript,
  no mission), so non-Nelson projects and edge cases are unaffected
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.

Bug: PreToolUse:TaskCreate hook and tool-mapping.md at odds

1 participant