Skip to content

Join preparation cleanup before intake close completes - #47

Merged
asher-aqi merged 6 commits into
mainfrom
fix/intake-preparation-cleanup
Nov 14, 2026
Merged

asher-aqi merged 6 commits into
mainfrom
fix/intake-preparation-cleanup

Conversation

@asher-aqi

@asher-aqi asher-aqi commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

A withdrawn intake receipt can reject before its preparation callback finishes cancellation cleanup. Keep that callback owned so close and engine shutdown wait for it, including work withdrawn before close began.

withdraw -> reject receipt and release logical input slot
callback cleanup -> settle owned awaitable
close -> join all started preparation and immediate effects -> return

Python shutdown now survives repeated runner cancellation. Both ports reject stop from the engine's own intake callback context, preventing shutdown from waiting on itself. Late values remain discarded. No reducer revision, stored schema or window policy changes.

Stacked on #46 (feat/accumulating-continuation). Retarget to main after its parent lands; do not merge into the feature branch.

Original implementation evidence

  • Before: close/stop completed while cooperative preparation cleanup was blocked. Repeated Python cancellation could publish completion early; a TypeScript preparation awaiting stop deadlocked.
    After: failing controls committed first now pass. Tests retain prompt receipt/capacity behavior, late-result refusal, shared waiter cancellation and synchronous/eager callback creation. Stop refusal is tested in preparation, context, judge and sink.
  • One final local run: 1607 TypeScript passes, two existing Redis conformance skips; 433 Python passes, zero skips, including real Redis/Postgres interoperability. Oracle 128 and benchmark contracts 77 pass. Types, lint/format, builds/wheel and docs pass (four existing optional-package snippets skipped).
  • Independent review findings are resolved; the original native probes were rerun after the fixes.

Integration check

The branch includes main's folded-event exports at 42eda91. The changes introduced by this layer are unchanged after removing diff line numbers and blob hashes. The combined stack has the same tree as the previously tested composition. All eight distinct CI jobs passed on this updated head. Duplicate runs also passed. The optional Macroscope review check was skipped.

Merge Danger

Door: two-way

No persisted format changes. Close can now wait longer for callback cleanup. A callback that never settles can keep close pending; arbitrary detached children remain the caller's responsibility.

Blast Radius: lifecycle

Input cancellation stays prompt. Already-applied writes can still commit after a fence. Package publication is separate.

A cancelled receipt can precede cooperative callback cleanup. Pin close and stop ownership, earlier withdrawn work, shared waiter cancellation, and a callback factory that aborts before handing back its task.
Retain direct preparation awaitables beyond withdrawal so close and engine shutdown wait for cooperative cleanup. Preserve prompt input rejection and logical queue progress, cancel tasks returned after a factory abort, and shield shared close completion from shutdown waiter cancellation.
The regression intentionally replaces cancellation with a late callback error; suppress the cancelled exception context so the test states that outcome directly.
A second runner cancellation can publish completion before cleanup, while stop awaited from its own preparation waits on itself. Pin both lifecycle boundaries before fixing shutdown ownership.
Run shutdown once in its own shielded task and publish completion only after it joins. Refuse stop from an intake callback context so cleanup cannot await itself; callers can request stop through the run signal.
Keep folded event exports available while retaining intake preparation cleanup guarantees.
@asher-aqi
asher-aqi changed the base branch from feat/accumulating-continuation to main November 14, 2026 04:22
@asher-aqi
asher-aqi merged commit 9030044 into main Nov 14, 2026
17 checks passed
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