Skip to content

Stabilize command and moderation timing tests - #1193

Merged
jatmn merged 2 commits into
mainfrom
fix/queue-666-command-moderation-fixtures
Dec 5, 2026
Merged

jatmn merged 2 commits into
mainfrom
fix/queue-666-command-moderation-fixtures

Conversation

@jatmn

@jatmn jatmn commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

Part of #666.

Changes

Remove 39 command and moderation allowlist rows covering 54 occurrences. With their allowances removed on the original baseline, Dylint reported 51 findings. The other three rows were already stale. With #1192 merged, these are the final 39 rows on main. The proposed allowlist contains only its two header lines.

The ban-expiry command and gateway startup fixtures supply fixed clocks at the existing timestamp reads. Normal command execution and gateway startup still read UTC. Case inserts, audit retries, pacing persistence and image capture now signal the steps their tests need to observe. The tests still use SQLite and loopback peers, and keep the existing timing bounds for a stalled insert, a hung stats request and synchronous status rendering.

Verification

  • Ran all 36 assigned behaviors in 20 serial and 12 concurrent repetitions, for 1,152 passing executions. Twelve deliberate regressions failed at the expected assertions.
  • On the integrated branch, ran the 256 affected bot tests, including the manual slash-retention measurement, and the 15 root case tests. Four gateway ordering tests also passed after integrating Synchronize bot worker and launcher timing tests #1192. The first integration passed another 160 stats and pacing executions.
  • The review repair starts each latency check at the operation and checks the absolute deadline on completion. SQLite signals from its native transaction authorizer while registration runs. Image capture publishes a per-bot signal even from another task, and the mock ban remains pending until released. All four repaired tests passed 20 serial and 12 contention executions each. Setup delays passed. Deliberately blocking the final stats render, stalling the synchronous status render, retaining the registration lock across SQL, or spawning capture before ban completion each failed its intended assertion.
  • Ran cargo fmt --check, cargo clippy --locked -p jmodguard-bot -p jmodguard --all-targets -- -D warnings, Dylint for both packages and bash scripts/ci-preflight.sh --only contracts. Dylint reported zero assigned findings. The 14 inherited bot and 27 inherited core diagnostics are tracked separately under test: audit CI history for flaky tests and fix them #666.

One earlier module invocation reused mutation build output. It was excluded, and a clean rebuild reproduced the original verified test binary byte for byte. Only executions against verified source are counted.

Summary by Sourcery

Stabilize command and moderation timing tests and remove their resolved flake allowances.

Enhancements:

  • Make command and moderation timing tests deterministic with fixed clocks and event-driven synchronization instead of wall-clock sleeps and polling.
  • Strengthen latency and ordering assertions for stalled case inserts, stats requests, status rendering, gateway audit retries, and image capture.

Build:

  • Add crossbeam-channel as a bot development dependency.

Tests:

  • Remove 39 command and moderation test-flake allowlist entries after their findings are resolved.

@jatmn
jatmn marked this pull request as ready for review December 5, 2026 21:53

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues

Sourcery assessment

Approval pending. 3 findings to address first.

Blocking findings: crates/bot/src/commands/behaviors.rs:2696, crates/bot/src/state.rs:2122, crates/bot/src/spam_actions.rs:1523


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread crates/bot/src/commands/behaviors.rs Resolved
Comment thread crates/bot/src/state.rs Resolved
Comment thread crates/bot/src/spam_actions.rs Resolved
pullfrog[bot]
pullfrog Bot previously approved these changes Dec 5, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No blocking issues. Two latency checks can accept late results.

Approach — Fixed clocks and fixture signals remove timing dependencies while preserving the SQLite and loopback paths the tests exercise.

Reviewed changes — Reviewed all 11 files in the PR.

  • Command timing — Checked the timed-ban clock, slash backoff fixture, and stats and status latency checks.
  • Moderation timing — Traced the paused clocks and signals used by automod, case inserts, gateway audit retries, member-sync pacing, and image capture.
  • Flake allowlist — Reviewed the removal of the 39 entries associated with this work.

Non-blocking

  • The latency tests can pass when the operation exceeds its limit. Tokio polls the inner future first, so a blocking step during final stats rendering can push the operation past 650 ms and still return Ok. The status render starts when the worker sends readiness, and recv_timeout starts when the receiver runs. If the receiver is descheduled between those points, it can accept a buffered result from a render that took longer than 200 ms. Keep the fixture setup outside the timed sections and assert elapsed time around each operation, measuring the status render inside the worker. Stats test · Status test · Pinned Tokio timeout implementation · Rust recv_timeout documentation

Verification was by source inspection. I did not rerun the Rust suite.

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-6.2-sol | 𝕏

@jatmn
jatmn force-pushed the fix/queue-666-command-moderation-fixtures branch from 4cf0327 to 7994c14 Compare December 5, 2026 22:09

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

jatmn commented Dec 5, 2026

Copy link
Copy Markdown
Owner Author

Addressed Pullfrog review 6206300380 in 7994c14. The status test starts and checks its 200 ms deadline on the thread that renders. The stats test retains its 650 ms Tokio watchdog and checks a monotonic deadline again after the future returns. A deliberately blocked final synchronous poll now fails even when Tokio returns the result. Both setup-delay controls passed, and both in-operation delays failed at their original limits.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes since the prior Pullfrog review at 4cf0327.

  • Restored the timing assertions. The stats and synchronous status tests check monotonic deadlines on completion, so a late render fails even if it returns a result. Pinned Crossbeam implementation
  • Verified registration during reconciliation. The fixture holds SQLite in its transaction authorizer while the same-subject ban observation registers, then exercises the busy retry and checks attribution. SQLite authorizer documentation
  • Held the mock ban pending. The per-bot capture probe observes capture from spawned tasks before the fixture releases the ban, then the test checks capture ordering and persistence. Pinned Tokio clock implementation
  • Integrated the allowlist cleanup. The rebased allowlist contains only its two header lines.

cargo fmt --check and bash scripts/ci-preflight.sh --only contracts passed locally. The Rust tests and Dylint were still running in PR CI and were not rerun locally. PR CI run

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

@jatmn
jatmn merged commit bf3a825 into main Dec 5, 2026
23 checks passed
@jatmn
jatmn deleted the fix/queue-666-command-moderation-fixtures branch December 5, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant