Skip to content

[Bug]: Retain earlier failure diagnostics across later conversation runs #1032

Description

@dennisonbertram

Work type

Bug / regression

Observed behavior

After #1029, an authoritative failed run restores its event-only error during reconciliation. When the same recurring-watcher conversation later receives a completed or cancelled terminal run, reconciliation reloads durable rows and restores errors only when the latest state is failed. The earlier failure diagnostic disappears.

Review evidence: PR #1029, P2 discussion discussion_r3682719105.

Expected behavior

Event-only diagnostics from every authoritative failed run retained in the replay window remain visible across later completed/cancelled runs. Latest run state reflects the latest authoritative terminal event independently of historical error-row retention.

Reproduction

On main 6e9ba9e9: replay run.failed(error=A), reconcile; replay a later run.completed, reconcile. Actual: error A disappears. Deterministic multi-run Swift conversation-stream test.

User and operational impact

P2: recurring deployment watchers lose the only explanation of an earlier failed check, weakening the full conversation record. Durable server messages do not contain the terminal event error.

Suspected seam and search evidence

Owners: RunSession.apply, Transcript.apply, Transcript.reconcile.
Searched runFailed|event-only|reconcile|messages\(conversation|run.completed in macOS sources/tests.
Hypothesis: error-row retention is incorrectly conditional on latest terminal state instead of being an independent authoritative-event history.

Blast-radius impact map

  • Data flow: multi-run conversation SSE -> event-only error history -> repeated durable reconciliation.
  • Config/API/schema/persistence: none.
  • Concurrency/lifecycle: ordered terminal replay and repeated idempotent hydration.
  • Security/privacy: no new access.
  • Clients: macOS only; TUI/API unaffected.
  • Provider/model/tools: none.
  • Deployment/observability: transcript diagnostics and engineering log.
  • Compatibility: same wire contracts.
  • Tests/docs: multi-run stream regression, plan/impact map/log.

Regression test first

Test: laterCompletedReplayPreservesEarlierFailureDetail.
Red command: swift test --package-path macapp --filter laterCompletedReplayPreservesEarlierFailureDetail.
Expected: earlier error absent after later completion.
Controls: latest state is completed; error appears once; repeated reconcile is idempotent; transport-only failure is not retained.

Fix boundaries

In scope: retain unique authoritative failure diagnostics independently from latest terminal state.
Out: server message schema, unbounded duplicate rows, transcript redesign, tool schemas.
Use existing RunSession/Transcript ownership; no parallel persistence.

Diagnostic and observability evidence

Red test proves disappearance; green proves one retained error after later completion and repeated reconciliation.

Verification plan

Focused red/green, adjacent suites, strict formatter, full Swift, full repository normal/race/coverage, shared native callback/cron acceptance after all UI repairs.

Rollout and rollback

Native patch, no migration. Revert if error rows duplicate or normal history loading regresses. No durable repair.

Documentation and handoff

Engineering log, issue plan/impact map/index, PR evidence.

Definition of done

  • Multi-run red reproduction observed
  • Earlier authoritative error remains once after later completion/cancellation
  • Latest run state remains correct
  • Transport-only errors are not retained
  • Targeted/full/race/coverage green
  • Shared native acceptance green

Parent: #1000
Discovered after: #1028 / PR #1029

Process acknowledgement

I will preserve the failing regression test and record newly discovered bugs separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions