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.
TypeScript canva-alternativecanvasdesigndesign-tooldrag-and-dropeditorgraphic-designkonvanextjsopen-sourcereactself-hostedtemplatestypescript
fix(v0.29.2): audit fix-round resilience — found on the PRODUCTION eval
Ashiq Hussain Mire3ba6537b961
diff --git a/src/lib/agent/harness.test.ts b/src/lib/agent/harness.test.tsindex 215c37e..a64eb59 100644--- a/src/lib/agent/harness.test.ts+++ b/src/lib/agent/harness.test.ts@@ -323,6 +323,53 @@ describe('harness · tool matrix', () => {expect(finalEvent.type).toBe('done')expect(String(finalEvent.summary)).toContain('disclosed')})++ it('CASE I: striking out during the audit fix round discloses instead of failing', async () => {+ const events: AgentEvent[] = []+ // bg → text → done (audit finds issues) → 3 INVALID tool calls in+ // the fix round → the run must END AS DONE with disclosure, not error+ const { chat } = scriptedChat([+ turn('set_background', { kind: 'solid', from: '#090B1A' }),+ turn('add_text', { text: 'Dark text', fontSize: 40, color: '#111122' }),+ done('Poster complete'),+ turn('patch_things', { nope: true }),+ turn('patch_things', { nope: true }),+ turn('patch_things', { nope: true }),+ ])+ const result = await runAgentLoop({+ chat,+ design,+ mode: 'create',+ emit: (e) => events.push(e),+ awaitApply: async () => ({ ok: true }),+ auditDesign: async () => ['Low contrast: text "Dark text" #111122 on #090B1A is 1.0:1 (needs 3:1)'],+ })+ expect(result.toolCalls).toBe(2)+ expect(events.filter((e) => e.type === 'error').length).toBe(0)+ const finalEvent = events[events.length - 1] as { type: string; summary?: string }+ expect(finalEvent.type).toBe('done')+ expect(String(finalEvent.summary)).toContain('could not be applied')+ })++ it('CASE J: update_elements accepts the color alias models habitually send', async () => {+ const events: AgentEvent[] = []+ const { chat, calls } = scriptedChat([+ turn('set_background', { kind: 'solid', from: '#090B1A' }),+ turn('update_elements', { ids: ['txt-1'], patch: { color: '#FFFFFF' } }),+ done('Fixed contrast'),+ ])+ const result = await runAgentLoop({+ chat,+ design,+ mode: 'create',+ emit: (e) => events.push(e),+ awaitApply: async () => ({ ok: true }),+ })+ // the alias must sanitize cleanly (no strike observation, 2 tool calls)+ expect(result.toolCalls).toBe(2)+ expect(events.some((e) => e.type === 'observation' && /not a known tool|invalid/i.test(e.message ?? ''))).toBe(false)+ expect(events[events.length - 1]?.type).toBe('done')+ })})// ═════════════════════════════════════════════════════════════diff --git a/src/lib/agent/loop.ts b/src/lib/agent/loop.tsindex e31a967..52184ae 100644--- a/src/lib/agent/loop.ts+++ b/src/lib/agent/loop.ts@@ -236,6 +236,15 @@ export async function runAgentLoop(deps: LoopDeps): Promise<LoopResult> {// ── resource guards (machine protection, NOT product caps) ──if (strikes >= AGENT_GUARDS.strikes) {+ // v0.29.2 (found on the PRODUCTION eval): striking out during the+ // quality-audit fix round must not kill an otherwise-complete+ // design. The canvas already passed the brief; the un-applied+ // polish is disclosed instead of failing the whole run.+ if (auditRounds > 0) {+ const disclosed = `${summary || 'Done.'} Note: quality-audit polish could not be applied (${AGENT_GUARDS.strikes} invalid patch attempts) — the validated design is kept as-is.`.slice(0, 800)+ emit({ v: AGENT_PROTOCOL_VERSION, type: 'done', summary: disclosed, steps, toolCalls, verification })+ return { summary: disclosed, steps, toolCalls, verification }+ }emit({v: AGENT_PROTOCOL_VERSION,type: 'error',diff --git a/src/lib/agent/tools.ts b/src/lib/agent/tools.tsindex 60e459f..ba2041a 100644--- a/src/lib/agent/tools.ts+++ b/src/lib/agent/tools.ts@@ -353,6 +353,13 @@ export const AGENT_TOOLS: AgentTool[] = [}const patch: Record<string, unknown> = {}const p = patchRaw as Record<string, unknown>+ // v0.29.2 (prod eval): models habitually spell the text colour+ // `color` / `fontColor` / `textColor`. Map the aliases instead of+ // striking — a rejected patch burned three strikes on canvix.app+ // and killed an otherwise-complete design.+ for (const alias of ['color', 'fontColor', 'textColor'] as const) {+ if (p[alias] !== undefined && p.fill === undefined) p.fill = p[alias]+ }for (const key of ['x', 'y', 'width', 'height', 'rotation', 'lineHeight', 'letterSpacing', 'curve'] as const) {if (p[key] !== undefined) {const v = num(p as Record<string, unknown>, key)@@ -391,7 +398,12 @@ export const AGENT_TOOLS: AgentTool[] = [}if (p.align !== undefined) patch.align = enumVal(p as Record<string, unknown>, 'align', ['left', 'center', 'right'] as const, 'center')if (Object.keys(patch).length === 0) {- return { ok: false, error: 'patch is empty — set at least one supported property (see the tool spec).' }+ const sent = Object.keys(p).filter((k) => k !== 'ids')+ const valid = ['x', 'y', 'width', 'height', 'rotation', 'text', 'fill', 'fontSize', 'bold', 'italic', 'underline', 'strike', 'uppercase', 'align', 'lineHeight', 'letterSpacing', 'curve', 'flipH', 'flipV', 'brightness', 'contrast', 'saturation', 'locked', 'visible', 'opacity']+ return {+ ok: false,+ error: `patch had no supported property. You sent: [${sent.join(', ')}]. Valid properties: [${valid.join(', ')}]. The text colour property is named fill.`,+ }}return {ok: true,