Skip to content

fix(ci): keep a squash-merged RPC recording pin reachable through its pull request - #23720

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/fix-ci-red-pufferfish
Sep 29, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/fix-ci-red-pufferfish

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​224 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​206
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​259 $\color{#cf222e}{\Huge{\mathbf{−}}}$​100 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​159

ELI5

The mobile test corpus records which exact commit it was recorded from. When a pull request re-records it, it points that record at one of its own commits. Squash-merging throws that commit away from main's history, and a CI check then turned main red until someone opened a follow-up PR just to point the record at a main commit. This PR teaches the check where the "thrown away" commit still lives, so main stays green and the follow-up PRs are no longer needed.

What Changed

Before: Mobile Checks / RPC recording pin has failed on every push to main since #22762 (29c7d5d). That PR pinned the corpus to its own branch commit 03995ae, and the squash left 03995ae out of main's history. The guard only accepted a pin that is an ancestor of the checked-out commit, so it failed with "pinned to a commit that is not an ancestor of this commit". The same thing happened after every PR that re-records the corpus, and each one needed a hand-made repin PR: #23565, #23535, #23046, #22702, #22407, #22394, #21105, #21092, #21065 and more. Main's history has 61 commits that touched the pin file, 49 of which changed the pin.

After: the guard (mobile/scripts/rpc-recording-pin-reachability.mts, split out of the guard file) accepts a pin that is either:

  1. an ancestor of the checked-out commit (unchanged), or
  2. inside the head of a pull request that GitHub associates with the pinned commit.

For (2) the guard asks GitHub which pull requests contain the pinned commit (GET /repos/{owner}/{repo}/commits/{pin}/pulls). For each one, in order, it fetches refs/pull/<n>/head into refs/rpc-recording-pin/pull/<n> and accepts the pin only if git confirms the pin is an ancestor of that head. GitHub only suggests candidates and git makes the decision, so a wrong or stale answer from GitHub can make the check fail but never pass. GitHub keeps pull request head refs after the branch is deleted.

The reproduce step runs the same check first, so the pinned tree can still be checked out when the branch is gone. The CLI subcommand is renamed from ancestry to reachable to match what it now checks.

CI passes the job's own token (GITHUB_TOKEN) to both guard steps, and the recording-pin job now declares contents: read and pull-requests: read. The token raises GitHub's API rate limit. Local runs work without a token because the repository is public, and they send GITHUB_TOKEN or GH_TOKEN when one is set. The repository name comes from GITHUB_REPOSITORY in CI, or else from the origin remote URL.

If GitHub cannot be reached, the guard fails with the HTTP status and GitHub's message, and it says when the cause is the unauthenticated rate limit. It never passes in that case. The workflow, its config test and the corpus README are updated. The README no longer tells people to open a follow-up repin after a squash.

The recorder (mobile/scripts/rpc-recording.mts) now tells a pinned commit that your clone does not have apart from real product drift. Before, a developer on main right after such a squash was told "Product sources or lockfile differ from the pinned main baseline" and sent to repin for nothing; now it prints git's error and the reachable command that fetches the pin.

Nothing changes for the app. This touches CI and test tooling only.

One accepted risk: on a push to main, the reproduction step now checks out the pinned pull request commit, which is not in main's history, and runs the recording suites from it. That same commit already ran in the pull request's own reproduction, and its SHA is in the reviewed diff. The job token is now read-only (contents: read, pull-requests: read) and no secrets reach the step. The remaining exposure is the pnpm package-store cache that the setup step saves for main at job end on a cache miss.

Why

The pin exists so the corpus can later be checked out and replayed against the exact tree it was recorded from. That only requires the pinned commit to stay retrievable. It does not have to be in main's history. Under squash-merge a branch commit never lands in main's history, but GitHub keeps it permanently under refs/pull/<n>/head. The follow-up repin PRs only rewrote the baseline header of every golden and changed no recorded behaviour, so they were bookkeeping that kept main red.

The pull request is found by asking GitHub about the pinned commit itself. This does not depend on how the squash was titled, how the branch was merged, or which later commit last touched the manifest. I checked the question against main's full history. Of the 49 commits that changed the pin, 22 pinned a commit that is not in main's history, so each of those turned main red under the old guard. For all 22, GitHub's answer named the right merged pull request, and all 22 of those pull request heads still hold the pin. For commits that a force-push removed from a pull request, GitHub returns no pull request, so those pins still fail.

Alternatives considered:

  • Read the pull request number from the squash commit's title. An earlier revision of this PR did this. It searched main's history for the commit that wrote the pin into the manifest (git log --first-parent -S<pin>) and read the (#n) that GitHub appends to squash titles. I rejected it because the title can be edited at merge time, and that has already happened here: fix(omp): attach desktop and mobile images through file mentions #21674 was squash-merged with an edited title that has no (#n). That is 1 of the 22 cases, and the title-based guard would still have turned main red there. The history search also cost up to 14 lazy file downloads in CI's partial clone (20 to 56 seconds on main's worst stretch), needed a 10-minute time budget, and misread a revert that restores an older pin. Asking GitHub about the pin needs one API call instead.
  • Accept any pin that git fetch origin <sha> can download. GitHub serves commits by SHA even when no branch or pull request keeps them. I checked this with four commits that force-pushes had removed from merged pull requests: all four still downloaded. So this check would pass a pin that GitHub may later delete. Requiring the pin to be an ancestor of a named pull request head is what makes the check sound.
  • Store the pull request number in the manifest. The number does not exist until the pull request is opened. It would add a manual step to every behaviour-change PR and a second copy of a fact GitHub already has, and the guard would still have to check it with git.
  • Repin to main's tip again. This clears today's red but guarantees the next one. It is what the last ten repin PRs did.
  • Pin a hash of the product sources instead of a commit. The pinned product paths (mobile/src, src/shared, the mobile lockfile) changed in 387 main commits over the last two weeks. A branch's recorded tree almost never exists unchanged on main after a squash, so that pin would break just as often.
  • Have a bot repin main after each squash. That needs a bot that can push to a protected main, plus a re-record in CI. It keeps the bookkeeping instead of removing it.

The check still fails where it should. A pin that no kept ref holds fails with the same repin instruction as before. That covers a pin GitHub links to no pull request, and a pull request whose head no longer holds the pin because the author force-pushed after pinning. The message now says which of the two happened. A pull request whose rebase dropped its own pinned commit fails on the pull request itself, before the squash reaches main.

Linked Issue

None. Reported in the team Slack (#orca CI channel), where main's Mobile Checks was red on #22762 and #23605.

Visual Proof

N/A — CI and test tooling only; no UI or app behaviour change.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • mobile/scripts/rpc-recording-pin-guard.test.ts: 30/30 pass. The reachability cases use a throwaway bare remote that keeps a branch head at refs/pull/7/head, and they replace the GitHub call with a stub:

    • a squash-merged pin passes from a main-only clone that lacks the pin until it is fetched, and still passes after later changes on main;
    • a branch opened after that squash passes when judged against its merge preview;
    • a squash whose title has no (#n) passes, because the pull request comes from GitHub (the fix(omp): attach desktop and mobile images through file mentions #21674 case);
    • when GitHub names two pull requests, the guard passes through the one whose head holds the pin;
    • a pull request head that no longer holds the pin (force-push) fails and names refs/pull/7/head;
    • when GitHub names no pull request, a squash fails with the repin instruction, and so does a pull request whose rebase dropped its own pinned commit;
    • when the GitHub call fails, the error propagates, and the guard gives neither a pass nor a repin instruction;
    • the GitHub call itself, with fetch stubbed: it sends the token and reads the pull request numbers; it treats GitHub's "No commit found" (HTTP 422) as no pull request; it mentions the rate limit on a 403 without a token; and it reads owner/repo from https and ssh remote URLs.
  • Ablations:

    • With the GitHub lookup disabled, the four squash-pass cases, the force-push case and the error-propagation case fail (6 failed / 24 passed).
    • With the git ancestry check removed, so that whatever GitHub names is trusted, the force-push case and the two-pull-request case fail (2 failed / 28 passed).
  • config/scripts/mobile-recording-pin-checkout.test.mjs now also asserts the job's contents: read / pull-requests: read permissions and the token on both guard steps. It passes 2/2, and it fails when pull-requests: read is removed.

  • Against the real repository, in a CI-shaped clone (--filter=blob:none, full history):

  • This PR edits the guard, which is one of the paths that force the full corpus reproduction to run on the PR. CI therefore replays the corpus against the pinned tree 03995ae, which it reaches through the new lookup.

  • oxlint and oxfmt --check are clean on the changed files. The guard test sits outside mobile's test typecheck on purpose (see mobile/tsconfig.test.json).

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Cross-platform: the guard runs git through runProcess with argv arrays, the same as before. SSH, mobile app and backwards compatibility: no runtime code changes. The pull request lookup is one HTTPS call to api.github.com, and it only happens when main's pin is held by a pull request rather than main's history; a network or GitHub error fails the job loudly (re-run clears it) and never passes it. The fetch uses the origin remote, as CI's checkout does. In a local clone whose origin is not on GitHub, the guard asks for GITHUB_REPOSITORY=<owner>/<repo>. In a clone whose origin is a fork, it asks about the fork, so it fails rather than passing wrongly, but the message does not say the fork is the cause.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

… pull request

Main's "RPC recording pin" check has been red since #22762: that branch pinned
the recording corpus to its own commit 03995ae, and the squash-merge left that
commit out of main's history. Every behaviour-change squash did the same, and
each needed a hand-made repin PR to clear it (#23565, #23535, #23046 and more).

The guard now accepts a pin that is either in this history or in the head of the
pull request whose squash wrote it into the manifest. It finds that pull request
from the `(#n)` subject of the commit that added the pin and fetches
`refs/pull/<n>/head`, which GitHub keeps after the branch is deleted. The
reproduce step uses the same lookup, so it can still check the pinned tree out.
@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Changes how the build system validates RPC recording pins.

The PR appears safe to merge, with a non-blocking pagination gap in the new lookup and two earlier documentation and replay-gate concerns still outstanding.

Findings

  1. P2 Later PR pages are ignored ▶
  2. P2 New module can skip replay ▶
  3. P2 Archive-tree guidance is outdated ▶

Summary

This PR lets the mobile recording-pin guard retrieve a squash-merged pin through an associated pull request’s head ref instead of requiring it in main’s ancestry.

  • It adds a GitHub PR lookup and fetch path, uses it before corpus reproduction, and supplies CI credentials.
  • It updates the guard tests and recording guidance. The lookup does not handle paginated PR results.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Pin[Manifest baseline] --> Ancestry{Ancestor of checkout?}
  Ancestry -->|Yes| Pass[Pin reachable]
  Ancestry -->|No| API[Look up associated PRs]
  API --> Heads[Fetch PR head refs]
  Heads --> Check{Head contains pin?}
  Check -->|Yes| Pass
  Check -->|No| Fail[Reject pin]
Loading

Reviews (3) · Last reviewed commit: "fix(ci): ask GitHub which pull request h..."

import { runProcess } from '../../src/shared/child-process/run-process.ts'
import { RECORDING_DRIVERS } from '../src/test-support/rpc-recording/recording-drivers.ts'
import { readScenarios } from '../src/test-support/rpc-recording/scenario-input.ts'
import { checkPinReachable, PIN_MANIFEST } from './rpc-recording-pin-reachability.mts'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 New module can skip replay The reproduction change gate still lists only the guard script, not this newly imported reachability module. If a future PR changes only the new module, reproduce --if-changed-since can skip the pinned-tree replay even though the code deciding whether reproduction can proceed has changed. Include the module in the gate's tracked paths.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

📝 Walkthrough

Walkthrough

The recording-pin checker now tests whether a baseline is reachable from the requested ref or from an associated pull-request head. The workflow invokes the reachable command and provides GITHUB_TOKEN to the reachability and reproduction steps. The guard checks reachability before reproducing recordings. Tests cover squash merges, pull-request-head changes, shallow clones, and GitHub lookup behavior. The recording guide describes the pull-request-head check and how to fetch a missing pin.

Priority: ⚪ Not assessed

Merge Risk: 🔵 Low · up to 70ba1

Some valid recording pins could fail the mobile CI check when their qualifying pull request is omitted from the first lookup page or follows an unavailable head. These are narrow cases; the change is mergeable with owner awareness or follow-up.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 70ba1

The change fixes squash-merged pins, but it also permits the reproduction job to run code from a pinned commit outside the checked-out branch while a read-scoped GitHub token is available. The exact commit is verified before use, which limits the exposure; its provenance and credential boundary still warrant review.

Retained concerns

  • Medium · security · inferred: A PR-backed pin can cause the main recording job to execute a commit outside main’s history while inheriting its read-scoped GitHub token. PR-head ancestry establishes availability, not whether that pinned tree was merged or approved.
  • Low · reliability · inferred: A failed fetch of one associated PR head aborts the search, so a later head that holds a valid pin cannot restore the CI verdict.
Security review details

Security Blast Radius

  • inferred — The widened execution boundary is the mobile recording job, including its read-scoped repository token. The reviewed path does not establish write authority or a change to the other scripts linked only by the token name.

Security Findings and Attack Paths

  • inferred — If a manifest change naming a commit held by an associated PR lands on main, the fallback can authorize reproduction from that commit even when it is outside main’s history. Code imported from the pinned tree can then run with the job’s inherited read token; this requires the manifest change to land and is not execution of an arbitrary fetched head.

Trust Boundaries and Controls

  • observed — The lookup supplies candidate PR numbers rather than an executable verdict. Fixed origin PR refs are fetched, ancestry is checked locally, shallow history is rejected, and reproduction requires a positive verdict.

Resilience and Maintainability Implications

  • inferred — The fallback fails closed, but an unavailable earlier PR head can prevent evaluation of a later valid head, leaving the CI gate blocked rather than weakening its acceptance rule.

Hardening Proposals

  • proposed — Keep the token available for lookup but remove it from the pinned-tree test subprocess; if pin provenance must imply a merged change, explicitly verify that relationship rather than using PR-head retention alone.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 5 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary change: keeping squash-merged RPC recording pins reachable through their pull requests.
Description check ✅ Passed The description is comprehensive and covers the required explanation, changes, rationale, testing, visual proof, risks, and checklist. The Linked Issue section states "None" instead of linking an issu…
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 5 files. (2 skipped: 2 unsupported.)

  • 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.

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

🧹 Nitpick comments (1)
mobile/scripts/rpc-recording-pin-guard.mts (1)

243-249: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a CLI regression test for the unreachable-pin early return.

The tests cover the helper verdict, but not the reproduce entrypoint. The workflow test only checks command text. Add focused entrypoint coverage that supplies an unreachable pin, asserts the failure, and confirms that the pinned-tree reproduction does not start. This covers caller sequencing without duplicating checkPinReachable tests.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 23cc7637-7711-485a-954a-95fb59955680

📥 Commits

Reviewing files that changed from the base of the PR and between 64569a8 and 6e82c43.

📒 Files selected for processing (6)
  • .github/workflows/mobile.yml
  • config/scripts/mobile-recording-pin-checkout.test.mjs
  • mobile/scripts/rpc-recording-pin-guard.mts
  • mobile/scripts/rpc-recording-pin-guard.test.ts
  • mobile/scripts/rpc-recording-pin-reachability.mts
  • mobile/src/test-support/rpc-recording/README.md

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

@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 — two minor suggestions inline.

Reviewed changes

  • New reachability module — mobile/scripts/rpc-recording-pin-reachability.mts accepts a pin that is an ancestor of the checked-out commit, or one kept by the head of the pull request whose squash wrote it, found via git log --first-parent --max-count=1 -S<pin> -- <manifest>.
  • Guard rewired — mobile/scripts/rpc-recording-pin-guard.mts drops the old checkPinAncestry, imports the new module, and fetches the pin in reproduce before checking it out; the subcommand is renamed ancestry → reachable.
  • Tests — mobile/scripts/rpc-recording-pin-guard.test.ts adds squash-pass, force-push-fail and no-(#n)-fail cases against a throwaway bare remote with refs/pull/7/head.
  • Workflow/config/docs — .github/workflows/mobile.yml, config/scripts/mobile-recording-pin-checkout.test.mjs and mobile/src/test-support/rpc-recording/README.md follow the rename; the README no longer prescribes a follow-up repin.

I independently verified the load-bearing external claim: GitHub permits fetching refs/pull/<n>/head for merged/closed PRs, and the explicit-refspec fetch plus lazy blob fetches work under fetch-depth: 0 + filter: blob:none with the persisted checkout credentials.

ℹ️ Nitpicks

  • The workflow comment ("GitHub keeps for good") and module JSDoc ("outlives the branch") claim stronger permanence than GitHub documents. Retention is reliable in practice but not guaranteed (repo-cache clearing is a documented exception), and the failure mode is a loud fetch error, so this is wording only.
  • fetchPullRequestHead throws on any fetch failure instead of returning a verdict, so a non-GitHub origin (e.g. GitLab) or a fork clone without the ref aborts with a stack trace rather than the repin instruction. Returning not-an-ancestor/unreachable would keep the guard's failure vocabulary uniform.

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

import { runProcess } from '../../src/shared/child-process/run-process.ts'
import { RECORDING_DRIVERS } from '../src/test-support/rpc-recording/recording-drivers.ts'
import { readScenarios } from '../src/test-support/rpc-recording/scenario-input.ts'
import { checkPinReachable, PIN_MANIFEST } from './rpc-recording-pin-reachability.mts'

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.

Splitting the pin logic into rpc-recording-pin-reachability.mts leaves the new file out of CORPUS_PROVENANCE_PATHS (lines 31-35), so a PR that changes only the reachability driver skips the reproduce gate even though it now decides which pin is fetched. Add mobile/scripts/rpc-recording-pin-reachability.mts to the list and to seedProvenance in the test so the "refuses to answer" check covers it.

In CI's blobless clone, `git log -S` fetches the manifest's blobs one commit at a
time, a few seconds each. Under the 30 s process default the walk was killed after
a handful of manifest commits, which main's history already exceeds (up to 7
manifest commits between a pin landing and the next pin change), and the guard
then failed with an empty "Could not find the commit that pinned" error. The
lookup and the pull request fetch now carry explicit budgets and say when they
timed out.

The not-an-ancestor instruction now names the pull request whose head was
checked, or says the commit that pinned it names none.

Adds the two merge-preview shapes the guard runs on: a branch opened after a
squash resolves main's pin through the squash's pull request, and a branch whose
rebase dropped its own pinned commit fails on its pull request instead of on main.
After a squash the pinned commit can live only in its pull request's head, so a
clone that never fetched it makes `git diff --quiet <baseline>` exit 128. The
recorder reported that as "Product sources or lockfile differ from the pinned
main baseline", which sends the developer to repin a tree that may match. It now
prints git's error and the command that fetches the pin.
})
if (baseline.code !== 0) {
// A pin a squash left only in its pull request's head is a missing object, not product drift.
if (baseline.code !== 0 && baseline.code !== 1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Archive-tree guidance is outdated

In an archive extraction without .git, git diff now reports a Git error, so this branch prints “Could not diff against the pinned baseline.” The README still says this case prints “Product sources or lockfile differ from the pinned main baseline.” That mismatch can send someone diagnosing an archive-tree failure down the wrong path; please update the README description.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@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 in the incremental delta — the two open threads from the prior review are not addressed by these commits and remain unresolved.

Reviewed changes

Since the prior pullfrog review (6e82c43), two commits:

  • Lookup timeouts — mobile/scripts/rpc-recording-pin-reachability.mts raises the pin-lookup and PR-head fetch budgets (PIN_LOOKUP_TIMEOUT_MS 600 s, PIN_FETCH_TIMEOUT_MS 180 s) because a blobless clone services the -S walk's blobs on demand, and failureDetail reports a timeout distinctly from a git error.
  • Missing pin vs drift — mobile/scripts/rpc-recording.mts treats any non-1 exit from git diff --quiet <baseline> as a missing pinned object and prints the reachable fetch instruction, leaving exit 1 as the product-drift failure.
  • Failure wording — the not-an-ancestor instruction now states whether the pinning commit named a pull request.
  • Tests/docs — merge-preview cases for a branch opened after the squash and for a rebase that dropped the pinned commit; README notes no follow-up repin is needed.

Verified independently: git diff --quiet <missing-object> exits 128, so the new !== 0 && !== 1 classification is correct, and mobile/scripts/rpc-recording-pin-guard.test.ts passes 23/23 in-container.

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

…ng pin

The recording pin guard found the pull request that keeps a squash-dropped
pin by walking main's first-parent history for the commit that wrote the pin
into the manifest and reading "(#n)" off its subject. A merger who edits the
squash title loses the number, and the push to main turns red anyway. That
already happened on main: of the 22 squashes that left a pin outside main's
history, #21674's title had no "(#n)".

The guard now asks GitHub for the pull requests associated with the pinned
commit (GET /repos/{owner}/{repo}/commits/{sha}/pulls) and, for each in turn,
fetches refs/pull/<n>/head and accepts only when git proves the pin is an
ancestor of that head. GitHub only nominates candidates, so a wrong answer can
fail the guard but never pass it. The endpoint named the right pull request
for all 22 historical cases, #21674 included, and names none for commits a
force-push orphaned.

This removes the pickaxe walk, its 600 s budget and its lazy blob fetches in
a blobless clone, the first-parent subtlety, and the subject regex. A revert
that restores an older pull-request-only pin now resolves too, because the
lookup is by the pin itself rather than by the commit that last wrote it.

CI passes the job token to both guard steps and grants the job
pull-requests: read. Local runs work without a token on this public repo and
send GITHUB_TOKEN or GH_TOKEN when set. A failed lookup throws with the HTTP
status, and names the rate limit when an unauthenticated call is refused.
`GitHub answered ${url} with something other than a list: ${body.slice(0, 300)}`
)
}
return pulls.flatMap((pull) => (typeof pull?.number === 'number' ? [pull.number] : []))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Later PR pages are ignored If GitHub returns more than one page of pull requests associated with a pinned commit, this lookup checks only the first page. If the PR whose head retains the pin appears on a later page, reachable and reproduce reject a valid pin and CI asks for an unnecessary repin.

@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: 9e3037fa-2232-4b21-8529-7c738afe6951

📥 Commits

Reviewing files that changed from the base of the PR and between 73d0d8e and 70ba1eb.

📒 Files selected for processing (6)
  • .github/workflows/mobile.yml
  • config/scripts/mobile-recording-pin-checkout.test.mjs
  • mobile/scripts/rpc-recording-pin-guard.mts
  • mobile/scripts/rpc-recording-pin-guard.test.ts
  • mobile/scripts/rpc-recording-pin-reachability.mts
  • mobile/src/test-support/rpc-recording/README.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • mobile/src/test-support/rpc-recording/README.md
  • mobile/scripts/rpc-recording-pin-guard.mts

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

Comment on lines +84 to +121
export async function pullRequestsWithCommit(root: string, commit: string): Promise<number[]> {
const url = `https://api.github.com/repos/${await gitHubRepository(root)}/commits/${commit}/pulls`
const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN
const response = await fetch(url, {
headers: {
Accept: 'application/vnd.github+json',
...(token ? { Authorization: `Bearer ${token}` } : {})
},
signal: AbortSignal.timeout(PULL_REQUEST_LOOKUP_TIMEOUT_MS)
}).catch((error: unknown) => {
// Node's fetch hides the network reason (DNS, TLS, reset) in `cause`.
const cause = error instanceof Error && error.cause ? ` (${String(error.cause)})` : ''
throw new Error(
`Could not ask GitHub which pull requests hold ${commit} (${url}): ${String(error)}${cause}`
)
})
const body = await response.text()
// GitHub's answer for a commit it has never seen, which no pull request can hold.
if (response.status === 422 && body.includes('No commit found')) {
return []
}
if (!response.ok) {
const rateLimited = !token && (response.status === 403 || response.status === 429)
throw new Error(
`GitHub answered ${response.status} to ${url}: ${body.slice(0, 300)}` +
(rateLimited
? '\nUnauthenticated GitHub API calls are rate-limited; set GITHUB_TOKEN or GH_TOKEN.'
: '')
)
}
const pulls: unknown = JSON.parse(body)
if (!Array.isArray(pulls)) {
throw new Error(
`GitHub answered ${url} with something other than a list: ${body.slice(0, 300)}`
)
}
return pulls.flatMap((pull) => (typeof pull?.number === 'number' ? [pull.number] : []))
}

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

🔎 Supported by static analysis

🏁 Script executed:

sed -n '80,205p' mobile/scripts/rpc-recording-pin-reachability.mts
sed -n '305,360p' mobile/scripts/rpc-recording-pin-guard.test.ts

Repository: stablyai/orca

Length of output: 7454


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- callers and related symbols ---'
rg -n -C 3 'pullRequestsWithCommit|PullRequestLookup|checkPinReachable|rpc-recording-pin-reachability|recording-pin' mobile/scripts .github README.md docs 2>/dev/null | head -n 500
printf '%s\n' '--- relevant source outline and surrounding definitions ---'
ast-grep outline mobile/scripts/rpc-recording-pin-reachability.mts
printf '%s\n' '--- project files mentioning pagination or GitHub API contracts ---'
rg -n -i -C 2 'per_page|pagination|GitHub API|pull request.*commit|commit.*pull request' . --glob '!node_modules' --glob '!dist' --glob '!build' | head -n 400

Repository: stablyai/orca

Length of output: 41774


🤖 get_repo_knowledge executed:

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

Length of output: 47632


🏁 Script executed:

#!/bin/bash
printf '%s\n' '--- callers ---'
rg -n -C 4 'pullRequestsWithCommit|PullRequestLookup|checkPinReachable|rpc-recording-pin-reachability|recording-pin' mobile .github README.md docs 2>/dev/null | head -n 500
printf '%s\n' '--- script structure ---'
ast-grep outline mobile/scripts/rpc-recording-pin-reachability.mts 2>/dev/null || true
printf '%s\n' '--- pagination references ---'
rg -n -i -C 2 'per_page|pagination|pull requests associated with a commit|commit.*pull request|pull request.*commit' . --glob '!node_modules' --glob '!dist' --glob '!build' 2>/dev/null | head -n 400

Repository: stablyai/orca

Length of output: 41782


Fetch all pages from the commit-to-pull-request lookup.

pullRequestsWithCommit reads only the first page. checkPinReachable uses this fallback when local ancestry fails, including pins retained only by a squashed pull request's head. The tests show that an associated pull request can be irrelevant while a later associated pull request qualifies.

A qualifying pull request on a later page can therefore be omitted, causing the recording-pin workflow to exit with failure. per_page=100 only increases one page's size. Follow Link: rel="next" until all pages are read.

Comment on lines +165 to +193
}
// A squash drops the branch commit the pin names, and the branch may already be deleted, but
// GitHub keeps the pull request's head ref for good.
const pullRequests = await pullRequestsHolding(root, baseline)
for (const pullRequest of pullRequests) {
const pullRequestHead = await fetchPullRequestHead(root, pullRequest)
if ((await present()) && (await isAncestor(root, baseline, pullRequestHead))) {
return { ok: true, baseline, ref, pullRequest }
}
}
const pullRequestCause =
pullRequests.length === 0
? 'and GitHub associates no pull request with it'
: 'and no head of a pull request GitHub associates with it holds it ' +
`(${pullRequests.map((pullRequest) => `refs/pull/${pullRequest}/head`).join(', ')})`
if (!(await present())) {
return {
ok: false,
baseline,
ref,
failure: 'unreachable',
message: repinInstruction(
baseline,
resolved,
`is not a commit in this clone, ${pullRequestCause}`
)
}
}
return {

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Continue checking associated pull-request heads after a fetch failure.

When an earlier associated pull-request head cannot be fetched, fetchPullRequestHead throws and aborts checkPinReachable. The checker therefore does not test later pull-request heads, even when a later head contains the baseline commit. This can fail the mobile CI guard for a narrow combination of multiple associated pull requests and an unavailable earlier head. Catch the fetch error for each head, continue the loop, and preserve the fetch failure if no head qualifies.

Suggested fix
   const pullRequests = await pullRequestsHolding(root, baseline)
+  let pullRequestHeadError: unknown
   for (const pullRequest of pullRequests) {
-    const pullRequestHead = await fetchPullRequestHead(root, pullRequest)
+    let pullRequestHead
+    try {
+      pullRequestHead = await fetchPullRequestHead(root, pullRequest)
+    } catch (error) {
+      pullRequestHeadError = error
+      continue
+    }
     if ((await present()) && (await isAncestor(root, baseline, pullRequestHead))) {
       return { ok: true, baseline, ref, pullRequest }
     }
   }
+  if (pullRequestHeadError !== undefined) throw pullRequestHeadError
📝 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
}
// A squash drops the branch commit the pin names, and the branch may already be deleted, but
// GitHub keeps the pull request's head ref for good.
const pullRequests = await pullRequestsHolding(root, baseline)
for (const pullRequest of pullRequests) {
const pullRequestHead = await fetchPullRequestHead(root, pullRequest)
if ((await present()) && (await isAncestor(root, baseline, pullRequestHead))) {
return { ok: true, baseline, ref, pullRequest }
}
}
const pullRequestCause =
pullRequests.length === 0
? 'and GitHub associates no pull request with it'
: 'and no head of a pull request GitHub associates with it holds it ' +
`(${pullRequests.map((pullRequest) => `refs/pull/${pullRequest}/head`).join(', ')})`
if (!(await present())) {
return {
ok: false,
baseline,
ref,
failure: 'unreachable',
message: repinInstruction(
baseline,
resolved,
`is not a commit in this clone, ${pullRequestCause}`
)
}
}
return {
}
// A squash drops the branch commit the pin names, and the branch may already be deleted, but
// GitHub keeps the pull request's head ref for good.
const pullRequests = await pullRequestsHolding(root, baseline)
let pullRequestHeadError: unknown
for (const pullRequest of pullRequests) {
let pullRequestHead
try {
pullRequestHead = await fetchPullRequestHead(root, pullRequest)
} catch (error) {
pullRequestHeadError = error
continue
}
if ((await present()) && (await isAncestor(root, baseline, pullRequestHead))) {
return { ok: true, baseline, ref, pullRequest }
}
}
if (pullRequestHeadError !== undefined) throw pullRequestHeadError
const pullRequestCause =
pullRequests.length === 0
? 'and GitHub associates no pull request with it'
: 'and no head of a pull request GitHub associates with it holds it ' +
`(${pullRequests.map((pullRequest) => `refs/pull/${pullRequest}/head`).join(', ')})`
if (!(await present())) {
return {
ok: false,
baseline,
ref,
failure: 'unreachable',
message: repinInstruction(
baseline,
resolved,
`is not a commit in this clone, ${pullRequestCause}`
)
}
}
return {

@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 in this incremental delta — the one open earlier thread on the provenance-path list is unchanged, so this is not an approval.

Reviewed changes

Since the prior pullfrog review (73d0d8e), one commit (70ba1eb):

  • GitHub-backed pin lookup — mobile/scripts/rpc-recording-pin-reachability.mts drops the git log --first-parent -S<pin> squash-subject parse for GET /repos/{owner}/{repo}/commits/{sha}/pulls, then fetches each returned refs/pull/<n>/head and accepts the pin only where git confirms it is an ancestor; the lookup is injectable (PullRequestLookup) so tests never touch the network.
  • Repository and token plumbing — gitHubRepositoryFromRemote/gitHubRepository resolve owner/repo from GITHUB_REPOSITORY or the origin URL, pullRequestsWithCommit sends GITHUB_TOKEN/GH_TOKEN when present, and maps GitHub's 422 No commit found to an empty result.
  • Workflow and tests — .github/workflows/mobile.yml grants pull-requests: read and passes GITHUB_TOKEN to both pin steps; the guard test adds a stubbed-fetch suite (lookup, token, rate-limit, remote parsing) plus squash, edited-squash-title and multi-PR-head cases.

Verified independently against the live repository: GET /commits/03995ae…/pulls returns #22762 (the squash that dropped the pin this PR exists to keep reachable), and a bogus SHA returns the exact No commit found for SHA 422 body the code matches.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready for a human decision (not merged; merge is Brennan's call)

What this fixes: Mobile Checks / RPC recording pin has been red on every push to main since #22762 squash-merged with the recording corpus pinned to its own branch commit 03995ae. The squash drops that commit from main's history, and the old guard only accepted a pin in main's history. The same thing happened after every behaviour-change PR and needed a hand-made repin PR each time. After this PR, main stays green after such a squash, and a pin that nothing keeps still fails with the same repin instruction.

How it works now (head 70ba1eb): if the pin is not in the checked-out history, the guard asks GitHub which pull requests contain the pinned commit, fetches each one's refs/pull/<n>/head, and passes only if git confirms the pin is an ancestor of that head. GitHub only suggests candidates; git decides, so a wrong or failed GitHub answer can make the check fail but never pass.

What changed during review (4 review loops plus an architecture review):

  • 369bb1f gave the git lookups explicit time budgets after measuring CI's partial clone.
  • 73d0d8e made the recorder (scripts/rpc-recording.mts) tell a pinned commit your clone lacks apart from real product drift, and print the command that fetches it. Before, a developer on main right after such a squash was wrongly told their product sources differed.
  • 70ba1eb replaced the first design, which read the PR number from the squash commit's title, with asking GitHub about the pinned commit. The title-based design would still have turned main red when a squash title was edited at merge, which already happened once (fix(omp): attach desktop and mobile images through file mentions #21674, 1 of the 22 past squash-dropped pins). The new lookup found the right PR for all 22, has no history walk (the old one took up to 174 s in the worst case), and also handles a revert that restores an older pin.

Evidence:

  • Live CI on this PR at 70ba1eb: "Check the recording pin is reachable" printed Recording pin 03995ae… is kept by refs/pull/22762/head., and "Reproduce the corpus from the pinned tree" replayed 794/794 tests and printed The corpus reproduces from the pinned tree 03995ae…. The job's token shows only Contents read, Metadata read and PullRequests read.
  • All PR checks green: 22 passed, 16 skipped, 0 failed.
  • Guard tests 30/30 pass. Ablations: disabling the GitHub lookup fails 6 tests; trusting GitHub without git's ancestry check fails 2. The workflow config test passes 2/2 and fails if pull-requests: read is removed.
  • A strict TypeScript check of the three guard scripts passes. No project typecheck covers mobile/scripts/*.mts, so this was run separately; that gap predates this PR.
  • Real repo, CI-shaped clone: main's tip resolves through refs/pull/22762/head in about 2 s; fix(omp): attach desktop and mobile images through file mentions #21674's squash (edited title) resolves through refs/pull/21674/head; a commit a force-push removed from feat(terminal): add Reset Terminal that clears leftover input modes on the host and pane #23602 fails.

Known limits, all failing loudly rather than passing wrongly:

  • While main's pin is held only by a PR, the job makes one GitHub API call. A network or API blip turns the job red until it is re-run.
  • A local run of reachable or reproduce then needs access to api.github.com. A local clone whose origin is a fork fails without saying the fork is why.
  • Only the first 30 PRs GitHub lists are checked.
  • Accepted risk, also stated in the PR body: on a push to main, the reproduction step runs the recording suites from the pinned PR commit, which is not in main's history. That commit already ran in the PR's own reproduction and the job token is read-only.

App QA: not applicable. This PR changes only CI and test tooling, with no app, mobile, Windows or SSH code, so Electron and emulator QA were not run. The live evidence is the PR's own recording-pin job above.

Not caused by this PR: an earlier run's "static analysis" red came from a localization key missing in main's en-runtime-required.json; it is green at this head. On a PR run, the repin instruction names the temporary merge-preview commit; that predates this PR.

@brennanb2025
brennanb2025 merged commit c5fc0c6 into main Sep 29, 2026
38 checks passed
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
Merging main brought #22762's recordings, #23757's repin and #23720's recorder change, so the
corpus is repinned to the merge commit, the last commit to touch a recorded path, and re-recorded
whole. Against main, 786 recordings move only their baseline header and 4 native chat recordings
change content: their nativeChat.subscribe and nativeChat.unsubscribe carry the per-subscription
token instead of claude:session-1, which also moves their scenarioSha256.
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
…3700, #22943, #23720, #23793, #23776, #23796) into #23059

#23573 (keep a turn's bar on the prompt that opened it) is ported onto the
turn-record membership instead of kept as a second owner lookup:
- The running turn's bar comes from nativeChatTurnMembership, which now
  returns barTurnKey beside liveTurnKey. Where the host states each row's
  turn they are the same key: the running root turn's anchor, and a
  message handed over mid-turn is already scoped to that turn. Where the
  host states no scope, rows still group by position, so barTurnKey is the
  user entry the running record names (through the same anchors) while
  liveTurnKey keeps the positional live group, as #23573 kept row liveness
  on the newest prompt.
- activeTurnOpenedBy, selectStructuredAgentTurnBars' openedBy and
  selectNativeChatActiveTurnKey are removed; the desktop list, the slot
  builder and both turn-status hooks read barTurnKey.
- The queued-send clock (queuedUntil: a turn counts from the previous
  turn's end when its send waited behind it) is kept, read in the same
  one-pass walk over root turn records that keys timing by anchor.
- Its tests are adapted to pass a journal: each runs on a host that
  states no scope (the original expectations), and the desktop and mobile
  bar tests also run on a scoped host.

#23621 (a message Claude folds into its running turn no longer splits the
turn) is host-only and merged as is: the translator contract carries both
openTurnInLiveProviderCycle and #23059's command-turn members.

Both sides grew the Claude translator past its line budget, so its result
branch moves unchanged into claude-result-journaling.ts, beside
claude-message-journaling.ts (the pre-commit lint refuses the merge
without it).

#23801's Codex child path (no error-driven end) and #23059's Codex /compact
guard (a command turn ends only on turn/completed) both stand.
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
Main's #23720 taught the RPC recording pin guard to find a squash-dropped
pin through its pull request's head. This branch removes the pin, the guard,
its CI job and the pin-checkout test, so the guard, its test, the new
rpc-recording-pin-reachability.mts, the checkout test and the job stay
deleted; nothing in #23720 outlives the pin. #23815's README wording edit
fell inside the deleted pin section and is superseded by this branch's text.
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
…chat feed that replaced it (#22939)

* fix(mobile): don't unsubscribe a terminal stream that already ended

* fix(mobile): keep the stream registry under the line cap and expect no error after a streamed end

The streamed `end` now closes a direct stream, so a later reply for that id is unrouted instead of
reaching the listener as an error; the subscription recording test expected the old error. Inline
the error wrapper so the registry fits the 300-line cap, and shorten the comments.

* fix(mobile): reopen a native chat stream the host ended while the screen still shows it

* fix(mobile): only the focused screen takes back a host-ended chat feed, and a reopen keeps loaded history

* fix(mobile): give each native chat subscription its own token, and reopen with the first page

* test(mobile): pin the reopened chat subscribe params without a cast

* fix(mobile): show a host-ended chat feed as an error instead of reopening it

With a token per subscription, the desktop ends a phone chat feed only when the
phone closes it or the socket drops: no client sends the connection-wide chat
unsubscribe, a socket close delivers no end, and every desktop with mobile chat
keys feeds by the client's token. The reopen-with-backoff layer and the
history-keeping reopen merge guarded a trigger that no longer exists, so they
are removed. An end that still reaches the screen settles the feed as an error,
so a dead feed is never shown as live; leaving and re-entering the chat
subscribes again with a fresh token.

* test(mobile): re-record the RPC goldens for the per-subscription chat token

Each nativeChat.subscribe now sends its own token, so the native chat scenarios
expect `claude:session-1:<id>` in the subscribe params, and the four native chat
recordings (native-chat-page-earlier and the session.native-chat-page matrix)
record that token in their subscribe and unsubscribe payloads. Every other
golden moved only its `baseline` header, repinned to the commit recorded from.

* test(mobile): repin RPC recordings to the merge with main and re-record

Merging main moved the product tree the recordings are pinned to, so the
baseline is repinned to the merge commit and the whole corpus re-recorded.
Only the four native chat recordings change content, because each
nativeChat.subscribe now carries a per-subscription token; every other
recording moves only its baseline header.

* test(mobile): repin RPC recordings to the merge with main and re-record

Merging main brought #22762's recordings, #23757's repin and #23720's recorder change, so the
corpus is repinned to the merge commit, the last commit to touch a recorded path, and re-recorded
whole. Against main, 786 recordings move only their baseline header and 4 native chat recordings
change content: their nativeChat.subscribe and nativeChat.unsubscribe carry the per-subscription
token instead of claude:session-1, which also moves their scenarioSha256.
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