Skip to content

fix(server): cancellation can leave committed child events unpublished #475

Closed

Description

@lastobelus

A provider or child task can commit its terminal event and then be cancelled before subscribers receive it. The database records completion, but a parent task or connected client can continue to show running work.

Source confirmation: at LastCode c909106a31be7aa452a31fce86bd32d47716fadb, apps/server/src/orchestration-v2/EventSink.ts:276 uses Effect.suspend around sql.withTransaction(...).pipe(Effect.tap(publish)). Only acquiring the publication lane is uninterruptible; publication after commit is still interruptible. Upstream fixes this exact boundary in 30fd973de3eda7e40ea3617baf93bc3f8ac324a9 (upstream change). That fix is absent from this LastCode baseline.

Deterministic reproduction for a repair PR:

  1. Subscribe to committed/live events and arrange a barrier immediately after the transaction commits, before publication.
  2. Write a terminal child-run event, reach the barrier, then interrupt the writer.
  3. Read the persisted event and wait for the subscriber notification. The persisted event exists, while publication can be lost.

Expected: once a transaction commits, all subscribers receive its events in commit order before writer cancellation completes. Cancellation before commit must still roll back.

Adapt the upstream uninterruptible commit/publication boundary while preserving LastCode run-outcome recording and ownership guards. Add the upstream-style barrier test to FoundationPersistence.test.ts and retain delegated completion/restart coverage in DelegatedCompletionDelivery.test.ts.

This issue is confirmed by source and upstream regression/fix evidence. No tests or installed-app reproduction were executed during this research pass. The installed version label was supplied by the user and was not independently validated.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions