feat(cockpit): Phase 2 live per-worker progress events - #58
Merged
Conversation
Add log-event.sh, a tiny best-effort observability helper the orchestrator/ implementer/reviewer agents call at each phase transition. It appends one JSONL event (ts, role, model, task, phase, lens, detail) to .claude/state/events.jsonl (gitignored, CLAUDE_EVENTS_FILE-overridable), built with node for safe escaping, and rotates to the last EVENTS_MAX_LINES (default 2000) lines via temp-file + atomic move. Extend cockpit.sh with a "Live worker progress" panel that reads the event log (or <fixtures>/events.jsonl in --fixtures mode), tolerates malformed lines, and dedups to each worker's LATEST phase keyed by (role, task). Degrades to a muted "no active workers" placeholder and never breaks the script's exit-0 contract, consistent with Phase 1. Wire the three agent prompts (orchestrator/implementer/reviewer) to log their phase transitions, explicitly noting this is additive-only observability that must never affect gate enforcement or review consensus. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TdLbxgUQhEVr6XtFGzBpsY
…t.sh Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TdLbxgUQhEVr6XtFGzBpsY
…rd array lines - cockpit.sh readEvents(): tighten the object guard to exclude JSON arrays (typeof [] === "object" too), which previously produced a phantom worker row on a stray array line. - cockpit.test.sh: fold a malformed JSON line, a blank line, a JSON-array line, and an XSS-payload worker (script tag + quote in role) into the events fixture. Assert the render still exits 0, a known-good worker row still renders, the live table has exactly the legitimate worker count (no phantom rows from the array line), and the live section escapes fields (raw <script> absent, escaped form present) — mirroring the existing issue-title escaping check. - log-event.test.sh: add a rotation boundary assertion — writing exactly N events with EVENTS_MAX_LINES=N leaves exactly N lines, no rotation at the boundary. Addresses reviewer feedback (tests lens rejection; correctness lens low-severity finding) on issue #52.
robercano
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cockpit Phase 2 (issue #52): live per-worker progress on top of the Phase 1 dashboard (#51). Observability only — no change to gate enforcement or review consensus, purely additive.
What's new
.claude/scripts/log-event.sh(new) — best-effort helper agents call at each phase transition. Appends one JSON line to.claude/state/events.jsonl(gitignored, runtime-only). Schema:ts(ISO-8601 UTC),role,model,task,phase,lens,detail. JSON is node-built (safe escaping). HonorsCLAUDE_EVENTS_FILEoverride. Rotation: caps the log to the last${EVENTS_MAX_LINES:-2000}lines via temp-file + atomic rename, so unattended multi-day runs stay bounded. Always exits 0 — it can never break the loop..claude/scripts/cockpit.sh— new "Live worker progress" section: reads the JSONL (default path,--fixtures <dir>/events.jsonloffline seam,CLAUDE_EVENTS_FILEoverride), dedups to the latest event per (role, task), renders role/task/model/phase/lens/updated. Tolerates blank/malformed/array lines (skipped, never crashes), shows "no active workers" when empty/missing, and still exits 0 on every degraded path — same contract as Phase 1. Re-read-on-refresh only: no daemon, notail -f, no persistent server..claude/agents/{orchestrator,implementer,reviewer}.md— each gains a short "Progress events" instruction to calllog-event.shat its phase transitions (scoped / implementing / gate-running / reviewing / done), explicitly best-effort and non-gating.Tests
.claude/scripts/log-event.test.sh(new) — 11 checks: JSONL validity, field round-trip, quote/backslash/</script>escaping, empty-optional defaults, rotation keeps exactly the last N (and the most recent), boundary at exactly N, best-effort exit 0 on odd/dangling args..claude/scripts/cockpit.test.sh— 36 checks (existing + new): live section present, dedup-to-latest, second worker in a different phase, malformed/blank/array-line tolerance still exits 0 with the good row surviving, array line yields no phantom row (exact row count), and live-section field HTML-escaping (stored-XSS guard).Gates (self-adapter)
GATES_FILE=.claude/self/gates.json bash .claude/scripts/gate.sh build|lint|test— all passbash .claude/scripts/cockpit.test.sh— 36/36bash .claude/scripts/log-event.test.sh— 11/11Review
Reviewed under the self-adapter lenses
correctness+tests(consensus: all). Both approve; the tests lens verified every new assertion has teeth via targeted code mutations.closes #52
🤖 Generated with Claude Code