Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix: integrate checker output limits with current dev
tt-a1i08d057862abe
diff --cc archify.zipindex ca5d6675,bf0ac8f5..95bcc155Binary files differdiff --cc archify/bin/archify.mjsindex 2fb68451,15b83c2d..9a796a2d--- a/archify/bin/archify.mjs+++ b/archify/bin/archify.mjs@@@ -6891,43 -6830,26 +6929,43 @@@ async function commandValidate(args)exitCode = render.status ?? 1;} else {if (render.stderr) process.stderr.write(render.stderr);- const check = runNode([path.join(skillRoot, 'scripts/check-render-output.mjs'), out], { stdio: 'pipe' });+ const checkMaxBuffer = artifactCheckMaxBuffer();+ const check = runNode([path.join(skillRoot, 'scripts/check-render-output.mjs'), out], {+ stdio: 'pipe',+ maxBuffer: checkMaxBuffer,+ });if (check.status !== 0) {- let checker;- try {- checker = JSON.parse(check.stdout);- checker.file = path.resolve(input);- } catch {- checker = { ok: false, diagnostic: 'Artifact checker failed without a parseable receipt.' };- }- report = () => reportValidateFailure({- json,- stage: 'check',- type,- input: path.resolve(input),- error: 'Final artifact check failed.',- diagnostics: checkerDiagnostics(checker),- checker,- status: check.status ?? 1,- });exitCode = check.status ?? 1;+ const outputLimit = checkerOutputLimitDiagnostics(check, checkMaxBuffer);+ if (outputLimit) {- reportValidateFailure({++ report = () => reportValidateFailure({+ json,+ stage: 'check',+ type,+ input: path.resolve(input),+ error: `The artifact checker exceeded its ${checkMaxBuffer} byte output buffer and was terminated before reporting a verdict.`,+ diagnostics: outputLimit,+ status: check.status ?? 1,+ });+ } else {+ let checker;+ try {+ checker = JSON.parse(check.stdout);+ checker.file = path.resolve(input);+ } catch {+ checker = { ok: false, diagnostic: 'Artifact checker failed without a parseable receipt.' };+ }- reportValidateFailure({++ report = () => reportValidateFailure({+ json,+ stage: 'check',+ type,+ input: path.resolve(input),+ error: 'Final artifact check failed.',+ diagnostics: checkerDiagnostics(checker),+ checker,+ status: check.status ?? 1,+ });+ }} else {const result = JSON.parse(check.stdout);const engineeringProfile = engineeringProfileFromArtifact(fs.readFileSync(out));diff --cc test/cli.test.mjsindex db868804,26dab11e..5d0fa330--- a/test/cli.test.mjs+++ b/test/cli.test.mjs@@@ -7,10 -7,9 +7,10 @@@ import os from 'node:os'import path from 'node:path';import { fileURLToPath, pathToFileURL } from 'node:url';import { extractSvgs, parseXml } from './helpers/xml.mjs';+import { bipartiteArchitectureSpec } from './helpers/dense-fixture.mjs';const __dirname = path.dirname(fileURLToPath(import.meta.url));- const skillRoot = path.resolve(__dirname, '..');+ const skillRoot = path.resolve(__dirname, '..', 'archify');const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-cli-'));const cli = path.join(skillRoot, 'bin/archify.mjs');@@@ -856,251 -854,6 +856,251 @@@ test('cli: deliver preserves the previo);});+// Dense-but-valid receipt fixtures live in helpers/dense-fixture.mjs.++test('cli: deliver accepts a dense artifact whose checker receipt exceeds the 1 MiB default buffer', { timeout: 60000 }, () => {+ const input = path.join(tmp, 'dense-receipt.architecture.json');+ fs.writeFileSync(input, JSON.stringify(bipartiteArchitectureSpec(8)));+ const out = path.join(tmp, 'dense-receipt.html');+ // Scrub the knob so this test exercises the default limit even when a+ // developer or CI environment overrides it.+ const env = { ...process.env };+ delete env.ARCHIFY_CHECK_MAX_BUFFER;+ const delivered = run(['deliver', 'architecture', input, out, '--json'], { env });+ assert.equal(delivered.status, 0, delivered.stderr);+ const receipt = JSON.parse(delivered.stdout);+ assert.equal(receipt.ok, true);+ assert.equal(receipt.command, 'deliver');+ const provenance = JSON.parse(fs.readFileSync(deliveryProvenancePath(out), 'utf8'));+ assert.equal(provenance.status, 'current');++ const checked = spawnSync(process.execPath, [path.join(skillRoot, 'scripts/check-render-output.mjs'), out], {+ cwd: skillRoot,+ encoding: 'utf8',+ maxBuffer: 64 * 1024 * 1024,+ });+ assert.equal(checked.status, 0, checked.stderr);+ const bytes = Buffer.byteLength(checked.stdout, 'utf8');+ assert.ok(bytes > 1024 * 1024, `checker receipt was only ${bytes} bytes; the fixture no longer overflows the 1 MiB default`);+ assert.equal(JSON.parse(checked.stdout).ok, true);+});++test('cli: deliver reports an output-limit failure distinctly and preserves the previous artifact', () => {+ const input = path.join(skillRoot, 'examples/web-app.architecture.json');+ const out = path.join(tmp, 'output-limit-preserved.html');+ const trustedPriorArtifact = '<!doctype html><title>trusted prior artifact</title>\n';+ fs.writeFileSync(out, trustedPriorArtifact);++ const result = run(['deliver', 'architecture', input, out, '--json'], {+ env: { ...process.env, ARCHIFY_CHECK_MAX_BUFFER: '1024' },+ });++ assert.equal(result.status, 1);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.ok, false);+ assert.equal(failure.stage, 'check');+ assert.equal(failure.diagnostics.length, 1);+ assert.equal(failure.diagnostics[0].code, 'artifact/check-output-limit');+ assert.notEqual(failure.diagnostics[0].code, 'artifact/check-failed');+ assert.equal(failure.diagnostics[0].evidence.systemCode, 'ENOBUFS');+ assert.equal(failure.diagnostics[0].evidence.limitBytes, 1024);+ assert.ok(failure.diagnostics[0].evidence.receivedBytes >= 1024);+ assert.ok(failure.diagnostics[0].supportedFixes.some((fix) => fix.includes('ARCHIFY_CHECK_MAX_BUFFER')));+ assert.equal(fs.readFileSync(out, 'utf8'), trustedPriorArtifact);+ const provenance = JSON.parse(fs.readFileSync(deliveryProvenancePath(out), 'utf8'));+ assert.equal(provenance.status, 'failed');+ assert.equal(provenance.stage, 'check');+ assert.deepEqual(+ fs.readdirSync(path.dirname(out)).filter((name) => name.includes('.archify-delivery-')),+ [],+ );+});++test('cli: deliver records the output-limit failure before it releases the delivery', () => {+ const input = path.join(skillRoot, 'examples/web-app.architecture.json');+ const out = path.join(tmp, 'output-limit-order.html');+ const trustedPriorArtifact = '<!doctype html><title>trusted prior artifact</title>\n';+ fs.writeFileSync(out, trustedPriorArtifact);++ // The failure receipt must be recorded before the delivery releases its+ // staging. Both steps are observable from the CLI process: the receipt is+ // published as the `.delivery.json` sidecar (linked into place), and the+ // staging directory is retired through an `.archify-staging-remove-` quarantine.+ const orderLog = path.join(tmp, 'output-limit-order.log');+ const probe = path.join(tmp, 'output-limit-order-probe.mjs');+ fs.writeFileSync(+ probe,+ `import fs from 'node:fs';+const log = process.env.ARCHIFY_ORDER_LOG;+// Instrumentation must never change CLI behavior, so a log write failure is ignored.+const note = (event) => { try { if (log) fs.appendFileSync(log, event + '\\n'); } catch {} };+const publishesReceipt = (to) => typeof to === 'string' && to.endsWith('.delivery.json');+const linkSync = fs.linkSync;+fs.linkSync = function (from, to) {+ if (publishesReceipt(to)) note('record-failure');+ return linkSync.apply(this, arguments);+};+const renameSync = fs.renameSync;+fs.renameSync = function (from, to) {+ if (publishesReceipt(to)) note('record-failure');+ if (typeof to === 'string' && to.includes('.archify-staging-remove-')) {+ const retired = String(from).split(/[\\\\/]/).pop();+ note('release-staging:' + retired);+ }+ return renameSync.apply(this, arguments);+};+`,+ );+ fs.writeFileSync(orderLog, '');+ const nodeOptions = `${process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} ` : ''}--import=${pathToFileURL(probe).href}`;++ const result = run(['deliver', 'architecture', input, out, '--json'], {+ env: { ...process.env, ARCHIFY_CHECK_MAX_BUFFER: '1024', ARCHIFY_ORDER_LOG: orderLog, NODE_OPTIONS: nodeOptions },+ });++ assert.equal(result.status, 1);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.diagnostics[0].code, 'artifact/check-output-limit');+ assert.equal(fs.readFileSync(out, 'utf8'), trustedPriorArtifact);+ const order = fs.readFileSync(orderLog, 'utf8').trim().split('\n').filter(Boolean);+ const recorded = order.indexOf('record-failure');+ // The delivery staging basename is its mkdtemp name; matching that shape keeps+ // sibling stagings and `.archify-delivery-lock.json` from colliding with it.+ const deliveryStaging = /^release-staging:\.archify-delivery-[A-Za-z0-9]{6}$/;+ const released = order.findIndex((event) => deliveryStaging.test(event));+ assert.notEqual(recorded, -1, `the failure receipt was not recorded (${order.join(' -> ') || 'no events'})`);+ assert.notEqual(released, -1, `the delivery staging directory was not released (${order.join(' -> ') || 'no events'})`);+ assert.ok(+ recorded < released,+ `the failure receipt must be recorded before the delivery staging is released (${order.join(' -> ')})`,+ );+});++test('cli: validate reports an output-limit failure with the same diagnostic', () => {+ const input = path.join(skillRoot, 'examples/web-app.architecture.json');+ const result = run(['validate', 'architecture', input, '--json'], {+ env: { ...process.env, ARCHIFY_CHECK_MAX_BUFFER: '1024' },+ });++ assert.equal(result.status, 1);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.ok, false);+ assert.equal(failure.command, 'validate');+ assert.equal(failure.stage, 'check');+ assert.equal(failure.diagnostics[0].code, 'artifact/check-output-limit');+ assert.equal(failure.diagnostics[0].evidence.systemCode, 'ENOBUFS');+});++test('cli: migrate reports an output-limit failure with the same diagnostic', () => {- const source = path.join(skillRoot, 'test/fixtures/v1-workflow-700x400.workflow.json');++ const source = path.join(__dirname, 'fixtures/v1-workflow-700x400.workflow.json');+ const destination = path.join(tmp, 'output-limit-migrated.workflow.json');+ const result = run(['migrate', 'workflow', source, destination, '--to-schema', '2', '--json'], {+ env: { ...process.env, ARCHIFY_CHECK_MAX_BUFFER: '1024' },+ });++ assert.equal(result.status, 1);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.ok, false);+ assert.equal(failure.command, 'migrate');+ const entry = failure.diagnostics.find((diagnosticEntry) => diagnosticEntry.code === 'artifact/check-output-limit');+ assert.ok(entry, `missing output-limit diagnostic in ${JSON.stringify(failure.diagnostics.map((d) => d.code))}`);+ assert.equal(entry.evidence.systemCode, 'ENOBUFS');+ assert.equal(entry.evidence.limitBytes, 1024);+});++test('cli: compare reports an output-limit failure with the same diagnostic', () => {+ const input = path.join(skillRoot, 'examples/web-app.architecture.json');+ const out = path.join(tmp, 'compare-output-limit.html');+ const result = run(['compare', 'architecture', input, input, out, '--json'], {+ env: { ...process.env, ARCHIFY_CHECK_MAX_BUFFER: '1024' },+ });++ assert.equal(result.status, 1);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.ok, false);+ assert.equal(failure.command, 'compare');+ assert.equal(failure.stage, 'check');+ assert.equal(failure.diagnostics[0].code, 'artifact/check-output-limit');+ assert.equal(failure.diagnostics[0].evidence.systemCode, 'ENOBUFS');+});++test('cli: check reports an output-limit failure with a classified receipt', () => {+ const input = path.join(skillRoot, 'examples/web-app.architecture.json');+ const artifact = path.join(tmp, 'check-output-limit.html');+ const rendered = run(['render', 'architecture', input, artifact]);+ assert.equal(rendered.status, 0, rendered.stderr);++ const result = run(['check', artifact], {+ env: { ...process.env, ARCHIFY_CHECK_MAX_BUFFER: '1024' },+ });++ assert.equal(result.status, 1);+ const receipt = JSON.parse(result.stdout);+ assert.equal(receipt.ok, false);+ assert.equal(receipt.command, 'check');+ assert.equal(receipt.diagnostics[0].code, 'artifact/check-output-limit');+ assert.equal(receipt.diagnostics[0].evidence.systemCode, 'ENOBUFS');+ assert.equal(receipt.error, receipt.diagnostics[0].message);+ assert.equal(receipt.diagnostic, receipt.diagnostics[0].message);+});++test('cli: finalize captures a near-limit check receipt with provenance', { timeout: 180000 }, () => {+ const input = path.join(tmp, 'near-limit-finalize.architecture.json');+ fs.writeFileSync(input, JSON.stringify(bipartiteArchitectureSpec(11)));+ const out = path.join(tmp, 'near-limit-finalize.html');+ // Setup runs must see the default limit even when the environment+ // overrides the knob; only the finalize invocation sets it explicitly.+ const setupEnv = { ...process.env };+ delete setupEnv.ARCHIFY_CHECK_MAX_BUFFER;+ const delivered = run(['deliver', 'architecture', input, out, '--json'], { env: setupEnv });+ assert.equal(delivered.status, 0, delivered.stderr);++ // The finalize gate that must capture big bytes is `check+ // --require-provenance`: its echo = raw checker receipt + provenance+ // additions. Size the knob inside [raw, echo) — the checker then admits+ // it while only capture headroom lets the wider echo through.+ const measured = spawnSync(process.execPath, [path.join(skillRoot, 'scripts/check-render-output.mjs'), out], {+ cwd: skillRoot,+ encoding: 'utf8',+ maxBuffer: 64 * 1024 * 1024,+ env: setupEnv,+ });+ assert.equal(measured.status, 0, measured.stderr);+ const rawBytes = Buffer.byteLength(measured.stdout, 'utf8');+ assert.ok(rawBytes > 4 * 1024 * 1024, `fixture receipt (${rawBytes} bytes) must exceed the 4 MiB capture floor for this test to bind`);++ const echoed = run(['check', out, '--require-provenance'], { env: setupEnv });+ assert.equal(echoed.status, 0, echoed.stderr);+ const echoBytes = Buffer.byteLength(echoed.stdout, 'utf8');+ assert.ok(echoBytes > rawBytes + 64, `provenance window missing (raw ${rawBytes}, echo ${echoBytes})`);+ const knob = rawBytes + Math.floor((echoBytes - rawBytes) / 2);++ const outDir = path.join(tmp, 'near-limit-finalize-evidence');+ const missingChrome = path.join(tmp, 'missing-finalize-chrome');+ const result = run([+ 'finalize', 'architecture', input, out,+ '--quality', 'standard', '--json', '--out-dir', outDir,+ ], {+ env: {+ ...process.env,+ ARCHIFY_CHECK_MAX_BUFFER: String(knob),+ ARCHIFY_CHROME: missingChrome,+ },+ });++ assert.equal(result.status, 2, result.stderr || result.stdout);+ const summary = JSON.parse(result.stdout);+ assert.equal(summary.status, 'skipped');+ assert.equal(summary.failedStage, 'browser-check');+ assert.deepEqual(summary.gates, {+ validate: 'pass', deliver: 'pass', check: 'pass', 'browser-check': 'skipped',+ });+ const full = JSON.parse(fs.readFileSync(summary.evidence.receipt, 'utf8'));+ assert.equal(full.stages.check.status, 'pass');+ assert.equal(full.stages.check.receipt.provenance, 'current');+ assert.equal(fs.existsSync(out), true, 'verified delivery remains available');+});+test('cli: deliver reports renderer failure as json and preserves the previous artifact', () => {const validInput = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const input = path.join(tmp, 'invalid-delivery.workflow.json');diff --cc test/finalize.test.mjsindex ca85aa89,1875888c..e7a8a4d5--- a/test/finalize.test.mjs+++ b/test/finalize.test.mjs@@@ -13,9 -13,8 +13,9 @@@ importdefaultFinalizeReceiptPath,defaultFinalizeSummaryPath,runFinalize,- } from '../bin/finalize.mjs';- import { CAPTURE_VIEWPORTS, VISUAL_CHECK_VIEWPORTS } from '../bin/visual-check.mjs';+ } from '../archify/bin/finalize.mjs';+ import { CAPTURE_VIEWPORTS, VISUAL_CHECK_VIEWPORTS } from '../archify/bin/visual-check.mjs';+import { bipartiteArchitectureSpec } from './helpers/dense-fixture.mjs';function workspace(t) {const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-finalize-'));@@@ -1105,72 -1104,3 +1105,73 @@@ test('finalize rechecks delivery barrieassert.equal(finalized.summary.diagnostics[0].code, scenario === 'pending-delivery' ? 'delivery/provenance-pending' : 'finalize/candidate-changed');}});++test('runFinalize reads the capture limit from the supplied env, not process.env', { timeout: 180000 }, async (t) => {+ const here = path.dirname(fileURLToPath(import.meta.url));- const cliPath = path.join(here, '..', 'bin', 'archify.mjs');++ const skillRoot = path.join(here, '..', 'archify');++ const cliPath = path.join(skillRoot, 'bin', 'archify.mjs');+ const directory = workspace(t);+ const input = path.join(directory, 'env-capture.architecture.json');+ fs.writeFileSync(input, JSON.stringify(bipartiteArchitectureSpec(10)));+ const output = path.join(directory, 'env-capture.html');+ const missingChrome = path.join(directory, 'missing-chrome');++ // The parent process sees a 5 MiB knob while the supplied env raises it+ // to 10 MiB. The dense check echo sits between the two knobs (6.1 MiB on+ // dev `9102a91`; it has drifted with dev-side warning volume before —+ // 8.8 MiB on `7d3594e`, 10.5 MiB at 11+11 on `baffbdd3`), so a runner+ // reading process.env overflows at the check gate while the child stages+ // (which inherit the supplied env) pass. The overflow probe below pins+ // the lower end of that window: if the echo ever drops under 5 MiB the+ // test fails loudly instead of passing without exercising the regression.+ // Restore, rather than clear, the variables this test overrides so a+ // preconfigured environment cannot be damaged for later tests.+ const previousCheckMaxBuffer = process.env.ARCHIFY_CHECK_MAX_BUFFER;+ const previousChrome = process.env.ARCHIFY_CHROME;+ process.env.ARCHIFY_CHECK_MAX_BUFFER = String(5 * 1024 * 1024);+ process.env.ARCHIFY_CHROME = missingChrome;+ t.after(() => {+ if (previousCheckMaxBuffer === undefined) delete process.env.ARCHIFY_CHECK_MAX_BUFFER;+ else process.env.ARCHIFY_CHECK_MAX_BUFFER = previousCheckMaxBuffer;+ if (previousChrome === undefined) delete process.env.ARCHIFY_CHROME;+ else process.env.ARCHIFY_CHROME = previousChrome;+ });++ const finalized = await runFinalize({+ cliPath,+ type: 'architecture',+ input,+ output,+ quality: 'standard',- cwd: path.join(here, '..'),++ cwd: skillRoot,+ env: {+ ...process.env,+ ARCHIFY_CHECK_MAX_BUFFER: String(10 * 1024 * 1024),+ ARCHIFY_CHROME: missingChrome,+ },+ });++ assert.equal(finalized.exitCode, 2, JSON.stringify(finalized.summary?.gates || finalized.receipt?.failedStage));+ assert.equal(finalized.receipt.stages.check.status, 'pass');+ assert.equal(finalized.receipt.stages['browser-check'].status, 'skipped');+ assert.equal(finalized.receipt.stages.check.receipt.provenance, 'current');++ // Same fixture, supplied env pinned to the parent's 5 MiB: the check+ // echo must overflow there, proving the window the first run relied on.+ const overflowed = await runFinalize({+ cliPath,+ type: 'architecture',+ input,+ output,+ quality: 'standard',- cwd: path.join(here, '..'),++ cwd: skillRoot,+ env: {+ ...process.env,+ ARCHIFY_CHECK_MAX_BUFFER: String(5 * 1024 * 1024),+ ARCHIFY_CHROME: missingChrome,+ },+ });++ assert.equal(overflowed.receipt.stages.validate.status, 'fail');+ assert.equal(overflowed.receipt.stages.validate.receipt.diagnostics[0].code, 'artifact/check-output-limit');+});diff --cc test/helpers/dense-fixture.mjsindex 0e0d294a,00000000..0e0d294amode 100644,000000..100644--- a/test/helpers/dense-fixture.mjs+++ b/test/helpers/dense-fixture.mjs