@indigoai-us/hq-cloud 6.15.0 → 6.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/sync-mutation.d.ts +16 -0
- package/dist/bin/sync-mutation.d.ts.map +1 -0
- package/dist/bin/sync-mutation.js +60 -0
- package/dist/bin/sync-mutation.js.map +1 -0
- package/dist/bin/sync-mutation.test.d.ts +2 -0
- package/dist/bin/sync-mutation.test.d.ts.map +1 -0
- package/dist/bin/sync-mutation.test.js +165 -0
- package/dist/bin/sync-mutation.test.js.map +1 -0
- package/dist/bin/sync-runner-company.d.ts +8 -0
- package/dist/bin/sync-runner-company.d.ts.map +1 -1
- package/dist/bin/sync-runner-company.js +16 -0
- package/dist/bin/sync-runner-company.js.map +1 -1
- package/dist/bin/sync-runner-company.test.d.ts +2 -0
- package/dist/bin/sync-runner-company.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-company.test.js +36 -0
- package/dist/bin/sync-runner-company.test.js.map +1 -0
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +98 -8
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner.d.ts +17 -0
- package/dist/bin/sync-runner.d.ts.map +1 -1
- package/dist/bin/sync-runner.js.map +1 -1
- package/dist/bin/sync-runner.test.js +109 -0
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/cli/conflict-recovery.test.d.ts +2 -0
- package/dist/cli/conflict-recovery.test.d.ts.map +1 -0
- package/dist/cli/conflict-recovery.test.js +201 -0
- package/dist/cli/conflict-recovery.test.js.map +1 -0
- package/dist/cli/conflict.d.ts +60 -0
- package/dist/cli/conflict.d.ts.map +1 -1
- package/dist/cli/conflict.js +333 -0
- package/dist/cli/conflict.js.map +1 -1
- package/dist/cli/sync.d.ts +35 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +100 -0
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/sync.test.js +85 -1
- package/dist/cli/sync.test.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/skill-telemetry.d.ts +6 -0
- package/dist/skill-telemetry.d.ts.map +1 -1
- package/dist/skill-telemetry.js +14 -2
- package/dist/skill-telemetry.js.map +1 -1
- package/dist/skill-telemetry.test.js +79 -0
- package/dist/skill-telemetry.test.js.map +1 -1
- package/dist/sync/candidate-uploader.d.ts +88 -0
- package/dist/sync/candidate-uploader.d.ts.map +1 -0
- package/dist/sync/candidate-uploader.js +212 -0
- package/dist/sync/candidate-uploader.js.map +1 -0
- package/dist/sync/candidate-uploader.test.d.ts +2 -0
- package/dist/sync/candidate-uploader.test.d.ts.map +1 -0
- package/dist/sync/candidate-uploader.test.js +132 -0
- package/dist/sync/candidate-uploader.test.js.map +1 -0
- package/dist/sync/delta-client.d.ts +73 -0
- package/dist/sync/delta-client.d.ts.map +1 -0
- package/dist/sync/delta-client.js +201 -0
- package/dist/sync/delta-client.js.map +1 -0
- package/dist/sync/delta-client.test.d.ts +2 -0
- package/dist/sync/delta-client.test.d.ts.map +1 -0
- package/dist/sync/delta-client.test.js +97 -0
- package/dist/sync/delta-client.test.js.map +1 -0
- package/dist/sync/durable-apply.d.ts +76 -0
- package/dist/sync/durable-apply.d.ts.map +1 -0
- package/dist/sync/durable-apply.js +530 -0
- package/dist/sync/durable-apply.js.map +1 -0
- package/dist/sync/durable-apply.test.d.ts +2 -0
- package/dist/sync/durable-apply.test.d.ts.map +1 -0
- package/dist/sync/durable-apply.test.js +180 -0
- package/dist/sync/durable-apply.test.js.map +1 -0
- package/dist/sync/event-sync.d.ts +33 -1
- package/dist/sync/event-sync.d.ts.map +1 -1
- package/dist/sync/event-sync.js +149 -1
- package/dist/sync/event-sync.js.map +1 -1
- package/dist/sync/event-sync.test.js +142 -1
- package/dist/sync/event-sync.test.js.map +1 -1
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +1 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/multipart-uploader.d.ts +99 -0
- package/dist/sync/multipart-uploader.d.ts.map +1 -0
- package/dist/sync/multipart-uploader.js +447 -0
- package/dist/sync/multipart-uploader.js.map +1 -0
- package/dist/sync/multipart-uploader.test.d.ts +2 -0
- package/dist/sync/multipart-uploader.test.d.ts.map +1 -0
- package/dist/sync/multipart-uploader.test.js +119 -0
- package/dist/sync/multipart-uploader.test.js.map +1 -0
- package/dist/sync/mutation-client.d.ts +85 -0
- package/dist/sync/mutation-client.d.ts.map +1 -0
- package/dist/sync/mutation-client.js +245 -0
- package/dist/sync/mutation-client.js.map +1 -0
- package/dist/sync/mutation-client.test.d.ts +2 -0
- package/dist/sync/mutation-client.test.d.ts.map +1 -0
- package/dist/sync/mutation-client.test.js +51 -0
- package/dist/sync/mutation-client.test.js.map +1 -0
- package/dist/sync/push-receiver.d.ts +45 -0
- package/dist/sync/push-receiver.d.ts.map +1 -1
- package/dist/sync/push-receiver.js +101 -0
- package/dist/sync/push-receiver.js.map +1 -1
- package/dist/sync/push-receiver.test.js +54 -2
- package/dist/sync/push-receiver.test.js.map +1 -1
- package/dist/sync/scope-inventory-client.d.ts +69 -0
- package/dist/sync/scope-inventory-client.d.ts.map +1 -0
- package/dist/sync/scope-inventory-client.js +210 -0
- package/dist/sync/scope-inventory-client.js.map +1 -0
- package/dist/sync/scope-inventory-client.test.d.ts +2 -0
- package/dist/sync/scope-inventory-client.test.d.ts.map +1 -0
- package/dist/sync/scope-inventory-client.test.js +94 -0
- package/dist/sync/scope-inventory-client.test.js.map +1 -0
- package/dist/sync/snapshot-client.d.ts +98 -0
- package/dist/sync/snapshot-client.d.ts.map +1 -0
- package/dist/sync/snapshot-client.js +402 -0
- package/dist/sync/snapshot-client.js.map +1 -0
- package/dist/sync/snapshot-client.test.d.ts +2 -0
- package/dist/sync/snapshot-client.test.d.ts.map +1 -0
- package/dist/sync/snapshot-client.test.js +169 -0
- package/dist/sync/snapshot-client.test.js.map +1 -0
- package/dist/sync/uploader-finalization.d.ts +97 -0
- package/dist/sync/uploader-finalization.d.ts.map +1 -0
- package/dist/sync/uploader-finalization.js +273 -0
- package/dist/sync/uploader-finalization.js.map +1 -0
- package/dist/sync/uploader-finalization.test.d.ts +2 -0
- package/dist/sync/uploader-finalization.test.d.ts.map +1 -0
- package/dist/sync/uploader-finalization.test.js +92 -0
- package/dist/sync/uploader-finalization.test.js.map +1 -0
- package/dist/telemetry.d.ts +11 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +21 -2
- package/dist/telemetry.js.map +1 -1
- package/dist/telemetry.test.js +80 -0
- package/dist/telemetry.test.js.map +1 -1
- package/package.json +6 -1
- package/.claude/policies/hq-cloud-esm-cannot-spy-fs-builtins.md +0 -30
- package/.claude/policies/hq-cloud-strip-types-no-parameter-properties.md +0 -22
- package/.github/workflows/ci.yml +0 -84
- package/.github/workflows/publish.yml +0 -56
- package/.github/workflows/unreleased-commits-nag.yml +0 -256
- package/eslint.config.js +0 -67
- package/pnpm-workspace.yaml +0 -2
- package/scripts/presign-transport-e2e.mjs +0 -250
- package/scripts/vault-rebaseline.sh +0 -323
- package/scripts/vault-rescue.sh +0 -332
- package/src/active-company.test.ts +0 -188
- package/src/active-company.ts +0 -168
- package/src/agent-codex-instructions.test.ts +0 -332
- package/src/agent-codex-instructions.ts +0 -309
- package/src/auth.ts +0 -146
- package/src/backup-prune.test.ts +0 -98
- package/src/backup-prune.ts +0 -182
- package/src/bin/backup-prune-runner.ts +0 -33
- package/src/bin/rescue-runner.ts +0 -25
- package/src/bin/sync-runner-company.ts +0 -695
- package/src/bin/sync-runner-events.test.ts +0 -143
- package/src/bin/sync-runner-events.ts +0 -55
- package/src/bin/sync-runner-planning.test.ts +0 -311
- package/src/bin/sync-runner-planning.ts +0 -258
- package/src/bin/sync-runner-rollup.test.ts +0 -37
- package/src/bin/sync-runner-rollup.ts +0 -97
- package/src/bin/sync-runner-telemetry.ts +0 -15
- package/src/bin/sync-runner-watch-loop.ts +0 -1235
- package/src/bin/sync-runner-watch-routes.test.ts +0 -71
- package/src/bin/sync-runner-watch-routes.ts +0 -184
- package/src/bin/sync-runner.test.ts +0 -8767
- package/src/bin/sync-runner.ts +0 -2190
- package/src/cli/accept.ts +0 -124
- package/src/cli/conflict.ts +0 -119
- package/src/cli/doctor.test.ts +0 -581
- package/src/cli/doctor.ts +0 -642
- package/src/cli/index.ts +0 -49
- package/src/cli/invite.test.ts +0 -250
- package/src/cli/invite.ts +0 -214
- package/src/cli/promote.ts +0 -157
- package/src/cli/reindex-knowledge.test.ts +0 -307
- package/src/cli/reindex-knowledge.ts +0 -450
- package/src/cli/reindex.test.ts +0 -957
- package/src/cli/reindex.ts +0 -979
- package/src/cli/rescue-classify-ordering.test.ts +0 -548
- package/src/cli/rescue-clone-diagnostics.test.ts +0 -120
- package/src/cli/rescue-core.ts +0 -3011
- package/src/cli/rescue-drift-reconcile.test.ts +0 -179
- package/src/cli/rescue-drop-dir-symlink.test.ts +0 -224
- package/src/cli/rescue-exec-bit-preserve.test.ts +0 -187
- package/src/cli/rescue-hq-root-guard.test.ts +0 -232
- package/src/cli/rescue-journal-reconcile.test.ts +0 -215
- package/src/cli/rescue-mtime-preserve.test.ts +0 -203
- package/src/cli/rescue-settings-reconcile.test.ts +0 -637
- package/src/cli/rescue-snapshot.test.ts +0 -57
- package/src/cli/rescue-snapshot.ts +0 -51
- package/src/cli/rescue.reindex.test.ts +0 -63
- package/src/cli/rescue.test.ts +0 -131
- package/src/cli/rescue.ts +0 -182
- package/src/cli/share.test.ts +0 -7843
- package/src/cli/share.ts +0 -3663
- package/src/cli/sync-scope.test.ts +0 -652
- package/src/cli/sync.test.ts +0 -5207
- package/src/cli/sync.ts +0 -3470
- package/src/cli/tombstones.ts +0 -106
- package/src/cli/watch-event-push-conflict.test.ts +0 -234
- package/src/client-info.test.ts +0 -214
- package/src/client-info.ts +0 -121
- package/src/cognito-auth.test.ts +0 -712
- package/src/cognito-auth.ts +0 -1422
- package/src/company-resolver.test.ts +0 -618
- package/src/company-resolver.ts +0 -521
- package/src/context.test.ts +0 -583
- package/src/context.ts +0 -378
- package/src/daemon-worker.ts +0 -26
- package/src/daemon.ts +0 -99
- package/src/entity-resolver.test.ts +0 -315
- package/src/entity-resolver.ts +0 -180
- package/src/ignore.test.ts +0 -466
- package/src/ignore.ts +0 -469
- package/src/index.ts +0 -439
- package/src/journal.test.ts +0 -968
- package/src/journal.ts +0 -765
- package/src/lib/cloud-authoritative.test.ts +0 -45
- package/src/lib/cloud-authoritative.ts +0 -59
- package/src/lib/conflict-file.ts +0 -86
- package/src/lib/conflict-index.ts +0 -289
- package/src/lib/conflict.test.ts +0 -348
- package/src/lib/describe-error.test.ts +0 -100
- package/src/lib/describe-error.ts +0 -58
- package/src/lib/exit-codes.ts +0 -24
- package/src/lib/machine-id.test.ts +0 -231
- package/src/lib/machine-id.ts +0 -175
- package/src/lib/net-errors.test.ts +0 -65
- package/src/lib/net-errors.ts +0 -86
- package/src/lib/readlink-safe.test.ts +0 -43
- package/src/lib/readlink-safe.ts +0 -29
- package/src/local-path-codec.test.ts +0 -138
- package/src/local-path-codec.ts +0 -161
- package/src/machine-auth.test.ts +0 -1323
- package/src/manifest-reconcile.test.ts +0 -1123
- package/src/manifest-reconcile.ts +0 -518
- package/src/object-io.test.ts +0 -1221
- package/src/object-io.ts +0 -1306
- package/src/operation-lock.test.ts +0 -484
- package/src/operation-lock.ts +0 -680
- package/src/outcome-telemetry.test.ts +0 -498
- package/src/outcome-telemetry.ts +0 -639
- package/src/personal-vault-exclusions.test.ts +0 -308
- package/src/personal-vault-exclusions.ts +0 -354
- package/src/personal-vault.test.ts +0 -756
- package/src/personal-vault.ts +0 -496
- package/src/prefix-coalesce.test.ts +0 -240
- package/src/prefix-coalesce.ts +0 -273
- package/src/public-surface.test.ts +0 -117
- package/src/qmd-reindex.test.ts +0 -877
- package/src/qmd-reindex.ts +0 -842
- package/src/read-only-state-dir.test.ts +0 -188
- package/src/remote-pull.test.ts +0 -1130
- package/src/remote-pull.ts +0 -618
- package/src/s3.symlink-materialize.test.ts +0 -492
- package/src/s3.test.ts +0 -1789
- package/src/s3.ts +0 -1532
- package/src/schemas/signal-types.test.ts +0 -82
- package/src/schemas/signal-types.ts +0 -38
- package/src/schemas/source-channels.test.ts +0 -82
- package/src/schemas/source-channels.ts +0 -53
- package/src/scope-shrink.test.ts +0 -633
- package/src/scope-shrink.ts +0 -481
- package/src/signals/get.test.ts +0 -310
- package/src/signals/get.ts +0 -75
- package/src/signals/internals.ts +0 -195
- package/src/signals/list.test.ts +0 -420
- package/src/signals/list.ts +0 -79
- package/src/signals/parse.ts +0 -8
- package/src/signals/types.ts +0 -91
- package/src/skill-telemetry.test.ts +0 -1825
- package/src/skill-telemetry.ts +0 -1439
- package/src/sources/get.test.ts +0 -293
- package/src/sources/get.ts +0 -66
- package/src/sources/internals.ts +0 -198
- package/src/sources/list.test.ts +0 -402
- package/src/sources/list.ts +0 -84
- package/src/sources/parse.ts +0 -43
- package/src/sources/types.ts +0 -84
- package/src/sync/event-sync.test.ts +0 -594
- package/src/sync/event-sync.ts +0 -545
- package/src/sync/feature-flags.test.ts +0 -378
- package/src/sync/feature-flags.ts +0 -62
- package/src/sync/index.ts +0 -76
- package/src/sync/lease-client.test.ts +0 -128
- package/src/sync/lease-client.ts +0 -207
- package/src/sync/logger.test.ts +0 -242
- package/src/sync/logger.ts +0 -79
- package/src/sync/metrics.test.ts +0 -462
- package/src/sync/metrics.ts +0 -213
- package/src/sync/pull-scope.ts +0 -265
- package/src/sync/push-event.test.ts +0 -266
- package/src/sync/push-event.ts +0 -224
- package/src/sync/push-receiver.test.ts +0 -566
- package/src/sync/push-receiver.ts +0 -1048
- package/src/sync/push-transport.ts +0 -231
- package/src/sync/realtime-rollout.test.ts +0 -86
- package/src/sync/realtime-rollout.ts +0 -262
- package/src/sync/state-store.test.ts +0 -194
- package/src/sync/state-store.ts +0 -727
- package/src/sync-core.ts +0 -58
- package/src/sync-progress.test.ts +0 -94
- package/src/sync-progress.ts +0 -140
- package/src/telemetry-events.test.ts +0 -88
- package/src/telemetry-events.ts +0 -205
- package/src/telemetry.test.ts +0 -1280
- package/src/telemetry.ts +0 -1109
- package/src/types.ts +0 -314
- package/src/vault-client.test.ts +0 -1380
- package/src/vault-client.ts +0 -1694
- package/src/version.ts +0 -24
- package/src/watch-roots.test.ts +0 -278
- package/src/watch-roots.ts +0 -162
- package/src/watcher-event-gate.test.ts +0 -212
- package/src/watcher.test.ts +0 -1079
- package/src/watcher.ts +0 -1741
- package/test/e2e/sync/cross-tenant-isolation.test.ts +0 -630
- package/test/e2e/sync/skill-telemetry-oversized-transcript.test.ts +0 -124
- package/test/e2e/sync/transient-company-leg.test.ts +0 -384
- package/test/e2e/sync/windows-unreadable-link-leg.test.ts +0 -191
- package/test/e2e/watcher-real-chokidar.test.ts +0 -165
- package/test/e2e/watcher-recursive-backend.test.ts +0 -181
- package/test/e2e/watcher-scoped-coverage.test.ts +0 -381
- package/test/invite-flow.integration.test.ts +0 -244
- package/test/joiner-manifest-reconcile.integration.test.ts +0 -322
- package/test/share-sync.integration.test.ts +0 -213
- package/tsconfig.json +0 -19
- package/vitest.config.ts +0 -22
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Regression tests for US-001 (hq-sync-windows-skill-symlink-collision):
|
|
3
|
-
* Windows-safe, idempotent symlink materialization in downloadFile.
|
|
4
|
-
*
|
|
5
|
-
* Background: the .claude/skills/<ns>:<skill> link farm is materialized from
|
|
6
|
-
* `hq-symlink:<target>` records. Pre-fix, downloadFile always did
|
|
7
|
-
* symlinkSync(temp) + renameSync(temp, dest). On Windows that is doubly
|
|
8
|
-
* broken: (1) rename() can never replace an existing directory — and a
|
|
9
|
-
* directory symlink counts as one — so every pull over the farm EPERM'd,
|
|
10
|
-
* never journaled, and re-downloaded forever; (2) a bare symlinkSync mints a
|
|
11
|
-
* FILE-type link, which is broken for directory targets on Windows.
|
|
12
|
-
*
|
|
13
|
-
* Windows semantics are exercised via the injectable `win32` option (the
|
|
14
|
-
* local-path-codec.ts convention) plus scripted fs fakes, so these tests are
|
|
15
|
-
* deterministic on POSIX CI and on a real Windows host alike.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
|
19
|
-
import * as fs from "fs";
|
|
20
|
-
import * as os from "os";
|
|
21
|
-
import * as path from "path";
|
|
22
|
-
|
|
23
|
-
// Re-export node:fs as a plain mutable object so vi.spyOn can instrument
|
|
24
|
-
// individual functions (the frozen ESM namespace of a builtin cannot be
|
|
25
|
-
// spied on directly). Every copied function still delegates to the real
|
|
26
|
-
// implementation until a test overrides it.
|
|
27
|
-
vi.mock("fs", async (importOriginal) => {
|
|
28
|
-
const actual = await importOriginal<typeof import("fs")>();
|
|
29
|
-
return { ...actual };
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
import { downloadFile, SYMLINK_BODY_PREFIX, SYMLINK_MARKER_META_VALUE } from "./s3.js";
|
|
33
|
-
import { localPathForVaultKey } from "./local-path-codec.js";
|
|
34
|
-
import { setObjectIOFactory, type ObjectIO } from "./object-io.js";
|
|
35
|
-
import type { EntityContext } from "./types.js";
|
|
36
|
-
|
|
37
|
-
function makeCtx(): EntityContext {
|
|
38
|
-
return {
|
|
39
|
-
uid: "cmp_TEST",
|
|
40
|
-
slug: "acme",
|
|
41
|
-
bucketName: "hq-vault-acme-123",
|
|
42
|
-
region: "us-east-1",
|
|
43
|
-
credentials: {
|
|
44
|
-
accessKeyId: "ASIA_TEST",
|
|
45
|
-
secretAccessKey: "secret",
|
|
46
|
-
sessionToken: "session",
|
|
47
|
-
},
|
|
48
|
-
expiresAt: new Date(Date.now() + 15 * 60 * 1000).toISOString(),
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** ObjectIO stub serving a single symlink record (marker + prefixed body). */
|
|
53
|
-
function symlinkRecordIO(target: string): ObjectIO {
|
|
54
|
-
return {
|
|
55
|
-
putObject: async () => ({ etag: '"unused"' }),
|
|
56
|
-
getObject: async () => ({
|
|
57
|
-
body: Buffer.from(SYMLINK_BODY_PREFIX + target, "utf-8"),
|
|
58
|
-
metadata: { "hq-symlink-target": SYMLINK_MARKER_META_VALUE },
|
|
59
|
-
}),
|
|
60
|
-
listObjects: async () => ({ objects: [] }),
|
|
61
|
-
deleteObject: async () => undefined,
|
|
62
|
-
headObject: async () => null,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function errnoError(code: string): NodeJS.ErrnoException {
|
|
67
|
-
const err = new Error(`${code}: scripted test failure`) as NodeJS.ErrnoException;
|
|
68
|
-
err.code = code;
|
|
69
|
-
return err;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Minimal fs.Stats fake — only the predicates downloadFile consults. */
|
|
73
|
-
function fakeStats(shape: {
|
|
74
|
-
symlink?: boolean;
|
|
75
|
-
dir?: boolean;
|
|
76
|
-
file?: boolean;
|
|
77
|
-
}): fs.Stats {
|
|
78
|
-
return {
|
|
79
|
-
isSymbolicLink: () => shape.symlink ?? false,
|
|
80
|
-
isDirectory: () => shape.dir ?? false,
|
|
81
|
-
isFile: () => shape.file ?? false,
|
|
82
|
-
} as unknown as fs.Stats;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
describe("downloadFile symlink materialization (US-001)", () => {
|
|
86
|
-
let tmpRoot: string;
|
|
87
|
-
|
|
88
|
-
beforeEach(() => {
|
|
89
|
-
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "s3-symlink-mat-test-"));
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
afterEach(() => {
|
|
93
|
-
vi.restoreAllMocks();
|
|
94
|
-
setObjectIOFactory(null);
|
|
95
|
-
fs.rmSync(tmpRoot, { recursive: true, force: true });
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("fast path: an unchanged symlink is a success WITHOUT touching disk", async () => {
|
|
99
|
-
// The perpetual-churn half of the bug: an already-correct link went
|
|
100
|
-
// through temp+rename anyway, EPERM'd on Windows, never journaled, and
|
|
101
|
-
// re-downloaded every pass. A pull whose incoming target matches the
|
|
102
|
-
// existing link must return success (so the caller journals it) with
|
|
103
|
-
// zero writes — no temp link, no rename, no beforeReplace.
|
|
104
|
-
const target = "../real-target.md";
|
|
105
|
-
const localPath = path.join(tmpRoot, "skills", "link.md");
|
|
106
|
-
fs.mkdirSync(path.dirname(localPath), { recursive: true });
|
|
107
|
-
// Real target on disk: the win32 fast path stat-follows the link to
|
|
108
|
-
// confirm it functions as the desired type (a dangling link would
|
|
109
|
-
// deliberately fall through to replacement).
|
|
110
|
-
fs.writeFileSync(path.join(tmpRoot, "real-target.md"), "target body");
|
|
111
|
-
fs.symlinkSync(target, localPath);
|
|
112
|
-
setObjectIOFactory(() => symlinkRecordIO(target));
|
|
113
|
-
|
|
114
|
-
const symlinkSpy = vi.spyOn(fs, "symlinkSync");
|
|
115
|
-
const renameSpy = vi.spyOn(fs, "renameSync");
|
|
116
|
-
const beforeReplace = vi.fn();
|
|
117
|
-
|
|
118
|
-
const res = await downloadFile(makeCtx(), "skills/link.md", localPath, {
|
|
119
|
-
beforeReplace,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// Success shape matches a materializing pull, so the caller journals it.
|
|
123
|
-
expect(res.metadata?.["hq-symlink-target"]).toBe(SYMLINK_MARKER_META_VALUE);
|
|
124
|
-
expect(symlinkSpy).not.toHaveBeenCalled();
|
|
125
|
-
expect(renameSpy).not.toHaveBeenCalled();
|
|
126
|
-
expect(beforeReplace).not.toHaveBeenCalled();
|
|
127
|
-
expect(fs.lstatSync(localPath).isSymbolicLink()).toBe(true);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("fast path compares readlink() separator-insensitively on win32", async () => {
|
|
131
|
-
// Windows stores the substitute path with backslashes (Node converts
|
|
132
|
-
// '/' at symlink() time), so readlink() of a link created from the
|
|
133
|
-
// POSIX-slashed wire target returns '..\\dir\\target'. The comparison
|
|
134
|
-
// must treat that as equal to the incoming '../dir/target' or the fast
|
|
135
|
-
// path would never fire for any multi-segment target on Windows.
|
|
136
|
-
const wireTarget = "../companies/indigo/skills/call-prep-brief";
|
|
137
|
-
const localPath = path.join(tmpRoot, "farm", "indigo%3Acall-prep-brief");
|
|
138
|
-
fs.mkdirSync(path.dirname(localPath), { recursive: true });
|
|
139
|
-
// Real directory at the resolved target: the link farm's normal shape,
|
|
140
|
-
// and what makes the desired flavor directory-ish (a junction, post-#219).
|
|
141
|
-
fs.mkdirSync(path.resolve(path.dirname(localPath), wireTarget), {
|
|
142
|
-
recursive: true,
|
|
143
|
-
});
|
|
144
|
-
setObjectIOFactory(() => symlinkRecordIO(wireTarget));
|
|
145
|
-
|
|
146
|
-
vi.spyOn(fs, "lstatSync").mockImplementation(() =>
|
|
147
|
-
fakeStats({ symlink: true }),
|
|
148
|
-
);
|
|
149
|
-
// A RELATIVE substitute path — the spelling an older client's 'dir'
|
|
150
|
-
// symlink left behind. It still resolves to the same target, so the
|
|
151
|
-
// fast path must accept it rather than churn the link.
|
|
152
|
-
vi.spyOn(fs, "readlinkSync").mockImplementation(
|
|
153
|
-
() => "..\\companies\\indigo\\skills\\call-prep-brief",
|
|
154
|
-
);
|
|
155
|
-
const realStatSync = fs.statSync.bind(fs) as (p: fs.PathLike) => fs.Stats;
|
|
156
|
-
// The follow-probe on the link itself reports a traversable directory,
|
|
157
|
-
// matching the flavor createStagedSymlink would mint — fast path holds.
|
|
158
|
-
vi.spyOn(fs, "statSync").mockImplementation(((p: fs.PathLike) =>
|
|
159
|
-
p === localPath
|
|
160
|
-
? fakeStats({ dir: true })
|
|
161
|
-
: realStatSync(p)) as typeof fs.statSync);
|
|
162
|
-
const symlinkSpy = vi.spyOn(fs, "symlinkSync");
|
|
163
|
-
const renameSpy = vi.spyOn(fs, "renameSync");
|
|
164
|
-
|
|
165
|
-
const res = await downloadFile(
|
|
166
|
-
makeCtx(),
|
|
167
|
-
".claude/skills/indigo:call-prep-brief",
|
|
168
|
-
localPath,
|
|
169
|
-
{ win32: true },
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
expect(res.metadata).toBeDefined();
|
|
173
|
-
expect(symlinkSpy).not.toHaveBeenCalled();
|
|
174
|
-
expect(renameSpy).not.toHaveBeenCalled();
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("fast path accepts a JUNCTION's absolute substitute path against a relative wire target", async () => {
|
|
178
|
-
// Post-#219, win32 directory overlays are materialized as junctions, and
|
|
179
|
-
// a junction can only store an ABSOLUTE substitute path. readlink() of a
|
|
180
|
-
// link this client itself created therefore returns
|
|
181
|
-
// 'C:\\...\\companies\\indigo\\skills\\call-prep-brief' while the wire
|
|
182
|
-
// target stays '../companies/...'. If equality were a raw string compare
|
|
183
|
-
// the fast path could never fire for the link farm on Windows — every
|
|
184
|
-
// pull would re-stage the whole farm, which is precisely the perpetual
|
|
185
|
-
// churn US-001 exists to kill. Both sides must be resolved before compare.
|
|
186
|
-
const wireTarget = "../companies/indigo/skills/call-prep-brief";
|
|
187
|
-
const localPath = path.join(tmpRoot, "farm", "indigo%3Acall-prep-brief");
|
|
188
|
-
fs.mkdirSync(path.dirname(localPath), { recursive: true });
|
|
189
|
-
const absTarget = path.resolve(path.dirname(localPath), wireTarget);
|
|
190
|
-
fs.mkdirSync(absTarget, { recursive: true });
|
|
191
|
-
setObjectIOFactory(() => symlinkRecordIO(wireTarget));
|
|
192
|
-
|
|
193
|
-
vi.spyOn(fs, "lstatSync").mockImplementation(() =>
|
|
194
|
-
fakeStats({ symlink: true }),
|
|
195
|
-
);
|
|
196
|
-
vi.spyOn(fs, "readlinkSync").mockImplementation(() =>
|
|
197
|
-
absTarget.split("/").join("\\"),
|
|
198
|
-
);
|
|
199
|
-
const realStatSync = fs.statSync.bind(fs) as (p: fs.PathLike) => fs.Stats;
|
|
200
|
-
vi.spyOn(fs, "statSync").mockImplementation(((p: fs.PathLike) =>
|
|
201
|
-
p === localPath
|
|
202
|
-
? fakeStats({ dir: true })
|
|
203
|
-
: realStatSync(p)) as typeof fs.statSync);
|
|
204
|
-
const symlinkSpy = vi.spyOn(fs, "symlinkSync");
|
|
205
|
-
const renameSpy = vi.spyOn(fs, "renameSync");
|
|
206
|
-
|
|
207
|
-
const res = await downloadFile(
|
|
208
|
-
makeCtx(),
|
|
209
|
-
".claude/skills/indigo:call-prep-brief",
|
|
210
|
-
localPath,
|
|
211
|
-
{ win32: true },
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
expect(res.metadata).toBeDefined();
|
|
215
|
-
expect(symlinkSpy).not.toHaveBeenCalled();
|
|
216
|
-
expect(renameSpy).not.toHaveBeenCalled();
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it("win32: a FILE-flavor link at a DIRECTORY target is broken despite a matching target string — recreated as a junction, never fast-pathed", async () => {
|
|
220
|
-
// Round-3 review P1: flavors matter on Windows. An older client (or a
|
|
221
|
-
// pull that ran while the target dir was absent) can leave a file-type
|
|
222
|
-
// link whose target string matches the incoming record exactly; it
|
|
223
|
-
// still cannot be traversed. The fast path must fall through and the
|
|
224
|
-
// materializer must mint the correct directory flavor — post-#219 that
|
|
225
|
-
// is a junction (unprivileged) rather than a 'dir' NTFS symlink.
|
|
226
|
-
const wireTarget = "../companies/indigo/skills/call-prep-brief";
|
|
227
|
-
const localPath = path.join(tmpRoot, "farm", "indigo%3Acall-prep-brief");
|
|
228
|
-
fs.mkdirSync(path.dirname(localPath), { recursive: true });
|
|
229
|
-
const resolvedTarget = path.resolve(path.dirname(localPath), wireTarget);
|
|
230
|
-
fs.mkdirSync(resolvedTarget, { recursive: true });
|
|
231
|
-
setObjectIOFactory(() => symlinkRecordIO(wireTarget));
|
|
232
|
-
|
|
233
|
-
const realStatSync = fs.statSync.bind(fs) as (p: fs.PathLike) => fs.Stats;
|
|
234
|
-
vi.spyOn(fs, "lstatSync").mockImplementation(((p: fs.PathLike) =>
|
|
235
|
-
p === localPath
|
|
236
|
-
? fakeStats({ symlink: true })
|
|
237
|
-
: fakeStats({})) as typeof fs.lstatSync);
|
|
238
|
-
vi.spyOn(fs, "readlinkSync").mockImplementation(
|
|
239
|
-
(() => "..\\companies\\indigo\\skills\\call-prep-brief") as unknown as typeof fs.readlinkSync,
|
|
240
|
-
);
|
|
241
|
-
// Windows refuses to traverse the wrong-flavor link: stat on the link
|
|
242
|
-
// throws, while the resolved target itself stats as a real directory.
|
|
243
|
-
vi.spyOn(fs, "statSync").mockImplementation(((p: fs.PathLike) => {
|
|
244
|
-
if (p === localPath) throw errnoError("EINVAL");
|
|
245
|
-
return realStatSync(p);
|
|
246
|
-
}) as typeof fs.statSync);
|
|
247
|
-
const symlinkSpy = vi
|
|
248
|
-
.spyOn(fs, "symlinkSync")
|
|
249
|
-
.mockImplementation(() => undefined);
|
|
250
|
-
vi.spyOn(fs, "unlinkSync").mockImplementation(() => undefined);
|
|
251
|
-
vi.spyOn(fs, "renameSync").mockImplementation(() => undefined);
|
|
252
|
-
|
|
253
|
-
await downloadFile(makeCtx(), ".claude/skills/indigo:call-prep-brief", localPath, {
|
|
254
|
-
win32: true,
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// Fell through the fast path and minted the correct flavor: a junction,
|
|
258
|
-
// which requires an absolute substitute path.
|
|
259
|
-
expect(symlinkSpy).toHaveBeenCalledTimes(1);
|
|
260
|
-
expect(symlinkSpy.mock.calls[0]![2]).toBe("junction");
|
|
261
|
-
expect(symlinkSpy.mock.calls[0]![0]).toBe(resolvedTarget);
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("win32: replaces a directory symlink via backup-swap, minting a junction temp link", async () => {
|
|
265
|
-
// Failure signature 1 from the incident: EPERM on rename over
|
|
266
|
-
// '...\\indigo%3Acall-prep-brief\\scripts' — the destination was a
|
|
267
|
-
// directory symlink, which Windows rename() can never replace.
|
|
268
|
-
// replaceStagedPath (upstream #193) swaps a symlink destination out to
|
|
269
|
-
// a sibling backup, installs the staged link, then removes the backup.
|
|
270
|
-
const wireTarget = "../companies/indigo/skills/call-prep-brief";
|
|
271
|
-
const localPath = path.join(tmpRoot, "farm", "indigo%3Acall-prep-brief");
|
|
272
|
-
fs.mkdirSync(path.dirname(localPath), { recursive: true });
|
|
273
|
-
// Real directory at the resolved target so the type probe picks 'dir'.
|
|
274
|
-
fs.mkdirSync(path.resolve(path.dirname(localPath), wireTarget), {
|
|
275
|
-
recursive: true,
|
|
276
|
-
});
|
|
277
|
-
setObjectIOFactory(() => symlinkRecordIO(wireTarget));
|
|
278
|
-
|
|
279
|
-
const realLstatSync = fs.lstatSync.bind(fs) as (p: fs.PathLike) => fs.Stats;
|
|
280
|
-
const realStatSync = fs.statSync.bind(fs) as (p: fs.PathLike) => fs.Stats;
|
|
281
|
-
// Destination is scripted as a live directory symlink to a STALE target.
|
|
282
|
-
vi.spyOn(fs, "lstatSync").mockImplementation(((p: fs.PathLike) =>
|
|
283
|
-
p === localPath
|
|
284
|
-
? fakeStats({ symlink: true })
|
|
285
|
-
: realLstatSync(p)) as typeof fs.lstatSync);
|
|
286
|
-
vi.spyOn(fs, "readlinkSync").mockImplementation(
|
|
287
|
-
(() => "..\\stale\\old-skill") as unknown as typeof fs.readlinkSync,
|
|
288
|
-
);
|
|
289
|
-
vi.spyOn(fs, "statSync").mockImplementation(((p: fs.PathLike) =>
|
|
290
|
-
p === localPath
|
|
291
|
-
? fakeStats({ dir: true })
|
|
292
|
-
: realStatSync(p)) as typeof fs.statSync);
|
|
293
|
-
const symlinkSpy = vi
|
|
294
|
-
.spyOn(fs, "symlinkSync")
|
|
295
|
-
.mockImplementation(() => undefined);
|
|
296
|
-
const unlinkSpy = vi
|
|
297
|
-
.spyOn(fs, "unlinkSync")
|
|
298
|
-
.mockImplementation(() => undefined);
|
|
299
|
-
const renameSpy = vi
|
|
300
|
-
.spyOn(fs, "renameSync")
|
|
301
|
-
.mockImplementation(() => undefined);
|
|
302
|
-
|
|
303
|
-
await downloadFile(makeCtx(), ".claude/skills/indigo:call-prep-brief", localPath, {
|
|
304
|
-
win32: true,
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
// Typed temp link: directory target ⇒ junction with an ABSOLUTE
|
|
308
|
-
// substitute path (#219 — a bare symlinkSync mints a broken file-type
|
|
309
|
-
// link, and a 'dir' NTFS symlink EPERMs without Developer Mode).
|
|
310
|
-
expect(symlinkSpy).toHaveBeenCalledTimes(1);
|
|
311
|
-
expect(symlinkSpy.mock.calls[0]![0]).toBe(
|
|
312
|
-
path.resolve(path.dirname(localPath), wireTarget),
|
|
313
|
-
);
|
|
314
|
-
expect(String(symlinkSpy.mock.calls[0]![1])).toContain(".hq-tmp-");
|
|
315
|
-
expect(symlinkSpy.mock.calls[0]![2]).toBe("junction");
|
|
316
|
-
// Backup-swap: old link → .hq-backup-*, staged link → destination,
|
|
317
|
-
// backup removed. The destination itself is never rm'd in place.
|
|
318
|
-
expect(renameSpy).toHaveBeenCalledTimes(2);
|
|
319
|
-
expect(renameSpy.mock.calls[0]![0]).toBe(localPath);
|
|
320
|
-
expect(String(renameSpy.mock.calls[0]![1])).toContain(".hq-backup-");
|
|
321
|
-
expect(String(renameSpy.mock.calls[1]![0])).toContain(".hq-tmp-");
|
|
322
|
-
expect(renameSpy.mock.calls[1]![1]).toBe(localPath);
|
|
323
|
-
expect(unlinkSpy).not.toHaveBeenCalledWith(localPath);
|
|
324
|
-
expect(
|
|
325
|
-
unlinkSpy.mock.calls.some((c) => String(c[0]).includes(".hq-backup-")),
|
|
326
|
-
).toBe(true);
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
it("win32: replaces a file symlink via backup-swap, minting a 'file'-type temp link", async () => {
|
|
330
|
-
const wireTarget = "../personal/skills/dm/SKILL.md";
|
|
331
|
-
const localPath = path.join(tmpRoot, "farm", "personal%3Adm");
|
|
332
|
-
fs.mkdirSync(path.dirname(localPath), { recursive: true });
|
|
333
|
-
// A GENUINE regular file at the resolved target — the only shape that
|
|
334
|
-
// still earns a real 'file' symlink post-#219. An unresolvable target is
|
|
335
|
-
// deliberately materialized as a junction instead (vault overlays are
|
|
336
|
-
// directories, and a junction needs no Windows symlink privilege).
|
|
337
|
-
const resolvedTarget = path.resolve(path.dirname(localPath), wireTarget);
|
|
338
|
-
fs.mkdirSync(path.dirname(resolvedTarget), { recursive: true });
|
|
339
|
-
fs.writeFileSync(resolvedTarget, "# dm skill");
|
|
340
|
-
setObjectIOFactory(() => symlinkRecordIO(wireTarget));
|
|
341
|
-
|
|
342
|
-
const realLstatSync = fs.lstatSync.bind(fs) as (p: fs.PathLike) => fs.Stats;
|
|
343
|
-
vi.spyOn(fs, "lstatSync").mockImplementation(((p: fs.PathLike) =>
|
|
344
|
-
p === localPath
|
|
345
|
-
? fakeStats({ symlink: true })
|
|
346
|
-
: realLstatSync(p)) as typeof fs.lstatSync);
|
|
347
|
-
vi.spyOn(fs, "readlinkSync").mockImplementation(
|
|
348
|
-
(() => "..\\stale\\dm.md") as unknown as typeof fs.readlinkSync,
|
|
349
|
-
);
|
|
350
|
-
const symlinkSpy = vi
|
|
351
|
-
.spyOn(fs, "symlinkSync")
|
|
352
|
-
.mockImplementation(() => undefined);
|
|
353
|
-
const rmdirSpy = vi.spyOn(fs, "rmdirSync");
|
|
354
|
-
const unlinkSpy = vi
|
|
355
|
-
.spyOn(fs, "unlinkSync")
|
|
356
|
-
.mockImplementation(() => undefined);
|
|
357
|
-
const renameSpy = vi
|
|
358
|
-
.spyOn(fs, "renameSync")
|
|
359
|
-
.mockImplementation(() => undefined);
|
|
360
|
-
|
|
361
|
-
await downloadFile(makeCtx(), ".claude/skills/personal:dm", localPath, {
|
|
362
|
-
win32: true,
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
expect(symlinkSpy.mock.calls[0]![2]).toBe("file");
|
|
366
|
-
// Backup-swap: two renames (old→backup, staged→destination) and the
|
|
367
|
-
// backup removed; the destination is never unlinked in place.
|
|
368
|
-
expect(renameSpy).toHaveBeenCalledTimes(2);
|
|
369
|
-
expect(unlinkSpy).not.toHaveBeenCalledWith(localPath);
|
|
370
|
-
expect(
|
|
371
|
-
unlinkSpy.mock.calls.some((c) => String(c[0]).includes(".hq-backup-")),
|
|
372
|
-
).toBe(true);
|
|
373
|
-
expect(rmdirSpy).not.toHaveBeenCalledWith(localPath);
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
it("win32: NEVER deletes a real (non-symlink) directory — the rename failure surfaces", async () => {
|
|
377
|
-
// The engine-level guarantee behind the caller's "manual reconciliation
|
|
378
|
-
// required" warning: a real directory at the destination is the user's
|
|
379
|
-
// data. The replace path may only remove SYMLINK destinations; a real
|
|
380
|
-
// dir is left in place and the (scripted, Windows-faithful) EPERM from
|
|
381
|
-
// rename-over-dir propagates.
|
|
382
|
-
const wireTarget = "../companies/indigo/skills/capture";
|
|
383
|
-
const localPath = path.join(tmpRoot, "farm", "indigo%3Acapture");
|
|
384
|
-
fs.mkdirSync(localPath, { recursive: true }); // REAL directory
|
|
385
|
-
fs.mkdirSync(path.resolve(path.dirname(localPath), wireTarget), {
|
|
386
|
-
recursive: true,
|
|
387
|
-
});
|
|
388
|
-
setObjectIOFactory(() => symlinkRecordIO(wireTarget));
|
|
389
|
-
|
|
390
|
-
vi.spyOn(fs, "symlinkSync").mockImplementation(() => undefined);
|
|
391
|
-
const rmdirSpy = vi.spyOn(fs, "rmdirSync");
|
|
392
|
-
const unlinkSpy = vi.spyOn(fs, "unlinkSync");
|
|
393
|
-
const renameSpy = vi.spyOn(fs, "renameSync").mockImplementation(() => {
|
|
394
|
-
throw errnoError("EPERM");
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
await expect(
|
|
398
|
-
downloadFile(makeCtx(), ".claude/skills/indigo:capture", localPath, {
|
|
399
|
-
win32: true,
|
|
400
|
-
}),
|
|
401
|
-
).rejects.toThrow(/EPERM/);
|
|
402
|
-
|
|
403
|
-
// Surfaced on the first failure — never silently swallowed, and a
|
|
404
|
-
// non-symlink destination gets no backup-swap (nothing to roll back).
|
|
405
|
-
expect(renameSpy).toHaveBeenCalledTimes(1);
|
|
406
|
-
// The real directory was never removed (temp cleanup may touch the
|
|
407
|
-
// .hq-tmp- path, but the destination itself is untouchable).
|
|
408
|
-
expect(rmdirSpy).not.toHaveBeenCalledWith(localPath);
|
|
409
|
-
expect(unlinkSpy).not.toHaveBeenCalledWith(localPath);
|
|
410
|
-
expect(fs.statSync(localPath).isDirectory()).toBe(true);
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
it("POSIX: symlink destination is replaced cleanly — fresh target installed, no temp/backup litter", async () => {
|
|
414
|
-
// replaceStagedPath backup-swaps symlink destinations on every
|
|
415
|
-
// platform; the observable contract is a clean replacement with no
|
|
416
|
-
// .hq-tmp-/.hq-backup- litter and a bare (no type hint) staged link.
|
|
417
|
-
const localPath = path.join(tmpRoot, "posix-link.md");
|
|
418
|
-
fs.symlinkSync("stale-target.md", localPath);
|
|
419
|
-
setObjectIOFactory(() => symlinkRecordIO("fresh-target.md"));
|
|
420
|
-
|
|
421
|
-
const symlinkSpy = vi.spyOn(fs, "symlinkSync");
|
|
422
|
-
|
|
423
|
-
await downloadFile(makeCtx(), "posix-link.md", localPath, {
|
|
424
|
-
win32: false,
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
expect(symlinkSpy).toHaveBeenCalledTimes(1);
|
|
428
|
-
expect(symlinkSpy.mock.calls[0]![2]).toBeUndefined();
|
|
429
|
-
expect(fs.readlinkSync(localPath)).toBe("fresh-target.md");
|
|
430
|
-
const litter = fs
|
|
431
|
-
.readdirSync(tmpRoot)
|
|
432
|
-
.filter((n) => n.startsWith(".hq-tmp-") || n.startsWith(".hq-backup-"));
|
|
433
|
-
expect(litter).toEqual([]);
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
it("2026-07-16 ENOENT mode (US-002): parents are created at the ENCODED local path, never the raw-colon path", async () => {
|
|
437
|
-
// Failure signature 2 from the incident:
|
|
438
|
-
// ENOENT mkdir 'C:\...\skills\indigo:team-agent-telemetry-report'
|
|
439
|
-
// — the pre-codec caller handed downloadFile a RAW-key local path, and
|
|
440
|
-
// Windows cannot mkdir a colon segment. The pull pipeline now derives
|
|
441
|
-
// localPath through the codec (sync.ts resolveContainedVaultPath →
|
|
442
|
-
// localPathForVaultKey); this pins the contract end-to-end: pulling the
|
|
443
|
-
// incident's exact key with a codec-derived localPath materializes the
|
|
444
|
-
// parent chain at `indigo%3Ateam-agent-telemetry-report`, and no
|
|
445
|
-
// raw-colon sibling ever appears.
|
|
446
|
-
const key = ".claude/skills/indigo:team-agent-telemetry-report/agents";
|
|
447
|
-
const wireTarget =
|
|
448
|
-
"../../../companies/indigo/skills/team-agent-telemetry-report/agents";
|
|
449
|
-
const localPath = localPathForVaultKey(tmpRoot, key, true);
|
|
450
|
-
setObjectIOFactory(() => symlinkRecordIO(wireTarget));
|
|
451
|
-
// Leaf materialization is exercised by the suites above; this test is
|
|
452
|
-
// about the parent chain, so the link+rename pair is inert.
|
|
453
|
-
vi.spyOn(fs, "symlinkSync").mockImplementation(() => undefined);
|
|
454
|
-
vi.spyOn(fs, "renameSync").mockImplementation(() => undefined);
|
|
455
|
-
|
|
456
|
-
await downloadFile(makeCtx(), key, localPath, { win32: true });
|
|
457
|
-
|
|
458
|
-
const encodedParent = path.join(
|
|
459
|
-
tmpRoot,
|
|
460
|
-
".claude",
|
|
461
|
-
"skills",
|
|
462
|
-
"indigo%3Ateam-agent-telemetry-report",
|
|
463
|
-
);
|
|
464
|
-
expect(fs.existsSync(encodedParent)).toBe(true);
|
|
465
|
-
expect(fs.statSync(encodedParent).isDirectory()).toBe(true);
|
|
466
|
-
// The raw-colon spelling must not exist anywhere in the farm.
|
|
467
|
-
expect(
|
|
468
|
-
fs.readdirSync(path.join(tmpRoot, ".claude", "skills")),
|
|
469
|
-
).toEqual(["indigo%3Ateam-agent-telemetry-report"]);
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
it("POSIX: fast path also fires with exact string equality", async () => {
|
|
473
|
-
// Separator normalization is win32-only; POSIX equality is exact (a
|
|
474
|
-
// backslash is an ordinary filename character there). A separator-free
|
|
475
|
-
// target makes this deterministic on any host platform.
|
|
476
|
-
const target = "plain-target.md";
|
|
477
|
-
const localPath = path.join(tmpRoot, "posix-noop.md");
|
|
478
|
-
fs.symlinkSync(target, localPath);
|
|
479
|
-
setObjectIOFactory(() => symlinkRecordIO(target));
|
|
480
|
-
|
|
481
|
-
const symlinkSpy = vi.spyOn(fs, "symlinkSync");
|
|
482
|
-
const renameSpy = vi.spyOn(fs, "renameSync");
|
|
483
|
-
|
|
484
|
-
const res = await downloadFile(makeCtx(), "posix-noop.md", localPath, {
|
|
485
|
-
win32: false,
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
expect(res.metadata).toBeDefined();
|
|
489
|
-
expect(symlinkSpy).not.toHaveBeenCalled();
|
|
490
|
-
expect(renameSpy).not.toHaveBeenCalled();
|
|
491
|
-
});
|
|
492
|
-
});
|