Skip to content

chore(xtask): lint test timeouts and negative waits, and key legacy sleeps by function - #530

Merged
lg2m merged 4 commits into
test/split-and-renamefrom
chore/test-lints
Nov 2, 2026
Merged

lg2m merged 4 commits into
test/split-and-renamefrom
chore/test-lints

Conversation

@lg2m

@lg2m lg2m commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #529.

Change

  • Timeout and negative-wait ratchets (B8). cargo xtask lint now counts two more patterns in test code, next to fixed sleeps:

    • real-time timeout(Duration::from_millis|from_secs(N), …) bounds under 10 s;
    • negative waits of any length, meaning a timeout(..) whose expected result is the elapsed branch (.await.is_err(), .unwrap_err(), let x = timeout(..).await; followed by assert!(x.is_err()), or .is_ok(); followed by assert!(!x)).

    Both ratchet like the sleep count, in one CEILINGS constant: above the ceiling fails, and below it fails until the ceiling comes down. // lint: allow(timeout) <reason> is the escape hatch. It follows the lint: allow(sleep) convention, which chore: strip comments from code and config #504 already kept as the only comment the no-comments rule allows.

  • within() hang guard. crate::test_support::within(fut) in qq-core gives one 60 s guard, and its Debug failure names the caller's location. 144 short qq-core timeouts became within(..), including all of settlement.rs and every 1 s bound in qq-core. A bound became within() only when it awaited a future that must finish (.await.unwrap()/.expect()). Real-time bounds that are the behavior under test stay counted, for example completed_compaction_does_not_restart_the_original_duration (900 ms) and pipe_read_failure_is_unobserved… (a 5 s bound against a shell sleep 30). Also, I removed one expect message's "within one second" claim.

  • Negative waits. The two 50 ms "a stop must not be requested" checks in the_stop_route_signals_only_a_host_that_opted_in_and_requires_the_token now use now_or_never(). The route has already answered (401/404) by then, and it writes the stop signal before it responds, so the absence can be checked immediately. The other 9 are left counted.

  • Legacy lists keyed by function. xtask/src/legacy-{sleeps,timeouts,negative-waits}.txt now key each entry by file, enclosing fn, and whitespace-free call text, so moving lines no longer breaks lint. The enclosing fn is found with brace tracking, so a nested fn stream inside a test no longer takes over as the key. Moving an occurrence to another function, or changing its call, still fails.

  • pr-status.sh. Each check is judged by its latest run, ordered by Actions run ID. A CANCELLED check is ignored when a newer run of the same workflow exists, for example one cancelled when a label was added. .github/scripts/test-pr-status.sh drives the script with a stub gh across 5 fixtures and runs as check::tests::pr_status_judges_each_check_by_its_latest_run. Both script paths are CROSS_CRATE_INPUTS for xtask. The .agents/ copies are identical.

  • Docs. docs/runbooks/testing.md test policy covers within(), both new ratchets, the function keying, and the allow marker. Both copies of the babysit-pr skill say how superseded runs count.

Verification

  • Counts, measured with the new lint binary on the base tree and on this branch:
    • short timeouts under 10 s: 191 → 47
    • negative waits: 11 → 9
    • sleeps: 11 → 11, still all keyed by function
  • Lint unit tests, positive and negative:
    • short_timeouts_are_counted_and_long_or_allowed_ones_are_not
    • negative_waits_are_counted_at_any_duration_and_cleanup_branches_are_not
    • each_wait_ratchet_fails_above_and_below_its_ceiling
    • a_wait_is_keyed_by_its_enclosing_function_not_a_nested_one
    • legacy_entries_follow_their_function_and_cannot_be_spent_twice: shifted lines and reflowed calls pass; another file, fn, or call fails
    • the_checked_in_baselines_match_the_ceilings
  • test-pr-status.sh against the old script fails with a run superseded by a label change: want [[],[]], got [["gate","platform"],[]] and passes with the new one.
  • PR test: split oversized test files by topic and name tests by behavior #529's rollup has no cancelled checks. test(core): share session fixtures and replace test-only hooks with three seams #528 and ci: size test threads to the machine and run platform tests through one nextest profile #523 had cancelled runs, but only on older heads, so their live rollups don't show the problem either. That is why the regression check is fixture-based. Real run on test: split oversized test files by topic and name tests by behavior #529: {"checks":{"total":15,"pending":[],"failing":[]},"ready":true}.
  • cargo nextest run -p qq-core -p qq-server -p xtask: 1490 passed. qq-core still takes about 4.2 s, because within() only lengthens the guard and not the waits.
  • cargo xtask check --full passed on 0f8f34a: 3008/3008 workspace tests, plus 224/224 for the minimal provider.

Known impact

  • Replaced test: lint::tests::replacing_a_sleep_cannot_spend_a_removed_legacy_entry became legacy_entries_follow_their_function_and_cannot_be_spent_twice. It keeps every old case except "shifted lines fail", which now passes by design.
  • The first CI run failed Windows clippy: an unused within import in the all-cfg(unix) execution_context.rs. 3f9936e fixed it by using the qualified path.
  • A hung test in a converted spot now fails after 60 s instead of 1–5 s. Nextest's 60 s slow-timeout period still reports it.
  • The lexical detector misses negative waits written in other shapes, such as select! against sleep. 47 short timeouts remain in headless, server, TUI, MCP, auth, host, and some qq-core integration tests, where within() is not available because it lives in qq-core's private test support.

lg2m added 3 commits November 1, 2026 16:01
… guard

Short real-time timeouts in qq-core tests become one 60 s hang guard, and the stop-route checks in qq-server use now_or_never instead of a 50 ms negative wait.
@lg2m lg2m added the ci:full label Nov 2, 2026
@lg2m

lg2m commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T01:37:38.021191Z 3f9936e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 3f9936ea3f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lg2m
lg2m added this pull request to stack #531 November 2, 2026 01:41
@lg2m
lg2m added this pull request to the merge queue Nov 2, 2026
@lg2m
lg2m removed this pull request from the merge queue due to a manual request Nov 2, 2026
@lg2m
lg2m added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit e4912c6 Nov 2, 2026
14 checks passed
@lg2m
lg2m deleted the chore/test-lints branch November 2, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant