fix: tighten code queue pr preflight contract
This commit is contained in:
@@ -2265,6 +2265,17 @@ function compactToolStatus(value: unknown): Record<string, unknown> {
|
||||
};
|
||||
}
|
||||
|
||||
function compactUniDeskGhCliStatus(value: unknown): Record<string, unknown> {
|
||||
const cli = asRecord(value) ?? {};
|
||||
return {
|
||||
ok: cli.ok ?? false,
|
||||
path: cli.path ?? null,
|
||||
present: cli.present ?? false,
|
||||
role: "repo-native REST GitHub CLI used by bun scripts/cli.ts gh",
|
||||
requiresSystemGhBinary: false,
|
||||
};
|
||||
}
|
||||
|
||||
function compactAgentPortStatus(value: unknown): Record<string, unknown> {
|
||||
const port = asRecord(value) ?? {};
|
||||
return {
|
||||
@@ -2298,6 +2309,7 @@ function tokenCoverageStatus(credentials: Record<string, unknown>): Record<strin
|
||||
function compactPrRuntimePreflight(preflight: Record<string, unknown>, options: CodexPrPreflightOptions): Record<string, unknown> {
|
||||
const pull = asRecord(preflight.pullRequestDelivery) ?? {};
|
||||
const tools = asRecord(pull.tools) ?? {};
|
||||
const unideskGhCli = compactUniDeskGhCliStatus(pull.unideskGhCli);
|
||||
const credentials = asRecord(pull.credentials) ?? {};
|
||||
const git = asRecord(pull.git) ?? {};
|
||||
const githubContext = asRecord(pull.githubContext) ?? {};
|
||||
@@ -2309,6 +2321,10 @@ function compactPrRuntimePreflight(preflight: Record<string, unknown>, options:
|
||||
const limitations = Array.isArray(pull.limitations) ? pull.limitations.map(String) : [];
|
||||
const risks = Array.isArray(pull.risks) ? pull.risks.map(String) : [];
|
||||
const ok = preflight.ok === true && tokenCoverage.ok === true;
|
||||
const defaultPushDryRunRef = "refs/heads/probe/code-queue-pr-capability-dryrun";
|
||||
const pushDryRunRef = options.pushDryRunRef ?? defaultPushDryRunRef;
|
||||
const targetBranch = "master";
|
||||
const expectedHeadBranch = options.prCreateDryRunHead ?? (typeof git.branch === "string" && git.branch.length > 0 ? git.branch : "<head-branch>");
|
||||
const result: Record<string, unknown> = {
|
||||
ok,
|
||||
checkedAt: preflight.checkedAt ?? pull.checkedAt ?? null,
|
||||
@@ -2320,13 +2336,48 @@ function compactPrRuntimePreflight(preflight: Record<string, unknown>, options:
|
||||
pid: preflight.pid ?? null,
|
||||
},
|
||||
tokenCoverage,
|
||||
prCapabilityContract: {
|
||||
targetBranch,
|
||||
tokenSource: tokenCoverage.source,
|
||||
systemGhBinaryRequiredForWrites: false,
|
||||
unideskGhCli,
|
||||
pushDryRun: {
|
||||
requested: options.pushDryRun,
|
||||
ref: pushDryRunRef,
|
||||
writesRemote: false,
|
||||
commandShape: `git push --dry-run origin HEAD:${pushDryRunRef}`,
|
||||
},
|
||||
prCreateDryRun: {
|
||||
requested: options.prCreateDryRun,
|
||||
headBranch: expectedHeadBranch,
|
||||
writesRemote: false,
|
||||
commandShape: `bun scripts/cli.ts gh pr create --repo pikasTech/unidesk --base ${targetBranch} --head ${expectedHeadBranch} --dry-run`,
|
||||
},
|
||||
expectedPrHandoff: {
|
||||
sourceBranch: expectedHeadBranch,
|
||||
targetBranch,
|
||||
runnerCreatesPrAfterAuthorization: true,
|
||||
commanderReviewsAndMerges: true,
|
||||
preflightCreatesPr: false,
|
||||
preflightMergesPr: false,
|
||||
},
|
||||
unsupportedMergeBoundary: {
|
||||
supported: false,
|
||||
command: "bun scripts/cli.ts gh pr merge <number> --repo pikasTech/unidesk",
|
||||
degradedReason: "unsupported-command",
|
||||
runnerDisposition: "business-failed",
|
||||
note: "UniDesk CLI intentionally does not merge PRs in this phase; runner handoff stops at PR creation and evidence.",
|
||||
},
|
||||
},
|
||||
tools: {
|
||||
git: compactToolStatus(tools.git),
|
||||
gh: compactToolStatus(tools.gh),
|
||||
systemGhBinary: compactToolStatus(tools.gh),
|
||||
hub: compactToolStatus(tools.hub),
|
||||
jq: compactToolStatus(tools.jq),
|
||||
ssh: compactToolStatus(tools.ssh),
|
||||
curl: compactToolStatus(tools.curl),
|
||||
unideskGhCli,
|
||||
},
|
||||
agentPorts: {
|
||||
codex: compactAgentPortStatus(ports.codex),
|
||||
@@ -2404,6 +2455,7 @@ function codeQueuePrPreflight(optionArgs: string[] = [], fetcher: CodexResponseF
|
||||
const compact = compactPrRuntimePreflight(preflight, options);
|
||||
return {
|
||||
ok: compact.ok,
|
||||
runnerDisposition: compact.runnerDisposition,
|
||||
upstream: response.upstream,
|
||||
preflight: compact,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user