Skip to content

test(mobile): an offline cold start reads the grants of the last manifest accepted (OTA phase D, finding 7) - #22175

Merged
Jinwoo-H merged 4 commits into
mainfrom
ota-d2-offline-grants
Sep 22, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
ota-d2-offline-grants

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​323 $\color{#cf222e}{\Huge{\mathbf{−}}}$​149 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​174
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​161 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​161

Summary

Closes finding 7 from #21503 (offline route/grant staleness, deferred to Phase D) with a verdict test: D1 (#22139) already fixed it end to end. No product change; the test is the evidence and the guard.

mobile/src/mobile-web-shell/mobile-web-shell-offline-grant-staleness.test.ts mounts the real useMobileWebShellSession over the real createGenerationStore on an in-memory disk. Only the RPC transport and the platform modules vitest cannot load are doubled. Generation G is written by the store's own stage-and-commit, each mount mints a fresh store sharing nothing but the on-disk tree, and every fixture is parsed through MobileWebBundleManifestReadSchema, so the build id really is the digest of the assets and a manifest the phone could not have received is refused rather than measured. goOffline() clears the staged manifest as well as the connection, so a mount that reached the host would fail its flow instead of agreeing with disk by accident.

Four arms, all green on main:

  • Grants A widen to A+B online; the offline cold start reads A+B.
  • A+B narrows to A; the offline cold start reads A, so a revoked capability does not survive the host going away.
  • No online read ever reaches the phone; the offline verdict is A.
  • A+B arrives under a wall; nothing is written, not even the pending half of a swap, and the offline verdict is A. An offline entry runs no compat check, so disk must hold the last manifest this shell accepted.

Mutation evidence: dropping the reducer's persist-manifest effect fails arms 1 and 2; skipping store.persistActiveManifest in the runner fails arms 1 and 2; making the wall arm persist fails arm 4.

The store suite's in-memory file system moves to generation-file-system-fake.ts so both suites drive the real store against one fake; a leftover aliased type name from the extraction is fixed in its own commit (tests are outside tsconfig.json, so only the ratchet saw it).

Recorded for later, outside this finding: an already-mounted session never re-reads the manifest on a reconnect (gates-changed starts a flow only when the state awaits gates), so a grant edit reaches a live page on its next mount. Pre-existing; noted in the plan's follow-ups.

Verification

Lane on the merged head: mobile tsc 0, ratchet 0 (811 files), full mobile 815 files / 9,066 passed, config/scripts 252 files, oxfmt 0, oxlint 0, anti-slop 0, changed-code quality 0 across 10 files, React Doctor 0.

Lead gate on ce92347 against 90d363a (gate-d2-ce92347252.log): tsc 0, ratchet 0, changed-code quality 0, react-doctor 0, anti-slop 0, max-lines 0, root-oxlint 0 (3 files), config/scripts 252 passed / 2 skipped, mobile 815 passed, machine-paths 0.

The fake answers the file-system port the store is written against, and the
offline-grant suite drives the same real store against it. Two in-memory trees
answering one port differently is how a passing suite stops being evidence.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…fest accepted

Finding 7 on #21503 end to end: the reducer, the runner, the real generation
store and a disk, with only the network and the platform modules doubled. A
grant-only edit keeps the bundle's build id, so the cached assets are right
under a manifest an edit behind; the verdict measured here belongs to a second
mount whose whole evidence is the tree on disk.

Both directions of the edit and both arms: a widened grant list reaches the
offline verdict, a revoked one is gone from it, and a manifest read under a wall
is not written, so offline keeps the last grants this shell could use.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The store suite still spelled the local type name. `tsconfig.json` excludes test
files, so only the tests-typecheck ratchet sees this.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ca7f9a66-4282-4839-a21f-81f3a3f39002

📥 Commits

Reviewing files that changed from the base of the PR and between 8568d77 and ce92347.

📒 Files selected for processing (3)
  • mobile/src/mobile-web-shell/generation-file-system-fake.ts
  • mobile/src/mobile-web-shell/generation-store.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-offline-grant-staleness.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a shared in-memory GenerationFileSystem fake with storage inspectors and fault injection. Existing generation-store tests use the shared fake. A new end-to-end test covers grant-only manifest edits across online and offline cold starts, including revoked grants, no prior online read, and unknown manifest schemas.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to ce923

This change adds offline grant coverage and refactors test-only filesystem support without changing shipped product behavior, so it has no identified production impact and is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides a detailed summary, rationale, linked issue reference, and verification results. However, it omits most required template sections, including ELI5, What Changed, Why, Linked I… Update the description to include all required template sections. Add concise ELI5, What Changed, and Why sections; use the Linked Issue section with the required issue reference; add Visual Proof with N/A and a reason because there is no U…
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: tests for offline cold starts that read grants from the last accepted manifest. It is specific and related to the pull request, although it is somewhat lo…
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: Description check

Explanation

The description provides a detailed summary, rationale, linked issue reference, and verification results. However, it omits most required template sections, including ELI5, What Changed, Why, Linked Issue with a Fixes entry, Visual Proof with an N/A explanation, Testing, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Update the description to include all required template sections. Add concise ELI5, What Changed, and Why sections; use the Linked Issue section with the required issue reference; add Visual Proof with N/A and a reason because there is no UI change; add a Testing section with the automated and manual test status; complete Review, Agent skill upstream boundary, Notes, and Checklist sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

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

This test-only PR closes finding 7 of #21503 with an end-to-end guard; the behavior it pins was already shipped by D1 (#22139), so nothing here changes the product.

  • Four-arm offline verdict suite — mobile-web-shell-offline-grant-staleness.test.ts mounts the real session hook over the real store over an in-memory disk, and asserts the offline cold start reads the grants of the last manifest the shell accepted (widen, revoke, never-read, and edit-under-a-wall).
  • Shared disk fake extracted — the in-memory GenerationFileSystem moves to generation-file-system-fake.ts so both suites drive the real store against one fake; behavior is identical to the inline version.
  • Guard verified, not assumed — I confirmed the suite can fail: replacing the reducer's persist effect with [] in mobile-web-shell-session.ts fails arms 1 and 2 (storedRouteGrants at line 238, and routeGrants at line 266). Both touched suites pass locally (44 tests).

Worth noting the fixture discipline is what makes this real coverage rather than theatre: each mount mints a fresh store, goOffline() clears the staged manifest as well as the connection, and fixtures are parsed through MobileWebBundleManifestReadSchema so the build id is genuinely the asset digest.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit ed90984 into main Sep 22, 2026
24 of 25 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-d2-offline-grants branch September 22, 2026 07:51
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