Skip to content

[BUG] TaskCompleted can precede restart-visible API history #1453

Description

@zoomote

Problem

The public TaskCompleted boundary does not explicitly guarantee that the task's API conversation history is visible to a fresh extension host. A consumer can observe completion, stop or restart the host, and then find no api_conversation_history.json to restore.

This is a candidate additional root cause under #1279. It is separate from the hydration, stale-writer, and resume/eviction hazards addressed by PR #1319.

Evidence

  • Mocked E2E run 33292570133 observed TaskCompleted, then immediately found no persisted API conversation history during the restart-persistence create phase.
  • The normal mocked E2E suite passed; only the separate restart-persistence phase failed.
  • The failure could not be reproduced in 120 local repetitions, so the exact concrete interleaving remains unproven.
  • Alloy model PR [Fix] Task history can disappear when users restart after completion #1452 demonstrates that the abstract current contract permits completion and host shutdown before history is restart-visible. A durability-gated contract removes the counterexample within the checked bounds without preventing successful completion.

Contract decision

Choose and document one production contract:

  1. TaskCompleted means the task is safe to close or restart, so required UI/API history writes must be restart-visible before the event is emitted; or
  2. TaskCompleted means only that completion was accepted, and production exposes a separate persistence-ready acknowledgment for restart-sensitive consumers.

Polling only in the E2E test is not sufficient unless the production event contract explicitly excludes persistence readiness.

Acceptance criteria

  • Add a deterministic regression that controls the completion-versus-persistence ordering.
  • Define the public completion and persistence-ready semantics in code and tests.
  • Ensure a host stopped after the relevant readiness boundary can restore API conversation history.
  • Define behavior for failed or indefinitely delayed history writes.
  • Preserve successful completion when persistence succeeds.
  • Verify the create and fresh-host restart phases end to end.

Non-goals

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions