Skip to content

fix(sdk): settle recorded terminal items before a resumed batch completes - #999

Open
MaxonT wants to merge 1 commit into
aws:mainfrom
MaxonT:contrib/835-auto
Open

MaxonT wants to merge 1 commit into
aws:mainfrom
MaxonT:contrib/835-auto

Conversation

@MaxonT

@MaxonT MaxonT commented Nov 27, 2026 •

Copy link
Copy Markdown

This is a small change to when a resumed map or parallel decides it is complete, so please check that waiting for the recorded items matches how you want replay to behave.

Thanks for the precise write-up of the [SUCCEEDED, SUCCEEDED, STARTED] case; it made the failing test easy to build.

Issue #, if available

Fixes #835

Description of changes

On resume, a map or parallel batch can contain child contexts that already recorded a terminal outcome. Their replays reach the coordinator in thread completion order, so the batch could decide it was complete before every recorded item had been settled, which left a recorded FAILED item reported as STARTED. ConcurrentExecutor now reads which NESTED child contexts already have a terminal record (_recorded_terminal_indexes), defers the completion decision until each of those has settled, and starts no new item past the last recorded index while any are unsettled. FLAT branches never checkpoint themselves, so they have no record and are unaffected.

Design

  • Design note (rule 3): not needed, no new feature, option or public API.
  • Simpler options considered (rule 2): I did not find one that keeps live behaviour unchanged; with no recorded items both new guards are no-ops (recorded_unsettled is empty and last_recorded is -1).
  • Root cause (rule 5): the completion check ran as soon as the policy said complete, before the replayed events of recorded items had all been applied.
  • Net change: about 38 added and 5 removed source lines in executor.py, no public API members.

Assumptions

  • Only NESTED child contexts carry a terminal record that matters here; I read this from the code and the existing FLAT replay tests, not from the service. Marked unverified against a real service run.

Decisions not covered by the issue or the design note

Checklist

  • Every new branch has a test that fails without it: removing the pending[0].index <= last_recorded condition, or the FLAT early return, makes tests fail.
  • The first commit adds a test that fails on the current code: not as separate commits here, the test and the fix are in one commit. The test (test_resumed_batch_settles_recorded_terminal_items_before_completing) gave [SUCCEEDED, SUCCEEDED, STARTED] instead of [..., FAILED] on the base executor.py when I ran it separately. I can split it into two commits if you want that.
  • No test expectation was edited.

How I checked: the full core suite gives 2284 passed with the fix (it needs the testing package installed), and ruff and mypy on the core source are clean. Not run: hatch run test:all, the CI checks script, commit-message lint, and the examples and wheel lanes. While running the suite repeatedly I saw parallel_test::test_parallel_item_deserialize fail about twice in 30 runs, and a different test once in 15 runs on main; both looked timing related and I did not chase them.

@MaxonT
MaxonT deployed to ai-pr-review-runtime November 27, 2026 22:55 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
ai-pr-review-runtime — 9719f6fd Deployed Nov 27, 2026 by MaxonT via notify / Generate notification summary #513
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Resumed map or parallel can omit recorded terminal item outcomes

1 participant