Skip to content

[CTX-1375] fix(runtime): deflake fs.list cap tests against wall-clock expiry - #2281

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-1348/fix-fs-list-deadline-tests
Oct 20, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-1348/fix-fs-list-deadline-tests

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Summary

De-flakes the fs.list unit tests merged in #2271. Quality gates (1) on PR #2277
(and #2270) failed in
plugin_runtime::fs_list::tests::granted_prefix_lists_expected_entries_deterministically
with BridgeError { class: "budget", code: "E_TIMEOUT", message: "host call exceeded its deadline" },
although neither PR touches bitty-runtime.

Root cause

FsListBackend::list applies the accepted RC-1 50 ms budget to the whole call
(Instant::now() + LIST_SCAN_BUDGET) and checks the deadline at walk index 0,
before the first entry. Cap, containment, and security tests called list()
directly, so a loaded CI runner only had to spend 50 ms in pre-scan work (grant
matching, canonicalization, read_dir) plus scheduling jitter for a tiny
three-entry fixture to abort with E_TIMEOUT before reaching its assertion.
#2271 already introduced a FIXTURE_SCAN_DEADLINE helper but only the
oversized-directory test used it.

Changes

  • Route all 33 non-timing test call sites through the existing
    list_with_generous_deadline helper (test-only 60 s fixture deadline), so
    entry/byte caps, containment, and denial assertions are decided by entries
    and bytes, never runner speed.
  • large_directory_aborts_near_the_scan_deadline stays the only test that
    depends on wall-clock expiry: an already-expired deadline aborts
    deterministically at the first check, and a 2 ms live budget aborts a
    20k-entry walk mid-scan.
  • That test now also asserts LIST_SCAN_BUDGET == RC1_WALL_CLOCK_BUDGET_MS, so
    a future "fix" cannot loosen the production deadline instead of opting the
    tests out.

Production deadlines, list_with_expiry semantics, and the bridge expiry
plumbing are untouched. No cfg(test) in production logic, no sleep-based
retries.

Verification

  • cargo nextest run -p bitty-runtime plugin_runtime::fs_list --no-fail-fast
    — 32 runs (4 concurrent workers x 8) with CARGO_BUILD_JOBS=8: every run
    18 tests run: 18 passed, zero failures.
  • cargo fmt --all -- --check: clean.
  • RUSTFLAGS="-D warnings" cargo clippy --workspace --all-targets: clean.
  • RUSTFLAGS="-D warnings" cargo check --target x86_64-pc-windows-gnu --workspace --all-targets --locked: clean.
  • bash scripts/check-scratch-paths.sh: OK.

Priority: P1 | Area: runtime | Labels: bug,P1,area:runtime | Milestone: 0.0.24 | RFC: RFC-0005 | Task: CTX-1375

Closes #2280

… wall-clock expiry

`FsListBackend::list` spends the accepted RC-1 50 ms budget on the whole
call and checks the deadline at walk index 0. Every cap, containment, and
security test called it, so a saturated runner only had to burn 50 ms in
pre-scan work (grant matching, canonicalization, `read_dir`) plus
scheduling jitter for a tiny fixture listing to abort with `E_TIMEOUT`
before reaching the property under test. That is what failed
`granted_prefix_lists_expected_entries_deterministically` on PR #2277.

- Route all 33 non-timing test call sites through the existing
  `list_with_generous_deadline` helper (test-only 60 s fixture deadline),
  so cap/containment/security assertions are decided by entries and bytes.
- Keep `large_directory_aborts_near_the_scan_deadline` as the only test
  that depends on wall-clock expiry (already-expired deadline plus a 2 ms
  live budget over 20k entries).
- Assert in that test that `LIST_SCAN_BUDGET` still equals
  `RC1_WALL_CLOCK_BUDGET_MS`, so the tests cannot be "fixed" by loosening
  the production deadline.

Production deadlines, `list_with_expiry`, and the bridge expiry plumbing
are unchanged. No `cfg(test)` in production logic, no sleep-based retries.

Closes #2280
@Xuepoo Xuepoo added this to the 0.0.24 milestone Oct 19, 2026
@Xuepoo Xuepoo added bug Something isn't working P1 Priority: high area:runtime Area: runtime orchestration labels Oct 19, 2026
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b307890-69af-4c6f-9656-b5b77cc9773a
📥 Commits

Reviewing files that changed from the base of the PR and between a888b51 and 91133b5.

📒 Files selected for processing: 1
  • crates/bitty-runtime/src/plugin_runtime/fs_list.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Xuepoo
Xuepoo merged commit e589c66 into main Oct 20, 2026
17 checks passed
@Xuepoo
Xuepoo deleted the ctx-1348/fix-fs-list-deadline-tests branch October 20, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Area: runtime orchestration bug Something isn't working P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[0.0.24] fs.list cap tests depend on wall-clock expiry

1 participant