Preserve bounded repair context

Keep repair attempt metadata and nested diagnostics while retaining prompt limits.\n\nAI assistance: Implemented and validated with OpenAI Codex under maintainer authorization.
This commit is contained in:
Paul Bakaus
2026-08-06 09:51:32 -07:00
parent aa1b4e4b02
commit 0e8eea2d91
2 changed files with 32 additions and 3 deletions
+9 -1
View File
@@ -310,17 +310,21 @@ function compactBatchRepair(repair) {
if (!repair || typeof repair !== 'object') return undefined;
return {
status: compactBatchString(repair.status),
attempt: normalizeOptionalBatchNumber(repair.attempt),
attempts: normalizeOptionalBatchNumber(repair.attempts),
maxAttempts: normalizeOptionalBatchNumber(repair.maxAttempts),
reason: compactBatchString(repair.reason),
transactionId: compactBatchString(repair.transactionId),
pageUrl: compactBatchString(repair.pageUrl),
failures: compactBatchDiagnostics(repair.failures),
files: compactBatchStringList(repair.files, 20),
};
}
function compactBatchDiagnostics(items) {
function compactBatchDiagnostics(items, depth = 0) {
if (!Array.isArray(items)) return undefined;
return items.slice(0, 12).map((item) => ({
entryId: compactBatchString(item?.entryId || item?.id),
reason: compactBatchString(item?.reason || item?.kind),
detail: compactBatchString(item?.detail),
message: compactBatchString(item?.message),
@@ -329,6 +333,9 @@ function compactBatchDiagnostics(items) {
ref: compactBatchString(item?.ref),
marker: compactBatchString(item?.marker),
files: compactBatchStringList(item?.files, 8),
candidates: depth < 2 ? compactBatchSourceMatches(item?.candidates, 8) : undefined,
failures: depth < 2 ? compactBatchDiagnostics(item?.failures, depth + 1) : undefined,
checks: depth < 2 ? compactBatchDiagnostics(item?.checks, depth + 1) : undefined,
}));
}
@@ -357,6 +364,7 @@ function compactBatchSourceMatch(match) {
file: compactBatchString(match.relativeFile || match.file),
line: normalizeBatchNumber(match.line),
column: normalizeBatchNumber(match.column),
kind: compactBatchString(match.kind),
reason: compactBatchString(match.reason || match.kind),
status: compactBatchString(match.status),
};
+23 -2
View File
@@ -100,8 +100,19 @@ describe('live-copy-edit-agent', () => {
pageUrl: '/',
repair: {
status: 'needs_decision',
attempt: 2,
maxAttempts: 3,
reason: 'source_verification_failed',
pageUrl: '/pricing',
transactionId: huge,
failures: [{ message: huge, extra: huge }],
failures: [{
entryId: 'bounded',
message: huge,
candidates: [{ file: huge, line: 12, kind: 'text' }],
failures: [{ ref: huge, reason: huge }],
checks: [{ file: huge, reason: huge }],
extra: huge,
}],
files: [huge],
extra: huge,
},
@@ -129,11 +140,21 @@ describe('live-copy-edit-agent', () => {
assert.deepEqual(Object.keys(compact.repair).sort(), [
'failures',
'files',
'attempt',
'maxAttempts',
'pageUrl',
'reason',
'status',
'transactionId',
]);
].sort());
assert.equal(compact.repair.attempt, 2);
assert.equal(compact.repair.reason, 'source_verification_failed');
assert.ok(compact.repair.transactionId.length < 400);
assert.ok(compact.repair.failures[0].message.length < 400);
assert.equal(compact.repair.failures[0].entryId, 'bounded');
assert.ok(compact.repair.failures[0].candidates[0].file.length < 400);
assert.ok(compact.repair.failures[0].failures[0].ref.length < 400);
assert.ok(compact.repair.failures[0].checks[0].file.length < 400);
assert.deepEqual(Object.keys(compact.candidates[0]).sort(), [
'entryId',
'ref',