Skip to content

fix(app): It's me resends only for the same sign-in, and a notice closed offline is replayed as closed (S2P-9, S2P-10) - #4370

Merged
devswha merged 6 commits into
mainfrom
fix/s2p-9-10-close-entry
Nov 20, 2026
Merged

devswha merged 6 commits into
mainfrom
fix/s2p-9-10-close-entry

Conversation

@devswha

@devswha devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner

It's me: one sign-in check for resends, and a notice closed offline is replayed as closed (S2P-9, S2P-10)

Behind OVIS_ACCOUNT_OPENS_ALL. The ledgered leftovers of #4367 (its gate was CLEAR; S2P-10 is CodeRabbit's thread PRRT_kwDOUfO9Bc66J8mZ). No new on-screen sentence; no wire schema or frame type change; no grant changes.

Device table rows: OD3, T53; ledger S2P-9, S2P-10.

What changes

  • S2P-9 (a): the It's me resend uses the same strict sign-in check as the refusal: matching sign_in_id when either session has one, else a matching non-empty refresh token. A replaced sign_in_id with the same refresh token, or a session with neither, is no longer sent twice. The first send is unchanged.
  • S2P-9 (b, c): a direct hook test for the feed's onClose; the first S2P-7 test's last step now asserts what it was meant to (the card is gone).
  • S2P-10 (server/account/device-journal.ts): when an open notice is decided, the journal records the decision together with a replay entry in one write. A device that acknowledged the admission and was offline when the PC closed it now gets, on reconnect, the existing device-notice-replay frame with the original notice id, a fresh seq and open: false, which clears the app's refusal and button lock (UI only).

Tests (red first)

  • dcfffcc (63 pass, 3 fail there): a replaced sign_in_id with the same refresh token was resent (2 answers instead of 1); a legacy session with neither id nor token was resent (2 instead of 1); an acknowledged admission closed while the device was offline: the replay returned [] instead of the open: false notice. The onClose hook test, the S2P-7 assertion and the app-side replay test pass on main's code (coverage).
  • a8849c2: the fix.

New exports

None.

Reviews

dori review + omo gate reviewer via relay-hub (t13t); security-triage (t13r) on the journal change.

Validation

bun run check fast on a8849c2 via dori heavy (hosthatch): unit 21132 pass / 0 fail, typecheck, build, generated files, actionlint. bun test on the It's me, notice feed, App notices, device journal, notice contract, its-me route, i18n and conventions files: 154 pass; socket and journal-consumer tests: 43 pass; typecheck 0.

@coderabbitai

coderabbitai Bot commented Nov 20, 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

  • Bug Fixes
    • Admission decisions made while a device is offline are now replayed after the journal reopens, made available to other devices, and stop replaying to the original device once it acknowledges the closure.
    • Device notice retries and refusal tracking now respond more accurately to sign-in changes, including when a refresh token is used.
    • Matching confirmations close the corresponding notice and notify the app with the relevant device and admission details.

The journal now records closed admissions for replay to devices. Client changes update answer retry matching and test reconnect replay, notice closure, and confirmation callbacks.

Changes: Device notice lifecycle

Layer / File(s) Summary
Record and replay closed admissions
server/account/device-journal.ts, server/account/device-journal.test.ts
The journal stores closed admissions within its retention limit and includes them in ordered, deduplicated replay. A decision records the close even if a device already acknowledged the admission.
Match answer retries to sign-in sessions
src/components/AccountDeviceNotices.tsx, src/components/AccountDeviceNotices.test.tsx
Answer retries and refusal indicators use the same session comparison helper. Tests cover sign-in ID changes and sessions without sign-in IDs or refresh tokens.
Handle closed notices and confirmations
src/App.deviceNotices.test.tsx, src/lib/useDeviceNotices.test.tsx, src/components/AccountDeviceNotices.test.tsx
Client tests cover replayed closed notices after reconnect and verify that matching confirmations close notices and invoke the close callback.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • devswha/ovis#4307: Introduces the device-change journal and unseen-notice replay that this change extends.
Merge Risk: Minimal · previous review a8849

This change makes "It's me" resends match the same sign-in and replays a notice closed while a device was offline as closed. No actionable merge-blocking risk was found, and the change is behind a feature flag.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two behavior changes in the PR: the It's me resend is scoped to the same sign-in, and a notice closed offline is replayed as closed. The summary and objectives describe the same tw…
Description check Passed The description follows the template's Change and Validation sections. Change explains the problem, the resulting behavior, and the two fixes (S2P-9 and S2P-10). Validation lists the commands run, the…
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 two behavior changes in the PR: the It's me resend is scoped to the same sign-in, and a notice closed offline is replayed as closed. The summary and objectives describe the same two fixes, so the title matches the main change. It is long (118 characters), but it is still specific.

