Skip to content

chore(mobile): RPC foundation step 0 inventory, manifests, and fail-closed checker - #19833

Closed
Jinwoo-H wants to merge 15 commits into
mainfrom
rpc-lane-a-step0
Closed

Jinwoo-H wants to merge 15 commits into
mainfrom
rpc-lane-a-step0

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​572 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​572
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1680 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1679

Summary

Step 0 of the mobile RPC contract foundation: the inventory, manifests, regression seeds and read-only checker the later steps are gated on. No product behavior changes. The only source edit is the git request path, which keeps its original method, params and response handling and gains 23 literal descriptor records.

What lands

  • Read-only checker mobile/scripts/rpc-foundation-check.mts (script pnpm --dir mobile rpc-foundation:check). Implements the full step0 flag contract and fails closed on any missing, stale or incomplete artifact. step0_5 / step1 / step2 / step3 validate their flag names and exit 2 as unimplemented. The two lane B checks (--require-gate-fail-closed, --require-below-floor-block-e2e) fail unless --allow-lane-b-deferred is passed; drop that flag once feat(mobile): retire protocol-2 pairings and fail closed on unverified host compatibility #19821 merges.
  • Access inventory via the TypeScript compiler API: 1,613 references across 291 files, including aliases, destructuring, bracket constants, bound senders, listener callbacks and transport forwards. Dynamic families are resolved either by walking their callers to a literal method set or as inventoried transport exceptions carrying owner, policy and scenario ids. Converting them to descriptors is step 4, not this PR.
  • Support-floor manifest, derived from the protocol constants and git tags rather than typed by hand, with historical DESKTOP_PROTOCOL_VERSION alias handling, source SHAs, both compatibility directions, and the owner's retirement decision recorded verbatim. Tags with no protocol constant file are recorded as excluded with their SHAs instead of being assigned an invented protocol.
  • Named-deltas ledger: seven reference-only entries (four disclosed deltas and three fixed bugs from refactor(mobile): route screen RPC through host operation adapters #19669, which is not merged) plus one main-only ticket, new-workspace-runtime-context-null-settings-typeerror, found by lane C's reply matrix and left unfixed by design.
  • Ratchet ported to main with its baseline regenerated: 155 files / 413 lexical hits, four deliberate-inline pins kept, zero routed-zero assertions (main has no adapters).
  • b1/b2/b3 regression seeds that pass on main and fail against the pinned bcba08b3e4 adapter sources.
  • Settings slice manifest pinned to PR refactor(mobile): extract settings, diagnostics and editor-document screens from their routes #19675 head dc423947f4: 45 records, 35 recordable host RPC, 10 non-recordable device preferences. prDiffBase and mainBaseline are distinct fields.
  • Native census: 7 native source files, zero host-RPC construction candidates.
  • Step 0.5 TODO with the 3 existing requireSuccess definitions and 403 candidate predicate expressions, each with file:line.

Derived floors

Namespace At minimum 2 (today) At minimum 3 (after #19821)
desktop stable v1.3.51 v1.4.5
mobile-v* mobile-v0.0.7 mobile-v0.0.8
mobile-ios-v* mobile-ios-v0.0.15 mobile-ios-v0.0.15
mobile-android-v* mobile-android-v0.0.14 mobile-android-v0.0.14

This branch keeps all three minimums at 2; #19821 moves them. Regenerate support-floor.json after that merges.

Passing invocation

ORCA_BACKGROUND_LAUNCH=1 pnpm --dir mobile rpc-foundation:check step0 \
  --inventory access-inventory.json --support-floor support-floor.json --deltas named-deltas.json \
  --baseline e80fae0c4d --regression bcba08b3e4 \
  --require-all-current-calls --require-no-dynamic-calls --require-regressions b1,b2,b3 \
  --require-floor-derived-from-protocol-gate --require-retirement-decision \
  --require-gate-fail-closed --require-below-floor-block-e2e --allow-lane-b-deferred \
  --slice settings-19675.json --pr-head dc423947f4 --require-native-rpc-inventory

Verified by the lead on the committed tree: step0: all requested checks passed.

Gates

Gate Result
pnpm --dir mobile typecheck exit 0, no diagnostics
pnpm --dir mobile test (full) 522 files, 4247 passed, 3 skipped
oxfmt --check on 26 changed files all correctly formatted
check:code-quality:changed 0 new findings across 17 files
check:react-doctor:changed 0 issues

Root pnpm tc is not applicable: nothing outside mobile/ changed. The .mts scripts, which mobile's normal include globs exclude, were typechecked directly and exit 0.

Limits

Step 0.5 policy consolidation is not implemented; see STEP0_5-TODO.md. Steps 1 to 3 are stubs. Settings scenario ids are planned, not executed coverage, and the manifest's consumed-fields are conservative enclosing-function expressions, so they are inventory evidence rather than approved reader definitions. The native census reads checked-in code and ABI declarations; it is not a runtime test.

Plan of record: mobile RPC contract foundation v7. Merge after #19821.

Record main-only settings bug and leave the acceptance consolidation census for step 0.5.

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

@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

  • Fail-closed checker — mobile/scripts/rpc-foundation-check.mts implements the full step0 flag contract, regenerating and deep-comparing each artifact in --check mode; step0_5/step1/step2/step3 validate flag names and exit 2 as unimplemented, and the lane-B flags fail unless --allow-lane-b-deferred is passed.
  • Access resolution engine — rpc-access-resolution.mts follows aliases, destructuring, bracket constants, bound senders and forwarder callers through the TS compiler API, failing closed on unresolved/dynamic calls (1,613 references across 291 files).
  • Artifact generators — rpc-support-floor.mts (floors derived from protocol constants and git tags), rpc-slice-manifest.mts (settings slice pinned to PR #19675), rpc-native-inventory.mts, rpc-acceptance-census.mts, plus shared rpc-artifact-io.mts --check/emit plumbing.
  • Regression seeds + ratchet — b1/b2/b3 seeds that pass on main and fail against the pinned bcba08b3e4 adapter sources, with provenance in named-deltas.json/regression-seeds.json/reference-regressions.json; screen-rpc-ratchet.test.ts pins the 155-file/413-hit baseline.
  • Sole source edit — use-mobile-git-requests.ts routes through mobileGitOperationDescriptors[method]?.method ?? method (23 descriptor records), an identity transform today that preserves method, params and response handling.

ℹ️ The fail-closed checker is not enforced anywhere

No CI workflow is changed in this PR, so pnpm --dir mobile rpc-foundation:check runs only by hand. It also shells out to git show/git tag/git rev-parse on historical SHAs, which needs a non-shallow clone with tags. If step 0 is meant to gate the later steps, the enforcement path (and the clone depth it runs on) is still open.

ℹ️ The screen ratchet pins token counts, not call sites

RPC_ENTRY_POINT (\bsendRequest\b …) matches declarations, type references and comments as well as real calls, so the 413 pinned hits are lexical occurrences rather than semantic RPC call sites. Future churn — a rename, a new comment, a refactor that moves sendRequest into a helper — will move the counts without any real RPC change. Worth confirming that noise level is acceptable before it becomes merge-blocking for unrelated mobile work.

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

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 7da275f1-55c5-4f8b-b9d1-aa551e19719f

📥 Commits

Reviewing files that changed from the base of the PR and between 1cfd6ab and d08c258.

📒 Files selected for processing (5)
  • mobile/rpc-foundation/access-inventory.json
  • mobile/scripts/rpc-access-inventory.mts
  • mobile/scripts/rpc-access-resolution.mts
  • mobile/scripts/rpc-artifact-io.mts
  • mobile/src/transport/rpc-access-resolution.test.ts

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


📝 Walkthrough

Walkthrough

Adds a mobile RPC foundation check command and supporting artifacts. The change adds TypeScript RPC access resolution, call-site inventory generation, native source inventory generation, and inline RPC ratchet tests. The Step 0 checker validates Git provenance, generated artifacts, regression seeds, and Vitest JSON results. Reference probes execute historical code for three regression cases. Focused tests cover stale file-search responses, merge results, comments transport errors, and resolver behavior.

Merge Risk: 🟡 Moderate · up to d08c2

This change does not alter product behavior, but its foundation checker can still accept incomplete or misleading RPC and regression evidence. The validation gaps should be addressed before relying on the checker as the contract baseline.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides detailed scope, rationale, implementation details, testing results, limitations, and merge conditions. However, it omits required template sections, including the linked issue… Add the missing template sections and complete the required information. Include a valid Fixes #<issue> reference, state N/A with a reason under Visual Proof because there is no UI or interaction change, complete the Testing checkboxes,…
Docstring Coverage ⚠️ Warning Docstring coverage is 15.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 17 files. (1 skipped:… 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 summarizes the main changes: the mobile RPC foundation step 0 inventory, manifests, and fail-closed checker.
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 detailed scope, rationale, implementation details, testing results, limitations, and merge conditions. However, it omits required template sections, including the linked issue with a Fixes # reference, Visual Proof with N/A and a reason, Testing checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Add the missing template sections and complete the required information. Include a valid Fixes #&lt;issue&gt; reference, state N/A with a reason under Visual Proof because there is no UI or interaction change, complete the Testing checkboxes, provide the AI Disclosure or leave it explicitly applicable per repository policy, complete the Review and Agent skill upstream boundary sections, address Notes, and complete the Checklist.

Full details: Docstring Coverage

Explanation

Docstring coverage is 15.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 17 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b671fd6b-4c18-4d44-a9cb-020c88328f2d

📥 Commits

Reviewing files that changed from the base of the PR and between aac38d6 and 0a1eadd.

📒 Files selected for processing (26)
  • mobile/package.json
  • mobile/rpc-foundation/STEP0_5-TODO.md
  • mobile/rpc-foundation/access-inventory.json
  • mobile/rpc-foundation/named-deltas.json
  • mobile/rpc-foundation/native-rpc-inventory.json
  • mobile/rpc-foundation/reference-regressions.json
  • mobile/rpc-foundation/regression-seeds.json
  • mobile/rpc-foundation/settings-19675.json
  • mobile/rpc-foundation/support-floor.json
  • mobile/scripts/rpc-acceptance-census.mts
  • mobile/scripts/rpc-access-inventory.mts
  • mobile/scripts/rpc-access-resolution.mts
  • mobile/scripts/rpc-artifact-io.mts
  • mobile/scripts/rpc-foundation-check.mts
  • mobile/scripts/rpc-native-inventory.mts
  • mobile/scripts/rpc-reference-regressions.mts
  • mobile/scripts/rpc-slice-manifest.mts
  • mobile/scripts/rpc-support-floor.mts
  • mobile/src/session/use-mobile-native-chat-file-search.test.ts
  • mobile/src/source-control/mobile-git-operation-descriptors.ts
  • mobile/src/source-control/use-mobile-git-requests.ts
  • mobile/src/tasks/use-mobile-tasks-item-detail-loading.test.ts
  • mobile/src/tasks/use-mobile-tasks-project-file-merge-actions.test.ts
  • mobile/src/transport/rpc-access-resolution.test.ts
  • mobile/src/transport/rpc-operation-descriptor.ts
  • mobile/src/transport/screen-rpc-ratchet.test.ts

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

Comment on lines +96 to +97
if (!Array.isArray(ledger.entries) || ledger.entries.length < 7) {
throw new Error('Incomplete named deltas')

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Validate required delta IDs and reject duplicate IDs.

The length check does not prove that the ledger contains each required named delta. A ledger with seven copies of one valid entry passes this check and the later shape checks.

Check the required ID set and ID uniqueness before the checker reports success.

Proposed validation
-  if (!Array.isArray(ledger.entries) || ledger.entries.length < 7) {
+  const requiredDeltaIds = [
+    'retired-names-refused-read',
+    'linear-select-workspace-refusal',
+    'malformed-error-operation-name',
+    'stop-ref-layout-effect',
+    'b1-stale-files-inventory',
+    'b2-null-project-mutation',
+    'b3-linear-settlement-order'
+  ]
+  const deltaIds = new Set(
+    Array.isArray(ledger.entries) ? ledger.entries.map((entry: { id?: string }) => entry.id) : []
+  )
+  if (
+    !Array.isArray(ledger.entries) ||
+    deltaIds.size !== ledger.entries.length ||
+    requiredDeltaIds.some((id) => !deltaIds.has(id))
+  ) {
     throw new Error('Incomplete named deltas')
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!Array.isArray(ledger.entries) || ledger.entries.length < 7) {
throw new Error('Incomplete named deltas')
const requiredDeltaIds = [
'retired-names-refused-read',
'linear-select-workspace-refusal',
'malformed-error-operation-name',
'stop-ref-layout-effect',
'b1-stale-files-inventory',
'b2-null-project-mutation',
'b3-linear-settlement-order'
]
const deltaIds = new Set(
Array.isArray(ledger.entries) ? ledger.entries.map((entry: { id?: string }) => entry.id) : []
)
if (
!Array.isArray(ledger.entries) ||
deltaIds.size !== ledger.entries.length ||
requiredDeltaIds.some((id) => !deltaIds.has(id))
) {
throw new Error('Incomplete named deltas')

Comment thread mobile/scripts/rpc-support-floor.mts Outdated
Comment on lines +43 to +140
const tags = (
await git(
'tag',
'--list',
'v*',
'mobile-v*',
'mobile-ios-v*',
'mobile-android-v*',
'--sort=version:refname'
)
).split('\n')
const namespaces = [
{
name: 'desktop-stable',
pattern: /^v\d+\.\d+\.\d+$/,
file: desktopPath,
protocol: 'RUNTIME_PROTOCOL_VERSION',
minimum: mobile.MIN_COMPATIBLE_DESKTOP_VERSION
},
{
name: 'desktop-rc',
pattern: /^v\d+\.\d+\.\d+-rc(?:[.-]?\d+)?$/,
file: desktopPath,
protocol: 'RUNTIME_PROTOCOL_VERSION',
minimum: mobile.MIN_COMPATIBLE_DESKTOP_VERSION
},
...['mobile-v', 'mobile-ios-v', 'mobile-android-v'].map((prefix) => ({
name: `${prefix}*`,
pattern: new RegExp(`^${prefix}\\d+\\.\\d+\\.\\d+(?:-rc[.-]?\\d+)?$`),
file: mobilePath,
protocol: 'MOBILE_PROTOCOL_VERSION',
minimum: desktop.MIN_COMPATIBLE_RUNTIME_CLIENT_VERSION
}))
]
const floors = []
for (const namespace of namespaces) {
const candidates = tags.filter((tag) => namespace.pattern.test(tag))
if (!candidates.length) {
throw new Error(`No tags for ${namespace.name}`)
}
const inspected = []
let floor: unknown, atMinimum3: unknown
for (const tag of candidates) {
const sha = await git('rev-parse', `${tag}^{commit}`)
let source: string
try {
source = await git('show', `${sha}:${namespace.file}`)
} catch {
inspected.push({ tag, sha, excluded: 'protocol constant file absent' })
continue
}
const values = constants(source)
const version = values[namespace.protocol] ?? values.DESKTOP_PROTOCOL_VERSION
if (!Number.isInteger(version)) {
throw new Error(`Missing protocol at ${tag}:${namespace.file}`)
}
const peerMinimum =
namespace.file === desktopPath
? (values.MIN_COMPATIBLE_RUNTIME_CLIENT_VERSION ?? values.MIN_COMPATIBLE_MOBILE_VERSION)
: values.MIN_COMPATIBLE_DESKTOP_VERSION
if (!Number.isInteger(peerMinimum)) {
throw new Error(`Missing peer minimum at ${tag}`)
}
const clientProtocol =
namespace.file === desktopPath
? mobile.MOBILE_PROTOCOL_VERSION
: desktop.RUNTIME_PROTOCOL_VERSION
const evidence = {
tag,
sha,
protocol: version,
peerMinimum,
protocolConstant:
values[namespace.protocol] === undefined ? 'DESKTOP_PROTOCOL_VERSION' : namespace.protocol
}
inspected.push(evidence)
if (!floor && version >= namespace.minimum && clientProtocol >= peerMinimum) {
floor = evidence
}
if (!atMinimum3 && version >= 3 && clientProtocol >= peerMinimum) {
atMinimum3 = evidence
}
if (floor && atMinimum3) {
break
}
}
if (!floor || !atMinimum3) {
throw new Error(`No compatible floor in ${namespace.name}`)
}
floors.push({
namespace: namespace.name,
consideredTags: candidates,
minimum: namespace.minimum,
floor,
atMinimum3,
inspected
})
}

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Select the desktop RC floor by release chronology. The Step 0 generator sorts tags by version:refname and stops after recording v0.0.1-rc.0. That tag was released on 2026-05-26, while the earlier v1.4.5-rc.0 release from 2026-05-17 already has compatible protocol values. The emitted desktop-rc floor can therefore omit the chronologically oldest compatible RC and misstate retirement support. Sort and validate candidates by release chronology before emitting the floor.

…lved provenance

Review of #19833 found the fail-closed claim did not hold. Each gate below was
reproduced failing open first, then fixed and re-proved.

The b2 seed pinned a V8 TypeError message rather than a guard: `toMatch(/null/)`
matched "Cannot read properties of null (reading 'ok')", so adding the correct
null guard would have made the seed fail and `result: undefined` was uncovered.
The oracle is now the outcome — the row is not committed and a non-empty error
is surfaced — which still fails against the pinned reference at bcba08b
(`response.result?.ok === false` silently accepts and commits) and passes under
an explicit guard. A second case covers `undefined`. The ledger's b2 provenance
pointed at line 149, inside the sibling review-comment function; the merge path
is line 220.

`--require-regressions` shelled out to `vitest -t <name>` and trusted the exit
code. A filter matching nothing and an `it.skip` are both a green skip, so a
retitled or skipped seed kept the gate green. The runs now read the JSON
reporter and require the named case itself to report `passed`; the ratchet run
requires every case in the file to pass.

The named-deltas ledger was shape-validated only, so fabricated shas, absent
files and line 999999 passed. Every provenance pointer is now resolved with
`git show <sha>:<file>` and must be at least `line` lines long; any git failure
or truncated read is a gate failure.

`rpc-acceptance-census.mts` had a `--check` branch nothing invoked, so the
415-line STEP0_5-TODO.md could drift silently. step0 now drives it like the
other five generators, and the census honours `--output`.

Ratchet and census exclusions matched `test-support` anywhere in the path, which
would have made lane C's `mobile/src/test-support/rpc-recording/` permanently
unwatched and let out any product file whose name contained the string. Both are
anchored to a path segment or the `.test-support` suffix; the watched file set is
unchanged.

The caller walk carried a hardcoded rescue for one file and one parameter name.
A caller reached only through a function-type alias was otherwise dropped, and a
partial caller set resolving to one literal was indistinguishable from a static
call. The rescue is replaced by a general contextual-alias rule with fixtures for
both the annotated-variable and shorthand-property shapes; the inventory is
byte-identical apart from the rewritten seed's own references.

Artifact honesty: support-floor records considered versus inspected counts and
the floor commit dates, and states that a floor is the lowest version-named
compatible tag rather than the oldest supported release, since the rc floor
v0.0.1-rc.0 is thirteen days newer than the stable floor v1.3.51. Its `git show`
catch no longer launders a truncation into "protocol constant file absent".
access-inventory records that 1,182 `role: reference` entries are exempt by
construction and that 44 dynamic call sites are the resolved ones, and that a
transport-exception method union is an over-approximation.

No product behavior changes.

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

@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

  • Fail-closed regression execution — rpc-foundation-check.mts gained a vitest helper that parses the JSON report and requires the pinned seed (or every case, for the ratchet) to report passed, so a -t filter matching nothing or an it.skip can no longer pass as green.
  • Fail-closed provenance — gitLineCount resolves each ledger sha:file and rejects any location past the file's end, closing the earlier shape-only check; the git show catch in rpc-support-floor.mts now only treats a genuinely-absent path as an exclusion.
  • Generalized alias resolution — the hardcoded StructuredAgentSessionMutate special case was replaced by aliasCarriers/ownerBinding, which follow a function value through contextual type-alias assignments; two new resolver tests cover the type-alias and shorthand-property paths.
  • Support-floor provenance — added committer timestamps and consideredCount/inspectedCount, and clarified the selection semantics (lowest-named compatible tag, not oldest release).
  • Anchored test-support exclusion — NOT_SOURCE in both the acceptance census and the screen ratchet now anchors test-support to a path segment or suffix, so a product file whose path merely contains test-support is no longer silently unwatched.
  • Acceptance census gated — step0 now regenerates and checks STEP0_5-TODO.md unconditionally.
  • b2 seed hardening — the Project-merge seed was refactored into projectMergeProbe/expectRejected and gained an undefined result variant, with the oracle expressed as the outcome rather than the error message.

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8a78141d-209d-4698-b777-eb5f34c26ba5

📥 Commits

Reviewing files that changed from the base of the PR and between 0a1eadd and dd3b291.

📒 Files selected for processing (11)
  • mobile/rpc-foundation/access-inventory.json
  • mobile/rpc-foundation/named-deltas.json
  • mobile/rpc-foundation/support-floor.json
  • mobile/scripts/rpc-acceptance-census.mts
  • mobile/scripts/rpc-access-inventory.mts
  • mobile/scripts/rpc-access-resolution.mts
  • mobile/scripts/rpc-foundation-check.mts
  • mobile/scripts/rpc-support-floor.mts
  • mobile/src/tasks/use-mobile-tasks-project-file-merge-actions.test.ts
  • mobile/src/transport/rpc-access-resolution.test.ts
  • mobile/src/transport/screen-rpc-ratchet.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • mobile/rpc-foundation/named-deltas.json

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

Comment thread mobile/scripts/rpc-access-inventory.mts Resolved
Comment on lines +115 to +118
const aliased = calls.filter((call) => {
const declaration = checker.getResolvedSignature(call)?.declaration
return Boolean(declaration?.parent && aliases.has(declaration.parent))
})

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Match aliased calls to their carrier binding.

When two bindings use the same RunHook alias, callers(owner) accepts calls through both bindings because it checks only the alias declaration. The unrelated call then reaches methods() for the RPC forwarder and adds its method literal to the caller-resolved entry emitted by rpc-access-inventory.mts. Match the call target to the owner binding as well as the alias, and add a regression test with two distinct bindings.

Comment on lines +87 to +94
args: ['show', `${sha}:${file}`],
cwd: root,
maxOutputBytes: 8_000_000
})
if (result.code !== 0 || result.timedOut || result.outputTruncated) {
throw new Error(`Unresolvable provenance ${sha}:${file}: ${result.stderr.trim()}`)
}
return result.stdout.replace(/\n$/, '').split('\n').length

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Require provenance paths to resolve to non-empty blobs.

git show <sha>:<path> succeeds for tree paths and returns a directory listing. That output can satisfy the line-count check. An empty blob also produces one line because ''.split('\n').length is 1. Use git cat-file -t to require a blob, and return 0 for empty blob content.

Proposed validation
 async function gitLineCount(sha: string, file: string): Promise<number> {
+  const object = `${sha}:${file}`
+  const type = await runProcess({
+    program: 'git',
+    args: ['cat-file', '-t', object],
+    cwd: root
+  })
+  if (type.code !== 0 || type.stdout.trim() !== 'blob') {
+    throw new Error(`Provenance is not a blob: ${object}`)
+  }
   const result = await runProcess({
     program: 'git',
-    args: ['show', `${sha}:${file}`],
+    args: ['show', object],
     cwd: root,
     maxOutputBytes: 8_000_000
   })
   if (result.code !== 0 || result.timedOut || result.outputTruncated) {
     throw new Error(`Unresolvable provenance ${sha}:${file}: ${result.stderr.trim()}`)
   }
-  return result.stdout.replace(/\n$/, '').split('\n').length
+  return result.stdout === '' ? 0 : result.stdout.replace(/\n$/, '').split('\n').length
 }

const cases: VitestCase[] = (summary.testResults ?? []).flatMap(
(suite: { assertionResults?: VitestCase[] }) => suite.assertionResults ?? []
)
const matched = name ? cases.filter((item) => item.fullName.includes(name)) : cases

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🌐 Web query:

For Vitest 4.1.11 JSON reporter output, what fields identify an assertion's exact test title and full suite-qualified name?

💡 Result:

In the Vitest 4.1.11 JSON reporter output, the fields that identify an assertion's exact test title and its full suite-qualified name are as follows: * title: Contains the individual, exact test title (the name passed to the test function) [1][2]. * fullName: Contains the full, suite-qualified name [1][2]. In recent versions of Vitest, this field is constructed by joining the suite hierarchy and the test name, typically separated by a > character (e.g., "suite > nested suite > test name") [1][3]. Additionally, the ancestorTitles field is available as an array of strings representing the hierarchy of describe blocks that contain the test [1][2]. Note that while the fullName format in Vitest's JSON reporter has transitioned in recent major versions to use a > separator to improve consistency and filtering behavior (such as with the --testNamePattern flag), older versions or specific configurations might have used different spacing [1]. You should rely on the fullName field for uniquely identifying the test within the suite tree [1].

Citations:


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- target file ---'
sed -n '1,210p' mobile/scripts/rpc-foundation-check.mts
printf '%s\n' '--- Vitest references and version declarations ---'
rg -n --glob '!node_modules' --glob '!dist' 'vitest|fullName|assertionResults|rpc-foundation-check' mobile package.json pnpm-lock.yaml yarn.lock package-lock.json 2>/dev/null | head -240

Repository: stablyai/orca

Length of output: 30595


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings

Length of output: 26292


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- vitest call sites and pinned names ---'
rg -n -C 4 'vitest\(|--require-regressions|regression-seeds|testNamePattern|fullName' mobile/scripts mobile/rpc-foundation 2>/dev/null | head -240

Repository: stablyai/orca

Length of output: 5053


Match the pinned test name exactly.

cases.filter((item) => item.fullName.includes(name)) can accept a different test whose full name contains the pinned name. Compare the exact normalized fullName with the pinned name, or compare Vitest's exact title and suite path.

Comment thread mobile/scripts/rpc-foundation-check.mts Outdated
Comment on lines +165 to +175
) {
throw new Error(`Invalid ${side} provenance: ${entry.id}`)
}
if ((await gitLineCount(location.sha, location.file)) < location.line) {
throw new Error(
`${side} provenance past end of file: ${entry.id} ${location.file}:${location.line}`
)
}
}
}
if (flags.has('require-all-current-calls') || flags.has('require-no-dynamic-calls')) {

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Compare Step 0 with the complete expected delta-ID set. named-deltas.json currently contains eight IDs, but checkStep0() only rejects fewer than seven entries. If one entry is removed, the remaining seven valid entries pass the ledger validation and the missing historical delta is no longer enforced. Add a checked-in expected ID set and compare the ledger IDs and count against it at this boundary.

Deletes 26,623 of the branch's 28,703 added lines. Nothing here changed product
behavior, and most of it guarded facts that were already written down or were
provably constant.

`support-floor.json` + its generator (2,496 lines): walked 1,078 tags and read
205 blobs to name five floors, three of which are just the oldest tag in their
namespace and one of which the artifact itself says not to read as a support
floor. Every namespace recorded `"minimum": 2`, so the bump to 3 would have
falsified every `floor` field. The only surviving field, `atMinimum3`, yields the
four strings already hand-written at protocol-version.ts:19-24. That comment is
the artifact. `--require-floor-derived-from-protocol-gate` and
`--require-retirement-decision` go with it.

`settings-19675.json` + the slice manifest (2,257 lines): a frozen AST inventory
pinned to `dc423947f4`, a head in no branch here. `--slice` and `--pr-head` go
with it.

`rpc-operation-descriptor.ts` + `mobile-git-operation-descriptors.ts` (51
lines): `defineRpcOperation` returned its argument, all 23 table entries mapped
their key to itself, all 23 policies were the literal `'unclassified'`, and the
sole consumer `descriptors[method]?.method ?? method` evaluated to `method` for
every input. The original `client.sendRequest(method, {...})` is restored
byte-for-byte from the base.

`rpc-acceptance-census.mts` + `STEP0_5-TODO.md` (474 lines): a scratch to-do
list whose freshness step0 enforced unconditionally, so any new `if
(response.ok)` in `mobile/src` broke the gate until someone regenerated it.

The unimplemented step contracts (22 flag names across `step0_5`/`step1`/
`step2`/`step3`) declared flags for migrations that have not happened; the code
printed "not implemented" and exited 2. Also gone are
`--require-gate-fail-closed`, `--require-below-floor-block-e2e` and
`--allow-lane-b-deferred`, three flags whose only behavior was requiring each
other.

`access-inventory.json` drops from 21,805 to 618 lines. 1,183 of its 1,614
entries were role `reference` — occurrences of the `sendRequest`/`subscribe`
token with no call attached, which the artifact's own summary conceded are
exempt by construction. Those become a count plus the 167-file list. The 431
real call sites stay, one per line as `file:line:column kind method`, which is
greppable in a way a 14-line object row was not. `--require-no-dynamic-calls`
and its exemption descriptors go: `transport-exception` was a 194-method union
the artifact called an over-approximation, and `non-rpc-listener` was two
hardcoded file paths. What remains is the checker's own resolution output.

Removing the descriptor table improved the census rather than degrading it. The
git call site now resolves through the type checker to the six literals its
in-file callers pass, where the hand table asserted 23. It is an
under-approximation — `callers()` misses the callers that reach `sendGitRequest`
through the `SendGitRequest` type alias — so read `resolvedFamily` as a lower
bound, not a closed set.

Verified `--require-all-current-calls` still fails closed in both directions:
dropping one row from a copy of the artifact, and adding a real
`client.sendRequest('proof.newCallSite')` to `mobile-open-pr-prefill.ts`, each
exit 1 with `Stale artifact`.

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

@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

  • Removed speculative machinery — deleted rpc-support-floor.mts/support-floor.json, rpc-slice-manifest.mts/settings-19675.json, rpc-acceptance-census.mts/STEP0_5-TODO.md, and the operation-descriptor table (rpc-operation-descriptor.ts, mobile-git-operation-descriptors.ts), restoring use-mobile-git-requests.ts to the base client.sendRequest(method, {...}) call byte-for-byte.
  • Simplified access inventory — rpc-access-inventory.mts now emits 431 greppable file:line:column kind method call-site rows plus a 1,183-reference count and 167-file list (schema v2), dropping --require-no-dynamic-calls and its exemption descriptors.
  • Reduced checker surface — rpc-foundation-check.mts now accepts only step0, deleting the unimplemented step0_5/step1/step2/step3 flag contracts and the lane-B flag trio.

ℹ️ PR description is out of sync with the code

The "What lands", "Derived floors", and "Passing invocation" sections still describe the removed support-floor manifest, settings slice, --require-no-dynamic-calls, and the lane-B flags. The documented "Passing invocation" command now fails at flag parsing (Unknown or duplicate flag: --require-no-dynamic-calls), so a reviewer following the body cannot actually verify the checker. Worth regenerating the hand-written sections.

ℹ️ resolvedFamily is a lower bound, but only the commit message says so

Removing the 23-entry descriptor table means the git call site now resolves through the type checker to the six literals its in-file callers pass (git.commit|git.fetch|git.pull|git.push|git.status|git.upstreamStatus); callers reached via the SendGitRequest type alias (e.g. git.rebaseFromBase, git.localBranches) are missed. That's a reasonable step-0 trade and the commit message documents it, but the caveat lives only there — a future maintainer reading access-inventory.json's note may treat a |-joined family as exhaustive.

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

…cannot leave CI red

`emit` wrote `JSON.stringify(value, null, 2)` while `format:check` runs oxfmt
over the same committed bytes, so the short `scope` array failed the gate.
The generator now formats what it writes; `--check` compares parsed JSON and
is unaffected.

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

@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 critical issues — one minor cross-platform suggestion inline.

Reviewed changes

  • Formats regenerated artifacts — emit in rpc-artifact-io.mts became async and now runs oxfmt --write on the emitted JSON before reporting success, so regeneration cannot leave a format:check CI job red; the three generators now await it.
  • Normalized committed inventory JSON — access-inventory.json's scope array collapsed to a single line to match oxfmt's output.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Comment thread mobile/scripts/rpc-artifact-io.mts Resolved
Reject partial caller families when sender bindings escape or alias calls are not enumerated. Inventory unsubscribe frame constructions and sender calls as a separate kind, and pin the failure modes with mutation-checked regressions.

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

@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

  • Fail-closed forwarder resolution — callers() in rpc-access-resolution.mts now returns the empty set unless every use of a function-value binding is a direct call or a fully-enumerated local alias (escapes() walks a new references map of every identifier use). Escaped senders (use-mobile-git-requests.ts, use-mobile-browser-request.ts, mobile-structured-agent-session-rpc.ts) now report dynamic:client.sendRequest instead of a silently-partial |-joined family, and the artifact note now documents dynamic:<callee> as "completeness cannot be proven" — closing the earlier lower-bound caveat.
  • unsubscribe access kind — entryKind recognizes sendUnsubscribe, and the new unsubscribeFrameMethod inventories literal *.unsubscribe frame method fields as a third kind, recomputing access-inventory.json (442 call sites, 1184 references, 23 resolved families).
  • Cross-platform regeneration — emit formats regenerated artifacts via pnpm exec oxfmt from mobile/ rather than spawning the extensionless POSIX shim, so the Windows regeneration path no longer relies on .bin/oxfmt.

The new escapes() cases (returned hook results, consumed senders, object assignment, alias chains) are each pinned by rpc-access-resolution.test.ts, and the resolver change is a behavior-correctness hardening for the step-0 inventory with no product-code surface.

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

@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Closing as superseded, unmerged by the owner's decision. The inventory this PR introduced as a manifest lives on as mobile/src/transport/unchecked-rpc-reader-inventory.ts, which the step-7 series drove from 137 entries to zero (#21269); unchecked-rpc-reader-boundary.test.ts is now the fail-closed check, backed by its 400-file scan floor, and the recording pin guard (#21156) covers the manifest half.

@Jinwoo-H Jinwoo-H closed this Sep 17, 2026
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