Skip to content

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

fix(checker): flush large artifact receipts before exiting (#311)

jackie-cqz559aee0715de
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 30329104..6d22bab8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ All notable changes are documented here. Format loosely follows [Keep a Changelo
> Development identity: `v2.17.0-dev.1`. Not a stable release.
### Fixed
+- **Complete artifact-check receipts (#311).** The checker now lets stdout drain before exiting, so large JSON receipts remain complete through pipes. Validation, delivery, and architecture comparison retain their original success/failure status without truncated-JSON errors.
- **License provenance in distributions.** Source and packaged Skill distributions retain Cocoon AI's exact MIT copyright notice, package staging and smoke tests fail closed when the notice or LICENSE is missing or altered, and the deterministic ZIP carries the same LICENSE bytes as the repository.
- **Third-party mark notices in distributions.** Source and packaged Skill distributions now identify the pinned Simple Icons collection, disclose all individual icon licenses recorded by that version, preserve source and brand-guideline links, and state that Archify's MIT license does not replace third-party copyright or trademark terms. Package staging and smoke tests fail closed when the notice is missing or altered.
- **Unsupported experiment source chains.** The Hivenue and Taiga Mermaid inputs and their generated derivatives are removed from the current tree because no verifiable redistribution license was available; the retained validation evidence now reports the remaining 3-source / 9-artifact set without rewriting historical results.
diff --git a/archify.zip b/archify.zip
index 152a97c9..aa3a02f2 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/scripts/check-render-output.mjs b/archify/scripts/check-render-output.mjs
index 704b9650..d24ce7f6 100644
--- a/archify/scripts/check-render-output.mjs
+++ b/archify/scripts/check-render-output.mjs
@@ -273,7 +273,8 @@ if (svgMatches.length === 1) {
const ok = checks.every((check) => check.ok) && composition.status !== 'fail';
console.log(JSON.stringify({ ok, file: htmlPath, checks, composition }, null, 2));
-process.exit(ok ? 0 : 1);
+// Let pending stdout writes drain: large receipts are asynchronous when piped.
+process.exitCode = ok ? 0 : 1;
function collectArrows(fragment) {
const arrows = [];
diff --git a/archify/test/artifact-receipt-flush.test.mjs b/archify/test/artifact-receipt-flush.test.mjs
new file mode 100644
index 00000000..50ec9465
--- /dev/null
+++ b/archify/test/artifact-receipt-flush.test.mjs
@@ -0,0 +1,126 @@
+import assert from 'node:assert/strict';
+import { spawnSync } from 'node:child_process';
+import { createHash } from 'node:crypto';
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
+import { after, test } from 'node:test';
+import { fileURLToPath } from 'node:url';
+
+const skillRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+const checker = path.join(skillRoot, 'scripts/check-render-output.mjs');
+const cli = path.join(skillRoot, 'bin/archify.mjs');
+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-receipt-flush-'));
+after(() => fs.rmSync(tmp, { recursive: true, force: true }));
+
+function run(script, args, options = {}) {
+ return spawnSync(process.execPath, [script, ...args], {
+ cwd: skillRoot,
+ encoding: 'utf8',
+ timeout: 30_000,
+ ...options,
+ });
+}
+
+for (const profile of ['standard', 'showcase']) {
+ test(`artifact checker flushes a large ${profile} receipt to a pipe`, () => {
+ // Distinct relationships sharing one corridor produce a real, large
+ // composition receipt: warnings in standard, errors in showcase.
+ const count = 24;
+ const arrows = Array.from({ length: count }, (_, index) => (
+ `<path data-edge-id="edge-${index}" data-edge-from="source-${index}" data-edge-to="target-${index}" d="M 20 40 L 220 40" class="a-default" marker-end="url(#arrowhead)"/>`
+ )).join('\n');
+ const html = path.join(tmp, `${profile}.html`);
+ fs.writeFileSync(html, `<svg viewBox="0 0 240 160" data-quality-profile="${profile}">${arrows}</svg>`);
+
+ // A regular file is the synchronous-output control. The pipe must carry
+ // exactly the same bytes, including the final diagnostic and closing JSON.
+ const reference = path.join(tmp, `${profile}.json`);
+ const descriptor = fs.openSync(reference, 'w');
+ let fileRun;
+ try {
+ fileRun = run(checker, [html], { stdio: ['ignore', descriptor, 'pipe'] });
+ } finally {
+ fs.closeSync(descriptor);
+ }
+ const expectedCode = profile === 'standard' ? 0 : 1;
+ assert.equal(fileRun.status, expectedCode, fileRun.stderr);
+ const expected = fs.readFileSync(reference, 'utf8');
+ assert.ok(Buffer.byteLength(expected) > 64 * 1024, 'fixture must exceed a 64 KiB pipe buffer');
+ const receipt = JSON.parse(expected);
+ assert.equal(receipt.ok, profile === 'standard');
+ assert.equal(receipt.composition.issues.length, count * (count - 1) / 2);
+ assert.ok(receipt.composition.issues.every((issue) => (
+ issue.code === 'composition/ambiguous-corridor'
+ && issue.severity === (profile === 'standard' ? 'warning' : 'error')
+ )));
+
+ const piped = run(checker, [html]);
+ assert.equal(piped.status, expectedCode, piped.stderr);
+ assert.equal(piped.stderr, '');
+ assert.equal(Buffer.byteLength(piped.stdout), Buffer.byteLength(expected), 'pipe must not truncate the receipt');
+ assert.equal(piped.stdout, expected);
+ assert.deepEqual(JSON.parse(piped.stdout), receipt);
+ });
+}
+
+function denseArchitecture() {
+ const count = 20;
+ const components = [];
+ const connections = [];
+ for (let index = 0; index < count; index += 1) {
+ const sourceX = 40 + index * 160;
+ const targetX = 40 + (count - 1 - index) * 160;
+ components.push(
+ { id: `source-${index}`, type: 'backend', label: `Source ${index}`, pos: [sourceX, 40], size: [120, 60] },
+ { id: `target-${index}`, type: 'database', label: `Target ${index}`, pos: [targetX, 400], size: [120, 60] },
+ );
+ connections.push({
+ id: `edge-${index}`,
+ from: `source-${index}`,
+ to: `target-${index}`,
+ fromSide: 'bottom',
+ toSide: 'top',
+ via: [[sourceX + 60, 240], [targetX + 60, 240]],
+ });
+ }
+ return {
+ schema_version: 1,
+ diagram_type: 'architecture',
+ meta: { title: 'Large receipt regression', quality_profile: 'standard' },
+ components,
+ connections,
+ };
+}
+
+for (const command of ['validate', 'deliver', 'compare']) {
+ test(`${command} consumes a complete artifact receipt larger than 64 KiB`, () => {
+ const source = denseArchitecture();
+ const input = path.join(tmp, `${command}.architecture.json`);
+ const output = path.join(tmp, `${command}.html`);
+ fs.writeFileSync(input, JSON.stringify(source));
+ const args = command === 'validate' ? [input]
+ : command === 'deliver' ? [input, output]
+ : [input, input, output];
+ const result = run(cli, [command, 'architecture', ...args, '--json']);
+ assert.equal(result.status, 0, result.stderr || result.stdout);
+ assert.equal(result.stderr, '');
+ const receipt = JSON.parse(result.stdout);
+ assert.equal(receipt.ok, true);
+ assert.equal(receipt.command, command);
+ if (command === 'validate') {
+ assert.ok(Buffer.byteLength(result.stdout) > 64 * 1024);
+ assert.ok(receipt.checks.every((check) => check.ok));
+ assert.ok(receipt.composition.issues.length > 100);
+ } else {
+ const artifact = fs.readFileSync(output);
+ assert.ok(artifact.length > 0);
+ if (command === 'deliver') {
+ assert.equal(receipt.artifact.sha256, createHash('sha256').update(artifact).digest('hex'));
+ } else {
+ assert.equal(receipt.completeness, 'complete');
+ assert.equal(receipt.proofLevel, 'authored');
+ }
+ }
+ });
+}