Repository navigation
Keep the cancellation test waiting on an unfinished write - #932
Merged
Merged
Conversation
A bulk-only gate does not hold point writes when the batching window expires. Hold the first point write too and assert cancellation is accepted before checking that close preserves every pending write. Signed-off-by: zlareb1 <[email protected]>
9 tasks done
zlareb1
added a commit
that referenced
this pull request
Nov 18, 2026
Related: #855 Related: #932 ### Changelog category (leave one): - Build/Testing/Packaging Improvement ### Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes): The first-set cancellation test controls the clock so its writes share one coalescing window. ### Why The test requires a bulk flush behind an unfinished point write. Yielding a fixed number of event-loop turns does not establish that all three calls fit inside one 200 ms window. If the window expires before the third call submits, that call can become a point write in a new window and finish while the earlier write waits. The existing manual clock holds this test in the window it intends to exercise. Explicitly closing the window still starts the flush, and the test still requires the cancelled caller's write to land before that flush. ### Scope and risk One test gains the existing clock fixture. Its cancellation, gates, both ordering assertions and scheduling yields remain unchanged. The SDK implementation and 200 ms window are unchanged. The separate close-cancellation test is unaffected. ### Compatibility, rollout and rollback - Wire: none. - Operator steps: none. - Rollback: reverting removes the clock control; no stored data changes. ### Tests - The exact changed test passes: `python -m pytest -q tests/unit/test_sdk_set_coalescer.py::test_a_first_set_its_caller_cancels_still_lands_before_the_windows_flush` — 1 passed in 1.64s. - A bounded witness invokes the original test with the actual SDK and existing fake transport. A frozen-clock control passes; advancing the clock by 0.21s before the third submission reproduces the failed assertion, with the newer value landing first. The hosted failure records no window ages, so its exact scheduling cause remains unproven. - Ruff format/check and whitespace checks pass for the changed file. AST comparison preserves the entire original file after removing only the clock setup and added fixture parameter, including both original assertions. - All 44 checks and all three applicable workflows pass in GitHub CI on this head, including the unit, integration, Postgres-authority, coverage and offline benchmark gates. ### AI assistance in the code (leave one; writing this description with AI is fine): - AI-generated: Codex wrote the clock setup. Source review checked the coalescer's window and cancellation behavior; a bounded witness checked the scheduling premise, and AST comparison checked the preserved assertions. - [x] I can explain every line of this diff and how it interacts with the rest of Loom. ### Checklist - [x] `make format-check`, `make lint`, `make typecheck` and `make test-unit` pass; the integration suite passes if server behaviour changed. - [x] Generated files are unaffected. - [x] No migration changes. - [x] No shipped plugin files change. - [x] No frontend changes. - [x] No operator steps or wire changes. - [x] Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers. - [x] Commits are signed off (`git commit -s`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
The SDK close cancellation test waits on an unfinished write even when its coalescing window expires.
Why
The test gates bulk writes, but the first calls in a coalescing window are point writes. If the window expires during setup, the bulk gate alone does not keep
close()pending. Gating the first point write establishes that precondition, and assertingcancel()succeeds checks it explicitly.Scope and risk
Two lines in one SDK unit test. The test still requires
CancelledError, successful results for all nine writes and a closed transport. No SDK implementation, timeout, batching window or assertion is weakened.Compatibility, rollout and rollback
Tests
Existing CI records this exact test failing because awaiting
close()did not raiseCancelledError. Static source review shows that point writes enter the coalescer's tracked in-flight set before their callers wait, so the shared gate keepsclose()pending independently of bulk formation. The failure log does not record the incident's clock or task state.Local checks cover Python AST syntax, whitespace and public prose only. The small scheduling witness and corrected test remain unrun: the resource guard refused the witness before execution because available memory was below its admission floor. No retry or dependency change followed. Full CI on the final commit is required.
AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated: Codex wrote the two-line test edit. Static review checked point-write tracking, cancellation propagation and the unchanged write assertions.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main; no migration changes.frontend/changed; no frontend files change.git commit -s).