fix: bound codex supervisor diagnostics
This commit is contained in:
@@ -20,6 +20,10 @@ function longText(marker: string, repeat: number): string {
|
||||
return Array.from({ length: repeat }, (_, index) => `${marker}-${index} #132 Gate report diagnostic review evidence direct workbench fix`).join("\n");
|
||||
}
|
||||
|
||||
function manyIds(prefix: string, count: number): string[] {
|
||||
return Array.from({ length: count }, (_, index) => `${prefix}-${String(index + 1).padStart(3, "0")}`);
|
||||
}
|
||||
|
||||
function task(id: string, status: string, updatedAt: string, readAt: string | null = null): JsonRecord {
|
||||
return {
|
||||
id,
|
||||
@@ -79,9 +83,30 @@ function fixtureResponse(path: string): JsonRecord {
|
||||
ok: true,
|
||||
queue: {
|
||||
executionDiagnostics: {
|
||||
state: "split-brain",
|
||||
splitBrain: true,
|
||||
effectiveLiveness: "live",
|
||||
splitBrainLive: true,
|
||||
recommendedAction: "continue-supervision",
|
||||
livenessSummary: longText("split-brain-live-summary", 45),
|
||||
databaseActiveTaskCount: 80,
|
||||
databaseActiveTaskIds: manyIds("db-active", 80),
|
||||
schedulerActiveRunSlotCount: 30,
|
||||
schedulerActiveTaskIds: manyIds("scheduler-active", 30),
|
||||
activeHeartbeatCount: 80,
|
||||
activeHeartbeatTaskIds: manyIds("active-heartbeat", 80),
|
||||
heartbeatFreshTaskIds: manyIds("fresh-heartbeat", 80),
|
||||
heartbeatExpiredTaskIds: [],
|
||||
heartbeatMissingTaskIds: [],
|
||||
staleRecoveryCandidateTaskIds: [],
|
||||
heartbeatRiskTaskIds: [],
|
||||
traceGapTaskIds: manyIds("trace-gap", 60),
|
||||
traceGapNotStaleTaskIds: manyIds("trace-gap-fresh", 40),
|
||||
reasons: Array.from({ length: 24 }, (_, index) => longText(`diagnostic-reason-${index + 1}`, 10)),
|
||||
oaPublisher: {
|
||||
pendingTaskIds: manyIds("oa-pending", 80),
|
||||
lastError: longText("oa-publisher-error", 60),
|
||||
},
|
||||
},
|
||||
},
|
||||
pagination: {
|
||||
@@ -131,11 +156,20 @@ export function runCodeQueueSupervisorDisclosureContract(): JsonRecord {
|
||||
const fullItem = asRecord(asArray(asRecord(asRecord(full).tasks).items)[0]);
|
||||
const completedUnread = asRecord(supervisorView.completedUnread);
|
||||
const fullTasks = asRecord(asRecord(full).tasks);
|
||||
const diagnostics = asRecord(supervisorView.executionDiagnostics);
|
||||
const listBudget = asRecord(diagnostics.listBudget);
|
||||
const omittedCounts = asRecord(listBudget.omittedCounts);
|
||||
|
||||
assertCondition(supervisorBody.length < fullBody.length * 0.55, "supervisor output should be materially smaller than full output", { supervisorChars: supervisorBody.length, fullChars: fullBody.length });
|
||||
assertCondition(supervisorBody.length < 70_000, "supervisor output should remain bounded even with large diagnostics", { supervisorChars: supervisorBody.length });
|
||||
assertCondition(recentItems.length === 5, "recentCompleted should be capped below --limit by default", { returned: recentItems.length });
|
||||
assertCondition(asArray(completedUnread.items).length === 7, "completedUnread should keep unread terminal tasks separate from recentCompleted", completedUnread);
|
||||
assertCondition(recentItems.every((item) => asRecord(item).unreadTerminal === false), "recentCompleted should not duplicate unread terminal tasks", { recentItems });
|
||||
assertCondition(asArray(diagnostics.databaseActiveTaskIds).length === 12, "diagnostic task id lists should be capped", diagnostics);
|
||||
assertCondition(omittedCounts.databaseActiveTaskIds === 68, "diagnostic omitted counts should preserve full visibility metadata", omittedCounts);
|
||||
assertCondition(asArray(diagnostics.reasons).length === 6, "diagnostic reasons should be capped", diagnostics);
|
||||
assertCondition(diagnostics.livenessSummaryTruncated === true, "long diagnostic liveness summary should be previewed", diagnostics);
|
||||
assertCondition(listBudget.truncated === true && typeof listBudget.rawCommand === "string", "diagnostic list budget should disclose raw command", listBudget);
|
||||
assertCondition(asArray(runningItem.issueRefs).includes("#132"), "supervisor row should expose issue refs for triage", runningItem);
|
||||
assertCondition(Number(prompt.chars) > String(prompt.text ?? "").length && prompt.truncated === true, "supervisor prompt must be a short preview with original char count", prompt);
|
||||
assertCondition(Number(lastMessage.chars) > String(lastMessage.text ?? "").length && lastMessage.truncated === true, "supervisor body must be a short preview with original char count", lastMessage);
|
||||
@@ -150,6 +184,7 @@ export function runCodeQueueSupervisorDisclosureContract(): JsonRecord {
|
||||
checks: [
|
||||
"supervisor output materially smaller than full",
|
||||
"recentCompleted capped",
|
||||
"split-brain diagnostics capped",
|
||||
"prompt/body previews bounded",
|
||||
"drill-down commands preserved",
|
||||
"full view remains detailed",
|
||||
|
||||
Reference in New Issue
Block a user