mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 19:17:28 +00:00
* 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.
179 lines
5.4 KiB
TypeScript
179 lines
5.4 KiB
TypeScript
import type { ListWorkItemsResult } from '../../shared/github/work-item-types'
|
|
import type { Repo } from '../../shared/repo-types'
|
|
import type { LocalProjectGhExecOptions } from '../project-runtime-git-options'
|
|
import {
|
|
countWorkItems,
|
|
getWorkItem,
|
|
getWorkItemByOwnerRepo,
|
|
listAssignableUsers,
|
|
listIssues,
|
|
listLabels,
|
|
listWorkItems,
|
|
type MainWorkItem
|
|
} from '../github/client'
|
|
import {
|
|
listGhAccountBindingInventory,
|
|
validateGhAccountBinding
|
|
} from '../github/gh-account-binding-inventory'
|
|
import { getRateLimit } from '../github/rate-limit'
|
|
import { resolveGhAccountRequiredHost } from '../github/account-binding-required-host'
|
|
import { getWorkItemDetails } from '../github/work-item-details'
|
|
import { getRepoRoutingConnectionId } from '../../shared/execution-host'
|
|
|
|
type LocalGitArgs = [] | [LocalProjectGhExecOptions]
|
|
|
|
type RuntimeGitHubRepositoryQueryCommandsDeps = {
|
|
resolveRepo: (selector: string) => Promise<Repo>
|
|
getLocalGitArgs: (repo: Repo) => LocalGitArgs
|
|
}
|
|
|
|
export class RuntimeGitHubRepositoryQueryCommands {
|
|
constructor(private readonly deps: RuntimeGitHubRepositoryQueryCommandsDeps) {}
|
|
|
|
async listRepoWorkItems(
|
|
repoSelector: string,
|
|
limit?: number,
|
|
query?: string,
|
|
page?: number,
|
|
noCache?: boolean
|
|
): Promise<ListWorkItemsResult<MainWorkItem>> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
return listWorkItems(
|
|
repo.path,
|
|
limit,
|
|
query,
|
|
page,
|
|
repo.issueSourcePreference,
|
|
getRepoRoutingConnectionId(repo),
|
|
noCache,
|
|
...this.deps.getLocalGitArgs(repo)
|
|
)
|
|
}
|
|
|
|
async listRepoIssues(
|
|
repoSelector: string,
|
|
limit?: number
|
|
): Promise<Awaited<ReturnType<typeof listIssues>>['items']> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
const result = await listIssues(
|
|
repo.path,
|
|
limit,
|
|
repo.issueSourcePreference,
|
|
getRepoRoutingConnectionId(repo),
|
|
...this.deps.getLocalGitArgs(repo)
|
|
)
|
|
return result.items
|
|
}
|
|
|
|
async getRepoWorkItem(
|
|
repoSelector: string,
|
|
number: number,
|
|
type?: 'issue' | 'pr'
|
|
): Promise<Awaited<ReturnType<typeof getWorkItem>>> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
return getWorkItem(
|
|
repo.path,
|
|
number,
|
|
type,
|
|
getRepoRoutingConnectionId(repo),
|
|
this.deps.getLocalGitArgs(repo)[0] ?? {},
|
|
repo.issueSourcePreference
|
|
)
|
|
}
|
|
|
|
async getRepoWorkItemByOwnerRepo(
|
|
repoSelector: string,
|
|
ownerRepo: { owner: string; repo: string; host?: string },
|
|
number: number,
|
|
type: 'issue' | 'pr'
|
|
): Promise<Awaited<ReturnType<typeof getWorkItemByOwnerRepo>>> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
return getWorkItemByOwnerRepo(
|
|
repo.path,
|
|
ownerRepo,
|
|
number,
|
|
type,
|
|
getRepoRoutingConnectionId(repo),
|
|
...this.deps.getLocalGitArgs(repo)
|
|
)
|
|
}
|
|
|
|
async getRepoWorkItemDetails(
|
|
repoSelector: string,
|
|
number: number,
|
|
type?: 'issue' | 'pr'
|
|
): Promise<Awaited<ReturnType<typeof getWorkItemDetails>>> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
return getWorkItemDetails(
|
|
repo.path,
|
|
number,
|
|
type,
|
|
getRepoRoutingConnectionId(repo),
|
|
this.deps.getLocalGitArgs(repo)[0] ?? {},
|
|
repo.issueSourcePreference
|
|
)
|
|
}
|
|
|
|
async countRepoWorkItems(repoSelector: string, query?: string): Promise<number> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
return countWorkItems(
|
|
repo.path,
|
|
query,
|
|
repo.issueSourcePreference,
|
|
getRepoRoutingConnectionId(repo),
|
|
...this.deps.getLocalGitArgs(repo)
|
|
)
|
|
}
|
|
|
|
async listRepoLabels(repoSelector: string): Promise<Awaited<ReturnType<typeof listLabels>>> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
return listLabels(
|
|
repo.path,
|
|
repo.issueSourcePreference,
|
|
getRepoRoutingConnectionId(repo),
|
|
...this.deps.getLocalGitArgs(repo)
|
|
)
|
|
}
|
|
|
|
async listRepoAssignableUsers(
|
|
repoSelector: string
|
|
): Promise<Awaited<ReturnType<typeof listAssignableUsers>>> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
return listAssignableUsers(
|
|
repo.path,
|
|
repo.issueSourcePreference,
|
|
getRepoRoutingConnectionId(repo),
|
|
...this.deps.getLocalGitArgs(repo)
|
|
)
|
|
}
|
|
|
|
getGitHubRateLimit(options?: {
|
|
force?: boolean
|
|
}): Promise<Awaited<ReturnType<typeof getRateLimit>>> {
|
|
return getRateLimit(options)
|
|
}
|
|
|
|
async listGitHubBindableAccounts(
|
|
repoSelector: string,
|
|
options?: { refreshCapability?: boolean }
|
|
): Promise<Awaited<ReturnType<typeof listGhAccountBindingInventory>>> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
const localGitOptions = this.deps.getLocalGitArgs(repo)[0] ?? {}
|
|
const requiredHost = await resolveGhAccountRequiredHost(repo, localGitOptions)
|
|
return listGhAccountBindingInventory(localGitOptions, {
|
|
refreshCapability: options?.refreshCapability === true,
|
|
...(requiredHost ? { requiredHost } : {})
|
|
})
|
|
}
|
|
|
|
async validateGitHubAccountBinding(
|
|
repoSelector: string,
|
|
binding: { host: string; user: string }
|
|
): Promise<Awaited<ReturnType<typeof validateGhAccountBinding>>> {
|
|
const repo = await this.deps.resolveRepo(repoSelector)
|
|
const localGitOptions = this.deps.getLocalGitArgs(repo)[0] ?? {}
|
|
const requiredHost = await resolveGhAccountRequiredHost(repo, localGitOptions)
|
|
return validateGhAccountBinding(binding, localGitOptions, requiredHost ? { requiredHost } : {})
|
|
}
|
|
}
|