Skip to content

serve: wait for the HTTP reset before advancing the gone-client test - #751

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:fix-serve-gone-client-test
Oct 23, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:fix-serve-gone-client-test

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

닫힌 클라이언트 시험이 HTTP 처리기의 reset 감지를 기다린 뒤 엔진을 한 번만 진행하도록 고칩니다.

What and why

a_whole_answer_whose_client_closed_ends_at_the_next_event (crates/serve/src/api.rs) resets the client's socket and then checks that the slot frees at the next engine event. The old test judged that by counting engine calls. After the reset it released the engine's gate once per step, up to 24 times, until the slot freed, and then required at most 8 calls. The reset is seen by the HTTP handler thread, which runs on its own schedule. If that thread is slow to get the CPU, the engine takes more steps first, and the test reads the scheduling gap as slow cancellation in the product.

The test now waits for state.shared.answers.in_flight() == 0, which is true once the HTTP handler has observed the reset and finished. Only then does it release the engine's gate once, wait for the slot to free, and assert exactly one engine call. This is stricter than the old <= 8 bound, so the next-event cancellation contract is not weakened. The wait reuses gone_client::wait_for and its 10 second limit. The change adds no helper, no sleep and no product hook, and removes the STEPS constant. Product code is unchanged.

The change is one test function, 7 lines added and 19 removed. The assertion carries a dated PIN with its reason, since the bound moved. Open PR #747 also edits crates/serve/src/api.rs, but not this test.

Release notes: internal: The gone-client serve test waits for the HTTP handler to see the reset before it advances the engine.

What I ran

Linux x86_64, rustc 1.100.0-nightly (e457a7b0d 2026-08-27), this change on main 2a7005b8. The test is CPU only and uses no model or GPU, so there is no device path to measure. Each repeated run used the test binary built with cargo test -p bloomery-serve --lib --no-run, pinned with taskset and run with --exact api::tests::gone_client::a_whole_answer_whose_client_closed_ends_at_the_next_event --test-threads=4.

  • Unmodified main, two cores, the whole serve lib binary, 30 rounds: no failure (BASELINE failures=0). I could not reproduce the flake by repetition on this host.
  • To reproduce the cause directly, I delayed only the return of the HTTP error probe by 250 ms, with two cores. The test on main then fails with the slot still runs the request of a closed client after 24 steps (test result: FAILED. 0 passed; 1 failed).
  • The fixed test with the same 250 ms delay passes on one core and on two cores (PROBE delayed cpus=0 rc=0, PROBE delayed cpus=0,1 rc=0).
  • Fixed test, one core, 30 rounds: SUMMARY cores=1 cpus=0 passed=30 failed=0. Two cores: SUMMARY cores=2 cpus=0,1 passed=30 failed=0.
  • The whole gone_client module on the fixed head: test result: ok. 8 passed; 0 failed.
  • With the product's Client::check call to probe_client replaced by Ok(()), the fixed test fails after its 10 second limit with timed out waiting for the HTTP handler to observe the reset (test result: FAILED. 0 passed; 1 failed). The source was restored byte for byte afterwards.
  • git diff --check is clean. I did not run fmt or clippy in this round.

What I ran into

None of this blocks the PR. The 250 ms delay is an injected schedule. I could not reproduce the original flake without it, so I make no claim about its natural frequency. The two delay runs and the product-check removal were temporary local changes that are not part of the commit.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot 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.

Verdict: CLEAN: The test waits for reset detection before advancing the engine and still requires cancellation at the next event.

Checked

Duplicates: 0 new functions, types or constants; existing wait and answer-count owners reused. Dryer reported 0 pairs.
Complexity: Crapper flagged no functions. The changed test removes a loop and branches.
Silent failure: 0 new sites. Both waits fail with named assertions; the permit send fails explicitly.
Tests: Source mutation check: replace the probe at crates/serve/src/api.rs:3281 with Ok(()); the reset wait asserts. Ignore the send error at crates/serve/src/worker.rs:461; the slot-release wait asserts. The PR reports the first mutant failing and all 8 module tests passing.
Gates: The engine-call bound changes from <= 8 to == 1, with a dated PIN and reason. The PR supplies an injected scheduling delay that fails the old test and passes the revised test.
Adversarial checks: The first blocked engine call proves the answer guard is active. Zero answers follows receiver destruction. The HTTP receive timeout permits reset detection while the engine is blocked. Snapshot sealing adds no counted call because this engine keeps the default synchronous snapshot policy.
Escape catalog: No patterns match. No production hot path changes.

Notes

Tests were reviewed statically and were not run locally.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 7ddadcb into midagedev:main Oct 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

serve The HTTP server: crates/serve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant