Skip to content

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

Merge remote-tracking branch 'upstream/dev' into perf/repair-signals

momoyeyu65ae229307e1
diff --cc archify.zip
index 39fa6f7d,95bcc155..6060b4c2
Binary files differ
diff --cc test/finalize.test.mjs
index b14d9264,e7a8a4d5..1b60d487
--- a/test/finalize.test.mjs
+++ b/test/finalize.test.mjs
@@@ -1181,55 -1106,72 +1182,125 @@@ test('finalize rechecks delivery barrie
}
});
+test('default finalize JSON preserves complete verified workflow repairs', t => {
+ const directory = workspace(t);
+ const input = path.join(directory, 'shared-endpoint.json');
+ const output = path.join(directory, 'shared-endpoint.html');
+ const receipt = path.join(directory, 'receipt.json');
+ const cli = fileURLToPath(new URL('../archify/bin/archify.mjs', import.meta.url));
+ const source = {
+ schema_version: 2,
+ diagram_type: 'workflow',
+ meta: { title: 'Shared missing endpoint', output: 'shared-endpoint.html', legend: { mode: 'hidden' } },
+ lanes: [{ id: 'main', label: 'M' }],
+ nodes: ['a', 'b', 'c'].map((id, col) => ({ id, lane: 'main', col, type: 'backend', label: id.toUpperCase() })),
+ edges: [{ id: 'ab', from: 'a', to: 'ghost' }, { id: 'bc', from: 'ghost', to: 'c' }],
+ mainPath: ['a', 'ghost', 'c'],
+ };
+ fs.writeFileSync(input, JSON.stringify(source));
+ const finalized = spawnSync(process.execPath, [
+ cli, 'finalize', 'workflow', input, output, '--quality', 'standard', '--json', '--receipt', receipt,
+ ], { encoding: 'utf8', timeout: 30000 });
+ assert.equal(finalized.status, 1, finalized.stderr || finalized.stdout);
+ const summary = JSON.parse(finalized.stdout);
+ const full = JSON.parse(fs.readFileSync(receipt, 'utf8'));
+ const diagnostic = summary.diagnostics.find(entry => entry.code === 'workflow/unknown-edge-endpoint');
+ assert.ok(diagnostic);
+ assert.deepEqual(diagnostic.supportedFixes,
+ full.diagnostics.find(entry => entry.code === diagnostic.code).supportedFixes);
+ const candidates = new Map();
+ for (const fix of diagnostic.supportedFixes) {
+ const match = /^set (\/\S+) to verified node id "([^"]+)"$/.exec(fix);
+ assert.ok(match, `Expected an executable verified repoint: ${fix}`);
+ const [, pointer, candidate] = match;
+ if (!candidates.has(candidate)) candidates.set(candidate, []);
+ candidates.get(candidate).push(pointer);
+ }
+ assert.ok(candidates.size > 0);
+ for (const [candidate, pointers] of candidates) {
+ assert.deepEqual([...pointers].sort(), ['/edges/0/to', '/edges/1/from', '/mainPath/1']);
+ const repaired = structuredClone(source);
+ for (const pointer of pointers) {
+ const segments = pointer.slice(1).split('/');
+ const key = segments.pop();
+ const parent = segments.reduce((value, segment) => value[segment], repaired);
+ parent[key] = candidate;
+ }
+ fs.writeFileSync(input, JSON.stringify(repaired));
+ const validated = spawnSync(process.execPath, [
+ cli, 'validate', 'workflow', input, '--quality', 'standard', '--json',
+ ], { encoding: 'utf8', timeout: 30000 });
+ assert.equal(validated.status, 0, validated.stderr || validated.stdout);
+ assert.equal(JSON.parse(validated.stdout).ok, true);
+ }
+});
++
+ 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 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: 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: 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');
+ });