Port os-adr Python hooks (pre_tool_use.py, session_start.py) to Ruby #1524
Labels
No labels
P0
P1
P2
P3
bug
category/code-change
category/cross-repo
category/eval-run
category/investigation
category/no-test-target
category/owner-ruling
category/prose-artifact
category/recurring-chore
category/structure
category/umbrella
crc-refactor
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
rule-proposal
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#1524
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
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) andhooks/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
Adrwith a thinhooks/*.rbwrapper, 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
VERDICT: CREATE
Work started by hand (agent port, as #1522) in worktree ticket-os-adr-hooks.
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