Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ Nelson is not purely advisory. A set of Claude Code hooks (`hooks/nelson_hooks.p
| Event | Hook | What it enforces |
|---|---|---|
| `PreToolUse` on `Agent` | `preflight` | Station tier gate, file ownership conflicts, mode-tool consistency |
| `PreToolUse` on `TaskCreate` | `mode-check` | Rejects task creation in non-agent-team modes |
| `PostToolUse` on `Write`/`Edit` | `brief-validate` | Turnover brief quality gate |
| `TaskCompleted` | `task-complete` | Validation evidence and station controls |
| `TeammateIdle` | `idle-ship` | Paid-off standing order advisory |
Expand Down
9 changes: 0 additions & 9 deletions hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/nelson_hooks.py\" preflight"
}
]
},
{
"matcher": "TaskCreate",
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/nelson_hooks.py\" mode-check"
}
]
}
],
"PostToolUse": [
Expand Down
31 changes: 0 additions & 31 deletions hooks/nelson_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

preflight — PreToolUse on Agent: station tier gate, file ownership
conflicts, mode-tool consistency
mode-check — PreToolUse on TaskCreate: reject in non-agent-team modes
brief-validate — PostToolUse on Write/Edit: turnover brief quality gate
task-complete — TaskCompleted: validation evidence and station controls
idle-ship — TeammateIdle: paid-off standing order advisory
Expand Down Expand Up @@ -222,31 +221,6 @@ def cmd_preflight(args: argparse.Namespace) -> None:
_allow()


# ---------------------------------------------------------------------------
# Subcommand: mode-check (PreToolUse on TaskCreate)
# ---------------------------------------------------------------------------


def cmd_mode_check(args: argparse.Namespace) -> None:
"""Reject TaskCreate in non-agent-team execution modes."""
payload = _read_stdin()
ctx = _load_mission_context(payload)
if ctx is None:
_allow()

_, battle_plan = ctx
mode = _get_mode(battle_plan)
if mode in ("subagents", "single-session"):
_reject(
f"Standing order violation (wrong-ensign): "
f"TaskCreate is not available in {mode} mode. "
f"Track work in the admiral's conversation context. "
f"See references/tool-mapping.md."
)

_allow()


# ---------------------------------------------------------------------------
# Subcommand: brief-validate (PostToolUse on Write/Edit)
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -669,10 +643,6 @@ def main() -> None:
"preflight",
help="Pre-flight standing order gate (PreToolUse on Agent)",
)
subparsers.add_parser(
"mode-check",
help="Mode-tool consistency check (PreToolUse on TaskCreate)",
)
subparsers.add_parser(
"brief-validate",
help="Turnover brief quality gate (PostToolUse on Write/Edit)",
Expand All @@ -690,7 +660,6 @@ def main() -> None:

dispatch = {
"preflight": cmd_preflight,
"mode-check": cmd_mode_check,
"brief-validate": cmd_brief_validate,
"task-complete": cmd_task_complete,
"idle-ship": cmd_idle_ship,
Expand Down
28 changes: 2 additions & 26 deletions hooks/test_nelson_hooks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Tests for nelson_hooks.py — hook enforcement script.

Tests the preflight, mode-check, brief-validate, task-complete,
and idle-ship subcommands using temporary mission directories and
monkeypatched stdin.
Tests the preflight, brief-validate, task-complete, and idle-ship
subcommands using temporary mission directories and monkeypatched stdin.
"""

from __future__ import annotations
Expand Down Expand Up @@ -35,7 +34,6 @@
_has_evidence,
cmd_brief_validate,
cmd_idle_ship,
cmd_mode_check,
cmd_preflight,
cmd_task_complete,
)
Expand Down Expand Up @@ -302,28 +300,6 @@ def test_marine_subagent_in_agent_team_allows(self, tmp_path: Path) -> None:
assert code == 0


# ---------------------------------------------------------------------------
# Mode-check
# ---------------------------------------------------------------------------


class TestModeCheck:
def test_no_mission_allows(self, tmp_path: Path) -> None:
assert _run(cmd_mode_check, {"tool_name": "TaskCreate", "tool_input": {}}, str(tmp_path)) == 0

def test_subagents_mode_rejects(self, tmp_path: Path) -> None:
_make_mission(tmp_path, mode="subagents")
assert _run(cmd_mode_check, {"tool_name": "TaskCreate", "tool_input": {}}, str(tmp_path)) == 2

def test_single_session_rejects(self, tmp_path: Path) -> None:
_make_mission(tmp_path, mode="single-session")
assert _run(cmd_mode_check, {"tool_name": "TaskCreate", "tool_input": {}}, str(tmp_path)) == 2

def test_agent_team_allows(self, tmp_path: Path) -> None:
_make_mission(tmp_path, mode="agent-team")
assert _run(cmd_mode_check, {"tool_name": "TaskCreate", "tool_input": {}}, str(tmp_path)) == 0


# ---------------------------------------------------------------------------
# Brief-validate
# ---------------------------------------------------------------------------
Expand Down
Loading