@ggui-ai/ui-gen 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-h4_V69LI.d.ts → adapter-DLQ-5COm.d.ts} +1 -1
- package/dist/adapters/base.js +2 -27
- package/dist/adapters/base.js.map +1 -1
- package/dist/adapters/generation-dispatch.d.ts +14 -6
- package/dist/adapters/generation-dispatch.js +40 -19260
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +25 -3561
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/types.js +2 -9
- package/dist/adapters/types.js.map +1 -1
- package/dist/advanced/index.d.ts +13 -12
- package/dist/advanced/index.js +63 -21954
- package/dist/advanced/index.js.map +1 -1
- package/dist/{bank-Ctdp3FUA.d.ts → bank-LWaiAtaA.d.ts} +1 -1
- package/dist/blueprint-validator.js +6 -2301
- package/dist/blueprint-validator.js.map +1 -1
- package/dist/boilerplate.d.ts +3 -2
- package/dist/boilerplate.js +6 -1867
- package/dist/boilerplate.js.map +1 -1
- package/dist/check/index.d.ts +3 -2
- package/dist/check/index.js +6 -1923
- package/dist/check/index.js.map +1 -1
- package/dist/chunk-33B3BAWS.js +24 -0
- package/dist/chunk-33B3BAWS.js.map +1 -0
- package/dist/chunk-3HSGA6NI.js +591 -0
- package/dist/chunk-3HSGA6NI.js.map +1 -0
- package/dist/chunk-3NNNGNTO.js +1707 -0
- package/dist/chunk-3NNNGNTO.js.map +1 -0
- package/dist/chunk-3T2HMTON.js +79 -0
- package/dist/chunk-3T2HMTON.js.map +1 -0
- package/dist/chunk-3ZSSDV3L.js +123 -0
- package/dist/chunk-3ZSSDV3L.js.map +1 -0
- package/dist/chunk-4MBR5GA3.js +99 -0
- package/dist/chunk-4MBR5GA3.js.map +1 -0
- package/dist/chunk-56NJFD55.js +337 -0
- package/dist/chunk-56NJFD55.js.map +1 -0
- package/dist/chunk-5AGTY555.js +26 -0
- package/dist/chunk-5AGTY555.js.map +1 -0
- package/dist/chunk-5EJM7EGY.js +115 -0
- package/dist/chunk-5EJM7EGY.js.map +1 -0
- package/dist/chunk-5KXCQLLR.js +529 -0
- package/dist/chunk-5KXCQLLR.js.map +1 -0
- package/dist/chunk-5VBXHVEH.js +171 -0
- package/dist/chunk-5VBXHVEH.js.map +1 -0
- package/dist/chunk-6KDDEING.js +515 -0
- package/dist/chunk-6KDDEING.js.map +1 -0
- package/dist/chunk-6VDRWAP6.js +123 -0
- package/dist/chunk-6VDRWAP6.js.map +1 -0
- package/dist/chunk-732IBFEJ.js +2400 -0
- package/dist/chunk-732IBFEJ.js.map +1 -0
- package/dist/chunk-73AURS3I.js +46 -0
- package/dist/chunk-73AURS3I.js.map +1 -0
- package/dist/chunk-77H5SKLX.js +8 -0
- package/dist/chunk-77H5SKLX.js.map +1 -0
- package/dist/chunk-7QE3AHLE.js +35 -0
- package/dist/chunk-7QE3AHLE.js.map +1 -0
- package/dist/chunk-A375NNWN.js +11 -0
- package/dist/chunk-A375NNWN.js.map +1 -0
- package/dist/chunk-AOU33EFS.js +140 -0
- package/dist/chunk-AOU33EFS.js.map +1 -0
- package/dist/chunk-BA4QYA6E.js +461 -0
- package/dist/chunk-BA4QYA6E.js.map +1 -0
- package/dist/chunk-DBP764GL.js +3 -0
- package/dist/chunk-DBP764GL.js.map +1 -0
- package/dist/chunk-DUU3ZJDQ.js +41 -0
- package/dist/chunk-DUU3ZJDQ.js.map +1 -0
- package/dist/chunk-DXKRBXNU.js +30 -0
- package/dist/chunk-DXKRBXNU.js.map +1 -0
- package/dist/chunk-FB7OEEAH.js +1467 -0
- package/dist/chunk-FB7OEEAH.js.map +1 -0
- package/dist/chunk-FLRNMZV2.js +18 -0
- package/dist/chunk-FLRNMZV2.js.map +1 -0
- package/dist/chunk-FWJIMKFZ.js +2032 -0
- package/dist/chunk-FWJIMKFZ.js.map +1 -0
- package/dist/chunk-FXRHWYIQ.js +163 -0
- package/dist/chunk-FXRHWYIQ.js.map +1 -0
- package/dist/chunk-G3PMV62Z.js +33 -0
- package/dist/chunk-G3PMV62Z.js.map +1 -0
- package/dist/chunk-GAJI7Y3P.js +13 -0
- package/dist/chunk-GAJI7Y3P.js.map +1 -0
- package/dist/chunk-GYINWMPR.js +2052 -0
- package/dist/chunk-GYINWMPR.js.map +1 -0
- package/dist/chunk-HD6ABIK7.js +484 -0
- package/dist/chunk-HD6ABIK7.js.map +1 -0
- package/dist/chunk-HDQVHYO6.js +100 -0
- package/dist/chunk-HDQVHYO6.js.map +1 -0
- package/dist/chunk-IHUT3SIW.js +7 -0
- package/dist/chunk-IHUT3SIW.js.map +1 -0
- package/dist/chunk-JDH5EGNZ.js +126 -0
- package/dist/chunk-JDH5EGNZ.js.map +1 -0
- package/dist/chunk-JMD4RGSV.js +37 -0
- package/dist/chunk-JMD4RGSV.js.map +1 -0
- package/dist/chunk-KJWGZL5B.js +33 -0
- package/dist/chunk-KJWGZL5B.js.map +1 -0
- package/dist/chunk-MKMDQFZ7.js +86 -0
- package/dist/chunk-MKMDQFZ7.js.map +1 -0
- package/dist/chunk-NF6JUZWF.js +85 -0
- package/dist/chunk-NF6JUZWF.js.map +1 -0
- package/dist/chunk-O2YC6XDC.js +1933 -0
- package/dist/chunk-O2YC6XDC.js.map +1 -0
- package/dist/chunk-OVLH5ICV.js +29 -0
- package/dist/chunk-OVLH5ICV.js.map +1 -0
- package/dist/chunk-PBOYHGSD.js +106 -0
- package/dist/chunk-PBOYHGSD.js.map +1 -0
- package/dist/chunk-PJFH7QWA.js +81 -0
- package/dist/chunk-PJFH7QWA.js.map +1 -0
- package/dist/chunk-PUH4CXGZ.js +284 -0
- package/dist/chunk-PUH4CXGZ.js.map +1 -0
- package/dist/chunk-QLXXPGTV.js +18 -0
- package/dist/chunk-QLXXPGTV.js.map +1 -0
- package/dist/chunk-R5GIGPW2.js +2845 -0
- package/dist/chunk-R5GIGPW2.js.map +1 -0
- package/dist/chunk-RH4IUSTO.js +83 -0
- package/dist/chunk-RH4IUSTO.js.map +1 -0
- package/dist/chunk-S2GVXKKY.js +153 -0
- package/dist/chunk-S2GVXKKY.js.map +1 -0
- package/dist/chunk-TVHGKFJS.js +58 -0
- package/dist/chunk-TVHGKFJS.js.map +1 -0
- package/dist/chunk-U7GALWLG.js +66 -0
- package/dist/chunk-U7GALWLG.js.map +1 -0
- package/dist/chunk-VTC263LT.js +256 -0
- package/dist/chunk-VTC263LT.js.map +1 -0
- package/dist/chunk-WEOXFEVE.js +739 -0
- package/dist/chunk-WEOXFEVE.js.map +1 -0
- package/dist/chunk-WYHP46LT.js +28 -0
- package/dist/chunk-WYHP46LT.js.map +1 -0
- package/dist/chunk-XGLO5LGG.js +274 -0
- package/dist/chunk-XGLO5LGG.js.map +1 -0
- package/dist/chunk-XRBCRKA2.js +29 -0
- package/dist/chunk-XRBCRKA2.js.map +1 -0
- package/dist/chunk-XW7ADFFV.js +340 -0
- package/dist/chunk-XW7ADFFV.js.map +1 -0
- package/dist/chunk-YIQ42IUX.js +34 -0
- package/dist/chunk-YIQ42IUX.js.map +1 -0
- package/dist/chunk-YJZTUY7B.js +101 -0
- package/dist/chunk-YJZTUY7B.js.map +1 -0
- package/dist/chunk-Z3CXME3K.js +107 -0
- package/dist/chunk-Z3CXME3K.js.map +1 -0
- package/dist/classifier/index.js +2 -527
- package/dist/classifier/index.js.map +1 -1
- package/dist/client-JBPCXU7W.js +4 -0
- package/dist/client-JBPCXU7W.js.map +1 -0
- package/dist/compose.js +3 -367
- package/dist/compose.js.map +1 -1
- package/dist/cost-tracker-HHGQ4FTW.js +67 -0
- package/dist/cost-tracker-HHGQ4FTW.js.map +1 -0
- package/dist/{create-ui-generator-BrZHF0cf.d.ts → create-ui-generator-BY-WeaPi.d.ts} +3 -3
- package/dist/{design-mode-DGWN_Gkm.d.ts → design-mode-XyOQmzE0.d.ts} +4 -3
- package/dist/{dispatch-B07TI30d.d.ts → dispatch-8LzTddKw.d.ts} +3 -2
- package/dist/dist-UALN6ZVB.js +543 -0
- package/dist/dist-UALN6ZVB.js.map +1 -0
- package/dist/dupe-break-X6K7QFIS.js +4 -0
- package/dist/dupe-break-X6K7QFIS.js.map +1 -0
- package/dist/evaluation/axis-checks/index.d.ts +5 -4
- package/dist/evaluation/axis-checks/index.js +6 -1914
- package/dist/evaluation/axis-checks/index.js.map +1 -1
- package/dist/evaluation/axis-checks/registry.d.ts +3 -2
- package/dist/evaluation/axis-checks/registry.js +3 -1844
- package/dist/evaluation/axis-checks/registry.js.map +1 -1
- package/dist/evaluation/index.d.ts +49 -132
- package/dist/evaluation/index.js +302 -6466
- package/dist/evaluation/index.js.map +1 -1
- package/dist/evaluation/types.d.ts +3 -2
- package/dist/evaluation/types.js +2 -5
- package/dist/evaluation/types.js.map +1 -1
- package/dist/fragments/index.js +2 -338
- package/dist/fragments/index.js.map +1 -1
- package/dist/{generate-tSO_shQ0.d.ts → generate-DQ4ci90s.d.ts} +1 -1
- package/dist/harness/check/runtime-render/index.d.ts +35 -15
- package/dist/harness/check/runtime-render/index.js +6 -2390
- package/dist/harness/check/runtime-render/index.js.map +1 -1
- package/dist/harness/check/runtime-render/render-check-worker.js +4 -1739
- package/dist/harness/check/runtime-render/render-check-worker.js.map +1 -1
- package/dist/harness/index.d.ts +3 -2
- package/dist/harness/index.js +23 -5126
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/llm-trace-sink.js +2 -24
- package/dist/harness/llm-trace-sink.js.map +1 -1
- package/dist/harness/prompts.d.ts +2 -2
- package/dist/harness/prompts.js +8 -324
- package/dist/harness/prompts.js.map +1 -1
- package/dist/harness/result-types.d.ts +6 -5
- package/dist/harness/result-types.js +2 -0
- package/dist/harness/result-types.js.map +1 -1
- package/dist/harness/runtime.d.ts +22 -5
- package/dist/harness/runtime.js +10 -2313
- package/dist/harness/runtime.js.map +1 -1
- package/dist/harness/types-public.d.ts +3 -2
- package/dist/harness/types-public.js +16 -2954
- package/dist/harness/types-public.js.map +1 -1
- package/dist/harness/validator-trace-sink.d.ts +3 -2
- package/dist/harness/validator-trace-sink.js +2 -26
- package/dist/harness/validator-trace-sink.js.map +1 -1
- package/dist/hash.js +2 -39
- package/dist/hash.js.map +1 -1
- package/dist/hashline-5OKREIRM.js +4 -0
- package/dist/hashline-5OKREIRM.js.map +1 -0
- package/dist/index.d.ts +50 -11
- package/dist/index.js +57 -22015
- package/dist/index.js.map +1 -1
- package/dist/llm-evaluator-PN3WFCS4.js +653 -0
- package/dist/llm-evaluator-PN3WFCS4.js.map +1 -0
- package/dist/magic-string.es-2NZTC4GZ.js +1307 -0
- package/dist/magic-string.es-2NZTC4GZ.js.map +1 -0
- package/dist/patch.d.ts +3 -2
- package/dist/patch.js +2 -56
- package/dist/patch.js.map +1 -1
- package/dist/policy-VCYKGSAC.js +5 -0
- package/dist/policy-VCYKGSAC.js.map +1 -0
- package/dist/policy.js +2 -35
- package/dist/policy.js.map +1 -1
- package/dist/primitive-index-2OF6F4TZ.js +131 -0
- package/dist/primitive-index-2OF6F4TZ.js.map +1 -0
- package/dist/primitive-slice-WTMBLYFJ.js +235 -0
- package/dist/primitive-slice-WTMBLYFJ.js.map +1 -0
- package/dist/{prompts-BhNUuRoZ.d.ts → prompts-CLZGywMP.d.ts} +1 -1
- package/dist/provider-adapter-contract.js +10407 -14204
- package/dist/provider-adapter-contract.js.map +1 -1
- package/dist/provider-adapter.js +2 -44
- package/dist/provider-adapter.js.map +1 -1
- package/dist/providers/index.d.ts +89 -1
- package/dist/providers/index.js +115 -44
- package/dist/providers/index.js.map +1 -1
- package/dist/raw-C6KBH5I3.js +141 -0
- package/dist/raw-C6KBH5I3.js.map +1 -0
- package/dist/raw-FXSBXQTZ.js +7 -0
- package/dist/raw-FXSBXQTZ.js.map +1 -0
- package/dist/raw-MURDUPGK.js +8 -0
- package/dist/raw-MURDUPGK.js.map +1 -0
- package/dist/raw-T3GW3UVX.js +8 -0
- package/dist/raw-T3GW3UVX.js.map +1 -0
- package/dist/render-check-host-ZNIS6BJ5.js +5 -0
- package/dist/render-check-host-ZNIS6BJ5.js.map +1 -0
- package/dist/sdk-4JNSDNSR.js +6 -0
- package/dist/sdk-4JNSDNSR.js.map +1 -0
- package/dist/sdk-DIVJMHCX.js +7 -0
- package/dist/sdk-DIVJMHCX.js.map +1 -0
- package/dist/sdk-QRJOCRTS.js +7 -0
- package/dist/sdk-QRJOCRTS.js.map +1 -0
- package/dist/tag-balance-CTHCTRJ7.js +123 -0
- package/dist/tag-balance-CTHCTRJ7.js.map +1 -0
- package/dist/tools/get-primitives-ts.d.ts +1 -1
- package/dist/tools/get-primitives-ts.js +3 -1
- package/dist/tools/get-primitives-ts.js.map +1 -1
- package/dist/tools/render-check-worker.js +3 -40
- package/dist/tools/render-check-worker.js.map +1 -1
- package/dist/{types-public-h8IMnYuh.d.ts → types-public-hYlrerZh.d.ts} +35 -2
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +3 -498
- package/dist/validation/index.js.map +1 -1
- package/dist/{visual-evaluator-C2strxqD.d.ts → visual-evaluator-KskajxD5.d.ts} +14 -4
- package/dist/visual-evaluator-TGEXYQTP.js +12 -0
- package/dist/visual-evaluator-TGEXYQTP.js.map +1 -0
- package/dist/workflows.d.ts +3 -2
- package/dist/workflows.js +2 -151
- package/dist/workflows.js.map +1 -1
- package/package.json +20 -16
- package/src/adapters/claude/sdk.ts +4 -2
- package/src/adapters/claude/tool-bridge.ts +2 -1
- package/src/adapters/generation-dispatch.ts +9 -0
- package/src/adapters/openai/raw.ts +4 -0
- package/src/adapters/openai/sdk.ts +6 -1
- package/src/adapters/openai/tokens.ts +21 -7
- package/src/adapters/tool-bridge.ts +1 -1
- package/src/adapters/tools.ts +1 -1
- package/src/advanced/feedback.ts +1 -2
- package/src/advanced/generator.ts +4 -3
- package/src/boilerplate/free-design-prompt.ts +7 -0
- package/src/boilerplate/generate.ts +18 -5
- package/src/boilerplate/hard-sections.ts +8 -3
- package/src/boilerplate/react-hooks.ts +56 -0
- package/src/boilerplate/system-prompt.ts +12 -3
- package/src/check/run-tier0.ts +233 -8
- package/src/check/type-checker.ts +128 -16
- package/src/coding-agent/tools.ts +26 -3
- package/src/design-mode.ts +4 -9
- package/src/evaluation/axis-checks/checks/state-merge.ts +2 -4
- package/src/evaluation/axis-checks/checks/state-payload.ts +1 -28
- package/src/evaluation/axis-checks/checks/tint.ts +197 -0
- package/src/evaluation/axis-checks/helpers.ts +121 -0
- package/src/evaluation/axis-checks/registry.ts +2 -0
- package/src/evaluation/criteria/__fixtures__/edge-v2-draw2.json +4629 -0
- package/src/evaluation/criteria/bank.ts +1 -1
- package/src/evaluation/criteria/edge-instruments.ts +14 -0
- package/src/evaluation/criteria/edge-probe-v2.ts +352 -0
- package/src/evaluation/criteria/edge-v2.ts +242 -0
- package/src/evaluation/criteria/resolve.ts +24 -5
- package/src/evaluation/index.ts +3 -5
- package/src/evaluation/mcp-server.ts +0 -50
- package/src/evaluation/types-public.ts +6 -1
- package/src/evaluation/visual-evaluator.ts +161 -30
- package/src/harness/check/runtime-render/index.ts +28 -4
- package/src/harness/check/runtime-render/render-check.ts +20 -21
- package/src/harness/claude-agent-sdk-loader.ts +93 -0
- package/src/harness/claude-code-login-query.ts +1 -1
- package/src/harness/coding/generate-task-runner.ts +1 -0
- package/src/harness/coding/run-coding-turn.ts +3 -0
- package/src/harness/coding/run-eval-round.ts +9 -0
- package/src/harness/llm-router.ts +50 -2
- package/src/harness/runtime.ts +17 -0
- package/src/index.ts +9 -0
- package/src/providers/anthropic-tool-call.ts +263 -0
- package/src/providers/index.ts +13 -0
- package/src/tools/get-primitives-ts.ts +1 -1
- package/src/tools/render-check.ts +4 -4
- package/src/validation/primitives.ts +2 -1
- package/src/evaluation/loop.ts +0 -218
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/evaluation/criteria/bank.ts","../src/evaluation/criteria/select.ts","../src/evaluation/criteria/edge-probe.ts","../src/evaluation/criteria/edge-probe-v2.ts","../src/evaluation/criteria/edge-instruments.ts","../src/evaluation/criteria/resolve.ts","../src/evaluation/ink-extent.ts","../src/evaluation/design-identity.ts","../src/evaluation/criteria/edge.ts","../src/evaluation/criteria/edge-v2.ts","../src/evaluation/visual-evaluator.ts"],"names":["KINDS","ROLES","isKind","isRole","num","field","createHash","CARD","same","overlaps","axis","contentEdge","columns","checkColumn","sum","round","resolve","readFileSync","x","edges","screenshot","attempt","result","response","elapsed"],"mappings":";;;;;;;;;;;;;;AAeA,IAAM,YAAA,GAAe,+CAAA;AAGd,IAAM,sBAAwB,CAAA,CAAA,MAAA,CAAO;AAAA,EAC1C,MAAQ,CAAA,CAAA,MAAA,EAAO,CAAE,GAAA,CAAI,CAAC,EAAE,QAAA,EAAS;AAAA,EACjC,QAAU,CAAA,CAAA,MAAA,EAAO,CAAE,GAAA,CAAI,CAAC,EAAE,QAAA,EAAS;AAAA,EACnC,QAAU,CAAA,CAAA,MAAA,EAAO,CAAE,GAAA,CAAI,CAAC,EAAE,QAAA;AAC5B,CAAC,CAAA;AAEM,IAAM,gBAAkB,CAAA,CAAA,MAAA,CAAO;AAAA,EACpC,EAAA,EAAM,CAAA,CAAA,MAAA,EAAO,CAAE,KAAA,CAAM,cAAc,8DAA8D,CAAA;AAAA,EACjG,KAAA,EAAS,CAAA,CAAA,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAC3B,KAAA,EAAO,mBAAA,CAAoB,OAAA,CAAQ,EAAE,CAAA;AAAA;AAAA,EAErC,QAAA,EAAY,CAAA,CAAA,IAAA,CAAK,CAAC,MAAA,EAAQ,QAAQ,CAAC,CAAA;AAAA;AAAA,EAEnC,YAAc,CAAA,CAAA,IAAA,CAAK,CAAC,YAAA,EAAc,OAAA,EAAS,OAAO,CAAC,CAAA;AAAA;AAAA,EAEnD,QAAU,CAAA,CAAA,IAAA,CAAK,CAAC,QAAQ,WAAA,EAAa,SAAA,EAAW,QAAQ,CAAC,CAAA;AAAA;AAAA,EAEzD,IAAA,EAAQ,CAAA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AAA,GAAY,EAAE,YAAA,EAAc,KAAA,CAAM,YAAA,EAAa,GAAI;AAAC,KAChF,CAAA;AACD,IAAA,OAAA,CAAQ,GAAA;AAAA,MACN,CAAA,oBAAA,EAAuB,MAAM,CAAA,CAAA,EAAI,KAAA,CAAM,QAAA,CAAS,KAAK,CAAA,IAAA,EAAI,KAAA,CAAM,QAAA,CAAS,MAAM,CAAA,SAAA,EACjE,aAAA,IAAiB,GAAG,CAAA,EAAA,EAAK,QAAA,GAAW,CAAA,WAAA,EAAc,KAAA,CAAM,MAAA,CAAO,QAAQ,CAAA,CAAA,CAAA,GAAM,EAAE,CAAA,KAAA,EACnF,QAAA,IAAY,GAAG,CAAA,EAAG,KAAA,KAAU,IAAA,GAAO,QAAA,GAAW,EAAE,CAAA,WAAA;AAAA,KAC3D;AAAA,EACF;AACA,EAAA,OAAO,EAAE,MAAA,EAAQ,UAAA,EAAY,MAAA,EAAQ,QAAA,EAAS;AAChD","file":"chunk-732IBFEJ.js","sourcesContent":["/**\n * The visual criteria bank — ggui#1436 (step 1 of the founder's visual-assessment steer).\n *\n * The bank is DATA, never code (#1437 authors it; #1060's bar-and-judge policy): a versioned set of\n * criteria the judge, an instrument or a person answers off the frame, split as the founder ruled —\n * `severity` is importance, `evaluation` the method, `status` the method's readiness (the only source\n * of an `n/a`), `scope` where a row applies ({} = every card; {kind} / {canvas} / {preset} = one). The\n * general rows are `criteria`; a preset's own expression is a `recipes` row carrying `scope.preset`.\n * This module is the ONE loader: a malformed bank refuses at launch with the offending path named,\n * never mid-run. Fields the loader does not read (`examples`, `fields`, `groups`, `seed`) are page\n * matter and are dropped here; an additive field tomorrow does not break today's loader.\n */\nimport * as z from 'zod';\n\n/** `family.property[.facet]` — `read.contrast`, `hello.field`. */\nconst CRITERION_ID = /^[a-z][a-z0-9-]*(?:\\.[a-zA-Z][a-zA-Z0-9-]*)+$/;\n\n/** Where a row applies; every key named must match the card's context. */\nexport const criteriaScopeSchema = z.object({\n kind: z.string().min(1).optional(),\n canvas: z.string().min(1).optional(),\n preset: z.string().min(1).optional(),\n});\n\nexport const bankRowSchema = z.object({\n id: z.string().regex(CRITERION_ID, 'a criterion id is family.property[.facet], lower-case family'),\n group: z.string().optional(),\n scope: criteriaScopeSchema.default({}),\n /** Importance, independent of whether anything automated checks it yet. */\n severity: z.enum(['must', 'should']),\n /** The method that produces the verdict. */\n evaluation: z.enum(['instrument', 'judge', 'human']),\n /** The method's readiness — the only source of an `n/a`. */\n status: z.enum(['live', 'reference', 'planned', 'manual']),\n /** The question, answerable yes/no from the frame. */\n text: z.string().min(1),\n /** The evidence rule: what the one-sentence evidence must name (a region or element). */\n evidence: z.string().min(1),\n /** The templated fix line a feedback channel may consume later; never read in v1. */\n fix: z.string().optional(),\n});\n\nexport const criteriaBankSchema = z\n .object({\n version: z.string().min(1),\n applies: z\n .object({\n /** `[\"*\"]` = every kind. */\n kind: z.array(z.string().min(1)).optional(),\n canvases: z.array(z.string().min(1)).optional(),\n })\n .optional(),\n criteria: z.array(bankRowSchema).min(1),\n recipes: z.array(bankRowSchema).optional(),\n })\n .superRefine((bank, ctx) => {\n const seen = new Set<string>();\n const check = (rows: readonly { id: string }[], key: 'criteria' | 'recipes'): void => {\n rows.forEach((c, i) => {\n if (seen.has(c.id)) ctx.addIssue({ code: 'custom', path: [key, i, 'id'], message: `duplicate criterion id ${c.id}` });\n seen.add(c.id);\n });\n };\n check(bank.criteria, 'criteria');\n check(bank.recipes ?? [], 'recipes');\n });\n\nexport type CriteriaBank = z.infer<typeof criteriaBankSchema>;\nexport type BankRow = z.infer<typeof bankRowSchema>;\nexport type CriteriaScope = z.infer<typeof criteriaScopeSchema>;\n\n/** Every row of the bank — the general criteria, then the recipes. */\nexport function bankRows(bank: CriteriaBank): readonly BankRow[] {\n return [...bank.criteria, ...(bank.recipes ?? [])];\n}\n\n/** The one door for bank data: refuses loudly, naming the path, before anything is judged. */\nexport function parseCriteriaBank(raw: unknown): CriteriaBank {\n const parsed = criteriaBankSchema.safeParse(raw);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((i) => `${i.path.map(String).join('.') || '<root>'}: ${i.message}`).join('; ');\n throw new Error(`criteria bank invalid — ${issues}`);\n }\n return parsed.data;\n}\n","/**\n * The selector — ggui#1436's \"dynamic\" layer, deterministic and recorded: a pure function of the\n * bank and the card's context. Same context → same `criteriaSetId` → same selection, so verdicts\n * pair across arms and replay from the record. A row the selector excludes is absent from the\n * block (the selector's decision); a selected row the judge cannot read comes back `n/a` (the\n * judge's answer). The two are different signals.\n */\nimport { createHash } from 'node:crypto';\nimport type { CriteriaContext, CriteriaSelection } from '../types-public.js';\nimport { bankRows, type BankRow, type CriteriaBank } from './bank.js';\n\n/** Bump when a selection rule changes: it is hashed into every `criteriaSetId`. */\nexport const CRITERIA_SELECTOR_VERSION = 'selector@2';\n\n/** The context as one string, keys sorted at every level — what the id hashes and what the record stores. */\nexport function canonicalCriteriaContext(ctx: CriteriaContext): string {\n const sortKeys = (value: unknown): unknown =>\n value !== null && typeof value === 'object' && !Array.isArray(value)\n ? Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([k, v]) => [k, sortKeys(v)]),\n )\n : value;\n return JSON.stringify(sortKeys(ctx));\n}\n\n/** sha256(bank version | selector version | canonical context), 16 hex — a label at this scale, not a security digest. */\nexport function criteriaSetIdFor(bankVersion: string, ctx: CriteriaContext): string {\n return createHash('sha256')\n .update(`${bankVersion}|${CRITERIA_SELECTOR_VERSION}|${canonicalCriteriaContext(ctx)}`, 'utf8')\n .digest('hex')\n .slice(0, 16);\n}\n\n/** The scope keys that hold for this context, or `null` when one fails; `[]` for an empty scope (static). */\nfunction matchedScope(row: BankRow, ctx: CriteriaContext): string[] | null {\n const s = row.scope;\n const matched: string[] = [];\n if (s.kind !== undefined) {\n if (ctx.kind !== s.kind) return null;\n matched.push(`kind=${s.kind}`);\n }\n if (s.canvas !== undefined) {\n if (ctx.canvas !== s.canvas) return null;\n matched.push(`canvas=${s.canvas}`);\n }\n if (s.preset !== undefined) {\n if (ctx.preset !== s.preset) return null;\n matched.push(`preset=${s.preset}`);\n }\n return matched;\n}\n\nexport interface CriteriaSelectionResult {\n readonly criteriaSetId: string;\n readonly selection: CriteriaSelection[];\n}\n\n/**\n * Select the bank's rows for one card. The bank-level `applies` gate is read first (canvases always;\n * kind only when the caller named one and the bank names kinds other than `*`); then each row's\n * `scope`. An empty scope is `static`; a matched scope is `context` with the keys that matched.\n */\nexport function selectCriteria(bank: CriteriaBank, ctx: CriteriaContext): CriteriaSelectionResult {\n const criteriaSetId = criteriaSetIdFor(bank.version, ctx);\n const applies = bank.applies;\n if (applies?.canvases !== undefined && !applies.canvases.includes(ctx.canvas)) return { criteriaSetId, selection: [] };\n if (applies?.kind !== undefined && ctx.kind !== undefined && !applies.kind.includes('*') && !applies.kind.includes(ctx.kind)) {\n return { criteriaSetId, selection: [] };\n }\n const selection: CriteriaSelection[] = [];\n for (const row of bankRows(bank)) {\n const matched = matchedScope(row, ctx);\n if (matched === null) continue;\n selection.push(matched.length === 0 ? { id: row.id, source: 'static', reason: 'static' } : { id: row.id, source: 'context', reason: `context: ${matched.join(', ')}` });\n }\n return { criteriaSetId, selection };\n}\n","/**\n * `space.edge`'s measurement (#1663): the expression a capture evaluates in the page to produce {@link EdgeBlock}s for\n * {@link judgeEdges}. It runs where the screenshot is taken, on the same DOM at the same width, so the rule reads what\n * the judge's frame shows. It only reads layout; it never writes to the page.\n *\n * What it measures, under `#root`, in CSS px from the card's left edge:\n *\n * - **Text blocks.** Text is grouped by its nearest non-inline element. A block's edge is its first visible character\n * in ink: text in a transparent colour, private-use icon-font glyphs and formatting characters are not characters of\n * the block. Its extent is the union of its inked line boxes. A marker before the text (an icon or image that paints,\n * or a number or bullet on the same line) makes it a hanging marker: `edge` is the marker's, `textEdge` the text's.\n * - **Control groups.** Native and ARIA controls, and bounded boxes the visitor clicks (a pointer cursor or a tab stop,\n * holding no control of their own), group by their parent and are measured at the first control: the border box\n * when bounded, else its text. A control's contents are never blocks of the enclosing column.\n * - **Surfaces.** A non-inline box with a border on at least three sides, its own fill different from what it sits on,\n * or a shadow. A table is a surface measured at its rule and not descended into. A box with no text, control, image\n * or icon inside (a loading bar) is a `placeholder`, which is not a block.\n * - **Roles.** A list item is `list-item` when its list follows a paragraph; text centred in a box wider than it, or\n * controls in a centring row, are `centred`.\n * - **Rows, first, read by geometry.** Items set on one line, however the CSS lays them out: an item after another\n * measured item on its line that holds one block (a text, a control, or a box holding at most one text) belongs to\n * the row and is not measured. An item with a stack inside it is a column.\n * - **Ornaments:** text with no letters or digits is not measured.\n *\n * Hidden elements (through any ancestor), zero-size ones and transparent text are skipped. What the rows and ornament\n * rules set aside is counted. A frame with no text in ink is reported as placeholders only. The expression returns a\n * JSON value; {@link parseEdgeProbe} is its typed read. *\n * **Validated instrument (#1663, 2026-10-02):** this file as of `cec465319` (with `7bb4da13e`) passed a fresh sealed\n * blind draw at the registered bar (27/30, κ 0.76), stricter than the design lead's reading on its disagreements. Any\n * later change to what this file measures or decides is a new instrument until another fresh sealed draw.\n */\nimport type { EdgeBlock } from './edge.js';\n\n/** What the probe returns: the measured blocks, and whether the frame showed nothing to evaluate. */\nexport interface EdgeProbe {\n readonly blocks: readonly EdgeBlock[];\n readonly placeholdersOnly: boolean;\n /** What the probe saw and did not measure, by rule, so a dropped block is counted rather than silent. */\n readonly skipped: { readonly rowItems: number; readonly ornaments: number };\n}\n\n// Plain ES2020 for the page: no imports, no template literals, no helpers a bundler might rename.\nexport const EDGE_BLOCKS_EXPRESSION = String.raw`(() => {\n const root = document.getElementById('root');\n if (!root) return null;\n const rootBox = root.getBoundingClientRect();\n const x0 = rootBox.left;\n const px = (v) => Math.round((v - x0) * 2) / 2;\n const CONTROL = 'button,input,select,textarea,[role=\"button\"],[role=\"tab\"],[role=\"switch\"],[role=\"checkbox\"],[role=\"radio\"],[role=\"option\"],[role=\"link\"],a[href]';\n const ALNUM = /[\\p{L}\\p{N}]/u;\n const css = (el) => getComputedStyle(el);\n const clear = (c) => !c || c === 'transparent' || /rgba\\([^)]*,\\s*0(\\.0+)?\\)$/.test(c);\n // Visible through every ancestor (an ancestor at opacity 0 or visibility hidden hides it), and not degenerate.\n const shown = (el) => {\n const s = css(el);\n if (s.display === 'none' || s.visibility === 'hidden' || Number(s.opacity) === 0) return false;\n if (typeof el.checkVisibility === 'function' && !el.checkVisibility({ opacityProperty: true, visibilityProperty: true })) return false;\n const r = el.getBoundingClientRect();\n return r.width > 1 && r.height > 1;\n };\n const inline = (s) => /^inline/.test(s.display) && s.display !== 'inline-block' && s.display !== 'inline-flex' && s.display !== 'inline-grid';\n const groundOf = (el) => {\n for (let p = el.parentElement; p; p = p.parentElement) { const b = css(p).backgroundColor; if (!clear(b)) return b; }\n return 'rgb(255, 255, 255)';\n };\n const sides = (s) => ['Top', 'Right', 'Bottom', 'Left'].filter((k) => parseFloat(s['border' + k + 'Width']) > 0 && s['border' + k + 'Style'] !== 'none' && !clear(s['border' + k + 'Color'])).length;\n const bounded = (el) => { const s = css(el); return sides(s) >= 1 || (!clear(s.backgroundColor) && s.backgroundColor !== groundOf(el)); };\n // A control: a native or ARIA one, or a bounded box the visitor clicks (a pointer cursor or a tab stop) that holds no\n // control of its own and is not the whole card. Its contents are not blocks of the column (decided 2026-10-02).\n const isControl = (el) => {\n const s = css(el);\n if (inline(s)) return false;\n if (el.matches(CONTROL)) return true;\n if (el === root) return false;\n const clickable = s.cursor === 'pointer' || (el.hasAttribute('tabindex') && el.tabIndex >= 0);\n if (!clickable || !bounded(el) || el.querySelector(CONTROL)) return false;\n const r = el.getBoundingClientRect();\n return r.width * r.height < 0.6 * rootBox.width * rootBox.height;\n };\n const isTable = (el) => el.matches('table,[role=\"table\"],[role=\"grid\"]');\n const isSurface = (el) => {\n if (el === root || isControl(el)) return false;\n const s = css(el);\n if (/^inline/.test(s.display) || s.display === 'contents') return false;\n if (isTable(el)) return true;\n return sides(s) >= 3 || (!clear(s.backgroundColor) && s.backgroundColor !== groundOf(el)) || (s.boxShadow && s.boxShadow !== 'none');\n };\n const path = (el) => {\n const parts = [];\n for (let e = el; e && e !== root && parts.length < 4; e = e.parentElement) {\n const i = e.parentElement ? Array.prototype.indexOf.call(e.parentElement.children, e) + 1 : 1;\n parts.unshift(e.tagName.toLowerCase() + ':' + i);\n }\n return parts.join('>');\n };\n const label = (el) => { const t = (el.innerText || '').replace(/\\s+/g, ' ').trim(); return path(el) + (t ? ' \"' + t.slice(0, 24) + '\"' : ''); };\n const surfaces = [];\n const surfaceOf = (el, self) => { for (let p = self ? el : el.parentElement; p && p !== root; p = p.parentElement) if (surfaces.indexOf(p) >= 0) return p; return null; };\n const inTable = (el) => { for (let p = el.parentElement; p && p !== root; p = p.parentElement) if (isTable(p)) return true; return false; };\n const inControl = (el) => { for (let p = el; p && p !== root; p = p.parentElement) if (isControl(p)) return p; return null; };\n const all = Array.prototype.slice.call(root.querySelectorAll('*')).filter(shown);\n for (const el of all) if (isSurface(el) && !inTable(el) && !inControl(el)) surfaces.push(el);\n const ids = new Map();\n const idOf = (el) => { if (!ids.has(el)) ids.set(el, label(el)); return ids.get(el); };\n const blocks = [];\n // Per block: the element it stands for and its first line's box, for rows.\n const owners = [];\n const lines = [];\n // Per block: its raw line boxes and left, so a row reads the line two items share, not a wrapped item's widest line.\n const rects = [];\n const rawLeft = [];\n const words = [];\n const within = (el, self) => { const s = surfaceOf(el, self); return s ? { within: idOf(s) } : {}; };\n for (const s of surfaces) {\n const r = s.getBoundingClientRect();\n owners.push(s); lines.push({ top: r.top, bottom: r.bottom }); rects.push([r]); rawLeft.push(r.left); words.push('');\n // A placeholder: a box with no text, no control and no image or icon inside it (a loading bar). Not a block.\n const holds = Array.prototype.some.call(s.querySelectorAll('*'), (el) => shown(el) && (el.matches(CONTROL) || el.tagName === 'IMG' || el.tagName.toLowerCase() === 'svg')) || ALNUM.test(s.innerText || '');\n blocks.push(Object.assign({ id: idOf(s), kind: 'surface', edge: px(r.left), left: px(r.left), right: px(r.right), top: Math.round(r.top) }, within(s, false), isTable(s) ? { role: 'table' } : holds ? {} : { role: 'placeholder' }));\n }\n const blockOf = (node) => { for (let p = node.parentElement; p && p !== root; p = p.parentElement) if (!inline(css(p))) return p; return root; };\n const groups = new Map();\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n for (let n = walker.nextNode(); n; n = walker.nextNode()) {\n if (!/\\S/.test(n.data) || !n.parentElement || n.parentElement.closest('style,script,noscript,template') || !shown(n.parentElement) || inControl(n.parentElement) || inTable(n.parentElement)) continue;\n const b = blockOf(n);\n if (!groups.has(b)) groups.set(b, []);\n groups.get(b).push(n);\n }\n // Ink: text whose own colour is not transparent. The edge is the first visible character in ink (decided 2026-10-02):\n // leading invisible text, private-use icon-font glyphs and formatting characters are not characters of the block,\n // while a currency sign or a quotation mark is.\n const inked = (n) => !clear(css(n.parentElement).color) && ALNUM.test(n.data);\n const textRects = (nodes) => {\n const rs = [];\n for (const n of nodes) { if (!inked(n)) continue; const range = document.createRange(); range.selectNodeContents(n); for (const r of range.getClientRects()) if (r.width > 0 && r.height > 0) rs.push(r); }\n return rs;\n };\n const glyphAt = (n, i) => { const range = document.createRange(); range.setStart(n, i); range.setEnd(n, i + 1); const r = range.getClientRects()[0]; return r || null; };\n const firstGlyph = (nodes) => {\n for (const n of nodes) { if (!inked(n)) continue; const i = n.data.search(/[^\\s\\p{Co}\\p{Cf}]/u); if (i < 0) continue; const r = glyphAt(n, i); if (r) return r; }\n return null;\n };\n // A marker paints: a loaded image, an SVG with a filled or stroked shape, or an element with its own fill, border\n // or visible text. An element that paints nothing is not a marker.\n const painted = (m) => {\n if (!shown(m)) return false;\n if (m.tagName === 'IMG') return m.complete && m.naturalWidth > 0;\n if (m.tagName.toLowerCase() === 'svg' || m.closest('svg')) {\n const shapes = m.querySelectorAll('path,circle,rect,line,polyline,polygon,ellipse,use,text');\n return Array.prototype.some.call(shapes, (sh) => { const st = css(sh); return (st.fill !== 'none' && !clear(st.fill)) || (st.stroke !== 'none' && !clear(st.stroke)); });\n }\n const s = css(m);\n if (!clear(s.backgroundColor) || sides(s) >= 1 || ((m.textContent || '').trim().length > 0 && !clear(s.color))) return true;\n // A wrapper that paints nothing itself is a marker when an image or icon inside it paints.\n return Array.prototype.some.call(m.querySelectorAll('svg,img'), (k) => painted(k));\n };\n const markerBefore = (b, textLeft, lineTop, lineBottom) => {\n const cands = [];\n const consider = (m) => { if (!painted(m)) return; const r = m.getBoundingClientRect(); if (r.left < textLeft - 2 && r.bottom > lineTop && r.top < lineBottom) cands.push(r.left); };\n for (const m of b.querySelectorAll('svg,img,[aria-hidden=\"true\"],i')) if ((m.textContent || '').trim().length <= 2) consider(m);\n const p = b.parentElement;\n if (p && p !== root && /flex/.test(css(p).display) && !/column/.test(css(p).flexDirection)) for (const sib of p.children) { if (sib === b) break; if (sib.matches('svg,img,i,[aria-hidden=\"true\"]') || !(sib.textContent || '').trim()) consider(sib); }\n return cands.length ? Math.min.apply(null, cands) : null;\n };\n let texts = 0;\n let ornaments = 0;\n for (const [b, nodes] of groups) {\n if (!nodes.some((n) => ALNUM.test(n.data))) { ornaments += 1; continue; }\n const rs = textRects(nodes);\n const g = firstGlyph(nodes);\n if (!rs.length || g === null) continue;\n texts += 1;\n const first = g.left;\n const left = Math.min.apply(null, rs.map((r) => r.left));\n const right = Math.max.apply(null, rs.map((r) => r.right));\n const top = Math.min.apply(null, rs.map((r) => r.top));\n const marker = markerBefore(b, first, g.top, g.bottom);\n const s = css(b);\n const box = b.getBoundingClientRect();\n const parent = b.parentElement ? css(b.parentElement) : null;\n const centredText = s.textAlign === 'center' && right - left < box.width * 0.9;\n const centredBox = parent && /flex/.test(parent.display) && /column/.test(parent.flexDirection) && parent.alignItems === 'center';\n const list = b.matches('li') || s.display === 'list-item' ? b.closest('ul,ol') : null;\n const inProse = list && list.previousElementSibling && list.previousElementSibling.matches('p');\n const block = { id: idOf(b), kind: 'text', edge: px(marker !== null ? marker : first), left: px(Math.min(left, marker !== null ? marker : left)), right: px(right), top: Math.round(top) };\n if (marker !== null) block.textEdge = px(first);\n if (centredText || centredBox) block.role = 'centred';\n else if (inProse) block.role = 'list-item';\n owners.push(b); lines.push({ top: g.top, bottom: g.bottom }); rects.push(rs); rawLeft.push(Math.min(left, marker !== null ? marker : left)); words.push(nodes.map((n) => n.data).join('').trim());\n blocks.push(Object.assign(block, within(b, true)));\n }\n const ctlGroups = new Map();\n for (const el of all) { if (!isControl(el) || inTable(el) || (el.parentElement && inControl(el.parentElement))) continue; const p = el.parentElement || root; if (!ctlGroups.has(p)) ctlGroups.set(p, []); ctlGroups.get(p).push(el); }\n let controls = 0;\n for (const [p, els] of ctlGroups) {\n const rs = els.map((e) => e.getBoundingClientRect());\n const topRow = Math.min.apply(null, rs.map((r) => r.top));\n let firstEl = null; let firstR = null;\n els.forEach((e, i) => { const r = rs[i]; if (r.top - topRow < r.height / 2 && (!firstR || r.left < firstR.left)) { firstEl = e; firstR = r; } });\n let edge = firstR.left;\n if (!bounded(firstEl)) { const tw = document.createTreeWalker(firstEl, NodeFilter.SHOW_TEXT); const ns = []; for (let n = tw.nextNode(); n; n = tw.nextNode()) ns.push(n); const g = firstGlyph(ns); if (g) edge = g.left; }\n controls += 1;\n const ps = css(p);\n const centred = ps.justifyContent === 'center' || (ps.textAlign === 'center' && !/flex|grid/.test(ps.display));\n const block = { id: idOf(p) + ' [controls]', kind: 'controls', edge: px(edge), left: px(Math.min.apply(null, rs.map((r) => r.left))), right: px(Math.max.apply(null, rs.map((r) => r.right))), top: Math.round(topRow) };\n if (centred) block.role = 'centred';\n owners.push(firstEl); lines.push({ top: firstR.top, bottom: firstR.bottom }); rects.push(rs); rawLeft.push(Math.min.apply(null, rs.map((r) => r.left))); words.push('');\n blocks.push(Object.assign(block, within(firstEl, true)));\n }\n // Rows (decided 2026-10-01, read by geometry 2026-10-02): items set on one line, however the CSS sets them. An item\n // after another measured item on its line that holds one block (a text, a control, or a box holding at most one\n // text) belongs to the row and is not measured; an item with a stack inside it is a column.\n const dropped = new Set();\n const sameLine = (a, b) => Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top) > Math.min(a.bottom - a.top, b.bottom - b.top) / 2;\n const contains = (o, el) => o === el || o.contains(el);\n const innerTexts = (i) => owners.map((el, k) => k).filter((k) => k !== i && blocks[k].kind !== 'surface' && contains(owners[i], owners[k]));\n const isPill = (i) => blocks[i].kind === 'surface' && innerTexts(i).length <= 1 && !owners.some((el, k) => k !== i && blocks[k].kind === 'surface' && contains(owners[i], el));\n const itemOf = (el, other) => { let e = el; while (e.parentElement && e.parentElement !== root && !e.parentElement.contains(other)) e = e.parentElement; return e; };\n for (let i = 0; i < blocks.length; i += 1) {\n if (blocks[i].kind === 'surface' && !isPill(i)) continue;\n const before = blocks.findIndex((bj, j) => j !== i && bj.within === blocks[i].within && !(bj.kind === 'surface' && !isPill(j)) && !contains(owners[j], owners[i]) && !contains(owners[i], owners[j]) && rects[j].some((r) => sameLine(r, lines[i]) && r.right <= rawLeft[i] + 1));\n if (before < 0) continue;\n // A number or bullet in front of a text on its line is a hanging marker, not a row: the pair is one block with two\n // edges, the marker's and the text's.\n if (blocks[i].kind === 'text' && blocks[before].kind === 'text' && /^[\\p{N}\\p{P}\\p{S}]{1,3}$/u.test(words[before])) {\n blocks[i] = Object.assign({}, blocks[i], { edge: blocks[before].edge, left: Math.min(blocks[i].left, blocks[before].left), textEdge: blocks[i].edge });\n delete blocks[i].role;\n dropped.add(before);\n continue;\n }\n const item = itemOf(owners[i], owners[before]);\n const inside = owners.map((el, k) => k).filter((k) => contains(item, owners[k]) && blocks[k].kind !== 'surface');\n const boxes = owners.map((el, k) => k).filter((k) => contains(item, owners[k]) && blocks[k].kind === 'surface' && k !== i);\n if (blocks[i].kind === 'surface') { if (boxes.length === 0) { dropped.add(i); for (const k of innerTexts(i)) dropped.add(k); } continue; }\n if (inside.length === 1 && boxes.length === 0) dropped.add(i);\n }\n const kept = blocks.filter((_, i) => !dropped.has(i));\n // Placeholders: a frame with no text in ink shows nothing to evaluate, whatever controls or boxes it draws.\n return { blocks: kept, placeholdersOnly: texts === 0, skipped: { rowItems: dropped.size, ornaments } };\n})()`;\n\nconst KINDS: readonly EdgeBlock['kind'][] = ['text', 'controls', 'surface'];\nconst ROLES: readonly NonNullable<EdgeBlock['role']>[] = ['list-item', 'table', 'centred', 'placeholder'];\nconst isKind = (v: unknown): v is EdgeBlock['kind'] => KINDS.some((k) => k === v);\nconst isRole = (v: unknown): v is NonNullable<EdgeBlock['role']> => ROLES.some((r) => r === v);\nconst num = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);\nconst field = (o: object, key: string): unknown => Reflect.get(o, key);\n\n/**\n * The probe's typed read: `null` when the page had no `#root` or returned something else, so a failed measurement is\n * reported as unmeasured and never read as \"no offsets\". A malformed block fails the whole read for the same reason.\n */\nexport function parseEdgeProbe(value: unknown): EdgeProbe | null {\n if (typeof value !== 'object' || value === null) return null;\n const raw = field(value, 'blocks');\n const placeholdersOnly = field(value, 'placeholdersOnly');\n if (!Array.isArray(raw) || typeof placeholdersOnly !== 'boolean') return null;\n const skippedRaw = field(value, 'skipped');\n if (typeof skippedRaw !== 'object' || skippedRaw === null) return null;\n const rowItems = field(skippedRaw, 'rowItems');\n const ornaments = field(skippedRaw, 'ornaments');\n if (!num(rowItems) || !num(ornaments)) return null;\n const blocks: EdgeBlock[] = [];\n for (const entry of raw) {\n if (typeof entry !== 'object' || entry === null) return null;\n const [id, kind, edge, left, right, top] = ['id', 'kind', 'edge', 'left', 'right', 'top'].map((k) => field(entry, k));\n const [within, textEdge, role] = ['within', 'textEdge', 'role'].map((k) => field(entry, k));\n if (typeof id !== 'string' || !isKind(kind) || !num(edge) || !num(left) || !num(right) || !num(top)) return null;\n if (within !== undefined && typeof within !== 'string') return null;\n if (textEdge !== undefined && !num(textEdge)) return null;\n if (role !== undefined && !isRole(role)) return null;\n blocks.push({\n id,\n kind,\n edge,\n left,\n right,\n top,\n ...(within !== undefined ? { within } : {}),\n ...(textEdge !== undefined ? { textEdge } : {}),\n ...(role !== undefined ? { role } : {}),\n });\n }\n return { blocks, placeholdersOnly, skipped: { rowItems, ornaments } };\n}\n","/**\n * `space.edge.v2`'s measurement (#1765): `edge-probe.ts` (v1, frozen at `cec465319`) with what the v2 rule\n * (`edge-v2.ts`) reads added, and nothing v1 measures changed. It runs where the screenshot is taken, on the same DOM at\n * the same width, and only reads layout.\n *\n * Added to every block: `bottom`. Added to surfaces: their content box (`contentLeft` / `contentRight`, inside border\n * and padding). Added to controls: `textEdge`, the first control's first character, so a control is compared by its\n * content (rule 5). Added blocks: `media`, a painted image, video or icon that is not a text's marker and sits in no\n * text, control or table, so a row led by an icon alone has a leader. Added to blocks in rows: `follows` and `item`, when\n * the block sits in an item of a horizontal flex or grid row that is not the row's leading item on its line (rule 2).\n * Added to the read: the card's own content box. Everything else is v1's, word for word.\n */\nimport type { CardContentBox, EdgeBlockV2 } from './edge-v2.js';\n\n/** What the probe returns: the measured blocks, and whether the frame showed nothing to evaluate. */\nexport interface EdgeProbeV2 {\n readonly blocks: readonly EdgeBlockV2[];\n readonly cardContent: CardContentBox;\n readonly placeholdersOnly: boolean;\n /** What the probe saw and did not measure, by rule, so a dropped block is counted rather than silent. */\n readonly skipped: { readonly rowItems: number; readonly ornaments: number };\n}\n\n// Plain ES2020 for the page: no imports, no template literals, no helpers a bundler might rename.\nexport const EDGE_BLOCKS_V2_EXPRESSION = String.raw`(() => {\n const root = document.getElementById('root');\n if (!root) return null;\n const rootBox = root.getBoundingClientRect();\n const x0 = rootBox.left;\n const px = (v) => Math.round((v - x0) * 2) / 2;\n const CONTROL = 'button,input,select,textarea,[role=\"button\"],[role=\"tab\"],[role=\"switch\"],[role=\"checkbox\"],[role=\"radio\"],[role=\"option\"],[role=\"link\"],a[href]';\n const ALNUM = /[\\p{L}\\p{N}]/u;\n const css = (el) => getComputedStyle(el);\n const clear = (c) => !c || c === 'transparent' || /rgba\\([^)]*,\\s*0(\\.0+)?\\)$/.test(c);\n // Visible through every ancestor (an ancestor at opacity 0 or visibility hidden hides it), and not degenerate.\n const shown = (el) => {\n const s = css(el);\n if (s.display === 'none' || s.visibility === 'hidden' || Number(s.opacity) === 0) return false;\n if (typeof el.checkVisibility === 'function' && !el.checkVisibility({ opacityProperty: true, visibilityProperty: true })) return false;\n const r = el.getBoundingClientRect();\n return r.width > 1 && r.height > 1;\n };\n const inline = (s) => /^inline/.test(s.display) && s.display !== 'inline-block' && s.display !== 'inline-flex' && s.display !== 'inline-grid';\n const groundOf = (el) => {\n for (let p = el.parentElement; p; p = p.parentElement) { const b = css(p).backgroundColor; if (!clear(b)) return b; }\n return 'rgb(255, 255, 255)';\n };\n const sides = (s) => ['Top', 'Right', 'Bottom', 'Left'].filter((k) => parseFloat(s['border' + k + 'Width']) > 0 && s['border' + k + 'Style'] !== 'none' && !clear(s['border' + k + 'Color'])).length;\n const bounded = (el) => { const s = css(el); return sides(s) >= 1 || (!clear(s.backgroundColor) && s.backgroundColor !== groundOf(el)); };\n // A control: a native or ARIA one, or a bounded box the visitor clicks (a pointer cursor or a tab stop) that holds no\n // control of its own and is not the whole card. Its contents are not blocks of the column (decided 2026-10-02).\n const isControl = (el) => {\n const s = css(el);\n if (inline(s)) return false;\n if (el.matches(CONTROL)) return true;\n if (el === root) return false;\n const clickable = s.cursor === 'pointer' || (el.hasAttribute('tabindex') && el.tabIndex >= 0);\n if (!clickable || !bounded(el) || el.querySelector(CONTROL)) return false;\n const r = el.getBoundingClientRect();\n return r.width * r.height < 0.6 * rootBox.width * rootBox.height;\n };\n const isTable = (el) => el.matches('table,[role=\"table\"],[role=\"grid\"]');\n const isSurface = (el) => {\n if (el === root || isControl(el)) return false;\n const s = css(el);\n if (/^inline/.test(s.display) || s.display === 'contents') return false;\n if (isTable(el)) return true;\n // v2 (the design lead, #1765): what paints owns its edge — any border side (a single rule counts), a fill, a shadow.\n return sides(s) >= 1 || (!clear(s.backgroundColor) && s.backgroundColor !== groundOf(el)) || (s.boxShadow && s.boxShadow !== 'none');\n };\n const path = (el) => {\n const parts = [];\n // v2: the whole path from the root, so nested boxes with the same tail and text never share an id (v1 kept four\n // steps, and three nested surfaces of one card read as one container).\n for (let e = el; e && e !== root; e = e.parentElement) {\n const i = e.parentElement ? Array.prototype.indexOf.call(e.parentElement.children, e) + 1 : 1;\n parts.unshift(e.tagName.toLowerCase() + ':' + i);\n }\n return parts.join('>');\n };\n const label = (el) => { const t = (el.innerText || '').replace(/\\s+/g, ' ').trim(); return path(el) + (t ? ' \"' + t.slice(0, 24) + '\"' : ''); };\n const surfaces = [];\n const surfaceOf = (el, self) => { for (let p = self ? el : el.parentElement; p && p !== root; p = p.parentElement) if (surfaces.indexOf(p) >= 0) return p; return null; };\n const inTable = (el) => { for (let p = el.parentElement; p && p !== root; p = p.parentElement) if (isTable(p)) return true; return false; };\n const inControl = (el) => { for (let p = el; p && p !== root; p = p.parentElement) if (isControl(p)) return p; return null; };\n const all = Array.prototype.slice.call(root.querySelectorAll('*')).filter(shown);\n for (const el of all) if (isSurface(el) && !inTable(el) && !inControl(el)) surfaces.push(el);\n const ids = new Map();\n const idOf = (el) => { if (!ids.has(el)) ids.set(el, label(el)); return ids.get(el); };\n const blocks = [];\n // Per block: the element it stands for and its first line's box, for rows.\n const owners = [];\n const lines = [];\n // Per block: its raw line boxes and left, so a row reads the line two items share, not a wrapped item's widest line.\n const rects = [];\n const rawLeft = [];\n const words = [];\n const within = (el, self) => { const s = surfaceOf(el, self); return s ? { within: idOf(s) } : {}; };\n for (const s of surfaces) {\n const r = s.getBoundingClientRect();\n owners.push(s); lines.push({ top: r.top, bottom: r.bottom }); rects.push([r]); rawLeft.push(r.left); words.push('');\n // A placeholder: a box with no text, no control and no image or icon inside it (a loading bar). Not a block.\n const holds = Array.prototype.some.call(s.querySelectorAll('*'), (el) => shown(el) && (el.matches(CONTROL) || el.tagName === 'IMG' || el.tagName.toLowerCase() === 'svg')) || ALNUM.test(s.innerText || '');\n const ss = css(s);\n const cl = r.left + parseFloat(ss.borderLeftWidth) + parseFloat(ss.paddingLeft);\n const cr = r.right - parseFloat(ss.borderRightWidth) - parseFloat(ss.paddingRight);\n blocks.push(Object.assign({ id: idOf(s), kind: 'surface', edge: px(r.left), left: px(r.left), right: px(r.right), top: Math.round(r.top), bottom: Math.round(r.bottom), contentLeft: px(cl), contentRight: px(cr) }, within(s, false), isTable(s) ? { role: 'table' } : holds ? {} : { role: 'placeholder' }));\n }\n const blockOf = (node) => { for (let p = node.parentElement; p && p !== root; p = p.parentElement) if (!inline(css(p))) return p; return root; };\n const groups = new Map();\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n for (let n = walker.nextNode(); n; n = walker.nextNode()) {\n if (!/\\S/.test(n.data) || !n.parentElement || n.parentElement.closest('style,script,noscript,template') || !shown(n.parentElement) || inControl(n.parentElement) || inTable(n.parentElement)) continue;\n const b = blockOf(n);\n if (!groups.has(b)) groups.set(b, []);\n groups.get(b).push(n);\n }\n // Ink: text whose own colour is not transparent. The edge is the first visible character in ink (decided 2026-10-02):\n // leading invisible text, private-use icon-font glyphs and formatting characters are not characters of the block,\n // while a currency sign or a quotation mark is.\n const inked = (n) => !clear(css(n.parentElement).color) && ALNUM.test(n.data);\n const textRects = (nodes) => {\n const rs = [];\n for (const n of nodes) { if (!inked(n)) continue; const range = document.createRange(); range.selectNodeContents(n); for (const r of range.getClientRects()) if (r.width > 0 && r.height > 0) rs.push(r); }\n return rs;\n };\n const glyphAt = (n, i) => { const range = document.createRange(); range.setStart(n, i); range.setEnd(n, i + 1); const r = range.getClientRects()[0]; return r || null; };\n const firstGlyph = (nodes) => {\n for (const n of nodes) { if (!inked(n)) continue; const i = n.data.search(/[^\\s\\p{Co}\\p{Cf}]/u); if (i < 0) continue; const r = glyphAt(n, i); if (r) return r; }\n return null;\n };\n // A marker paints: a loaded image, an SVG with a filled or stroked shape, or an element with its own fill, border\n // or visible text. An element that paints nothing is not a marker.\n const painted = (m) => {\n if (!shown(m)) return false;\n if (m.tagName === 'IMG') return m.complete && m.naturalWidth > 0;\n if (m.tagName.toLowerCase() === 'svg' || m.closest('svg')) {\n const shapes = m.querySelectorAll('path,circle,rect,line,polyline,polygon,ellipse,use,text');\n return Array.prototype.some.call(shapes, (sh) => { const st = css(sh); return (st.fill !== 'none' && !clear(st.fill)) || (st.stroke !== 'none' && !clear(st.stroke)); });\n }\n const s = css(m);\n if (!clear(s.backgroundColor) || sides(s) >= 1 || ((m.textContent || '').trim().length > 0 && !clear(s.color))) return true;\n // A wrapper that paints nothing itself is a marker when an image or icon inside it paints.\n return Array.prototype.some.call(m.querySelectorAll('svg,img'), (k) => painted(k));\n };\n const markerEls = [];\n const markerBefore = (b, textLeft, lineTop, lineBottom) => {\n const cands = [];\n const consider = (m) => { if (!painted(m)) return; const r = m.getBoundingClientRect(); if (r.left < textLeft - 2 && r.bottom > lineTop && r.top < lineBottom) { cands.push(r.left); markerEls.push(m); } };\n for (const m of b.querySelectorAll('svg,img,[aria-hidden=\"true\"],i')) if ((m.textContent || '').trim().length <= 2) consider(m);\n const p = b.parentElement;\n if (p && p !== root && /flex/.test(css(p).display) && !/column/.test(css(p).flexDirection)) for (const sib of p.children) { if (sib === b) break; if (sib.matches('svg,img,i,[aria-hidden=\"true\"]') || !(sib.textContent || '').trim()) consider(sib); }\n return cands.length ? Math.min.apply(null, cands) : null;\n };\n let texts = 0;\n let ornaments = 0;\n for (const [b, nodes] of groups) {\n if (!nodes.some((n) => ALNUM.test(n.data))) { ornaments += 1; continue; }\n const rs = textRects(nodes);\n const g = firstGlyph(nodes);\n if (!rs.length || g === null) continue;\n texts += 1;\n const first = g.left;\n const left = Math.min.apply(null, rs.map((r) => r.left));\n const right = Math.max.apply(null, rs.map((r) => r.right));\n const top = Math.min.apply(null, rs.map((r) => r.top));\n const marker = markerBefore(b, first, g.top, g.bottom);\n const s = css(b);\n const box = b.getBoundingClientRect();\n const parent = b.parentElement ? css(b.parentElement) : null;\n const centredText = s.textAlign === 'center' && right - left < box.width * 0.9;\n const centredBox = parent && /flex/.test(parent.display) && /column/.test(parent.flexDirection) && parent.alignItems === 'center';\n const list = b.matches('li') || s.display === 'list-item' ? b.closest('ul,ol') : null;\n const inProse = list && list.previousElementSibling && list.previousElementSibling.matches('p');\n const bottom = Math.max.apply(null, rs.map((r) => r.bottom));\n const block = { id: idOf(b), kind: 'text', edge: px(marker !== null ? marker : first), left: px(Math.min(left, marker !== null ? marker : left)), right: px(right), top: Math.round(top), bottom: Math.round(bottom) };\n if (marker !== null) block.textEdge = px(first);\n if (centredText || centredBox) block.role = 'centred';\n else if (inProse) block.role = 'list-item';\n owners.push(b); lines.push({ top: g.top, bottom: g.bottom }); rects.push(rs); rawLeft.push(Math.min(left, marker !== null ? marker : left)); words.push(nodes.map((n) => n.data).join('').trim());\n blocks.push(Object.assign(block, within(b, true)));\n }\n const ctlGroups = new Map();\n for (const el of all) { if (!isControl(el) || inTable(el) || (el.parentElement && inControl(el.parentElement))) continue; const p = el.parentElement || root; if (!ctlGroups.has(p)) ctlGroups.set(p, []); ctlGroups.get(p).push(el); }\n let controls = 0;\n for (const [p, els] of ctlGroups) {\n const rs = els.map((e) => e.getBoundingClientRect());\n const topRow = Math.min.apply(null, rs.map((r) => r.top));\n let firstEl = null; let firstR = null;\n els.forEach((e, i) => { const r = rs[i]; if (r.top - topRow < r.height / 2 && (!firstR || r.left < firstR.left)) { firstEl = e; firstR = r; } });\n let edge = firstR.left;\n const tw = document.createTreeWalker(firstEl, NodeFilter.SHOW_TEXT); const ns = []; for (let n = tw.nextNode(); n; n = tw.nextNode()) ns.push(n);\n const cg = firstGlyph(ns);\n if (!bounded(firstEl) && cg) edge = cg.left;\n // v2: a control's edge is its first painted content — its first character or a painted icon inside its box,\n // whichever is leftmost; an icon drawn over a native field counts. A field with neither reads its padding edge.\n const fs = css(firstEl);\n const fieldEdge = firstEl.matches('input,select,textarea') ? firstR.left + parseFloat(fs.borderLeftWidth) + parseFloat(fs.paddingLeft) : null;\n const iconLefts = all.filter((k) => k.matches('svg,img,i,[aria-hidden=\"true\"]') && !(k.parentElement && k.parentElement.closest('svg')) && painted(k)).map((k) => k.getBoundingClientRect()).filter((r) => r.left >= firstR.left - 1 && r.right <= firstR.right + 1 && r.top >= firstR.top - 1 && r.bottom <= firstR.bottom + 1).map((r) => r.left);\n const iconLeft = iconLefts.length ? Math.min.apply(null, iconLefts) : null;\n controls += 1;\n const ps = css(p);\n const centred = ps.justifyContent === 'center' || (ps.textAlign === 'center' && !/flex|grid/.test(ps.display));\n const block = { id: idOf(p) + ' [controls]', kind: 'controls', edge: px(edge), left: px(Math.min.apply(null, rs.map((r) => r.left))), right: px(Math.max.apply(null, rs.map((r) => r.right))), top: Math.round(topRow), bottom: Math.round(Math.max.apply(null, rs.map((r) => r.bottom))) };\n const firstPaint = [cg ? cg.left : null, iconLeft].filter((v) => v !== null);\n if (firstPaint.length) block.textEdge = px(Math.min.apply(null, firstPaint));\n else if (fieldEdge !== null) block.textEdge = px(fieldEdge);\n if (centred) block.role = 'centred';\n owners.push(firstEl); lines.push({ top: firstR.top, bottom: firstR.bottom }); rects.push(rs); rawLeft.push(Math.min.apply(null, rs.map((r) => r.left))); words.push('');\n blocks.push(Object.assign(block, within(firstEl, true)));\n }\n // v2: media — a painted image, video or icon that is not a text's marker and sits in no text, control or table.\n const textOwners = Array.from(groups.keys());\n for (const el of all) {\n if (!el.matches('img,video,picture,svg') || (el.parentElement && el.parentElement.closest('svg')) || !painted(el) || inControl(el) || inTable(el)) continue;\n if (markerEls.some((m) => m === el || m.contains(el))) continue;\n if (textOwners.some((t) => t.contains(el))) continue;\n const r = el.getBoundingClientRect();\n // An icon drawn inside a control's box (a search field's glass) is the control's adornment, not a block.\n if (all.some((k) => isControl(k) && (() => { const kr = k.getBoundingClientRect(); return r.left >= kr.left - 1 && r.right <= kr.right + 1 && r.top >= kr.top - 1 && r.bottom <= kr.bottom + 1; })())) continue;\n owners.push(el); lines.push({ top: r.top, bottom: r.bottom }); rects.push([r]); rawLeft.push(r.left); words.push('');\n blocks.push(Object.assign({ id: idOf(el) + ' [media]', kind: 'media', edge: px(r.left), left: px(r.left), right: px(r.right), top: Math.round(r.top), bottom: Math.round(r.bottom) }, within(el, false)));\n }\n // v2 rule 2, trailing: the right content edge of the box a block sits in (its nearest wider, non-inline ancestor\n // inside its container), where a right-anchored item ends.\n for (let i = 0; i < blocks.length; i += 1) {\n const el = owners[i];\n const w = el.getBoundingClientRect().width;\n for (let p = el.parentElement; p && p !== root.parentElement; p = p.parentElement) {\n const ps = css(p);\n if (inline(ps) || ps.display === 'contents') continue;\n const pr = p.getBoundingClientRect();\n if (pr.width <= w + 2) continue;\n blocks[i].parentRight = px(pr.right - parseFloat(ps.borderRightWidth) - parseFloat(ps.paddingRight));\n break;\n }\n }\n // v2 rule 2: a block in a row item that is not the row's leading item on its line follows that leader. A row is a\n // horizontal flex or grid box; the leading item is the leftmost of the shown children that share the item's line.\n const isRowBox = (el) => { const s = css(el); return (/flex/.test(s.display) && !/column/.test(s.flexDirection)) || /grid/.test(s.display); };\n const vOverlap = (a, b) => Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top) > 1;\n for (let i = 0; i < blocks.length; i += 1) {\n const el = owners[i];\n const c = (blocks[i].kind === 'surface' ? surfaceOf(el, false) : surfaceOf(el, true)) || root;\n for (let e = el; e && e !== c && e !== root; e = e.parentElement) {\n const p = e.parentElement;\n if (!p) break;\n if (isRowBox(p)) {\n const er = e.getBoundingClientRect();\n const line = Array.prototype.filter.call(p.children, (k) => shown(k) && vOverlap(k.getBoundingClientRect(), er));\n if (line.length >= 2) {\n const lead = line.reduce((a, k) => (k.getBoundingClientRect().left < a.getBoundingClientRect().left ? k : a));\n // A leader that paints nothing (an empty icon slot) leads nothing: the item after it stands alone on its line.\n const leads = painted(lead) || ALNUM.test(lead.innerText || '');\n if (lead !== e && leads) { blocks[i].follows = label(lead); blocks[i].item = label(e); break; }\n }\n }\n if (p === c) break;\n }\n }\n // Rows (decided 2026-10-01, read by geometry 2026-10-02): items set on one line, however the CSS sets them. An item\n // after another measured item on its line that holds one block (a text, a control, or a box holding at most one\n // text) belongs to the row and is not measured; an item with a stack inside it is a column.\n const dropped = new Set();\n const sameLine = (a, b) => Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top) > Math.min(a.bottom - a.top, b.bottom - b.top) / 2;\n const contains = (o, el) => o === el || o.contains(el);\n const innerTexts = (i) => owners.map((el, k) => k).filter((k) => k !== i && blocks[k].kind !== 'surface' && contains(owners[i], owners[k]));\n const isPill = (i) => blocks[i].kind === 'surface' && innerTexts(i).length <= 1 && !owners.some((el, k) => k !== i && blocks[k].kind === 'surface' && contains(owners[i], el));\n const itemOf = (el, other) => { let e = el; while (e.parentElement && e.parentElement !== root && !e.parentElement.contains(other)) e = e.parentElement; return e; };\n for (let i = 0; i < blocks.length; i += 1) {\n if (blocks[i].kind === 'surface' && !isPill(i)) continue;\n const before = blocks.findIndex((bj, j) => j !== i && bj.within === blocks[i].within && !(bj.kind === 'surface' && !isPill(j)) && !contains(owners[j], owners[i]) && !contains(owners[i], owners[j]) && rects[j].some((r) => sameLine(r, lines[i]) && r.right <= rawLeft[i] + 1));\n if (before < 0) continue;\n // A number or bullet in front of a text on its line is a hanging marker, not a row: the pair is one block with two\n // edges, the marker's and the text's.\n if (blocks[i].kind === 'text' && blocks[before].kind === 'text' && /^[\\p{N}\\p{P}\\p{S}]{1,3}$/u.test(words[before])) {\n blocks[i] = Object.assign({}, blocks[i], { edge: blocks[before].edge, left: Math.min(blocks[i].left, blocks[before].left), textEdge: blocks[i].edge });\n delete blocks[i].role;\n // v2: the merged block's edge is its marker's, which leads the row, so it stands in its container's column.\n delete blocks[i].follows;\n delete blocks[i].item;\n dropped.add(before);\n continue;\n }\n const item = itemOf(owners[i], owners[before]);\n const inside = owners.map((el, k) => k).filter((k) => contains(item, owners[k]) && blocks[k].kind !== 'surface');\n const boxes = owners.map((el, k) => k).filter((k) => contains(item, owners[k]) && blocks[k].kind === 'surface' && k !== i);\n if (blocks[i].kind === 'surface') { if (boxes.length === 0) { dropped.add(i); for (const k of innerTexts(i)) dropped.add(k); } continue; }\n if (inside.length === 1 && boxes.length === 0) dropped.add(i);\n }\n const kept = blocks.filter((_, i) => !dropped.has(i));\n // Placeholders: a frame with no text in ink shows nothing to evaluate, whatever controls or boxes it draws.\n const rs0 = css(root);\n const cardContent = { left: px(rootBox.left + parseFloat(rs0.borderLeftWidth) + parseFloat(rs0.paddingLeft)), right: px(rootBox.right - parseFloat(rs0.borderRightWidth) - parseFloat(rs0.paddingRight)) };\n return { blocks: kept, cardContent, placeholdersOnly: texts === 0, skipped: { rowItems: dropped.size, ornaments } };\n})()`;\n\nconst KINDS: readonly EdgeBlockV2['kind'][] = ['text', 'controls', 'surface', 'media'];\nconst ROLES: readonly NonNullable<EdgeBlockV2['role']>[] = ['list-item', 'table', 'centred', 'placeholder'];\nconst isKind = (v: unknown): v is EdgeBlockV2['kind'] => KINDS.some((k) => k === v);\nconst isRole = (v: unknown): v is NonNullable<EdgeBlockV2['role']> => ROLES.some((r) => r === v);\nconst num = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);\nconst field = (o: object, key: string): unknown => Reflect.get(o, key);\nconst optNum = (v: unknown): boolean => v === undefined || num(v);\nconst optStr = (v: unknown): boolean => v === undefined || typeof v === 'string';\n\n/**\n * The v2 probe's typed read: `null` when the page had no `#root` or returned something else, so a failed measurement\n * is reported as unmeasured and never read as \"no offsets\". A malformed block fails the whole read for the same reason.\n */\nexport function parseEdgeProbeV2(value: unknown): EdgeProbeV2 | null {\n if (typeof value !== 'object' || value === null) return null;\n const raw = field(value, 'blocks');\n const placeholdersOnly = field(value, 'placeholdersOnly');\n const cc = field(value, 'cardContent');\n if (!Array.isArray(raw) || typeof placeholdersOnly !== 'boolean' || typeof cc !== 'object' || cc === null) return null;\n const ccLeft = field(cc, 'left');\n const ccRight = field(cc, 'right');\n if (!num(ccLeft) || !num(ccRight)) return null;\n const skippedRaw = field(value, 'skipped');\n if (typeof skippedRaw !== 'object' || skippedRaw === null) return null;\n const rowItems = field(skippedRaw, 'rowItems');\n const ornaments = field(skippedRaw, 'ornaments');\n if (!num(rowItems) || !num(ornaments)) return null;\n const blocks: EdgeBlockV2[] = [];\n for (const entry of raw) {\n if (typeof entry !== 'object' || entry === null) return null;\n const [id, kind, edge, left, right, top, bottom] = ['id', 'kind', 'edge', 'left', 'right', 'top', 'bottom'].map((k) => field(entry, k));\n const [within, textEdge, role, contentLeft, contentRight, follows, item, parentRight] = ['within', 'textEdge', 'role', 'contentLeft', 'contentRight', 'follows', 'item', 'parentRight'].map((k) => field(entry, k));\n if (typeof id !== 'string' || !isKind(kind) || !num(edge) || !num(left) || !num(right) || !num(top) || !num(bottom)) return null;\n if (!optStr(within) || !optNum(textEdge) || !optNum(contentLeft) || !optNum(contentRight) || !optStr(follows) || !optStr(item) || !optNum(parentRight)) return null;\n if (role !== undefined && !isRole(role)) return null;\n blocks.push({\n id,\n kind,\n edge,\n left,\n right,\n top,\n bottom,\n ...(typeof within === 'string' ? { within } : {}),\n ...(num(textEdge) ? { textEdge } : {}),\n ...(role !== undefined ? { role } : {}),\n ...(num(contentLeft) ? { contentLeft } : {}),\n ...(num(contentRight) ? { contentRight } : {}),\n ...(typeof follows === 'string' ? { follows } : {}),\n ...(typeof item === 'string' ? { item } : {}),\n ...(num(parentRight) ? { parentRight } : {}),\n });\n }\n return { blocks, cardContent: { left: ccLeft, right: ccRight }, placeholdersOnly, skipped: { rowItems, ornaments } };\n}\n","/**\n * #1765 — the identity of each edge instrument on a capture: its row id and the sha256 of the page expression it ran,\n * so every reading names exactly which probe produced it (v1 is frozen at `cec465319`; v2 is a separate instrument).\n */\nimport { createHash } from 'node:crypto';\nimport { EDGE_BLOCKS_EXPRESSION } from './edge-probe.js';\nimport { EDGE_BLOCKS_V2_EXPRESSION } from './edge-probe-v2.js';\n\nconst digest = (expression: string): string => createHash('sha256').update(expression).digest('hex').slice(0, 12);\n\nexport const EDGE_INSTRUMENT_IDS = {\n v1: `space.edge@${digest(EDGE_BLOCKS_EXPRESSION)}`,\n v2: `space.edge.v2@${digest(EDGE_BLOCKS_V2_EXPRESSION)}`,\n} as const;\n","/**\n * From K judge answers and the capture's measurements to one `CriteriaBlock` — ggui#1436.\n *\n * The judge is asked every `evaluation: judge` row (this block IS their implementation; the row's\n * `status` is carried on the verdict as the author wrote it). An `instrument` row is answered by a\n * measurement the capture already ran when its status is `live` and a binding exists; otherwise it\n * reads `n/a` with the reason from `status`. A `human` row reads `n/a` for the judge. K-majority per\n * id; a tie or an unanswered id reads `n/a` (the CTO's A2) — a `must` at `n/a` is never a pass when\n * a gate later reads the set.\n */\nimport { EDGE_INSTRUMENT_IDS } from './edge-instruments.js';\nimport type { MountFit } from '@ggui-ai/design/rendering';\nimport type { CriteriaAnswer } from '../types.js';\nimport type { CriteriaAnswerCounts, CriteriaBlock, CriteriaContext, CriteriaVerdict, CriterionVerdict } from '../types-public.js';\nimport type { VisionFinishReason } from '../../harness/llm-router.js';\nimport { bankRows, type BankRow, type CriteriaBank } from './bank.js';\nimport { CRITERIA_SELECTOR_VERSION, type CriteriaSelectionResult } from './select.js';\nimport type { EdgeVerdict } from './edge.js';\n\n/** The instruments the capture runs today, by the bank ids they answer (v1 binding; a bank field may replace it). */\nexport const INSTRUMENT_BY_ID: Readonly<Record<string, 'fit' | 'fill'>> = {\n 'comp.fit': 'fit',\n 'floor.fit': 'fit',\n 'finish.canvas.inhabited': 'fill',\n};\n\n/**\n * ggui#1663 — instruments that read BESIDE a judge row, report-only: the row keeps the judge's verdict and gains the\n * measurement as `instrument`, so the two can be compared before any verdict moves.\n */\nexport const INSTRUMENT_BESIDE_JUDGE: Readonly<Record<string, 'edge'>> = {\n 'space.edge': 'edge',\n};\n\n/**\n * ggui#1711 — judge rows a single pre-action frame cannot answer. Their own text makes them not-evaluated \"when the\n * capture has no post-action state\", and every judged frame today is one capture taken before any action. Asked\n * anyway, the judge answered `n/a` 94 of 94 times and left the row out 15 more times (a dropped row reads like a\n * skip). So the absence is decided here, from the capture: such a row is never asked without a post-action capture,\n * and it reads `n/a` with its reason, still in the tally. With one, the judge is asked as for any row.\n */\nexport const REQUIRES_POST_ACTION_CAPTURE: ReadonlySet<string> = new Set(['state.feedback']);\nconst NO_POST_ACTION = 'not evaluated: no post-action capture';\n\nexport interface CriteriaMeasurements {\n readonly overflow: boolean;\n readonly contentHeight: number | null;\n readonly viewportHeight: number;\n readonly inkRatio: number | null;\n /**\n * ggui#1663 — the edge rule on the capture's DOM: absent when this capture had no page to read (a stored frame),\n * `null` when the probe ran and failed.\n */\n readonly edge?: EdgeVerdict | null;\n /** #1765 — the v2 edge rule on the same capture, read beside v1: absent / `null` as for `edge`. */\n readonly edgeV2?: EdgeVerdict | null;\n /** ggui#1711 — the capture includes a state after an action ran. Absent = no (every capture today). */\n readonly postActionCapture?: boolean;\n}\n\nfunction besideRead(kind: 'edge', m: CriteriaMeasurements): Read {\n return edgeRead(m.edge);\n}\n\nfunction edgeRead(e: EdgeVerdict | null | undefined): Read {\n if (e === undefined) return { verdict: 'n/a', evidence: 'not measured: this capture had no page to read' };\n if (e === null) return { verdict: 'n/a', evidence: 'edge probe failed on this capture' };\n return { verdict: e.verdict, evidence: e.evidence };\n}\n\ntype Read = { verdict: CriteriaVerdict; evidence: string };\n\nfunction majority(id: string, answers: readonly CriteriaAnswer[][], unansweredReason: string | undefined): Read {\n const votes = answers.flatMap((a) => a.filter((x) => x.id === id));\n if (votes.length === 0) return { verdict: 'n/a', evidence: unansweredReason ?? 'not answered' };\n const counts = new Map<CriteriaVerdict, number>();\n for (const v of votes) counts.set(v.verdict, (counts.get(v.verdict) ?? 0) + 1);\n const ranked = [...counts.entries()].sort((a, b) => b[1] - a[1]);\n const top = ranked[0]!;\n if (ranked.length > 1 && ranked[1]![1] === top[1]) return { verdict: 'n/a', evidence: 'no majority' };\n const evidence = votes.find((v) => v.verdict === top[0])?.evidence ?? '';\n return { verdict: top[0], evidence };\n}\n\nfunction instrumentRead(kind: 'fit' | 'fill', m: CriteriaMeasurements): Read {\n if (kind === 'fit') {\n if (m.contentHeight === null) return { verdict: 'n/a', evidence: 'content height unmeasurable' };\n return { verdict: m.overflow ? 'fail' : 'pass', evidence: `content ${m.contentHeight}px against a ${m.viewportHeight}px box` };\n }\n if (m.inkRatio === null) return { verdict: 'n/a', evidence: 'capture unreadable' };\n // Reported, never gated: no fill floor is ruled (hello-finish property 1).\n return { verdict: 'n/a', evidence: `fill ${m.inkRatio.toFixed(3)} reported; no floor ruled` };\n}\n\nfunction readRow(row: BankRow, answers: readonly CriteriaAnswer[][], m: CriteriaMeasurements, unansweredReason: string | undefined): Read {\n if (row.evaluation === 'judge' && REQUIRES_POST_ACTION_CAPTURE.has(row.id) && m.postActionCapture !== true) return { verdict: 'n/a', evidence: NO_POST_ACTION };\n if (row.evaluation === 'judge') return majority(row.id, answers, unansweredReason);\n if (row.evaluation === 'human') return { verdict: 'n/a', evidence: `reader's column (status ${row.status})` };\n if (row.status !== 'live') return { verdict: 'n/a', evidence: `not implemented (status ${row.status})` };\n const kind = INSTRUMENT_BY_ID[row.id];\n return kind === undefined ? { verdict: 'n/a', evidence: 'instrument not wired (status live, no binding)' } : instrumentRead(kind, m);\n}\n\nexport function resolveCriteriaBlock(args: {\n readonly bank: CriteriaBank;\n readonly context: CriteriaContext;\n readonly selected: CriteriaSelectionResult;\n readonly answers: readonly CriteriaAnswer[][];\n readonly measurements: CriteriaMeasurements;\n /**\n * ggui#1127 — why a judge row has no answer, when the caller knows: a salvaged criteria answer keeps no criteria,\n * so its rows say so instead of reading as a clean `n/a`. Absent ⇒ \"not answered\".\n */\n readonly unansweredReason?: string;\n /** ggui#1687 — the call that answered, as it came back: its answer's counts and its stop reason. */\n readonly call?: { readonly answer: CriteriaAnswerCounts; readonly finishReason?: VisionFinishReason };\n}): CriteriaBlock {\n const byId = new Map<string, BankRow>(bankRows(args.bank).map((r) => [r.id, r]));\n const verdicts: CriterionVerdict[] = [];\n for (const s of args.selected.selection) {\n const row = byId.get(s.id);\n if (row === undefined) continue;\n const read = readRow(row, args.answers, args.measurements, args.unansweredReason);\n const beside = INSTRUMENT_BESIDE_JUDGE[row.id];\n verdicts.push({\n id: row.id,\n severity: row.severity,\n method: row.evaluation,\n status: row.status,\n source: s.source,\n verdict: read.verdict,\n evidence: read.evidence,\n ...(beside !== undefined && row.evaluation === 'judge'\n ? {\n instrument: { ...besideRead(beside, args.measurements), id: EDGE_INSTRUMENT_IDS.v1 },\n // #1765 — v2 beside v1 on the same capture, report-only, until its own fresh sealed draw.\n instrumentV2: { ...edgeRead(args.measurements.edgeV2), id: EDGE_INSTRUMENT_IDS.v2 },\n }\n : {}),\n });\n }\n return {\n criteriaSetId: args.selected.criteriaSetId,\n bankVersion: args.bank.version,\n selectorVersion: CRITERIA_SELECTOR_VERSION,\n context: args.context,\n selection: args.selected.selection,\n verdicts,\n ...(args.call !== undefined\n ? {\n call: {\n answer: args.call.answer,\n // Kept answers whose id names no row of the bank: the judge answered something nobody asked.\n unknownIds: args.answers.flat().filter((a) => !byId.has(a.id)).length,\n ...(args.call.finishReason !== undefined ? { finishReason: args.call.finishReason } : {}),\n },\n }\n : {})\n };\n}\n\n/** The judge's prompt block for the selected `judge` rows; empty when none is selected. */\n/** The capture the judge is handed: its canvas class and the box it was taken at (the class box, or a declared one). */\nexport interface CriteriaJudgeFrame {\n readonly canvas: CriteriaContext['canvas'];\n readonly width: number;\n readonly height: number;\n /** ggui#1492 — the host whose presentation framed this canvas (e.g. \"a chat widget, inline, reference theme\"); absent ⇒ the judge's own stand-in. */\n readonly hostLabel?: string;\n /** How the card was composed on this frame (`resolveMountFit`, the one rule the runtime serves by); the sentence follows it. */\n readonly fit: MountFit;\n}\n\n/** What the block carries besides the selected rows: the frame's box, and the props the card was rendered with. */\nexport interface CriteriaJudgeInputs {\n readonly frame?: CriteriaJudgeFrame;\n /** JSON text of the props the card was rendered with; bounded by {@link CRITERIA_PROPS_MAX_CHARS}. */\n readonly propsJson?: string;\n /** ggui#1711 — the capture includes a post-action state; absent = no, and rows needing one are not asked. */\n readonly postActionCapture?: boolean;\n}\n\n/** Bound on the props text handed to the judge beside the frame, in characters. */\nexport const CRITERIA_PROPS_MAX_CHARS = 2000;\n\n/**\n * The frame's box and how the card occupies it, named so the judge reads the capture it was handed and\n * never guesses it: without it, phone rows described a 390×844 frame as a 768×1024 tablet, and the\n * inline card's verdicts flipped between near-identical frames (the evidence audit on ggui#1438).\n * The inline chat card is sized to its content by the host (the box grows and shrinks with the card; a\n * `maxHeight` caps and scrolls), so the judge captures it at its natural height on the host's ground\n * (ggui#1475) and composition is judged within the card's extent; every other canvas is a fixed box the\n * card fills.\n */\nexport function criteriaFrameLine(frame: CriteriaJudgeFrame): string {\n const box = `${frame.width}×${frame.height}`;\n if (frame.fit === 'framed-card') {\n return `This frame is ${box}${frame.hostLabel !== undefined ? ` (${frame.hostLabel})` : ''} with the card at its natural height at the top, inside the card's own frame — its surface, a thin ring of its ink and rounded corners — on the host's ground: the card is sized to its content, so judge composition and space within the card's own extent, and read the ground round it as the host's, not the card's.`;\n }\n if (frame.fit === 'card') {\n const framedBy =\n frame.hostLabel !== undefined\n ? `inside the host's own frame (${frame.hostLabel}), on the host's ground`\n : \"inside a generic stand-in for the host's frame — the card's surface with a thin ring and rounded corners, on the page ground\";\n return `This frame is an inline chat card captured at its natural height (at most ${box}, the host's ceiling), ${framedBy}: the host sizes the card to its content and draws that frame, so judge composition and space within the card's own extent, and read the frame and the ground round it as the host's, not the card's.`;\n }\n return `This frame is ${box}, a fixed full-screen box the card fills${frame.hostLabel !== undefined ? ` (${frame.hostLabel})` : ''}: judge composition and space against the whole box, edge to edge.`;\n}\n\n/**\n * The one declared input besides the frame. Rows whose evidence names props (whether a rendered string\n * came from content or props, whether the primary action is the one the props and contract name) cannot\n * be answered from pixels alone; every other row stays frame-only.\n */\nfunction criteriaPropsSection(propsJson: string): string {\n const text = propsJson.length > CRITERIA_PROPS_MAX_CHARS ? `${propsJson.slice(0, CRITERIA_PROPS_MAX_CHARS)}… (truncated)` : propsJson;\n return (\n 'The one input besides the frame — the props this card was rendered with. Read them ONLY for rows whose evidence names props ' +\n '(for example, whether a rendered string came from them); every other row is read off the frame alone:\\n' +\n `${text}\\n`\n );\n}\n\n/** The judge's prompt block for the selected `judge` rows; empty when none is selected. */\nexport function buildCriteriaJudgeBlock(bank: CriteriaBank, selected: CriteriaSelectionResult, inputs: CriteriaJudgeInputs = {}): string {\n const byId = new Map<string, BankRow>(bankRows(bank).map((r) => [r.id, r]));\n const asked = selected.selection\n .map((s) => byId.get(s.id))\n .filter((r): r is BankRow => r !== undefined && r.evaluation === 'judge')\n .filter((r) => inputs.postActionCapture === true || !REQUIRES_POST_ACTION_CAPTURE.has(r.id));\n if (asked.length === 0) return '';\n const lines = asked.map((r) => `- ${r.id} (${r.severity}): ${r.text} Evidence must name: ${r.evidence}`);\n return (\n '## Criteria — answer each one from the FRAME only\\n' +\n 'Read these off the screenshot. Never infer them from the request, the styling profile or any direction text above.\\n' +\n (inputs.frame !== undefined ? `${criteriaFrameLine(inputs.frame)}\\n` : '') +\n (inputs.propsJson !== undefined ? criteriaPropsSection(inputs.propsJson) : '') +\n `${lines.join('\\n')}\\n` +\n 'Add to your JSON a top-level \"criteria\" array with exactly these ids: ' +\n '[{ \"id\": \"<id>\", \"verdict\": \"pass\" | \"fail\" | \"n/a\", \"evidence\": \"<one sentence naming the region or element you read it from>\" }]. ' +\n 'Every row here was selected as applicable to this card, so \"n/a\" never means \"does not apply\": ' +\n 'use it ONLY when this frame cannot show the criterion — it is then recorded as not evaluated.'\n );\n}\n","/**\n * The ink extent of a judge screenshot (ggui#1120): how far down the frame anything was painted, read\n * from the pixels the judge already holds. `contentHeight` is the document's scroll height, floored at\n * the viewport by definition — it can see overflow and never under-fill, and never a blank.\n *\n * The reading: the region's DOMINANT colour (its most common pixel) is the ground; a pixel is ink when\n * any channel differs from it by more than {@link INK_TOLERANCE}; `lastInkRow` is the last region row\n * with ink and `ratio` is `(lastInkRow + 1) / region.height`. Dominant, not the corners: an opening\n * hero band makes the top corners content, and a host panel's rounded corners expose the scrim behind\n * it (measured on the ggui#1083 judge frames — corner sampling read a card that fills as 1.0 and a\n * panelled page as all ink).\n *\n * Only the ZERO is judged (`canvas-blank`, the judge's verdict): a region with no ink is one flat\n * colour — the tree mounted and painted nothing, the mount-path class no compile-time check can reach\n * (ggui#1104 / #1119). Every other value is reported, never scored: the corpus does not support a\n * dead-space threshold (#1120).\n *\n * A PNG reader of exactly the judge's own captures — 8-bit RGB / RGBA, non-interlaced, `node:zlib`\n * for the IDAT stream and the five scanline filters by hand — so a published package takes no image\n * dependency. Any other PNG reads as unmeasurable (a reason), never as blank.\n */\nimport { inflateSync } from 'node:zlib';\n\n/** A channel difference at or below this is the same colour (anti-aliasing and compositing noise). */\nexport const INK_TOLERANCE = 8;\n\nexport interface PixelRegion {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\nexport interface InkExtent {\n /** `(lastInkRow + 1) / region.height`, rounded to 3 places; `0` when nothing differs from the ground. */\n readonly ratio: number;\n /** The last region row (0-based from the region's top) carrying ink; `null` when there is none — the blank. */\n readonly lastInkRow: number | null;\n /** The region read, in image px. */\n readonly region: PixelRegion;\n /** The dominant colour the ink was read against, `[r, g, b]`. */\n readonly ground: readonly [number, number, number];\n}\n\n/** Why a capture could not be read — reported, never mistaken for a blank. */\nexport interface InkUnreadable {\n readonly reason: string;\n}\n\nexport interface DecodedImage {\n readonly width: number;\n readonly height: number;\n readonly channels: 3 | 4;\n /** Row-major, `channels` bytes per pixel, scanline filters undone. */\n readonly pixels: Uint8Array;\n}\n\nconst PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a] as const;\n\n/** The PNG subset the judge's browser writes: 8-bit RGB (colour type 2) or RGBA (6), not interlaced. */\nexport function decodePng(png: Uint8Array): DecodedImage | InkUnreadable {\n const buf = Buffer.from(png.buffer, png.byteOffset, png.byteLength);\n if (buf.length < 8 + 25) return { reason: `not a PNG: ${buf.length} bytes` };\n for (let i = 0; i < PNG_SIGNATURE.length; i++) {\n if (buf[i] !== PNG_SIGNATURE[i]) return { reason: 'not a PNG: signature mismatch' };\n }\n let width = 0;\n let height = 0;\n let channels: 3 | 4 | null = null;\n const idat: Buffer[] = [];\n let offset = 8;\n while (offset + 8 <= buf.length) {\n const length = buf.readUInt32BE(offset);\n const type = buf.toString('latin1', offset + 4, offset + 8);\n const start = offset + 8;\n if (start + length + 4 > buf.length) return { reason: `truncated PNG: ${type} chunk runs past the end` };\n const data = buf.subarray(start, start + length);\n if (type === 'IHDR') {\n if (length !== 13) return { reason: `malformed IHDR: ${length} bytes` };\n width = data.readUInt32BE(0);\n height = data.readUInt32BE(4);\n const bitDepth = data[8];\n const colorType = data[9];\n const interlace = data[12];\n if (bitDepth !== 8) return { reason: `unsupported PNG: bit depth ${bitDepth}` };\n if (interlace !== 0) return { reason: 'unsupported PNG: interlaced' };\n if (colorType === 2) channels = 3;\n else if (colorType === 6) channels = 4;\n else return { reason: `unsupported PNG: colour type ${colorType}` };\n } else if (type === 'IDAT') {\n idat.push(data);\n } else if (type === 'IEND') {\n break;\n }\n offset = start + length + 4;\n }\n if (channels === null) return { reason: 'malformed PNG: no IHDR' };\n if (width === 0 || height === 0) return { reason: `empty PNG: ${width}×${height}` };\n if (idat.length === 0) return { reason: 'malformed PNG: no IDAT' };\n let raw: Buffer;\n try {\n raw = inflateSync(Buffer.concat(idat));\n } catch (error) {\n return { reason: `corrupt IDAT stream: ${error instanceof Error ? error.message : String(error)}` };\n }\n const stride = width * channels;\n if (raw.length !== (stride + 1) * height) {\n return { reason: `malformed PNG: ${raw.length} raw bytes for ${width}×${height}×${channels}` };\n }\n const pixels = new Uint8Array(stride * height);\n const bpp = channels;\n for (let y = 0; y < height; y++) {\n const filter = raw[y * (stride + 1)]!;\n const inRow = y * (stride + 1) + 1;\n const outRow = y * stride;\n const prevRow = outRow - stride;\n for (let i = 0; i < stride; i++) {\n const x = raw[inRow + i]!;\n const a = i >= bpp ? pixels[outRow + i - bpp]! : 0;\n const b = y > 0 ? pixels[prevRow + i]! : 0;\n const c = y > 0 && i >= bpp ? pixels[prevRow + i - bpp]! : 0;\n let value: number;\n switch (filter) {\n case 0:\n value = x;\n break;\n case 1:\n value = x + a;\n break;\n case 2:\n value = x + b;\n break;\n case 3:\n value = x + ((a + b) >> 1);\n break;\n case 4: {\n const p = a + b - c;\n const pa = Math.abs(p - a);\n const pb = Math.abs(p - b);\n const pc = Math.abs(p - c);\n value = x + (pa <= pb && pa <= pc ? a : pb <= pc ? b : c);\n break;\n }\n default:\n return { reason: `malformed PNG: scanline filter ${filter} at row ${y}` };\n }\n pixels[outRow + i] = value & 0xff;\n }\n }\n return { width, height, channels, pixels };\n}\n\n/**\n * The ink extent of a capture, read `insetPx` in from every edge — the judge's inset skips a host\n * panel's gap, rounded corners and hairline ({@link JUDGE_INK_INSET_PX}); `0` reads the whole image.\n */\nexport function readInkExtent(png: Uint8Array, insetPx = 0): InkExtent | InkUnreadable {\n const image = decodePng(png);\n if ('reason' in image) return image;\n const region: PixelRegion = { x: insetPx, y: insetPx, width: image.width - 2 * insetPx, height: image.height - 2 * insetPx };\n if (insetPx < 0 || region.width <= 0 || region.height <= 0) {\n return { reason: `an inset of ${insetPx}px leaves nothing of a ${image.width}×${image.height} image` };\n }\n const { channels, pixels, width } = image;\n // The ground: the region's most common colour.\n const counts = new Map<number, number>();\n let ground = 0;\n let groundCount = 0;\n for (let y = region.y; y < region.y + region.height; y++) {\n for (let x = region.x; x < region.x + region.width; x++) {\n const i = (y * width + x) * channels;\n const key = (pixels[i]! << 16) | (pixels[i + 1]! << 8) | pixels[i + 2]!;\n const n = (counts.get(key) ?? 0) + 1;\n counts.set(key, n);\n if (n > groundCount) {\n groundCount = n;\n ground = key;\n }\n }\n }\n const gr = (ground >> 16) & 0xff;\n const gg = (ground >> 8) & 0xff;\n const gb = ground & 0xff;\n let lastInkRow: number | null = null;\n for (let y = region.y; y < region.y + region.height; y++) {\n for (let x = region.x; x < region.x + region.width; x++) {\n const i = (y * width + x) * channels;\n if (\n Math.abs(pixels[i]! - gr) > INK_TOLERANCE ||\n Math.abs(pixels[i + 1]! - gg) > INK_TOLERANCE ||\n Math.abs(pixels[i + 2]! - gb) > INK_TOLERANCE\n ) {\n lastInkRow = y - region.y;\n break;\n }\n }\n }\n const ratio = lastInkRow === null ? 0 : Math.round(((lastInkRow + 1) / region.height) * 1000) / 1000;\n return { ratio, lastInkRow, region, ground: [gr, gg, gb] };\n}\n","// The design tree a judge paints with is an INPUT to the judgement and a\n// part of its identity (ggui#1042, D3): a judge-only re-judge renders every\n// arm with the tree on disk, so the row must say WHICH tree — `srcSha256`\n// over every RENDERING INPUT under the design package's `src`, sorted by\n// relative path — and the local judge path must accept the tree explicitly.\n// A served hello is compared to a judged one only when this hash and the\n// runtime's design agree (`design@judge == design@runtime`, generation-triad.md).\n//\n// Rendering inputs only: tests (`*.test.*`, `__tests__/`), stories\n// (`*.stories.*`) and docs (`*.md`) paint nothing, and a built image ships\n// the design package without them — the first rows on candidate 34 stamped\n// `e2dc89e4…` (123 files) while a checkout of the same git tree computed\n// `2cd62cb7…` (199 files). One identity must read the same on every host\n// that carries the same rendering inputs.\nimport { createHash } from 'node:crypto';\nimport { readFileSync, readdirSync, statSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\n\nexport interface JudgeDesignIdentity {\n /** Absolute path of the design `src` tree the judge bundled against. */\n readonly src: string;\n /** sha256 over every rendering input under `src` (see {@link isDesignRenderingInput}) — sorted relative path, then contents. */\n readonly srcSha256: string;\n}\n\n/**\n * Whether a file under the design `src` tree is something the judge PAINTS\n * with. Tests, stories and docs are not — and a built image carries the\n * package without them, so they must not move the identity.\n */\nexport function isDesignRenderingInput(relativePath: string): boolean {\n const rel = relativePath.split('\\\\').join('/');\n if (rel.startsWith('__tests__/') || rel.includes('/__tests__/')) return false;\n if (/\\.test\\.[cm]?[jt]sx?$/.test(rel)) return false;\n if (/\\.stories\\.[cm]?[jt]sx?$/.test(rel)) return false;\n if (rel.endsWith('.md')) return false;\n return true;\n}\n\n/**\n * sha256 over every rendering input under `root` (sorted relative path +\n * contents) — the identity of a design tree as it paints.\n *\n * A function of the TREE, not of the spelling of `root`: the relative keys\n * are taken against the RESOLVED root, so `…/design/src`, `…/design/src/` and\n * `…/ui-gen/../design/src` hash the same bytes. Before this the key was\n * sliced by the unresolved root's length while each entry had already been\n * resolved, so an un-normalised root produced a different hash for the same\n * tree — a phantom design skew for any caller composing the path.\n */\nexport function designTreeSha256(root: string): string {\n const base = resolve(root);\n const files: string[] = [];\n const walk = (dir: string): void => {\n for (const name of readdirSync(dir).sort()) {\n const full = resolve(dir, name);\n if (statSync(full).isDirectory()) walk(full);\n else if (isDesignRenderingInput(relative(base, full))) files.push(full);\n }\n };\n walk(base);\n const h = createHash('sha256');\n for (const f of files) {\n h.update(relative(base, f) + '\\n');\n h.update(readFileSync(f));\n h.update('\\n');\n }\n return h.digest('hex');\n}\n\nconst identityCache = new Map<string, JudgeDesignIdentity | null>();\n\n/**\n * The identity of the tree at `src`, computed once per process per path (a\n * judge run paints hundreds of frames from one tree).\n *\n * `null` when the tree cannot be READ (ggui#1110): a deployed image ships the\n * design package as built output with no `src/`, and an identity is a receipt\n * about a judgement — never a precondition for making one. Before this,\n * `scandir` threw ENOENT inside the evaluation round wherever the package ships\n * built output only, the round returned no evaluation at all, and a bar refused\n * a card that had cleared it. A row without the receipt says so; a round that cannot\n * stamp one still runs.\n */\nexport function judgeDesignIdentity(src: string): JudgeDesignIdentity | null {\n const key = resolve(src);\n const cached = identityCache.get(key);\n if (cached !== undefined) return cached;\n let identity: JudgeDesignIdentity | null;\n try {\n identity = { src: key, srcSha256: designTreeSha256(key) };\n } catch (e) {\n // Unreadable tree: no source directory (a built package), no permission,\n // a path that is not a directory. The reason is logged ONCE per path —\n // the judgement proceeds unstamped rather than not at all.\n const reason = e instanceof Error ? e.message : String(e);\n console.warn(`[visual-eval] design tree unreadable at ${key} — the judgement carries no design identity (${reason})`);\n identity = null;\n }\n identityCache.set(key, identity);\n return identity;\n}\n\n/** Test seam: forget cached identities (a test that rewrites a tree between runs). */\nexport function resetJudgeDesignIdentityCache(): void {\n identityCache.clear();\n}\n","/**\n * `space.edge` as an instrument (#1663): the alignment rule applied to measured blocks, never to a model's estimate.\n *\n * The rule (docs/design/direction/visual-criteria.md, \"The edge rule, measurable\"): in each column of a card, the things\n * that stack start on one edge. A block may start in only two other places — inside a box, on the box's inner edge,\n * which everything inside the box then shares; or next to a box or a band, on the box's own outer edge or on the edge\n * of the text inside it. Same edge means within 2 px. A card fails if any captured width fails; this function judges one\n * width.\n *\n * Levels that are allowed: a hanging marker (a block with two edges, the marker's and its text's); a list inside\n * running text (list items share an edge of their own); a table (measured at its rule, its cells not re-checked);\n * columns side by side (each with its own edge); a centred group (one centre axis). A frame that shows only loading\n * placeholders is not evaluated.\n *\n * Input is the measured block list (a DOM probe at capture produces it); output is the verdict plus every offset in\n * px, so a near miss reads apart from a split. This module measures nothing itself. *\n * **Validated instrument (#1663, 2026-10-02):** this file as of `cec465319` (with `7bb4da13e`) passed a fresh sealed\n * blind draw at the registered bar (27/30, κ 0.76), stricter than the design lead's reading on its disagreements. Any\n * later change to what this file measures or decides is a new instrument until another fresh sealed draw.\n */\n\n/** The rule's tolerance: two edges within this many px are the same edge. */\nexport const EDGE_TOLERANCE_PX = 2;\n\n/** One block of a captured card, at one canvas width. All x in CSS px from the card's left. */\nexport interface EdgeBlock {\n /** A stable label for evidence (a DOM path in production, a name in tests). */\n readonly id: string;\n /** A text block, a control group (measured at its first control), or a surface (a box: border or its own fill). */\n readonly kind: 'text' | 'controls' | 'surface';\n /**\n * The block's edge: a text's first-character origin, a bounded control's or a surface's border box, an unbounded\n * control's text. For a hanging marker, the marker's edge.\n */\n readonly edge: number;\n /** Horizontal extent, for telling side-by-side columns apart. */\n readonly left: number;\n readonly right: number;\n /** Vertical position, for finding a surface's first text. */\n readonly top: number;\n /** The surface this block sits inside, by id; absent at the card's own level. */\n readonly within?: string;\n /** A hanging marker's text edge: what stacks with the block may line up with this or with `edge`. */\n readonly textEdge?: number;\n /** Structure the DOM names: a list item, a table (measured at its rule), a member of a centred group. */\n readonly role?: 'list-item' | 'table' | 'centred' | 'placeholder';\n}\n\nexport interface EdgeOffset {\n /** The container checked: the card, or a surface's id. */\n readonly container: string;\n /** The block that sits off every allowed edge. */\n readonly block: string;\n /** Its edge, and the nearest edge the rule allowed it, in px. */\n readonly at: number;\n readonly nearest: number;\n readonly offPx: number;\n /** Why the block is off when it is not plain distance (a centred block among edge-aligned ones). */\n readonly reason?: string;\n}\n\nexport interface EdgeVerdict {\n readonly verdict: 'pass' | 'fail' | 'n/a';\n /** Every block that sits off the allowed edges, with its offset; empty on a pass. */\n readonly offsets: readonly EdgeOffset[];\n readonly evidence: string;\n}\n\nconst CARD = 'card';\nconst same = (a: number, b: number): boolean => Math.abs(a - b) <= EDGE_TOLERANCE_PX;\nconst overlaps = (a: EdgeBlock, b: EdgeBlock): boolean => a.left < b.right && b.left < a.right;\nconst axis = (b: EdgeBlock): number => (b.left + b.right) / 2;\n\n/** A surface's content edge: where its first text starts (its topmost text block's edge), or undefined if it has none. */\nfunction contentEdge(surface: EdgeBlock, blocks: readonly EdgeBlock[]): number | undefined {\n const texts = blocks.filter((b) => b.within === surface.id && b.kind !== 'surface' && b.role !== 'centred');\n if (texts.length === 0) return undefined;\n const first = texts.reduce((a, b) => (b.top < a.top ? b : a));\n return first.textEdge ?? first.edge;\n}\n\n/** Columns among a container's direct blocks: non-surface blocks that overlap horizontally, transitively. */\nfunction columns(direct: readonly EdgeBlock[]): EdgeBlock[][] {\n const all = direct.filter((b) => b.kind !== 'surface');\n // A block that spans two columns side by side (it overlaps two blocks that do not overlap each other) belongs to\n // their parent column, never to either (decided 2026-10-02): it must not chain them into one.\n const bridges = (b: EdgeBlock): boolean => {\n const under = all.filter((x) => x !== b && overlaps(x, b));\n return under.some((x, i) => under.slice(i + 1).some((y) => !overlaps(x, y)));\n };\n const flow = all.filter((b) => !bridges(b));\n const parentPool: EdgeBlock[] = all.filter((b) => bridges(b));\n const parent = flow.map((_, i) => i);\n const find = (i: number): number => (parent[i] === i ? i : (parent[i] = find(parent[i]!)));\n for (let i = 0; i < flow.length; i += 1) for (let j = i + 1; j < flow.length; j += 1) if (overlaps(flow[i]!, flow[j]!)) parent[find(i)] = find(j);\n const groups = new Map<number, EdgeBlock[]>();\n flow.forEach((b, i) => groups.set(find(i), [...(groups.get(find(i)) ?? []), b]));\n const cols = [...groups.values()];\n // A surface joins the one column whose text or controls it overlaps. One that overlaps two or more columns spans\n // them and goes to their parent, like a spanning text block; one that overlaps none stands with the other\n // unclaimed blocks. Only flow blocks decide, so a surface never chains another surface into a column.\n for (const s of direct.filter((b) => b.kind === 'surface')) {\n const hit = cols.filter((c) => c.some((b) => b.kind !== 'surface' && overlaps(b, s)));\n if (hit.length === 1) hit[0]!.push(s);\n else parentPool.push(s);\n }\n // The parent's blocks and the unclaimed surfaces form columns among themselves: blocks that overlap stack.\n const lp = parentPool.map((_, i) => i);\n const lfind = (i: number): number => (lp[i] === i ? i : (lp[i] = lfind(lp[i]!)));\n for (let i = 0; i < parentPool.length; i += 1) for (let j = i + 1; j < parentPool.length; j += 1) if (overlaps(parentPool[i]!, parentPool[j]!)) lp[lfind(i)] = lfind(j);\n const lgroups = new Map<number, EdgeBlock[]>();\n parentPool.forEach((b, i) => lgroups.set(lfind(i), [...(lgroups.get(lfind(i)) ?? []), b]));\n cols.push(...lgroups.values());\n return cols;\n}\n\n/** One column's check: one edge, or a stacked surface's content edge (the surface is then a ground). */\nfunction checkColumn(container: string, col: readonly EdgeBlock[], blocks: readonly EdgeBlock[]): EdgeOffset[] {\n const surfaces = col.filter((b) => b.kind === 'surface');\n const grounds = surfaces.flatMap((s) => {\n const c = s.role === 'table' ? undefined : contentEdge(s, blocks);\n return c === undefined ? [] : [c];\n });\n const flow = col.filter((b) => b.kind !== 'surface' && b.role !== 'centred' && b.role !== 'list-item');\n const listItems = col.filter((b) => b.role === 'list-item');\n // Every edge a flow block or a surface offers; the common edge E must sit on one of them.\n const candidates = [...flow.flatMap((b) => [b.edge, ...(b.textEdge !== undefined ? [b.textEdge] : [])]), ...surfaces.flatMap((s) => [s.edge]), ...grounds];\n const blockEdges = (b: EdgeBlock): number[] => [b.edge, ...(b.textEdge !== undefined ? [b.textEdge] : [])];\n // The end edges another block of the column offers: its boxes' and its other control sets'.\n const endEdgesBesides = (b: EdgeBlock): number[] => [...surfaces.map((s) => s.right), ...flow.filter((x) => x !== b && x.kind === 'controls').map((x) => x.right)];\n // A column of only list items or only a centred group has no common edge to find; their own checks below still run.\n let best: EdgeOffset[] | null = candidates.length === 0 ? [] : null;\n for (const E of candidates) {\n const allowed = [E, ...grounds];\n const off: EdgeOffset[] = [];\n for (const b of flow) {\n if (blockEdges(b).some((x) => allowed.some((a) => same(x, a)))) continue;\n // A control set alone on its line may END on the end edge its column's boxes or other controls share.\n if (b.kind === 'controls' && endEdgesBesides(b).some((r) => same(b.right, r))) continue;\n const nearest = allowed.reduce((n, a) => (Math.abs(a - b.edge) < Math.abs(n - b.edge) ? a : n));\n off.push({ container, block: b.id, at: b.edge, nearest, offPx: Math.abs(b.edge - nearest) });\n }\n for (const s of surfaces) {\n const c = s.role === 'table' ? undefined : contentEdge(s, blocks);\n if (same(s.edge, E) || (c !== undefined && same(c, E))) continue;\n const nearest = c !== undefined && Math.abs(c - E) < Math.abs(s.edge - E) ? c : s.edge;\n off.push({ container, block: s.id, at: nearest, nearest: E, offPx: Math.abs(nearest - E) });\n }\n if (best === null || off.length < best.length || (off.length === best.length && sum(off) < sum(best))) best = off;\n if (best.length === 0) break;\n }\n const offsets = best ?? [];\n // A list inside running text: its items share an edge of their own.\n if (listItems.length > 1) {\n const e0 = listItems[0]!.edge;\n for (const li of listItems.slice(1)) if (!same(li.edge, e0)) offsets.push({ container, block: li.id, at: li.edge, nearest: e0, offPx: Math.abs(li.edge - e0) });\n }\n // A centred group: its members share one centre axis, and it must be the whole content of its column. A column is\n // edge-aligned or centred, never both (decided 2026-10-02).\n const centred = col.filter((b) => b.role === 'centred');\n // A centred group of two or more may follow a label or heading when nothing edge-aligned follows it (an empty state\n // under its section label). One centred block among edge-aligned ones, or a column that returns to an edge after\n // the group, fails (decided 2026-10-02).\n const edgeAligned = col.filter((b) => b.role !== 'centred');\n const groupTop = centred.length > 0 ? Math.min(...centred.map((c) => c.top)) : 0;\n const groupEndsColumn = centred.length > 1 && edgeAligned.every((b) => b.top < groupTop);\n if (centred.length > 0 && edgeAligned.some((b) => b.kind !== 'surface') && !groupEndsColumn) {\n const E = flow[0]?.edge ?? edgeAligned[0]!.edge;\n for (const c of centred) offsets.push({ container, block: c.id, at: c.edge, nearest: E, offPx: Math.abs(c.edge - E), reason: 'a centred block in an edge-aligned column' });\n } else if (centred.length > 1) {\n const a0 = axis(centred[0]!);\n for (const c of centred.slice(1)) if (!same(axis(c), a0)) offsets.push({ container, block: c.id, at: axis(c), nearest: a0, offPx: Math.abs(axis(c) - a0) });\n }\n return offsets;\n}\nconst sum = (o: readonly EdgeOffset[]): number => o.reduce((s, x) => s + x.offPx, 0);\n\n/**\n * Judge one captured width. `placeholdersOnly`: the frame shows only loading placeholders, so the row is not evaluated.\n */\nexport function judgeEdges(measured: readonly EdgeBlock[], opts: { readonly placeholdersOnly?: boolean } = {}): EdgeVerdict {\n if (opts.placeholdersOnly === true) return { verdict: 'n/a', offsets: [], evidence: 'only loading placeholders are shown; not evaluated' };\n let blocks = measured;\n // A placeholder (a box with nothing in it, shown while content loads) is not a block, and the rule needs two blocks to\n // compare: with fewer than two once placeholders are set aside, the frame is not evaluated (decided 2026-10-02).\n // The two blocks are content, text or controls: a box holds them and is not one of them for this count.\n const kept = blocks.filter((b) => b.role !== 'placeholder');\n const content = kept.filter((b) => b.kind !== 'surface').length;\n if (content < 2) return { verdict: 'n/a', offsets: [], evidence: kept.length === 0 ? 'no blocks were measured' : 'fewer than two blocks once placeholders are set aside; not evaluated' };\n blocks = kept;\n const offsets: EdgeOffset[] = [];\n const containers = [CARD, ...blocks.filter((b) => b.kind === 'surface' && b.role !== 'table').map((b) => b.id)];\n for (const container of containers) {\n const direct = blocks.filter((b) => (b.within ?? CARD) === container);\n for (const col of columns(direct)) offsets.push(...checkColumn(container, col, blocks));\n }\n if (offsets.length === 0) return { verdict: 'pass', offsets, evidence: 'every column shares its edge, or sits on a stacked surface’s content edge, within 2 px' };\n const worst = offsets.reduce((a, b) => (b.offPx > a.offPx ? b : a));\n const lines = offsets.map((o) => `${o.block} at x${round(o.at)} is ${round(o.offPx)} px from x${round(o.nearest)} (in ${o.container}${o.reason !== undefined ? `; ${o.reason}` : ''})`);\n return { verdict: 'fail', offsets, evidence: `${offsets.length} block(s) off the allowed edges, largest ${round(worst.offPx)} px: ${lines.join('; ')}` };\n}\nconst round = (n: number): string => (Math.round(n * 10) / 10).toString();\n","/**\n * `space.edge.v2` (#1765): the edge rule as the design lead rewrote it, as a SEPARATE instrument beside the frozen v1\n * (`edge.ts` / `edge-probe.ts`, validated at `cec465319`). v1 is untouched and keeps reporting; both verdicts go on\n * every capture until v2 has its own fresh sealed draw.\n *\n * The rule (the design lead, #1765): in each column of a card the things that stack start on one content edge.\n * 1. One-step nesting is legal only inside a visible surface (its own fill or a hairline): a surface's content may sit\n * on the surface's content edge. An unboxed wrapper is not a surface; its content is compared at its container.\n * 2. In a row, the leading item sits on the content edge; every item after it in the same row is measured from the\n * item before it, not from the card. A trailing item is legal when its right edge sits on its container's right\n * content edge (within 2 px) or when the row has a leading item on the edge. A block alone on its line whose right\n * edge sits mid-card is a split.\n * 3. Grid columns (items side by side in a row) each have their own edge: they are rows' later items (rule 2).\n * 4. A media column may centre its image.\n * 5. Content to content: a control is compared by its content's edge (its first character), never its border box.\n *\n * Input is the measured block list from `edge-probe-v2.ts`; this module measures nothing itself.\n */\nimport { EDGE_TOLERANCE_PX, type EdgeBlock, type EdgeOffset, type EdgeVerdict } from './edge.js';\n\n/** One block of a captured card, as the v2 probe measures it: v1's fields, plus what the v2 rule reads. */\nexport interface EdgeBlockV2 extends Omit<EdgeBlock, 'kind'> {\n /** v1's kinds, plus `media`: a painted image, video or icon that is not a text's marker. */\n readonly kind: EdgeBlock['kind'] | 'media';\n /** The block's bottom, CSS px from the card's top, for rows. */\n readonly bottom: number;\n /** A surface's content box (inside its border and padding): where its content may sit, and where a trailing item may end. */\n readonly contentLeft?: number;\n readonly contentRight?: number;\n /**\n * Rule 2: the block sits in a row item that is not the row's leading item. The value names the row's leading item, so\n * the block is measured with the other blocks of its own item, never against its container's column.\n */\n readonly follows?: string;\n /** A row item's own id, so blocks that follow the same leader in the same item are grouped together. */\n readonly item?: string;\n /** Rule 2, trailing: the right content edge of the box the block sits in, where a right-anchored item ends. */\n readonly parentRight?: number;\n}\n\n/** The card's own content box, from the probe: where the card's content edge is and where a trailing item may end. */\nexport interface CardContentBox {\n readonly left: number;\n readonly right: number;\n}\n\nexport { EDGE_TOLERANCE_PX };\nexport type { EdgeOffset, EdgeVerdict };\n\n// ── v1's column logic, copied verbatim from `edge.ts` at `cec465319` (that file stays frozen), typed for v2 blocks ──\nconst CARD = 'card';\nconst same = (a: number, b: number): boolean => Math.abs(a - b) <= EDGE_TOLERANCE_PX;\nconst overlaps = (a: EdgeBlockV2, b: EdgeBlockV2): boolean => a.left < b.right && b.left < a.right;\nconst axis = (b: EdgeBlockV2): number => (b.left + b.right) / 2;\n\n/** A surface's content edge: where its first text starts (its topmost text block's edge), or undefined if it has none. */\nfunction contentEdge(surface: EdgeBlockV2, blocks: readonly EdgeBlockV2[]): number | undefined {\n const texts = blocks.filter((b) => b.within === surface.id && b.kind !== 'surface' && b.role !== 'centred');\n if (texts.length === 0) return undefined;\n const first = texts.reduce((a, b) => (b.top < a.top ? b : a));\n return first.textEdge ?? first.edge;\n}\n\n/** Columns among a container's direct blocks: non-surface blocks that overlap horizontally, transitively. */\nfunction columns(direct: readonly EdgeBlockV2[]): EdgeBlockV2[][] {\n const all = direct.filter((b) => b.kind !== 'surface');\n // A block that spans two columns side by side (it overlaps two blocks that do not overlap each other) belongs to\n // their parent column, never to either (decided 2026-10-02): it must not chain them into one.\n const bridges = (b: EdgeBlockV2): boolean => {\n const under = all.filter((x) => x !== b && overlaps(x, b));\n return under.some((x, i) => under.slice(i + 1).some((y) => !overlaps(x, y)));\n };\n const flow = all.filter((b) => !bridges(b));\n const parentPool: EdgeBlockV2[] = all.filter((b) => bridges(b));\n const parent = flow.map((_, i) => i);\n const find = (i: number): number => (parent[i] === i ? i : (parent[i] = find(parent[i]!)));\n for (let i = 0; i < flow.length; i += 1) for (let j = i + 1; j < flow.length; j += 1) if (overlaps(flow[i]!, flow[j]!)) parent[find(i)] = find(j);\n const groups = new Map<number, EdgeBlockV2[]>();\n flow.forEach((b, i) => groups.set(find(i), [...(groups.get(find(i)) ?? []), b]));\n const cols = [...groups.values()];\n // A surface joins the one column whose text or controls it overlaps. One that overlaps two or more columns spans\n // them and goes to their parent, like a spanning text block; one that overlaps none stands with the other\n // unclaimed blocks. Only flow blocks decide, so a surface never chains another surface into a column.\n for (const s of direct.filter((b) => b.kind === 'surface')) {\n const hit = cols.filter((c) => c.some((b) => b.kind !== 'surface' && overlaps(b, s)));\n if (hit.length === 1) hit[0]!.push(s);\n else parentPool.push(s);\n }\n // The parent's blocks and the unclaimed surfaces form columns among themselves: blocks that overlap stack.\n const lp = parentPool.map((_, i) => i);\n const lfind = (i: number): number => (lp[i] === i ? i : (lp[i] = lfind(lp[i]!)));\n for (let i = 0; i < parentPool.length; i += 1) for (let j = i + 1; j < parentPool.length; j += 1) if (overlaps(parentPool[i]!, parentPool[j]!)) lp[lfind(i)] = lfind(j);\n const lgroups = new Map<number, EdgeBlockV2[]>();\n parentPool.forEach((b, i) => lgroups.set(lfind(i), [...(lgroups.get(lfind(i)) ?? []), b]));\n cols.push(...lgroups.values());\n return cols;\n}\n\n/** One column's check: one edge, or a stacked surface's content edge (the surface is then a ground). */\nfunction checkColumn(container: string, col: readonly EdgeBlockV2[], blocks: readonly EdgeBlockV2[]): EdgeOffset[] {\n const surfaces = col.filter((b) => b.kind === 'surface');\n const grounds = surfaces.flatMap((s) => {\n const c = s.role === 'table' ? undefined : contentEdge(s, blocks);\n return c === undefined ? [] : [c];\n });\n const flow = col.filter((b) => b.kind !== 'surface' && b.role !== 'centred' && b.role !== 'list-item');\n const listItems = col.filter((b) => b.role === 'list-item');\n // Every edge a flow block or a surface offers; the common edge E must sit on one of them.\n const candidates = [...flow.flatMap((b) => [b.edge, ...(b.textEdge !== undefined ? [b.textEdge] : [])]), ...surfaces.flatMap((s) => [s.edge]), ...grounds];\n const blockEdges = (b: EdgeBlockV2): number[] => [b.edge, ...(b.textEdge !== undefined ? [b.textEdge] : [])];\n // The end edges another block of the column offers: its boxes' and its other control sets'.\n const endEdgesBesides = (b: EdgeBlockV2): number[] => [...surfaces.map((s) => s.right), ...flow.filter((x) => x !== b && x.kind === 'controls').map((x) => x.right)];\n // A column of only list items or only a centred group has no common edge to find; their own checks below still run.\n let best: EdgeOffset[] | null = candidates.length === 0 ? [] : null;\n for (const E of candidates) {\n const allowed = [E, ...grounds];\n const off: EdgeOffset[] = [];\n for (const b of flow) {\n if (blockEdges(b).some((x) => allowed.some((a) => same(x, a)))) continue;\n // A control set alone on its line may END on the end edge its column's boxes or other controls share.\n if (b.kind === 'controls' && endEdgesBesides(b).some((r) => same(b.right, r))) continue;\n const nearest = allowed.reduce((n, a) => (Math.abs(a - b.edge) < Math.abs(n - b.edge) ? a : n));\n off.push({ container, block: b.id, at: b.edge, nearest, offPx: Math.abs(b.edge - nearest) });\n }\n for (const s of surfaces) {\n const c = s.role === 'table' ? undefined : contentEdge(s, blocks);\n if (same(s.edge, E) || (c !== undefined && same(c, E))) continue;\n const nearest = c !== undefined && Math.abs(c - E) < Math.abs(s.edge - E) ? c : s.edge;\n off.push({ container, block: s.id, at: nearest, nearest: E, offPx: Math.abs(nearest - E) });\n }\n if (best === null || off.length < best.length || (off.length === best.length && sum(off) < sum(best))) best = off;\n if (best.length === 0) break;\n }\n const offsets = best ?? [];\n // A list inside running text: its items share an edge of their own.\n if (listItems.length > 1) {\n const e0 = listItems[0]!.edge;\n for (const li of listItems.slice(1)) if (!same(li.edge, e0)) offsets.push({ container, block: li.id, at: li.edge, nearest: e0, offPx: Math.abs(li.edge - e0) });\n }\n // A centred group: its members share one centre axis, and it must be the whole content of its column. A column is\n // edge-aligned or centred, never both (decided 2026-10-02).\n const centred = col.filter((b) => b.role === 'centred');\n // A centred group of two or more may follow a label or heading when nothing edge-aligned follows it (an empty state\n // under its section label). One centred block among edge-aligned ones, or a column that returns to an edge after\n // the group, fails (decided 2026-10-02).\n const edgeAligned = col.filter((b) => b.role !== 'centred');\n const groupTop = centred.length > 0 ? Math.min(...centred.map((c) => c.top)) : 0;\n const groupEndsColumn = centred.length > 1 && edgeAligned.every((b) => b.top < groupTop);\n if (centred.length > 0 && edgeAligned.some((b) => b.kind !== 'surface') && !groupEndsColumn) {\n const E = flow[0]?.edge ?? edgeAligned[0]!.edge;\n for (const c of centred) offsets.push({ container, block: c.id, at: c.edge, nearest: E, offPx: Math.abs(c.edge - E), reason: 'a centred block in an edge-aligned column' });\n } else if (centred.length > 1) {\n const a0 = axis(centred[0]!);\n for (const c of centred.slice(1)) if (!same(axis(c), a0)) offsets.push({ container, block: c.id, at: axis(c), nearest: a0, offPx: Math.abs(axis(c) - a0) });\n }\n return offsets;\n}\nconst sum = (o: readonly EdgeOffset[]): number => o.reduce((s, x) => s + x.offPx, 0);\n\n// ── v2 ──\n\n/** Rule 2: a block in a row item after the row's leader is measured with its own item, never against its container. */\nconst follower = (b: EdgeBlockV2): boolean => b.follows !== undefined;\nconst vOverlap = (a: EdgeBlockV2, b: EdgeBlockV2): boolean => Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top) > 1;\n\n/**\n * Judge one captured width under the v2 rule. `cardContent` is the card's own content box from the probe;\n * `placeholdersOnly`: the frame shows only loading placeholders, so the row is not evaluated.\n */\nexport function judgeEdgesV2(\n measured: readonly EdgeBlockV2[],\n opts: { readonly cardContent: CardContentBox; readonly placeholdersOnly?: boolean },\n): EdgeVerdict {\n if (opts.placeholdersOnly === true) return { verdict: 'n/a', offsets: [], evidence: 'only loading placeholders are shown; not evaluated' };\n const content = measured.filter((b) => b.role !== 'placeholder' && (b.kind === 'text' || b.kind === 'controls')).length;\n if (content < 2) return { verdict: 'n/a', offsets: [], evidence: measured.length === 0 ? 'no blocks were measured' : 'fewer than two blocks once placeholders are set aside; not evaluated' };\n const byId = new Map(measured.map((b) => [b.id, b]));\n const containerOf = (b: EdgeBlockV2): string => b.within ?? CARD;\n const contentBoxOf = (container: string): CardContentBox | undefined => {\n if (container === CARD) return opts.cardContent;\n const s = byId.get(container);\n return s?.contentLeft !== undefined && s.contentRight !== undefined ? { left: s.contentLeft, right: s.contentRight } : undefined;\n };\n // A placeholder leads its row when a block of its container follows it on its line; otherwise it is not a block (v1).\n const leadsARow = (p: EdgeBlockV2): boolean => measured.some((b) => b !== p && containerOf(b) === containerOf(p) && follower(b) && b.left >= p.right - 1 && vOverlap(b, p));\n // Rule 4 (re-registered): media is a painted image, or a painted box with no control inside, that is the only block\n // on its line in its container; it may centre in its column, and its own content may centre inside it.\n const holdsControl = (s: EdgeBlockV2): boolean => {\n const inside = (b: EdgeBlockV2): boolean => { for (let w = b.within; w !== undefined; w = byId.get(w)?.within) if (w === s.id) return true; return false; };\n return measured.some((b) => b.kind === 'controls' && inside(b));\n };\n const aloneOnItsLine = (m: EdgeBlockV2): boolean =>\n !measured.some((b) => b !== m && containerOf(b) === containerOf(m) && b.role !== 'placeholder' && vOverlap(b, m));\n // Centred, and narrower than its column: a box that starts on its container's content edge is full width, not centred.\n const centredInContainer = (m: EdgeBlockV2): boolean => {\n const box = contentBoxOf(containerOf(m));\n return box !== undefined && same((m.left + m.right) / 2, (box.left + box.right) / 2) && !same(m.left, box.left);\n };\n const mediaKind = (b: EdgeBlockV2): boolean => b.kind === 'media' || (b.kind === 'surface' && b.role !== 'table' && !holdsControl(b));\n const blocks = measured.filter((b) => {\n if (b.role === 'placeholder') return leadsARow(b);\n if (b.kind === 'media' && centredInContainer(b)) return false;\n return true;\n });\n\n // A surface that bleeds to the card's own edge (x0, full width): its outer edge is the card's, not a content edge,\n // so it is compared by its content edge alone (the design lead, c.6263664713: the root's content edge against every\n // bleeding surface's content).\n const bleeds = (b: EdgeBlockV2): boolean => b.kind === 'surface' && containerOf(b) === CARD && b.left <= EDGE_TOLERANCE_PX && b.right >= opts.cardContent.right - EDGE_TOLERANCE_PX;\n const judged = blocks.map((b) => (bleeds(b) && b.contentLeft !== undefined ? { ...b, edge: b.contentLeft } : b));\n // Rule 2, trailing: a block alone on its line that ends on its container's right content edge is right-anchored.\n // A trailing item trails: it starts in the right half of its container's content box, and is never a bleed.\n const rightAnchored = (b: EdgeBlockV2): boolean => {\n const box = contentBoxOf(containerOf(b));\n const ends = (r: number | undefined): boolean => r !== undefined && same(b.right, r);\n return (ends(box?.right) || ends(b.parentRight)) && box !== undefined && b.left >= (box.left + box.right) / 2 && !bleeds(b);\n };\n const offsets: EdgeOffset[] = [];\n const containers = [CARD, ...judged.filter((b) => b.kind === 'surface' && b.role !== 'table').map((b) => b.id)];\n for (const container of containers) {\n const inContainer = judged.filter((b) => containerOf(b) === container);\n // The container's own column: its blocks that lead (or are not in) a row, less right-anchored trailing items.\n const direct = inContainer.filter((b) => !follower(b) && !rightAnchored(b));\n for (const col of columns(direct)) {\n // Rule 4: media alone in its column, centred in its container, may centre (the design lead, c.6282971546). A\n // lone block of any kind passes its own column; this only exempts the media from its NEIGHBOURS' column, which\n // is how a centred cover beside or above edge-aligned text reaches a column at all.\n const only = col.length === 1 ? col[0]! : undefined;\n if (only !== undefined && mediaKind(only) && aloneOnItsLine(only) && centredInContainer(only)) continue;\n offsets.push(...checkColumn(container, col, judged));\n }\n // Each row item after a leader is its own column group, measured among its own blocks.\n const items = new Map<string, EdgeBlockV2[]>();\n for (const b of inContainer.filter(follower)) items.set(b.item ?? b.id, [...(items.get(b.item ?? b.id) ?? []), b]);\n for (const [item, group] of items) for (const col of columns(group)) offsets.push(...checkColumn(`${container} › ${item}`, col, judged));\n }\n if (offsets.length === 0) return { verdict: 'pass', offsets, evidence: 'every column shares its content edge, every row item after its leader shares its own, within 2 px' };\n const worst = offsets.reduce((a, b) => (b.offPx > a.offPx ? b : a));\n const lines = offsets.map((o) => `${o.block} at x${round(o.at)} is ${round(o.offPx)} px from x${round(o.nearest)} (in ${o.container}${o.reason !== undefined ? `; ${o.reason}` : ''})`);\n return { verdict: 'fail', offsets, evidence: `${offsets.length} block(s) off the allowed edges, largest ${round(worst.offPx)} px: ${lines.join('; ')}` };\n}\nconst round = (n: number): string => (Math.round(n * 10) / 10).toString();\n","// packages/ui-gen/src/evaluation/visual-evaluator.ts\n//\n// Visual evaluator — renders compiled component, takes screenshot,\n// sends to multimodal LLM for visual quality scoring.\n//\n// Two modes:\n// 1. Screenshot mode (puppeteer available): full visual evaluation\n// 2. Source-only mode (no puppeteer): falls back to code-based evaluation\n//\n// The visual evaluator complements the code-based evaluator by catching\n// issues only visible when rendered: broken layouts, overlapping elements,\n// poor visual hierarchy, missing whitespace.\n\nimport { buildStylingProfileJudgeBlock } from '../boilerplate/styling-profile.js';\nimport type { GenerationProfileInput } from '../boilerplate/styling-profile.js';\nimport type { CriteriaAnswer } from './types.js';\nimport type { CriteriaBlock, CriteriaContext, CriteriaRollup } from './types-public.js';\nimport type { CriteriaBank } from './criteria/bank.js';\nimport type { JsonObject } from '@ggui-ai/protocol';\nimport type { CriteriaContextInput } from './criteria/context.js';\nimport { selectCriteria } from './criteria/select.js';\nimport { buildCriteriaJudgeBlock, resolveCriteriaBlock } from './criteria/resolve.js';\nimport { build } from 'esbuild';\nimport { EXPANDED_FRAME, FRAMED_CARD_GROUND, GGUI_MOUNT_CANVAS_EXPORT, mountFitCss, expandedFramePanelDecls, expandedFramePanelRule, expandedFrameScrimDecls, getCssTokens, inlineCardRadius, resolveMountFit, type MountFit } from '@ggui-ai/design/rendering';\nimport { readInkExtent, type InkExtent } from './ink-extent.js';\nimport { judgeDesignIdentity, type JudgeDesignIdentity } from './design-identity.js';\nimport { resolve, dirname } from 'path';\nimport { fileURLToPath } from 'url';\nimport { createRequire } from 'node:module';\nimport { existsSync, readFileSync, writeFileSync, mkdtempSync, rmSync } from 'fs';\nimport { createHash } from 'node:crypto';\nimport { tmpdir } from 'os';\nimport { createVisionAgent, type AgentConfig, type VisionFinishReason } from '../harness/llm-router';\nimport type { EvaluationResult, EvaluationIssue, DimensionScores } from './types';\n\n/**\n * An issue as the visual leg CREATES it (ggui#1545 follow-up): its `origin` is required here, so a new producer, an\n * instrument check or a judge-side parse, that forgets to say whose finding it is fails to compile instead of\n * quietly dropping out of `visualEvaluation.actOn`'s treatment. The public `EvaluationIssue` keeps `origin` optional\n * for stored and external data.\n */\ntype VisualIssue = EvaluationIssue & { origin: 'judge' | 'instrument' };\nimport type { CanvasHostPresentation, CanvasJudgeRecord, CriteriaAnswerCounts, CanvasPresentationOutcome, CanvasVisualSummary, EvalIssue, HostInlineFrame, HostPresentationIgnoredReason, JudgeSalvageCause, JudgeSalvageCounts, VisualCoverage, VisualEvalSummary, VisualFitStamp } from './types-public.js';\nimport type { LaunchOptions } from 'puppeteer-core';\nimport { CANVAS_VIEWPORTS, displayModeForCanvas, type CanvasClass, type CanvasViewport } from '../design-mode.js';\nimport { judgeEdges, type EdgeVerdict } from './criteria/edge.js';\nimport { EDGE_BLOCKS_EXPRESSION, parseEdgeProbe } from './criteria/edge-probe.js';\nimport { EDGE_BLOCKS_V2_EXPRESSION, parseEdgeProbeV2 } from './criteria/edge-probe-v2.js';\nimport { judgeEdgesV2 } from './criteria/edge-v2.js';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface VisualEvalConfig {\n /** LLM provider for multimodal evaluation */\n provider: 'claude' | 'google';\n /** Model ID (must support vision/multimodal) */\n model?: string;\n /** Pass threshold for visual score (0-100) */\n passThreshold: number;\n /** Sample props to render the component with */\n sampleProps?: Record<string, unknown>;\n /** Viewport dimensions for screenshot */\n viewport?: { width: number; height: number };\n /**\n * Per-canvas judging — ARM-NEUTRAL (the same judge, prompt and\n * threshold in every design mode). When set, the SAME rendered HTML\n * shell is screenshotted once per class at `CANVAS_VIEWPORTS[class]`\n * and judged once per class; the result carries one entry per class\n * in `canvases`, and the single-shot fields aggregate: `finalScore` =\n * mean of the canvas scores (rounded), `passed` = every canvas passed,\n * `dimensions` = per-dimension means, `issues` = every canvas's issues\n * (description prefixed `[<canvas>]`). Unset (or empty) = today's\n * single screenshot at `viewport`; no `canvases` field on the result.\n */\n canvases?: readonly CanvasClass[];\n /**\n * ggui#1195 — the box a canvas is COMPOSED for and CAPTURED at when the\n * order declared one (the chat card at the visitor's real column, not the\n * class's 400×640). Keyed by canvas; a canvas without an entry is judged\n * at `CANVAS_VIEWPORTS[canvas]` as before. The composer's\n * `rendering.viewport` and this entry are ONE value written once (the\n * seam derives it), so the judge never scores a box the mint did not\n * target. Only read in per-canvas mode. Captured at WHOLE CSS px: the\n * browser's device-metrics override takes integers (measured — a 383.5 px\n * width is refused by CDP), so a fractional declared box is rounded once\n * where it enters and the capture, the ceiling and the reported\n * `viewport` all carry that same integer box.\n */\n canvasViewports?: Partial<Readonly<Record<CanvasClass, CanvasViewport>>>;\n /**\n * ggui#1492 — how a host presents each canvas, as data the caller supplies (a lane that knows its host). Keyed by\n * canvas; a canvas without an entry is judged exactly as before (the generic stand-in round the inline card, the\n * scrim under a panel). The box stays in {@link canvasViewports}. An entry this judge cannot use (a colour that is\n * not `#rrggbb`, a number out of range, a frame on a canvas that is not the inline card) is ignored for its canvas,\n * said once in the log, never partly applied.\n */\n hostPresentations?: Partial<Readonly<Record<CanvasClass, CanvasHostPresentation>>>;\n /**\n * Optional provider-routing override — see\n * `AgentConfig.routeOverride`. Threaded onto the agent this\n * evaluator constructs so its multimodal call never falls back to\n * `process.env` for credentials or model routing.\n */\n /**\n * Vision calls per judged canvas on the SAME captured frame, aggregated by\n * the median (ggui#1072). Default 1 — a single judgement, byte-identical to\n * the instrument before this option existed. K is an instrument dial: a\n * run mixes K at its own peril.\n */\n judgeK?: number;\n /** The canvases sampled `judgeK` times; default = every judged canvas when `judgeK > 1`. */\n judgeKCanvases?: readonly CanvasClass[];\n /**\n * The design `src` tree the judge bundles the component against\n * (ggui#1042): an explicit input, so a judge-only re-judge names the tree\n * it painted with. Default: the design package beside this one.\n */\n designSrcDir?: string;\n /** The mode the caller composed `cssTokens` in — a receipt on the row, never a switch (ggui#1076: judge and runtime must name the same mode). */\n themeMode?: 'light' | 'dark';\n routeOverride?: AgentConfig['routeOverride'];\n /**\n * Provider-429-retry observer — see `AgentConfig.onRetry`.\n * Without it, a rate-limited retry inside the evaluation call\n * happens (the agent's retry loop is unconditional) but never\n * reaches the caller's structured log.\n */\n onRetry?: AgentConfig['onRetry'];\n}\n\n/**\n * ggui#1436 — what the report-only criteria call spent. Kept APART from the scoring calls' `inputTokens` /\n * `outputTokens`: those price the judgement a caller may meter, and the criteria call is a measurement beside it.\n */\nexport interface CriteriaCallTokens {\n readonly inputTokens: number;\n readonly outputTokens: number;\n}\n\n/** One canvas's verdict — screenshot + judge score at that class's viewport. */\nexport interface CanvasVisualResult {\n canvas: CanvasClass;\n viewport: CanvasViewport;\n /** The judge's weighted score for this canvas (0-100). */\n score: number;\n /** `score >= passThreshold`. */\n passed: boolean;\n /** The PNG the judge saw — kept for artefact persistence + the human look. */\n screenshotPng: Buffer;\n /**\n * The document's scroll height at this canvas's viewport, CSS px — what\n * the box would have to be for nothing to be hidden (ggui#1027). `null`\n * when the page could not be measured.\n */\n contentHeight: number | null;\n /** `contentHeight > viewport.height` — a measurement; what it MEANS is {@link canvasFitPolicy}'s. */\n overflow: boolean;\n /** How `score` was reached — always present (ggui#1072). */\n /**\n * ggui#1120 — how far down the capture anything was painted (the last inked row over the measured\n * region's height, read against the capture's dominant colour, inside a drawn panel's chrome); `0`\n * is the blank the judge fails, `null` an unreadable capture.\n */\n inkRatio: number | null;\n judge: CanvasJudgeRecord;\n /** How the judge composed the mount (ggui#1100): `'fill'` on every fullscreen canvas, absent on the inline card. */\n fit?: 'fill';\n /** ggui#1195 — `true` when the order DECLARED this canvas's box (`config.canvasViewports` carried an entry), whatever its value. */\n declared?: true;\n /** ggui#1436 — the typed criteria block, when a bank was configured. */\n criteria?: CriteriaBlock;\n /** ggui#1436 — the criteria call's own spend, when one was asked and answered; never inside the canvas's scoring tokens. */\n criteriaTokens?: CriteriaCallTokens;\n /** ggui#1492 — what the judge did with this canvas's host presentation (drawn, or ignored and why), when one was supplied. */\n presentation?: CanvasPresentationOutcome;\n}\n\n/** How a canvas is captured for the judge and what an overflow means there (ggui#1027). */\n/**\n * How a canvas is captured. `card-box` (ggui#1953): a framed card (a chat-width card on a fullscreen surface,\n * ggui#1924) is captured as the inline card is — its OWN box at its natural extent, plus the frame ground's margin on\n * every side, ring and corners visible — never the pane round it, whose empty ground is the host's, not the card's.\n */\nexport type CaptureMode = 'viewport' | 'full-page' | 'natural' | 'card-box';\nexport interface CanvasFitPolicy {\n /**\n * `viewport` = the whole box; `full-page` = the whole scrolled document; `natural` (ggui#1475) = the\n * card at its OWN height, clipped to its extent and capped at the box — the inline card a host sizes\n * to its content, on the host's ground ({@link JUDGE_GROUND_MARGIN_PX}).\n */\n readonly capture: CaptureMode;\n /** The verdict an overflow earns on this canvas. */\n readonly overflow: 'fail' | 'warn' | 'none';\n}\n\n/**\n * The inline chat card takes its NATURAL height under a ceiling (ggui#1475):\n * an MCP Apps host sizes the inline frame to the card's content\n * (`ui/notifications/size-changed`, auto-resize) up to its maximum, so the\n * visitor sees the card and nothing under it. The judge captures exactly\n * that — the card's own extent on the host's ground, capped at the box — and\n * never the box's remainder (a fixed 640 px capture scored every hello\n * against a void no visitor sees). The box stays the ceiling: content taller\n * than it is a critical layout issue that fails the canvas (a 1289 px hello\n * on a 640 px card was scored 86 from a full-page capture that showed the\n * judge what no user sees). A phone's first screen may scroll, so the\n * overflow is reported as a major issue and the score stands. Pages\n * (`md`/`lg`/`xl`) scroll by design: measured, never judged.\n */\nexport function canvasFitPolicy(canvas: CanvasClass): CanvasFitPolicy {\n switch (canvas) {\n case 'xs-chat-card':\n return { capture: 'natural', overflow: 'fail' };\n case 'mobile-fullscreen-small':\n return { capture: 'full-page', overflow: 'warn' };\n default:\n return { capture: 'full-page', overflow: 'none' };\n }\n}\n\n/**\n * The mount element of the judge page (ggui#1100). Its class is the scope\n * `fillFitRule` targets — the judge's counterpart of the runtime's mount list.\n */\nexport const JUDGE_SCOPE_CLASS = 'ggui-judge-scope';\n/** The panel the judge draws round a fill canvas's scope on its stand-in host page (ggui#1083 cut 3) — see {@link canvasChrome}. */\nexport const JUDGE_PANEL_CLASS = 'ggui-judge-panel';\n/**\n * How far in from a panelled page's edges the ink is read (ggui#1120): past the panel's gap, its\n * largest rounded corner (the `round` bucket, 24 px — the scrim shows through the corner) and its\n * 1 px hairline, so the host's chrome never counts as paint. The card's own inset is 16 px, so the\n * band skipped inside the card is 25 px of a canvas — reported ratios are over the region.\n */\nexport const JUDGE_INK_INSET_PX = EXPANDED_FRAME.insetPx + 24 + 1;\n\n/**\n * How the judge composes a canvas (ggui#1100): the served runtime stretches\n * the mounted root to the frame on every fullscreen surface (`fit: 'fill'`,\n * ggui#1041/#1073/#1096) and leaves the inline card at its natural height —\n * the judge does the same, or it scores a picture the user never sees (a\n * content-sized hello on an empty 768×1024 page; candidate 34's hellos).\n */\nexport function canvasFit(canvas: CanvasClass): 'fill' | undefined {\n return displayModeForCanvas(canvas) === 'fullscreen' ? 'fill' : undefined;\n}\n/**\n * What the judge's stand-in host draws round a canvas: the embedding shell's floating panel on its\n * scrim (a fill canvas, md and up), the host's ground round the inline card (`ground`, ggui#1475), or\n * nothing (the phone, edge to edge).\n */\nexport type CanvasChrome = 'panel' | 'ground' | undefined;\n/**\n * The host ground round a naturally-captured inline card (ggui#1475): the card is mounted this far in\n * from the page's edges and captured with this margin, so its edge and radius are read against the\n * host surface — the page's scrim ground, never the card's own. The design's one gap (the panel's).\n */\nexport const JUDGE_GROUND_MARGIN_PX = EXPANDED_FRAME.insetPx;\n/** The class the judge page wraps a naturally-captured card's mount in — its padding is the ground margin. */\nexport const JUDGE_GROUND_CLASS = 'ggui-judge-ground';\n/**\n * The host's frame round the inline card (ggui#1475). An inline card draws no chrome of its own (the\n * chat layout tells it the host draws it), so without a frame it sits transparent on the page ground\n * and has no edge to read. The judge draws a GENERIC stand-in for the host's frame, built from the\n * card's own theme: its container surface, a 1 px ring of its ink at 8 %, a 16 px radius, and\n * overflow hidden. It is a stand-in, and the frame line says so: a host's exact frame arrives as data.\n */\nexport const JUDGE_INLINE_FRAME_CLASS = 'ggui-judge-inline-frame';\nexport const JUDGE_INLINE_FRAME_BORDER_PX = 1;\nexport const JUDGE_INLINE_FRAME_RADIUS_PX = 16;\n/** What the inline card's page adds on each side of the card: the ground margin plus the frame's border. */\nexport const JUDGE_INLINE_PAD_PX = JUDGE_GROUND_MARGIN_PX + JUDGE_INLINE_FRAME_BORDER_PX;\n/** How far in the inline card's ink is read: past the margin, the frame's ring and its rounded corner, so the host's frame never counts as paint. */\nexport const JUDGE_INLINE_INK_INSET_PX = JUDGE_INLINE_PAD_PX + JUDGE_INLINE_FRAME_RADIUS_PX;\n\n/**\n * The bounds a host frame must meet to be drawn (ggui#1492), exported so a lane's reader applies exactly the frames\n * this judge draws: an entry the reader accepts and the judge ignores would be echoed as applied while never drawn.\n */\nexport const HOST_COLOUR_PATTERN = /^#[0-9a-f]{6}$/;\nexport const HOST_FRAME_BOUNDS = {\n ringWidthPx: { min: 0, max: 8 },\n ringAlpha: { min: 0, max: 1 },\n radiusPx: { min: 0, max: 64 },\n minHeightPx: { min: 0, max: 2560 },\n} as const;\n/**\n * ggui#1492 — what this judge will do with a canvas's host presentation: draw it, or ignore it with the lane\n * reader's own reason code. `undefined` when none was supplied. Every string drawn reaches the page's CSS, so a\n * colour must be `#rrggbb` and a number must sit inside {@link HOST_FRAME_BOUNDS}; an inline card's room lives on\n * its frame, so a top-level `ground` there is refused rather than silently unused.\n */\nfunction resolvePresentation(canvas: CanvasClass, p: CanvasHostPresentation | undefined): CanvasPresentationOutcome | undefined {\n if (p === undefined) return undefined;\n const ignored = (reason: HostPresentationIgnoredReason, why: string): CanvasPresentationOutcome => {\n console.warn(`[visual-eval] host presentation for ${canvas} ignored (${reason}): ${why}`);\n return { status: 'ignored', reason };\n };\n const inline = canvasFitPolicy(canvas).capture === 'natural';\n if (typeof p.label !== 'string' || p.label.length === 0) return ignored('label_missing', 'no label');\n if (p.ground !== undefined && !HOST_COLOUR_PATTERN.test(p.ground)) return ignored('color_not_hex', 'ground is not #rrggbb');\n if (inline && p.ground !== undefined) return ignored('ground_on_inline', \"the inline card's room is its frame's ground\");\n const f = p.frame;\n if (f !== undefined) {\n if (!inline) return ignored('frame_off_inline', 'a frame on a canvas that is not the inline card');\n if (![f.surface, f.ground, f.ring.color].every((c) => HOST_COLOUR_PATTERN.test(c))) return ignored('color_not_hex', 'a frame colour is not #rrggbb');\n const B = HOST_FRAME_BOUNDS;\n const inRange = (n: number, b: { readonly min: number; readonly max: number }): boolean => Number.isFinite(n) && n >= b.min && n <= b.max;\n if (!inRange(f.ring.widthPx, B.ringWidthPx) || !inRange(f.ring.alpha, B.ringAlpha) || !inRange(f.radiusPx, B.radiusPx)) return ignored('frame_malformed', 'a frame number out of range');\n if (f.minHeightPx !== undefined && !inRange(f.minHeightPx, B.minHeightPx)) return ignored('frame_malformed', 'minHeightPx out of range');\n }\n return { status: 'applied', applied: p };\n}\n/** What the inline card's page adds per side, where its ink is read from, and the host's floor — from the host frame when given, else the stand-in's. */\ninterface InlineGeometry {\n readonly padPx: number;\n readonly inkInsetPx: number;\n readonly floorPx: number | undefined;\n}\nfunction inlineGeometry(frame: HostInlineFrame | undefined): InlineGeometry {\n if (frame === undefined) return { padPx: JUDGE_INLINE_PAD_PX, inkInsetPx: JUDGE_INLINE_INK_INSET_PX, floorPx: undefined };\n const padPx = JUDGE_GROUND_MARGIN_PX + frame.ring.widthPx;\n return { padPx, inkInsetPx: padPx + frame.radiusPx, floorPx: frame.minHeightPx };\n}\n/**\n * The host stand-in round a fill canvas (ggui#1083 cut 3, ggui#1067 §5): the embedding shell floats\n * the card in a panel on its scrim — a hairline, the theme's `xl` radius, `shadow-sm`, a 16 px gap —\n * only when expanded at ≥ 601 px; below that the card owns the phone edge to edge. So the panel\n * canvases are the fill canvases from `md` up (the shell's panel reaches `lg` / `xl` on wide windows)\n * and `mobile-fullscreen-small` carries no chrome. The panel is the design's ONE definition\n * (`expandedFramePanelRule`), never a second drawing, and the judge pads its window by the panel's\n * gap so the CARD's box stays the canvas box ({@link judgeWindow}): the frame the founder approves\n * carries the chrome the visitor sees, and the card is measured where it was before.\n */\nexport function canvasChrome(canvas: CanvasClass): CanvasChrome {\n if (canvasFitPolicy(canvas).capture === 'natural') return 'ground';\n return canvasFit(canvas) === 'fill' && canvas !== 'mobile-fullscreen-small' ? 'panel' : undefined;\n}\n/** The browser window for a canvas: the canvas box, plus the chrome's gap on every side when the judge draws one (the panel's, or the host ground's). */\nexport function judgeWindow(viewport: CanvasViewport, chrome: CanvasChrome, inlinePadPx: number = JUDGE_INLINE_PAD_PX): CanvasViewport {\n if (chrome === undefined) return viewport;\n const gap = 2 * (chrome === 'ground' ? inlinePadPx : EXPANDED_FRAME.insetPx);\n return { width: viewport.width + gap, height: viewport.height + gap };\n}\n/**\n * The card's height on a panelled page: the panel grows with the card and carries the gap above and\n * below it. A document shorter than the gap laid out no panel (the panel alone is a viewport tall), so\n * there is no reading — `null`, never a negative height.\n */\nfunction cardHeight(documentHeight: number | null, chrome: CanvasChrome): number | null {\n // A natural capture measures the card itself (the mount's extent), never the document.\n if (documentHeight === null || chrome === undefined || chrome === 'ground') return documentHeight;\n const gap = 2 * EXPANDED_FRAME.insetPx;\n return documentHeight < gap ? null : documentHeight - gap;\n}\n\n/**\n * The box a browser can be asked for: whole CSS px. CDP's\n * `Emulation.setDeviceMetricsOverride` deserialises width/height as int32 and\n * refuses a fraction (measured on Chrome: `383.5` → \"int32 value expected\"),\n * while a host measuring its chat column with `getBoundingClientRect()` may\n * legitimately declare one. Rounded once, at the judge's boundary.\n */\nexport function integerBox(viewport: { width: number; height: number }): { width: number; height: number } {\n return { width: Math.round(viewport.width), height: Math.round(viewport.height) };\n}\n\n/** ggui#1195 — `true` when a canvas was judged at a box other than its class viewport (the order declared one). */\nexport function isDeclaredViewport(canvas: CanvasClass, viewport: CanvasViewport): boolean {\n const classBox = CANVAS_VIEWPORTS[canvas];\n return viewport.width !== classBox.width || viewport.height !== classBox.height;\n}\n\n/** The deterministic fit issue — one per overflowing canvas, in the judge's issue shape so it rides the same channel. */\nexport function canvasOverflowIssue(\n canvas: CanvasClass,\n viewport: CanvasViewport,\n contentHeight: number,\n verdict: 'fail' | 'warn',\n): VisualIssue {\n const hidden = contentHeight - viewport.height;\n // ggui#1195 — when the judge captured at a DECLARED box, the refusal names\n // both boxes: the ceiling the content was measured against and the class\n // box a reader would otherwise assume.\n const classBox = CANVAS_VIEWPORTS[canvas];\n const box = isDeclaredViewport(canvas, viewport)\n ? `declared ${viewport.width}×${viewport.height}; class box ${classBox.width}×${classBox.height}`\n : `${viewport.width}×${viewport.height}`;\n return {\n dimension: 'canvas-overflow',\n origin: 'instrument',\n severity: verdict === 'fail' ? 'critical' : 'major',\n description:\n `Rendered content is ${contentHeight}px tall on the ${canvas} canvas (${box}) — ` +\n `${hidden}px ${verdict === 'fail' ? 'is cut off: the inline card does not scroll' : 'sits below the first screen'}.`,\n fix:\n 'Fit the composition to the canvas: fewer and shorter sections, one compact row of chips, no hero taller than ' +\n 'a third of the box, no fixed min-heights or tall paddings — measure against the canvas, not the page.',\n };\n}\n\n/** ggui#1475 — the horizontal twin of {@link canvasOverflowIssue}: content wider than the card, which its frame clips out of the capture. */\nexport function canvasOverflowXIssue(\n canvas: CanvasClass,\n viewport: CanvasViewport,\n hiddenPx: number,\n verdict: 'fail' | 'warn',\n): VisualIssue {\n return {\n dimension: 'canvas-overflow-x',\n origin: 'instrument',\n severity: verdict === 'fail' ? 'critical' : 'major',\n description:\n `Content runs ${hiddenPx}px past the ${canvas} card's ${viewport.width}px width — the card's frame clips it, ` +\n 'so a visitor sees a cut-off row or a sideways scroll.',\n fix:\n 'Keep every row within the card: wrap long text (overflow-wrap: anywhere), let a wide table or code block scroll ' +\n 'inside its own container, and give no child a fixed width wider than the card.',\n };\n}\n\n/** ggui#1120 — the deterministic blank: the capture is one flat colour, so the component mounted and painted nothing. */\nexport function canvasBlankIssue(canvas: CanvasClass, viewport: CanvasViewport): VisualIssue {\n const classBox = CANVAS_VIEWPORTS[canvas];\n const box = isDeclaredViewport(canvas, viewport)\n ? `declared ${viewport.width}×${viewport.height}; class box ${classBox.width}×${classBox.height}`\n : `${viewport.width}×${viewport.height}`;\n return {\n dimension: 'canvas-blank',\n origin: 'instrument',\n severity: 'critical',\n description: `Nothing painted on the ${canvas} canvas (${box}): the capture is one flat colour — the component mounted and rendered no pixels.`,\n fix:\n 'Return and paint the component tree: a root that renders nothing is a blank, not an empty state. Check that the ' +\n 'default export returns its JSX, that no early return yields null on the sample props, and that the first paint ' +\n 'shows visible content.',\n };\n}\n/**\n * `runVisualEvaluation`'s result. Identical to `EvaluationResult` when\n * `config.canvases` is unset; with canvases set, `canvases` holds the\n * per-class verdicts and the base fields aggregate them (see\n * `VisualEvalConfig.canvases`).\n */\nexport interface VisualEvaluationResult extends EvaluationResult {\n canvases?: CanvasVisualResult[];\n /**\n * ggui#1436 — the criteria calls' spend across canvases, when any was asked and answered. `inputTokens` /\n * `outputTokens` stay the SCORING calls' alone, so a cost read off them never includes the report-only block.\n */\n criteriaTokens?: CriteriaCallTokens;\n /**\n * ggui#1127 — salvaged judge answers across the canvases, per leg, as N of M (scoring answers; criteria calls\n * answered). Present on every canvas run, zeros included, so a reader can tell \"none salvaged\" from \"not counted\".\n */\n judgeSalvage?: JudgeSalvageCounts;\n /** The design tree the judge painted with (ggui#1042) — present on every per-canvas judgement. */\n design?: JudgeDesignIdentity;\n /** The mode `cssTokens` were composed in, when the caller said (ggui#1076). */\n themeMode?: 'light' | 'dark';\n}\n\n/** Injection points for `runVisualEvaluation` — screenshot deps plus the judge call (tests). */\nexport interface VisualEvalDeps extends ScreenshotDeps {\n /** The multimodal judge call (default: `callMultimodalLLM`). */\n judge?: typeof callMultimodalLLM;\n}\n\nexport interface VisualEvalContext {\n /** Compiled JavaScript code (ESM with imports) */\n compiledCode: string;\n /** Original user prompt */\n originalPrompt: string;\n /** Design system CSS tokens */\n cssTokens?: string;\n /** The app's generation profile (#991) — judged relative to, never against. */\n profile?: GenerationProfileInput;\n /** ggui#1436 — a criteria bank and the card's context; the judge selects per canvas and answers report-only. */\n criteria?: { readonly bank: CriteriaBank; readonly context: CriteriaContextInput };\n}\n\n// ---------------------------------------------------------------------------\n// HTML blueprint for rendering\n// ---------------------------------------------------------------------------\n\n/**\n * Bundle the compiled component with the design system using esbuild.\n * Produces a self-contained IIFE that only needs React + ReactDOM from CDN.\n * Resolves @ggui-ai/design/* imports from the local monorepo packages.\n */\n/**\n * The on-disk root of `@ggui-ai/design`, for the esbuild aliases that\n * let JUDGED components resolve the same design source production\n * ships. Exported for the ggui#613 regression pin: the previous inline\n * `'..','..','..','packages','design'` resolved a pre-`oss/`-migration\n * path (`oss/packages/packages/design`) that exists from NEITHER the\n * src nor the dist layout — the visual leg's bundle broke silently at\n * the migration. Three ups from `<pkg>/src/evaluation` (or\n * `<pkg>/dist/evaluation`) is `oss/packages/`; the design package is\n * its direct child.\n */\n/**\n * The on-disk root of `@ggui-ai/ui-gen` itself. The bundle's entry lives\n * in a temp dir, so bare imports in the GENERATED component (`@ggui-ai/wire`\n * and every other allowlisted package) resolve nowhere from there — they\n * resolve from this package's `node_modules` instead (`nodePaths`), the\n * same place the harness's own imports come from.\n */\nexport function resolveUiGenPackageDir(): string {\n // ggui#1769: found by walking up to this package's own manifest, never by counting directories. The code moves\n // with the bundle's layout: under `src/evaluation/` and the old per-entry `dist/evaluation/` the package root\n // was two levels up, but a shared chunk sits at `dist/` itself, one level up.\n return findPackageRootAbove(dirname(fileURLToPath(import.meta.url)), '@ggui-ai/ui-gen');\n}\n\n/** The nearest directory at or above `start` whose `package.json` is named `name`; throws when there is none. */\nexport function findPackageRootAbove(start: string, name: string): string {\n for (let dir = start; ; dir = dirname(dir)) {\n const manifest = resolve(dir, 'package.json');\n if (existsSync(manifest) && readPackageName(manifest) === name) return dir;\n if (dirname(dir) === dir) throw new Error(`${name}: no package.json named ${name} at or above ${start}`);\n }\n}\n\nfunction readPackageName(manifest: string): string | undefined {\n const parsed: unknown = JSON.parse(readFileSync(manifest, 'utf8'));\n return typeof parsed === 'object' && parsed !== null && 'name' in parsed && typeof parsed.name === 'string' ? parsed.name : undefined;\n}\n\n/**\n * Where `@ggui-ai/wire` actually is, from ui-gen's OWN module graph —\n * layout-proof: a workspace checkout links it under `node_modules/`, a\n * `pnpm deploy` tree puts it beside ui-gen under `.pnpm/…/node_modules/`,\n * and a plain install nests it; `import.meta.resolve` answers for all\n * three (directory candidates first, module graph last). Aliased\n * explicitly in the judge's bundle so the generated component's wire\n * import never depends on the directory layout the evaluator runs in.\n */\nexport function resolveWirePackageDir(): string | null {\n const uiGenDir = resolveUiGenPackageDir();\n const candidates = [\n resolve(uiGenDir, 'node_modules', '@ggui-ai', 'wire'), // workspace / nested install\n resolve(uiGenDir, '..', 'wire'), // pnpm deploy: `.pnpm/<ui-gen>@<ver>/node_modules/@ggui-ai/{ui-gen,wire}`\n resolve(uiGenDir, '..', '..', '@ggui-ai', 'wire'), // hoisted flat install beside the scope dir\n ];\n for (const dir of candidates) {\n if (existsSync(resolve(dir, 'package.json'))) return dir;\n }\n try {\n // Last resort: ask the module graph (Node ≥ 20.6). Not every runner\n // supports it synchronously, hence the guarded position.\n const entry = fileURLToPath(import.meta.resolve('@ggui-ai/wire'));\n let dir = dirname(entry);\n for (let i = 0; i < 6; i++) {\n if (existsSync(resolve(dir, 'package.json'))) return dir;\n dir = dirname(dir);\n }\n } catch {\n // fall through — nodePaths still gets a chance\n }\n return null;\n}\n\n/**\n * The `@ggui-ai/design` package root — resolved by MODULE ID, never by counting\n * directories (ggui#1110).\n *\n * The arithmetic this replaced (`…/'..','..','..','design'`) was correct only\n * for the layout it was written against — `node_modules/@ggui-ai/ui-gen/dist/\n * evaluation` → `node_modules/@ggui-ai/` + `design`. Under a deploy-flattened\n * layout it landed one level too high, at `node_modules/design`, a path that is\n * not the design package at all: the judge then walked a directory that does not\n * exist, threw ENOENT inside every evaluation round on that deployment, and a\n * bar refused cards no one could judge. `@ggui-ai/design` exports `./package.json`,\n * so the module resolver answers correctly in every layout — scoped, flattened,\n * hoisted — and the receipt keeps working inside the image.\n */\nexport function resolveDesignPackageDir(): string {\n try {\n return dirname(createRequire(import.meta.url).resolve('@ggui-ai/design/package.json'));\n } catch {\n // A runner whose module graph cannot see the package (a bundled judge, a\n // test double). The layout guess is the last resort, and a wrong answer is\n // now a NAMED absent receipt rather than a thrown round (`judgeDesignIdentity`).\n const selfDir = dirname(fileURLToPath(import.meta.url));\n return resolve(selfDir, '..', '..', '..', 'design');\n }\n}\n\nasync function bundleForRendering(\n compiledCode: string,\n sampleProps: Record<string, unknown>,\n designSrc: string = resolve(resolveDesignPackageDir(), 'src'),\n): Promise<string> {\n // Write component + entry to temp files for esbuild — in a directory of THIS\n // call's own. `mkdtempSync` is atomic and unique: a timestamp-named directory\n // was shared by two bundles started in the same millisecond, so the first\n // build read the second's component (a judge scoring the wrong generation)\n // and the first's cleanup deleted the files the second was building.\n const tmpDir = mkdtempSync(resolve(tmpdir(), 'ggui-visual-eval-'));\n const componentFile = resolve(tmpDir, 'component.tsx');\n const entryFile = resolve(tmpDir, 'entry.tsx');\n\n const designPkgDir = resolve(designSrc, '..');\n const wirePkgDir = resolveWirePackageDir();\n\n // Write the compiled component as a separate module\n writeFileSync(componentFile, compiledCode);\n\n // Entry file imports the component and renders it\n // The generated component is rendered the way a host renders it: inside\n // `GguiWireProvider` with a stub config (dispatch/subscribe are no-ops —\n // the judge sees the first paint, not the wire round-trip). Without the\n // provider every `useAction` / `useStream` bearer threw\n // \"useWireContext must be used within a WireProvider\", React unmounted\n // the root and the judge scored a blank page. An error boundary turns a\n // render throw into visible \"Render error\" text (which the rubric\n // scores 0) instead of the same blank.\n const entryCode = `\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { GguiWireProvider } from '@ggui-ai/wire';\nimport Component from './component.tsx';\n\nconst props = ${JSON.stringify(sampleProps)};\nconst wireConfig = {\n app: { appId: 'visual-eval', appName: 'Visual evaluation' },\n render: { sessionId: 'visual-eval', isConnected: true },\n auth: { isAuthenticated: false },\n dispatch: () => {},\n subscribe: () => () => {},\n};\nclass RenderErrorBoundary extends React.Component<{ children: React.ReactNode }, { message: string | null }> {\n state = { message: null as string | null };\n static getDerivedStateFromError(err: unknown) { return { message: err instanceof Error ? err.message : String(err) }; }\n render() {\n return this.state.message === null\n ? this.props.children\n : React.createElement('div', { className: 'error' }, 'Render error: ' + this.state.message);\n }\n}\nconst root = createRoot(document.getElementById('root')!);\ntry {\n root.render(\n React.createElement(GguiWireProvider, { config: wireConfig },\n React.createElement(RenderErrorBoundary, null, React.createElement(Component, props))),\n );\n} catch (err) {\n root.render(React.createElement('div', { className: 'error' }, 'Render error: ' + (err as Error).message));\n}\n`;\n\n writeFileSync(entryFile, entryCode);\n\n try {\n const result = await build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n format: 'esm',\n platform: 'browser',\n target: 'es2020',\n jsx: 'automatic',\n jsxImportSource: 'react',\n external: ['react', 'react-dom', 'react-dom/client', 'react/jsx-runtime'],\n alias: {\n // The wire hooks: resolved from ui-gen's own module graph so the\n // alias holds in a workspace checkout AND in a `pnpm deploy` image\n // (where deps are siblings, not children, of this package).\n ...(wirePkgDir !== null ? { '@ggui-ai/wire': wirePkgDir } : {}),\n // D1: generated code imports the single `@ggui-ai/design` barrel.\n // The subpath aliases stay for any first-party / legacy code.\n '@ggui-ai/design': resolve(designPkgDir, 'src', 'index.ts'),\n '@ggui-ai/design/primitives': resolve(designPkgDir, 'src', 'primitives', 'index.ts'),\n '@ggui-ai/design/components': resolve(designPkgDir, 'src', 'components', 'index.ts'),\n '@ggui-ai/design/compositions': resolve(designPkgDir, 'src', 'compositions', 'index.ts'),\n '@ggui-ai/design/interact': resolve(designPkgDir, 'src', 'interact', 'index.ts'),\n },\n // Bare imports in the generated component resolve against ui-gen's\n // own node_modules — the temp entry dir has none. Without this every\n // wire-bearing component (`@ggui-ai/wire`) failed to bundle.\n // Workspace layout (deps under this package's node_modules) and the\n // `pnpm deploy` layout (deps as siblings of this package) — both\n // searched for any other allowlisted bare import.\n nodePaths: [resolve(resolveUiGenPackageDir(), 'node_modules'), resolve(resolveUiGenPackageDir(), '..')],\n logLevel: 'silent',\n });\n\n return result.outputFiles[0]?.text ?? '';\n } finally {\n // The whole per-call directory; `force` makes an already-absent path a no-op.\n rmSync(tmpDir, { recursive: true, force: true });\n }\n}\n\n/** The inline card's frame: the host's, as data, when given; else the generic stand-in built from the card's own tokens. */\nfunction inlineFrameDecls(frame: HostInlineFrame | undefined): string {\n if (frame === undefined) {\n return `background: var(--ggui-color-container); border: ${JUDGE_INLINE_FRAME_BORDER_PX}px solid color-mix(in srgb, var(--ggui-color-onContainer) 8%, transparent); border-radius: ${JUDGE_INLINE_FRAME_RADIUS_PX}px; overflow: hidden;`;\n }\n const alphaPct = Math.round(frame.ring.alpha * 1000) / 10;\n return `background: ${frame.surface}; border: ${frame.ring.widthPx}px solid color-mix(in srgb, ${frame.ring.color} ${alphaPct}%, transparent); border-radius: ${frame.radiusPx}px; overflow: hidden;`;\n}\n\nfunction buildRenderHTML(\n bundledCode: string,\n cssTokens?: string,\n fit?: 'fill',\n chrome?: CanvasChrome,\n presentation?: CanvasHostPresentation,\n /** Set for a `framed-card` mount: the card frame's radius ({@link inlineCardRadius}); `null` keeps the theme's `lg` token. */\n framedCardRadiusPx?: number | null,\n): string {\n const framedCard = framedCardRadiusPx !== undefined;\n if (chrome === 'panel' && fit !== 'fill' && !framedCard) throw new Error(\"the judge's panel frames a fill canvas only (ggui#1083 cut 3)\");\n if (chrome === 'ground' && fit === 'fill') throw new Error(\"the host ground frames an inline card only — a fill canvas has no natural height (ggui#1475)\");\n // Default to the design tokens production's no-theme branch injects\n // (getCssTokens → default theme, light) — ggui#613: under the s4\n // fallback ban the generated component's `var(--ggui-*)` references\n // carry no literal fallbacks, so an un-injected judged render shows\n // unset colors and the multimodal judge grades broken output. An\n // explicit caller value still wins (theme-aware callers pass their\n // own).\n const tokens = cssTokens ?? getCssTokens();\n return `<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <style>\n ${tokens}\n *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }\n body {\n font-family: var(--ggui-font-family-sans, system-ui, -apple-system, sans-serif);\n /* ggui#1083 — the host stand-in (neutral-50) under the theme's scrim (its tint at\n its opacity): the ground a frosted host puts under the card, so the judge scores\n the card where the visitor sees it. */\n ${presentation?.frame !== undefined ? `background: ${presentation.frame.ground};` : presentation?.ground !== undefined ? `background: ${presentation.ground};` : expandedFrameScrimDecls()}\n color: var(--ggui-color-neutral-900, #111827);\n }\n .error { color: #dc2626; padding: 16px; font-family: monospace; white-space: pre-wrap; }\n ${/* ggui#1765 — the fit's rules come from the ONE selection the runtime's composeThemeCss uses. */ mountFitCss(JUDGE_SCOPE_CLASS, fit === 'fill' ? 'fill' : framedCard ? 'framed-card' : 'card', framedCardRadiusPx ?? null)}\n ${fit === 'fill' && chrome === 'panel' ? expandedFramePanelRule(JUDGE_PANEL_CLASS, JUDGE_SCOPE_CLASS) : ''}\n ${framedCard ? `.${JUDGE_PANEL_CLASS} { ${expandedFramePanelDecls()} background: ${FRAMED_CARD_GROUND}; display: flow-root; } body > .${JUDGE_PANEL_CLASS} { margin: ${EXPANDED_FRAME.insetPx}px; height: calc(100vh - ${2 * EXPANDED_FRAME.insetPx}px); }` : ''}\n ${framedCard && chrome !== 'panel' ? `body { background: ${FRAMED_CARD_GROUND}; }` : ''}\n ${chrome === 'ground' ? `.${JUDGE_GROUND_CLASS} { padding: ${JUDGE_GROUND_MARGIN_PX}px; } .${JUDGE_INLINE_FRAME_CLASS} { ${inlineFrameDecls(presentation?.frame)} }` : ''}\n </style>\n</head>\n<body>\n ${chrome === 'panel' ? `<div class=\"${JUDGE_PANEL_CLASS}\">` : chrome === 'ground' ? `<div class=\"${JUDGE_GROUND_CLASS}\"><div class=\"${JUDGE_INLINE_FRAME_CLASS}\">` : ''}<div id=\"root\" class=\"${JUDGE_SCOPE_CLASS}\"></div>${chrome === 'panel' ? '</div>' : chrome === 'ground' ? '</div></div>' : ''}\n <script type=\"importmap\">\n {\n \"imports\": {\n \"react\": \"https://esm.sh/react@18\",\n \"react-dom\": \"https://esm.sh/react-dom@18\",\n \"react-dom/client\": \"https://esm.sh/react-dom@18/client\",\n \"react/jsx-runtime\": \"https://esm.sh/react@18/jsx-runtime\"\n }\n }\n </script>\n <script type=\"module\">\n${bundledCode}\n </script>\n</body>\n</html>`;\n}\n\n// ---------------------------------------------------------------------------\n// Screenshot capture (optional puppeteer dependency)\n// ---------------------------------------------------------------------------\n\n/** A screenshot's region in page px (puppeteer's `clip`). */\nexport interface ScreenshotClip {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** The page surface the capture uses — a structural subset of puppeteer's `Page`. */\nexport interface ScreenshotPage {\n setContent(html: string, options: { waitUntil: 'load'; timeout: number }): Promise<void>;\n waitForNetworkIdle(options: { idleTime: number; timeout: number }): Promise<void>;\n waitForSelector(selector: string, options: { timeout: number }): Promise<unknown>;\n /** Evaluates a JS expression in the page and returns its serialised value — the fit measurement (ggui#1027). */\n evaluate(expression: string): Promise<unknown>;\n screenshot(options: { type: 'png'; fullPage: boolean; clip?: ScreenshotClip }): Promise<Uint8Array>;\n}\n\n/** The browser surface the capture uses — a structural subset of puppeteer's `Browser`. */\nexport interface ScreenshotBrowser {\n newPage(): Promise<ScreenshotPage>;\n close(): Promise<void>;\n}\n\nexport type ScreenshotLauncher = (options: LaunchOptions) => Promise<ScreenshotBrowser>;\n\n/** The two members of `@sparticuz/chromium` the fallback launch path reads. */\nexport interface ChromiumProvider {\n readonly args: string[];\n executablePath(): Promise<string>;\n}\n\n/**\n * Injection points for the capture — every default is the production\n * path; tests replace them to pin branch selection without launching a\n * browser.\n */\nexport interface ScreenshotDeps {\n /** Launches the browser (default: `puppeteer-core`'s `launch`). */\n launch?: ScreenshotLauncher;\n /** Environment the executable-path override is read from (default: `process.env`). */\n env?: NodeJS.ProcessEnv;\n /** Loads `@sparticuz/chromium` (default: dynamic import) — only consulted when no override is set. */\n loadChromium?: () => Promise<ChromiumProvider>;\n /** Post-load settle time before the screenshot, ms (default 1000). */\n settleMs?: number;\n}\n\n/**\n * Chromium flags the `PUPPETEER_EXECUTABLE_PATH` launch adds: a system\n * Chromium inside a container has no user namespace for the sandbox and\n * `/dev/shm` is too small for a render surface.\n */\nexport const EXECUTABLE_PATH_LAUNCH_ARGS: readonly string[] = ['--no-sandbox', '--disable-dev-shm-usage'];\n\nconst DEFAULT_SCREENSHOT_VIEWPORT = { width: 1280, height: 800 } as const;\n\nasync function loadSparticuzChromium(): Promise<ChromiumProvider> {\n const chromium = await import('@sparticuz/chromium');\n return chromium.default;\n}\n\n/**\n * Pick the browser binary. `PUPPETEER_EXECUTABLE_PATH` (a system\n * Chromium — the bench runner image, a dev box) wins and skips the\n * `@sparticuz/chromium` load entirely; otherwise the bundled Lambda\n * Chromium supplies both binary and flags, as before.\n */\nexport async function resolveLaunchOptions(\n viewport: { width: number; height: number },\n deps: Pick<ScreenshotDeps, 'env' | 'loadChromium'> = {},\n): Promise<LaunchOptions> {\n const env = deps.env ?? process.env;\n const override = env.PUPPETEER_EXECUTABLE_PATH?.trim();\n // Whole px at the one place `defaultViewport` is built — the single-shot path takes the caller's box verbatim.\n const defaultViewport = integerBox(viewport);\n if (override) {\n return {\n executablePath: override,\n args: [...EXECUTABLE_PATH_LAUNCH_ARGS],\n defaultViewport,\n headless: true,\n };\n }\n const chromium = await (deps.loadChromium ?? loadSparticuzChromium)();\n return {\n args: chromium.args,\n defaultViewport,\n executablePath: await chromium.executablePath(),\n headless: true,\n };\n}\n\nasync function launchWithPuppeteer(options: LaunchOptions): Promise<ScreenshotBrowser> {\n const puppeteer = await import('puppeteer-core');\n return puppeteer.default.launch(options);\n}\n\n/**\n * Take a screenshot of the rendered component.\n * Returns the PNG bytes, or null if no browser could be launched.\n */\n/** Screenshot plus the reason when none could be taken — the judge's `unavailableReason`. */\nexport interface ScreenshotAttempt {\n readonly png: Buffer | null;\n readonly reason?: string;\n /** The document's scroll height at the viewport (ggui#1027); `null` when unmeasurable. */\n readonly contentHeight: number | null;\n /** ggui#1475 — a natural capture's horizontal overflow: how many px the card's content runs past its width; absent on every other capture. */\n readonly overflowX?: number | null;\n /**\n * ggui#1663 — the edge rule on this capture's DOM, read just before the screenshot (report-only); `null` when the\n * probe failed. Absent on a failed capture.\n */\n readonly edge?: EdgeVerdict | null;\n /** #1765 — the v2 edge rule on the same DOM, read beside `edge` (report-only); `null` when its probe failed. */\n readonly edgeV2?: EdgeVerdict | null;\n}\n\n/** The expression the fit measurement evaluates in the page — the taller of the two scroll heights. */\nexport const CONTENT_HEIGHT_EXPRESSION =\n 'Math.max(document.documentElement.scrollHeight, document.body ? document.body.scrollHeight : 0)';\n\n/**\n * ggui#1475 — the natural capture's measurement: the card's height as the host is told it. The MCP\n * Apps SDK's size-changed notification (the report an auto-resizing host sizes the inline frame by)\n * reads the document at `height: max-content` and restores the style; the judge reads the same\n * quantity, minus what its page adds on both sides (the ground margin and the host frame's border), so content outside the mount (a\n * portal into body) counts here exactly as it counts for the host. The document's scroll height\n * could not be used: it is floored at the viewport by definition, so it sees an overflow but never\n * a card shorter than its box.\n */\nexport function cardHeightExpression(padPx: number): string {\n return (\n \"(() => { const el = document.documentElement; const prev = el.style.height; el.style.height = 'max-content'; \" +\n `const h = Math.ceil(el.getBoundingClientRect().height); el.style.height = prev; return h - ${2 * padPx}; })()`\n );\n}\n/** The stand-in page's card height ({@link cardHeightExpression} at the stand-in's pad). */\nexport const CARD_HEIGHT_EXPRESSION = cardHeightExpression(JUDGE_INLINE_PAD_PX);\n\n/**\n * ggui#1475 — the inline card's horizontal overflow: how far its content runs past the card's width. The host's\n * frame (and the judge's stand-in) clips at the card's edge, so the capture cannot show it, while a visitor's frame\n * scrolls it sideways: only a measurement carries it.\n */\n/** The sideways reading layout rounding alone can produce (ggui#1475): `scrollWidth` and `clientWidth` are integers. */\nexport const OVERFLOW_X_ROUNDING_PX = 1;\nexport const CARD_OVERFLOW_X_EXPRESSION =\n \"(() => { const r = document.getElementById('root'); return r ? Math.max(0, Math.ceil(r.scrollWidth - r.clientWidth)) : null; })()\";\n\n/**\n * The natural capture's region: the card on the host ground, the ground margin on every side, the\n * card's height capped at the box (content past it is the overflow the fit verdict reads). At least\n * one row of card is kept, so a card that painted nothing is still read — as a blank, never as an\n * unreadable capture.\n */\nexport function naturalClip(window: { width: number; height: number }, cardHeightPx: number, padPx: number = JUDGE_INLINE_PAD_PX): ScreenshotClip {\n const m = padPx;\n const box = window.height - 2 * m;\n return { x: 0, y: 0, width: window.width, height: Math.max(1, Math.min(Math.ceil(cardHeightPx), box)) + 2 * m };\n}\n\n/** The expression a card-box capture reads: the mount's own border box, in page CSS px (ggui#1953). */\nexport const CARD_BOX_EXPRESSION = `(() => { const r = document.querySelector('.${JUDGE_SCOPE_CLASS}'); if (!r) return null; const b = r.getBoundingClientRect(); return { x: b.x, y: b.y, width: b.width, height: b.height }; })()`;\n\nasync function measureCardBox(page: ScreenshotPage): Promise<{ x: number; y: number; width: number; height: number } | null> {\n try {\n const v: unknown = await page.evaluate(CARD_BOX_EXPRESSION);\n if (typeof v !== 'object' || v === null) return null;\n const n = (k: string): number | null => { const x = Reflect.get(v, k); return typeof x === 'number' && Number.isFinite(x) ? x : null; };\n const [x, y, width, height] = [n('x'), n('y'), n('width'), n('height')];\n return x === null || y === null || width === null || height === null || width <= 0 || height <= 0 ? null : { x, y, width, height };\n } catch (e) {\n console.warn(`[visual-eval] card box unavailable: ${e instanceof Error ? e.message : String(e)}`);\n return null;\n }\n}\n\n/**\n * The card-box capture's region (ggui#1953): the card's own box with the frame ground's margin on every side, clamped\n * to the window. The card is never cropped above its own bottom edge while the window can hold it.\n */\nexport function cardBoxClip(window: { width: number; height: number }, box: { x: number; y: number; width: number; height: number }): ScreenshotClip {\n const m = JUDGE_GROUND_MARGIN_PX;\n const x = Math.max(0, Math.floor(box.x - m));\n const y = Math.max(0, Math.floor(box.y - m));\n return { x, y, width: Math.min(window.width - x, Math.ceil(box.width + 2 * m)), height: Math.max(1, Math.min(window.height - y, Math.ceil(box.height + 2 * m))) };\n}\n\n/** Measure the rendered document's height (or the card's, for a natural capture); a failed measurement is reported, never a failed capture. */\nasync function measureContentHeight(page: ScreenshotPage, expression: string = CONTENT_HEIGHT_EXPRESSION): Promise<number | null> {\n try {\n const h = await page.evaluate(expression);\n return typeof h === 'number' && Number.isFinite(h) ? Math.round(h) : null;\n } catch (e) {\n console.warn(`[visual-eval] content height unavailable: ${e instanceof Error ? e.message : String(e)}`);\n return null;\n }\n}\n\n/**\n * ggui#1663 — read the edge rule off the page the screenshot is about to take. The probe only reads layout (it never\n * writes to the DOM), so the frame is unchanged; a failed read is reported and returns `null`, never a failed capture.\n */\nasync function measureEdges(page: ScreenshotPage): Promise<{ edge: EdgeVerdict | null; edgeV2: EdgeVerdict | null }> {\n return { edge: await measureEdgesV1(page), edgeV2: await measureEdgesV2(page) };\n}\n\n/** #1765 — the v2 rule on the same page, beside v1; a failed read is reported and returns `null`, never a failed capture. */\nasync function measureEdgesV2(page: ScreenshotPage): Promise<EdgeVerdict | null> {\n try {\n const probe = parseEdgeProbeV2(await page.evaluate(EDGE_BLOCKS_V2_EXPRESSION));\n if (probe === null) {\n console.warn('[visual-eval] edge probe v2 unavailable: the page returned no readable blocks');\n return null;\n }\n return judgeEdgesV2(probe.blocks, { cardContent: probe.cardContent, placeholdersOnly: probe.placeholdersOnly });\n } catch (e) {\n console.warn(`[visual-eval] edge probe v2 unavailable: ${e instanceof Error ? e.message : String(e)}`);\n return null;\n }\n}\n\nasync function measureEdgesV1(page: ScreenshotPage): Promise<EdgeVerdict | null> {\n try {\n const probe = parseEdgeProbe(await page.evaluate(EDGE_BLOCKS_EXPRESSION));\n if (probe === null) {\n console.warn('[visual-eval] edge probe unavailable: the page returned no readable blocks');\n return null;\n }\n return judgeEdges(probe.blocks, { placeholdersOnly: probe.placeholdersOnly });\n } catch (e) {\n console.warn(`[visual-eval] edge probe unavailable: ${e instanceof Error ? e.message : String(e)}`);\n return null;\n }\n}\n\n/** ggui#1492 — a natural capture's geometry: the page's pad per side, and the host's floor when it has one. */\nexport interface NaturalCaptureOptions {\n readonly padPx: number;\n readonly floorPx?: number;\n}\n\nexport async function captureScreenshotDetailed(\n html: string,\n viewport: { width: number; height: number } = DEFAULT_SCREENSHOT_VIEWPORT,\n deps: ScreenshotDeps = {},\n capture: CaptureMode = 'full-page',\n natural: NaturalCaptureOptions = { padPx: JUDGE_INLINE_PAD_PX },\n): Promise<ScreenshotAttempt> {\n try {\n const launchOptions = await resolveLaunchOptions(viewport, deps);\n const browser = await (deps.launch ?? launchWithPuppeteer)(launchOptions);\n try {\n const page = await browser.newPage();\n // puppeteer ≥24.43 narrowed setContent's waitUntil to\n // 'load' | 'domcontentloaded'; waitForNetworkIdle (0 connections\n // for 500ms) reproduces the old 'networkidle0' semantics.\n await page.setContent(html, { waitUntil: 'load', timeout: 15000 });\n await page.waitForNetworkIdle({ idleTime: 500, timeout: 15000 }).catch(() => {});\n await page.waitForSelector('#root > *', { timeout: 10000 }).catch(() => {});\n // Wait a bit for CSS/fonts to settle\n await new Promise((r) => setTimeout(r, deps.settleMs ?? 1000));\n if (capture === 'natural') {\n // ggui#1475 — the inline card at its natural height: the capture is the card's extent on the host ground.\n const cardHeightPx = await measureContentHeight(page, natural.padPx === JUDGE_INLINE_PAD_PX ? CARD_HEIGHT_EXPRESSION : cardHeightExpression(natural.padPx));\n const overflowX = await measureContentHeight(page, CARD_OVERFLOW_X_EXPRESSION);\n // ggui#1492 — the host's floor: measured AFTER the card (its height stays the card's own), then applied to the\n // frame so the capture shows what a visitor sees under a short card — the frame's surface, as void.\n const floorPx = natural.floorPx;\n if (floorPx !== undefined && cardHeightPx !== null && cardHeightPx < floorPx) {\n await page.evaluate(`(() => { const f = document.querySelector('.${JUDGE_INLINE_FRAME_CLASS}'); if (f) f.style.minHeight = '${floorPx}px'; })()`);\n }\n const framed = cardHeightPx === null ? viewport.height - 2 * natural.padPx : floorPx !== undefined ? Math.max(cardHeightPx, floorPx) : cardHeightPx;\n const clip = naturalClip(viewport, framed, natural.padPx);\n const edges = await measureEdges(page);\n const screenshot = await page.screenshot({ type: 'png', fullPage: false, clip });\n return { png: Buffer.from(screenshot), contentHeight: cardHeightPx, overflowX, ...edges };\n }\n if (capture === 'card-box') {\n // ggui#1953 — the card's own box (the mount, which wears the card frame), so a root that stretches itself still\n // shows its void, and the host's empty ground below a short card is never in the frame.\n const box = await measureCardBox(page);\n // Fail closed, named: a card-box capture that cannot find the card's own box never falls back to the pane, which\n // is the frame this capture exists to stop judging (and would read as the old defect, silently).\n if (box === null) return { png: null, reason: `card-box capture: the card's own box (.${JUDGE_SCOPE_CLASS}) could not be measured`, contentHeight: null };\n const clip = cardBoxClip(viewport, box);\n const edges = await measureEdges(page);\n const screenshot = await page.screenshot({ type: 'png', fullPage: false, clip });\n return { png: Buffer.from(screenshot), contentHeight: Math.round(box.height), ...edges };\n }\n const contentHeight = await measureContentHeight(page);\n const edges = await measureEdges(page);\n const screenshot = await page.screenshot({ type: 'png', fullPage: capture === 'full-page' });\n return { png: Buffer.from(screenshot), contentHeight, ...edges };\n } finally {\n await browser.close();\n }\n } catch (e) {\n const reason = `screenshot failed: ${e instanceof Error ? e.message : String(e)}`;\n console.warn(`[visual-eval] ${reason}`);\n return { png: null, reason, contentHeight: null };\n }\n}\n\nexport async function captureScreenshot(\n html: string,\n viewport: { width: number; height: number } = DEFAULT_SCREENSHOT_VIEWPORT,\n deps: ScreenshotDeps = {},\n): Promise<Buffer | null> {\n return (await captureScreenshotDetailed(html, viewport, deps)).png;\n}\n\n// ---------------------------------------------------------------------------\n// Multimodal LLM evaluation\n// ---------------------------------------------------------------------------\n\nexport const VISUAL_EVAL_PROMPT = `You are a visual quality evaluator for ggui — a platform where AI agents generate React UI components on demand.\n\n## Context\nThe screenshot shows a generated React component built from a design system with CSS variable theming. The component was created by an LLM to fulfill a user's request. Your job is to evaluate whether the generated UI achieves the user's goal AND looks professionally designed.\n\n## Scoring Dimensions (0-100 each)\n\n1. **completeness** (25%): Does the screenshot show ALL features the user requested? Are all sections, controls, data fields, and interactive elements present? Missing features or sections = major deduction. Compare against the original request carefully.\n\n2. **layout** (25%): Is the layout well-composed? Clear sections and grouping? No overlapping elements? Proper spacing between elements? Responsive-looking? Does it look like a professional app UI, not a homework project?\n\n3. **hierarchy** (25%): Clear visual hierarchy? Headings are visually distinct from body text? Primary actions (buttons) are prominent? Information grouped logically with clear section breaks? Color and size used to guide the eye?\n\n4. **aesthetics** (25%): Professional, polished appearance? Consistent color palette? Good use of whitespace — not too sparse, not too cluttered? Cards, shadows, and borders used effectively? Does it look like something a designer would approve? Would you be comfortable showing this to a client?\n\n## Scoring Guide\n- 90-100: Production-ready. Would ship to real users. Polished layout, clear hierarchy, professional aesthetics.\n- 80-89: Good quality. Minor improvements needed (slightly tight spacing, one section could be better grouped).\n- 70-79: Acceptable but generic. Works correctly but lacks design polish or visual refinement.\n- 60-69: Below standard. Noticeable problems — cramped layout, poor hierarchy, or missing sections.\n- Below 60: Broken or fundamentally incomplete. Error messages visible, blank areas, or critical features missing.\n\n## Important\n- Check the screenshot against the \"Original Request\" — does it actually deliver what was asked for?\n- Error messages like \"Render error\" or blank white space = rendering score 0\n- A component that renders but is just a wall of text with no structure should score low on layout and hierarchy\n\nList AT MOST 6 issues, most severe first, one sentence each for \"description\" and \"fix\" — a longer list is cut off and lost.\n\nRespond with ONLY a JSON object (no markdown, no explanation):\n{\n \"completeness\": <0-100>,\n \"layout\": <0-100>,\n \"hierarchy\": <0-100>,\n \"aesthetics\": <0-100>,\n \"issues\": [\n { \"dimension\": \"<dimension>\", \"severity\": \"<critical|major|minor>\", \"description\": \"<what's wrong>\", \"fix\": \"<specific fix>\" }\n ],\n \"critique\": \"<2-3 sentences: what's good, what needs improvement, does it achieve the user's goal?>\"\n}`;\n\n/**\n * Send the screenshot to the configured multimodal provider through\n * the shared `LLMAgent` machinery. Routing through `createVisionAgent`\n * (rather than constructing provider SDK clients inline) is what puts\n * this call inside the same `apiCall()` choke point as every other\n * completion: provider 429s retry with `Retry-After` honoring, the\n * caller's `onRetry` observer sees each retry, and `routeOverride`\n * governs credentials and model routing (including the Anthropic\n * Bedrock path) instead of `process.env`.\n */\n/**\n * Output budget for the judge's answer. 1500 cut a board's issue list\n * mid-array (`Expected ',' or ']' after array element`, six kanban cells\n * on 2026-09-11) — deterministic on the content, so a same-prompt retry\n * could never clear it. 4096 fits the bounded list the prompt now asks for\n * with room; the salvage path covers the remainder.\n */\nexport const VISUAL_JUDGE_MAX_OUTPUT_TOKENS = 4096;\n\n/**\n * The judge instrument's name and content digest, for the record a run\n * stamps beside every visual score. The NAME is for readers; the DIGEST\n * is computed from the prompt text at module load, so a stamped row can\n * never claim a prompt version it did not run — change the prompt and the\n * digest moves with it (the pin ties the name to the bounded-list text).\n */\nexport const VISUAL_JUDGE_PROMPT_VERSION = 'v2-bounded-issues';\nexport const VISUAL_JUDGE_PROMPT_DIGEST = createHash('sha256').update(VISUAL_EVAL_PROMPT, 'utf8').digest('hex');\n\nasync function callMultimodalLLM(\n config: VisualEvalConfig,\n model: string,\n prompt: string,\n screenshot: Buffer,\n originalPrompt: string,\n profileBlock = '',\n criteriaBlock = '',\n) {\n // ggui#1436 — the criteria block rides in the USER turn after the profile block, so the\n // system prompt (and its digest pin) never moves; the block's digest is the set id.\n const userPrompt =\n `## Original Request\\n${originalPrompt}\\n\\n` +\n (profileBlock.length > 0 ? `${profileBlock}\\n\\n` : '') +\n (criteriaBlock.length > 0 ? `${criteriaBlock}\\n\\n` : '') +\n 'Evaluate the screenshot of the generated component.';\n const agent = createVisionAgent({\n provider: config.provider === 'claude' ? 'anthropic' : config.provider,\n model,\n routeOverride: config.routeOverride,\n onRetry: config.onRetry,\n });\n return agent.callVision(\n model,\n prompt,\n userPrompt,\n { mediaType: 'image/png', base64: screenshot.toString('base64') },\n VISUAL_JUDGE_MAX_OUTPUT_TOKENS,\n );\n}\n\n// ---------------------------------------------------------------------------\n// Main entry point\n// ---------------------------------------------------------------------------\n\n/**\n * Run visual evaluation on a compiled component.\n *\n * 1. Builds an HTML page with the component + sample props\n * 2. Takes a screenshot via puppeteer (if available)\n * 3. Sends screenshot to multimodal LLM for visual scoring\n *\n * Returns null if puppeteer is not available (graceful fallback).\n */\n/**\n * The judge's answer WITH the reason when it could not judge: `result` is\n * null exactly when no screenshot could be taken (no browser, a launch or\n * in-page failure) or the component could not be bundled; `unavailableReason`\n * names why in words and `canvas` the canvas it happened at. A production\n * caller records the reason in its receipt — a `judge_unavailable` that only\n * says \"null\" cost a log dive on 2026-09-10 (puppeteer-core missing in the\n * deploy image).\n */\nexport interface VisualEvalDetailed {\n readonly result: VisualEvaluationResult | null;\n readonly unavailableReason?: string;\n readonly canvas?: CanvasClass;\n}\n\n\n/**\n * One canvas, framed: the box it is captured at (ggui#1195 — the DECLARED box\n * when the order carried one, else the class box), the canvas's fit policy,\n * the runtime's fit for the mount (ggui#1100 — fullscreen canvases fill, the\n * inline card does not) and the capture. The judge path and the fit-only path\n * ({@link runVisualFit}) frame through this ONE function, so a fit verdict\n * reached without the judge is taken on the frame the judge would have seen.\n */\n/**\n * The canvas a compiled bundle declares in its {@link GGUI_MOUNT_CANVAS_EXPORT} export, read from the code as the runtime\n * reads it from the module: the binding exported under that name (`export{r as gguiMountCanvas}` minified, or the plain\n * `const gguiMountCanvas`) and its string literal. Untrusted: `resolveMountFit` narrows it, and anything unread is `undefined`.\n */\nexport function mountCanvasOf(compiledCode: string): string | undefined {\n const name = GGUI_MOUNT_CANVAS_EXPORT;\n const binding = new RegExp(`([A-Za-z_$][\\\\w$]*)\\\\s+as\\\\s+${name}\\\\b`).exec(compiledCode)?.[1] ?? name;\n return new RegExp(`(?:^|[^\\\\w$.])${binding.replace(/\\$/g, '\\\\$')}\\\\s*=\\\\s*\"([^\"\\\\\\\\]*)\"`).exec(compiledCode)?.[1];\n}\n/** The `--ggui-*` custom properties a composed token block declares (the last declaration of a name wins, as in CSS). */\nfunction themeVarsOf(css: string): Readonly<Record<string, string>> {\n const vars: Record<string, string> = {};\n for (const [, name, value] of css.matchAll(/(--ggui-[\\w-]+)\\s*:\\s*([^;}]+)/g)) {\n if (name !== undefined && value !== undefined) vars[name] = value.trim();\n }\n return vars;\n}\ninterface CanvasFrame {\n readonly viewport: CanvasViewport;\n readonly policy: CanvasFitPolicy;\n /** How the runtime would compose this card on this canvas (`resolveMountFit`) — the capture and the frame statement follow it. */\n readonly mountFit: MountFit;\n readonly fit: 'fill' | undefined;\n /** The host stand-in drawn round the scope (ggui#1083 cut 3) — the window is padded by its gap; `viewport` stays the card's box. */\n readonly chrome: CanvasChrome;\n /** `true` when `canvasViewports` carried an entry for this canvas, whatever its value. */\n readonly declared: boolean;\n readonly attempt: ScreenshotAttempt;\n /** The capture's ink extent (ggui#1120); `null` when there is no capture or it could not be read. */\n readonly ink: InkExtent | null;\n /** ggui#1492 — what the judge did with this canvas's host presentation, when the caller supplied one. */\n readonly presentation?: CanvasPresentationOutcome;\n}\n/** The capture's ink extent (ggui#1120), read inside a drawn panel's chrome; an unreadable capture is reported, never blank. */\nfunction readInk(png: Buffer | null, chrome: CanvasChrome, canvas: CanvasClass, inlineInkInsetPx: number = JUDGE_INLINE_INK_INSET_PX): InkExtent | null {\n if (png === null) return null;\n const ink = readInkExtent(png, chrome === 'panel' ? JUDGE_INK_INSET_PX : chrome === 'ground' ? inlineInkInsetPx : 0);\n if ('reason' in ink) {\n console.warn(`[visual-eval] ink extent unreadable at canvas ${canvas}: ${ink.reason}`);\n return null;\n }\n return ink;\n}\n/** The deterministic blank verdict (ggui#1120): an issue when the frame read no ink at all; `null` otherwise, an unreadable capture included. */\nfunction blankVerdict(canvas: CanvasClass, frame: CanvasFrame): VisualIssue | null {\n // ggui#1475 — a naturally-captured card that measured no height painted nothing: its capture is only the host's frame,\n // which the ink reading skips by design, so the blank is read from the measurement, never mistaken for unreadable.\n if (frame.chrome === 'ground' && frame.attempt.contentHeight !== null && frame.attempt.contentHeight <= 0) {\n return canvasBlankIssue(canvas, frame.viewport);\n }\n return frame.ink !== null && frame.ink.lastInkRow === null ? canvasBlankIssue(canvas, frame.viewport) : null;\n}\n\nasync function frameCanvas(\n bundledCode: string,\n context: VisualEvalContext,\n canvas: CanvasClass,\n canvasViewports: VisualEvalConfig['canvasViewports'],\n deps: ScreenshotDeps,\n hostPresentations?: VisualEvalConfig['hostPresentations'],\n): Promise<CanvasFrame> {\n const declaredBox = canvasViewports?.[canvas];\n const viewport = declaredBox !== undefined ? integerBox(declaredBox) : CANVAS_VIEWPORTS[canvas];\n // The ONE fit rule the runtime serves by: the bundle's canvas export + the display mode this canvas stands for.\n const mountFit = resolveMountFit({ canvas: mountCanvasOf(context.compiledCode), displayMode: displayModeForCanvas(canvas) });\n // ggui#1953 — the fit decides the overflow posture: a framed card is a card, seen whole in its room, so a card that\n // cannot fit its pane fails the canvas as the inline card does (#1475), never scrolls as a page.\n const policy: CanvasFitPolicy = mountFit === 'framed-card' ? { capture: 'card-box', overflow: 'fail' } : canvasFitPolicy(canvas);\n const fit = mountFit === 'framed-card' ? undefined : canvasFit(canvas);\n const chrome = canvasChrome(canvas);\n const outcome = resolvePresentation(canvas, hostPresentations?.[canvas]);\n const presentation = outcome?.status === 'applied' ? outcome.applied : undefined;\n const geometry = inlineGeometry(presentation?.frame);\n const framedCardRadiusPx = mountFit === 'framed-card' ? inlineCardRadius(themeVarsOf(context.cssTokens ?? getCssTokens())).radiusPx : undefined;\n // Every canvas's page is composed by the one builder, from this canvas's fit, chrome and frame: a framed card on a\n // canvas with no chrome (the phone, ggui#1953) is still composed as the runtime serves it, never the plain page.\n const canvasHtml = buildRenderHTML(bundledCode, context.cssTokens, fit, chrome, presentation, framedCardRadiusPx);\n // ggui#1953 — a framed card is captured as a card, on its own box, at every canvas it is framed on.\n const capture: CaptureMode = policy.capture;\n const captured = await captureScreenshotDetailed(canvasHtml, judgeWindow(viewport, chrome, geometry.padPx), deps, capture, {\n padPx: geometry.padPx,\n ...(geometry.floorPx !== undefined ? { floorPx: geometry.floorPx } : {}),\n });\n // ggui#1083 cut 3 — on a panelled page the document is the panel plus its gap; every verdict reads the CARD's height.\n // A card-box capture already measured the card itself; only the full-page document carries the panel's gap.\n const attempt: ScreenshotAttempt = { ...captured, contentHeight: capture === 'card-box' ? captured.contentHeight : cardHeight(captured.contentHeight, chrome) };\n // A card-box frame has the inline card's geometry (margin, ring, corner), so its ink is read past the same inset.\n const cardBoxInk = JUDGE_GROUND_MARGIN_PX + JUDGE_INLINE_FRAME_BORDER_PX + (framedCardRadiusPx ?? JUDGE_INLINE_FRAME_RADIUS_PX);\n return {\n viewport, policy, mountFit, fit, chrome, declared: declaredBox !== undefined, attempt,\n ink: capture === 'card-box' ? readInk(captured.png, 'ground', canvas, cardBoxInk) : readInk(captured.png, chrome, canvas, geometry.inkInsetPx),\n ...(outcome !== undefined ? { presentation: outcome } : {}),\n };\n}\n\n/**\n * The box a frame's card must fit (ggui#1953): the canvas box, except for a framed card, which sits in its pane with\n * the frame's gap above and below — so its ceiling is the pane less that gap on both sides (704 in a 736 pane).\n */\nexport function fitCeiling(frame: Pick<CanvasFrame, 'viewport' | 'mountFit'>): { width: number; height: number } {\n return frame.mountFit === 'framed-card'\n ? { width: frame.viewport.width, height: frame.viewport.height - 2 * EXPANDED_FRAME.insetPx }\n : frame.viewport;\n}\n\n/**\n * The deterministic fit verdict on one frame (ggui#1027): the issue the\n * canvas's policy gives an overflow, or `null` when the content fits, could\n * not be measured, or the canvas scrolls by design.\n */\nfunction fitVerdict(canvas: CanvasClass, frame: CanvasFrame): VisualIssue | null {\n const contentHeight = frame.attempt.contentHeight;\n const ceiling = fitCeiling(frame);\n if (contentHeight === null || contentHeight <= ceiling.height || frame.policy.overflow === 'none') return null;\n return canvasOverflowIssue(canvas, ceiling, contentHeight, frame.policy.overflow);\n}\n\n/**\n * ggui#1475 — the deterministic horizontal verdict on a natural capture: the card's content runs past its width. It\n * is judged by the canvas's own fit policy (the inline card: a critical that fails the canvas), in its own dimension,\n * so the in-loop `[fit]` extension (vertical overflow) is unchanged.\n */\nfunction overflowXVerdict(canvas: CanvasClass, frame: CanvasFrame): VisualIssue | null {\n const px = frame.attempt.overflowX;\n // `scrollWidth` / `clientWidth` are rounded integers: a fractional layout width reads as 1 px past the card with\n // nothing a visitor could see, so 1 px is rounding and an overflow starts at 2.\n if (px === undefined || px === null || px <= OVERFLOW_X_ROUNDING_PX || frame.policy.overflow === 'none') return null;\n return canvasOverflowXIssue(canvas, frame.viewport, px, frame.policy.overflow);\n}\n\n/** One judge call parsed, retried ONCE on a malformed answer (#1017); the FIRST reason is kept verbatim. */\ntype JudgedAnswer =\n | {\n readonly kind: 'ok';\n readonly result: EvaluationResult;\n readonly inputTokens: number;\n readonly outputTokens: number;\n /** ggui#1127 — present when the answer did not parse and its score was salvaged. */\n readonly salvage?: JudgeSalvage;\n /** ggui#1687 — the provider's stop reason and the model it says answered; each absent when unreported. */\n readonly finishReason?: VisionFinishReason;\n readonly servedModel?: string;\n }\n | { readonly kind: 'unparsable'; readonly reason: string };\n\n/** ggui#1127 — what a salvaged answer leaves on the record: why, and where the parse broke. Never the answer's text. */\ninterface JudgeSalvage {\n readonly cause: JudgeSalvageCause;\n /** The provider's normalized stop reason; absent when it reported none. */\n readonly finishReason?: VisionFinishReason;\n /** The parser's error, with every quoted span of the answer removed. */\n readonly parseError: string;\n /** Where the parse broke, as a character offset into the answer, when the parser said. */\n readonly offset?: number;\n /** The answer's length in characters: an offset at the end reads as a cut, one mid-answer as malformed. */\n readonly chars: number;\n}\n\n/**\n * ggui#1127 — why an unparsable answer was salvaged. The cause comes from the provider's stop reason, never from the\n * answer's length: a short answer can still be cut (thinking spends the cap), and a long one can still be malformed.\n */\nfunction judgeSalvageOf(error: unknown, text: string, finishReason: VisionFinishReason | undefined): JudgeSalvage {\n const cause: JudgeSalvageCause =\n finishReason === undefined ? 'unknown' : finishReason === 'length' ? 'output-cap' : finishReason === 'stop' ? 'malformed' : 'stopped';\n const message = error instanceof Error ? error.message : String(error);\n // The JSON is parsed from the first `{` (parseVisualResponse), so the parser's position is shifted by that start.\n const position = /position (\\d+)/.exec(message);\n const start = text.indexOf('{');\n const offset = position !== null ? (start > 0 ? start : 0) + Number(position[1]) : undefined;\n const parseError = message.startsWith('Visual evaluator did not return valid JSON')\n ? 'no complete JSON object in the answer'\n : message.replace(/\"(?:[^\"\\\\]|\\\\.)*\"/g, '\"…\"').slice(0, 160);\n return { cause, ...(finishReason !== undefined ? { finishReason } : {}), parseError, ...(offset !== undefined ? { offset } : {}), chars: text.length };\n}\n\n/** ggui#1127 — a canvas's judge record: the K samples, and which of them (and the criteria call) were salvaged. */\nfunction judgeRecordOf(\n k: number,\n parsed: readonly Extract<JudgedAnswer, { kind: 'ok' }>[],\n samples: number[],\n criteria: JudgedAnswer | undefined,\n requestedModel: string,\n): CanvasJudgeRecord {\n const salvaged = parsed.flatMap((a) => (a.salvage !== undefined ? [a.salvage.cause] : []));\n // ggui#1687 — every model the provider said answered, scoring and criteria, deduplicated in call order.\n const answered = [...parsed, ...(criteria?.kind === 'ok' ? [criteria] : [])];\n const served = [...new Set(answered.flatMap((a) => (a.servedModel !== undefined ? [a.servedModel] : [])))];\n const criteriaSalvaged = criteria?.kind === 'ok' ? criteria.salvage?.cause : undefined;\n return {\n k,\n rule: 'median',\n samples,\n sigma: populationSigma(samples),\n notes: parsed.map((a) => a.result.critique ?? ''),\n ...(salvaged.length > 0 ? { salvaged } : {}),\n ...(criteriaSalvaged !== undefined ? { criteriaSalvaged } : {}),\n models: { requested: requestedModel, served },\n };\n}\n\n/** ggui#1687 — what one call's response says about itself: its stop reason and the model that answered. */\nfunction callFacts(response: { readonly finishReason?: VisionFinishReason; readonly servedModel?: string }): {\n finishReason?: VisionFinishReason;\n servedModel?: string;\n} {\n return {\n ...(response.finishReason !== undefined ? { finishReason: response.finishReason } : {}),\n ...(response.servedModel !== undefined ? { servedModel: response.servedModel } : {}),\n };\n}\n\nconst NO_CRITERIA_ARRAY: CriteriaAnswerCounts = { array: false, received: 0, kept: 0, dropped: { notObject: 0, badId: 0, badVerdict: 0 } };\n\n/** ggui#1687 — the criteria call as it came back, for the block: its answer's counts and its stop reason. */\nfunction criteriaCallOf(criteria: JudgedAnswer | undefined): { call?: { answer: CriteriaAnswerCounts; finishReason?: VisionFinishReason } } {\n if (criteria?.kind !== 'ok') return {};\n const answer = criteria.result.criteriaCounts ?? NO_CRITERIA_ARRAY;\n return { call: { answer, ...(criteria.finishReason !== undefined ? { finishReason: criteria.finishReason } : {}) } };\n}\n\n/**\n * ggui#1436 — the criteria are REPORT-ONLY, so they are never asked inside a call whose score binds. The K\n * scoring calls go out exactly as they did before the block existed (the same user turn, byte for byte); when a\n * block was selected, the criteria get ONE call of their own on the same frame, run beside them, and that call's\n * score is discarded. Its spend is reported apart (`criteriaTokens`), never inside the scoring calls' tokens, so a\n * cost read off the judgement is the judgement's alone. Asked inside the scoring call, the block moved the score it\n * sat beside — the first release that carried it into a served judge lowered first-attempt scores on the same kind\n * of card (ggui#1436). One read, not K: the block binds on nothing, and a second K would double its calls.\n */\nasync function judgeFrame(\n judge: typeof callMultimodalLLM,\n config: VisualEvalConfig,\n model: string,\n png: Buffer,\n originalPrompt: string,\n profileBlock: string,\n canvas: CanvasClass,\n k: number,\n criteriaBlock: string,\n): Promise<{ readonly scoring: readonly JudgedAnswer[]; readonly criteria: JudgedAnswer | undefined }> {\n const [scoring, criteria] = await Promise.all([\n Promise.all(Array.from({ length: k }, () => judgeAndParse(judge, config, model, png, originalPrompt, profileBlock, canvas))),\n criteriaBlock.length > 0 ? judgeAndParse(judge, config, model, png, originalPrompt, profileBlock, canvas, criteriaBlock) : undefined,\n ]);\n return { scoring, criteria };\n}\n\n/** What the frame's criteria call spent, when it was asked and answered — reported apart from the scoring calls. */\nfunction criteriaCallTokens(criteria: JudgedAnswer | undefined): CriteriaCallTokens | undefined {\n return criteria?.kind === 'ok' ? { inputTokens: criteria.inputTokens, outputTokens: criteria.outputTokens } : undefined;\n}\n\n/** The criteria call's answers, as the one read the block resolves; none when it was not asked or did not parse. */\nfunction criteriaReads(criteria: JudgedAnswer | undefined): CriteriaAnswer[][] {\n // ggui#1127 — a salvaged answer keeps no criteria: it is no read, and its rows say why (criteriaUnansweredReason).\n return criteria?.kind === 'ok' && criteria.salvage === undefined ? [criteria.result.criteriaAnswers ?? []] : [];\n}\n\n/** ggui#1127 — the reason a salvaged criteria answer's judge rows give, so none reads as a clean `n/a`. */\nfunction criteriaUnansweredReason(criteria: JudgedAnswer | undefined): { unansweredReason?: string } {\n return criteria?.kind === 'ok' && criteria.salvage !== undefined\n ? { unansweredReason: `not answered: the criteria answer was salvaged (${criteria.salvage.cause})` }\n : {};\n}\n\n/** How many vision calls this canvas gets (ggui#1072): `judgeK` when the canvas is sampled, else 1. */\nfunction judgeCountFor(config: VisualEvalConfig, canvas: CanvasClass): number {\n const k = Math.max(1, Math.floor(config.judgeK ?? 1));\n if (k === 1) return 1;\n return config.judgeKCanvases === undefined || config.judgeKCanvases.includes(canvas) ? k : 1;\n}\n\n/** The median of a non-empty list — the lower middle for an even count, so the decision is always one judge's number. */\nfunction medianOf(values: readonly number[]): number {\n const sorted = [...values].sort((a, b) => a - b);\n return sorted[Math.floor((sorted.length - 1) / 2)]!;\n}\n\n/** Population σ, rounded to one decimal; 0 for one sample. */\nfunction populationSigma(values: readonly number[]): number {\n if (values.length < 2) return 0;\n const mean = values.reduce((a, b) => a + b, 0) / values.length;\n const variance = values.reduce((a, b) => a + (b - mean) ** 2, 0) / values.length;\n return Math.round(Math.sqrt(variance) * 10) / 10;\n}\n\nasync function judgeAndParse(\n judge: typeof callMultimodalLLM,\n config: VisualEvalConfig,\n model: string,\n screenshot: Buffer,\n originalPrompt: string,\n profileBlock: string,\n canvas?: CanvasClass,\n criteriaBlock = '',\n): Promise<JudgedAnswer> {\n let firstReason: string | undefined;\n for (let attempt = 1; attempt <= 2; attempt++) {\n const response = await judge(config, model, VISUAL_EVAL_PROMPT, screenshot, originalPrompt, profileBlock, criteriaBlock);\n try {\n const result = parseVisualResponse(response.text, config.passThreshold);\n return { kind: 'ok', result, inputTokens: response.inputTokens, outputTokens: response.outputTokens, ...callFacts(response) };\n } catch (e) {\n // An answer that fails to parse but whose four dimensions closed is SALVAGED (ggui#1127): they are emitted\n // before `issues`, so the score is recoverable from the closed prefix. Whether it was cut at the output cap or\n // ended malformed is the provider's stop reason to say, not the answer's length; the record and the warn\n // line carry the cause, the parse error and where it broke, never the answer's text. One token per leg.\n const salvaged = salvageTruncatedVisualAnswer(response.text, config.passThreshold);\n if (salvaged !== null) {\n const salvage = judgeSalvageOf(e, response.text, response.finishReason);\n const token = criteriaBlock.length > 0 ? 'visual_criteria_salvaged' : 'visual_judge_salvaged';\n console.warn(\n `[visual-eval] ${token}${canvas ? ` canvas=${canvas}` : ''} cause=${salvage.cause} finish=${salvage.finishReason ?? 'unreported'} ` +\n `at=${salvage.offset ?? '?'}/${salvage.chars} (${salvage.parseError}): score recovered from the closed prefix, issues list partial`,\n );\n return { kind: 'ok', result: salvaged, inputTokens: response.inputTokens, outputTokens: response.outputTokens, salvage, ...callFacts(response) };\n }\n const reason = `judge answer unparsable: ${e instanceof Error ? e.message : String(e)}`;\n if (attempt === 1) {\n firstReason = reason;\n console.warn(`[visual-eval] visual_judge_retry${canvas ? ` canvas=${canvas}` : ''}: ${reason}`);\n } else {\n console.warn(`[visual-eval] visual_judge_retry failed again${canvas ? ` canvas=${canvas}` : ''}: ${reason}`);\n }\n }\n }\n return { kind: 'unparsable', reason: firstReason ?? 'judge answer unparsable' };\n}\n\nexport async function runVisualEvaluation(\n context: VisualEvalContext,\n config: VisualEvalConfig,\n deps: VisualEvalDeps = {},\n): Promise<VisualEvaluationResult | null> {\n return (await runVisualEvaluationDetailed(context, config, deps)).result;\n}\n\nexport async function runVisualEvaluationDetailed(\n context: VisualEvalContext,\n config: VisualEvalConfig,\n deps: VisualEvalDeps = {},\n): Promise<VisualEvalDetailed> {\n const startTime = Date.now();\n const judge = deps.judge ?? callMultimodalLLM;\n // ggui#1042: the design tree is an input and a part of the judgement's identity.\n const designSrc = config.designSrcDir ?? resolve(resolveDesignPackageDir(), 'src');\n const design = judgeDesignIdentity(designSrc);\n const stamp = <T extends VisualEvaluationResult>(r: T): T => ({\n ...r,\n ...(design !== null ? { design } : {}),\n ...(config.themeMode !== undefined ? { themeMode: config.themeMode } : {}),\n });\n\n // Bundle component + design system into a single JS file\n let bundledCode: string;\n try {\n bundledCode = await bundleForRendering(context.compiledCode, config.sampleProps ?? {}, designSrc);\n } catch (e) {\n const unavailableReason = `bundle failed: ${e instanceof Error ? e.message : String(e)}`;\n console.warn(`[visual-eval] ${unavailableReason}`);\n return { result: null, unavailableReason };\n }\n console.log(`[visual-eval] bundled: ${bundledCode.length}B (${Date.now() - startTime}ms)`);\n\n // Build the HTML page — ONE shell; per-canvas mode re-renders it at each viewport.\n const html = buildRenderHTML(bundledCode, context.cssTokens);\n const model = config.model ?? getDefaultVisualModel(config.provider);\n\n // ── Per-canvas mode: one screenshot + one judge call per class ──\n if (config.canvases !== undefined && config.canvases.length > 0) {\n const perCanvas: CanvasVisualResult[] = [];\n const perCanvasResults: EvaluationResult[] = [];\n for (const canvas of config.canvases) {\n const frame = await frameCanvas(bundledCode, context, canvas, config.canvasViewports, deps, config.hostPresentations);\n const { viewport, policy, fit, attempt } = frame;\n const screenshot = attempt.png;\n if (!screenshot) {\n const unavailableReason = attempt.reason ?? 'no browser available';\n console.warn(`[visual-eval] ${unavailableReason} at canvas ${canvas} — skipping visual evaluation`);\n return { result: null, unavailableReason, canvas };\n }\n // ggui#1072: k vision calls on the SAME frame; the decision value is the median.\n const k = judgeCountFor(config, canvas);\n const profileBlock = buildStylingProfileJudgeBlock(context.profile);\n // ggui#1436 — the selection is decided BEFORE the judge runs and recorded with the verdict.\n const criteriaContext: CriteriaContext | undefined =\n context.criteria !== undefined ? { ...context.criteria.context, canvas } : undefined;\n const criteriaSelected =\n context.criteria !== undefined && criteriaContext !== undefined ? selectCriteria(context.criteria.bank, criteriaContext) : undefined;\n const criteriaBlock =\n context.criteria !== undefined && criteriaSelected !== undefined\n ? buildCriteriaJudgeBlock(context.criteria.bank, criteriaSelected, {\n frame: { canvas, width: viewport.width, height: viewport.height, fit: frame.mountFit, ...(frame.presentation?.status === 'applied' ? { hostLabel: frame.presentation.applied.label } : {}) },\n ...(config.sampleProps !== undefined ? { propsJson: JSON.stringify(config.sampleProps) } : {}),\n })\n : '';\n const { scoring: answers, criteria: criteriaAnswer } = await judgeFrame(\n judge, config, model, screenshot, context.originalPrompt, profileBlock, canvas, k, criteriaBlock,\n );\n const parsed = answers.filter((a): a is Extract<JudgedAnswer, { kind: 'ok' }> => a.kind === 'ok');\n if (parsed.length === 0) {\n const first = answers.find((a): a is Extract<JudgedAnswer, { kind: 'unparsable' }> => a.kind === 'unparsable');\n return { result: null, unavailableReason: first?.reason ?? 'judge answer unparsable', canvas };\n }\n const samples = parsed.map((a) => a.result.finalScore);\n const median = medianOf(samples);\n const representative = parsed[samples.indexOf(median)]!;\n const result = representative.result;\n result.finalScore = median;\n result.passed = median >= config.passThreshold;\n result.inputTokens = parsed.reduce((sum, a) => sum + a.inputTokens, 0);\n result.outputTokens = parsed.reduce((sum, a) => sum + a.outputTokens, 0);\n const response = { inputTokens: result.inputTokens, outputTokens: result.outputTokens };\n const criteriaTokens = criteriaCallTokens(criteriaAnswer);\n const judgeRecord = judgeRecordOf(k, parsed, samples, criteriaAnswer, model);\n // The fit verdict (ggui#1027): deterministic, in the judge's issue channel.\n const contentHeight = attempt.contentHeight;\n const overflow = contentHeight !== null && contentHeight > viewport.height;\n const fitIssue = fitVerdict(canvas, frame);\n if (fitIssue !== null) {\n result.issues.push(fitIssue);\n if (policy.overflow === 'fail') result.passed = false;\n }\n const overflowXIssue = overflowXVerdict(canvas, frame);\n if (overflowXIssue !== null) {\n result.issues.push(overflowXIssue);\n if (policy.overflow === 'fail') result.passed = false;\n }\n // The blank verdict (ggui#1120): deterministic, critical on every canvas — a render that painted nothing fails.\n const blankIssue = blankVerdict(canvas, frame);\n if (blankIssue !== null) {\n result.issues.push(blankIssue);\n result.passed = false;\n }\n const inkRatio = frame.ink?.ratio ?? null;\n // ggui#1436 — the block: the criteria call's read, the instruments' measurements, report-only.\n const criteria: CriteriaBlock | undefined =\n context.criteria !== undefined && criteriaContext !== undefined && criteriaSelected !== undefined\n ? resolveCriteriaBlock({\n bank: context.criteria.bank,\n context: criteriaContext,\n selected: criteriaSelected,\n answers: criteriaReads(criteriaAnswer),\n measurements: { overflow, contentHeight, viewportHeight: viewport.height, inkRatio, edge: attempt.edge ?? null, edgeV2: attempt.edgeV2 ?? null },\n ...criteriaUnansweredReason(criteriaAnswer),\n ...criteriaCallOf(criteriaAnswer),\n })\n : undefined;\n perCanvasResults.push(result);\n perCanvas.push({\n canvas,\n viewport,\n score: result.finalScore,\n passed: result.passed,\n screenshotPng: screenshot,\n contentHeight,\n overflow,\n inkRatio,\n judge: judgeRecord,\n ...(fit !== undefined ? { fit } : {}),\n ...(frame.declared ? { declared: true as const } : {}),\n ...(criteria !== undefined ? { criteria } : {}),\n ...(criteriaTokens !== undefined ? { criteriaTokens } : {}),\n ...(frame.presentation !== undefined ? { presentation: frame.presentation } : {}),\n });\n console.log(\n `[visual-eval] canvas=${canvas} ${viewport.width}×${viewport.height} score=${result.finalScore}${k > 1 ? ` (median of ${judgeRecord.samples.length}/${k}: ${judgeRecord.samples.join(',')} σ=${judgeRecord.sigma})` : ''} ` +\n `${result.passed ? 'pass' : 'FAIL'} | content=${contentHeight ?? '?'}px${overflow ? ` OVERFLOW (${policy.overflow})` : ''} ` +\n `ink=${inkRatio ?? '?'}${blankIssue !== null ? ' BLANK' : ''} ` +\n `| in=${response.inputTokens} out=${response.outputTokens}` +\n (criteriaTokens !== undefined ? ` | criteria in=${criteriaTokens.inputTokens} out=${criteriaTokens.outputTokens}` : ''),\n );\n }\n const aggregate = aggregateCanvasResults(perCanvas, perCanvasResults);\n const elapsed = Date.now() - startTime;\n console.log(\n `[visual-eval] score=${aggregate.finalScore} (mean of ${perCanvas.length} canvases; ` +\n `${aggregate.passed ? 'every canvas passed' : `${perCanvas.filter((c) => !c.passed).length} failed`}) (${elapsed}ms)`,\n );\n return { result: stamp(aggregate) };\n }\n\n // ── Single-shot mode (today's path) ──\n const attempt = await captureScreenshotDetailed(html, config.viewport, deps);\n const screenshot = attempt.png;\n if (!screenshot) {\n const unavailableReason = attempt.reason ?? 'no browser available';\n console.warn(`[visual-eval] ${unavailableReason} — skipping visual evaluation`);\n return { result: null, unavailableReason };\n }\n console.log(`[visual-eval] screenshot: ${screenshot.length}B (${Date.now() - startTime}ms)`);\n\n // Send to multimodal LLM (one retry on a malformed answer — #1017)\n const answer = await judgeAndParse(\n judge,\n config,\n model,\n screenshot,\n context.originalPrompt,\n buildStylingProfileJudgeBlock(context.profile),\n );\n if (answer.kind === 'unparsable') {\n return { result: null, unavailableReason: answer.reason };\n }\n const result = answer.result;\n result.inputTokens = answer.inputTokens;\n result.outputTokens = answer.outputTokens;\n const response = { inputTokens: answer.inputTokens, outputTokens: answer.outputTokens };\n\n const elapsed = Date.now() - startTime;\n console.log(`[visual-eval] score=${result.finalScore} (${elapsed}ms) | in=${response.inputTokens} out=${response.outputTokens}`);\n\n return { result: stamp(result) };\n}\n\n/**\n * Fold per-canvas verdicts into the single-shot fields: `finalScore` =\n * rounded mean, `passed` = every canvas passed, `dimensions` = rounded\n * per-dimension means, `issues` = union (description prefixed with the\n * canvas), `critique` = one line per canvas, tokens summed.\n */\n/** A canvas's issue as the aggregate carries it: the description prefixed `[<canvas>]`. */\nfunction canvasScopedIssue(canvas: CanvasClass, issue: EvaluationIssue): EvaluationIssue {\n return { ...issue, description: `[${canvas}] ${issue.description}` };\n}\n\nfunction aggregateCanvasResults(\n perCanvas: readonly CanvasVisualResult[],\n results: readonly EvaluationResult[],\n): VisualEvaluationResult {\n const n = results.length;\n const mean = (pick: (r: EvaluationResult) => number): number =>\n Math.round(results.reduce((sum, r) => sum + pick(r), 0) / n);\n const dimensions: DimensionScores = {\n completeness: mean((r) => r.dimensions.completeness),\n visualPolish: mean((r) => r.dimensions.visualPolish),\n interactivity: mean((r) => r.dimensions.interactivity),\n accessibility: mean((r) => r.dimensions.accessibility),\n codeQuality: mean((r) => r.dimensions.codeQuality),\n };\n const issues: EvaluationIssue[] = [];\n const critiques: string[] = [];\n let inputTokens = 0;\n let outputTokens = 0;\n results.forEach((r, i) => {\n const canvas = perCanvas[i]!.canvas;\n for (const issue of r.issues) issues.push(canvasScopedIssue(canvas, issue));\n if (r.critique) critiques.push(`${canvas}: ${r.critique}`);\n inputTokens += r.inputTokens ?? 0;\n outputTokens += r.outputTokens ?? 0;\n });\n const criteriaSpent = perCanvas.flatMap((c) => (c.criteriaTokens !== undefined ? [c.criteriaTokens] : []));\n // ggui#1127 — N of M per leg. A criteria call that parsed or was salvaged reports its spend, so `criteriaTokens`\n // marks an answered call.\n const judgeSalvage: JudgeSalvageCounts = {\n scoring: {\n salvaged: perCanvas.reduce((sum, c) => sum + (c.judge.salvaged?.length ?? 0), 0),\n answers: perCanvas.reduce((sum, c) => sum + c.judge.samples.length, 0),\n },\n criteria: {\n salvaged: perCanvas.filter((c) => c.judge.criteriaSalvaged !== undefined).length,\n answered: perCanvas.filter((c) => c.criteriaTokens !== undefined).length,\n },\n };\n return {\n judgeSalvage,\n passed: perCanvas.every((c) => c.passed),\n finalScore: mean((r) => r.finalScore),\n dimensions,\n issues,\n ...(critiques.length > 0 ? { critique: critiques.join('\\n') } : {}),\n inputTokens,\n outputTokens,\n ...(criteriaSpent.length > 0\n ? {\n criteriaTokens: {\n inputTokens: criteriaSpent.reduce((sum, t) => sum + t.inputTokens, 0),\n outputTokens: criteriaSpent.reduce((sum, t) => sum + t.outputTokens, 0),\n },\n }\n : {}),\n canvases: [...perCanvas],\n };\n}\n\n/** The per-canvas verdicts without the PNGs — what the harness stamps on `EvalResult.visual`. */\nexport function summarizeVisualResult(result: VisualEvaluationResult): VisualEvalSummary | undefined {\n if (result.canvases === undefined) return undefined;\n const canvases: CanvasVisualSummary[] = result.canvases.map((c) => ({\n canvas: c.canvas,\n viewport: c.viewport,\n score: c.score,\n passed: c.passed,\n contentHeight: c.contentHeight,\n overflow: c.overflow,\n inkRatio: c.inkRatio,\n judge: c.judge,\n ...(c.fit !== undefined ? { fit: c.fit } : {}),\n ...(c.criteria !== undefined ? { criteria: c.criteria } : {}),\n ...(c.presentation !== undefined ? { presentation: c.presentation } : {}),\n }));\n // ggui#1436 — the roll-up: ids failed / unreadable across canvases, deduped; a must at n/a is listed, never passed.\n const blocks = result.canvases.map((c) => c.criteria).filter((b): b is CriteriaBlock => b !== undefined);\n const idsWhere = (severity: 'must' | 'should', verdict: 'fail' | 'n/a'): string[] => [\n ...new Set(blocks.flatMap((b) => b.verdicts.filter((v) => v.severity === severity && v.verdict === verdict).map((v) => v.id))),\n ];\n const rollup: CriteriaRollup | undefined =\n blocks.length > 0 ? { mustFailed: idsWhere('must', 'fail'), shouldFailed: idsWhere('should', 'fail'), mustNa: idsWhere('must', 'n/a') } : undefined;\n // ggui#1195 — the fit stamp: the first canvas whose policy FAILS an\n // overflow (the inline card), judged with a measurable height.\n const fitCanvas = result.canvases.find((c) => canvasFitPolicy(c.canvas).overflow === 'fail' && c.contentHeight !== null);\n const fit: VisualFitStamp | undefined =\n fitCanvas !== undefined && fitCanvas.contentHeight !== null\n ? {\n canvas: fitCanvas.canvas,\n ceiling: { width: fitCanvas.viewport.width, height: fitCanvas.viewport.height },\n // Declared = the order carried a box, even one equal to the class box (the review's point).\n declared: fitCanvas.declared === true,\n overflowPx: Math.max(0, fitCanvas.contentHeight - fitCanvas.viewport.height),\n }\n : undefined;\n return {\n score: result.finalScore,\n passed: result.passed,\n canvases,\n ...(fit !== undefined ? { fit } : {}),\n ...(result.design !== undefined ? { design: result.design } : {}),\n ...(result.themeMode !== undefined ? { themeMode: result.themeMode } : {}),\n ...(rollup !== undefined ? { criteria: rollup } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// A stored capture, judged (ggui#1438)\n// ---------------------------------------------------------------------------\n\n/** One stored capture to judge: the frame the judge saw at capture time, plus what the capture measured. */\nexport interface StoredCaptureInput {\n /** How the stored capture was composed. Absent ⇒ the canvas's composition before mount fits existed (`fill` on a fullscreen canvas, else `card`). */\n readonly mountFit?: MountFit;\n readonly canvas: CanvasClass;\n /** The capture as saved (`canvas-<class>.png`). */\n readonly png: Buffer;\n /** The box the capture was taken at — the class box, or the declared one. */\n readonly viewport: CanvasViewport;\n /** The document's scroll height the capture recorded; `null` when it did not. */\n readonly contentHeight: number | null;\n readonly originalPrompt: string;\n readonly profile?: GenerationProfileInput;\n /** ggui#1436 — the bank and the card's context; absent = today's judge, no block. */\n readonly criteria?: { readonly bank: CriteriaBank; readonly context: CriteriaContextInput };\n /** The props the capture was rendered with — handed to the criteria block for the rows whose evidence names props. */\n readonly sampleProps?: JsonObject;\n}\n\nexport interface StoredCaptureVerdict {\n readonly canvas: CanvasClass;\n readonly viewport: CanvasViewport;\n readonly score: number;\n readonly passed: boolean;\n readonly issues: EvaluationIssue[];\n readonly judge: CanvasJudgeRecord;\n readonly contentHeight: number | null;\n readonly overflow: boolean;\n readonly inkRatio: number | null;\n readonly criteria?: CriteriaBlock;\n /** The scoring calls' spend. */\n readonly inputTokens: number;\n readonly outputTokens: number;\n /** ggui#1436 — the report-only criteria call's spend, apart from the scoring calls'; absent when none was asked or answered. */\n readonly criteriaTokens?: CriteriaCallTokens;\n}\n\nexport type StoredCaptureOutcome =\n | { readonly kind: 'ok'; readonly verdict: StoredCaptureVerdict }\n | { readonly kind: 'unavailable'; readonly reason: string };\n\n/**\n * Judge a STORED capture exactly as the per-canvas leg judges a fresh one — the same K scoring calls on the\n * same frame, the same median, the same fit and blank verdicts, the same report-only criteria call — without\n * rendering.\n * This is the calibration's path (ggui#1438): the frame his eye marks is the frame the judge saw, and a\n * re-judge costs judge tokens only. Fit reads the capture's recorded `contentHeight`; ink is read off the\n * PNG inside the canvas's chrome, as at capture.\n */\nexport async function judgeStoredCapture(\n input: StoredCaptureInput,\n config: VisualEvalConfig,\n deps: Pick<VisualEvalDeps, 'judge'> = {},\n): Promise<StoredCaptureOutcome> {\n const judge = deps.judge ?? callMultimodalLLM;\n const model = config.model ?? getDefaultVisualModel(config.provider);\n const { canvas, viewport, png } = input;\n const chrome = canvasChrome(canvas);\n const ink = readInk(png, chrome, canvas);\n const inkRatio = ink?.ratio ?? null;\n const k = judgeCountFor(config, canvas);\n const profileBlock = buildStylingProfileJudgeBlock(input.profile);\n const criteriaContext: CriteriaContext | undefined = input.criteria !== undefined ? { ...input.criteria.context, canvas } : undefined;\n const criteriaSelected =\n input.criteria !== undefined && criteriaContext !== undefined ? selectCriteria(input.criteria.bank, criteriaContext) : undefined;\n const criteriaBlock =\n input.criteria !== undefined && criteriaSelected !== undefined\n ? buildCriteriaJudgeBlock(input.criteria.bank, criteriaSelected, {\n frame: { canvas, width: viewport.width, height: viewport.height, fit: input.mountFit ?? (canvasFit(canvas) === 'fill' ? 'fill' : 'card') },\n ...(input.sampleProps !== undefined ? { propsJson: JSON.stringify(input.sampleProps) } : {}),\n })\n : '';\n const { scoring: answers, criteria: criteriaAnswer } = await judgeFrame(judge, config, model, png, input.originalPrompt, profileBlock, canvas, k, criteriaBlock);\n const parsed = answers.filter((a): a is Extract<JudgedAnswer, { kind: 'ok' }> => a.kind === 'ok');\n if (parsed.length === 0) {\n const first = answers.find((a): a is Extract<JudgedAnswer, { kind: 'unparsable' }> => a.kind === 'unparsable');\n return { kind: 'unavailable', reason: first?.reason ?? 'judge answer unparsable' };\n }\n const samples = parsed.map((a) => a.result.finalScore);\n const median = medianOf(samples);\n const result = parsed[samples.indexOf(median)]!.result;\n const issues = [...result.issues];\n let passed = median >= config.passThreshold;\n const contentHeight = input.contentHeight;\n const overflow = contentHeight !== null && contentHeight > viewport.height;\n const policy = canvasFitPolicy(canvas);\n if (overflow && contentHeight !== null && policy.overflow !== 'none') {\n issues.push(canvasOverflowIssue(canvas, viewport, contentHeight, policy.overflow));\n if (policy.overflow === 'fail') passed = false;\n }\n if (ink !== null && ink.lastInkRow === null) {\n issues.push(canvasBlankIssue(canvas, viewport));\n passed = false;\n }\n const criteria: CriteriaBlock | undefined =\n input.criteria !== undefined && criteriaContext !== undefined && criteriaSelected !== undefined\n ? resolveCriteriaBlock({\n bank: input.criteria.bank,\n context: criteriaContext,\n selected: criteriaSelected,\n answers: criteriaReads(criteriaAnswer),\n measurements: { overflow, contentHeight, viewportHeight: viewport.height, inkRatio },\n ...criteriaUnansweredReason(criteriaAnswer),\n ...criteriaCallOf(criteriaAnswer),\n })\n : undefined;\n const criteriaTokens = criteriaCallTokens(criteriaAnswer);\n return {\n kind: 'ok',\n verdict: {\n canvas,\n viewport,\n score: median,\n passed,\n issues,\n judge: judgeRecordOf(k, parsed, samples, criteriaAnswer, model),\n contentHeight,\n overflow,\n inkRatio,\n ...(criteria !== undefined ? { criteria } : {}),\n inputTokens: parsed.reduce((sum, a) => sum + a.inputTokens, 0),\n outputTokens: parsed.reduce((sum, a) => sum + a.outputTokens, 0),\n ...(criteriaTokens !== undefined ? { criteriaTokens } : {}),\n },\n };\n}\n\n/**\n * Exported for testing — bundles and builds the HTML for rendering;\n * `callMultimodalLLM` so the #504 routing contract (config →\n * `createVisionAgent`) is assertable without a screenshot pipeline.\n */\nexport { bundleForRendering, buildRenderHTML, callMultimodalLLM };\n\n// ---------------------------------------------------------------------------\n// Response parsing\n// ---------------------------------------------------------------------------\n\n/**\n * Recover a judge answer cut off inside its `issues` array: all four\n * dimensions must be present in the prefix (else null); issue objects\n * that closed are kept; `critique` (emitted last) is usually lost and is\n * replaced by a truncation note so the receipt says what happened.\n */\nexport function salvageTruncatedVisualAnswer(text: string, passThreshold: number): EvaluationResult | null {\n const dim = (name: string): number | null => {\n const m = text.match(new RegExp(`\"${name}\"\\\\s*:\\\\s*(\\\\d+(?:\\\\.\\\\d+)?)`));\n return m ? Number(m[1]) : null;\n };\n const completeness = dim('completeness');\n const layout = dim('layout');\n const hierarchy = dim('hierarchy');\n const aesthetics = dim('aesthetics');\n if (completeness === null || layout === null || hierarchy === null || aesthetics === null) return null;\n const issues: Array<{ dimension: string; severity: string; description: string; fix: string }> = [];\n const issuesAt = text.indexOf('\"issues\"');\n if (issuesAt >= 0) {\n for (const m of text.slice(issuesAt).matchAll(/\\{[^{}]*\\}/g)) {\n try {\n const o = JSON.parse(m[0]) as { dimension?: unknown; severity?: unknown; description?: unknown; fix?: unknown };\n if (typeof o.description === 'string') {\n issues.push({\n dimension: typeof o.dimension === 'string' ? o.dimension : 'layout',\n severity: typeof o.severity === 'string' ? o.severity : 'minor',\n description: o.description,\n fix: typeof o.fix === 'string' ? o.fix : '',\n });\n }\n } catch {\n // an unclosed object at the cut — skipped by construction\n }\n }\n }\n const rebuilt = JSON.stringify({\n completeness,\n layout,\n hierarchy,\n aesthetics,\n issues,\n critique: `[salvaged judge answer — it did not parse; score recovered from the closed prefix; ${issues.length} issue(s) kept, the rest and the critique lost]`,\n });\n return parseVisualResponse(rebuilt, passThreshold);\n}\n\nfunction parseVisualResponse(text: string, passThreshold: number): EvaluationResult {\n const jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\n if (!jsonMatch) {\n throw new Error('Visual evaluator did not return valid JSON: ' + text.slice(0, 200));\n }\n\n const raw = JSON.parse(jsonMatch[0]);\n\n // Visual dimensions (equal weights now)\n const completeness = raw.completeness ?? 0;\n const layout = raw.layout ?? 0;\n const hierarchy = raw.hierarchy ?? 0;\n const aesthetics = raw.aesthetics ?? 0;\n\n // Weighted average\n const finalScore = Math.round(\n completeness * 0.25 +\n layout * 0.25 +\n hierarchy * 0.25 +\n aesthetics * 0.25,\n );\n\n // Map to standard dimensions for consistency\n const dimensions: DimensionScores = {\n completeness,\n visualPolish: aesthetics,\n interactivity: 0, // can't assess interactivity from screenshot\n accessibility: 0, // can't assess a11y from screenshot\n codeQuality: 0, // can't assess code from screenshot\n };\n\n const issues: VisualIssue[] = (raw.issues || []).map((i: Record<string, string>) => ({\n dimension: i.dimension || 'visual',\n origin: 'judge',\n severity: (i.severity as 'critical' | 'major' | 'minor') || 'minor',\n description: i.description || '',\n fix: i.fix || '',\n }));\n\n // ggui#1436 — the criteria answers, tolerant: absent block → no field (an old answer stays\n // valid); an entry without a string id or with a verdict outside the vocabulary is dropped.\n const criteria = parseCriteriaAnswers(raw.criteria);\n\n return {\n passed: finalScore >= passThreshold,\n finalScore,\n dimensions,\n issues,\n critique: raw.critique,\n ...(criteria.answers !== undefined ? { criteriaAnswers: criteria.answers } : {}),\n criteriaCounts: criteria.counts,\n };\n}\n\n/**\n * The criteria answers, tolerant (ggui#1436), and what the tolerance dropped (ggui#1687): an absent or non-array block\n * reads no row, and each dropped entry is counted by why, so an empty or cut call is visible rather than a row of\n * clean `n/a`s.\n */\nfunction parseCriteriaAnswers(raw: unknown): { answers?: CriteriaAnswer[]; counts: CriteriaAnswerCounts } {\n if (!Array.isArray(raw)) return { counts: NO_CRITERIA_ARRAY };\n const answers: CriteriaAnswer[] = [];\n const dropped = { notObject: 0, badId: 0, badVerdict: 0 };\n for (const entry of raw) {\n if (typeof entry !== 'object' || entry === null) {\n dropped.notObject += 1;\n continue;\n }\n const o = entry as { id?: unknown; verdict?: unknown; evidence?: unknown };\n if (typeof o.id !== 'string') {\n dropped.badId += 1;\n continue;\n }\n if (o.verdict !== 'pass' && o.verdict !== 'fail' && o.verdict !== 'n/a') {\n dropped.badVerdict += 1;\n continue;\n }\n answers.push({ id: o.id, verdict: o.verdict, evidence: typeof o.evidence === 'string' ? o.evidence : '' });\n }\n return { answers, counts: { array: true, received: raw.length, kept: answers.length, dropped } };\n}\n\n// ---------------------------------------------------------------------------\n// Default models for visual evaluation\n// ---------------------------------------------------------------------------\n\nfunction getDefaultVisualModel(provider: 'claude' | 'google'): string {\n switch (provider) {\n case 'claude': return 'claude-haiku-5-5';\n case 'google': return 'gemini-3-flash-preview';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Tier 2 adapter — returns EvalIssue[]\n// ---------------------------------------------------------------------------\n\n/**\n * ggui#1522 — what a visual leg's judge calls spent: the scoring calls, and the report-only criteria calls apart\n * (ggui#1436). Priced at the VISUAL agent's model, never folded into a text evaluator's or a coding turn's tokens.\n */\nexport interface VisualLegTokens {\n readonly inputTokens: number;\n readonly outputTokens: number;\n readonly criteria?: CriteriaCallTokens;\n}\n\n/** What the harness's eval round consumes from the visual leg. */\nexport interface VisualEvalOutcome {\n /** Tier-2 issues (empty when no browser is available). */\n issues: EvalIssue[];\n /**\n * Per-canvas summary — present ONLY when `config.canvases` was set and\n * the leg ran; the harness stamps it on `EvalResult.visual`. Absent on\n * the single-shot path (byte-identical to the pre-canvas result).\n */\n summary?: VisualEvalSummary;\n /**\n * ggui#1221 — whether the judge leg ran or was skipped (with the reason\n * `runVisualEvaluationDetailed` names). Always present: the absence of a\n * summary used to be indistinguishable from a clean single-shot run.\n */\n coverage: VisualCoverage;\n /**\n * ggui#1522 — the leg's own spend, when its judge ran and reported tokens. The round records it in the cost\n * tracker at the visual agent's model and carries it apart; absent on a skipped leg.\n */\n tokens?: VisualLegTokens;\n}\n\n/**\n * Run visual evaluation and return tier 2 EvalIssues (+ the per-canvas\n * summary when canvases were requested).\n */\nexport async function runVisualEval(\n context: VisualEvalContext,\n config: VisualEvalConfig,\n deps: VisualEvalDeps = {},\n): Promise<VisualEvalOutcome> {\n const detailed = await runVisualEvaluationDetailed(context, config, deps);\n const result = detailed.result;\n if (!result) {\n // ggui#1221 — no browser / launch failure / unbundlable / unparsable judge:\n // the leg is SKIPPED, and says so on the outcome instead of leaving `{ issues: [] }`.\n const reason = detailed.unavailableReason ?? 'no browser available';\n return { issues: [], coverage: { status: 'skipped', reason } };\n }\n\n const issues: EvalIssue[] = (result.issues || []).map(toEvalIssue);\n const summary = summarizeVisualResult(result);\n const coverage: VisualCoverage = { status: 'ran' };\n // ggui#1522 — the judge's spend rides the outcome; until now it was dropped here, before the harness saw it.\n const tokens: VisualLegTokens | undefined =\n result.inputTokens !== undefined && result.outputTokens !== undefined\n ? {\n inputTokens: result.inputTokens,\n outputTokens: result.outputTokens,\n ...(result.criteriaTokens !== undefined ? { criteria: result.criteriaTokens } : {}),\n }\n : undefined;\n return { issues, ...(summary !== undefined ? { summary } : {}), coverage, ...(tokens !== undefined ? { tokens } : {}) };\n}\n\n/** A judge-shaped issue as the harness's tier-2 issue: critical ⇒ a blocking fail, anything else ⇒ a warn. */\nfunction toEvalIssue(issue: EvaluationIssue): EvalIssue {\n return {\n tier: 2,\n result: issue.severity === 'critical' ? 'fail' : 'warn',\n category: 'visual',\n subcategory: issue.dimension,\n severity: issue.severity === 'critical' ? 'critical' : 'major',\n description: issue.description,\n fix: issue.fix || '',\n ...(issue.origin !== undefined ? { origin: issue.origin } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// The fit half without the judge\n// ---------------------------------------------------------------------------\n\n/** What the fit half reads — the frame's inputs; nothing about a judge. */\nexport type VisualFitConfig = Pick<VisualEvalConfig, 'sampleProps' | 'canvases' | 'canvasViewports' | 'hostPresentations' | 'designSrcDir'>;\n\n/** One canvas's fit reading: the box, the measure, whether it overflowed — no score. */\nexport interface CanvasFitReading {\n readonly canvas: CanvasClass;\n readonly viewport: CanvasViewport;\n readonly contentHeight: number | null;\n readonly overflow: boolean;\n /** ggui#1120 — the capture's ink ratio; `0` is the blank, `null` an unreadable capture. */\n readonly inkRatio: number | null;\n /** `true` when the order declared this canvas's box. */\n readonly declared?: true;\n /** ggui#1492 — what the judge did with this canvas's host presentation, when one was supplied. */\n readonly presentation?: CanvasPresentationOutcome;\n}\n\n/** `measured` = every canvas was framed (its fit issues, possibly none); `unavailable` = no verdict, with why. */\nexport type VisualFitOutcome =\n | { readonly status: 'measured'; readonly issues: EvalIssue[]; readonly readings: CanvasFitReading[] }\n | { readonly status: 'unavailable'; readonly reason: string };\n\n/**\n * The visual leg's deterministic half, taken WITHOUT the vision judge.\n *\n * The fit verdict needs a browser and nothing else: each canvas is framed at\n * its box (the declared one when the order carried it), its scroll height is\n * measured against the box's height, and the canvas's fit policy decides what\n * an overflow earns — the same frame ({@link frameCanvas}), the same measure\n * and the same issue ({@link fitVerdict}, canvas-scoped) as the judge path, so\n * the two reach one verdict. What is absent is the score. A caller whose\n * generation provider has no vision judge takes this half alone, so a chat\n * card cut off at its declared box is still reported in the loop, where the\n * round can buy the composition fix.\n *\n * Per-canvas only: without `canvases` there is no box to hold the content\n * against, and the outcome is `unavailable`. A frame that cannot be taken is\n * `unavailable` with the capture's reason — never a pass.\n */\nexport async function runVisualFit(\n context: VisualEvalContext,\n config: VisualFitConfig,\n deps: ScreenshotDeps = {},\n): Promise<VisualFitOutcome> {\n if (config.canvases === undefined || config.canvases.length === 0) {\n return { status: 'unavailable', reason: 'no canvases — the fit verdict is taken per canvas' };\n }\n const designSrc = config.designSrcDir ?? resolve(resolveDesignPackageDir(), 'src');\n let bundledCode: string;\n try {\n bundledCode = await bundleForRendering(context.compiledCode, config.sampleProps ?? {}, designSrc);\n } catch (e) {\n return { status: 'unavailable', reason: `bundle failed: ${e instanceof Error ? e.message : String(e)}` };\n }\n const issues: EvalIssue[] = [];\n const readings: CanvasFitReading[] = [];\n for (const canvas of config.canvases) {\n const frame = await frameCanvas(bundledCode, context, canvas, config.canvasViewports, deps, config.hostPresentations);\n if (!frame.attempt.png) {\n return { status: 'unavailable', reason: `${frame.attempt.reason ?? 'no browser available'} at canvas ${canvas}` };\n }\n const contentHeight = frame.attempt.contentHeight;\n const overflow = contentHeight !== null && contentHeight > frame.viewport.height;\n const verdict = fitVerdict(canvas, frame);\n if (verdict !== null) issues.push(toEvalIssue(canvasScopedIssue(canvas, verdict)));\n const overflowXIssue = overflowXVerdict(canvas, frame);\n if (overflowXIssue !== null) issues.push(toEvalIssue(canvasScopedIssue(canvas, overflowXIssue)));\n const blank = blankVerdict(canvas, frame);\n if (blank !== null) issues.push(toEvalIssue(canvasScopedIssue(canvas, blank)));\n const inkRatio = frame.ink?.ratio ?? null;\n readings.push({\n canvas,\n viewport: frame.viewport,\n contentHeight,\n overflow,\n inkRatio,\n ...(frame.declared ? { declared: true as const } : {}),\n ...(frame.presentation !== undefined ? { presentation: frame.presentation } : {}),\n });\n console.log(\n `[visual-fit] canvas=${canvas} ${frame.viewport.width}×${frame.viewport.height} ` +\n `content=${contentHeight ?? '?'}px${overflow ? ` OVERFLOW (${frame.policy.overflow})` : ''} ` +\n `ink=${inkRatio ?? '?'}${blank !== null ? ' BLANK' : ''} | no judge`,\n );\n }\n return { status: 'measured', issues, readings };\n}\n"]}
|