Files
orca/src/main/runtime/runtime-provider-command-ssh-routing.test.ts
T
Neil 12bf32836b feat(ci): ratchet raw repo connectionId host checks; migrate the cheap ones (#31096)
* feat(ci): ratchet raw repo connectionId host reads; one drop-in resolver

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.

* fix(ipc): PR base IPC routes executionHostId-only SSH rows; ratchet is 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.

* test(ci): pin the repo host-read ratchet step to the static phase

* fix(ci): repo host-read ratchet skips verbatim field copies into projected 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.
2026-10-20 14:00:32 -07:00

72 lines
2.3 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { Repo } from '../../shared/repo-types'
const { getIssueMock, listTodosMock } = vi.hoisted(() => ({
getIssueMock: vi.fn(),
listTodosMock: vi.fn()
}))
vi.mock('../github/client', () => ({
getIssue: getIssueMock,
getPRCheckDetails: vi.fn(),
getPRChecks: vi.fn(),
getPRComments: vi.fn()
}))
vi.mock('../github/work-item-details', () => ({ getPRFileContents: vi.fn() }))
vi.mock('../gitlab/client', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
listTodos: listTodosMock
}))
import { RuntimeGitHubReviewQueryCommands } from './runtime-github-review-query-commands'
import { RuntimeGitLabQueryCommands } from './runtime-gitlab-query-commands'
function repoOn(fields: Pick<Repo, 'connectionId' | 'executionHostId'>): Repo {
return {
id: 'repo-1',
path: '/srv/project',
displayName: 'project',
badgeColor: '#000',
addedAt: 0,
kind: 'git',
...fields
}
}
// Why: these commands used to pass the raw `connectionId`, so an `ssh:`-only row ran gh/glab here.
describe('runtime provider commands route an SSH project to its host', () => {
beforeEach(() => {
getIssueMock.mockReset().mockResolvedValue(null)
listTodosMock.mockReset().mockResolvedValue([])
})
it.each([
['executionHostId only', { executionHostId: 'ssh:gpu' as const }, 'gpu'],
['legacy connectionId', { connectionId: 'gpu' }, 'gpu'],
['local', { executionHostId: 'local' as const }, null]
])('GitHub issue lookup (%s)', async (_label, fields, expected) => {
const commands = new RuntimeGitHubReviewQueryCommands({
resolveRepo: async () => repoOn(fields),
getLocalGitArgs: () => []
})
await commands.getRepoIssue('id:repo-1', 7)
expect(getIssueMock).toHaveBeenCalledWith('/srv/project', 7, expected)
})
it.each([
['executionHostId only', { executionHostId: 'ssh:gpu' as const }, 'gpu'],
['local', { executionHostId: 'local' as const }, null]
])('GitLab todo list (%s)', async (_label, fields, expected) => {
const commands = new RuntimeGitLabQueryCommands({
resolveRepo: async () => repoOn(fields),
getLocalGitArgs: () => [],
recordProjectRecent: () => {}
})
await commands.listGitLabRepoTodos('id:repo-1')
expect(listTodosMock).toHaveBeenCalledWith('/srv/project', expected)
})
})