Skip to content

Fail unattested query and validation rebuilds that read entry time - #382

Merged
rmcdaniel merged 2 commits into
mainfrom
general/215-replay-clock-query-attestation
Nov 25, 2026
Merged

rmcdaniel merged 2 commits into
mainfrom
general/215-replay-clock-query-attestation

Conversation

@rmcdaniel

Copy link
Copy Markdown
Member

What

Follow-up to #380 for durable-workflow/.github#215. The independent review of the matching Rust change found a gap that Python shares.

The gap: a query or pre-accept validation rebuild with no replay_clock lets a body that catches ReplayClockUnavailable at entry (try: ctx.replay_now() except ...) build different state from its workflow task. The query then answers with that state silently.

The fix: a rebuild now records an entry read that it found unavailable only because its own task doesn't attest the carrier, and that read fails the query or validation.

Query/validation task's replay_clock Rebuild
a valid v1 object uses it, same as the workflow task
explicit null (durable-workflow/server#1338: run has no provable start) proceeds; the workflow task had no carrier either
key absent (Server before #1338), or invalid object an entry read fails the query or validation, even if the body catches it

Unchanged:

  • Reads after a durable step, and an entry read with a redrive start that history already proves, have history authority on both sides and need no carrier.
  • Workflow and update tasks are unchanged: Server attaches the carrier to every workflow task under the same proof.
  • Direct query_state() and validate_update() (no Server) keep treating no carrier as attested-none, so they stay consistent with offline replay().

Evidence

  • tests/test_business_replay_clock_query_attestation.py covers:
    • matching answers for the carrier and null cases;
    • fail-closed for an absent key and an invalid object, on both query and validation;
    • post-step reads that need no attestation;
    • a history-proved redrive entry that needs no carrier;
    • real Worker._run_query_task runs with the key absent, null and an object.
  • Regression corpus fixture business-clock-query-entry-attestation runs a tolerant body through two workflow-task leases and three query tasks. It fails on base, where the key-absent query completes with None.
  • Locally: pytest -m "not integration" (8018 passed, 3 skipped), ruff, mypy and validate-regression-corpus.py --base-ref origin/main all pass.
  • CHANGELOG and the SDK reference describe the rule and add an upgrade note: code that branches on entry unavailability needs versioning or draining.

Refs durable-workflow/.github#215

🤖 Generated with Claude Code

A query or validation rebuild without the workflow task's replay_clock let
a body that catches ReplayClockUnavailable at entry build different state,
and the query answered with it silently. A rebuild now records an entry read
that it could only find unavailable because its task has no replay_clock key
(or an invalid one), and fails the query or validation. An explicit null,
which server#1338 sends when no start is provable, attests that the
workflow task had no carrier either, so the rebuild proceeds.

Refs durable-workflow/.github#215

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #382: an empty group carries the entry time into the next resume,
so the entry mark now follows the time through preserve_boundary instead of
only the first resume. An object this SDK rejects was rejected on the
workflow task too, so a rebuild treats it like an explicit null. The
docstring, reference and CHANGELOG match, and a corpus variant pins the
empty-group case.

Refs durable-workflow/.github#215

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@rmcdaniel

Copy link
Copy Markdown
Member Author

Independent review: PASS at 0d5aa51432ddbfa405905558244980b9b637b4cf after one blocking round.

Round 1 (blocking): an empty group (yield []) carried the entry time into a resume that wasn't marked as entry. A key-absent query of a tolerant body then answered silently.

The fix: _pending_entry/_current_entry follow the time through preserve_boundary, and a rejected carrier object attests none, like null.

Evidence:

  • Removing the preserve_boundary line fails both the new corpus fixture and its unit test.
  • With base src/, both attestation fixtures fail.
  • 603 targeted tests pass, and ruff and mypy are clean.
  • All 21 CI checks pass (4 intended skips), including integration and SonarCloud.

Non-blocking nit: the uneven CHANGELOG wrapping.

🤖 Generated with Claude Code

@rmcdaniel
rmcdaniel merged commit 1271868 into main Nov 25, 2026
25 checks passed
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.

1 participant