Skip to content

Make the multi-recipient inbox benchmark test deterministic - #1220

Merged
dahlia merged 1 commit into
fedify-dev:2.3-maintenancefrom
dahlia:bugfix/deterministic-inbox-rotation-test
Oct 3, 2026
Merged

dahlia merged 1 commit into
fedify-dev:2.3-maintenancefrom
dahlia:bugfix/deterministic-inbox-rotation-test

Conversation

@dahlia

@dahlia dahlia commented Oct 3, 2026

Copy link
Copy Markdown
Member

Fixes #1218.

Why it flaked

The runner assigns recipients round-robin by signing index, and that part is correct. The test, though, guaranteed neither enough deliveries nor a balanced split. A slow first round on CI could leave the 300ms closed-loop run with only one or two deliveries. In the default pipeline mode, four concurrent signers fill the buffer in completion order, so every dispatched request could target Alice.

How it's fixed

The test now schedules exactly four attempts: constant open-loop arrivals at 10/s over 400ms, under the fake clock pattern from failure.test.ts. Delivery and signature verification stay real; only the schedule is detached from wall-clock time. The open loop doesn't wait on completions to decide when to stop, so a failing request shows up as a failed assertion rather than a hang.

It runs in both jit and presign modes. Each attempt uses exactly one allocation index, so each recipient gets two deliveries regardless of completion order. Presign signs four requests and the run consumes all four, which keeps buffered-mode coverage. Default pipeline mode can't promise that split because it consumes an arbitrary prefix of a 256-entry buffer.

The target counts POSTs per inbox path, and the test asserts exactly two for each recipient instead of just checking that both were hit. Breaking the rotation makes both tests fail.

No CHANGES.md entry for this test-only change. The warm-up test in the same file has a similar timing dependency, tracked in #1219.

@dahlia dahlia self-assigned this Oct 3, 2026
@dahlia dahlia added component/cli CLI tools related runtime/node Node.js runtime related component/ci CI/CD workflows and GitHub Actions labels Oct 3, 2026
The "rotates deliveries across multiple recipients" test failed
intermittently on CI with only Alice's inbox hit.  It ran a closed-loop
load for a 300ms real-clock window with the default pipeline signing
mode, and neither part guaranteed that Bob's inbox would see a delivery:

- The closed-loop workers stop dispatching once the real-time
  deadline passes, so a slow first round (a cold target dereferencing
  the synthetic actors, the baseline stats request, CI scheduling)
  could leave only one or two deliveries.

- The runner allocates recipients round-robin by signing index, but
  pipeline mode fills its buffer from four concurrent signers in
  completion order, so the prefix actually dispatched can contain
  only one recipient's requests.

The runner itself allocates correctly; only the test's assumptions were
wrong.  The test now makes a fixed number of attempts: four constant
open-loop arrivals (10/s over 400ms) under a fake clock, so the count no
longer depends on real time.  It runs once with jit signing and once
with presign signing.  In both modes each attempt consumes exactly one
allocation index (presign signs exactly the four requests and the run
consumes them all), so the deliveries split exactly two per recipient
regardless of completion order.  The target now counts POSTs per inbox
path so the test can assert that exact split.

Fixes fedify-dev#1218

Changelog: none
Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Codex:gpt-6-astra
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
CONTRIBUTING.md — configured

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e0acdc91-a212-4730-8ed7-952a4be2b859
📥 Commits

Reviewing files that changed from the base of the PR and between 0e1fc88 and f365df5.

📒 Files selected for processing (1)
  • packages/cli/src/bench/scenarios/inbox.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The inbox benchmark test target now counts POSTs per inbox path. The allocation test uses a fake clock to check delivery counts for JIT and presigned signing.

Changes

Inbox allocation tests

Layer / File(s) Summary
Controlled recipient allocation checks
packages/cli/src/bench/scenarios/inbox.test.ts
The benchmark target counts POSTs per inbox path. A shared helper runs a four-arrival fake-clock scenario for each signing mode and verifies four successful deliveries, with two POSTs to each personal inbox.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to f365d

The allocation test reliably checks four deliveries and an even split between recipients. It is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making the multi-recipient inbox benchmark test deterministic.
Description check ✅ Passed The description explains why the test flaked and how the change makes delivery scheduling and recipient-count assertions deterministic.
Linked Issues check ✅ Passed Issue #1218 requires deterministic recipient-rotation coverage without a 300ms real-clock delivery window. packages/cli/src/bench/scenarios/inbox.test.ts now uses a fake clock to schedule four arriv…
Out of Scope Changes check ✅ Passed The reported changes are limited to the inbox benchmark test. Counting POSTs by inbox path and exercising the four-delivery allocation in both signing modes directly support issue #1218. No unrelated …
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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.

@dahlia
dahlia force-pushed the bugfix/deterministic-inbox-rotation-test branch from 34db2c1 to f365df5 Compare October 3, 2026 16:58
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.
see 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dahlia
dahlia merged commit db3f75f into fedify-dev:2.3-maintenance Oct 3, 2026
17 checks passed
@dahlia
dahlia deleted the bugfix/deterministic-inbox-rotation-test branch October 3, 2026 23:01
@dahlia dahlia linked an issue Oct 4, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/ci CI/CD workflows and GitHub Actions component/cli CLI tools related runtime/node Node.js runtime related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the multi-recipient inbox benchmark test deterministic

1 participant