Repository navigation
feat(ci): ratchet raw repo connectionId host checks; migrate the cheap ones - #31096
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
Codex review 6 class fix (#4/#6/#7): host decisions read off a repo row's legacy connectionId miss rows that name SSH only as executionHostId. - getRepoRoutingConnectionId (shared/execution-host.ts): drop-in for a raw repo.connectionId routing check that also finds executionHostId-only SSH. - check-repo-host-read-ratchet: per-file count of raw repo connectionId reads in src/main, src/shared, src/cli; counts may only shrink. - Migrated 66 cheap reads: runtime GitHub/GitLab commands, PR/MR head ref fetches, preserved-branch cleanup, ref queries, base-ref IPC, worktree preparation, trash sweep, scan cache TTL, usage metadata.
…s a stated lower bound Review follow-up (Opus on #31096): - worktrees:resolvePrBase decided git/gh routing on the raw connectionId while its head-ref fetches already used the resolver; one resolved connectionId now drives all of it (test fails on main). - getRepoRoutingConnectionId's contract is stated exactly: never local when the raw field is set; on a contradictory ssh row executionHostId wins. - The ratchet regex no longer matches report.connectionId; header and docs say it is a lower bound. - Regression tests for a runtime GitHub and GitLab command site.
78069e0 to
a79b3ad
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
3ace6565-44e9-4f1d-a510-c729ccbeadd7
📒 Files selected for processing: 27
.github/workflows/pr.ymlconfig/repo-host-read-baseline.txtconfig/scripts/check-repo-host-read-ratchet.mjsconfig/scripts/check-repo-host-read-ratchet.test.mjsconfig/scripts/pr-preflight-gates.test.mjspackage.jsonsrc/main/github/pr-head-tracking-ref.test.tssrc/main/github/pr-head-tracking-ref.tssrc/main/gitlab/mr-head-tracking-ref.tssrc/main/ipc/repos/base-ref-query-handlers.tssrc/main/ipc/worktrees-ssh-pr-head-fetch.test.tssrc/main/ipc/worktrees/create/register-review-base-handlers.tssrc/main/runtime/runtime-github-issue-comment-commands.tssrc/main/runtime/runtime-github-repository-query-commands.tssrc/main/runtime/runtime-github-review-mutation-commands.tssrc/main/runtime/runtime-github-review-query-commands.tssrc/main/runtime/runtime-gitlab-mutation-commands.tssrc/main/runtime/runtime-gitlab-query-commands.tssrc/main/runtime/runtime-preserved-branch-cleanup.tssrc/main/runtime/runtime-provider-command-ssh-routing.test.tssrc/main/runtime/runtime-repository-ref-queries.tssrc/main/runtime/runtime-worktree-scan-cache.tssrc/main/usage-worktree-metadata.tssrc/main/worktree-create-preparation.tssrc/main/worktree-trash.tssrc/shared/execution-host.tssrc/shared/repo-routing-connection-id.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
|
|
||
| /** Raw `<repo>.connectionId` reads in one file's code; comments are prose and do not count. */ | ||
| export function countRawRepoHostReads(text) { | ||
| return [...stripSlashComments(text).matchAll(RAW_READ)].length |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Exclude string literals from raw-read counts.
stripSlashComments preserves quoted text, so this regex counts a string such as 'Replace repo.connectionId with getRepoRoutingConnectionId(repo)' as a property read. If a developer adds that message to a scanned file, the ratchet can fail pnpm lint and the static-analysis job although the code adds no raw read. Use a token-aware count that excludes literal text but still counts reads inside template interpolations.
…ected rows A copy of connectionId into a projected row decides nothing; migrating it to the resolver would change what the projection publishes. The sidebar feed catalog's copy (added after the baseline) and two older projections no longer count; baseline pruned to 91.
ELI5
A project row records which machine it lives on in two ways: the old
connectionIdfield, and the newerexecutionHostId(for examplessh:gpu). Newer rows sometimes fill in only the newer one. A lot of code still decides "is this project on SSH?" by reading only the old field, so it treats those newer SSH projects as local and runs commands on the wrong computer. Codex review 6 found three bugs of this kind.This PR adds a drop-in helper that reads both fields, switches the easy existing checks over to it, and adds a CI ratchet so new raw checks can't creep back in.
This follows #31054 (worktree base), #31055 (project dedupe) and #31066 (CLI host), all merged.
What Changed
getRepoRoutingConnectionId(repo)(src/shared/execution-host.ts) replaces a rawrepo.connectionIdin routing and "is this SSH?" checks.executionHostId: 'ssh:<target>', which the raw field reported as local.ssh:Brow withconnectionId: 'A', B wins, as everywheregetRepoExecutionHostIdis used.config/scripts/check-repo-host-read-ratchet.mjsplusconfig/repo-host-read-baseline.txt.<repo>.connectionIdreads per file insrc/main,src/sharedandsrc/cli. Comments, assignments, tests and the resolver modules are excluded.repo/*Repo*aren't seen.pnpm lintand in the pr.yml static job, and its failure text names the helpers to use instead.runCountRatchetand the existing comment stripper.executionHostId, each of these used to run or route locally and now refuses or routes over SSH:repo.connectionId ?? nullworktrees:resolvePrBaseIPC handler, whose git/gh routing read the raw field while its head-ref fetches did notWhy
The three review items (#4 worktree base, #6 CLI host, #7 project dedupe) are one bug class: host identity read from a legacy field or dropped. Fixing three call sites would leave the class alive.
A drop-in helper plus a shrink-only ratchet makes the safe path the easy one, and stops new raw checks from landing.
I chose a per-file count over per-function entries, because the existing count ratchets show it is stable under refactors.
Renderer files are out of scope for now: they belong to the renderer strict-read-routes work.
Linked Issue
N/A (internal review finding: Codex review 6, class fix for #4/#6/#7).
Visual Proof
N/A. This is CI tooling and server-side routing; nothing is drawn differently.
Testing
config/scripts/check-repo-host-read-ratchet.test.mjschecks what counts and what doesn't: reads, writes, comments, type positions, other receivers, and the excluded files.src/shared/repo-routing-connection-id.test.tschecks the helper on every row shape, and that it agrees with the raw field whenever that field is set.pr-head-tracking-ref.test.tsadds a fetch that refuses anexecutionHostId-only SSH row.worktrees-ssh-pr-head-fetch.test.tsadds a PR-base IPC that refuses local git for that row. It fails on main.runtime-provider-command-ssh-routing.test.tscovers one GitHub and one GitLab runtime command site.Review
gpt-6.1-sol, high): no findings, on both the original and the final head.reportfalse positive, the lower-bound wording, and command-site tests.Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)