Skip to content

fix(account): Not me claims the account's number of the device it blocks (F6) - #4693

Closed
devswha wants to merge 4 commits into
mainfrom
fix/not-me-block-refused
Closed

devswha wants to merge 4 commits into
mainfrom
fix/not-me-block-refused

Conversation

@devswha

@devswha devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Summary

Staging QA (F6): "Not me" on a new device's notice blocked it on the PC that showed the notice, but the
account service refused the same signed block with a 403. The block never reached the account, so a PC
that was off never got it and the device's sign-in stayed.

Cause. A PC's admit notice carries the PC's own admission number (row.origin.admit_no,
server/account/account-devices.ts), which counts every device that PC ever let in, across pairings
and readmissions. notMeBlocks signed that number as the block's target_no. The account service holds
target_no to its own number of the key and answers 403 unknown_target when they differ. The PCs read
the numbers only as claims and judge by their own order, which is why the PC took the block.

The QA lane confirmed it on staging: the PC's journal admitted the new device as number 5, while the
account's number for it is 4.

This is old, not part of the 0.5.10 list work: v0.5.9 has the same notMeBlocks and the same notice
number. It shows wherever the account's safety route is open and a PC's count runs apart from the
account's numbers.

Fix (client only). The press asks the account service for the target's number
(AccountService.deviceNo, GET /v1/devices, five-second timeout) and signs that as target_no.

  • Who may sign is unchanged: canBlockAdmission still decides, before the lookup, and the account's
    number never widens it (test).
  • If the lookup fails, times out or names no such key, the block is still signed, with the notice's
    number as before. A slow or missing account service never holds a block back from the PCs.
  • The PCs judge as before. The one PC path that reads the claims (a legacy target judged by the account
    order, server/devices.ts commitBlock) expects the account's numbers, which it now gets.
  • A block the account service refuses for good now logs the refusal's code. Before, nothing logged it.
  • A new test pins that a block refused for good does not hold up moving the account onto its list. The
    device leaves the blocked key out and starts the move at once.

Not in this PR

  • The offer gate (canBlockAdmission) still compares this device's account number with the PC's
    admission number. It is left alone because changing it changes who is offered Not me. A PC could put the
    account's number in its notice, but that is a wire change.
  • The fake does not tie a block's signer to the sign-in that registered its key, and the service does.
    A block kept by one sign-in and resent by a later one passes the fake and is refused by the service.
  • The refusal line "The block was refused. Block it again from this device." asks for something that
    cannot work. New wording is proposed to the lead; it needs four i18n files.

Validation

bun run check fast was not run locally: the PC's heavy queue did not open for over an hour (load above 150); ran the typecheck, the convention tests and the touched test files; CI's Fast checks run the unit suite.

  • bun run typecheck: passes.
  • bun test --timeout 60000 on src/components/AccountDeviceNotices.test.tsx,
    src/components/AccountDeviceNotices.list.test.tsx, src/lib/account/fleet-block.test.ts,
    src/lib/account/account.test.ts, src/lib/account/unsentBlocks.test.ts,
    src/lib/account/listMigrate.review.test.ts, src/lib/account/listMigrate.service.test.ts,
    scripts/conventions.test.ts, src/conventions.test.ts, server/conventions.test.ts: 256 pass,
    0 fail.
  • Red first: src/components/AccountDeviceNotices.test.tsx "F6: Not me claims the account's number of
    the device ..." fails on main (commit 6e83d0c alone): the page shows the account's refusal. The test
    drives the page's own press against the fake account service, with an account that has no list and is on
    the migrate switch, four registered keys, and a PC notice that numbers the fourth as 5. It passes with
    the fix.
  • The fake account service needed no change for this case. It refuses a wrong target_no with
    403 unknown_target, as the service does.
  • Skipped: check integration and the browser batteries (lead's decision; no server, shared or
    layout change).

🤖 Generated with Claude Code

devswha and others added 4 commits November 25, 2026 16:14
…a PC numbers the device apart (F6, red)

