@openclaw/matrix 2026.11.11 → 2026.12.1-beta.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.
Files changed (192) hide show
  1. package/dist/.setup/{approval-handler.runtime-CCGCnRgz.mjs → approval-handler.runtime-BfY586xJ.mjs} +4 -4
  2. package/dist/.setup/{channel-BEgolhUJ.mjs → channel-Cc7auxIF.mjs} +8 -8
  3. package/dist/.setup/{channel.runtime-_NMfiRJl.mjs → channel.runtime-B6ZmWLDZ.mjs} +5 -5
  4. package/dist/.setup/{channel.setup-B7r4NCcE.mjs → channel.setup-D9-chyNP.mjs} +2 -2
  5. package/dist/.setup/{cli-CyjnAIzU.mjs → cli-BrTpL9JI.mjs} +7 -7
  6. package/dist/.setup/{cli-metadata-DNeLBXHC.mjs → cli-metadata-R7WyIFzA.mjs} +1 -1
  7. package/dist/.setup/{client-BVgnwwz0.mjs → client-BmxOI9-U.mjs} +2 -2
  8. package/dist/.setup/{client-gch0wggI.mjs → client-DOb_5cJm.mjs} +2 -2
  9. package/dist/.setup/{client-bootstrap-CHs5OQ1Z.mjs → client-bootstrap-BwDbzw5i.mjs} +1 -1
  10. package/dist/.setup/{create-client-mnjEWdZV.mjs → create-client-BQpMgtl2.mjs} +2 -2
  11. package/dist/.setup/{crypto-runtime-tZ95jwNO.mjs → crypto-runtime-CStae6zK.mjs} +1 -1
  12. package/dist/.setup/{direct-management-D59C1WO-.mjs → direct-management-Bm4vd-k1.mjs} +1 -1
  13. package/dist/.setup/{directory-live-CQNKUJJx.mjs → directory-live-DRGF3zFp.mjs} +1 -1
  14. package/dist/.setup/{draft-stream-DI_6HWy4.mjs → draft-stream-DpSefQTK.mjs} +2 -2
  15. package/dist/.setup/{exec-approvals-B23spbVI.mjs → exec-approvals-CTkGLt3Z.mjs} +2 -2
  16. package/dist/.setup/{messages-VnZ4u4iq.mjs → messages-DjmI7l5t.mjs} +3 -3
  17. package/dist/.setup/{monitor-wbUkxHXK.mjs → monitor-HjyjGlys.mjs} +18 -18
  18. package/dist/.setup/{onboarding-B51d5a6R.mjs → onboarding-BPkKv4dw.mjs} +3 -3
  19. package/dist/.setup/{outbound-D8rgFTRa.mjs → outbound-CthMgcxZ.mjs} +2 -2
  20. package/dist/.setup/{profile-update-DAQFPf4L.mjs → profile-update-myTQ_w_e.mjs} +3 -3
  21. package/dist/.setup/{reaction-events-CZlbNkx_.mjs → reaction-events-C22fpTeK.mjs} +5 -5
  22. package/dist/.setup/{resolve-targets-B3NLls5a.mjs → resolve-targets-3B6QJQUf.mjs} +1 -1
  23. package/dist/.setup/{room-info-Cw-BH1CA.mjs → room-info-7ER9IkzT.mjs} +3 -3
  24. package/dist/.setup/{sdk-Bzp2OIxv.mjs → sdk-DphkoEH1.mjs} +32 -33
  25. package/dist/.setup/{send-CK8h-x83.mjs → send-CAfHI3Oi.mjs} +18 -13
  26. package/dist/.setup/{send-currentness-D1x6YP9O.mjs → send-currentness-Zv5Z-1_t.mjs} +9 -5
  27. package/dist/.setup/{setup-bootstrap-DsHa4swp.mjs → setup-bootstrap-COKlzUTV.mjs} +2 -2
  28. package/dist/.setup/{setup-core-B3MI_zz4.mjs → setup-core-B1dRvn1h.mjs} +1 -1
  29. package/dist/.setup/setup-plugin-api-BGpOj2cE.mjs +2 -0
  30. package/dist/.setup/{thread-bindings-C_SHelhg.mjs → thread-bindings-DFF_4WP3.mjs} +1 -1
  31. package/dist/.setup/{tool-actions-nhsof0wb.mjs → tool-actions-Cal-116X.mjs} +11 -11
  32. package/dist/.setup/{verification-BZqaSKCW.mjs → verification-2flsiwT7.mjs} +1 -1
  33. package/dist/.source-module-urls/1cd4d4ff8d44e1c8b830932b44d7cf8a7f3350e09e169910e1d7a85e131b7bea.json +1 -1
  34. package/dist/api.js +4 -4
  35. package/dist/channel-plugin-api.js +1 -1
  36. package/dist/cli-metadata.js +1 -1
  37. package/dist/contract-api.js +2 -2
  38. package/dist/index.js +1 -1
  39. package/dist/plugin-entry.handlers.runtime.js +2 -2
  40. package/dist/session-binding-contract-api.js +1 -1
  41. package/dist/setup-entry.js +1 -1
  42. package/dist/setup-plugin-api.js +1 -1
  43. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +57 -0
  44. package/node_modules/@openclaw/fs-safe/README.md +6 -0
  45. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  46. package/node_modules/@openclaw/fs-safe/dist/atomic-io.d.ts +1 -0
  47. package/node_modules/@openclaw/fs-safe/dist/atomic-io.js +10 -0
  48. package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts +1 -1
  49. package/node_modules/@openclaw/fs-safe/dist/bounded-read.js +15 -4
  50. package/node_modules/@openclaw/fs-safe/dist/directory-guard.js +11 -2
  51. package/node_modules/@openclaw/fs-safe/dist/drvfs-parent.d.ts +6 -0
  52. package/node_modules/@openclaw/fs-safe/dist/drvfs-parent.js +38 -0
  53. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-acquisition.d.ts +1 -1
  54. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-acquisition.js +2 -2
  55. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.js +13 -8
  56. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-io.js +13 -0
  57. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-mutation.d.ts +2 -2
  58. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-mutation.js +34 -24
  59. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-stale-admission.js +7 -2
  60. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.js +20 -20
  61. package/node_modules/@openclaw/fs-safe/dist/file-observation.d.ts +13 -2
  62. package/node_modules/@openclaw/fs-safe/dist/file-observation.js +8 -4
  63. package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.d.ts +1 -0
  64. package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.js +11 -1
  65. package/node_modules/@openclaw/fs-safe/dist/file-store-write-options.d.ts +2 -0
  66. package/node_modules/@openclaw/fs-safe/dist/file-store-write-options.js +17 -0
  67. package/node_modules/@openclaw/fs-safe/dist/file-store.d.ts +2 -1
  68. package/node_modules/@openclaw/fs-safe/dist/file-store.js +12 -16
  69. package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +1 -1
  70. package/node_modules/@openclaw/fs-safe/dist/guest.js +3 -4
  71. package/node_modules/@openclaw/fs-safe/dist/json-document-store.d.ts +2 -0
  72. package/node_modules/@openclaw/fs-safe/dist/json-document-store.js +1 -0
  73. package/node_modules/@openclaw/fs-safe/dist/json-store.js +1 -0
  74. package/node_modules/@openclaw/fs-safe/dist/json.d.ts +5 -2
  75. package/node_modules/@openclaw/fs-safe/dist/json.js +6 -2
  76. package/node_modules/@openclaw/fs-safe/dist/local-file-descriptor.js +16 -10
  77. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +6 -0
  78. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +4 -0
  79. package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.d.ts +20 -0
  80. package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.js +18 -0
  81. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +3 -18
  82. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +48 -24
  83. package/node_modules/@openclaw/fs-safe/dist/opened-file-failure.js +19 -7
  84. package/node_modules/@openclaw/fs-safe/dist/output.d.ts +1 -0
  85. package/node_modules/@openclaw/fs-safe/dist/output.js +3 -0
  86. package/node_modules/@openclaw/fs-safe/dist/path-policy.js +4 -1
  87. package/node_modules/@openclaw/fs-safe/dist/permissions-windows.js +35 -10
  88. package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts +9 -2
  89. package/node_modules/@openclaw/fs-safe/dist/pinned-open.js +42 -23
  90. package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +85 -34
  91. package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +3 -0
  92. package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +4 -0
  93. package/node_modules/@openclaw/fs-safe/dist/prepare-directory-mode.d.ts +1 -0
  94. package/node_modules/@openclaw/fs-safe/dist/prepare-directory-mode.js +1 -1
  95. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +2 -2
  96. package/node_modules/@openclaw/fs-safe/dist/publication-recovery.d.ts +24 -0
  97. package/node_modules/@openclaw/fs-safe/dist/publication-recovery.js +151 -0
  98. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.d.ts +1 -0
  99. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +2 -1
  100. package/node_modules/@openclaw/fs-safe/dist/realpath.d.ts +1 -1
  101. package/node_modules/@openclaw/fs-safe/dist/realpath.js +22 -11
  102. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.d.ts +1 -0
  103. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +5 -0
  104. package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.d.ts +7 -0
  105. package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.js +75 -2
  106. package/node_modules/@openclaw/fs-safe/dist/replace-file-types.d.ts +2 -0
  107. package/node_modules/@openclaw/fs-safe/dist/replace-file.js +14 -10
  108. package/node_modules/@openclaw/fs-safe/dist/root-context.js +28 -12
  109. package/node_modules/@openclaw/fs-safe/dist/root-copy.js +1 -0
  110. package/node_modules/@openclaw/fs-safe/dist/root-create-input.js +2 -2
  111. package/node_modules/@openclaw/fs-safe/dist/root-file-final-admission.d.ts +4 -0
  112. package/node_modules/@openclaw/fs-safe/dist/root-file-final-admission.js +53 -36
  113. package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.js +3 -1
  114. package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts +2 -1
  115. package/node_modules/@openclaw/fs-safe/dist/root-file.js +24 -13
  116. package/node_modules/@openclaw/fs-safe/dist/root-impl.js +17 -1
  117. package/node_modules/@openclaw/fs-safe/dist/root-options.d.ts +4 -2
  118. package/node_modules/@openclaw/fs-safe/dist/root-path.d.ts +1 -1
  119. package/node_modules/@openclaw/fs-safe/dist/root-path.js +2 -1
  120. package/node_modules/@openclaw/fs-safe/dist/root-read-admission.js +31 -9
  121. package/node_modules/@openclaw/fs-safe/dist/root-write-admission.js +6 -2
  122. package/node_modules/@openclaw/fs-safe/dist/secret-file.d.ts +1 -0
  123. package/node_modules/@openclaw/fs-safe/dist/secret-file.js +2 -0
  124. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.d.ts +1 -0
  125. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +84 -4
  126. package/node_modules/@openclaw/fs-safe/dist/sibling-temp.d.ts +1 -0
  127. package/node_modules/@openclaw/fs-safe/dist/sibling-temp.js +2 -0
  128. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.js +22 -15
  129. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-publication.d.ts +22 -0
  130. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-publication.js +303 -0
  131. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.d.ts +2 -0
  132. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js +9 -1
  133. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-root.d.ts +8 -0
  134. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-root.js +37 -3
  135. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-staging.d.ts +14 -0
  136. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-staging.js +155 -0
  137. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-stale-admission.js +7 -2
  138. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-write.d.ts +10 -0
  139. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-write.js +143 -0
  140. package/node_modules/@openclaw/fs-safe/dist/temp-target.js +28 -7
  141. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-admission.d.ts +2 -2
  142. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-admission.js +34 -18
  143. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.d.ts +1 -1
  144. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +13 -3
  145. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.js +1 -1
  146. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-types.d.ts +9 -0
  147. package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts +6 -0
  148. package/node_modules/@openclaw/fs-safe/dist/text-atomic.d.ts +1 -1
  149. package/node_modules/@openclaw/fs-safe/dist/text-atomic.js +1 -0
  150. package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts +1 -0
  151. package/node_modules/@openclaw/fs-safe/dist/windows-owner.js +2 -1
  152. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
  153. package/node_modules/@openclaw/fs-safe/docs/advanced.md +6 -1
  154. package/node_modules/@openclaw/fs-safe/docs/atomic.md +64 -0
  155. package/node_modules/@openclaw/fs-safe/docs/contributing.md +69 -0
  156. package/node_modules/@openclaw/fs-safe/docs/file-store.md +2 -0
  157. package/node_modules/@openclaw/fs-safe/docs/json-store.md +2 -0
  158. package/node_modules/@openclaw/fs-safe/docs/json.md +2 -0
  159. package/node_modules/@openclaw/fs-safe/docs/output.md +2 -0
  160. package/node_modules/@openclaw/fs-safe/docs/permissions.md +20 -7
  161. package/node_modules/@openclaw/fs-safe/docs/reading.md +24 -9
  162. package/node_modules/@openclaw/fs-safe/docs/root.md +2 -0
  163. package/node_modules/@openclaw/fs-safe/docs/security-model.md +2 -0
  164. package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +12 -7
  165. package/node_modules/@openclaw/fs-safe/docs/staged-file.md +2 -0
  166. package/node_modules/@openclaw/fs-safe/docs/temp-isolation-reference.md +73 -0
  167. package/node_modules/@openclaw/fs-safe/docs/temp.md +65 -0
  168. package/node_modules/@openclaw/fs-safe/docs/testing.md +1 -0
  169. package/node_modules/@openclaw/fs-safe/docs/writing.md +2 -0
  170. package/node_modules/@openclaw/fs-safe/package.json +25 -20
  171. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  172. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  173. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  174. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  175. package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
  176. package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +1 -1
  177. package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
  178. package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +1 -1
  179. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  180. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  181. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  182. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  183. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  184. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  185. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  186. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  187. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
  188. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +1 -1
  189. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  190. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  191. package/package.json +5 -5
  192. package/dist/.setup/setup-plugin-api-D6-D6LLj.mjs +0 -2
@@ -5,6 +5,7 @@ export type ExternalFileWriteOptions<T = void> = {
5
5
  maxBytes?: number;
6
6
  mode?: number;
7
7
  staging?: "workspace" | "sibling";
8
+ allowDrvfsRenameRecovery?: boolean;
8
9
  /** Isolate sibling producers; workspace staging is already private. */
9
10
  producerIsolation?: "private-directory";
10
11
  fallbackFileName?: string;
@@ -94,6 +94,7 @@ export async function writeExternalFileWithinRoot(options) {
94
94
  fallbackFileName,
95
95
  maxBytes,
96
96
  mode,
97
+ allowDrvfsRenameRecovery: options.allowDrvfsRenameRecovery,
97
98
  });
98
99
  return { path: siblingFinalPath, result };
99
100
  }
@@ -108,6 +109,7 @@ export async function writeExternalFileWithinRoot(options) {
108
109
  mode,
109
110
  mkdir: true,
110
111
  sourceHardlinks: "reject",
112
+ allowDrvfsRenameRecovery: options.allowDrvfsRenameRecovery,
111
113
  });
112
114
  return { path: finalPath, result };
113
115
  }
@@ -139,6 +141,7 @@ async function writeExternalFileViaSibling(params) {
139
141
  mode: params.mode,
140
142
  maxBytes: params.maxBytes,
141
143
  syncTempFile: true,
144
+ allowDrvfsRenameRecovery: params.allowDrvfsRenameRecovery,
142
145
  syncParentDir: true,
143
146
  });
144
147
  return result;
@@ -1,4 +1,5 @@
1
1
  import fs from "node:fs";
2
+ import { recordFileObservationFailure } from "./file-observation.js";
2
3
  import { ROOT_PATH_ALIAS_POLICIES, resolveRootPath, } from "./root-path.js";
3
4
  import { isNotFoundPathError } from "./path.js";
4
5
  import { shortPath } from "./error-detail.js";
@@ -44,6 +45,8 @@ export async function assertNoHardlinkedFinalPath(params) {
44
45
  return;
45
46
  }
46
47
  if (stat.nlink > 1) {
47
- throw new Error(`Hardlinked path is not allowed under ${boundaryLabel} (${shortPath(root)}): ${shortPath(filePath)}`);
48
+ const error = new Error(`Hardlinked path is not allowed under ${boundaryLabel} (${shortPath(root)}): ${shortPath(filePath)}`);
49
+ recordFileObservationFailure(error, "hardlink");
50
+ throw error;
48
51
  }
49
52
  }
@@ -5,7 +5,7 @@ import { executePermissionCommand } from "./permission-exec.js";
5
5
  import { safeStat } from "./permissions.js";
6
6
  import { normalizeLowercaseStringOrEmpty } from "./string-coerce.js";
7
7
  import { resolveWindowsSystemCommand } from "./windows-command.js";
8
- import { inspectWindowsOwner } from "./windows-owner.js";
8
+ import { inspectWindowsOwner, TRUSTED_INSTALLER_SID } from "./windows-owner.js";
9
9
  import { assertWindowsAclRemediationAllowed } from "./windows-appcontainer.js";
10
10
  import { hasWindowsPathAlias } from "./windows-path-alias.js";
11
11
  const INHERIT_FLAGS = new Set(["I", "OI", "CI", "IO", "NP"]);
@@ -25,7 +25,7 @@ const SID_RE = /^\*?s-\d+-\d+(-\d+)+$/i;
25
25
  const TRUSTED_SIDS = new Set([
26
26
  "s-1-5-18",
27
27
  "s-1-5-32-544",
28
- "s-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464",
28
+ TRUSTED_INSTALLER_SID,
29
29
  ]);
30
30
  const WORLD_SIDS = new Set(["s-1-1-0", "s-1-5-11", "s-1-5-32-545", "s-1-5-7", "s-1-5-32-546", "s-1-5-4", "s-1-2-0", "s-1-5-2"]);
31
31
  const STATUS_PREFIXES = [
@@ -46,24 +46,39 @@ function inspectWindowsPermissionsNative(targetPath, unverified) {
46
46
  if (!native)
47
47
  return undefined;
48
48
  const facts = native.readOwnerAndDacl(targetPath);
49
- if (facts.fallbackRequired) {
49
+ if (facts.fallbackRequired || !facts.isLocal || !facts.aceListComplete || facts.unsupportedAceTypes.length !== 0) {
50
50
  if (facts.currentAppContainerSid) {
51
51
  throw new FsSafeError("helper-unavailable", "AppContainer ACL facts require an unavailable external helper");
52
52
  }
53
53
  return undefined;
54
54
  }
55
+ // Native coarse flags also serve secure descriptors' stricter policy.
56
+ // Public reporting classifies the observations with the fallback's policy.
57
+ const acl = summarizeWindowsOwnerAcl({
58
+ sid: facts.ownerSid,
59
+ daclPresent: facts.daclPresent,
60
+ currentUserSid: facts.currentUserSid,
61
+ currentAppContainerSid: facts.currentAppContainerSid ?? undefined,
62
+ aces: facts.aces.map(ace => ({
63
+ sid: ace.sid, mask: ace.mask, deny: ace.aceType === "deny",
64
+ inheritOnly: ace.flags.inheritOnly,
65
+ })),
66
+ });
67
+ if (!acl.ok)
68
+ return { ...unverified, error: acl.error };
69
+ const worldWritable = acl.untrustedWorld.some(entry => entry.canWrite);
70
+ const groupWritable = acl.untrustedGroup.some(entry => entry.canWrite);
71
+ const worldReadable = acl.untrustedWorld.some(entry => entry.canRead);
72
+ const groupReadable = acl.untrustedGroup.some(entry => entry.canRead);
55
73
  return {
56
74
  ...unverified,
57
75
  source: "windows-acl",
58
- worldWritable: facts.worldWritable,
59
- groupWritable: facts.groupWritable,
60
- worldReadable: facts.worldReadable,
61
- groupReadable: facts.groupReadable,
76
+ worldWritable, groupWritable, worldReadable, groupReadable,
62
77
  ownerSid: facts.ownerSid,
63
- ownerTrusted: facts.ownerClass !== "foreign",
78
+ ownerTrusted: facts.ownerClass !== "foreign" || normalizeSid(facts.ownerSid) === TRUSTED_INSTALLER_SID,
64
79
  aclSummary: `native owner=${facts.ownerClass} world=` +
65
- `${facts.worldReadable ? "r" : "-"}${facts.worldWritable ? "w" : "-"} ` +
66
- `group=${facts.groupReadable ? "r" : "-"}${facts.groupWritable ? "w" : "-"}`,
80
+ `${worldReadable ? "r" : "-"}${worldWritable ? "w" : "-"} ` +
81
+ `group=${groupReadable ? "r" : "-"}${groupWritable ? "w" : "-"}`,
67
82
  };
68
83
  }
69
84
  export async function inspectWindowsPermissions(targetPath, unverified, opts) {
@@ -252,6 +267,16 @@ function summarizeWindowsOwnerAcl(owner) {
252
267
  };
253
268
  });
254
269
  const summary = summarizeWindowsAcl(entries, { USERSID: owner.currentUserSid });
270
+ // Admit serviced sources, but not user-owned or user-writable profiles.
271
+ const ownerSid = normalizeSid(owner.sid ?? "");
272
+ const serviceOwned = ownerSid === TRUSTED_INSTALLER_SID || ownerSid === "s-1-5-18" || ownerSid === "s-1-5-32-544";
273
+ const userWritable = entries.some(entry => entry.canWrite &&
274
+ (entry.sid === owner.currentUserSid || entry.sid === owner.currentAppContainerSid));
275
+ if (!serviceOwned || userWritable) {
276
+ const servicing = summary.trusted.filter(entry => entry.sid === TRUSTED_INSTALLER_SID);
277
+ summary.untrustedGroup.push(...servicing);
278
+ summary.trusted = summary.trusted.filter(entry => entry.sid !== TRUSTED_INSTALLER_SID);
279
+ }
255
280
  if (owner.currentAppContainerSid) {
256
281
  const own = summary.untrustedGroup.filter(entry => entry.sid === owner.currentAppContainerSid);
257
282
  summary.trusted.push(...own);
@@ -1,4 +1,5 @@
1
1
  import fs from "node:fs";
2
+ import type { OwnedFileDescriptorSync } from "./create-owned-file.js";
2
3
  export type PinnedOpenSyncFailureReason = "path" | "validation" | "io";
3
4
  export type PinnedOpenSyncResult = {
4
5
  ok: true;
@@ -6,6 +7,7 @@ export type PinnedOpenSyncResult = {
6
7
  fd: number;
7
8
  stat: fs.Stats;
8
9
  identity: fs.BigIntStats;
10
+ close?: () => void;
9
11
  } | {
10
12
  ok: false;
11
13
  reason: PinnedOpenSyncFailureReason;
@@ -18,7 +20,7 @@ export type PinnedOpenSyncFinalAdmission = (params: {
18
20
  }) => string;
19
21
  export type PinnedOpenSyncFs = Pick<typeof fs, "constants" | "lstatSync" | "realpathSync" | "openSync" | "fstatSync" | "closeSync">;
20
22
  export declare function isExpectedPathError(error: unknown): boolean;
21
- export declare function openPinnedFileSync(params: {
23
+ type PinnedOpenParams = {
22
24
  filePath: string;
23
25
  resolvedPath?: string;
24
26
  rejectPathSymlink?: boolean;
@@ -27,6 +29,11 @@ export declare function openPinnedFileSync(params: {
27
29
  maxBytes?: number;
28
30
  allowedType?: PinnedOpenSyncAllowedType;
29
31
  ioFs?: PinnedOpenSyncFs;
30
- admittedFd?: number;
32
+ admittedFile?: OwnedFileDescriptorSync;
33
+ finalAdmission?: (params: Parameters<PinnedOpenSyncFinalAdmission>[0]) => string | Promise<string>;
34
+ };
35
+ export declare function openPinnedFileSync(params: PinnedOpenParams & {
31
36
  finalAdmission?: PinnedOpenSyncFinalAdmission;
32
37
  }): PinnedOpenSyncResult;
38
+ export declare function openPinnedFile(params: PinnedOpenParams): Promise<PinnedOpenSyncResult>;
39
+ export {};
@@ -1,28 +1,42 @@
1
1
  import { numberStats } from "./exact-identity.js";
2
2
  import fs from "node:fs";
3
+ import asyncFs from "node:fs/promises";
4
+ import { promisify } from "node:util";
5
+ import { runAsync, runSync, wait } from "./atomic-io.js";
3
6
  import { isUnsafeDeviceReadPath } from "./device-path.js";
4
7
  import { FsSafeError } from "./errors.js";
5
- import { inspectFileIdentitySync } from "./strict-file-identity.js";
8
+ import { inspectFileIdentity, inspectFileIdentitySync } from "./strict-file-identity.js";
6
9
  import { resolveReadOpenFlags } from "./read-open-flags.js";
7
10
  import { assertNoWindowsPathAlias } from "./windows-path-alias.js";
8
11
  import { realpathSync } from "./realpath.js";
12
+ const openFd = promisify(fs.open);
13
+ const statFd = promisify(fs.fstat);
14
+ const closeFd = promisify(fs.close);
9
15
  export function isExpectedPathError(error) {
10
16
  const code = typeof error === "object" && error !== null && "code" in error ? String(error.code) : "";
11
17
  return code === "ENOENT" || code === "ENOTDIR" || code === "ELOOP";
12
18
  }
13
19
  export function openPinnedFileSync(params) {
20
+ return runSync(openPinnedFileProcedure(params, false));
21
+ }
22
+ export function openPinnedFile(params) {
23
+ return runAsync(openPinnedFileProcedure(params, true));
24
+ }
25
+ function* openPinnedFileProcedure(params, asynchronous) {
14
26
  const filePath = params.filePath;
15
27
  const resolvedPath = params.resolvedPath;
16
28
  const ioFs = params.ioFs ?? fs;
17
29
  const allowedType = params.allowedType ?? "file";
18
30
  const rejectPathSymlink = params.rejectPathSymlink === true;
31
+ const finalAdmission = params.finalAdmission;
19
32
  const statPolicy = {
20
33
  rejectHardlinks: params.rejectHardlinks,
21
34
  rejectLeafSymlinks: params.rejectLeafSymlinks,
22
35
  maxBytes: params.maxBytes,
23
36
  };
24
37
  const openReadFlags = resolveReadOpenFlags({ constants: ioFs.constants });
25
- let fd = params.admittedFd ?? null;
38
+ const admittedFile = params.admittedFile;
39
+ let fd = admittedFile?.fd ?? null;
26
40
  try {
27
41
  assertNoWindowsPathAlias(filePath, "filesystem", "file path uses a Windows filesystem namespace alias");
28
42
  if (resolvedPath !== undefined) {
@@ -32,39 +46,39 @@ export function openPinnedFileSync(params) {
32
46
  return { ok: false, reason: "validation" };
33
47
  }
34
48
  if (rejectPathSymlink) {
35
- const candidateStat = ioFs.lstatSync(filePath);
49
+ const candidateStat = asynchronous ? yield* wait(asyncFs.lstat(filePath)) : ioFs.lstatSync(filePath);
36
50
  if (candidateStat.isSymbolicLink()) {
37
51
  return { ok: false, reason: "validation" };
38
52
  }
39
53
  }
40
- const realPath = resolvedPath ??
41
- (ioFs === fs ? realpathSync(filePath) : ioFs.realpathSync(filePath));
54
+ const realPath = resolvedPath ?? (asynchronous ? yield* wait(asyncFs.realpath(filePath)) :
55
+ (ioFs === fs ? realpathSync(filePath) : ioFs.realpathSync(filePath)));
42
56
  assertNoWindowsPathAlias(realPath, "filesystem", "resolved path uses a Windows filesystem namespace alias");
43
57
  if (isUnsafeDeviceReadPath(realPath)) {
44
58
  return { ok: false, reason: "validation" };
45
59
  }
46
- const preOpenStat = inspectFileIdentitySync(() => {
47
- const stat = ioFs.lstatSync(realPath, { bigint: true });
48
- assertAllowedStat(stat, allowedType, statPolicy);
49
- return stat;
50
- });
51
- fd ??= ioFs.openSync(realPath, openReadFlags);
52
- const identity = inspectFileIdentitySync(() => {
53
- const stat = ioFs.fstatSync(fd, { bigint: true });
60
+ const admitStat = (stat) => {
54
61
  assertAllowedStat(stat, allowedType, statPolicy);
55
62
  return stat;
56
- }, preOpenStat);
57
- inspectFileIdentitySync(() => {
58
- const stat = ioFs.lstatSync(realPath, { bigint: true });
59
- assertAllowedStat(stat, allowedType, statPolicy);
60
- return stat;
61
- }, identity);
62
- const admittedPath = params.finalAdmission?.({
63
+ };
64
+ function* inspectPath(expected) {
65
+ return asynchronous
66
+ ? yield* wait(inspectFileIdentity(async () => admitStat(await asyncFs.lstat(realPath, { bigint: true })), expected))
67
+ : inspectFileIdentitySync(() => admitStat(ioFs.lstatSync(realPath, { bigint: true })), expected);
68
+ }
69
+ const preOpenStat = yield* inspectPath();
70
+ fd ??= asynchronous ? yield* wait(openFd(realPath, openReadFlags)) : ioFs.openSync(realPath, openReadFlags);
71
+ const identity = asynchronous
72
+ ? yield* wait(inspectFileIdentity(async () => admitStat(await statFd(fd, { bigint: true })), preOpenStat))
73
+ : inspectFileIdentitySync(() => admitStat(ioFs.fstatSync(fd, { bigint: true })), preOpenStat);
74
+ yield* inspectPath(identity);
75
+ const admittedPath = finalAdmission ? yield* wait(finalAdmission({
63
76
  path: realPath,
64
77
  descriptorIdentity: identity,
65
- }) ?? realPath;
78
+ })) : realPath;
66
79
  const openedStat = numberStats(identity);
67
- const opened = { ok: true, path: admittedPath, fd, stat: openedStat, identity };
80
+ const opened = { ok: true, path: admittedPath, fd, stat: openedStat, identity,
81
+ ...(admittedFile ? { close: admittedFile.close } : {}) };
68
82
  fd = null;
69
83
  return opened;
70
84
  }
@@ -79,7 +93,12 @@ export function openPinnedFileSync(params) {
79
93
  finally {
80
94
  if (fd !== null) {
81
95
  try {
82
- ioFs.closeSync(fd);
96
+ if (admittedFile)
97
+ admittedFile.close();
98
+ else if (asynchronous)
99
+ yield* wait(closeFd(fd));
100
+ else
101
+ ioFs.closeSync(fd);
83
102
  }
84
103
  catch {
85
104
  // Preserve the failed admission result; success transfers fd above.
@@ -16,11 +16,13 @@ import { assertPinnedWriteMode, pinnedWriteModeAssertion, preparePinnedWriteMode
16
16
  import { publishCopyStage } from "./publish-copy-stage.js";
17
17
  import { openPublicationHandle } from "./publication-handle.js";
18
18
  import { resolveReadOpenFlags } from "./read-open-flags.js";
19
- import { cleanupPinnedFilePath } from "./file-cleanup.js";
19
+ import { cleanupPinnedFilePath, hasErrorCode } from "./file-cleanup.js";
20
20
  import { assertFinalSymlinkRejected } from "./root-symlink-policy.js";
21
21
  import { createStagedFileReceipt, settleStagedFile } from "./staged-file-settlement.js";
22
22
  import { getFsSafeTestHooks } from "./test-hooks.js";
23
23
  import { restoreCopyMetadata } from "./copy-metadata.js";
24
+ import { assertRecoveredFile, recoverAfterHiddenRename, shouldPrepareDrvfsRecovery } from "./publication-recovery.js";
25
+ import { retainDrvfsParent } from "./drvfs-parent.js";
24
26
  export async function runPinnedStagedWrite(params, parentPath, parentGuard) {
25
27
  const verifyPosixMode = process.platform !== "win32" &&
26
28
  (params.verifyPosixMode === true || params.private === true);
@@ -38,11 +40,45 @@ export async function runPinnedStagedWrite(params, parentPath, parentGuard) {
38
40
  let readHandle;
39
41
  let handoffCloseFailure;
40
42
  let renamed = false;
43
+ let recoveryParent;
44
+ let recoveryIdentity;
45
+ let recoveryContent;
41
46
  const completeCreate = params.overwrite === false && params.input.kind !== "file" && params.input.stageBeforePublish === true;
42
47
  let receipt;
43
48
  let publication = Object.freeze({ status: "not-published" });
44
49
  let phase = "prepare";
45
50
  let failure;
51
+ const observePublished = () => {
52
+ try {
53
+ return fsSync.lstatSync(targetPath, { bigint: true });
54
+ }
55
+ catch (error) {
56
+ if (!hasErrorCode(error, "ENOENT") || !handle || !recoveryParent)
57
+ throw error;
58
+ const previous = handle;
59
+ return (async () => {
60
+ // DrvFS reveals the name only after the operation releases its writer.
61
+ readHandle = await recoverAfterHiddenRename({
62
+ closeWriter: () => { handle = undefined; return previous.close(); },
63
+ parentFd: recoveryParent.fd,
64
+ reopen: async () => {
65
+ recoveryParent.assertCurrent();
66
+ const reopened = await openPublicationHandle(targetPath, recoveryIdentity);
67
+ try {
68
+ assertRecoveredFile(reopened.fd, recoveryIdentity, recoveryContent);
69
+ recoveryParent.assertCurrent();
70
+ return reopened;
71
+ }
72
+ catch (error) {
73
+ await reopened.close();
74
+ throw error;
75
+ }
76
+ },
77
+ });
78
+ return fsSync.lstatSync(targetPath, { bigint: true });
79
+ })();
80
+ }
81
+ };
46
82
  try {
47
83
  params.assertBeforeMutation?.();
48
84
  assertExclusiveCreateLeaf(tempPath);
@@ -95,6 +131,14 @@ export async function runPinnedStagedWrite(params, parentPath, parentGuard) {
95
131
  const canHandoff = process.platform !== "win32" &&
96
132
  ((params.mode & 0o400) !== 0 ||
97
133
  (process.platform === "linux" && (process.arch === "x64" || process.arch === "arm64")));
134
+ if (shouldPrepareDrvfsRecovery(params.allowDrvfsRenameRecovery)) {
135
+ recoveryParent = retainDrvfsParent(parentPath, parentGuard.stat.dev);
136
+ if (recoveryParent)
137
+ recoveryIdentity = fsSync.fstatSync(handle.fd, { bigint: true });
138
+ if (recoveryParent && params.input.kind === "buffer")
139
+ recoveryContent = typeof params.input.data === "string"
140
+ ? Buffer.from(params.input.data, params.input.encoding) : Buffer.from(params.input.data);
141
+ }
98
142
  phase = "publish";
99
143
  await withAsyncDirectoryGuards([parentGuard], async () => {
100
144
  assertFinalSymlinkRejected(targetPath, params.rejectFinalSymlink);
@@ -113,6 +157,7 @@ export async function runPinnedStagedWrite(params, parentPath, parentGuard) {
113
157
  publication = Object.freeze({ status: "published", staged: receipt, basename: params.basename, overwrite: false });
114
158
  params.onPublished?.(identity);
115
159
  },
160
+ afterRename: recoveryParent ? observePublished : undefined,
116
161
  beforeTemporaryUnlink: !canHandoff ? undefined : async () => {
117
162
  readHandle = await openPublicationHandle(targetPath, expectedTempStat);
118
163
  // Keep the destination pinned while closing the stage's NFS dentry.
@@ -136,7 +181,8 @@ export async function runPinnedStagedWrite(params, parentPath, parentGuard) {
136
181
  await getFsSafeTestHooks()?.afterPinnedWriteFallbackRename?.(targetPath);
137
182
  if (params.sync !== false)
138
183
  await syncDirectoryBestEffort(parentPath);
139
- const targetStat = fsSync.lstatSync(targetPath, { bigint: true });
184
+ const observed = observePublished();
185
+ const targetStat = observed instanceof Promise ? await observed : observed;
140
186
  if (targetStat.isSymbolicLink()) {
141
187
  throw new FsSafeError("path-mismatch", "fallback target changed during write");
142
188
  }
@@ -174,39 +220,44 @@ export async function runPinnedStagedWrite(params, parentPath, parentGuard) {
174
220
  throw error;
175
221
  }
176
222
  finally {
177
- const preservedPreparation = params.private && !handle && hasPreservedCreationArtifacts(failure?.error);
178
- if (completeCreate || preservedPreparation) {
179
- await settleStagedFile({
180
- temporaryBasename: path.basename(tempPath), publication, phase, failure,
181
- cleanup: async () => {
182
- if (preservedPreparation)
183
- return "preserved";
184
- if (publication.status === "indeterminate")
185
- return "preserved";
186
- if (renamed) {
187
- return failure?.error instanceof FsSafeError && failure.error.details?.cleanup === "failed"
188
- ? "failed" : "not-needed";
223
+ try {
224
+ const preservedPreparation = params.private && !handle && hasPreservedCreationArtifacts(failure?.error);
225
+ if (completeCreate || preservedPreparation) {
226
+ await settleStagedFile({
227
+ temporaryBasename: path.basename(tempPath), publication, phase, failure,
228
+ cleanup: async () => {
229
+ if (preservedPreparation)
230
+ return "preserved";
231
+ if (publication.status === "indeterminate")
232
+ return "preserved";
233
+ if (renamed) {
234
+ return failure?.error instanceof FsSafeError && failure.error.details?.cleanup === "failed"
235
+ ? "failed" : "not-needed";
236
+ }
237
+ return handle ? await cleanupPinnedFilePath({
238
+ pathname: tempPath, handle, identity: tempIdentity, parentGuard, throwOnCleanupError: true,
239
+ }) : "not-needed";
240
+ },
241
+ close: [async () => { await readHandle?.close(); }, async () => {
242
+ await handle?.close();
243
+ if (handoffCloseFailure)
244
+ throw handoffCloseFailure.error;
245
+ }],
246
+ });
247
+ }
248
+ else
249
+ try {
250
+ if (!renamed && handle) {
251
+ await cleanupPinnedFilePath({ pathname: tempPath, handle, identity: tempIdentity, parentGuard });
189
252
  }
190
- return handle ? await cleanupPinnedFilePath({
191
- pathname: tempPath, handle, identity: tempIdentity, parentGuard, throwOnCleanupError: true,
192
- }) : "not-needed";
193
- },
194
- close: [async () => { await readHandle?.close(); }, async () => {
195
- await handle?.close();
196
- if (handoffCloseFailure)
197
- throw handoffCloseFailure.error;
198
- }],
199
- });
200
- }
201
- else
202
- try {
203
- if (!renamed && handle) {
204
- await cleanupPinnedFilePath({ pathname: tempPath, handle, identity: tempIdentity, parentGuard });
205
253
  }
206
- }
207
- finally {
208
- await readHandle?.close().catch(() => undefined);
209
- await handle?.close().catch(() => undefined);
210
- }
254
+ finally {
255
+ await readHandle?.close().catch(() => undefined);
256
+ await handle?.close().catch(() => undefined);
257
+ }
258
+ }
259
+ finally {
260
+ recoveryParent?.close();
261
+ }
211
262
  }
212
263
  }
@@ -12,6 +12,7 @@ export type PinnedWriteInput = {
12
12
  kind: "buffer";
13
13
  data: string | Buffer;
14
14
  encoding?: BufferEncoding;
15
+ sidecar?: boolean;
15
16
  stageBeforePublish?: boolean;
16
17
  } | {
17
18
  kind: "stream";
@@ -63,11 +64,13 @@ export type PinnedWriteParams = {
63
64
  strictFileSync?: boolean;
64
65
  overwrite?: boolean;
65
66
  assertBeforeMutation?: () => void;
67
+ assertSidecarCleanupCandidate?: (candidate: string) => void;
66
68
  rejectFinalSymlink?: boolean;
67
69
  maxBytes?: number;
68
70
  input: PinnedWriteInput;
69
71
  rootIdentity?: FileIdentityStat;
70
72
  mutationAdmission?: PinnedWriteMutationAdmission;
73
+ allowDrvfsRenameRecovery?: boolean;
71
74
  onRenameIdentityMismatch?: "verify-content";
72
75
  onPublished?: (identity: PublishedWriteIdentity) => void;
73
76
  verifyPublished?: (fd: number, identity: PublishedWriteIdentity, parentGuard: AnyAsyncDirectoryGuard, nativeParent?: NativeWriteParent) => Promise<void>;
@@ -22,6 +22,7 @@ import { assertPinnedWriteMode, preparePinnedWriteMode } from "./pinned-write-mo
22
22
  import { runPinnedStagedWrite } from "./pinned-write-staged.js";
23
23
  import { assertFinalSymlinkRejected } from "./root-symlink-policy.js";
24
24
  import { assertNoWindowsPathAlias } from "./windows-path-alias.js";
25
+ import { writeSidecarAtParent } from "./sidecar-lock-write.js";
25
26
  import { copyLinkAtParent } from "./copy-link.js";
26
27
  function assertSafeBasename(basename) {
27
28
  if (!basename ||
@@ -227,6 +228,9 @@ async function runPinnedWriteFallback(params) {
227
228
  }
228
229
  if (params.input.kind === "link")
229
230
  return await copyLinkAtParent(params, params.input, parentGuard);
231
+ if (params.input.kind === "buffer" && params.input.sidecar) {
232
+ return await writeSidecarAtParent(params, parentGuard);
233
+ }
230
234
  if (params.overwrite === false && params.input.kind !== "file" && !params.input.stageBeforePublish) {
231
235
  const assertBeforeMutation = () => {
232
236
  assertFinalSymlinkRejected(targetPath, params.rejectFinalSymlink);
@@ -6,4 +6,5 @@ export declare function prepareDirectoryMode(io: AtomicIo, params: {
6
6
  mode: number | "preserve";
7
7
  mutation?: AtomicMutation;
8
8
  ignoreChmodError?: boolean;
9
+ allowDrvfsRenameRecovery?: boolean;
9
10
  }): Procedure<void>;
@@ -33,7 +33,7 @@ export function* prepareDirectoryMode(io, params) {
33
33
  const parent = path.dirname(params.dirPath);
34
34
  if (parent === params.dirPath)
35
35
  throw error;
36
- yield* prepareDirectoryMode(io, { ...params, dirPath: parent });
36
+ yield* prepareDirectoryMode(io, { ...params, dirPath: parent, allowDrvfsRenameRecovery: false });
37
37
  params.mutation?.assert();
38
38
  try {
39
39
  yield* io.mkdirExclusive(params.dirPath, 0o700);
@@ -169,7 +169,7 @@ function registerTempWorkspace(dir, retainedChild, capability, admission, dirMod
169
169
  }
170
170
  async function createTempWorkspace(options, scopedPrefix = false) {
171
171
  const { rootDir, dirMode, mode, cleanupSafety } = tempWorkspaceSettings(options);
172
- const admission = await admitTempWorkspaceRoot(rootDir);
172
+ const admission = await admitTempWorkspaceRoot(rootDir, options.trustedWritableAncestors);
173
173
  const root = admission.dir;
174
174
  const childPrefix = tempWorkspaceChildPrefix(root, options, scopedPrefix);
175
175
  const capability = new TempWorkspaceCleanupCapability(root, cleanupSafety, admission, dirMode);
@@ -260,7 +260,7 @@ export async function withTempWorkspace(options, run) {
260
260
  }
261
261
  function createTempWorkspaceSync(options, scopedPrefix = false) {
262
262
  const { rootDir, dirMode, mode, cleanupSafety } = tempWorkspaceSettings(options);
263
- const admission = admitTempWorkspaceRootSync(rootDir);
263
+ const admission = admitTempWorkspaceRootSync(rootDir, options.trustedWritableAncestors);
264
264
  const root = admission.dir;
265
265
  const childPrefix = tempWorkspaceChildPrefix(root, options, scopedPrefix);
266
266
  const capability = new TempWorkspaceCleanupCapability(root, cleanupSafety, admission, dirMode);
@@ -0,0 +1,24 @@
1
+ import fs from "node:fs";
2
+ import type { NativeBinding } from "./native-binding.js";
3
+ /** Other platforms keep their existing path even when the option is enabled. */
4
+ export declare function shouldPrepareDrvfsRecovery(enabled: boolean | undefined, dev?: bigint): boolean;
5
+ /** Negative evidence only: a stale/reused device number can only disable recovery. */
6
+ export declare function mayPrepareDrvfsRecoveryAtFd(parentFd: number, dev: bigint): boolean;
7
+ /** No sampling or positive cache: the retained directory's exact mount owns admission. */
8
+ export declare function admitsDrvfsRenameRecoveryAtFd(parentFd: number): boolean;
9
+ /** Exact metadata is necessary but cannot exclude inode reuse after the final close. */
10
+ export declare function assertRecoveredPublication(actual: fs.BigIntStats, expected: fs.BigIntStats): void;
11
+ export declare function recoverAfterHiddenRename<T>(params: {
12
+ closeWriter: () => Promise<void>;
13
+ reopen: () => Promise<T>;
14
+ parentFd: number;
15
+ retain?: (recovered: T) => Promise<void>;
16
+ dispose?: (recovered: T) => Promise<void>;
17
+ }): Promise<T>;
18
+ export declare function recoverAfterHiddenRenameSync<T>(params: {
19
+ closeWriter: () => void;
20
+ reopen: () => T;
21
+ parentFd: number;
22
+ }): T;
23
+ export declare function assertRecoveredFile(fd: number, expected: fs.BigIntStats, content?: Uint8Array): void;
24
+ export declare function reopenRecoveredNativeFile(binding: NativeBinding, parentFd: number, basename: string, expected: fs.BigIntStats, content?: Uint8Array): number;