Skip to content

test(account): take the per-PC call budget out of the carried-PC keys contract test (red main) - #4743

Merged
devswha merged 2 commits into
mainfrom
fix/list-migrate-poll-spin
Nov 25, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/list-migrate-poll-spin

Conversation

@devswha

@devswha devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the red Integration and browser check on main since e897294 (#4735): src/lib/account/listMigrate.contract.test.ts failed with 429 rate_limited at the last allowDevice of carriedPcGetsKeys.

It is a flake in the new test, not a product regression. The fake account service allows one proven PC 30 list calls per minute (listLimits.pcCallsPerMinute). The test stands the clock still and sets accountListAddPollMs: 0, so how many PC list calls fall into that "minute" depends only on how the PC and the phone interleave. Counted with a temporary probe: 24 to 32 calls per run (/v2/pc/list/log 10-17, /v2/pc/list/attempt 7-11, ...); every run that failed had 32. The budget is not what this test measures, so the test lifts it (listLimits is the instance knob tests already use). No skip, retry or timing change.

Validation

  • Before (origin/main 5832729): the file alone 20 times: 18 pass, 2 fail, both 429 rate_limited.
  • After: the file alone 20 times: 20 pass; 48 runs with 24 at a time (load average ~70 on 128 cores): 48 pass.
  • bun run typecheck: clean. bun run check fast: every step ok (unit 28137 pass, 0 fail); the run then reported "source changed during the check" only because the commit was made while it ran (the tree it checked is this commit's).
  • Not run locally: the full integration suite and browser batteries (CI runs them). Test-only change: no changelog fragment.

… contract test

The test freezes the clock and has the PC step its list add with no pause, so the
number of list calls the PC makes in the fake service's minute depends only on how
the PC and the phone interleave (24 to 32 per run). Past 30 the fake answers 429
rate_limited, and the last allowDevice failed: main's Integration tests went red at
e897294 (2 of 20 solo runs failed locally the same way). The budget is not what
this test measures, so it is lifted for it.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated account migration test limits so results are not affected by timing variations during the flow. No end-user behavior changes.

The carriedPcGetsKeys contract test sets the fake account service’s per-PC call limit to Number.MAX_SAFE_INTEGER. Added comments explain that clock and interleaving behavior affects minute-based call counts.

Changes: Contract test call-limit adjustment

Layer / File(s) Summary
Per-PC call-limit setup
src/lib/account/listMigrate.contract.test.ts
The test sets the fake service’s per-PC call limit to Number.MAX_SAFE_INTEGER. Comments explain why minute-based call counts vary with interleaving.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other

Merge Risk: Minimal · previous review 928e0

This change only makes a flaky contract test deterministic by lifting a fake service's rate limit. It has no production impact and is safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: it updates the carried-PC keys contract test by removing the per-PC call budget, which matches the single-file change that sets the fake service's per-PC call limit to Numb…
Description check Passed The description covers the problem, the cause (test interleaving under a 30-calls-per-minute limit), the change, and detailed validation with before and after results. It does not follow the repositor…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: it updates the carried-PC keys contract test by removing the per-PC call budget, which matches the single-file change that sets the fake service's per-PC call limit to Number.MAX_SAFE_INTEGER. It is specific and conventional, and it also states the reason (red main). It is slightly long at 94 characters, but this does not reduce clarity.

Full details: Description check

Explanation

The description covers the problem, the cause (test interleaving under a 30-calls-per-minute limit), the change, and detailed validation with before and after results. It does not follow the repository template exactly: the Change section lacks an issue link, and the Validation section does not mention contract-test coverage. It also omits a CONTRIBUTING.md reference. These gaps are minor, so the description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 748b529 and 928e093.

Files selected for processing: 1

  • src/lib/account/listMigrate.contract.test.ts

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

@devswha
devswha merged commit 374f625 into main Nov 25, 2026
13 checks passed
@devswha
devswha deleted the fix/list-migrate-poll-spin branch November 25, 2026 14:30
@devswha

devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head d169301b3. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit said it did not review (a limit or a skip) since this head.

Owner chose to merge (2026-11-25): test-only fix for a red-main flake. The gate reviewer's reproduced HIGH (a PC waiting ~50s for the number check spends the per-PC 30/min budget so the last allowDevice gets 429) predates this PR and is fixed in a follow-up before the release. Reviews: gate reviewer (BLOCK on the pre-existing product issue only), Codex adversarial (CLEAR).

devswha added a commit that referenced this pull request Nov 25, 2026
…w after the time the service names (#4750)

## Summary

Closes #4746. A PC that the account move carried into the signed list
with no key gets its keys by the list add and a number checked on a
member device. While it waits for the number it reads the list every few
seconds, and the account service allows one PC 30 list calls a minute
(`MACHINE_LIMITER`, mirrored by `listLimits.pcCallsPerMinute` in the
fake). When the person took about 50 seconds to confirm, the PC's Allow
that followed met `429 rate_limited` and the device was refused
(`auth_failed` / `list_refused`). The gate review of #4743 reproduced it
with the default 3 s poll and the default budget.

- `ListFollow.allow` treats `429 rate_limited` on `/v2/pc/list/entries`
like a busy service: it waits the `retry-after` the service names (1 s
at least, a minute at most) and sends the same signed entry again,
within `LIST_ALLOW_TRIES`. The service counts a PC's call before it
reads it (the real service's `provenPc` -> `byMachine`, the fake's
`v2Pc`), so a 429 placed nothing; the resend is the same signed bytes on
the same head, so an entry is never placed twice (a replay answers
`placed: 0`, another head answers `head_moved`).
- The device's session waits `LIST_ALLOW_MS` for its entry from the
moment `allowDevice` is called (`allowIntoList`). `allowDevice` now
hands `allow` that time, and a wait that would leave less than one try's
time before it ends the Allow instead, so no entry is placed after the
device gave up (found by both reviews of the first commit: two 60 s
waits placed the entry at 121 s).

No HTTP/WS contract or UI change.

## Reviews

- Gate reviewer (first commit): BLOCK, HIGH: retries could place the
entry after the session's 90 s; fixed in the second commit (test: "a
wait the service names that would outlast..."). It also confirmed its
original 49.5 s reproducer now passes with the default poll and budget,
and found no duplicate placement.
- Codex adversarial (gpt-6.2-sol-fast, first commit): BLOCK on the same
HIGH (fixed). MEDIUM: a member-approved join (`awaitMember`) whose log
reads keep meeting 429 can end `not_in_list` after its 30 s wait; LOW: a
60 s throttle on `/v2/pc/list/attempt` before the number shows can
outlast the phone's 30 s wait for the PC's nonce; LOW: test strength
(the rate-limit test now names 2 s, not the 1 s default). The MEDIUM and
the first LOW are other paths of the same budget, left for a follow-up.

## Validation

- New contract tests in `server/account/list-allow.contract.test.ts`:
the rate-limit sequence the gate review traced (entry placed, the read
after it and the resend throttled) fails on origin/main (`auth_failed`
`list_refused`) and passes now; the deadline test times out without the
deadline check and passes with it. The whole file: 55 pass.
- All 140 test files of `server/account/`, `server/relay/` and
`src/lib/account/listMigrate.contract.test.ts`, one per process, four at
a time, on e1b1501: all pass; under load (load average about 100)
these failed only with `herdr session.snapshot timed out after 10000ms`
or a 5 s test timeout and each passed alone right after:
waiting-block-list, witness (2), step2-upgrade (4), unknown-key-signin,
and nine server/relay files. `listMigrate.contract` needs #4743's test
fix: after merging main (e571551) it passed 5 of 5.
- `bun run check fast` at e571551: every step ok (unit 28154 pass, 0
fail).
- `bun run typecheck`: clean.
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