- Add backup before overwriting hook in installer (consistent with
existing backup pattern for agents/skills/commands)
- Add TTL-based eviction for pendingValidations Map (prevents memory
leak if tool.execute.after never fires on timeout/crash)
- Fix tilde fallback: skip HOME-based candidate path when HOME is
undefined instead of using literal '~' that Node can't resolve
- Document non-atomic race window in restore-and-validate flow
Requested-by: @jeff-music-city
OpenCode integration for the gate progression validator using
tool.execute.before/after hooks with detect-and-revert strategy.
Since OpenCode SDK lacks hard block (deny) support in tool hooks,
this uses a two-phase approach:
1. tool.execute.before: saves backup of current-cycle.json
2. tool.execute.after: runs the same shell validator used by Claude
Code. If invalid → reverts file to previous state + replaces tool
output with block message showing which gates need completion.
Tested in live OpenCode session: agent attempted to write
current-cycle.json with gate 8 while testing gates were pending.
Hook detected, reverted, and injected error message. Agent saw
'⛔ GATE PROGRESSION BLOCKED' instead of 'Wrote file successfully'.
Also updates installer.sh to copy validate-gate-progression.sh
to ~/.config/opencode/hooks/ during ring install.
Requested-by: @jeff-music-city