Skip to content

Deepen Session log recording and Model evidence ownership #630

Closed

Description

@JacobStephens2

What to build

Keep each Session log's Model evidence under one owned recording module, so a Run notification names the Models its sessions reported even when execution fails or is interrupted, and child Runs remain attributed to their owning Command. Preserve current notification text and Harness interpretation behavior while removing the Session log caller's responsibility to coordinate provisional and completed evidence writes.

This is one standalone Ticket: recording, child inheritance, notification collection, documentation and verification fit one fresh context window and land together.

Acceptance criteria

  • One Session log recording module owns transcript consumption and the provisional/completed Model evidence handoff. Session execution no longer calls a separate metadata writer twice or extracts observation vectors for persistence. Invocation selection, session Purpose, Resume policy and review-report retention remain with their existing modules.
  • The recording instance captures owning Command identity and start stamp once and uses that same identity for both evidence writes. A local Command log takes precedence over inherited ownership. Child and nested child Runs retain the exact owning Command path through the existing inheritance mechanism; absent ownership is removed from the child environment and never attributed to another Command.
  • Reader completion preserves stream evidence before the process owner can discard recovered interpretation on interruption, including a reader that returns an error. Completed interpretation replaces it only when a completion report exists; a present report with no observed Models is authoritative, while an absent report leaves the stream checkpoint intact. Startup failure and consumer panic preserve their existing behavior; no new destructor writes or retained-record reads are introduced.
  • The existing metadata format, record filenames, exact-owner filtering, stamp filtering, lexical session order, observed-Model deduplication, requested/default fallback and Effort wording remain compatible. A corrupt record warns and does not suppress valid records. Collection and persistence failures remain warnings and never change the Session outcome or prevent sending the Run notification.
  • Child Run launch and notification rendering use the same recording module's inheritance and collection capabilities. Notification rendering owns the section layout; recording owns record discovery, selection, fallback lines and read/write warning policy. Delete the displaced metadata module and handoff code rather than retaining forwarding modules.
  • Tests through the recording interface verify stream survival on execution/read failure and interruption, authoritative retained Models (including an empty authoritative set), absence of a completion report, immutable ownership across both writes, nested inheritance, wrong-owner exclusion, corruption tolerance and fallback wording. Add coverage that retained Muse/OpenCode Model evidence reaches a notification, using local stand-ins rather than installed Harnesses.
  • Preserve the existing end-to-end notification and Session execution regressions. Run the focused recording tests, Run notification tests, Session execution tests, and affected Muse/OpenCode interpretation or session tests; complete the repository's normal formatting, lint and test checks for the implementation.
  • Update the existing Session log and Run notification descriptions in CONTEXT.md to state that Model evidence is kept beside each Session log, belongs to the exact owning Command across child Runs, survives an interrupted stream, and is replaced by completed retained evidence only when a report is available. Keep requested Model/Effort choices distinct from observed Models. No new domain term or ADR is required.

Blocked by

None (can start immediately).

Decisions

The design tree is: recording responsibility → compatibility and module placement → ownership, evidence handoff, and presentation → test seam and documentation. The following rounds exhaust its frontier; there is no pending human decision.

Round 1 — responsibility and constraints

  1. Deepen Session log recording, using the existing domain term, with local-substitutable dependencies. Keep Harness Model discovery and retained-record interpretation in the Harness module, and process spawning, cleanup, interruption and worker joining in the existing process module. Reason: the friction is evidence ownership and handoff; neither dependency needs a new interpretation or supervision implementation.
  2. Put the runner and Model evidence implementation together in the Session log recording module. Absorb the existing private Session execution runner and stream-following logic rather than adding a forwarding module. Reason: transcript consumption and evidence checkpoint ordering are one lifecycle; moving only serialization would leave the shallow interface and ordering knowledge in its caller.
  3. Preserve the persisted format and observable output. Reason: historical records, existing tests and the Run notification already define usable contracts; this Ticket deepens their implementation without introducing a migration or new user configuration.

