Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

fix: drop unsound static header-overflow prediction

momoyeyue40f33b2d2ed
diff --git a/archify/renderers/shared/validator.mjs b/archify/renderers/shared/validator.mjs
index 801a0674..7664657b 100644
--- a/archify/renderers/shared/validator.mjs
+++ b/archify/renderers/shared/validator.mjs
@@ -1,6 +1,5 @@
import * as validators from './generated-validators.mjs';
import { throwDiagnosticError } from './diagnostics.mjs';
-import { textUnits } from './utils.mjs';
// "/nodes/3/label" reads much better as "/nodes/3 (id: "router") /label" for the
// LLM fixing the JSON; resolve the nearest enclosing element's id or label.
@@ -84,41 +83,4 @@ export function validateSchema(diagramType, data) {
diagnostics,
);
}
- validateHeaderFitsViewport(diagramType, data);
-}
-
-// Widest visual-check viewport (archify/bin/visual-check.mjs). The per-unit
-// multipliers deliberately underestimate the rendered h1 (1.5rem) and
-// .subtitle (0.875rem) widths, so a predicted overflow is certain: the real
-// header only ever renders wider than the estimate.
-const WIDEST_VIEWPORT_PX = 2048;
-const TITLE_PX_PER_UNIT = 10;
-const SUBTITLE_PX_PER_UNIT = 6;
-
-export function validateHeaderFitsViewport(diagramType, data) {
- const diagnostics = [];
- for (const [field, pxPerUnit] of [['title', TITLE_PX_PER_UNIT], ['subtitle', SUBTITLE_PX_PER_UNIT]]) {
- const text = data?.meta?.[field];
- if (typeof text !== 'string' || !text.length) continue;
- const estimatedWidth = Math.round(textUnits(text) * pxPerUnit);
- if (estimatedWidth <= WIDEST_VIEWPORT_PX) continue;
- diagnostics.push({
- code: 'viewer/viewport-overflow',
- severity: 'error',
- message: `meta.${field} (~${estimatedWidth}px estimated) exceeds the widest ${WIDEST_VIEWPORT_PX}px viewport — it will overflow before render.`,
- subject: { diagramType, path: `/meta/${field}` },
- evidence: {
- estimatedTextWidthPx: estimatedWidth,
- widestViewportPx: WIDEST_VIEWPORT_PX,
- prediction: 'lower-bound text-width estimate; the rendered header is wider',
- },
- supportedFixes: [`shorten meta.${field} until its rendered width fits within ${WIDEST_VIEWPORT_PX}px`],
- });
- }
- if (diagnostics.length) {
- throwDiagnosticError(
- `${diagramType} header overflows the widest viewport:\n${diagnostics.map((d) => ` ${d.message}`).join('\n')}`,
- diagnostics,
- );
- }
}
diff --git a/archify/test/cli.test.mjs b/archify/test/cli.test.mjs
index ec066a2a..a5f9e5a5 100644
--- a/archify/test/cli.test.mjs
+++ b/archify/test/cli.test.mjs
@@ -4027,6 +4027,20 @@ test('cli: validate JSON exposes only the primary v1 column-capacity diagnostic'
)));
});
+test('cli: validate accepts deliverable headers including narrow glyphs and wrapping text', () => {
+ // h1 and .subtitle wrap; even an unbreakable run of narrow glyphs fits the
+ // widest viewport, so validation must not second-guess the browser with a
+ // static width estimate.
+ const source = JSON.parse(fs.readFileSync(path.join(skillRoot, 'examples/agent-tool-call.workflow.json'), 'utf8'));
+ source.meta.title = 'i'.repeat(205);
+ source.meta.subtitle = 'a reasonably long subtitle sentence that wraps onto multiple lines inside the viewer header without any need for overflow'.repeat(2);
+ const input = path.join(tmp, 'narrow-glyph-header.workflow.json');
+ fs.writeFileSync(input, JSON.stringify(source));
+ const result = run(['validate', 'workflow', input, '--json']);
+ assert.equal(result.status, 0, result.stderr || result.stdout);
+ assert.equal(JSON.parse(result.stdout).ok, true);
+});
+
test('cli: --quality overrides the source profile for render, validate, and deliver', () => {
const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');
const out = path.join(tmp, 'workflow-standard.html');
diff --git a/archify/test/repair-rounds.test.mjs b/archify/test/repair-rounds.test.mjs
index 136a3a62..2b604df7 100644
--- a/archify/test/repair-rounds.test.mjs
+++ b/archify/test/repair-rounds.test.mjs
@@ -109,14 +109,14 @@ test('diagnostics the rules cannot map are counted as unactionable and stall the
assert.equal(receipt.totals.unactionable > 0, true);
});
-test('a header overflow is predicted early, at the validate gate', { skip: !chromeAvailable }, () => {
+test('a header overflow is detected at the browser-check gate, where measurement is authoritative', { skip: !chromeAvailable }, () => {
const file = miniManifest('arch-title-overflow', 'architecture', [{ class: 'title-overflow' }]);
const result = run(['run', '--manifest', file, '--command', 'finalize', '--repair', 'oracle']);
assert.equal(result.status, 0, result.stderr || result.stdout);
const receipt = JSON.parse(result.stdout.split('\n')[0]);
assert.equal(receipt.passed, true);
- assert.equal(receipt.defects[0].firstSeenGate, 'validate');
- assert.equal(receipt.defects[0].late, false);
+ assert.equal(receipt.defects[0].firstSeenGate, 'browser-check');
+ assert.equal(receipt.defects[0].late, true);
});
test('report aggregates disclosure, late discovery, and token cost across receipts', () => {