Full details: Description check

Explanation

The description follows the template's Change and Validation sections. Change explains the problem, the resulting behavior, and the two fixes (S2P-9 and S2P-10). Validation lists the commands run, their results, and the test files. It does not link a maintainer-agreed issue. It also does not mention contract-test coverage for the device-notice-replay frame, although the author says there is no wire schema change. The CONTRIBUTING.md and changelog.d/ items are not addressed.

Resolution

Optional: add a changelog.d/ entry, state whether contract tests were run for the device-notice-replay frame, and link the issue or ledger entry for S2P-9 and S2P-10.

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 579da73 and a8849c2.

Files selected for processing: 6

  • server/account/device-journal.test.ts
  • server/account/device-journal.ts
  • src/App.deviceNotices.test.tsx
  • src/components/AccountDeviceNotices.test.tsx
  • src/components/AccountDeviceNotices.tsx
  • src/lib/useDeviceNotices.test.tsx

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

@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Gate findings at a8849c2: BLOCK (omo gate reviewer; dori CLEAR; t13r YES on access)

S2P-9 passes: replacing sign_in_id while keeping the refresh token no longer sends It's me twice. The four changed suites go from 63/3 on dcfffcc to 66/0 at head, plus 27 related tests; typecheck is clean. Two MEDIUMs on S2P-10, neither an access change. One commit, reds first:

  • MEDIUM: an applied "Not me" bypasses the replay close. The row-drop write removes the admission BEFORE the socket calls decide(), so an observer offline at the time gets an empty replay and keeps the card open (device-journal.ts:219-229; socket.ts:229-230). Fix: record the admission's replay close in the same write that removes it.
  • MEDIUM: rotation leaves a stale admission actionable. After 1000 later events trim the close, the reconnect reports cut:1 and no open admission, but the client keeps its old open card (device-journal.ts:211-217; deviceNotices.ts:35-46). Fix: when the replay reports lost history, reconcile retained actionable notices against the PC's current open set.
  • dori LOWs: devices.ts:2579-2585; device-journal.ts:136-140 (settleList), 263-273. Fold them in if they're still true.

@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Round 1 (gate at a8849c2) -> 32e6579

Red: 9312b70 (22 pass, 3 fail there). Fix: 32e6579. No access, wire-schema or copy change.

  • MEDIUM 1: Not me's row drop and the same-id open: false replay entry are written in ONE journal write, so an observer that acknowledged the admission and was offline gets the close on reconnect. Red: the observer received [] instead of the closed notice.
  • MEDIUM 2: a reconnect replay with cut > 0 (history rotated past the close) reconciles the device's retained cards against the PC's current open set: cards the PC no longer has open go, with their refusal and button lock; cards still open stay (also when a live notice arrives after). Reds: after rotation the refused case kept button states [false, false] and the locked case [true, false]; both now [false] for the surviving card.
  • An existing test updated (server/account/account-drop-recovery.test.ts, "offline Revoke recovery allocates no new drop after the original is trimmed"): it counted one journal entry per drop; the drop now also writes its replay-only close, so the first retained entry moved by one. The test still asserts its intent explicitly: the original drop is trimmed, the restart removes the row, and no replacement drop is written.

Validation: bun run check fast on 32e6579 via dori heavy (hosthatch): unit 21134 pass / 0 fail, typecheck, build, generated files, actionlint. bun test ./server/account: 920 pass, 1 skip (needs Linux root).

@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Gate findings at 32e6579: BLOCK (round 2; gate + dori MEDIUM, same path; t13r YES on access)

Fixed and verified: the ordinary listed-row drop writes its close atomically; both rotation cases clear the stale refusal and lock; 115 tests pass; S2P-9 holds.

  • MEDIUM (gate + dori, device-journal.ts decide :268, row-delete path :213-215; list-notices.ts:23): when a listed admission has TRANSFERRED to a paired member while its notice is still open, an applied "Not me" removes the device (access is correctly denied), but the member-removal path (devices.ts:2512-2515) journals no close for the carried admission, and the open-filter drops it silently (device-journal.ts:136-139). The offline observer reconnects with cut:0 and keeps an actionable card. Fix: persist the same-id close in the journal write that removes that notice, on EVERY path that removes an open notice (row drop, member removal, decide), and extend notice-answer-authority.contract.test.ts:13-52 to a transferred target.
  • dori LOWs: App.deviceNotices.test.tsx:7 and :298-342.
    Round 3 is the cap.

@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Round 2 (gate at 32e6579; the last round) -> abc334f

