Skip to content

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

fix(cli): report checker buffer overflow as an output-limit failure

zhanhuangchao623188a539b2
diff --git a/archify.zip b/archify.zip
index 2b57fc3b..236233eb 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/bin/archify.mjs b/archify/bin/archify.mjs
index fa2066d9..59db0b0f 100755
--- a/archify/bin/archify.mjs
+++ b/archify/bin/archify.mjs
@@ -2226,15 +2226,54 @@ function rendererPath(type) {
return path.join(skillRoot, 'renderers', type, `render-${type}.mjs`);
}
+// Default capture ceiling for piped child output. spawnSync's own default
+// is 1 MiB, which is below what a dense diagram's checker receipt reaches.
+const DEFAULT_MAX_BUFFER = 64 * 1024 * 1024;
+
function runNode(args, options = {}) {
return spawnSync(process.execPath, args, {
cwd: options.cwd || process.cwd(),
encoding: 'utf8',
stdio: options.stdio || 'inherit',
+ maxBuffer: options.maxBuffer ?? DEFAULT_MAX_BUFFER,
env: options.env ? { ...process.env, ...options.env } : process.env,
});
}
+// The artifact checker prints its whole receipt on stdout; a dense,
+// warning-heavy diagram can grow that receipt past spawnSync's 1 MiB
+// default, which kills the child before it reports a verdict. Deliver,
+// validate, migrate, compare, and check share this explicit limit so one
+// environment knob moves them together.
+function artifactCheckMaxBuffer() {
+ const raw = process.env.ARCHIFY_CHECK_MAX_BUFFER;
+ if (raw === undefined || raw === '') return DEFAULT_MAX_BUFFER;
+ const parsed = Number(raw);
+ return Number.isFinite(parsed) && Math.floor(parsed) >= 1 ? Math.floor(parsed) : DEFAULT_MAX_BUFFER;
+}
+
+// A checker terminated while streaming its output never judged the
+// artifact; its truncated stdout must not be reinterpreted as a verdict.
+function checkerOutputLimitDiagnostics(check, limitBytes) {
+ if (check.error?.code !== 'ENOBUFS') return null;
+ const receivedBytes = Buffer.byteLength(check.stdout || '', 'utf8');
+ return [diagnostic({
+ code: 'artifact/check-output-limit',
+ message: `The artifact checker exceeded the ${limitBytes} byte output buffer and was terminated before reporting a verdict (${receivedBytes} stdout bytes received); the artifact was not judged.`,
+ subject: { check: 'render_output' },
+ evidence: {
+ systemCode: check.error.code,
+ ...(check.signal ? { signal: check.signal } : {}),
+ status: check.status ?? null,
+ limitBytes,
+ receivedBytes,
+ },
+ supportedFixes: [
+ 'set ARCHIFY_CHECK_MAX_BUFFER to a much larger limit (for example 1073741824) and re-run',
+ ],
+ })];
+}
+
function extractQualityArgs(args) {
const rest = [];
let quality;
@@ -3527,16 +3566,25 @@ function renderValidatedArchitecture(inputPath, outputPath, quality, repoRoot, c
artifact = fs.readFileSync(outputPath);
captureStagingFile(outputPath, artifactIdentity(artifact));
}
- const check = runNode([path.join(skillRoot, 'scripts/check-render-output.mjs'), outputPath], { stdio: 'pipe' });
+ const checkMaxBuffer = artifactCheckMaxBuffer();
+ const check = runNode([path.join(skillRoot, 'scripts/check-render-output.mjs'), outputPath], {
+ stdio: 'pipe',
+ maxBuffer: checkMaxBuffer,
+ });
if (check.status !== 0) {
const error = new Error('Validated snapshot failed final artifact checks.');
error.compareStage = 'check';
error.compareStatus = check.status ?? 1;
- try {
- error.checker = JSON.parse(check.stdout);
- error.diagnostics = checkerDiagnostics(error.checker);
- } catch {
- error.diagnostics = [];
+ const outputLimit = checkerOutputLimitDiagnostics(check, checkMaxBuffer);
+ if (outputLimit) {
+ error.diagnostics = outputLimit;
+ } else {
+ try {
+ error.checker = JSON.parse(check.stdout);
+ error.diagnostics = checkerDiagnostics(error.checker);
+ } catch {
+ error.diagnostics = [];
+ }
}
throw error;
}
@@ -4760,11 +4808,27 @@ async function commandDeliver(args) {
// Leave an unbound entry untouched during private-directory cleanup.
}
+ const checkMaxBuffer = artifactCheckMaxBuffer();
const check = runNode([path.join(skillRoot, 'scripts/check-render-output.mjs'), candidatePath], {
stdio: 'pipe',
+ maxBuffer: checkMaxBuffer,
});
if (check.status !== 0) {
if (check.stderr) process.stderr.write(check.stderr);
+ const outputLimit = checkerOutputLimitDiagnostics(check, checkMaxBuffer);
+ if (outputLimit) {
+ reportDeliveryFailure({
+ json,
+ stage: 'check',
+ type,
+ input: inputPath,
+ output: outputPath,
+ error: `The artifact checker exceeded its ${checkMaxBuffer} byte output buffer and was terminated before reporting a verdict; the previous artifact was preserved.`,
+ diagnostics: outputLimit,
+ status: check.status ?? 1,
+ });
+ return;
+ }
let checker;
try {
checker = JSON.parse(check.stdout);
@@ -5387,9 +5451,30 @@ async function commandCheck(args) {
process.exitCode = 1;
return;
}
- const result = runNode([path.join(skillRoot, 'scripts/check-render-output.mjs'), html], { stdio: 'pipe' });
+ const checkMaxBuffer = artifactCheckMaxBuffer();
+ const result = runNode([path.join(skillRoot, 'scripts/check-render-output.mjs'), html], {
+ stdio: 'pipe',
+ maxBuffer: checkMaxBuffer,
+ });
if (result.error) {
- console.error(result.error.message);
+ if (result.stderr) process.stderr.write(result.stderr);
+ const outputLimit = checkerOutputLimitDiagnostics(result, checkMaxBuffer);
+ if (outputLimit) {
+ const file = path.resolve(html);
+ const message = outputLimit[0].message;
+ console.log(JSON.stringify({
+ schemaVersion: 1,
+ ok: false,
+ command: 'check',
+ artifact: { path: file },
+ file,
+ error: message,
+ diagnostic: message,
+ diagnostics: outputLimit,
+ }, null, 2));
+ } else {
+ console.error(result.error.message);
+ }
process.exitCode = 1;
return;
}
@@ -6384,10 +6469,24 @@ async function commandMigrate(args) {
content: artifactIdentity(migrationArtifact),
});
+ const checkMaxBuffer = artifactCheckMaxBuffer();
const check = runNode([path.join(skillRoot, 'scripts/check-render-output.mjs'), artifactPath], {
stdio: 'pipe',
+ maxBuffer: checkMaxBuffer,
});
if (check.status !== 0) {
+ const outputLimit = checkerOutputLimitDiagnostics(check, checkMaxBuffer);
+ if (outputLimit) {
+ reportMigrationFailure({
+ ...migration,
+ newSchemaDiagnostics: [
+ ...migration.newSchemaDiagnostics,
+ ...outputLimit,
+ ],
+ status: check.status ?? 1,
+ });
+ return;
+ }
let checker;
try {
checker = JSON.parse(check.stdout);
@@ -6792,26 +6891,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.' };
- }
- 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({
+ 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({
+ 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 --git a/archify/bin/finalize.mjs b/archify/bin/finalize.mjs
index 4407059b..bea39a9b 100644
--- a/archify/bin/finalize.mjs
+++ b/archify/bin/finalize.mjs
@@ -408,9 +408,27 @@ function browserEvidence(receipt, artifactPath) {
};
}
+// Stage receipts (dense validate/check JSON) can exceed execFile's 1 MiB
+// default. Track ARCHIFY_CHECK_MAX_BUFFER so a raised checker limit is not
+// defeated one layer up, with a 4 MiB floor: a lowered knob makes failing
+// stages emit compact classified receipts, but those receipts — and any
+// successful receipt the knob let through — still have to fit the capture.
+// The 64 KiB headroom covers the stage echo over the raw checker receipt:
+// commandCheck appends provenance and deliveryReceiptId after the checker
+// ran, so the printed receipt can exceed the knob that admitted it. Read the
+// knob from the runner's env, not process.env: runFinalize callers supply
+// their own env and the child stages inherit exactly that object.
+function stageCaptureMaxBuffer(env = process.env) {
+ const parsed = Number(env.ARCHIFY_CHECK_MAX_BUFFER);
+ const knob = Number.isFinite(parsed) && Math.floor(parsed) >= 1
+ ? Math.floor(parsed)
+ : 64 * 1024 * 1024;
+ return Math.max(knob, 4 * 1024 * 1024) + 64 * 1024;
+}
+
function defaultRunner({ cliPath, args, cwd, env }) {
return new Promise((resolve) => {
- execFile(process.execPath, [cliPath, ...args], { cwd, env, encoding: 'utf8' }, (error, stdout, stderr) => {
+ execFile(process.execPath, [cliPath, ...args], { cwd, env, encoding: 'utf8', maxBuffer: stageCaptureMaxBuffer(env) }, (error, stdout, stderr) => {
resolve({
status: error ? (Number.isInteger(error.code) ? error.code : 1) : 0,
stdout,
diff --git a/archify/test/cli.test.mjs b/archify/test/cli.test.mjs
index ec066a2a..a6319b2f 100644
--- a/archify/test/cli.test.mjs
+++ b/archify/test/cli.test.mjs
@@ -7,6 +7,7 @@ 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, '..');
@@ -21,6 +22,7 @@ function run(args, options = {}) {
return spawnSync(process.execPath, [cli, ...args], {
cwd: options.cwd || skillRoot,
encoding: 'utf8',
+ maxBuffer: 64 * 1024 * 1024,
env: options.env || process.env,
});
}
@@ -854,6 +856,191 @@ test('cli: deliver preserves the previous artifact when the final check fails',
);
});
+// 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: 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 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 --git a/archify/test/finalize.test.mjs b/archify/test/finalize.test.mjs
index 0a679f6c..e90a9300 100644
--- a/archify/test/finalize.test.mjs
+++ b/archify/test/finalize.test.mjs
@@ -15,6 +15,7 @@ import {
runFinalize,
} from '../bin/finalize.mjs';
import { CAPTURE_VIEWPORTS, VISUAL_CHECK_VIEWPORTS } from '../bin/visual-check.mjs';
+import { bipartiteArchitectureSpec } from './helpers/dense-fixture.mjs';
function workspace(t) {
const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-finalize-'));
@@ -1104,3 +1105,66 @@ test('finalize rechecks delivery barriers and the frozen candidate after the bro
assert.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 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.
+ process.env.ARCHIFY_CHECK_MAX_BUFFER = String(5 * 1024 * 1024);
+ process.env.ARCHIFY_CHROME = missingChrome;
+ t.after(() => {
+ delete process.env.ARCHIFY_CHECK_MAX_BUFFER;
+ delete process.env.ARCHIFY_CHROME;
+ });
+
+ const finalized = await runFinalize({
+ cliPath,
+ type: 'architecture',
+ input,
+ output,
+ quality: 'standard',
+ cwd: path.join(here, '..'),
+ 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, '..'),
+ 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 --git a/archify/test/helpers/dense-fixture.mjs b/archify/test/helpers/dense-fixture.mjs
new file mode 100644
index 00000000..0e0d294a
--- /dev/null
+++ b/archify/test/helpers/dense-fixture.mjs
@@ -0,0 +1,39 @@
+// Two columns with every left node connected to every right node: all edges
+// span the empty middle channel, so the diagram stays valid while the dense
+// label/route field pushes the checker receipt past spawnSync's 1 MiB default
+// (and past multi-MiB capture floors for near-limit tests).
+export function bipartiteArchitectureSpec(nodeCount) {
+ const step = nodeCount <= 11 ? 56 : 50;
+ const nodeHeight = step - 14;
+ const components = [];
+ for (let i = 0; i < nodeCount; i += 1) {
+ const y = 40 + i * step;
+ components.push({ id: `l${i}`, type: 'backend', label: `Source ${i}`, sublabel: 'left', pos: [60, y], size: [150, nodeHeight] });
+ components.push({ id: `r${i}`, type: 'database', label: `Target ${i}`, sublabel: 'right', pos: [950, y], size: [150, nodeHeight] });
+ }
+ const connections = [];
+ for (let i = 0; i < nodeCount; i += 1) {
+ for (let j = 0; j < nodeCount; j += 1) {
+ connections.push({
+ id: `l${i}-r${j}`,
+ from: `l${i}`,
+ to: `r${j}`,
+ fromSide: 'right',
+ toSide: 'left',
+ label: `f${i}t${j}`,
+ });
+ }
+ }
+ return {
+ schema_version: 1,
+ diagram_type: 'architecture',
+ meta: {
+ title: 'Dense receipt fixture',
+ output: 'dense.html',
+ quality_profile: 'standard',
+ },
+ components,
+ connections,
+ cards: [{ dot: 'cyan', title: 'Dense', items: ['Complete bipartite connection set'] }],
+ };
+}