Skip to content

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

fix: support long UNC staging paths

sunsunsunbe6c63fa4651
diff --git a/archify.zip b/archify.zip
index e3736e21..4041fdca 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/bin/archify.mjs b/archify/bin/archify.mjs
index 6e726856..2040760f 100755
--- a/archify/bin/archify.mjs
+++ b/archify/bin/archify.mjs
@@ -850,7 +850,10 @@ function cleanupOwnedStagingDirectory(directory, identity, registry, fileBinding
}
function createOwnedEmptyStagingDirectory(prefix) {
- const directory = fs.mkdtempSync(prefix);
+ // Node's Windows mkdtemp binding does not consistently promote an ordinary
+ // UNC prefix past MAX_PATH. Use the equivalent namespaced spelling for the
+ // syscall while preserving the same physical directory identity.
+ const directory = fs.mkdtempSync(path.toNamespacedPath(prefix));
const metadata = fs.lstatSync(directory, { bigint: true });
if (!metadata.isDirectory() || metadata.isSymbolicLink() || metadata.ino === 0n) {
throw new Error(`Private staging directory identity is unavailable: ${directory}`);
diff --git a/archify/bin/preview.mjs b/archify/bin/preview.mjs
index 4c50befc..53af8a54 100644
--- a/archify/bin/preview.mjs
+++ b/archify/bin/preview.mjs
@@ -371,7 +371,9 @@ export async function startPreview(options) {
// symlink or junction in the requested output parent may be redirected while
// preview is running and must not redirect recursive cleanup to a claimant.
const physicalOutputDirectory = fs.realpathSync.native(outputDirectory);
- const stagingDirectory = fs.mkdtempSync(path.join(physicalOutputDirectory, '.archify-preview-'));
+ const stagingDirectory = fs.mkdtempSync(path.toNamespacedPath(
+ path.join(physicalOutputDirectory, '.archify-preview-'),
+ ));
let stagingIdentity;
try {
stagingIdentity = captureOwnedDirectory(stagingDirectory);
diff --git a/archify/bin/visual-check.mjs b/archify/bin/visual-check.mjs
index 9943ef6f..28fd59f7 100644
--- a/archify/bin/visual-check.mjs
+++ b/archify/bin/visual-check.mjs
@@ -753,7 +753,9 @@ function beginVisualEvidenceWrite(artifactPath, artifactBytes, outputs) {
let stagingDirectory;
let stagingStat;
try {
- stagingDirectory = fs.mkdtempSync(path.join(parent.parentPath, '.archify-visual-check-'));
+ stagingDirectory = fs.mkdtempSync(path.toNamespacedPath(
+ path.join(parent.parentPath, '.archify-visual-check-'),
+ ));
stagingStat = fs.lstatSync(stagingDirectory, { bigint: true });
if (!stagingStat.isDirectory() || stagingStat.isSymbolicLink() || stagingStat.ino === 0n) {
throw new Error('the newly created staging directory has no stable directory identity');
diff --git a/archify/test/release-package-gates.test.mjs b/archify/test/release-package-gates.test.mjs
index 4c1d2c3a..1d56bd36 100644
--- a/archify/test/release-package-gates.test.mjs
+++ b/archify/test/release-package-gates.test.mjs
@@ -1541,8 +1541,13 @@ test('CI and tagged releases share the maintained Windows path contract on Node
assert.match(runner, /checkForUpdate\(\{/);
assert.match(runner, /let ordinaryLongDirectory = uncRoot/);
assert.match(runner, /ordinary UNC delivery beyond traditional MAX_PATH/);
+ assert.match(runner, /ordinary UNC visual-check beyond traditional MAX_PATH/);
assert.match(runner, /let extendedLongDirectory = extendedUncRoot/);
assert.match(runner, /extended UNC delivery beyond traditional MAX_PATH/);
+ assert.match(runner, /path\.win32\.join\(ordinaryLongDirectory, `\$\{token\}-preview[.]html`\)/);
+ assert.match(runner, /assertNoPrivateStaging\(ordinaryLongDirectory, '[.]archify-delivery-'\)/);
+ assert.match(runner, /assertNoPrivateStaging\(evidenceDirectory, '[.]archify-visual-check-'\)/);
+ assert.match(runner, /assertNoPrivateStaging\(ordinaryLongDirectory, '[.]archify-preview-'\)/);
assert.match(runner, /case-sensitive upper artifact visual-check to shared UNC/);
assert.match(runner, /case-sensitive lower artifact visual-check to shared UNC/);
assert.match(runner, /case-variant artifacts must receive distinct evidence names/);
@@ -1553,6 +1558,16 @@ test('CI and tagged releases share the maintained Windows path contract on Node
assert.match(runner, /normalization-distinct artifacts must receive distinct evidence names/);
assert.match(runner, /build-zip[.]sh/);
+ const cliSource = fs.readFileSync(path.join(repoRoot, 'archify', 'bin', 'archify.mjs'), 'utf8');
+ const previewSource = fs.readFileSync(path.join(repoRoot, 'archify', 'bin', 'preview.mjs'), 'utf8');
+ const visualCheckSource = fs.readFileSync(
+ path.join(repoRoot, 'archify', 'bin', 'visual-check.mjs'),
+ 'utf8',
+ );
+ assert.match(cliSource, /mkdtempSync\(path[.]toNamespacedPath\(prefix\)\)/);
+ assert.match(previewSource, /mkdtempSync\(path[.]toNamespacedPath\(\s*path[.]join\(physicalOutputDirectory, '[.]archify-preview-'\),\s*\)\)/);
+ assert.match(visualCheckSource, /mkdtempSync\(path[.]toNamespacedPath\(\s*path[.]join\(parent[.]parentPath, '[.]archify-visual-check-'\),\s*\)\)/);
+
const previewSuite = fs.readFileSync(path.join(repoRoot, 'archify', 'test', 'preview.test.mjs'), 'utf8');
assert.match(previewSuite, /process\.env\.ARCHIFY_REQUIRE_WINDOWS_8DOT3 === '1'/);
assert.match(previewSuite, /process\.env\.ARCHIFY_WINDOWS_8DOT3_ROOT/);
diff --git a/scripts/run-windows-path-tests.mjs b/scripts/run-windows-path-tests.mjs
index 862e6e34..82a3bb4f 100644
--- a/scripts/run-windows-path-tests.mjs
+++ b/scripts/run-windows-path-tests.mjs
@@ -65,6 +65,14 @@ function removeChildren(directory) {
}
}
+function assertNoPrivateStaging(directory, prefix) {
+ assert.deepEqual(
+ fs.readdirSync(directory).filter((entry) => entry.startsWith(prefix)),
+ [],
+ `${prefix} staging must be removed from ${directory}`,
+ );
+}
+
async function waitForVerifiedPreview(url, timeoutMs = 30_000) {
const started = Date.now();
let latest;
@@ -320,6 +328,8 @@ async function runControlledWindowsPathE2E() {
requireSuccess('ordinary UNC delivery beyond traditional MAX_PATH', ordinaryLongDelivery);
assert.equal(JSON.parse(ordinaryLongDelivery.stdout).ok, true);
assert.ok(fs.existsSync(ordinaryLongOutput));
+ assertNoPrivateStaging(ordinaryLongDirectory, '.archify-delivery-');
+ assertNoPrivateStaging(ordinaryLongDirectory, '.archify-provenance-');
let extendedLongDirectory = extendedUncRoot;
for (let index = 0; extendedLongDirectory.length <= 320; index += 1) {
@@ -342,13 +352,22 @@ async function runControlledWindowsPathE2E() {
assert.equal(JSON.parse(extendedLongDelivery.stdout).ok, true);
assert.ok(fs.existsSync(extendedLongOutput));
- const evidenceDirectory = path.win32.join(uncRoot, `${token}-visual-evidence`);
+ const evidenceDirectory = path.win32.join(
+ ordinaryLongDirectory,
+ `${token}-visual-evidence`,
+ );
const visual = runCli([
- 'visual-check', ordinaryDelivery, '--json', '--require-provenance',
+ 'visual-check', ordinaryLongOutput, '--json', '--require-provenance',
'--out-dir', evidenceDirectory,
], { timeout: 180_000 });
- requireSuccess('ordinary UNC visual-check', visual);
- assert.equal(JSON.parse(visual.stdout).status, 'pass');
+ requireSuccess('ordinary UNC visual-check beyond traditional MAX_PATH', visual);
+ const ordinaryLongVisualReceipt = JSON.parse(visual.stdout);
+ assert.equal(ordinaryLongVisualReceipt.status, 'pass');
+ assert.ok(fs.existsSync(path.win32.join(
+ ordinaryLongVisualReceipt.sidecars.directory,
+ ordinaryLongVisualReceipt.sidecars.receipt,
+ )));
+ assertNoPrivateStaging(evidenceDirectory, '.archify-visual-check-');
const sharedCaseEvidenceDirectory = path.win32.join(
uncRoot,
@@ -430,7 +449,7 @@ async function runControlledWindowsPathE2E() {
nfdReceipt.sidecars.receipt,
)));
- const previewOutput = path.win32.join(extendedUncRoot, `${token}-preview.html`);
+ const previewOutput = path.win32.join(ordinaryLongDirectory, `${token}-preview.html`);
const { startPreview } = await import('../archify/bin/preview.mjs');
preview = await startPreview({
type: 'architecture',
@@ -442,9 +461,10 @@ async function runControlledWindowsPathE2E() {
pollMs: 60_000,
});
await waitForVerifiedPreview(preview.url);
- assert.ok(fs.existsSync(path.win32.join(uncRoot, path.win32.basename(previewOutput))));
+ assert.ok(fs.existsSync(previewOutput));
await preview.stop();
preview = null;
+ assertNoPrivateStaging(ordinaryLongDirectory, '.archify-preview-');
if (Number(process.versions.node.split('.')[0]) === 22) {
const uncArchive = path.win32.join(uncRoot, `${token}-archify.zip`);