Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: keep rejection evidence conservative under reassignment (#11403)
[._.]/ Adam Eivy53cdebc03b53
diff --git a/server/lib/goalFidelity.js b/server/lib/goalFidelity.jsindex 268ebc11a7..3c45e14f4f 100644--- a/server/lib/goalFidelity.js+++ b/server/lib/goalFidelity.js@@ -515,12 +515,13 @@ export function productionAuditEvidence(diff) {record('binding', { name: code(node.id), value: code(node.init),...(value !== null && node.id.type === 'Identifier'&& ast.program.body[0].type === 'VariableDeclaration'+ && ast.program.body[0].kind === 'const'&& ast.program.body[0].declarations.length === 1&& ast.program.body[0].declarations[0] === node? { handledRejectionValue: value } : {}),});}- if (node.type === 'UpdateExpression' || node.type === 'AssignmentExpression') record('write');+ if (node.type === 'UpdateExpression' || node.type === 'AssignmentExpression') record('write', { target: code(node.type === 'UpdateExpression' ? node.argument : node.left) });if (node.type === 'ReturnStatement') record('return', { value: node.argument ? code(node.argument) : null });if (node.type === 'CallExpression') {record('call', { callee: code(node.callee), arguments: node.arguments.map(code) });@@ -566,7 +567,7 @@ export function productionAuditEvidence(diff) {if (attempts > 64 || (consumed <= start.index && /^\s*(?:if|for|while|try|switch)\b/.test(remainder))) break;}// Evaluate only the adjacent complete statement with a literal boolean- // returned by an awaited catch. This is a syntax scenario, not a claim+ // returned by an awaited catch into an immutable binding. This is a syntax scenario, not a claim// about unseen surrounding branches or whether the callback can throw.const handledRejectionScenarios = statements.flatMap((statement, index) => {const binding = statement.facts.find(fact => fact.kind === 'binding' && typeof fact.handledRejectionValue === 'boolean');@@ -576,6 +577,8 @@ export function productionAuditEvidence(diff) {statement.range[1], next.range[0],);if (blankLiterals(between).trim()) return [];+ if (next.facts.some(fact => fact.kind === 'write'+ && (fact.target.match(/[A-Za-z_$][\w$]*/g) || []).includes(binding.name))) return [];return next.facts.filter(fact => fact.kind === 'write' && fact.callbacks.length === 0).flatMap(write => {const values = write.conditions.map(condition => condition === binding.namediff --git a/server/lib/goalFidelity.test.js b/server/lib/goalFidelity.test.jsindex b4d87b72ec..74c76b16e6 100644--- a/server/lib/goalFidelity.test.js+++ b/server/lib/goalFidelity.test.js@@ -236,14 +236,14 @@ describe('productionAuditEvidence', () => {expect(row.file).toBe('lifecycle.js');expect(row.hunk).toBe('@@ -10,2 +10,2 @@');expect(row.statements.flatMap(statement => statement.facts)).toContainEqual({- kind: 'write', source: 'backfilled++', conditions: ['recorded'], callbacks: [],+ kind: 'write', source: 'backfilled++', target: 'backfilled', conditions: ['recorded'], callbacks: [],});expect(row.statements.flatMap(statement => statement.facts)).toContainEqual(expect.objectContaining({kind: 'conditional', test: 'failed', whenTruthy: "'warn'", whenFalsy: "'info'",}));const mutated = productionAuditEvidence(makeDiff('backfilled++;'));expect(mutated[0].statements.flatMap(statement => statement.facts)).toContainEqual({- kind: 'write', source: 'backfilled++', conditions: [], callbacks: [],+ kind: 'write', source: 'backfilled++', target: 'backfilled', conditions: [], callbacks: [],});expect(JSON.stringify(mutated)).not.toContain('expect(');});@@ -276,7 +276,10 @@ else backfilled++;`));'while (pending) backfilled++;','if (recorded) { while (pending) backfilled++; }','const next = () => { backfilled++; };',+ 'if (recorded) {} else { recorded = true; if (recorded) backfilled++; }',]) expect(productionAuditEvidence(diff(`${binding}\n${statement}`))[0].handledRejectionScenarios).toEqual([]);+ expect(productionAuditEvidence(diff(`let recorded = await recordTaskCompletion().catch(() => false);+if (recorded) {} else { recorded = true; if (recorded) backfilled++; }`))[0].handledRejectionScenarios).toEqual([]);const [commented] = productionAuditEvidence(diff(`/*\nif (recorded) backfilled++;\n*/\nconst label = "if (recorded) backfilled++;";`));expect(commented.statements.flatMap(statement => statement.facts).filter(fact => fact.kind === 'write')).toEqual([]);});diff --git a/server/services/codeReview.js b/server/services/codeReview.jsindex 601dd7f804..b026ca5286 100644--- a/server/services/codeReview.js+++ b/server/services/codeReview.js@@ -1492,7 +1492,9 @@ export async function runLocalGoalFidelityReview({ backend, model, objective, di}}}- if ((summaryDisclosureObjective || backfillAudit) && verdict.verdict !== 'rethink') {+ const auditProductionCheck = backfillAudit+ || (oneFindingAudit && productionAfterChangeHunks(trimmedDiff).length === 0)+ if ((summaryDisclosureObjective || auditProductionCheck) && verdict.verdict !== 'rethink') {const rows = oneFindingAudit ? productionAuditEvidence(trimmedDiff) : productionAfterChangeHunks(trimmedDiff)const checks = [{label: 'AFTER-CHANGE PRODUCTION HUNKS',diff --git a/server/services/codeReview.test.js b/server/services/codeReview.test.jsindex eb4f2e42e5..3d015388f2 100644--- a/server/services/codeReview.test.js+++ b/server/services/codeReview.test.js@@ -1432,6 +1432,11 @@ describe('codeReview helpers', () => {global.fetch = vi.fn(async (_url, init) => {const { messages, tools } = JSON.parse(init.body)expect(tools).toBeUndefined()+ if (messages[0].content.startsWith('Check each explicitly requested production outcome independently')) {+ expect(messages[1].content).toContain('AFTER-CHANGE PRODUCTION HUNKS')+ expect(messages[1].content).toContain('[]')+ return completion(shipVerdict)+ }if (messages[0].content.startsWith('Check potential contradictions')) {expect(messages[0].content).toContain('a successful recovery message on stdout is compatible')expect(messages[1].content).toContain('SURVIVING PRODUCTION USES')