Skip to content

Session post-mortem subsystem + autonomous decision capture (A003)#2

Open
pskeshu wants to merge 2 commits into
feature/temperature-operations-allfrom
feature/session-postmortem
Open

Session post-mortem subsystem + autonomous decision capture (A003)#2
pskeshu wants to merge 2 commits into
feature/temperature-operations-allfrom
feature/session-postmortem

Conversation

@pskeshu

@pskeshu pskeshu commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Why

The first autonomous run (session 6a4a3d9b) was analyzed by hand and surfaced a stack of harness issues — 3 live embryos falsely terminated, a dead vision tool, and an empty decisions.jsonl that forced the whole analysis to be reverse-engineered from conversation.json. This PR turns that one-off into a repeatable capability and fixes the highest-leverage gap it exposed.

What

1. feat(postmortem) — Claude Code session post-mortem scaffold

Packages the forensic analysis into a repeatable, Claude-Code-authored, stored capability. Gently owns only the inputs/schema/storage/trigger; the intelligence lives in Claude Code.

  • .claude/skills/session-postmortem/ — the analyst skill + report schema (v1)
  • .claude/workflows/session-postmortem.js — fan-out → adversarial-verify → synthesize, parameterized by session
  • docs/POSTMORTEM_DESIGN.md — architecture, storage layout, the dev/agent-facing feedback loop (recurrence-tracked rollup + regression evals), and the phased build plan

No harness runtime code changes in this commit.

2. fix(observability) — capture autonomous wake turns in decisions.jsonl (A003)

Autonomous (event-driven) turns wrote no Decision row — only the non-streaming call_claude path recorded one, hardcoded to trigger=USER_MESSAGE. So a fully autonomous run left decisions.jsonl empty.

  • run_wake_turn now aggregates the turn's tool calls and writes one Decision(trigger=EVENT, trigger_detail=<wake reason>) per wake.
  • _write_production_decision gains optional trigger/trigger_detail params; defaults preserve the USER_MESSAGE behaviour, so chat turns are unchanged.
  • Capture is best-effort and never breaks a turn.

Scope: autonomous path only; user turns on the web streaming path remain a separate (smaller) capture gap.

Verification

  • tests/test_wake_decision_capture.py (new, 4 cases) — EVENT trigger + wake reason + tool calls captured; default path still tags USER_MESSAGE; safe no-op when no decision log is attached.
  • tests/test_eval.py (existing, 27) still pass — no regression.
  • ⚠️ A full live wake turn through a running agent was not exercised here (needs the rig + API). Smoke-check on the instrument before relying on it.

Notes

  • Based off feature/temperature-operations-all (not main), so the PR targets that branch.
  • The first stored report (sessions/…_6a4a3d9b/postmortem/report.{yaml,md}) lives under D:\Gently3\ (runtime data) and is intentionally not in the repo.
  • The report's item A005 (tool-arg coercion) is already fixed on the base branch by d846dcda.

Follow-ups (deferred; tracked in the report + design doc)

  • Evidence-pack builder + put_postmortem storage
  • _finalize_perception_run trigger + orphaned-run reconciler (A006)
  • A004 (restore analyze_volume), A001/A002 (drift-aware termination + refocus write-back)

🤖 Generated with Claude Code

pskeshu and others added 2 commits July 9, 2026 01:37
Packages the forensic session analysis (first run by hand for session 6a4a3d9b) into a repeatable, stored capability authored by Claude Code: the session-postmortem skill + report schema (v1); a fan-out -> adversarial-verify -> synthesize workflow parameterized by session; and docs/POSTMORTEM_DESIGN.md covering the architecture, storage layout, the dev/agent-facing feedback loop (recurrence-tracked rollup + regression evals), and the phased build plan.

Gently owns only the inputs/schema/storage/trigger; the intelligence lives in Claude Code. No harness runtime code changes in this commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Autonomous (event-driven) turns wrote no Decision row: only the non-streaming call_claude path recorded one, hardcoded to trigger=USER_MESSAGE. A fully autonomous run therefore left decisions.jsonl empty (session 6a4a3d9b), forcing post-mortems to reconstruct reasoning from conversation.json.

run_wake_turn now aggregates the turn's tool calls and writes one Decision(trigger=EVENT, trigger_detail=<wake reason>) per wake. _write_production_decision gains optional trigger/trigger_detail params (defaults preserve the USER_MESSAGE behaviour, so chat turns are unchanged). Capture is best-effort and never breaks a turn.

Scoped to the autonomous path; user turns on the web streaming path remain a separate capture gap. Verified: new tests/test_wake_decision_capture.py (4 cases) + existing tests/test_eval.py (27) pass. Full live wake-turn not exercised here.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant