@openclaw/matrix 2026.11.6 → 2026.11.7

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.
Files changed (148) hide show
  1. package/dist/.setup/{approval-handler.runtime-CshxBDs7.mjs → approval-handler.runtime-LBvkygUK.mjs} +3 -3
  2. package/dist/.setup/{channel-OLndtGNE.mjs → channel-CHryi9FS.mjs} +7 -7
  3. package/dist/.setup/{channel.runtime-CFSou_MS.mjs → channel.runtime-DluXWaGb.mjs} +2 -2
  4. package/dist/.setup/{channel.setup-CqcEb6JR.mjs → channel.setup-BDbs0FLq.mjs} +2 -2
  5. package/dist/.setup/{cli-CkMedN4Y.mjs → cli-C7Jmy2x4.mjs} +6 -6
  6. package/dist/.setup/{cli-metadata-DN1E7yCf.mjs → cli-metadata-B0GHIn05.mjs} +1 -1
  7. package/dist/.setup/{client-Rlwtz1hG.mjs → client-mFRVrUt3.mjs} +1 -1
  8. package/dist/.setup/{draft-stream-DbTsJkoL.mjs → draft-stream-bVedfEB3.mjs} +1 -1
  9. package/dist/.setup/{exec-approvals-CiGrN-cV.mjs → exec-approvals-BeYF9-3o.mjs} +2 -2
  10. package/dist/.setup/{messages-DJDczJnC.mjs → messages-BqVczVlt.mjs} +2 -2
  11. package/dist/.setup/{monitor-ZDbuZRVB.mjs → monitor-BsSo3tCv.mjs} +29 -15
  12. package/dist/.setup/{onboarding-DwhMV1fp.mjs → onboarding-CoMpgTiK.mjs} +1 -1
  13. package/dist/.setup/{outbound-7iSmOloX.mjs → outbound-ntm0KOfK.mjs} +2 -2
  14. package/dist/.setup/{profile-update-Fu4u-aSC.mjs → profile-update-gC436enW.mjs} +8 -3
  15. package/dist/.setup/{reaction-events-CBltCP52.mjs → reaction-events-DTThoaJQ.mjs} +3 -3
  16. package/dist/.setup/{room-info-DFDDmkBC.mjs → room-info-CM3MKoh4.mjs} +3 -3
  17. package/dist/.setup/{send-DiS4anyi.mjs → send-DFB7JGg2.mjs} +6 -6
  18. package/dist/.setup/{setup-bootstrap-OfuocnF0.mjs → setup-bootstrap-razh2kSp.mjs} +2 -2
  19. package/dist/.setup/{setup-core-CEQJRnym.mjs → setup-core-BVbxltMM.mjs} +1 -1
  20. package/dist/.setup/setup-plugin-api-CQKySg7F.mjs +2 -0
  21. package/dist/.setup/{thread-bindings-BvoisBZE.mjs → thread-bindings-D5VJEDZV.mjs} +1 -1
  22. package/dist/.setup/{tool-actions-TYBYDIkj.mjs → tool-actions-DexlmVDf.mjs} +9 -9
  23. package/dist/.setup/{verification-BhFA9xF6.mjs → verification-B122bsH2.mjs} +1 -1
  24. package/dist/.source-module-urls/1cd4d4ff8d44e1c8b830932b44d7cf8a7f3350e09e169910e1d7a85e131b7bea.json +1 -1
  25. package/dist/api.js +4 -4
  26. package/dist/channel-plugin-api.js +1 -1
  27. package/dist/cli-metadata.js +1 -1
  28. package/dist/contract-api.js +2 -2
  29. package/dist/index.js +1 -1
  30. package/dist/plugin-entry.handlers.runtime.js +1 -1
  31. package/dist/session-binding-contract-api.js +1 -1
  32. package/dist/setup-entry.js +1 -1
  33. package/dist/setup-plugin-api.js +1 -1
  34. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +45 -1
  35. package/node_modules/@openclaw/fs-safe/README.md +4 -0
  36. package/node_modules/@openclaw/fs-safe/dist/absolute-path.js +2 -2
  37. package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +2 -2
  38. package/node_modules/@openclaw/fs-safe/dist/advanced.js +2 -2
  39. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  40. package/node_modules/@openclaw/fs-safe/dist/atomic-io.d.ts +1 -0
  41. package/node_modules/@openclaw/fs-safe/dist/atomic-io.js +6 -0
  42. package/node_modules/@openclaw/fs-safe/dist/atomic.d.ts +1 -0
  43. package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts +5 -0
  44. package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.js +13 -0
  45. package/node_modules/@openclaw/fs-safe/dist/directory-mode-options.d.ts +3 -0
  46. package/node_modules/@openclaw/fs-safe/dist/directory-mode-options.js +6 -0
  47. package/node_modules/@openclaw/fs-safe/dist/errors.d.ts +1 -1
  48. package/node_modules/@openclaw/fs-safe/dist/errors.js +1 -0
  49. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-admission.d.ts +0 -1
  50. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-admission.js +1 -11
  51. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.js +3 -3
  52. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-stale-admission.js +2 -3
  53. package/node_modules/@openclaw/fs-safe/dist/file-store-boundary.d.ts +3 -3
  54. package/node_modules/@openclaw/fs-safe/dist/file-store-boundary.js +30 -4
  55. package/node_modules/@openclaw/fs-safe/dist/file-store-prune.d.ts +1 -1
  56. package/node_modules/@openclaw/fs-safe/dist/file-store-prune.js +7 -1
  57. package/node_modules/@openclaw/fs-safe/dist/file-store-sync-directory.d.ts +1 -1
  58. package/node_modules/@openclaw/fs-safe/dist/file-store-sync-directory.js +30 -4
  59. package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.d.ts +1 -1
  60. package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.js +2 -0
  61. package/node_modules/@openclaw/fs-safe/dist/file-store.d.ts +2 -1
  62. package/node_modules/@openclaw/fs-safe/dist/file-store.js +5 -0
  63. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts +2 -0
  64. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.js +9 -0
  65. package/node_modules/@openclaw/fs-safe/dist/json-store.d.ts +2 -1
  66. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +4 -1
  67. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +1 -1
  68. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +1 -1
  69. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +19 -13
  70. package/node_modules/@openclaw/fs-safe/dist/overwrite-file-handle.d.ts +2 -0
  71. package/node_modules/@openclaw/fs-safe/dist/overwrite-file-handle.js +27 -5
  72. package/node_modules/@openclaw/fs-safe/dist/path-prefix.d.ts +1 -0
  73. package/node_modules/@openclaw/fs-safe/dist/path-prefix.js +84 -7
  74. package/node_modules/@openclaw/fs-safe/dist/pinned-write-input.js +0 -11
  75. package/node_modules/@openclaw/fs-safe/dist/prepare-directory-mode.d.ts +9 -0
  76. package/node_modules/@openclaw/fs-safe/dist/prepare-directory-mode.js +61 -0
  77. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +2 -1
  78. package/node_modules/@openclaw/fs-safe/dist/realpath.d.ts +2 -0
  79. package/node_modules/@openclaw/fs-safe/dist/realpath.js +16 -0
  80. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.d.ts +2 -1
  81. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +8 -6
  82. package/node_modules/@openclaw/fs-safe/dist/replace-file-types.d.ts +2 -1
  83. package/node_modules/@openclaw/fs-safe/dist/replace-file.js +20 -13
  84. package/node_modules/@openclaw/fs-safe/dist/root-context.js +4 -1
  85. package/node_modules/@openclaw/fs-safe/dist/root-create-native.d.ts +1 -1
  86. package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +18 -9
  87. package/node_modules/@openclaw/fs-safe/dist/root-errors.d.ts +2 -0
  88. package/node_modules/@openclaw/fs-safe/dist/root-errors.js +9 -0
  89. package/node_modules/@openclaw/fs-safe/dist/root-impl.js +4 -1
  90. package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.d.ts +1 -1
  91. package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js +35 -16
  92. package/node_modules/@openclaw/fs-safe/dist/root-path-existing.d.ts +6 -2
  93. package/node_modules/@openclaw/fs-safe/dist/root-path-existing.js +32 -20
  94. package/node_modules/@openclaw/fs-safe/dist/root-path.js +32 -26
  95. package/node_modules/@openclaw/fs-safe/dist/root-write-admission.js +4 -1
  96. package/node_modules/@openclaw/fs-safe/dist/secret-file.d.ts +2 -1
  97. package/node_modules/@openclaw/fs-safe/dist/secret-file.js +2 -0
  98. package/node_modules/@openclaw/fs-safe/dist/sibling-temp.d.ts +2 -1
  99. package/node_modules/@openclaw/fs-safe/dist/sibling-temp.js +5 -4
  100. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-policy.d.ts +3 -2
  101. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-policy.js +8 -9
  102. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-stale-admission.js +3 -1
  103. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-types.d.ts +2 -1
  104. package/node_modules/@openclaw/fs-safe/dist/text-atomic.d.ts +2 -1
  105. package/node_modules/@openclaw/fs-safe/dist/types.d.ts +1 -0
  106. package/node_modules/@openclaw/fs-safe/dist/watch-hints.js +12 -3
  107. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
  108. package/node_modules/@openclaw/fs-safe/dist/write-file-handle.d.ts +0 -1
  109. package/node_modules/@openclaw/fs-safe/dist/write-file-handle.js +10 -12
  110. package/node_modules/@openclaw/fs-safe/docs/advanced.md +3 -3
  111. package/node_modules/@openclaw/fs-safe/docs/atomic.md +16 -3
  112. package/node_modules/@openclaw/fs-safe/docs/compiler-qualification.md +1 -1
  113. package/node_modules/@openclaw/fs-safe/docs/contributing.md +27 -18
  114. package/node_modules/@openclaw/fs-safe/docs/errors.md +3 -1
  115. package/node_modules/@openclaw/fs-safe/docs/file-store.md +14 -2
  116. package/node_modules/@openclaw/fs-safe/docs/in-place-write.md +31 -0
  117. package/node_modules/@openclaw/fs-safe/docs/install.md +1 -1
  118. package/node_modules/@openclaw/fs-safe/docs/json-store.md +6 -1
  119. package/node_modules/@openclaw/fs-safe/docs/json.md +5 -1
  120. package/node_modules/@openclaw/fs-safe/docs/path-prefix.md +14 -4
  121. package/node_modules/@openclaw/fs-safe/docs/public-api.md +4 -2
  122. package/node_modules/@openclaw/fs-safe/docs/secret-file.md +5 -1
  123. package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +4 -0
  124. package/node_modules/@openclaw/fs-safe/docs/temp.md +9 -1
  125. package/node_modules/@openclaw/fs-safe/docs/types.md +5 -1
  126. package/node_modules/@openclaw/fs-safe/package.json +12 -12
  127. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  128. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  129. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  130. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  131. package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
  132. package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +1 -1
  133. package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
  134. package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +1 -1
  135. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  136. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  137. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  138. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  139. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  140. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  141. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  142. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  143. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
  144. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +1 -1
  145. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  146. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  147. package/package.json +5 -5
  148. package/dist/.setup/setup-plugin-api-4hHy1k4x.mjs +0 -2
@@ -1,12 +1,18 @@
1
1
  import fs from "node:fs";
2
+ import asyncFs from "node:fs/promises";
2
3
  import path from "node:path";
4
+ import { runAsync, runSync, wait } from "./atomic-io.js";
3
5
  import { FsSafeError } from "./errors.js";
4
6
  import { formatErrorDetail } from "./error-detail.js";
5
7
  import { isNotFoundPathError, isPathInside, isSymlinkOpenError } from "./path.js";
6
- import { realpathSync } from "./realpath.js";
8
+ import { realpathNative, realpathSync } from "./realpath.js";
7
9
  import { assertNoWindowsPathAlias, isForeignWindowsShareOrDevicePath, pathForWindowsFilesystem, resolvePathFromBasePreservingWindowsRoot, resolvePathPreservingWindowsRoot, } from "./windows-path-alias.js";
8
10
  import { admitPathInsideRoot } from "./root-boundary.js";
9
11
  import { errorCauseOptions } from "./root-errors.js";
12
+ // Windows native realpath denies delete sharing. Preserve read/publication
13
+ // scheduling until canonicalization can safely overlap replacement.
14
+ export const synchronousRootTraversal = process.platform === "win32";
15
+ export const runRootTraversal = synchronousRootTraversal ? runSync : runAsync;
10
16
  export function absolutePathWithRawSegments(candidate) {
11
17
  if (path.sep !== "\\") {
12
18
  if (path.isAbsolute(candidate))
@@ -24,7 +30,7 @@ export function absolutePathWithRawSegments(candidate) {
24
30
  const base = drive ? path.resolve(drive) : process.cwd();
25
31
  return `${base}${base.endsWith(path.sep) ? "" : path.sep}${raw.slice(drive.length)}`;
26
32
  }
27
- export function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options = {}) {
33
+ export function* rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options = {}, synchronous = true) {
28
34
  assertNoWindowsPathAlias(candidate);
29
35
  assertNoWindowsPathAlias(rootCanonicalPath);
30
36
  const absolute = absolutePathWithRawSegments(candidate);
@@ -43,7 +49,7 @@ export function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, opt
43
49
  let isSymlink = false;
44
50
  try {
45
51
  const operationPath = pathForWindowsFilesystem(prefix);
46
- const stat = fs.lstatSync(operationPath);
52
+ const stat = synchronous ? fs.lstatSync(operationPath) : yield* wait(asyncFs.lstat(operationPath));
47
53
  isSymlink = stat.isSymbolicLink();
48
54
  // Check the original leaf before canonicalization can erase an entry alias.
49
55
  if (isSymlink && options.rejectFinalSymlink && index === finalComponentIndex) {
@@ -52,10 +58,11 @@ export function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, opt
52
58
  if (!isSymlink && !stat.isDirectory() && index < segments.length - 1)
53
59
  return undefined;
54
60
  traversedSymlink ||= isSymlink;
55
- canonical = realpathSync.native(operationPath);
61
+ canonical = synchronous ? realpathSync.native(operationPath) : yield* wait(realpathNative(operationPath));
56
62
  assertNoWindowsPathAlias(canonical);
57
63
  if (isSymlink && index < segments.length - 1 &&
58
- !fs.statSync(pathForWindowsFilesystem(canonical)).isDirectory())
64
+ !(synchronous ? fs.statSync(pathForWindowsFilesystem(canonical))
65
+ : yield* wait(asyncFs.stat(pathForWindowsFilesystem(canonical)))).isDirectory())
59
66
  return undefined;
60
67
  if (isSymlink && !isPathInside(rootCanonicalPath, canonical) && !isPathInside(canonical, rootCanonicalPath)) {
61
68
  throw new FsSafeError("outside-workspace", `symlink prefix resolves outside the root ancestry: ${formatErrorDetail(candidate)}`);
@@ -84,9 +91,10 @@ export function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, opt
84
91
  }
85
92
  return undefined;
86
93
  }
87
- function pathExists(targetPath) {
94
+ function* pathExists(targetPath, synchronous) {
88
95
  try {
89
- return fs.lstatSync(pathForWindowsFilesystem(targetPath), { throwIfNoEntry: false }) !== undefined;
96
+ return (synchronous ? fs.lstatSync(pathForWindowsFilesystem(targetPath), { throwIfNoEntry: false })
97
+ : yield* wait(asyncFs.lstat(pathForWindowsFilesystem(targetPath)))) !== undefined;
90
98
  }
91
99
  catch (error) {
92
100
  if (isNotFoundPathError(error)) {
@@ -96,17 +104,20 @@ function pathExists(targetPath) {
96
104
  }
97
105
  }
98
106
  export async function resolvePathViaExistingAncestor(targetPath) {
99
- return resolveExistingAncestor(targetPath, "native");
107
+ return runRootTraversal(resolveExistingAncestorProcedure(targetPath, "native", synchronousRootTraversal));
100
108
  }
101
- function pathExistsSync(targetPath) {
109
+ function* ordinaryExists(targetPath) {
102
110
  return fs.existsSync(pathForWindowsFilesystem(targetPath));
103
111
  }
104
112
  export function resolvePathViaExistingAncestorSync(targetPath) {
105
113
  return resolveExistingAncestor(targetPath, "ordinary");
106
114
  }
107
115
  export function resolveExistingAncestor(targetPath, mode, preserveRawSegments = false, remainingHops = 64) {
108
- const exists = mode === "native" || preserveRawSegments ? pathExists : pathExistsSync;
109
- const canonicalize = realpathSync.native;
116
+ return runSync(resolveExistingAncestorProcedure(targetPath, mode, true, preserveRawSegments, remainingHops));
117
+ }
118
+ export function* resolveExistingAncestorProcedure(targetPath, mode, synchronous, preserveRawSegments = false, remainingHops = 64) {
119
+ const exists = (pathname) => mode === "native" || preserveRawSegments
120
+ ? pathExists(pathname, synchronous) : ordinaryExists(pathname);
110
121
  assertNoWindowsPathAlias(targetPath);
111
122
  const normalized = resolvePathPreservingWindowsRoot(targetPath);
112
123
  assertNoWindowsPathAlias(normalized);
@@ -114,22 +125,23 @@ export function resolveExistingAncestor(targetPath, mode, preserveRawSegments =
114
125
  let cursor = candidate;
115
126
  const filesystemRoot = path.parse(candidate).root;
116
127
  while (cursor !== filesystemRoot &&
117
- !exists(cursor)) {
128
+ !(yield* exists(cursor))) {
118
129
  cursor = path.dirname(cursor);
119
130
  }
120
- if (!exists(cursor)) {
131
+ if (!(yield* exists(cursor))) {
121
132
  return normalized;
122
133
  }
123
134
  let rawResolvedAncestor;
124
135
  try {
125
- rawResolvedAncestor = canonicalize(pathForWindowsFilesystem(cursor));
136
+ rawResolvedAncestor = synchronous ? realpathSync.native(pathForWindowsFilesystem(cursor))
137
+ : yield* wait(realpathNative(pathForWindowsFilesystem(cursor)));
126
138
  }
127
139
  catch (error) {
128
140
  if (!preserveRawSegments)
129
141
  return normalized;
130
142
  if (!isNotFoundPathError(error))
131
143
  throw error;
132
- rawResolvedAncestor = resolveSymlinkHopPath(cursor, mode, false, remainingHops);
144
+ rawResolvedAncestor = yield* resolveSymlinkHopPath(cursor, mode, false, remainingHops, synchronous);
133
145
  }
134
146
  assertNoWindowsPathAlias(rawResolvedAncestor);
135
147
  const resolvedAncestor = resolvePathPreservingWindowsRoot(rawResolvedAncestor);
@@ -145,10 +157,10 @@ export function resolveExistingAncestor(targetPath, mode, preserveRawSegments =
145
157
  assertNoWindowsPathAlias(resolved);
146
158
  return resolved;
147
159
  }
148
- export function resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remainingHops = 64) {
160
+ export function* resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remainingHops = 64, synchronous = true) {
149
161
  try {
150
- const canonicalize = realpathSync.native;
151
- const rawRealPath = canonicalize(symlinkPath);
162
+ const rawRealPath = synchronous ? realpathSync.native(symlinkPath)
163
+ : yield* wait(realpathNative(symlinkPath));
152
164
  assertNoWindowsPathAlias(rawRealPath, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
153
165
  const realPath = resolvePathPreservingWindowsRoot(rawRealPath);
154
166
  assertNoWindowsPathAlias(realPath, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
@@ -162,14 +174,14 @@ export function resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remai
162
174
  throw error;
163
175
  if (remainingHops <= 0)
164
176
  throw new FsSafeError("symlink", "too many unresolved symlink hops");
165
- const linkTarget = fs.readlinkSync(symlinkPath);
177
+ const linkTarget = synchronous ? fs.readlinkSync(symlinkPath) : yield* wait(asyncFs.readlink(symlinkPath));
166
178
  assertNoWindowsPathAlias(linkTarget, "filesystem", "symlink target uses a Windows filesystem namespace alias");
167
179
  const linkDir = resolvePathPreservingWindowsRoot(path.dirname(symlinkPath));
168
180
  // Keep parent segments until the kernel has resolved the existing prefix.
169
181
  const targetPath = path.isAbsolute(linkTarget) ? linkTarget
170
182
  : path.parse(linkTarget).root ? resolvePathFromBasePreservingWindowsRoot(linkDir, linkTarget)
171
183
  : `${linkDir}${path.sep}${linkTarget}`;
172
- const resolved = resolveExistingAncestor(targetPath, mode, true, remainingHops - 1);
184
+ const resolved = yield* resolveExistingAncestorProcedure(targetPath, mode, synchronous, true, remainingHops - 1);
173
185
  assertNoWindowsPathAlias(resolved, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
174
186
  return resolved;
175
187
  }
@@ -1,11 +1,13 @@
1
1
  import fs, {} from "node:fs";
2
+ import asyncFs from "node:fs/promises";
2
3
  import path from "node:path";
4
+ import { runSync, wait } from "./atomic-io.js";
3
5
  import { shortPath } from "./error-detail.js";
4
6
  import { pathEscapeError, sanitizeRootPathError, symlinkEscapeError } from "./root-path-errors.js";
5
7
  import { FsSafeError } from "./errors.js";
6
8
  import { isNativeDirectoryObservationGuard } from "./native-directory-observation.js";
7
9
  import { assertNoNulPathInput, isNotFoundPathError, isPathRelativeEscape, } from "./path.js";
8
- import { absolutePathWithRawSegments, rawPathRelativeToCanonicalRoot, resolveExistingAncestor, resolveSymlinkHopPath, } from "./root-path-existing.js";
10
+ import { absolutePathWithRawSegments, rawPathRelativeToCanonicalRoot, resolveExistingAncestorProcedure, resolveSymlinkHopPath, runRootTraversal, synchronousRootTraversal, } from "./root-path-existing.js";
9
11
  import { admitPathInsideRoot, } from "./root-boundary.js";
10
12
  import { RootPathObservationError, captureRootPathObservedDirectory, createRootPathTraversalObservation, inspectRootPathTraversalEntry, } from "./root-path-observation.js";
11
13
  import { assertNoDriveRelativePathSegments } from "./safe-path-segment.js";
@@ -23,36 +25,38 @@ export const ROOT_PATH_ALIAS_POLICIES = {
23
25
  }),
24
26
  };
25
27
  export async function resolveRootPath(params) {
26
- return resolveRootPathInternal(params);
28
+ return runRootTraversal(resolveRootPathInternal(params));
27
29
  }
28
30
  export async function resolveRootPathWithCanonicalRootObservation(params, observeRoot) {
29
- return resolveRootPathInternal(params, { observeRoot });
31
+ return runRootTraversal(resolveRootPathInternal(params, { observeRoot }));
30
32
  }
31
33
  export async function resolveRootPathWithObservation(params, request) {
32
34
  const observation = { request };
33
- const resolved = resolveRootPathInternal(params, { observation });
35
+ const resolved = synchronousRootTraversal
36
+ ? runSync(resolveRootPathInternal(params, { observation }))
37
+ : await runRootTraversal(resolveRootPathInternal(params, { observation }));
34
38
  return observation.receipt ? { resolved, receipt: observation.receipt } : { resolved };
35
39
  }
36
40
  // Removal receipts are separate from metadata observations and canonical-root
37
- // callbacks; the public resolver's options and result remain unchanged.
41
+ // callbacks; retain their synchronous admission and mutation-fence owner.
38
42
  export async function resolveRootPathForRemoval(params, receipts) {
39
- return resolveRootPathInternal(params, { removalReceipts: receipts });
43
+ return runSync(resolveRootPathInternal(params, { removalReceipts: receipts }, true));
40
44
  }
41
45
  export function resolveRootPathSync(params) {
42
- return resolveRootPathInternal(params, { mode: "ordinary" });
46
+ return runSync(resolveRootPathInternal(params, { mode: "ordinary" }, true));
43
47
  }
44
48
  export function resolveRootPathSyncWithCanonicalRootObservation(params, observeRoot) {
45
- return resolveRootPathInternal(params, { mode: "ordinary", observeRoot });
49
+ return runSync(resolveRootPathInternal(params, { mode: "ordinary", observeRoot }, true));
46
50
  }
47
- function resolveRootPathInternal(params, options = {}) {
51
+ function* resolveRootPathInternal(params, options = {}, synchronous = synchronousRootTraversal) {
48
52
  try {
49
- return traverseRootPath(params, options);
53
+ return yield* traverseRootPath(params, options, synchronous);
50
54
  }
51
55
  catch (error) {
52
56
  throw sanitizeRootPathError(error);
53
57
  }
54
58
  }
55
- function prepareRootTraversal(params, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath) {
59
+ function* prepareRootTraversal(params, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath, synchronous) {
56
60
  let raw = rawAbsolutePath;
57
61
  let trustedAbsolutePath = false;
58
62
  // Even a metadata lookup on a foreign share contacts that host, including the
@@ -68,7 +72,7 @@ function prepareRootTraversal(params, rootPath, rootCanonicalPath, absolutePath,
68
72
  else {
69
73
  const canonical = admitRawPathInsideRoot(rootCanonicalPath, raw, params.rootIdentity);
70
74
  const relative = canonical?.relativePath
71
- ?? rawPathRelativeToCanonicalRoot(raw, rootCanonicalPath, params);
75
+ ?? (yield* rawPathRelativeToCanonicalRoot(raw, rootCanonicalPath, params, synchronous));
72
76
  if (relative === undefined) {
73
77
  throw pathEscapeError({ rootPath, absolutePath: raw, boundaryLabel: params.boundaryLabel });
74
78
  }
@@ -249,27 +253,28 @@ function assertDirectoryBeforeMoreSegments(stat, pathname, isLast) {
249
253
  throw Object.assign(new Error(`Path component is not a directory: ${pathname}`), { code: "ENOTDIR" });
250
254
  }
251
255
  }
252
- function assertResolvedLinkDirectory(pathname, isLast) {
256
+ function* assertResolvedLinkDirectory(pathname, isLast, synchronous) {
253
257
  if (isLast)
254
258
  return;
255
- const stat = fs.statSync(pathForWindowsFilesystem(pathname));
259
+ const stat = synchronous ? fs.statSync(pathForWindowsFilesystem(pathname))
260
+ : yield* wait(asyncFs.stat(pathForWindowsFilesystem(pathname)));
256
261
  assertDirectoryBeforeMoreSegments(stat, pathname, isLast);
257
262
  }
258
- // Both public APIs use kernel canonicalization and synchronous metadata; only
259
- // ancestor existence differs. Promise wrappers preserve asynchronous rejection.
260
- function traverseRootPath(params, { mode = "native", observation: observationOutput, observeRoot, removalReceipts }) {
263
+ // Both drivers share containment policy. Observation receipts and platform-specific
264
+ // native guards retain their existing synchronous owners.
265
+ function* traverseRootPath(params, { mode = "native", observation: observationOutput, observeRoot, removalReceipts }, synchronous) {
261
266
  const input = captureValidRootPathInputs(params);
262
267
  const rawAbsolutePath = absolutePathWithRawSegments(input.absolutePath);
263
268
  const rootPath = resolvePathPreservingWindowsRoot(input.rootPath);
264
269
  const absolutePath = resolvePathPreservingWindowsRoot(rawAbsolutePath);
265
270
  const rootCanonicalPath = input.rootCanonicalPath
266
271
  ? resolvePathPreservingWindowsRoot(input.rootCanonicalPath)
267
- : resolveExistingAncestor(rootPath, mode);
272
+ : yield* resolveExistingAncestorProcedure(rootPath, mode, synchronous);
268
273
  assertNoWindowsPathAlias(rootPath);
269
274
  assertNoWindowsPathAlias(absolutePath);
270
275
  assertNoWindowsPathAlias(rootCanonicalPath);
271
276
  observeRoot?.(rootCanonicalPath);
272
- const context = createLexicalTraversalContext(prepareRootTraversal(input, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath));
277
+ const context = createLexicalTraversalContext(yield* prepareRootTraversal(input, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath, synchronous));
273
278
  const { state } = context;
274
279
  const observation = createLexicalTraversalObservation(context, observationOutput?.request);
275
280
  for (let idx = 0; idx < state.segments.length; idx += 1) {
@@ -306,7 +311,8 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
306
311
  }
307
312
  stat = isNativeDirectoryObservationGuard(observed)
308
313
  ? undefined
309
- : observed?.stat ?? fs.lstatSync(state.lexicalCursor);
314
+ : observed?.stat ?? (synchronous ? fs.lstatSync(state.lexicalCursor)
315
+ : yield* wait(asyncFs.lstat(state.lexicalCursor)));
310
316
  }
311
317
  }
312
318
  catch (error) {
@@ -369,12 +375,12 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
369
375
  }
370
376
  if (observation?.enabled)
371
377
  disableLexicalTraversalObservation(context, observation);
372
- const linkCanonical = resolveSymlinkHopPath(state.lexicalCursor, mode, context.resolveParams.rejectUnresolvedSymlinks);
378
+ const linkCanonical = yield* resolveSymlinkHopPath(state.lexicalCursor, mode, context.resolveParams.rejectUnresolvedSymlinks, 64, synchronous);
373
379
  applyResolvedSymlinkHop(context, linkCanonical);
374
380
  if (context.resolveParams.rejectSymlinks === true) {
375
381
  throw new FsSafeError("symlink", "symlink path component not allowed");
376
382
  }
377
- assertResolvedLinkDirectory(linkCanonical, isLast);
383
+ yield* assertResolvedLinkDirectory(linkCanonical, isLast, synchronous);
378
384
  }
379
385
  const completeObservation = observation?.enabled === true && observation.directoryGuard !== undefined &&
380
386
  observation.targetPath === state.canonicalCursor && observation.target !== undefined;
@@ -382,7 +388,7 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
382
388
  ? isNativeDirectoryObservationGuard(observation.target)
383
389
  ? "directory"
384
390
  : toResolvedKind(observation.target.stat)
385
- : getPathKindSync(state.canonicalCursor, state.preserveFinalSymlink);
391
+ : yield* getPathKind(state.canonicalCursor, state.preserveFinalSymlink, synchronous);
386
392
  if (completeObservation && observationOutput) {
387
393
  observationOutput.receipt = {
388
394
  kind: observation.request.kind,
@@ -395,12 +401,12 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
395
401
  }
396
402
  return finalizeLexicalResolution(context, kind);
397
403
  }
398
- function getPathKindSync(absolutePath, preserveFinalSymlink) {
404
+ function* getPathKind(absolutePath, preserveFinalSymlink, synchronous) {
399
405
  try {
400
406
  const operationPath = pathForWindowsFilesystem(absolutePath);
401
407
  const stat = preserveFinalSymlink
402
- ? fs.lstatSync(operationPath)
403
- : fs.statSync(operationPath);
408
+ ? synchronous ? fs.lstatSync(operationPath) : yield* wait(asyncFs.lstat(operationPath))
409
+ : synchronous ? fs.statSync(operationPath) : yield* wait(asyncFs.stat(operationPath));
404
410
  return toResolvedKind(stat);
405
411
  }
406
412
  catch (error) {
@@ -8,7 +8,7 @@ import { assertNoPathAliasEscape } from "./path-policy.js";
8
8
  import { preparePinnedWriteMutationAdmission, snapshotPinnedMutationPolicy, } from "./pinned-mutation-admission.js";
9
9
  import { admitPathInsideRoot, sameNormalizedPathSpelling } from "./root-boundary.js";
10
10
  import { resolvePathInRoot } from "./root-context.js";
11
- import { errorCauseOptions, hardlinkedPathNotAllowedError, outsideWorkspaceError } from "./root-errors.js";
11
+ import { errorCauseOptions, hardlinkedPathNotAllowedError, outsideWorkspaceError, pathTraversalPermissionError } from "./root-errors.js";
12
12
  import { inheritWriteTargetMode } from "./root-write-mode.js";
13
13
  import { mutationSymlinkResolution, } from "./root-symlink-policy.js";
14
14
  import { inspectFileIdentitySync } from "./strict-file-identity.js";
@@ -179,6 +179,9 @@ export async function resolveGuardedWritePathInRoot(root, params) {
179
179
  });
180
180
  }
181
181
  catch (error) {
182
+ const permissionError = pathTraversalPermissionError(error, resolvedPath.resolved);
183
+ if (permissionError)
184
+ throw permissionError;
182
185
  throw new FsSafeError("path-alias", "path alias escape blocked", errorCauseOptions(error));
183
186
  }
184
187
  }
@@ -1,4 +1,5 @@
1
1
  import { type BigIntStats } from "node:fs";
2
+ import { type DirectoryMode } from "./directory-mode-options.js";
2
3
  import { type AsyncDirectoryGuard } from "./directory-guard.js";
3
4
  import { type SecretFileReadOptions } from "./secret-read-policy.js";
4
5
  export declare const PRIVATE_SECRET_DIR_MODE = 448;
@@ -10,7 +11,7 @@ type SecretFileWriteParams = {
10
11
  filePath: string;
11
12
  content: string | Uint8Array;
12
13
  mode?: number;
13
- dirMode?: number;
14
+ dirMode?: DirectoryMode;
14
15
  durable?: boolean;
15
16
  };
16
17
  type SecretFileCreateParams = Omit<SecretFileWriteParams, "durable"> & {
@@ -1,6 +1,7 @@
1
1
  import fs, {} from "node:fs";
2
2
  import fsp from "node:fs/promises";
3
3
  import path from "node:path";
4
+ import { rejectPrivateDirectoryPreservation } from "./directory-mode-options.js";
4
5
  import { recursiveMkdirPath } from "./recursive-mkdir-path.js";
5
6
  import { canonicalPathFromExistingAncestor } from "./absolute-path.js";
6
7
  import { readFileDescriptorBoundedSync } from "./bounded-read.js";
@@ -238,6 +239,7 @@ export async function prepareSecretFileWrite(params) {
238
239
  assertNoWindowsPathAlias(filePath, "filesystem", "private secret path uses a Windows filesystem namespace alias");
239
240
  const mode = params.mode ?? PRIVATE_SECRET_FILE_MODE;
240
241
  const dirMode = params.dirMode ?? PRIVATE_SECRET_DIR_MODE;
242
+ rejectPrivateDirectoryPreservation(dirMode);
241
243
  const resolvedRoot = resolvePathPreservingWindowsRoot(rootDir);
242
244
  const resolvedFile = path.resolve(filePath);
243
245
  assertNoWindowsPathAlias(resolvedRoot, "filesystem", "private secret root uses a Windows filesystem namespace alias");
@@ -1,3 +1,4 @@
1
+ import type { DirectoryMode } from "./directory-mode-options.js";
1
2
  export type WriteSiblingTempFileOptions<T> = {
2
3
  dir: string;
3
4
  writeTemp: (tempPath: string) => Promise<T>;
@@ -5,7 +6,7 @@ export type WriteSiblingTempFileOptions<T> = {
5
6
  producerIsolation?: "private-directory";
6
7
  resolveFinalPath: (result: T) => string;
7
8
  tempPrefix?: string;
8
- dirMode?: number;
9
+ dirMode?: DirectoryMode;
9
10
  chmodDir?: boolean;
10
11
  /** Final file mode; omitted preserves the producer's mode. Applied through the retained descriptor. */
11
12
  mode?: number;
@@ -3,7 +3,7 @@ import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { assertAsyncDirectoryGuard, createAsyncDirectoryGuard } from "./directory-guard.js";
5
5
  import { fitFileNameToPortableComponent, sanitizeUntrustedFileName } from "./filename.js";
6
- import { applyDirectoryMode } from "./replace-file-descriptor.js";
6
+ import { prepareDirectoryMode } from "./prepare-directory-mode.js";
7
7
  import { AtomicIo, runAsync } from "./atomic-io.js";
8
8
  import { realpathSync } from "./realpath.js";
9
9
  import { recursiveMkdirPath } from "./recursive-mkdir-path.js";
@@ -34,14 +34,15 @@ export async function writeSiblingTempFile(options) {
34
34
  const mode = options.mode;
35
35
  const syncTempFile = options.syncTempFile === true;
36
36
  const syncParentDir = options.syncParentDir === true;
37
- await fs.mkdir(recursiveMkdirPath(dir), { recursive: true, mode: dirMode });
38
- if (chmodDir) {
39
- await runAsync(applyDirectoryMode(AtomicIo.async(fs), {
37
+ if (dirMode === "preserve" || chmodDir) {
38
+ await runAsync(prepareDirectoryMode(AtomicIo.async(fs), {
40
39
  dirPath: dir,
41
40
  mode: dirMode,
42
41
  ignoreChmodError: true,
43
42
  }));
44
43
  }
44
+ else
45
+ await fs.mkdir(recursiveMkdirPath(dir), { recursive: true, mode: dirMode });
45
46
  return await writeCallbackSibling({
46
47
  tempDir: dir,
47
48
  tempName: buildTempName(tempPrefix),
@@ -1,4 +1,5 @@
1
- import type { SidecarLockReclaimParams, SidecarLockRetryOptions } from "./sidecar-lock-types.js";
1
+ import type { SidecarLockSnapshot } from "./sidecar-lock-reclaim.js";
2
+ import type { SidecarLockRetryOptions } from "./sidecar-lock-types.js";
2
3
  export declare function validateSidecarLockRetryOptions(retry: SidecarLockRetryOptions): void;
3
4
  export declare function validateSidecarLockTimeoutMs(timeoutMs: number | undefined): void;
4
5
  export declare function validateSidecarLockStaleMs(staleMs: number | undefined): void;
@@ -11,4 +12,4 @@ export declare function sidecarLockRetryDelay(retry: SidecarLockRetryOptions, ti
11
12
  export declare const maxTransientLockDenials = 8;
12
13
  export declare function isTransientLockFileDenial(error: unknown, lockPath: string): boolean;
13
14
  export declare function sidecarLockPayloadCreatedAtMs(payload: unknown): number | null;
14
- export declare function defaultSidecarLockShouldReclaim(params: Pick<SidecarLockReclaimParams, "lockPath" | "payload" | "staleMs" | "nowMs">): Promise<boolean>;
15
+ export declare function defaultSidecarLockShouldReclaim(snapshot: SidecarLockSnapshot, staleMs: number, nowMs: number): boolean;
@@ -1,4 +1,3 @@
1
- import fsSync from "node:fs";
2
1
  const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
3
2
  function assertFiniteNonNegative(value, label) {
4
3
  if (!Number.isFinite(value) || value < 0) {
@@ -100,14 +99,14 @@ export function sidecarLockPayloadCreatedAtMs(payload) {
100
99
  const createdAtMs = Date.parse(createdAt);
101
100
  return Number.isFinite(createdAtMs) ? createdAtMs : null;
102
101
  }
103
- export async function defaultSidecarLockShouldReclaim(params) {
104
- const createdAtMs = sidecarLockPayloadCreatedAtMs(params.payload);
102
+ export function defaultSidecarLockShouldReclaim(snapshot, staleMs, nowMs) {
103
+ const createdAtMs = sidecarLockPayloadCreatedAtMs(snapshot.payload);
105
104
  if (createdAtMs !== null)
106
- return params.nowMs - createdAtMs > params.staleMs;
107
- try {
108
- return params.nowMs - fsSync.statSync(params.lockPath).mtimeMs > params.staleMs;
109
- }
110
- catch {
105
+ return nowMs - createdAtMs > staleMs;
106
+ if (!snapshot.stat)
111
107
  return true;
112
- }
108
+ // A released pathname may already name another owner; age only the admitted record.
109
+ const mtimeMs = "mtimeNs" in snapshot.stat
110
+ ? Number(snapshot.stat.mtimeNs) / 1e6 : snapshot.stat.mtimeMs;
111
+ return nowMs - mtimeMs > staleMs;
113
112
  }
@@ -97,12 +97,14 @@ export async function handleStaleSidecarAdmission(params) {
97
97
  return;
98
98
  throw error;
99
99
  }
100
- const shouldReclaim = staleOptions.shouldReclaim ?? defaultSidecarLockShouldReclaim;
100
+ const shouldReclaim = staleOptions.shouldReclaim;
101
101
  let reclaim;
102
102
  try {
103
103
  reclaim = await admission.run(async () => {
104
104
  assertUnheld();
105
105
  try {
106
+ if (!shouldReclaim)
107
+ return defaultSidecarLockShouldReclaim(snapshot, params.staleMs, Date.now());
106
108
  return await Reflect.apply(shouldReclaim, undefined, [{
107
109
  lockPath,
108
110
  normalizedTargetPath,
@@ -1,11 +1,12 @@
1
1
  import type { ExactFileIdentity } from "./exact-identity.js";
2
+ import type { DirectoryMode } from "./directory-mode-options.js";
2
3
  import type { FileStore, FileStoreSync } from "./file-store.js";
3
4
  import type { TempPathIdentityReceipt } from "./temp-cleanup.js";
4
5
  import type { TempWorkspaceCleanupResult, TempWorkspaceCleanupSafety } from "./temp-workspace-owner.js";
5
6
  export type TempWorkspaceOptions = {
6
7
  rootDir: string;
7
8
  prefix: string;
8
- dirMode?: number;
9
+ dirMode?: DirectoryMode;
9
10
  mode?: number;
10
11
  cleanupSafety?: TempWorkspaceCleanupSafety;
11
12
  };
@@ -1,7 +1,8 @@
1
1
  import { type ReplaceFileAtomicOptions } from "./replace-file.js";
2
+ import type { DirectoryMode } from "./directory-mode-options.js";
2
3
  export type WriteTextAtomicOptions = Pick<ReplaceFileAtomicOptions, "beforeRename" | "tempPrefix"> & {
3
4
  mode?: number;
4
- dirMode?: number;
5
+ dirMode?: DirectoryMode;
5
6
  trailingNewline?: boolean;
6
7
  /** Defaults to true; false skips file and parent fsync without changing replacement. */
7
8
  durable?: boolean;
@@ -24,3 +24,4 @@ export type BasePathOptions = {
24
24
  relativePath: string;
25
25
  };
26
26
  export type { ExactFileIdentity } from "./exact-identity.js";
27
+ export type { DirectoryMode } from "./directory-mode-options.js";
@@ -173,8 +173,11 @@ export async function admittedNativeChanges(root, scopes, before, after, batch,
173
173
  }
174
174
  }
175
175
  const guards = new Map();
176
+ // These guards have no published dependants. Reuse acquisition only within
177
+ // this pass, with a fresh physical-path/identity fence for every hint.
178
+ const unselectedGuards = new Map();
176
179
  const admittedParent = async (parent) => {
177
- let guard = guards.get(parent);
180
+ let guard = guards.get(parent) ?? unselectedGuards.get(parent);
178
181
  if (!guard) {
179
182
  const resolved = await resolvePathInRoot(root, parent ? "./" + parent : ".", { rejectSymlinks: true });
180
183
  guard = await createRootDirectoryObservationGuard(root, resolved.resolved);
@@ -257,6 +260,7 @@ export async function admittedNativeChanges(root, scopes, before, after, batch,
257
260
  if (scheduling || retained)
258
261
  throw error;
259
262
  guards.delete(parent);
263
+ unselectedGuards.delete(parent);
260
264
  if (isNotFoundPathError(error) || (error instanceof FsSafeError && ["not-found", "path-alias", "outside-workspace", "symlink", "not-file"].includes(error.code)))
261
265
  break;
262
266
  // A yielded admission may race an ordinary sibling deletion. Fresh
@@ -284,9 +288,14 @@ export async function admittedNativeChanges(root, scopes, before, after, batch,
284
288
  // A newly created directory may contain selected entries absent from the baseline.
285
289
  if (scheduling)
286
290
  return undefined;
287
- // The guarded observation proved this parent is not a selected alias.
288
- // No result depends on it; do not extend its lifetime through sibling churn.
291
+ // No result depends on this parent. Later hints must revalidate it,
292
+ // and a failed fence gets fresh admission rather than becoming a stale
293
+ // selected-alias dependency. Do not retain it in the final result fence.
289
294
  guards.delete(hint.directory);
295
+ // An alias spelling may be redirected while its old canonical referent
296
+ // survives. Only the original canonical route can be fenced by this guard.
297
+ if (guard.dir === path.join(root.rootReal, hint.directory))
298
+ unselectedGuards.set(hint.directory, guard);
290
299
  continue;
291
300
  }
292
301
  [parent, expected] = admitted;
@@ -10,5 +10,4 @@ export declare function writeAllToFile(target: FileHandle | number, data: string
10
10
  encoding?: BufferEncoding;
11
11
  position?: number;
12
12
  assertBeforeMutation?: () => void;
13
- synchronous?: boolean;
14
13
  }): Promise<void>;
@@ -31,18 +31,16 @@ export async function writeAllToFile(target, data, options = {}) {
31
31
  const length = Math.min(WRITE_CHUNK_BYTES, buffer.byteLength - offset);
32
32
  const position = options.position === undefined ? null : options.position + offset;
33
33
  options.assertBeforeMutation?.();
34
- const written = typeof target === "number" && options.synchronous
35
- ? fs.writeSync(target, buffer, offset, length, position)
36
- : typeof target === "number"
37
- ? await new Promise((resolve, reject) => {
38
- fs.write(target, buffer, offset, length, position, (error, bytesWritten) => {
39
- if (error)
40
- reject(error);
41
- else
42
- resolve(bytesWritten);
43
- });
44
- })
45
- : (await target.write(buffer, offset, length, position)).bytesWritten;
34
+ const written = typeof target === "number"
35
+ ? await new Promise((resolve, reject) => {
36
+ fs.write(target, buffer, offset, length, position, (error, bytesWritten) => {
37
+ if (error)
38
+ reject(error);
39
+ else
40
+ resolve(bytesWritten);
41
+ });
42
+ })
43
+ : (await target.write(buffer, offset, length, position)).bytesWritten;
46
44
  if (written <= 0) {
47
45
  throw new FsSafeError("helper-failed", "file write made no progress");
48
46
  }
@@ -31,9 +31,9 @@ The exports group into a handful of themes. Documented helpers link to their con
31
31
  | `resolveExistingPathsWithinRoot` | – | Validate existing regular files inside the root, while allowing missing paths. |
32
32
  | `resolveStrictExistingPathsWithinRoot` | – | Require every target to exist as a regular non-symlink file inside the root. |
33
33
  | `resolveWritablePathWithinRoot` | – | Resolve a write target inside a root. |
34
- | `resolveRootPath`, `resolveRootPathSync`, `ResolvedRootPath`, `ROOT_PATH_ALIAS_POLICIES`, `RootPathAliasPolicy` | – | Resolve a root directory honoring alias policy. |
34
+ | `resolveRootPath`, `resolveRootPathSync`, `ResolvedRootPath`, `ROOT_PATH_ALIAS_POLICIES`, `RootPathAliasPolicy` | – | Resolve a root directory honoring alias policy. Awaited POSIX traversal uses asynchronous Node metadata and canonicalization; the explicit sync variant blocks. Windows retains synchronous traversal to preserve concurrent reads and atomic publication until canonicalization supports delete sharing. Identity/observation guards and runtime-specific native canonicalization may still be synchronous. |
35
35
  | `resolvePathViaExistingAncestorSync` | – | Walk to an existing ancestor for paths whose tail does not yet exist. |
36
- | `resolvePathPrefixSync`, `ResolvedPathPrefix` | [path-prefix.md](path-prefix.md) | Follow physical symlink targets and return a canonical existing prefix with the raw missing suffix; propagate uncertain resolution failures. |
36
+ | `resolvePathPrefix`, `resolvePathPrefixSync`, `ResolvedPathPrefix` | [path-prefix.md](path-prefix.md) | Follow physical symlink targets and return a canonical existing prefix with the raw missing suffix; propagate uncertain resolution failures. |
37
37
  | `probePathCaseInsensitiveSync`, `ProbePathCaseOptions` | [path-case.md](path-case.md) | Observe local ASCII-case behavior with explicit read-only mode and owned temporary-probe cleanup. |
38
38
  | `probePathSuffixAliasesSync`, `ProbePathSuffixAliasesOptions` | [path-suffix-aliases.md](path-suffix-aliases.md) | Observe selected missing suffix aliases with bounded temporary directory probes; ambiguity, dynamic budget exhaustion, or incomplete cleanup returns `undefined`. |
39
39
 
@@ -77,7 +77,7 @@ concurrent namespace changes.
77
77
  | `writeFileWindowFully`, `WriteFileWindowOptions` | [Borrowed-handle writes](#borrowed-handle-writes) | Write all supplied bytes at an explicit position or the current cursor, completing short writes with cancellation and per-write authority checks. |
78
78
  | `copyFileHandle`, `copyFileDescriptorSync`, `CopyFileHandleOptions` | [copy.md](copy.md#borrowed-filehandle-transfers) | Copy caller-owned regular files through async handles or sync descriptors from position zero with byte limits and synchronous callbacks; preserves cursors and leaves publication and cleanup to the caller. |
79
79
  | `sameFileContentsSync`, `SameFileContentsOptions` | [Exact file comparison](file-contents.md) | Compare borrowed regular-file descriptors byte for byte through EOF with bounded memory and an optional per-file byte limit, preserving both cursors and lifetimes. |
80
- | `overwriteFileHandle`, `OverwriteFileHandleOptions` | [in-place-write.md](in-place-write.md) | Overwrite a borrowed read/write handle with prefix-only preparation and best-effort rollback; preserves its inode, cursor, and caller-owned lifetime. |
80
+ | `overwriteFileHandle`, `overwriteFileHandleWithAuthority`, `OverwriteFileHandleOptions` | [in-place-write.md](in-place-write.md) | Overwrite a borrowed read/write handle with prefix-only preparation and best-effort rollback; preserves its inode, cursor, and caller-owned lifetime. |
81
81
  | `openRootFile`, `openRootFileSync`, `canUseRootFileOpen`, `matchRootFileOpenFailure`, related types | – | Low-level root-bounded open; rejects every symlink component by default, with `symlinks: "follow-parents-within-root"` for contained parent aliases or `"follow-within-root"` for final links too. |
82
82
  | `createRootFileOpenBatchSync`, `RootFileOpenBatchSync` | [Synchronous open batches](reading.md#synchronous-open-batches) | Reuse native Windows root handles for synchronous file opens while retaining fresh file checks. |
83
83
  | `appendRegularFile`, `appendRegularFileSync`, `readRegularFile`, `readRegularFileSync`, `statRegularFile`, `statRegularFileSync`, `resolveRegularFileAppendFlags`, `AppendRegularFileOptions`, `RegularFileStatResult` | [regular-file.md](regular-file.md) | Type-checked regular-file I/O. |