mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 17:37:40 +00:00
* refactor(daemon): group transport, provider, endpoint, and terminal owners * refactor(daemon): consolidate owner imports and preserve pinned baseline sources * refactor(daemon): import termination budgets from their defining owner * fix(ci): retain serve mode coverage for extracted orcad startup * fix daemon build smoke to load concrete argument owner * read daemon protocol facts from historical defining paths * route protocol revision owners through compatibility checks
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
import { runProcessSync } from '@orca/process-host'
|
|
import { dirname, resolve } from 'node:path'
|
|
|
|
export function readGitBaselineSources(repo, ref, sources) {
|
|
const historicalPaths = new Map(
|
|
[...sources].map(([current, historical]) => [current, historical.slice(ref.length + 1)])
|
|
)
|
|
const candidates = [...historicalPaths].flatMap(([current, historical]) => [current, historical])
|
|
const read = (args, maxOutputBytes) => {
|
|
const result = runProcessSync({
|
|
program: 'git',
|
|
args,
|
|
cwd: repo,
|
|
timeoutMs: 10_000,
|
|
maxOutputBytes,
|
|
env: { ...process.env, ORCA_BACKGROUND_LAUNCH: '1' }
|
|
})
|
|
if (result.code !== 0 || result.outputTruncated) {
|
|
throw new Error(`Cannot read pinned Git baseline sources: ${result.stderr}`)
|
|
}
|
|
return result.stdout
|
|
}
|
|
const available = new Set(
|
|
read(['ls-tree', '--name-only', ref, '--', ...candidates], 64 * 1024)
|
|
.trim()
|
|
.split('\n')
|
|
)
|
|
return new Map(
|
|
[...historicalPaths].map(([current, historical]) => {
|
|
const source = available.has(current)
|
|
? current
|
|
: available.has(historical)
|
|
? historical
|
|
: null
|
|
if (!source) {
|
|
throw new Error(`Pinned Git baseline source is absent: ${ref}:${current}`)
|
|
}
|
|
return [
|
|
resolve(repo, current),
|
|
{
|
|
contents: read(['show', `${ref}:${source}`], 16 * 1024 * 1024),
|
|
resolveDir: dirname(resolve(repo, source))
|
|
}
|
|
]
|
|
})
|
|
)
|
|
}
|