A device presses Not me on a PC's notice for the account's fourth device, in an account with no
list on the migrate switch. The PC numbers its own admissions (admit_no), so its notice says 5;
the block claims target_no 5 and the account service refuses it 403 unknown_target, while the PC
takes it. Red: the page shows the account's refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cks (F6)

A PC's admit notice carries the PC's own admission number (admit_no), which counts every device
that PC ever let in. The account service holds a block's target_no to its own number of the key
and refused the block (403 unknown_target) whenever the two ran apart, so a PC that was off never
got the block and the device's sign-in stayed.

The press now asks the account service for the target's number (GET /v1/devices, five seconds)
and signs that. Who may sign is unchanged (canBlockAdmission), the PCs still judge by their own
order, and a lookup that fails or names nothing signs as before, with the notice's number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… good

A final refusal of a Not me block was not logged at all, so the staging QA saw a bare 403. The
device's log now names the refusal's code (unknown_target, signer_not_older, ...).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… list (F6)

Pins what the staging QA asked: a block the account service refused for good stays in unsent_blocks
marked refused and its target in own_blocks, the birth goes at once and leaves the blocked key out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 25, 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 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b0f20e7 and 966f381.

Files selected for processing: 9

  • changelog.d/not-me-account-number.md
  • src/components/AccountDeviceNotices.test.tsx
  • src/components/AccountDeviceNotices.tsx
  • src/lib/account/account.test.ts
  • src/lib/account/fleet-block.test.ts
  • src/lib/account/fleet-block.ts
  • src/lib/account/listMigrate.review.test.ts
  • src/lib/account/service.ts
  • src/lib/account/unsentBlocks.ts
  • 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

@devswha

devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Review standing in for CodeRabbit (it skipped this PR)

This PR touches a safety action (the block a device signs for "Not me"), so it gets a read before the merge. I read the whole diff at 966f381.

What I checked

  1. The number the block claims. notMeBlocks now takes the target's number from the account service (GET /v1/devices, the no of the row with the target's key) and falls back to the notice's number when the lookup fails or names nothing. The account service holds target_no to its own number (unknown_target otherwise), and its device list does carry no for every row. Confirmed on staging before the fix: the PC had admitted the target as its number 5 (a pairing at the PC took 1) while the account's number was 4, and the block was refused with 403.
  2. The PC's side is not broken by it. The same record goes to the PCs. A PC judges a block by its own admission order and ignores the claimed numbers, except on the path that denies by the account's order (server/devices.ts, denyByAccountOrder), where it compares the claim with the account's placement: that path wanted the account's number all along. So the part that worked (the open PC blocking at once) keeps working.
  3. Who may block is unchanged. canBlockAdmission still decides whether to sign; the lookup only fills the claim. The signer, its number and the sign-in are as before, and nothing about lifting a block is touched.
  4. A refusal for good is logged with its code (postKept): until now nothing recorded it, which is why this failure carried no code.
  5. A block refused for good does not hold an account's move onto its list (the new test in listMigrate): the plan leaves the target out as removed.

Left for a follow-up (not in this PR)

  • The offer gate (canBlockAdmission: own.no < notice.no) still compares the device's account number with the PC's own admission number. Where the two orders differ the button can be missing, or shown and then refused (signer_not_older). Closing it needs the PC's notice to carry the account's number, a wire change.
  • When the lookup fails the block falls back to the PC's number and can be refused as before; the person then sees "The block was refused. Block it again from this device." A retry of the lookup would be better than the fallback.

No finding that blocks the merge. The staging QA re-runs the same sequence after the merge.

@devswha

devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Closed in favour of #4723, which merges this branch together with the other fixes the signed-list staging QA asked for. Nothing of this pull request was dropped: #4723 is main with these branches merged in. The reason is CI capacity: twelve separate runs and twelve merges, each waiting for Fast checks on a new base, had filled the self-hosted runners for every session.

The description, the tests and the review of this change stay here; #4723's table links back to it.

@devswha devswha closed this Nov 25, 2026
@devswha
devswha deleted the fix/not-me-block-refused branch November 25, 2026 13:00
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