You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs(v2): adopt v2 rearchitecture plan from 3-repo deep-dive review
Adopt all 12 features synthesized from full-source reviews of
oh-my-claudecode (yeachan-heo), ruflo (ruvnet), and ralph (snarktank),
organized into five layer-based workstreams across six gated phases.
- plans/zo-v2-rearchitecture.md: 20-check tiered oracle, anti-scope,
reference repo links (+ .gitignore exception)
- docs/reference/v2-rearchitecture.mdx: full feature table w/ provenance
- docs/roadmap.mdx: v2 section (4 pillars + repo credits)
- website: new §11 'What's next' crediting the three source repos
- memory: STATE session 040, DECISION_LOG v2 decision, research corpus
at memory/zo-platform/research/2026-08-12-repo-reviews/
Website change verified via HTML balance check + static-server DOM
inspection; Astro build deferred to CI (no Node.js on this machine).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(enforcement): v2 Phase 1 — WS-A enforcement plane (contracts, drift guard, memory hooks, sealed paths, nonce gates)
Implements all five WS-A features from plans/zo-v2-rearchitecture.md:
- contracts.json emitted at decompose (src/zo/contracts.py) with concrete
deliverable paths; SubagentStop hook blocks agents stopping with unmet
deliverables (missing/undersized/pattern/empty-dir checks)
- workflow-drift-guard Stop hook: completion claim in last message + added
TODO/FIXME/NotImplementedError diff lines -> block (ZO_DRIFT_GUARD=0 opt-out)
- PreCompact/SessionEnd/PostToolUseFailure hooks mechanize the memory
protocol (STATE flush, summary backfill, structured failure JSONL feed)
- sealed-paths PreToolUse guard: memory-root control files + user prefixes
denied; per-agent off-limits write scopes enforced from contracts.json
- nonce-verified gates end to end: minted at GATED, required by
apply_human_decision (PermissionError otherwise, single-use), new
'zo gates approve/reject --nonce' CLI, /approve+/reject slash commands
rewritten to route through it (forgeable hand-edit path closed)
One shim (.claude/hooks/zo-hookkit.sh -> python3 -m zo.hookkit) routes all
six hook events; every handler fail-open. Plan check 6 amended to
path-scoped verifier enforcement (no disallowedTools frontmatter exists;
rationale in DECISION_LOG).
Tests: 854 -> 904 passed / 7 skipped (+50, incl. the repo's first
hook-script tests: subprocess + stdin JSON). ruff src/ clean.
validate-docs green. Seeded-failure tests cover plan oracle checks 1-5, 7.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(enforcement): hook-trace observability + live-session verification evidence
- zo.hookkit: one JSONL trace line per hook invocation (event, stdin keys,
agent identity, emitted-output flag) to logs/hook-trace-{date}.jsonl;
ZO_HOOK_TRACE=0 disables. This is how the enforcement plane's firing is
observable in live sessions (handlers are silent unless they block).
- drift-guard: prefer the live Stop payload's last_assistant_message
(verified present in the 2026-08-12 live trace); transcript parse kept
as fallback.
- Live verification evidence (DECISION_LOG 15:30 entry): sealed-paths
DENIED a real Write to gate_mode in a live session; drift-guard fired
correctly-silent on a real Stop; subagent-stop fired with agent_type +
agent_id in the live payload — resolves the Phase-1 agent-identity
question (per-agent contract enforcement keys correctly).
- PR-046 prior: this Desktop-managed Mac has no claude CLI/uv/npm; hook
shims must run on bare python3 (venv fallback is load-bearing).
Tests: 904 -> 908 passed / 7 skipped. ruff src/ clean. validate-docs green.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Sam Tukra <sam101fe4x@Sams-MBP.Home>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/COMMANDS.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,6 +158,26 @@ zo gates set MODE --project NAME
158
158
159
159
`MODE` is one of: `supervised` (human approves every gate), `auto` (orchestrator approves unless ambiguous), `full-auto` (all gates auto-approved).
160
160
161
+
### zo gates approve / reject
162
+
163
+
Record a nonce-verified human decision on the pending blocking gate (v2
164
+
WS-A5). When a phase reaches its blocking gate, ZO mints a single-use
165
+
approval nonce and shows it in the gate review banner. Decisions are only
166
+
valid through these commands — hand-edited approvals cannot pass the nonce
167
+
check, which is what makes gate passage unforgeable by agents.
168
+
169
+
```
170
+
zo gates approve PHASE --project NAME --nonce NONCE [--notes TEXT]
171
+
zo gates reject PHASE --project NAME --nonce NONCE --reason TEXT
172
+
```
173
+
174
+
Both validate the nonce, append the decision to `DECISION_LOG.md`, log a
175
+
comms gate event, and record the decision for the orchestrator (applied
176
+
live at the next gate poll, or on `zo continue` for a fresh session).
177
+
`reject` returns the phase to ACTIVE for rework with your `--reason`
178
+
driving the next iteration. The nonce is cleared on use — replaying an
179
+
old approval can never pass a later gate.
180
+
161
181
### zo watch-training
162
182
163
183
Live training metrics dashboard. Tails `logs/training/metrics.jsonl` in the delivery repo and renders a persistent Rich panel with epoch progress, loss/metrics table, checkpoint log, and loss sparkline. Auto-launched by `zo build` during Phase 4 via tmux split-pane.
Copy file name to clipboardExpand all lines: docs/reference/v2-rearchitecture.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ architecture — features from different repos interlock into single mechanisms.
46
46
| 1 |**Machine-checked deliverable contracts** — every agent's produced/consumed contract compiles to JSON (required files, sections, patterns) verified mechanically when the agent stops, plus a zero-cost "completion claim vs. TODO-stub diff" drift guard | oh-my-claudecode | P0 |
47
47
| 3 |**Hook-enforced memory protocol** — STATE.md flushes before compaction, session summaries verified at session end, structured failure records captured automatically; the model can't forget because the model isn't asked | oh-my-claudecode | P0 |
48
48
| 7 |**Anti-forgery gate approvals** — approvals only valid as structured tags carrying a per-verification nonce, so no agent can forge gate passage by echoing text | oh-my-claudecode | P1 |
49
-
| 9 |**Structurally trustworthy verifiers** — the oracle and reviewers mechanically cannot edit code (tool-level enforcement), evaluators emit a strict JSON contract, and evaluation files are sealed against modification by the loop they evaluate | oh-my-claudecode | P1 |
49
+
| 9 |**Structurally trustworthy verifiers** — verifier writes are mechanically confined to their contract scope (a PreToolUse guard denies writes into off-limits paths), evaluators emit a strict JSON contract, and oracle/control files are sealed against modification by the loop they evaluate | oh-my-claudecode | P1 |
Copy file name to clipboardExpand all lines: memory/zo-platform/DECISION_LOG.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1239,3 +1239,29 @@ The `--no-headlines` flag is preserved (not removed) for backwards compatibility
1239
1239
**Alternatives considered:** (1) Source-repo workstreams ("ralph track", "ruflo track") — rejected, provenance is not architecture; (2) P0-only scope — rejected by Sam, all 12 wanted; (3) waiting for the SDK refactor before substrate work — rejected, the fresh-context loop is the cheapest on-ramp to that refactor, not a competitor.
1240
1240
1241
1241
**Outcome:** Shipped: plan (+ gitignore exception), docs reference page + mint.json nav, roadmap v2 section, website §11 + drawer nav + §12 renumber, STATE/session-040/research-README memory updates. Verification honest note: **no Node.js available on this machine**, so the Astro build was NOT run locally — the website edit was verified via HTML tag-balance parsing and DOM inspection through a static file server (section renders, all 4 external links present, drawer link + renumbering correct); the deploy pipeline's build is the binding check. validate-docs run pre-commit per protocol.
**Decision:** Implemented all five WS-A features from plans/zo-v2-rearchitecture.md as a deterministic hook plane beneath the prompt plane: (1) machine-readable `contracts.json` emitted at decompose with concrete deliverable paths, validated by a SubagentStop hook that blocks agents stopping with unmet deliverables; (2) a zero-LLM workflow-drift-guard Stop hook (completion claim + added stub markers → block); (3) PreCompact/SessionEnd/PostToolUseFailure memory hooks mechanizing the "AUTOMATIC" memory protocol; (4) a sealed-paths PreToolUse guard denying writes to oracle/control state and enforcing per-agent off-limits scopes from contracts.json; (5) nonce-verified gate approvals end to end — minted at GATED, required by `apply_human_decision`, `zo gates approve/reject --nonce` CLI, slash commands rewritten to route through it. One bash shim (`zo-hookkit.sh`) routes all six hook events to `python3 -m zo.hookkit` so file mutation reuses MemoryManager's atomic/flock code paths.
1248
+
1249
+
**Rationale:** Direct implementation of the review's loudest theme ("enforcement plane below the prompt plane") and ZO's own PR-035 prior (aspirational contracts get ignored). Every mechanism ships wired (settings.json entries asserted by test) with a seeded-failure test proving it catches a planted violation — the "nothing ships unwired" rule from the plan's anti-scope.
1250
+
1251
+
**Plan amendment (check 6):** The plan called for "disallowedTools + PreToolUse" on verifiers. Recon showed (a) Claude Code has no disallowedTools frontmatter for subagents (tools: is an allowlist), and (b) verifiers require scoped write access (oracle-qa owns oracle/reports/, code-reviewer owns reviews/) — total Write removal would break their contracts. Amended check 6 to path-scoped enforcement: off-limits writes denied via contracts.json, keyed on agent identity in hook input, fail-open when absent. Honest limitation recorded: production identity presence depends on Claude Code's hook payload; verified in tests via seeded identity, to be confirmed live in Phase 6 e2e.
1252
+
1253
+
**Alternatives considered:** (1) tools: allowlist frontmatter on verifiers — rejected, cosmetic without Bash coverage and breaks legitimate writes; (2) six separate bash hook scripts — rejected for one parameterized shim (DRY, one venv-resolution path); (3) hard-blocking every stop while work remains (OMC's stop-engine) — explicitly rejected by the plan's anti-scope (fresh spawns + caps are the foundation; these hooks only catch violations).
1254
+
1255
+
**Outcome:** 854 → 904 passed / 7 skipped (+50: 19 contracts, 19 hookkit, 9 nonce, 8 shim integration — first tests ever to execute a .claude/hooks script), ruff src/ clean, validate-docs green. 4 pre-existing integration tests updated to supply the nonce (designed behaviour change). Cascade: docs/COMMANDS.md (+gates approve/reject), specs/memory.md recovery section rewritten to implemented reality, plan check 6 + docs feature #9 amended. Branch `claude/v2-phase1-enforcement` stacked on `claude/v2-rearchitecture-plan`.
1256
+
1257
+
## Decision: 2026-08-12T15:30:00Z
1258
+
**Type:** VERIFICATION
1259
+
**Title:** Live pre-PR verification of the WS-A enforcement plane (in-session, bypass-equivalent)
1260
+
1261
+
**Decision:** Verified the Phase 1 hooks firing in a REAL Claude Code session before merging PR #107, per Sam's direction. Method: added always-on hook-trace observability (one JSONL line per invocation to `logs/hook-trace-{date}.jsonl`: event, stdin keys, agent identity, whether output was emitted; `ZO_HOOK_TRACE=0` disables), then used the current live session itself as the test vehicle — the runtime picked up the new settings.json wiring mid-session.
1262
+
1263
+
**Evidence (from logs/hook-trace-2026-08-12.jsonl):** (1) `drift-guard` fired on a real Stop event, correctly silent — and the live payload carries `last_assistant_message` directly (drift-guard now prefers it; transcript parse kept as fallback). (2) `sealed-paths` fired on a real Write to `memory/zo-platform/gate_mode` and DENIED it — the lead agent of a live session was mechanically blocked from touching gate control state. (3) `subagent-stop` fired when a probe subagent stopped, and the live payload carries `agent_type` + `agent_id` + `agent_transcript_path` — RESOLVING the Phase-1 open question: per-agent contract enforcement will key correctly in live team sessions; the fail-open path is the exception, not the norm.
1264
+
1265
+
**Honest caveats:** PostToolUseFailure did not fire for nonzero-exit Bash commands in this session — its semantics appear limited to tool-infrastructure errors, so the failure feed will capture fewer events than designed; if nonzero-exit capture matters, add PostToolUse-with-error-inspection in WS-D. PreCompact/SessionEnd not yet observed live (no compaction occurred; SessionEnd fires at session close) — same wiring pattern as the three proven events. A full `zo build` demo run remains desirable on a machine with the claude CLI (this Desktop-managed Mac has none — see PR-046).
1266
+
1267
+
**Outcome:** 904 → 908 tests (3 trace + 1 live-payload drift-guard), ruff clean. Fail-open verified end to end in production conditions. Evidence committed to PR #107.
0 commit comments