Skip to content

Reconcile API streams from State#2027

Open
AlexCheema wants to merge 11 commits into
mainfrom
codex/api-stream-reconcile-state
Open

Reconcile API streams from State#2027
AlexCheema wants to merge 11 commits into
mainfrom
codex/api-stream-reconcile-state

Conversation

@AlexCheema
Copy link
Copy Markdown
Contributor

Why

The API was still closing active streams by reacting directly to InstanceDeleted. That violates the event-sourcing boundary: after snapshot bootstrap, the API may receive State that already reflects a deleted instance without replaying the deletion event.

How

  • Remove the API InstanceDeleted side-effect path.
  • Add a reconciliation loop that compares active stream queues against generation tasks in State.
  • Close queues for commands that were observed in State and are no longer live.
  • Preserve a guard for newly sent commands whose TaskCreated has not reached State yet, so the reconciler does not prematurely close fresh requests.
  • Update stream-cleanup tests around State reconciliation rather than event reaction.

Tests

  • uv run pytest src/exo/api/tests/test_instance_deleted_stream_cleanup.py
  • uv run pytest
  • uv run ruff check src/exo/api/main.py src/exo/api/tests/test_instance_deleted_stream_cleanup.py
  • uv run basedpyright
  • nix fmt

@Evanev7 Evanev7 force-pushed the codex/worker-custom-cards-state branch 2 times, most recently from d7c62aa to caa300d Compare May 7, 2026 07:14
Base automatically changed from codex/worker-custom-cards-state to codex/custom-model-cards-state May 7, 2026 07:14
@Evanev7 Evanev7 force-pushed the codex/custom-model-cards-state branch 7 times, most recently from 5592e65 to e119e57 Compare May 7, 2026 08:00
Base automatically changed from codex/custom-model-cards-state to main May 7, 2026 08:06
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