Repository navigation
fix(github): use the pinned gh account on every PR, Checks and branch-prefix path - #170
Merged
Merged
Conversation
The PR refresh queue attached the repo's account binding to its candidate, then dropped it: `GitHubPRRefreshCandidate.localGitOptions` declared only `wslDistro`, and `hostedReviewOptionArgs` copied exactly that field. Every background and visible branch→PR lookup therefore ran as the ambient `gh` login, so a repo bound to another account had its own PRs read as absent — which is what empties the Checks panel and the review pane. Carry `ghAccount` through the candidate type and the policy copy. The read cache already keys on the full execution scope, so a rebind cannot serve the previous account's result.
Creating a workspace probes for an existing PR on the candidate branch so a PR that belongs to someone else does not silently take the name. Those probes run `gh pr list` with the WSL route only, so a repo bound to another account could not see its own PR: Orca suffixed the branch (or adopted the wrong one) while the PR sat there under the pinned login. Thread the binding through both create paths. The helper that builds gh execution options is now what the probes receive, so `ghAccount` survives the route in one place instead of being rebuilt per call site.
`resolveLocalGitUsername` answers "who is this repo's user" with the machine's active `gh` login, cached process-wide. A pinned repo therefore generated branch prefixes, and showed a Settings username, for an account Orca is not supposed to act as. When the repo carries a binding, use that login and skip the probe entirely. Explicit `github.user`/`user.username` git config still wins, and the remote-is-GitHub gate still runs, so a GitLab checkout cannot borrow a GitHub login as a prefix.
nplez1
added a commit
that referenced
this pull request
Oct 24, 2026
…ne runs (#178) * test(unit-gate): run the unit lane's file set and the fork-local tests Two gaps made a gate verdict narrower than it read. The suite ran `defaultExclude` rather than upstream's `UNIT_EXCLUDE`, so it collected 80 files the unit lane quarantines — electron, node-pty, live-shell and the whole cross-version-wire directory — and charged this fork for their reds. And `local/**/*.test.mjs` match nothing in `UNIT_INCLUDE`, so the sync-tooling tests were in no lane at all (fork issue #151 § 3 and § 5). The exclusion switch is `ORCA_BALANCE_UNIT_SHARDS=1`, the one `config/vitest.config.ts` already reads; a `--exclude` flag cannot reach the projects because each sets `extends: false`. Since parity is now a switch, the gate asserts the report collected none of the quarantined files and fails closed if one appears, and it treats an allowlist entry for a quarantined file as a problem rather than letting an entry that can never match sit there. Fork-local tests run first, so a broken sync tool cannot produce a verdict about anything else, and the summary line reports both facts. * test(unit-gate): name every allowlisted failure and drop the quarantined files The manifest was 15 entries, 14 of them file-level wildcards. A wildcard also covers a NEW failure in the same file, which is how one hid for two syncs. Every entry now names its test title, taken from a reconciliation run over the allowlisted files whose arithmetic closes: 32 allowlisted + 5 upstream-quarantined + 1 fixed = 38 records. Three files leave the manifest because the gate no longer runs them: upstream's own unit lane excludes repro-13767, relay-region-correction and the whole cross-version-wire directory, so their reds are upstream's to carry. Ownership is corrected where it was unattributed — both remaining `unattributed` files are upstream files this fork never touched. * test(runtime): assert the documented undefined read for an unbound pane `terminal-pane-screen-prompt.ts` returns `undefined` for a pane it cannot bind to a terminal, and says why in the method's own doc comment: a restored pane reconnects after the hook store starts, so "cannot see it" must not read as "no dialog". The case asserted `toBeNull()` for that path in the same commit that added both (`3526000b5c`), so it never passed — and a file-level allowlist entry kept it hidden inside a 1,476-case file. Found by tightening `local/unit-known-red.json` to test titles (fork issue #151 § 1). Renamed to match what it asserts. * docs(fork): record issue #151's allowlist rework and correct the extend-test diagnosis LOCAL-PATCHES.md gains the section for this work, and the extend-test entry is corrected where fork issue #151 § 4 says it no longer matches the import graph: `ephemeral-vm-runtime-extend.ts:22` imports only `getSshConnectionManager`, so the mock was complete for the module under test and the missing export was only visible to what that module reaches. The 28 `TypeError: {} is not iterable` rejections were a second cause — the renderer's reclaim bridge iterating a non-list `listRuntimes` answer, fixed in `2368ed38da` — which the recorded sentence welded to the mock because both appeared in one run. BRANCHES.md gets the branch's entry and its place under nplez1/main. * test(tools): put the unit gate's tests where the unit suite collects them `tests/tools/**` is in `UNIT_INCLUDE` and is where `local/gate-lint.mjs` keeps its tests, so the gate's judging rules run in the suite rather than only in the gate's own fork-local lane. The lane stays, because `local/sync/lib/*.test.mjs` are still outside `UNIT_INCLUDE` and are what fork issue #151 § 5 is about. Written as vitest to match `tests/tools/lint-gate.test.mjs`; same assertions. * fix(unit-gate): judge an isolated re-run per test, and stop a dead entry hiding Two gaps that naming the entries opened, both from the Opus review round. The isolation re-run asked whether the *file* passed alone. With named entries that question is unanswerable: the file's own allowlisted reds still fail when it runs alone, so a load flake in a file that also has recorded reds always looked like a real break — process-host-dev-rebuild and orca-runtime are both that shape. The re-run now writes its own JSON report and a failure counts as reproduced only when that same test failed there; a missing report still counts as reproduced, so it fails closed. `unseen` meant "the file did not fail", which cannot happen to a dead entry in a file that still reds elsewhere — so a renamed case left its entry matching nothing forever. It now means "nothing in the run matched this entry and it is not stale", which covers the renamed case and the vanished file alike. Also here: the fork-local lane gets its own five-minute deadline instead of the suite's hour, `closeSync` is imported (every `closeSyncSafe` had been throwing into its own catch, leaking the log descriptor), the duplicate JSDoc on `judgeUnhandled` is gone, and `repoPath` normalises the checkout prefix so the new quarantine check can fire on Windows too. The two new checks are extracted and tested rather than inlined in `evaluate()`. * fix(cli): link the launcher this fork actually ships in the privileged repair case The case symlinked `/Applications/Old Orca.app/.../bin/orca` and expected the installer to adopt it. This fork ships `orca-np` (`cli-install-constants.ts:6`), and `isManagedSymlinkTarget` rejects a target whose basename differs from the launcher's own name (`cli-command-inspection.ts:117`), so the installer read its own launcher as a foreign command and refused it: `Refusing to replace non-Orca command at /var/folders/...`. The two sibling cases in this file already link `old/orca-np` — this one arrived later from upstream, after the fork's identity patch. One hunk, and the red is gone rather than recorded, so its allowlist entry goes with it. `local/unit-known-red.json` therefore drops to 31 named entries and its `observedRun` arithmetic closes at 38 records: 31 allowlisted, 5 upstream-quarantined, 2 repaired. The note also stops contradicting itself about keeping an entry that has stopped reproducing: prune wins, and LOCAL-PATCHES.md stays the history of why a class was red. * test(ephemeral-vm): mock the module the extend unit actually imports `vi.mock('./ipc/runtime-environments')` named a path the 2026-10-19 module reorganisation deleted; the code imports `./ipc/runtime-environments/runtime-environments` (`ephemeral-vm-runtime-extend.ts:16`) and the directory has no `index.ts`, so the mock was inert and the real module loaded with everything it reaches. That is the mechanism behind the failure `LOCAL-PATCHES.md` recorded by guess: a gap in the mocked SSH registry surfaced thirty frames away, because the graph the dead mock failed to cut still read `getSshTargetRegistryStore`. Naming the real module is the fix; the registry mock stays as it is. * docs(fork): re-diagnose the extend-test red and record the review round's corrections The review round found the recorded cause wrong twice over, so LOCAL-PATCHES.md now says what is checkable: - the extend test's mock named `./ipc/runtime-environments`, a path the 2026-10-19 reorganisation deleted, so it was inert and the real module loaded — which is why a registry-mock gap surfaced thirty frames away; - the `TypeError: {} is not iterable` rejections had their own cause, the renderer reclaim bridge iterating a non-list answer, fixed in `2368ed38da`; - both files are fork-owned (`902955072a` is fork PR #81, absent from `upstream/main`), so the issue's "send it upstream" premise does not hold. The `local(test)` section also records the two reds the tightening repaired, the per-test isolation rule, the new `unseen` meaning, and the resolved keep-vs-prune contradiction. BRANCHES.md follows: 31 entries, and what § 4 actually turned out to be. * fix(unit-gate): do not call every entry unseen when a selector filters the run A forwarded selector describes a different suite, so every entry outside it matches nothing. Reporting those as unseen made a one-file smoke run print all 31 entries as prune candidates, which is the false signal the new rule was supposed to avoid. Unseen is now only judged when the gate runs the whole suite, and a filtered run says so instead. The quarantine list also stops at twelve names without saying so; it now counts the rest. * fix(unit-gate): waive a failure only when the re-run saw that test pass The per-test rule asked whether the re-run *failed* the test, which is not the same as proof it passed. Three shapes slipped through as waivable flakes: a collect error in the re-run replaces every case with one `(suite)` entry, a failing `beforeAll` reports its cases as skipped, and a report with no files at all has an empty failure set. In each, the original test is absent — and absent is not evidence, which is the rule a missing report already followed. `reproducedFailures()` now waives only a test the re-run reported as passing; a `(suite)` failure is waived only when the file itself passed. A corrupt isolation report is parsed locally instead of through `readJsonFile`, which would exit mid-verdict. `prunableEntries()` replaces the bare `fullRun` filter for the same reason: an entry may be called unseen only on a complete, unfiltered run, and not when its file reported nothing but a collect failure. `repoPath` now checks the path separator, so a sibling checkout named `issue-151-x` no longer reads as inside this one. The judgement moved to `local/unit-gate-judgement.mjs`: it is pure over data the gate already holds, it is what the tests now import, and the gate had grown past this fork's 600-line budget carrying both roles. * docs(fork): point the old privileged-CLI entry at its re-diagnosis `local(test)` § "five more environment-bound reds" filed that case under the `/private/var` symlink cause, which the re-diagnosis two sections down now contradicts — the recorded error path is `/var/…` and the cause is the fork's `orca-np` rename. The bullet says so and points at the entry, rather than leaving two causes for one red. Also names the reorganisation that deleted the extend test's mock path (`1938bd055a`, stablyai#30362) and records where the gate's judgement now lives. * fix(unit-gate): name the preparation steps so the failure line type-checks The changed-code gate's type-aware pass rejects `${label}` in the preparation failure line: destructuring a heterogeneous tuple array widens `label` to `string | string[]`. Objects give it one type, and the fork-local lane still runs before both. * fix(unit-gate): refuse a waiver the re-run contradicts, and read one file's report Round-3 delta findings, both one hunk. A waiver now needs the pass to be the whole story: a name the same report also failed (a `test.each` duplicate) or a `(suite)` entry beside it (a hook broken under) keeps the failure, which is also what puts `rerun.failures` back to work instead of leaving it built and unread. The re-run is also read per file — `reportForFile()` filters by path, because a positional selector is a substring match and `thing.test.ts` collects `thing.test.tsx` too. That function is tested directly, which the `filePassed` branch was not. Prune advice stays silent on a report with no tests at all, not merely on one that did not complete. * test(ipc): accept the gh-account argument the branch-prefix login now takes `a8ca9685a3` (#170) made the branch-prefix login follow the repo's pinned gh account: `resolveLocalGitUsername(repoPath, ghAccount)`. This upstream case still asserted the one-argument call, so `nplez1/main` has been red on it since that merge — it surfaced as the only unallowlisted failure of the first full gate run on this branch, which is exactly what the tightened allowlist exists to show. The case's repo has no binding, so the second argument is `undefined`. * docs(fork): record the gate verdict for issue #151 Verdict on the revision that ships, and the honest note that its first full run found a red the base had carried since #170 rather than a red this branch made — an upstream case still asserting the one-argument branch-prefix login. No entry was stale and none was unseen, which is the check that the tightening was faithful rather than merely equivalent to the wildcard it replaced. BRANCHES.md carries the same verdict plus the three review rounds. * fix(unit-gate): order the fs imports NIT from the merge-resolution review: `closeSync` sorts before `openSync`. EOF2 * docs(fork): reframe the gate verdict the #177 merge superseded PR #177 landed `local/gate-verdict-cache.mjs` and made `local/open-pr.mjs` read it, so a verdict now belongs to one exact revision and the shipped one is quoted in the PR body. This records the earlier full run as what it was — the first run after the tightening, before #177 — instead of calling it the shipped revision's verdict, and notes the merge-resolution review round. Raised as the only MINOR by the review of the merge resolution.
nplez1
added a commit
that referenced
this pull request
Oct 28, 2026
The release gate on the merge found 140 failures across 25 test files. Three were merge damage in product code: - `updater-prerelease-feed.ts`: upstream's new `fetchLatestStableReleaseTag` hardcoded `stablyai/orca` in both the `releases/latest` URL and the redirect regex, so a fork build's stable-fallback probe never matched the fork's own redirect and every background check died in preflight. Retargeted to `nplez1/orca` with the rest of the file. - `use-checks-panel-ai-acknowledgement.tsx`: the resolution dropped the latest-consumer refresh ref both parents had, so a head-churn rerender bound the post-launch refresh to a stale `fetchComments` and the forced refresh was silently dropped. - `ai-vault-session-refresh.ts`: upstream declares the throttle test hook in this module; the fork's throttle lives in its own file, so the name is re-exported from where upstream's suites import it. The rest were expectations that predate the code they assert — the fork's own PRs (#134 refresh-on-refusal, #169 reply-only comment ack, #170 gh exec options, #198 keep-cached-check-details, #175 window binding) changed behaviour with `pr.yml` disabled and no unit lane backstopping them, so `main` was red before this merge. Each expectation now asserts the fork's contract; no test was deleted, skipped, or widened. Four reference repairs follow modules the merge moved (`filesystem-auth`, `filesystem-search-file-paths`), two fixtures gained fields upstream added, and two suites needed the WSL gate mocked so they stop spawning a real `wsl.exe` per case. `ws-inbound-message-queue.test.ts` is a GC-timing flake, not a fix: it passes 18/18 in isolation and the gate's isolation re-run reproduces it as green. Verified per file with `pnpm test <path>` — all 25 green — plus `pnpm tc:web` clean and the identity sweep still 0 fixable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
Issue #167 asks Orca to pin a GitHub account for all of its
ghinteractions without touching theuser's globally active login. The pinning mechanism itself is already on
nplez1/main(repo-scopedbinding,
gh auth token --user <account> --hostname <host>resolved into a child-onlyGH_TOKEN/GH_ENTERPRISE_TOKEN, and the Settings control). What it did not do was hold on realcall paths: three of them dropped the binding and ran as the ambient login.
This branch closes those three, so the issue's promise — every Orca
ghsubprocess uses the pinnedaccount, and nothing falls back silently — actually holds.
The gaps this fixes
1. PR refresh ran as the ambient login — the exact symptom in the issue.
d93cf4c7b7GitHubPRRefreshCandidate.localGitOptionsdeclared onlywslDistro, andhostedReviewOptionArgs()copied exactly that field. The producer(
applyRegisteredRepoToPRRefreshCandidate) had the binding and attached it; the copy threw it away.Every background and visible branch→PR lookup therefore ran as the ambient account, so a repo pinned
to another account had its own PRs read as absent — which is what empties the PR pane and the Checks
panel, precisely the breakage the issue reports.
The same commit scopes the refresh key by account. Without it, a repo re-pinned from A to B kept
polling as A: the queue re-schedules from the candidate it last ran, and its non-promoting merge only
refreshes
cacheKey/branch/currentHeadOid/isSelected. Ambient keys are byte-identical tobefore, so nothing else about the queue moved.
2. Worktree create probed for branch PRs as the ambient login.
9e2d56e57aThe PR-collision probes in both create paths took WSL-only options, so a repo pinned to another
account could not see its own PR on the candidate branch: Orca suffixed the branch (or adopted the
wrong one) while the PR sat there under the pinned login. The probes now receive the output of
getLocalProjectGhExecOptions— the one blessed builder — rather than a hand-rebuilt option object.3. The branch-prefix login came from the ambient account.
33be44b013resolveLocalGitUsername()answered "who is this repo's user" with the machine's activeghlogin,cached process-wide. A pinned repo therefore generated branch prefixes, and showed a Settings
username, for an account Orca is not supposed to act as. A bound
github.comrepo now uses its boundlogin and skips the probe entirely. Explicit
github.user/user.usernamegit config still wins, theremote-is-GitHub gate still runs, a GHES binding is not turned into a github.com prefix, and the
process-wide ambient cache is never read or written on the bound path.
Acceptance criteria
Repo['ghAccount'], Settings → Repository → GitHub account (RepositoryGitHubAccountSection.tsx), persisted and re-normalized on hydrateghsubprocesses use the configured accountresolveGitHubRepoExecution; branch→PR probes in create fixed hereghaccount is not changedgh auth switchexists anywhere insrc/(checked); the token is injected into the child env only and never process-wideBound GitHub account <user>@<host> is unavailable on this runtime.— the failure names the account and does not fall back to the active oneDeliberately still ambient (documented, not defects)
src/main/github/project-view/internals.tsstates the exclusion explicitly.authargv is exempt frombinding by design inside the runner; binding it would recurse.
gh api rate_limit— host- and runtime-scoped, not account-scoped(
src/main/github/rate-limit.ts).gitUsername— enriched once per session, so Settings' stored copy is stale after arebind until relaunch. Create paths resolve the username live, so branch prefixes are correct
immediately.
new account and replaces it.
Verification
Run on the shipped revision
33be44b013, in this worktree, throughorca-queue:pnpm tc— clean (No type errors in 18,060 files, plus the 3,231 / 34 / 16,084 projects).src/main/github/pr-refresh*,src/main/github/client-pr-lookup*,src/main/github/gh-account-token*,src/main/git/runner-gh-account*,src/main/git/git-username*,src/main/repo-git-username*,src/main/agent-hooks/first-work*,src/main/runtime/runtime-worktree-create*,src/main/runtime/runtime-local-worktree-create*,src/main/ipc/worktree-remote*,src/main/project-runtime-git-options*,src/main/ipc/github-repo-routing*,src/main/github/github-repository-identity*,src/shared/github*.pnpm run check:code-quality:changed— passed, 0 new findings across 16 changed files.Not run, deliberately: the full
pnpm testsuite (known runtime trap on this machine — theinstruction was not to block on it). A wider 26-file run of every suite that mocks
project-runtime-git-options(497 tests) was also green, since that module gained a consumer.The tests fail without the fix, which is what makes them worth anything: reverting the policy
copy produces 3 failures in
pr-refresh-gh-account-binding.test.ts, and stubbing the account out ofrefreshKeyre-breaks the rebind test plus the key unit test.Opus review
Reviewed by Opus 5.5, high (
claude/opus), tool-enabled and adversarial over the actual commits.nplez1/main..aca3264a54): CHANGES-REQUESTED — 0 BLOCKER, 1 SHOULD-FIX, 2 MINOR, 4 NIT.The SHOULD-FIX was real: with the binding now honoured,
refreshKeyignoring the account meant are-pinned repo kept polling as the previous account (criterion 2, and it muddied criterion 4). Both
MINORs were also taken: a GHES binding could become a github.com branch prefix, and the create-path
test only exercised the fallback rather than the production call shape.
aca3264a54..HEAD): APPROVE, delta-clean on all six answered findings, with three NITsand no new defects (checked for stranded queue entries, double-polling, ambiguous keys, tier
disagreement and import cycles).
(
not.toContainEqual(null)can never fire, since an unbound call yieldsundefined). Test-only;no production code changed. R2's other two NITs were left as-is by design: GitHub logins are
case-insensitive so lowercasing the key segment is harmless and would be wrong to extend to GHES
logins, and the multi-window rebind window is bounded and self-healing.
No production code changed after the APPROVE verdict.
Fixes #167