Skip to content

fix(core): reject checkpoints at virtual child ids - #778

Merged
zhongkechen merged 2 commits into
aws:mainfrom
Thanatos9404:fix/704-reject-virtual-child-checkpoint
Oct 16, 2026
Merged

zhongkechen merged 2 commits into
aws:mainfrom
Thanatos9404:fix/704-reject-virtual-child-checkpoint

Conversation

@Thanatos9404

Copy link
Copy Markdown
Contributor

Issue #, if available: Closes #704

Description of changes:

A virtual child context never writes a checkpoint of its own, so a checkpoint at its operation id can only come from a non-virtual child in an earlier invocation. is_virtual is not part of OperationIdentifier, so that checkpoint passed the identity checks and check_result_status() returned the cached result (or re-raised the cached error) without running the virtual body.

  • ChildOperationExecutor.check_result_status(): for a virtual child, any checkpoint at its id raises NonDeterministicExecutionError ("... checkpoint contains a non-virtual child context but current child context is virtual", in the style of the FLAT message from fix(core): validate replay operation identity #698), after the identity check and before terminal handling. The check is the new ChildOperationExecutor.validate_virtual_checkpoint().
  • DurableContext.run_in_child_context(): passes is_virtual through _operation_replay_aware() to _replay_aware(), which runs the same check right after validate_checkpoint(), before the replay or update plugin hook fires.

Outside replay, a virtual child or FLAT branch that finds a checkpoint at its id now fails with this error instead of using it. While replaying, FLAT branches still hit _validate_branch_checkpoint_nesting() first.

Testing:

  • operation/child_test.py: a virtual child over a SUCCEEDED (with and without ReplayChildren), FAILED or STARTED checkpoint raises the error; the user function never runs and nothing is checkpointed.
  • context_test.py: with a real PluginExecutor, a STARTED and an updated SUCCEEDED checkpoint fail before any replay or update hook.
  • execution_test.py: a composed durable_execution test replays a non-virtual SUCCEEDED, FAILED or STARTED child as virtual and fails with NonDeterministicExecutionError; the body never runs and nothing is checkpointed.

All 9 new cases fail on main. The context test also fails with the _replay_aware check removed.

Locally (Windows, Python 3.13, Hatch 1.16.5): hatch run dev-core:cov reaches 98.28% (gate 98%), with context.py and child.py at 100%; the only failures are two Windows-only timestamp tests that also fail on main. hatch run dev-core:typecheck, the types:check script (mypy, all checked packages) and hatch fmt --check are clean. No conformance tests were added or changed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

A virtual child context never writes a checkpoint of its own, so a
checkpoint at its operation id can only come from a non-virtual child in
an earlier invocation. Replay accepted that checkpoint, because
virtualness is not part of the operation identity, and returned the
cached result (or re-raised the cached error) without running the
virtual body.

- ChildOperationExecutor.check_result_status raises
  NonDeterministicExecutionError for any checkpoint at a virtual
  child's id, after the identity check and before terminal handling.
- run_in_child_context passes is_virtual through
  _operation_replay_aware to _replay_aware, which runs the same check
  before the replay and update plugin hooks fire.
- Add an executor unit test, a context test showing the error comes
  before the replay and update plugin hooks, and a composed
  durable_execution test that replays a non-virtual child as virtual.
@Thanatos9404
Thanatos9404 deployed to ai-pr-review-runtime October 15, 2026 16:09 — with GitHub Actions Active
@zhongkechen

Copy link
Copy Markdown
Contributor

/ai review

@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

No actionable findings in the PR changes. Residual test risk: regression tests were inspected but not executed, as required by the review constraints.

Reviewed commit 86c58a702c0f5b9725abb91e565fd9ddf99f238c. Workflow run

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.

[Bug]: Virtual child replay can consume a non-virtual container checkpoint

2 participants