Round 2 — branches enabled by Round 1

  1. Use an owned recording instance with three capabilities: run one recorded session using its existing launch facts and Interpretation, apply owning Command inheritance to a child command, and collect notification lines. Capture immutable owner and stamp facts when constructing the instance, after Command logging has been established; production resolves those facts from current logging/inherited state, while tests supply fixture facts. Never lazily cache ownership before logging starts. Reason: one captured identity spans the worker and final completion without forcing callers to understand the record format or carry metadata snapshots.
  2. Choose the runner-shaped design. Reject a cloneable recorder accepting stream/completion events because callers would still coordinate both stages and synchronization. Reject an Interpretation decorator that records in destruction because it introduces implicit filesystem effects and could record a session that never started. Reason: the runner hides the substantive ordering rules while preserving startup and process-owner behavior.
  3. Inside the runner, keep the reader's observed Models after transcript consumption returns, including an error return, and before the reader returns to process supervision. After recovered state is available, invoke the existing Interpretation completion and replace the checkpoint only for a present report. A present report is authoritative even when its Models are empty; an absent report cannot erase the checkpoint. Reason: interrupted execution deliberately suppresses recovered state and retained reads, whereas Muse/OpenCode completed evidence has its own authority. Preserve that distinction instead of interpreting an absent report as an empty report.
  4. Keep evidence writes explicit, best effort and separate from the Session result. The existing process owner still joins workers before returning; recording does not clear interruption, attempt retained reads after interruption, create a second process owner, or add a generic filesystem port. Reason: attribution must survive failure without changing execution semantics or introducing a hypothetical seam.
  5. Centralize child ownership inheritance and notification record selection in this module. Use local Command identity before inherited identity, propagate the exact path through nested children, and remove stale inherited ownership when none is available. Collection freezes owner/stamp, filters by the existing stamp candidate rule and exact record owner, sorts paths, skips individual corrupt records with warnings, and preserves display fallbacks. Handle directory-level failures inside collection with the existing warning and an empty section. Reason: matching timestamps alone cannot establish Command ownership, and attribution failures must not abort notification delivery.

Round 3 — verification and domain consequences

  1. The recording interface is the test surface. Use the real filesystem in temporary directories and existing local CLI stand-ins as adapters; supply captured identity as fixture facts, without mutating process globals. Exercise the runner with real Interpretation and assert persisted/collected evidence and returned outcomes. Retain process-level integration tests for interruption and child ownership. Reason: a serialization-only test cannot verify the handoff where current changes concentrate.
  2. Add retained Muse/OpenCode attribution coverage and a missing-report checkpoint regression. Existing tests establish retained reply/usage authority, but do not directly prove that those retained Models reach a notification. Reason: both live evidence and retained evidence cross this seam, and an empty authoritative report must remain distinguishable from no report. Replace any redundant low-level serialization tests instead of duplicating them.
  3. Record the clarified ownership and evidence semantics in the existing domain entries as this Ticket's work. Do not add an ADR: placement and interface choices are reversible and preserve the current domain contracts. Reason: future readers need the invariants without inventing a new domain concept or re-litigating an established decision.

Baseline verification at main 04c807760edd5e0b743f7335c433d2f8123393af: all 28 Run notification tests and all 9 Session execution tests passed. The review changed no tracked files. These results establish the current contracts; the implementation must add and run the new recording-interface coverage above.

Architecture review

Strength: Strong · Dependencies: local-substitutable

Files: src/session.rs:360, src/session/models.rs:25, src/child_run.rs:390, src/notification.rs:153, src/harness/interpretation.rs:203, tests/run_notification.rs, src/session/execution_tests.rs, tests/muse_sessions.rs, tests/opencode_sessions.rs, CONTEXT.md

Before

flowchart LR
  Sessions[Harness sessions] --> Transcript[Session log]
  Transcript -. checkpoint then replace .-> Evidence[Model evidence]
  Child[Child Run] --> Evidence
  Notification[Run notification] --> Evidence
  classDef leak stroke:#dc2626,stroke-width:2px;
  class Transcript,Evidence leak
Loading

After

flowchart LR
  Sessions[Harness sessions] --> Recording
  Child[Child Run] --> Recording
  Notification[Run notification] --> Recording
  subgraph Recording[Session log recording module]
    Transcript[Session log] --> Evidence[Model evidence]
  end
  classDef deep stroke-width:3px;
  class Recording deep
Loading

Problem: the shallow Model evidence interface makes the Session log caller coordinate provisional and completed writes while ownership, child inheritance and notification failures spread across the seam.

Solution: deepen Session log recording so one owned implementation absorbs evidence handoff, ownership and collection behind three capabilities, with filesystem adapters confined to its test seam.

Wins

  • Depth: one lifecycle, three callers
  • Locality: ownership and handoff concentrate
  • Leverage: every Session log benefits
  • Tests cross the recording interface

Deletion test: deleting the deep module would redistribute checkpoint ordering, owner capture, child inheritance, selection and best-effort failures across its callers.

Coverage: no open issue proposes this deepening; notification-content issues #219/#313 and recovery-reporting issues #586/#588 cover different behavior. ADRs 0005 and 0011 remain satisfied.

Activity

  1. added
    needs-triage
    ready-for-agent
    architect-plan
    in-progress
    and removed
    needs-triage
    ready-for-agent
    on Oct 10, 2026
  2. removed
    in-progress
    on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architect-plan

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions