Skip to content

Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.

fix(v0.34.1): the wrap-up repair — a guard exit fixes what code can fix before disclosing

Ashiq Hussain Mir06925e8f7063
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d339582..cef7b49 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4439,3 +4439,19 @@ batch 5, semantic 2, the live integration 1 — covered text + low
contrast repaired in code, re-audit authoritative-clean, done
accepted, zero extra model turns); full suite 1,846/1,846 across
132 files; typecheck, lint and production build green.
+
+### Fixed — v0.34.1: the wrap-up repair — a guard exit fixes what code can fix before disclosing
+
+The 27 Nov live evaluation (the NEON after-run, 38 steps · 40
+actions) ended at the CYCLE guard with 12 disclosed-unfixed
+low-contrast issues — every one a fill-ladder fix. The deterministic
+repair only ran on the DONE path; a run that wraps at a guard exit
+(idle/cycle/strikes) never reached it. guardExit now plans + applies
+the deterministic repair FIRST (no model round-trip — the run is
+ending anyway; the repairs ride the same acked bridge, undoable +
+authoritative), re-audits, and discloses only the genuine residue.
+The wrap-up message says "residue after the deterministic repair".
+
+Harness: +1 regression (the cycle-guard wrap-up with contrast residue
+applies the repair through the bridge, re-audits, then discloses) —
+1,847/1,847 across the full suite.
diff --git a/src/lib/agent/harness.test.ts b/src/lib/agent/harness.test.ts
index 4cc80f2..d2ba19f 100644
--- a/src/lib/agent/harness.test.ts
+++ b/src/lib/agent/harness.test.ts
@@ -3620,3 +3620,44 @@ describe('v0.34 · the deterministic repair pass — code fixes what code can fi
expect(result.toolCalls).toBe(2)
})
})
+
+describe('v0.34.1 · the guard-exit wrap-up repairs before disclosing', () => {
+ it('a cycle-guard wrap-up with low-contrast residue applies the deterministic repair through the bridge, then discloses only what remains', async () => {
+ const events: AgentEvent[] = []
+ let auditCalls = 0
+ // the model stalls: the same no-effect call until the cycle guard wraps
+ const { chat } = scriptedChat([
+ turn('set_background', { kind: 'solid', from: '#0A0A1A' }),
+ turn('plan_layout', { background: '#0A0A1A', sections: [{ name: 'hero', y: 65, height: 300, contains: 'headline' }] }),
+ turn('add_text', { text: 'Dark', fontSize: 40, color: '#3A1A5E' }),
+ turn('add_text', { text: 'x', fontSize: 12, color: '#000000' }),
+ turn('add_text', { text: 'x', fontSize: 12, color: '#000000' }),
+ turn('add_text', { text: 'x', fontSize: 12, color: '#000000' }),
+ ])
+ const result = await runAgentLoop({
+ chat,
+ design: {
+ name: 'Poster', width: 1080, height: 1080, pageCount: 1, currentPageIndex: 0,
+ background: '#0A0A1A',
+ elements: [
+ { id: 't9', type: 'text', text: 'Dark', x: 100, y: 100, width: 400, height: 60, fill: '#3A1A5E', fontSize: 40 },
+ ],
+ colorsInUse: [], otherPages: [],
+ } as never,
+ mode: 'create',
+ request: 'Create a poster with a dark headline',
+ emit: (e) => events.push(e),
+ awaitApply: async () => ({ ok: true }),
+ auditDesign: (async () => {
+ auditCalls += 1
+ return ['Low contrast: text "Dark" #3a1a5e on its effective backdrop #0a0a1e is 1.5:1 (needs 3:1) — change the text fill or the card behind it.']
+ }) as never,
+ })
+ // the wrap-up REPAIRED in code through the acked bridge first
+ expect(events.some((e) => e.type === 'action' && (e as { tool?: string }).tool === 'repair')).toBe(true)
+ expect(events.some((e) => e.type === 'observation' && String((e as { message?: string }).message ?? '').includes('DETERMINISTIC REPAIR AT WRAP-UP'))).toBe(true)
+ // the re-audit ran; the residue disclosure names the deterministic repair
+ expect(auditCalls).toBeGreaterThanOrEqual(2)
+ expect(String(result.summary)).toContain('residue after the deterministic repair')
+ })
+})
diff --git a/src/lib/agent/loop.ts b/src/lib/agent/loop.ts
index 3488730..e319d7e 100644
--- a/src/lib/agent/loop.ts
+++ b/src/lib/agent/loop.ts
@@ -525,15 +525,51 @@ export async function runAgentLoop(deps: LoopDeps): Promise<LoopResult> {
}
if ((mode === 'create' || mode === 'improve') && deps.auditDesign) {
try {
- const issues = (await deps.auditDesign(planBands.length ? planBands : undefined)) ?? []
+ let issues = (await deps.auditDesign(planBands.length ? planBands : undefined)) ?? []
+ // v0.34.1 · REPAIR AT WRAP-UP TOO. The 27 Nov live repro ended
+ // at the cycle guard with 12 disclosed-unfixed low-contrast
+ // issues — every one a fill-ladder fix — because the
+ // deterministic repair only ran on the done path and the run
+ // never reached done. A guard exit now repairs what code can
+ // fix FIRST (no model round-trip — the run is ending anyway,
+ // and the repairs ride the same acked bridge), re-audits, and
+ // discloses only the genuine residue.
+ try {
+ const live = deps.refreshedContext?.() ?? design
+ const repair = planRepair(live, issues)
+ if (repair.actions.length) {
+ emit({
+ v: AGENT_PROTOCOL_VERSION,
+ type: 'action',
+ stepIndex: steps,
+ callId: `repair-${steps}-${Math.random().toString(36).slice(2, 8)}`,
+ risk: 'write',
+ tool: 'repair',
+ actions: repair.actions,
+ })
+ const ack = (await deps.awaitApply?.()) ?? { ok: true }
+ if (ack.ok) {
+ emit({
+ v: AGENT_PROTOCOL_VERSION,
+ type: 'observation',
+ stepIndex: steps,
+ message: `DETERMINISTIC REPAIR AT WRAP-UP — ${repair.actions.length} fix(es) applied: ${repair.notes.slice(0, 4).join('; ')}${repair.notes.length > 4 ? ` (+${repair.notes.length - 4} more)` : ''}`,
+ })
+ verificationLog.push(`wrap-up repair: ${repair.actions.length} deterministic fix(es)`)
+ issues = (await deps.auditDesign(planBands.length ? planBands : undefined)) ?? []
+ }
+ }
+ } catch {
+ /* the wrap-up repair is best-effort; the disclosure still runs */
+ }
if (issues.length) {
const residue = issues.slice(0, 4).map((i) => `· ${i}`).join('\n')
- const withResidue = `${base}\nQuality audit at wrap-up (fixable residue):\n${residue}`
+ const withResidue = `${base}\nQuality audit at wrap-up (residue after the deterministic repair):\n${residue}`
return {
summary: withResidue,
verification: verification
- ? `${verification} Quality audit at wrap-up reports ${issues.length} issue(s) — disclosed, unfixed.`
- : `Quality audit at wrap-up reports ${issues.length} issue(s) — disclosed, unfixed.`,
+ ? `${verification} Quality audit at wrap-up reports ${issues.length} issue(s) after the deterministic repair — disclosed, unfixed.`
+ : `Quality audit at wrap-up reports ${issues.length} issue(s) after the deterministic repair — disclosed, unfixed.`,
}
}
} catch {