Red: 2cf3168 (29 pass, 15 fail there). Fix: abc334f. No access, wire-schema or copy change.

  • MEDIUM: a Not me on an admission that transferred to a paired member now writes the close for the carried notice in the same journal write as the removal. An observer that acknowledged it and was offline gets the same-id open: false replay on reconnect.
  • Every path that takes a notice out of the open set was audited and now writes its close in that same write:
    • paired-member removal: Not me / block, Revoke, Revoke all, lock teardown, signed self-leave (the exact held or carried notice);
    • listed-row removal: receipt-backed block, Revoke, Revoke all, signed removal (already atomic), and, newly, list changes, catch-up rejection, idle expiry, PC leave and identity reset even without a receipt;
    • other journal removals: key-only local recovery, legacy admission-id replacement, owner reconciliation (screen-confirmed promotion, orphan cleanup, interrupted Revoke-all recovery);
    • explicit decisions: decide() writes a same-id close; It's me keeps its atomic, replayable confirmation; a transfer that carries the notice forward does not close it.
  • Reds: transferred Not me, key-only recovery and resumed Revoke all returned [] instead of the close; four paired-removal cases and five receipt-less listed drops still showed open: true at the removal write; screen promotion and legacy id replacement had no matching notice; orphan reconciliation omitted the orphan's close.

Validation: bun run check fast on abc334f via dori heavy (hosthatch): unit 21140 pass / 0 fail, typecheck, build, generated files, actionlint. bun test ./server/account: 933 pass, 1 skip (needs Linux root).

@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Final gate round at abc334f (round 3, the cap): no HIGH, no LOW. The transferred Not me is fixed (removal + same-id close in one write; the offline observer gets open:false). One MEDIUM ledgered as S2P-11: an accepted It's me writes no same-id close for the original admission; the app already removes that card by other fields, and access is correct. 134 tests pass. dori CLEAR. Merges on t13r's YES and green CI. Relay-hub.

@devswha
devswha merged commit c0f19ee into main Nov 20, 2026
24 checks passed
@devswha
devswha deleted the fix/s2p-9-10-close-entry branch November 20, 2026 22:15
@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head abc334fe6. 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.

Reviews at abc334f: dori CLEAR (receipt devswha__ovis_4370@abc334fe6); omo gate reviewer (gpt-6.2-astra) final round 3: no HIGH, no LOW; one MEDIUM ledgered as S2P-11 (an accepted It's me writes no same-id close for the original admission; the app removes the card by other fields, access correct). security-triage (t13r) YES on access at abc334f: a list notice closes only in the same journal write as the removal of that exact row; notices and replay only, no grant changes. Closes S2P-9 and S2P-10. Relay-hub.

devswha added a commit that referenced this pull request Nov 20, 2026
…for devices that were offline (S2P-11) (#4383)

## It's me: an accepted It's me also closes the original admission for
devices that were offline (S2P-11)

Behind `OVIS_ACCOUNT_OPENS_ALL`. The ledgered leftover of #4370's final
round (no HIGH there), plus two of dori's LOWs on #4370. No access,
wire-schema or copy change.

Device table rows: **OD3, T53, T57**; ledger S2P-11.

### What changes (server/account/device-journal.ts, the app's notice
feed)
- **S2P-11:** an accepted It's me now writes the T53 confirmation and
the original admission's same-id `open: false` close in one journal
replacement. A device that acknowledged the admission and was offline
gets that id closed on reconnect. The app folds the close into its
matching confirmation, so the admission card never reappears.
- **dori LOW (decide on a broken journal):** when the journal is already
strict, `decide()` throws without overwriting the stored cause; only a
real write failure records a new message.
- **dori LOW (journal cap):** `JOURNAL_MAX` now says that close entries
count toward the cap (unchanged).
- dori's third LOW was #4370's PR body (the validation line named an
older head); this body names its own head.

### Tests (red first)
- d08c2d3 (3 fail there): the It's me route replay had only the
confirmation, not the original id with `open: false`; a strict journal's
second `decide()` wrapped the original `EISDIR` cause in another
message; the client feed still held the closed admission's id after
replay.
- df98318: the fix.

### New exports
None.

### Reviews
dori review + omo gate reviewer via relay-hub (t13t); security-triage
(t13r) on the journal change.

### Validation
`bun run check fast` on df98318 via dori heavy (hosthatch): unit 21516
pass / 0 fail, typecheck, build, generated files, actionlint. `bun test
./server/account`: 934 pass, 1 skip (needs Linux root);
`src/components/AccountDeviceNotices.test.tsx`,
`src/App.deviceNotices.test.tsx`, `src/lib/useDeviceNotices.test.tsx`,
`server/conventions.test.ts`: 72 pass; typecheck 0.
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