Skip to content

fix(sdk): answer PENDING on revoked token - #757

Open
hln33 wants to merge 23 commits into
mainfrom
722-feature-exit-gracefully-with-pending-when-a-checkpoint-response-has-no-checkpointtoken
Open

hln33 wants to merge 23 commits into
mainfrom
722-feature-exit-gracefully-with-pending-when-a-checkpoint-response-has-no-checkpointtoken

Conversation

@hln33

@hln33 hln33 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available:

Fixes #722

Description of changes:

This PR updates the SDK to return PENDING when a checkpoint response omits the next checkpoint token for non-terminal work, instead of treating that response as execution completion.

Changes include:

  • Stop further checkpointing after token revocation and wake queued work through the existing SuspendExecution path.
  • Ensure execution exits return bare PENDING when the token has been revoked.
  • Preserve true terminal completion when the accepted checkpoint batch contains the execution terminal update.
  • Add local test runner pause/resume support for withholding checkpoint tokens and deferring invocations while paused.
  • Add unit and e2e coverage for revoked-token handling, queued work, refreshes, oversized results, and pause/resume scenarios.

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

hln33 added 3 commits October 1, 2026 17:16
A checkpoint response without a token means the current invocation must
stop checkpointing. The background thread previously treated every such
response as execution completion, which could report SUCCEEDED or FAILED
while operation work was still in flight. It now reports PENDING.

- Add ExecutionSuspendedByService and a token-revoked latch distinct
  from execution completion.
- Exempt a batch carrying the execution's terminal update because that
  execution is already complete.
- Reject newly queued operations and refreshes after token withdrawal,
  and wake accepted and queued waiters through the suspension path.
- Return a bare PENDING response from every otherwise-terminal exit,
  including oversized-result paths and the CheckpointError exit, which
  now consults the latch for symmetry with the other exits.
- Treat a refresh-only batch exactly like every other non-terminal batch
  when its response omits the token.
- Document ExecutionSuspendedByService in the Raises section of
  create_checkpoint and schedule_refresh.
- Drop ExecutionSuspendedByService's redundant constructor override,
  identical to SuspendExecution's.
- Describe only the SDK-observed condition and resulting behavior in
  comments and docstrings.
- Cover queue guards, deferred refreshes, completion versus withdrawal,
  oversized results, the CheckpointError exit, and every PENDING exit.

Fixes #722
- Executor: skip PENDING-validator rejection when execution.paused
- Add 9 new tests (6 unit + 3 e2e) covering pause/resume semantics
- Fix 61 pre-existing executor_test.py mocks missing .paused=False
  (unconfigured Mock attrs are truthy, broke new paused-aware paths)
- Update 3 mock-sequencing tests for new _invoke_execution store.load call
Use the existing SuspendExecution control flow for revoked checkpoint tokens and simplify the surrounding comments and tests.

Clean up the local test runner pause and resume path, including deferred invocation naming and focused pause/resume coverage.
@hln33
hln33 marked this pull request as ready for review October 3, 2026 00:12
@hln33
hln33 deployed to ai-pr-review-runtime October 3, 2026 00:12 — with GitHub Actions Active
@hln33
hln33 requested a review from yaythomas October 3, 2026 00:17
@hln33
hln33 deployed to ai-pr-review-runtime October 3, 2026 00:18 — with GitHub Actions Active
Comment thread packages/aws-durable-execution-sdk-python-testing/tests/e2e/pause_resume_test.py Outdated
@github-actions

This comment has been minimized.

@hln33 hln33 closed this Oct 3, 2026
@hln33 hln33 reopened this Oct 5, 2026
@hln33
hln33 deployed to ai-pr-review-runtime October 5, 2026 16:24 — with GitHub Actions Active
@hln33
hln33 deployed to ai-pr-review-runtime October 5, 2026 16:25 — with GitHub Actions Active
Comment thread packages/aws-durable-execution-sdk-python-testing/tests/e2e/pause_resume_test.py Outdated
@github-actions

This comment has been minimized.

