Port os-adr Python hooks (pre_tool_use.py, session_start.py) to Ruby #1524

Closed
opened 2026-11-03 14:14:50 +00:00 by jared · 2 comments
Owner

Problem

The journey tracer records in-process Ruby messages only. os-adr ships two Python hooks: hooks/pre_tool_use.py (53 lines, PreToolUse deny of direct Write/Edit to docs/adr) and hooks/session_start.py (139 lines, setup existence check, not registered in hooks.json). Both are entry points by the 2026-11-02 ruling and both are untraceable while Python. Same mechanism as #1522.

Reproduce

n/a: feature ticket; the gap is structural.

Approach

Port each hook to Ruby as a lib class under Adr with a thin hooks/*.rb wrapper, as #1522 did for os-backlog. Port the Python tests (tests/pre_tool_use_test.py, tests/hook_test.py) to Minitest and delete the Python files. Output must stay byte-identical for the same stdin. Register the wrappers in hooks.json where the Python file was registered.

Required work: none beyond the acceptance criteria.

Origin

  • Trigger: #1522 shipped; Jared asked 2026-11-03 to port the remaining os-adr and os Python hooks the same way
  • Improvised this session: none
  • Chain: hooks untraceable ← hooks are Python ← DESIGN (plugins/os-adr/hooks/pre_tool_use.py, plugins/os-adr/hooks/session_start.py predate the Ruby hook convention in os-aidd-lint, os-me, os-backlog)
  • Root candidate: none found; searched python, hook ruby port, .py, os-adr, session_start, pre_tool_use
  • Where: plugins/os-adr/hooks/pre_tool_use.py, plugins/os-adr/hooks/session_start.py
  • Session: 32008a4e-5b0f-4863-94d9-7afb84ba65b6
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/32008a4e-5b0f-4863-94d9-7afb84ba65b6.jsonl

VERDICT: CREATE

## Problem The journey tracer records in-process Ruby messages only. os-adr ships two Python hooks: `hooks/pre_tool_use.py` (53 lines, PreToolUse deny of direct Write/Edit to docs/adr) and `hooks/session_start.py` (139 lines, setup existence check, not registered in hooks.json). Both are entry points by the 2026-11-02 ruling and both are untraceable while Python. Same mechanism as #1522. ## Reproduce n/a: feature ticket; the gap is structural. ## Approach Port each hook to Ruby as a lib class under `Adr` with a thin `hooks/*.rb` wrapper, as #1522 did for os-backlog. Port the Python tests (`tests/pre_tool_use_test.py`, `tests/hook_test.py`) to Minitest and delete the Python files. Output must stay byte-identical for the same stdin. Register the wrappers in hooks.json where the Python file was registered. Required work: none beyond the acceptance criteria. ## Origin - Trigger: #1522 shipped; Jared asked 2026-11-03 to port the remaining os-adr and os Python hooks the same way - Improvised this session: none - Chain: hooks untraceable ← hooks are Python ← DESIGN (plugins/os-adr/hooks/pre_tool_use.py, plugins/os-adr/hooks/session_start.py predate the Ruby hook convention in os-aidd-lint, os-me, os-backlog) - Root candidate: none found; searched python, hook ruby port, .py, os-adr, session_start, pre_tool_use - Where: plugins/os-adr/hooks/pre_tool_use.py, plugins/os-adr/hooks/session_start.py - Session: 32008a4e-5b0f-4863-94d9-7afb84ba65b6 - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/32008a4e-5b0f-4863-94d9-7afb84ba65b6.jsonl VERDICT: CREATE
Author
Owner

Work started by hand (agent port, as #1522) in worktree ticket-os-adr-hooks.

Work started by hand (agent port, as #1522) in worktree ticket-os-adr-hooks.
Author
Owner

Resolution

Done: Ported both os-adr hooks to Ruby: Adr::PreToolUse (docs/adr write deny), Adr::SessionStart (setup check, still unregistered as before), Adr::ProjectState; thin hooks/*.rb wrappers; hooks.json runs ruby; Python hooks and Python tests deleted; every Python test case ported to Minitest with one use_case tag per hook.

Evidence: main 15b65e48. Parity: 16 stdin/fixture cases (10 pre_tool_use, 6 session_start); exit status, stderr and written files identical; stdout JSON parses equal, differs only in Python json.dumps separator spaces, which the hook consumer ignores. Suite: 165 runs, 409 assertions, 0 failures. Rubocop: 16 offenses, all in untouched files.

Follow-ups: none; symlinked docs/adr paths untested (File.realpath vs Path.resolve), dropped as no real project uses one

## Resolution **Done:** Ported both os-adr hooks to Ruby: Adr::PreToolUse (docs/adr write deny), Adr::SessionStart (setup check, still unregistered as before), Adr::ProjectState; thin hooks/*.rb wrappers; hooks.json runs ruby; Python hooks and Python tests deleted; every Python test case ported to Minitest with one use_case tag per hook. **Evidence:** main 15b65e48. Parity: 16 stdin/fixture cases (10 pre_tool_use, 6 session_start); exit status, stderr and written files identical; stdout JSON parses equal, differs only in Python json.dumps separator spaces, which the hook consumer ignores. Suite: 165 runs, 409 assertions, 0 failures. Rubocop: 16 offenses, all in untouched files. **Follow-ups:** none; symlinked docs/adr paths untested (File.realpath vs Path.resolve), dropped as no real project uses one
jared closed this issue 2026-11-03 14:20:38 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#1524
No description provided.