Repository navigation
[CTX-1382] fix(runtime): freeze the fs.list rate-window clock in tests - #2306
Conversation
The accepted `fs.list` window is one second and admission read the real clock on every call, so the three rate-window tests — which exhaust the window with ~1024 real listings — drifted across the boundary on a loaded runner, cleared the usage mid-loop, and then failed with `Table([])` where they expect `E_FS_OVER_BOUND`. That is the Windows failure on PR #2292. - Thread an explicit window instant through `admit_fs_list_at` and `fs_list_at`; `HostServices::fs_list_with_expiry` passes `Instant::now()` at the same point as before, so accepted window semantics, caps, and the scan expiry are unchanged. - All three window tests drive one frozen instant derived from the services' window start, so "exhausted denies", "usage survives inside the window", and "one full window later reopens" are exact; the reopen test no longer pokes `refresh_fs_window_at` directly. - Audit of the `plugin_runtime` test modules also converted the sleep-based `debug_trace_expired_call_never_opens_a_trace` (instant 1 ms in the past) and the overlay `timeout_revokes_at_the_deadline` boundary (assert on both sides of an explicit deadline). Left real-time on purpose: live process lifecycle tests in `plugin_runtime::spawn`, the dedicated scan-deadline test in `plugin_runtime::fs_list`, and future/past-dated `SystemTime` fixture mtimes in `fs`/`resolution` (exact by construction, no boundary to cross). Closes #2305
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
`list_at` still passed the RC-1 50 ms scan budget as the expiry, so the 1024-call exhaustion loops could abort with `E_TIMEOUT` before the rate window denied — the new CI failure in `fs_list_tight_loop_hits_the_per_plugin_window` on PR #2306. - Add the named `FIXTURE_SCAN_BUDGET` (60 s) and pass it as the scan expiry from `list_at`; window accounting stays frozen and exact. - Convert the remaining fs.list tests in this module (`fs_list_serves_granted_entries_with_untrusted_shape`, `fs_list_without_backend_or_grant_fails_closed`) to the same fixture budget through `list_with_generous_budget`, so no fs.list test in the module races a wall clock any more. - The tight-loop test keeps asserting `E_FS_OVER_BOUND` and that the byte charge denies before the op cap; removing the byte charge still fails it at call 1025. Production budgets and window semantics are unchanged.
Summary
Fixes the Windows CI flake on PR #2292:
plugin_runtime::services::tests::fs_list_window_reopens_after_the_accepted_windowpanicked with
exhausted window must deny: Table([])— the listing succeededwhere the test expects
E_FS_OVER_BOUND. #2281 fixed the same class of defectin the
fs.listcap tests; this covers the rate-window tests.Root cause
The accepted
fs.listwindow is one second (FS_LIST_WINDOW=RC8_WINDOW),and admission read the real clock on every call (
admit_fs_list->refresh_fs_window->Instant::now). Three tests exhaust that window with~1024 real listings, each doing grant matching, canonicalization,
read_dir,and scope filtering:
fs_list_tight_loop_hits_the_per_plugin_windowfs_list_empty_pages_still_charge_the_op_windowfs_list_window_reopens_after_the_accepted_windowOn a loaded runner the loop outlives the window, the window advances mid-loop,
the usage clears, no denial ever arrives, and the test fails. The existing
refresh_fs_window_athelper only covered the last two assertions of thereopen test, never the exhaustion loop itself.
Determinism method
admit_fs_list_at) andthe listing path (
fs_list_at).HostServices::fs_list_with_expirypassesInstant::now()at the same point as before: window length, caps, the scanexpiry, and the denial ordering are unchanged.
fs_window_start + 1 ms),so "exhausted denies", "usage survives until the window elapses", and "one
full window later reopens" are exact. The reopen test no longer pokes
refresh_fs_window_atdirectly.FIXTURE_SCAN_BUDGET(60 s) as the scanexpiry instead of the production 50 ms budget, and the remaining
fs.listtests in the module use the same budget. Under load the scan deadline could
otherwise abort a 1024-call loop with
E_TIMEOUTbefore the rate windowdenied; that is the failure seen on the first head of this PR.
Test-module audit (
plugin_runtime)Converted:
debug_trace_expired_call_never_opens_a_traceusedInstant::now()plusthread::sleep(2ms); now an instant 1 ms in the past.overlay::tests::timeout_revokes_at_the_deadlineasserted the live side withInstant::now(); it now asserts on both sides of an explicit deadline.Deliberately left real-time:
plugin_runtime::spawnlive process lifecycle tests (sleep-poll on realchild processes; bounding them needs a process-runner seam, not a clock).
plugin_runtime::fs_list::large_directory_aborts_near_the_scan_deadline(the dedicated scan-deadline test; wall-clock by definition).
fs/resolutionfixture mtimes dated relative toSystemTime::now()(fresh/stale by construction, no boundary to cross).
services::tests::window_advance_restores_budget(history window) sets thewindow start into the past; no assertion depends on elapsed time.
Mutation evidence
Each mutation was applied, the
fs_listfilter run, then reverted:refresh_fs_window_atnever advancesfs_list_window_reopens_after_the_accepted_window(elapsed window must restore capacitygotE_FS_OVER_BOUND)admit_fs_list_atreturnsOk(())without chargingfs_list_empty_pages_still_charge_the_op_window,fs_list_window_reopens_after_the_accepted_windowFS_LIST_WINDOWshortened to 500 µsfs_list_window_reopens_after_the_accepted_window(usage must survive until the window elapsesgotOk)Verification
cargo nextest run -p bitty-runtime fs_list(4 workersx 10,
CARGO_BUILD_JOBS=8): every run23 tests run: 23 passed, zerofailures.
cargo nextest run -p bitty-runtime: 2658 passed, 2 skipped.cargo fmt --all -- --check: clean.RUSTFLAGS="-D warnings" cargo clippy --workspace --all-targets --locked: clean.RUSTFLAGS="-D warnings" cargo check --target x86_64-pc-windows-gnu --workspace --all-targets --locked: clean.Priority: P1 | Area: runtime | Labels: bug,P1,area:runtime | Milestone: 0.0.24 | RFC: RFC-0005 | Task: CTX-1382
Closes #2305
Summary by CodeRabbit