fix: compact codex pr preflight output
This commit is contained in:
+209
-10
@@ -4180,9 +4180,193 @@ function prPreflightAuthScopeSummary(tokenCoverage: Record<string, unknown> | nu
|
||||
};
|
||||
}
|
||||
|
||||
function prPreflightTokenCoverage(record: Record<string, unknown>): Record<string, unknown> | null {
|
||||
const preflight = asRecord(record.preflight);
|
||||
const schedulerPreflight = asRecord(record.schedulerPreflight);
|
||||
const schedulerAuth = asRecord(schedulerPreflight?.auth);
|
||||
const schedulerSummary = schedulerPreflight === null ? null : {
|
||||
ok: schedulerPreflight.authReady ?? null,
|
||||
source: schedulerPreflight.authSource ?? null,
|
||||
credentialSource: schedulerPreflight.credentialSource ?? null,
|
||||
scope: schedulerPreflight.scope ?? null,
|
||||
missing: Array.isArray(schedulerPreflight.missing) && schedulerPreflight.missing.length > 0
|
||||
? schedulerPreflight.missing.map(String)
|
||||
: schedulerPreflight.authReady === false
|
||||
? ["GH_TOKEN", "GITHUB_TOKEN"]
|
||||
: [],
|
||||
runnerDisposition: schedulerPreflight.authReady === true ? "ready" : "infra-blocked",
|
||||
};
|
||||
return asRecord(record.tokenCoverage)
|
||||
?? asRecord(preflight?.tokenCoverage)
|
||||
?? schedulerAuth
|
||||
?? schedulerSummary
|
||||
?? null;
|
||||
}
|
||||
|
||||
function prPreflightAuthBroker(record: Record<string, unknown>): Record<string, unknown> | null {
|
||||
const preflight = asRecord(record.preflight);
|
||||
const schedulerPreflight = asRecord(record.schedulerPreflight);
|
||||
return asRecord(record.authBroker)
|
||||
?? asRecord(preflight?.authBroker)
|
||||
?? asRecord(schedulerPreflight?.authBroker)
|
||||
?? null;
|
||||
}
|
||||
|
||||
function prPreflightCapabilityContract(record: Record<string, unknown>): Record<string, unknown> | null {
|
||||
const preflight = asRecord(record.preflight);
|
||||
const prCapability = asRecord(record.prCapability);
|
||||
return asRecord(record.prCapabilityContract)
|
||||
?? asRecord(preflight?.prCapabilityContract)
|
||||
?? prCapability
|
||||
?? null;
|
||||
}
|
||||
|
||||
function prPreflightCommandSet(record: Record<string, unknown>, options: CodexPrPreflightOptions): Record<string, unknown> {
|
||||
const preflight = asRecord(record.preflight);
|
||||
const commands = asRecord(record.commands) ?? asRecord(preflight?.commands) ?? {};
|
||||
const activeRunnerDevContainer = asRecord(record.activeRunnerDevContainer) ?? activeRunnerDevContainerCapability();
|
||||
const activeCommands = asRecord(activeRunnerDevContainer.commands) ?? {};
|
||||
const remoteFlag = options.remote ? " --remote" : "";
|
||||
const fullDetail = `bun scripts/cli.ts codex pr-preflight${remoteFlag} --full`;
|
||||
return {
|
||||
verifyActiveRunnerAuth: activeCommands.authStatus ?? commands.local ?? "bun scripts/cli.ts gh auth status --repo pikasTech/unidesk",
|
||||
verifyActiveRunnerPrCreateDryRun: activeCommands.prCreateDryRun ?? "bun scripts/cli.ts gh pr create --repo pikasTech/unidesk --title <title> --body-file <file> --base master --head <head> --dry-run",
|
||||
rerunSchedulerPreflight: commands.runner ?? `bun scripts/cli.ts codex pr-preflight${remoteFlag}`,
|
||||
fullDetail,
|
||||
rawProxy: commands.rawProxy ?? "bun scripts/cli.ts microservice proxy code-queue /api/runtime-preflight?remote=1 --raw --full",
|
||||
schedulerAuthSource: "configure auth-broker or inject GH_TOKEN/GITHUB_TOKEN into the scheduler runtime secret",
|
||||
};
|
||||
}
|
||||
|
||||
function compactRecommendedActions(record: Record<string, unknown>): Record<string, unknown>[] {
|
||||
const actions = Array.isArray(record.recommendedActions) ? record.recommendedActions : [];
|
||||
if (actions.length > 0) {
|
||||
return actions.slice(0, 3).map((item) => {
|
||||
const action = asRecord(item) ?? {};
|
||||
return {
|
||||
scope: action.scope ?? null,
|
||||
priority: action.priority ?? null,
|
||||
action: action.action ?? null,
|
||||
command: action.command ?? null,
|
||||
writesRemote: action.writesRemote ?? false,
|
||||
};
|
||||
});
|
||||
}
|
||||
const tokenCoverage = prPreflightTokenCoverage(record);
|
||||
return prPreflightRecommendedActions(tokenCoverage);
|
||||
}
|
||||
|
||||
function compactPrPreflightCommanderView(record: Record<string, unknown>, options: CodexPrPreflightOptions): Record<string, unknown> {
|
||||
if (options.full) return record;
|
||||
|
||||
const tokenCoverage = prPreflightTokenCoverage(record);
|
||||
const authBroker = prPreflightAuthBroker(record);
|
||||
const capability = prPreflightCapabilityContract(record);
|
||||
const activeRunnerDevContainer = asRecord(record.activeRunnerDevContainer) ?? activeRunnerDevContainerCapability();
|
||||
const activeCommands = asRecord(activeRunnerDevContainer.commands) ?? {};
|
||||
const authBrokerCapability = asRecord(authBroker?.capability);
|
||||
const expectedPrHandoff = asRecord(capability?.expectedPrHandoff);
|
||||
const unideskGhCli = asRecord(capability?.unideskGhCli);
|
||||
const pushDryRun = asRecord(capability?.pushDryRun);
|
||||
const prCreateDryRun = asRecord(capability?.prCreateDryRun);
|
||||
const unsupportedMergeBoundary = asRecord(capability?.unsupportedMergeBoundary);
|
||||
const commands = prPreflightCommandSet(record, options);
|
||||
const schedulerAuthReady = tokenCoverage?.ok === true;
|
||||
const activeRunnerTokenCandidatePresent = activeRunnerDevContainer.ok === true;
|
||||
const failureKind = record.failureKind ?? (schedulerAuthReady ? null : "auth-missing");
|
||||
const degradedReason = record.degradedReason ?? (schedulerAuthReady ? null : "auth-broker-needed");
|
||||
const githubTransient = asRecord(record.githubTransient);
|
||||
|
||||
return {
|
||||
ok: record.ok === true,
|
||||
runnerDisposition: record.runnerDisposition ?? (record.ok === true ? "ready" : "infra-blocked"),
|
||||
failureKind,
|
||||
degradedReason,
|
||||
...(record.retryable === true ? { retryable: true } : {}),
|
||||
...(typeof record.commanderAction === "string" ? { commanderAction: record.commanderAction } : {}),
|
||||
...(githubTransient === null ? {} : { githubTransient }),
|
||||
summary: {
|
||||
status: record.ok === true ? "ready" : "blocked",
|
||||
schedulerPreflightAuthReady: schedulerAuthReady,
|
||||
schedulerPreflightScope: tokenCoverage?.scope ?? "scheduler-runner-env",
|
||||
activeRunnerTokenCandidatePresent,
|
||||
activeRunnerScope: activeRunnerDevContainer.scope ?? "current-cli-process",
|
||||
interpretation: schedulerAuthReady
|
||||
? "scheduler preflight auth is ready; still use active-runner dry-runs before writes"
|
||||
: "scheduler auth is missing for preflight admission only; this does not prove the active runner/dev container cannot create or comment PRs",
|
||||
},
|
||||
schedulerPreflight: {
|
||||
scope: tokenCoverage?.scope ?? "scheduler-runner-env",
|
||||
authReady: schedulerAuthReady,
|
||||
authSource: tokenCoverage?.source ?? null,
|
||||
credentialSource: tokenCoverage?.credentialSource ?? null,
|
||||
missing: Array.isArray(tokenCoverage?.missing) ? tokenCoverage.missing.map(String) : [],
|
||||
failureKind: schedulerAuthReady ? null : failureKind,
|
||||
degradedReason: schedulerAuthReady ? null : degradedReason,
|
||||
authBroker: authBroker === null ? null : {
|
||||
ok: authBroker.ok ?? schedulerAuthReady,
|
||||
source: authBroker.source ?? null,
|
||||
configured: authBroker.configured ?? null,
|
||||
needed: authBroker.needed ?? !schedulerAuthReady,
|
||||
nextAction: authBroker.nextAction ?? null,
|
||||
capabilitySource: authBrokerCapability?.source ?? tokenCoverage?.credentialSource ?? null,
|
||||
},
|
||||
},
|
||||
activeRunnerPrCapability: {
|
||||
scope: activeRunnerDevContainer.scope ?? "current-cli-process",
|
||||
tokenCandidatePresent: activeRunnerTokenCandidatePresent,
|
||||
credentialSource: activeRunnerDevContainer.credentialSource ?? null,
|
||||
ghTokenPresent: activeRunnerDevContainer.ghTokenPresent ?? false,
|
||||
githubTokenPresent: activeRunnerDevContainer.githubTokenPresent ?? false,
|
||||
independentOfSchedulerPreflight: activeRunnerDevContainer.notEquivalentToSchedulerEnv ?? true,
|
||||
verifyCommands: {
|
||||
authStatus: activeCommands.authStatus ?? commands.verifyActiveRunnerAuth,
|
||||
prCreateDryRun: activeCommands.prCreateDryRun ?? commands.verifyActiveRunnerPrCreateDryRun,
|
||||
},
|
||||
},
|
||||
prCapability: capability === null ? null : {
|
||||
targetBranch: capability.targetBranch ?? "master",
|
||||
sourceBranch: expectedPrHandoff?.sourceBranch ?? prCreateDryRun?.headBranch ?? null,
|
||||
unideskGhCliOk: unideskGhCli?.ok ?? null,
|
||||
systemGhBinaryRequiredForWrites: capability.systemGhBinaryRequiredForWrites ?? false,
|
||||
realPrCreateRequiresCommanderAuthorization: capability.realPrCreateRequiresCommanderAuthorization ?? true,
|
||||
pushDryRun: pushDryRun === null ? null : {
|
||||
requested: pushDryRun.requested ?? false,
|
||||
writesRemote: pushDryRun.writesRemote ?? false,
|
||||
commandShape: pushDryRun.commandShape ?? null,
|
||||
},
|
||||
prCreateDryRun: prCreateDryRun === null ? null : {
|
||||
requested: prCreateDryRun.requested ?? false,
|
||||
writesRemote: prCreateDryRun.writesRemote ?? false,
|
||||
commandShape: prCreateDryRun.commandShape ?? null,
|
||||
},
|
||||
mergeSupported: unsupportedMergeBoundary?.supported ?? false,
|
||||
mergeCommand: unsupportedMergeBoundary?.command ?? "bun scripts/cli.ts gh pr merge <number> --repo pikasTech/unidesk",
|
||||
},
|
||||
authScopeSummary: record.authScopeSummary ?? prPreflightAuthScopeSummary(tokenCoverage, activeRunnerDevContainer),
|
||||
scopeBoundary: record.scopeBoundary ?? prPreflightScopeBoundary(tokenCoverage),
|
||||
recommendedActions: compactRecommendedActions(record),
|
||||
upstream: record.upstream ?? null,
|
||||
controlPlane: record.controlPlane ?? null,
|
||||
observationGap: record.observationGap ?? undefined,
|
||||
localObservationGap: record.localObservationGap ?? undefined,
|
||||
localObservationSummary: record.localObservationSummary ?? undefined,
|
||||
remoteObservationSummary: record.remoteObservationSummary ?? undefined,
|
||||
commands,
|
||||
disclosure: {
|
||||
defaultView: "commander-compact",
|
||||
fullDetailOmitted: true,
|
||||
fullObservationsOmitted: asRecord(record.disclosure)?.fullObservationsOmitted ?? true,
|
||||
expandWith: commands.fullDetail,
|
||||
rawProxy: commands.rawProxy,
|
||||
detailFieldsOmitted: ["preflight", "tools", "agentPorts", "git", "egress", "remote", "limitations", "risks", "rawRuntimePreflight"],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function decoratePrPreflightScopeBoundary(record: Record<string, unknown>): Record<string, unknown> {
|
||||
const preflight = asRecord(record.preflight);
|
||||
const tokenCoverage = asRecord(record.tokenCoverage) ?? asRecord(preflight?.tokenCoverage);
|
||||
const tokenCoverage = prPreflightTokenCoverage(record);
|
||||
const scopeBoundary = prPreflightScopeBoundary(tokenCoverage);
|
||||
const activeRunnerDevContainer = activeRunnerDevContainerCapability();
|
||||
const authScopeSummary = prPreflightAuthScopeSummary(tokenCoverage, activeRunnerDevContainer);
|
||||
@@ -4224,7 +4408,20 @@ function prPreflightObservationGap(kind: Exclude<CodeQueueObservationGapKind, nu
|
||||
function prPreflightObservationSummary(record: Record<string, unknown> | null): Record<string, unknown> | null {
|
||||
if (record === null) return null;
|
||||
const preflight = asRecord(record.preflight);
|
||||
const tokenCoverage = asRecord(record.tokenCoverage) ?? asRecord(preflight?.tokenCoverage);
|
||||
const schedulerPreflight = asRecord(record.schedulerPreflight);
|
||||
const tokenCoverage = asRecord(record.tokenCoverage)
|
||||
?? asRecord(preflight?.tokenCoverage)
|
||||
?? (schedulerPreflight === null ? null : {
|
||||
ok: schedulerPreflight.authReady ?? null,
|
||||
source: schedulerPreflight.authSource ?? null,
|
||||
credentialSource: schedulerPreflight.credentialSource ?? null,
|
||||
scope: schedulerPreflight.scope ?? null,
|
||||
missing: Array.isArray(schedulerPreflight.missing) && schedulerPreflight.missing.length > 0
|
||||
? schedulerPreflight.missing.map(String)
|
||||
: schedulerPreflight.authReady === false
|
||||
? ["GH_TOKEN", "GITHUB_TOKEN"]
|
||||
: [],
|
||||
});
|
||||
const controlPlane = asRecord(record.controlPlane);
|
||||
const targetStack = asRecord(record.targetStack);
|
||||
return {
|
||||
@@ -4561,7 +4758,7 @@ function codeQueuePrPreflight(optionArgs: string[] = [], transport: CodeQueuePrP
|
||||
const remoteRecord = asRecord(remoteResponse);
|
||||
if (remoteRecord !== null) {
|
||||
if (remoteRecord.ok === false) {
|
||||
return decoratePrPreflightScopeBoundary({
|
||||
return compactPrPreflightCommanderView(decoratePrPreflightScopeBoundary({
|
||||
...remoteRecord,
|
||||
observationGap: prPreflightObservationGap(
|
||||
remoteRecord.failureKind === "control-plane-missing" ? "control-plane-observation-gap" : "runner-local-observation-gap",
|
||||
@@ -4584,9 +4781,9 @@ function codeQueuePrPreflight(optionArgs: string[] = [], transport: CodeQueuePrP
|
||||
remoteFallbackUsed: true,
|
||||
},
|
||||
...maybeFullPrPreflightObservations(options, localRecord, remoteRecord),
|
||||
});
|
||||
}), options);
|
||||
}
|
||||
return decoratePrPreflightScopeBoundary({
|
||||
return compactPrPreflightCommanderView(decoratePrPreflightScopeBoundary({
|
||||
...remoteRecord,
|
||||
localObservationGap: prPreflightObservationGap("runner-local-observation-gap", {
|
||||
reason: "local backend-core target-stack absence was bypassed by healthy remote control-plane fallback",
|
||||
@@ -4603,7 +4800,7 @@ function codeQueuePrPreflight(optionArgs: string[] = [], transport: CodeQueuePrP
|
||||
remoteFallbackUsed: true,
|
||||
},
|
||||
...maybeFullPrPreflightObservations(options, localRecord, remoteRecord),
|
||||
});
|
||||
}), options);
|
||||
}
|
||||
}
|
||||
if (localRecord?.ok !== true) {
|
||||
@@ -4693,13 +4890,14 @@ function codeQueuePrPreflight(optionArgs: string[] = [], transport: CodeQueuePrP
|
||||
};
|
||||
}
|
||||
const compact = compactPrRuntimePreflight(preflight, options);
|
||||
return {
|
||||
return compactPrPreflightCommanderView({
|
||||
ok: compact.ok,
|
||||
runnerDisposition: compact.runnerDisposition,
|
||||
failureKind: compact.failureKind ?? null,
|
||||
degradedReason: compact.degradedReason ?? null,
|
||||
...(compact.retryable === true ? { retryable: true } : {}),
|
||||
...(typeof compact.commanderAction === "string" ? { commanderAction: compact.commanderAction } : {}),
|
||||
...(asRecord(compact.githubTransient) === null ? {} : { githubTransient: compact.githubTransient }),
|
||||
authScopeSummary: compact.authScopeSummary,
|
||||
scopeBoundary: compact.scopeBoundary,
|
||||
activeRunnerDevContainer: compact.activeRunnerDevContainer,
|
||||
@@ -4711,7 +4909,7 @@ function codeQueuePrPreflight(optionArgs: string[] = [], transport: CodeQueuePrP
|
||||
remoteFallbackUsed: false,
|
||||
},
|
||||
preflight: compact,
|
||||
};
|
||||
}, options);
|
||||
}
|
||||
|
||||
export function codexPrPreflightQueryForTest(optionArgs: string[], transport: CodeQueuePrPreflightTransport = {}): unknown {
|
||||
@@ -4751,13 +4949,14 @@ export async function codexPrPreflightQueryAsync(optionArgs: string[], fetcher:
|
||||
};
|
||||
}
|
||||
const compact = compactPrRuntimePreflight(preflight, options);
|
||||
return {
|
||||
return compactPrPreflightCommanderView({
|
||||
ok: compact.ok,
|
||||
runnerDisposition: compact.runnerDisposition,
|
||||
failureKind: compact.failureKind ?? null,
|
||||
degradedReason: compact.degradedReason ?? null,
|
||||
...(compact.retryable === true ? { retryable: true } : {}),
|
||||
...(typeof compact.commanderAction === "string" ? { commanderAction: compact.commanderAction } : {}),
|
||||
...(asRecord(compact.githubTransient) === null ? {} : { githubTransient: compact.githubTransient }),
|
||||
authScopeSummary: compact.authScopeSummary,
|
||||
scopeBoundary: compact.scopeBoundary,
|
||||
activeRunnerDevContainer: compact.activeRunnerDevContainer,
|
||||
@@ -4769,7 +4968,7 @@ export async function codexPrPreflightQueryAsync(optionArgs: string[], fetcher:
|
||||
remoteFallbackUsed: false,
|
||||
},
|
||||
preflight: compact,
|
||||
};
|
||||
}, options);
|
||||
}
|
||||
|
||||
export function codexSubmitRoutingRecommendationForTest(prompt: string, model?: string): SubmitRoutingRecommendation {
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ export function rootHelp(): unknown {
|
||||
{ command: "codex deploy <commitId> [--provider-id D601] [--timeout-ms N]", description: "Disabled legacy Code Queue deploy path; use the dev-only artifact consumer instead." },
|
||||
{ command: "codex submit [prompt] [--prompt-file path|--prompt-stdin] [--queue queueId] [--provider-id id] [--cwd path] [--model model] [--execution-mode mode] [--max-attempts N] [--reference-task-id id] [--dry-run]", description: "Submit a Code Queue task through backend-core -> code-queue proxy; --dry-run shows the structured request, while real success only confirms the write and task id." },
|
||||
{ command: "codex skills-sync --dry-run [--full]", description: "Inspect the controlled runner skills hostPath lifecycle contract without copying files, restarting services, reading secrets, or mutating live runner paths." },
|
||||
{ command: "codex pr-preflight [--remote] [--push-dry-run --push-dry-run-ref refs/heads/probe/<name>] [--pr-create-dry-run --pr-create-dry-run-head <head>] [--issue N]", description: "Read-only PR admission check against the D601 scheduler/runner token, GitHub egress, repo visibility, skills lifecycle health, optional push dry-run, and PR body/create dry-run guard." },
|
||||
{ command: "codex pr-preflight [--remote] [--push-dry-run --push-dry-run-ref refs/heads/probe/<name>] [--pr-create-dry-run --pr-create-dry-run-head <head>] [--issue N] [--full|--raw]", description: "Read-only PR admission check with compact commander output by default; use --full or --raw to expand the full runtime preflight, tool, and observation payload." },
|
||||
{ command: "codex task <taskId> [--detail] [--trace --tail|--from-start|--after-seq N|--before-seq N --limit N] [--full]", description: "Fetch the bounded review view by default; --detail is still capped, while --full/trace/output explicitly expand evidence." },
|
||||
{ command: "codex tasks [--view supervisor|full] [--queue id] [--status status[,status]] [--unread|--unread-only] [--limit N] [--before-id id]", description: "Show the low-noise supervisor view by default: compact task rows, tiny local sections, activity counts, diagnostics, and drill-down commands; use --view full for detailed rows." },
|
||||
{ command: "codex output <taskId> [--tail|--from-start|--after-seq N|--before-seq N --limit N] [--full-text]", description: "Fetch paged raw Code Queue output records; default caps large limits/text previews, --full-text explicitly expands one seq window." },
|
||||
@@ -258,7 +258,7 @@ function codexHelp(): unknown {
|
||||
"bun scripts/cli.ts codex read <taskId>",
|
||||
"bun scripts/cli.ts codex dev-ready",
|
||||
"bun scripts/cli.ts codex skills-sync --dry-run [--full]",
|
||||
"bun scripts/cli.ts codex pr-preflight [--remote] [--push-dry-run --push-dry-run-ref refs/heads/probe/<name>] [--pr-create-dry-run --pr-create-dry-run-head <head>] [--issue N]",
|
||||
"bun scripts/cli.ts codex pr-preflight [--remote] [--push-dry-run --push-dry-run-ref refs/heads/probe/<name>] [--pr-create-dry-run --pr-create-dry-run-head <head>] [--issue N] [--full|--raw]",
|
||||
"bun scripts/cli.ts codex judge <taskId> --attempt N [--dry-run] [--include-prompt]",
|
||||
"bun scripts/cli.ts codex steer <taskId> [prompt|--prompt-file path|--prompt-stdin] [--dry-run] [--no-retry|--retry-attempts N]",
|
||||
"bun scripts/cli.ts codex interrupt|cancel <taskId>",
|
||||
|
||||
Reference in New Issue
Block a user