@hln33
hln33 force-pushed the 722-feature-exit-gracefully-with-pending-when-a-checkpoint-response-has-no-checkpointtoken branch from 8859615 to aa2d825 Compare October 6, 2026 18:54
…n-a-checkpoint-response-has-no-checkpointtoken
@hln33
hln33 deployed to ai-pr-review-runtime October 6, 2026 21:12 — with GitHub Actions Active

@yaythomas yaythomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @hln33, this is a careful port of the JS fix, and the state_test.py coverage of the real checkpoint loop is excellent!

Thanks for the follow-up commit for the Codex findings. _invoke_execution no longer reads and saves outside the worker lane, a retried checkpoint no longer receives the withheld token, and the mid-step pause test now fails without the fix (I checked against main's core SDK).

Please could you rename the PR to the conventional commit format, e.g. fix(sdk): answer PENDING on revoked token (your first commit's subject)? The PR title becomes the squash commit message: https://github.com/aws/aws-durable-execution-sdk-python/blob/main/CONTRIBUTING.md#pull-request-title-and-commit-message-format

Maybe this behaviour also warrants a conformance requirement? If so, please could you note it in the description or open an issue in aws-durable-execution-conformance-tests?

@github-actions

This comment has been minimized.

hln33 added 7 commits October 13, 2026 10:18
Add a finite timeout to pause_execution and preserve the pause request
when waiting times out. Raise TimeoutError on expiry, matching
wait_for_result and wait_for_callback. Forward the timeout through the
test runner.

Cover timeout validation, worker errors, and pause/resume behavior
with unit and end-to-end tests.
- Reuse queue draining across the three checkpoint exit paths.
- Preserve overflow-first order and caller-specific errors.
- Include the execution ARN in token-revocation warnings.
- Count submitted updates without including refresh-only entries.
- Test queue draining, waiter errors, and warning accuracy.
Document guard precedence and checkpoint-loop stop conditions.
Distinguish terminal completion from token revocation. Explain why a
quota-limit failure can return PENDING without changing the execution
status from FAILED.

Add two unit tests for guards that run before token revocation.
@hln33

hln33 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

@yaythomas Thanks for identifying these follow-ups. I opened separate issues for:

The conformance issue calls out the need to agree on a deterministic test mechanism before adding requirements or SDK handlers.

@hln33 hln33 changed the title 722 feature exit gracefully with pending when a checkpoint response has no checkpointtoken fix(sdk): answer PENDING on revoked token Oct 14, 2026
…ken-revoked

# Conflicts:
#	packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python/execution.py
@hln33
hln33 marked this pull request as ready for review October 14, 2026 01:28
@hln33
hln33 deployed to ai-pr-review-runtime October 14, 2026 01:28 — with GitHub Actions Active
@hln33
hln33 deployed to ai-pr-review-runtime October 14, 2026 01:42 — with GitHub Actions Active
@github-actions

This comment has been minimized.

@hln33
hln33 requested a review from yaythomas October 14, 2026 17:12
…n-a-checkpoint-response-has-no-checkpointtoken
@hln33
hln33 deployed to ai-pr-review-runtime October 14, 2026 22:35 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

Four confirmed findings:

  • P1: Cleanup-time revocation — packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python/execution.py:412
  • P2: Lost accepted-state notifications — packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python/state.py:1074
  • P2: Broken checkpoint retry idempotency — packages/aws-durable-execution-sdk-python-testing/src/aws_durable_execution_sdk_python_testing/checkpoint/core.py:162
  • P3: Unknown-execution worker leak — packages/aws-durable-execution-sdk-python-testing/src/aws_durable_execution_sdk_python_testing/executor.py:1833

Static review completed; tests were not executed under the read-only constraints.

Reviewed commit f401083dc35782f81357f4c8cc4860529c07a4e9. Workflow run

This branch was successfully deployed

1 active deployment
ai-pr-review-runtime — f401083d Deployed Oct 14, 2026 by hln33 via ai-pr-review / Codex review / Generate Codex review #1714
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.

[Feature]: Exit gracefully with PENDING when a checkpoint response has no CheckpointToken

2 participants