@openclaw/feishu 2026.10.6 → 2026.10.8
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/.setup/{channel-DykAJJhn.mjs → channel-C6xKXhoV.mjs} +2 -2
- package/dist/.setup/{channel.runtime-CC15v8AP.mjs → channel.runtime-u62eAaRZ.mjs} +1 -1
- package/dist/.setup/{monitor-Cy9ofY1Q.mjs → monitor-BkQxhpUk.mjs} +1 -1
- package/dist/.setup/{monitor.account-UbN1RhlP.mjs → monitor.account-lTPltlCL.mjs} +19 -30
- package/dist/.setup/{setup-api-CRjDSHmn.mjs → setup-api-DfO9XC1M.mjs} +1 -1
- package/dist/.source-module-urls/6579f1b33dd01f8f0aaea28311ed6df1a635f9ad1e6fa86dcba53bca46407e55.json +1 -0
- package/dist/api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/setup-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/node_modules/@openclaw/fs-safe/CHANGELOG.md +48 -0
- package/node_modules/@openclaw/fs-safe/README.md +14 -4
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +28 -3
- package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.js +11 -5
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-loader.js +4 -2
- package/node_modules/@openclaw/fs-safe/dist/archive.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/clone-metadata.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +4 -3
- package/node_modules/@openclaw/fs-safe/dist/copy-link.d.ts +26 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-link.js +169 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-metadata.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-metadata.js +39 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/copy-tree-portable.js +3 -6
- package/node_modules/@openclaw/fs-safe/dist/copy.js +3 -3
- package/node_modules/@openclaw/fs-safe/dist/darwin-acl.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/darwin-acl.js +29 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.js +27 -2
- package/node_modules/@openclaw/fs-safe/dist/entry-publication.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/file-handle-transfer.js +4 -2
- package/node_modules/@openclaw/fs-safe/dist/file-hash.js +4 -3
- package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-write-lease.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/file-write-lease.js +42 -0
- package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.js +5 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.js +16 -3
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +57 -18
- package/node_modules/@openclaw/fs-safe/dist/native-directory-observation.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +19 -1
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts +4 -1
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +18 -0
- package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native.d.ts +5 -3
- package/node_modules/@openclaw/fs-safe/dist/native.js +25 -6
- package/node_modules/@openclaw/fs-safe/dist/opened-realpath.js +9 -1
- package/node_modules/@openclaw/fs-safe/dist/overwrite-file-handle.js +4 -1
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-windows.js +36 -47
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-input.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +5 -3
- package/node_modules/@openclaw/fs-safe/dist/pipe.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/pipe.js +26 -0
- package/node_modules/@openclaw/fs-safe/dist/private-producer-handoff.js +2 -5
- package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +92 -10
- package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/publish-file.js +12 -11
- package/node_modules/@openclaw/fs-safe/dist/root-copy.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/root-copy.js +128 -0
- package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +12 -4
- package/node_modules/@openclaw/fs-safe/dist/root-impl.js +6 -92
- package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/root-options.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/root-remove-native.js +8 -1
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-target.js +8 -1
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-native.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.cs +11 -5
- package/node_modules/@openclaw/fs-safe/dist/windows-security-command.js +9 -1
- package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.d.ts +16 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.js +51 -0
- package/node_modules/@openclaw/fs-safe/docs/archive.md +16 -0
- package/node_modules/@openclaw/fs-safe/docs/contributing.md +35 -5
- package/node_modules/@openclaw/fs-safe/docs/copy.md +22 -0
- package/node_modules/@openclaw/fs-safe/docs/durability.md +4 -2
- package/node_modules/@openclaw/fs-safe/docs/errors.md +8 -0
- package/node_modules/@openclaw/fs-safe/docs/guest.md +2 -0
- package/node_modules/@openclaw/fs-safe/docs/install.md +13 -5
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +5 -5
- package/node_modules/@openclaw/fs-safe/docs/native-helper.md +15 -5
- package/node_modules/@openclaw/fs-safe/docs/native.md +51 -2
- package/node_modules/@openclaw/fs-safe/docs/pipe.md +81 -0
- package/node_modules/@openclaw/fs-safe/docs/platform-capabilities.md +63 -0
- package/node_modules/@openclaw/fs-safe/docs/quickstart.md +23 -3
- package/node_modules/@openclaw/fs-safe/docs/reading.md +7 -1
- package/node_modules/@openclaw/fs-safe/docs/secret-file.md +5 -5
- package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +31 -13
- package/node_modules/@openclaw/fs-safe/docs/store.md +11 -0
- package/node_modules/@openclaw/fs-safe/docs/types.md +45 -80
- package/node_modules/@openclaw/fs-safe/docs/writing.md +121 -14
- package/node_modules/@openclaw/fs-safe/package.json +18 -10
- package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
- package/package.json +5 -5
|
@@ -106,6 +106,7 @@ Use the main entry for the common surface, or the focused subpaths when you want
|
|
|
106
106
|
| `@openclaw/fs-safe/json` | `tryReadJson`, `readJson`, `readJsonIfExists`, `writeJson`, sync variants. |
|
|
107
107
|
| `@openclaw/fs-safe/store` | `fileStore()`, `fileStoreSync()`, and `jsonStore<T>()`. |
|
|
108
108
|
| `@openclaw/fs-safe/secret` | Secret file read/write helpers. |
|
|
109
|
+
| `@openclaw/fs-safe/pipe` | Native-owned, reopenable anonymous pipes for one-shot child input. |
|
|
109
110
|
| `@openclaw/fs-safe/atomic` | `replaceFileAtomic`, `writeTextAtomic`, `replaceDirectoryAtomic`, `movePathWithCopyFallback`. |
|
|
110
111
|
| `@openclaw/fs-safe/durability` | Pinned directories, strict sync, durable directory creation, exclusive publication, and streaming SHA-256. |
|
|
111
112
|
| `@openclaw/fs-safe/temp` | `tempWorkspace`, `withTempWorkspace`, sync variants, `resolveSecureTempRoot`. |
|
|
@@ -125,9 +126,11 @@ Use the main entry for the common surface, or the focused subpaths when you want
|
|
|
125
126
|
|
|
126
127
|
`@openclaw/fs-safe` bundles an import-free WASM build of its Rust TAR parser and zstd/bzip2 codecs for guarded [archive extraction and bounded entry reads](archive.md). Plain TAR, gzip, zstd, and bzip2 work in `off` and missing-native `auto`, including installs with all optional dependencies omitted; gzip uses Node's built-in decoder. These archive fallbacks need no runtime interpreter, download, or consumer compiler. ZIP fallback uses lazily loaded optional `jszip` and reports a missing-dependency error without it. Public subpaths remain safe to import with all optional dependencies omitted, but imports do not prove native availability. Native `require` remains strict, and an available native operation's failure never triggers a WASM retry.
|
|
127
128
|
|
|
128
|
-
There are no peer dependencies. Exact-version optional packages carry the
|
|
129
|
+
There are no peer dependencies. Exact-version optional packages carry the
|
|
129
130
|
native targets and npm-compatible OS, CPU, and Linux libc filters install only
|
|
130
|
-
the matching binary.
|
|
131
|
+
the matching binary. Windows ARM64 Node selects
|
|
132
|
+
`@openclaw/fs-safe-win32-arm64-msvc`; x64 Node on the same host selects the x64
|
|
133
|
+
package. Consumers do not run a Rust build, download code at
|
|
131
134
|
runtime, or execute a postinstall step. Omitting optional dependencies keeps
|
|
132
135
|
fallback-capable operations working in `auto` or `off`. Native-only
|
|
133
136
|
features, including strict owned-tree temp cleanup, retained-directory staging,
|
|
@@ -145,8 +148,11 @@ before deploying with native mode `require` or native-only features.
|
|
|
145
148
|
The native addon supports kernels without `openat2` (before Linux 5.6) and
|
|
146
149
|
containers returning `ENOSYS` or probe-time `EPERM` for that syscall. Beneath
|
|
147
150
|
opens use a guarded no-follow component walk and report `best-effort`.
|
|
148
|
-
Nested no-clobber moves retain
|
|
149
|
-
|
|
151
|
+
Nested no-clobber moves retain native parent admission and exact identity checks;
|
|
152
|
+
keep native mode enabled. If `renameat2(RENAME_NOREPLACE)` is also unsupported,
|
|
153
|
+
Linux `auto` uses [move fallbacks](writing.md#fs-move-from-to-options), including
|
|
154
|
+
a directory rename that can replace a concurrently created empty directory.
|
|
155
|
+
Native `require` refuses these fallbacks. Strict bounded cleanup still
|
|
150
156
|
requires `openat2` with `RESOLVE_NO_XDEV` and reports `helper-unavailable`
|
|
151
157
|
without it. See [Linux capability behavior and limits](native.md#linux-without-openat2).
|
|
152
158
|
|
|
@@ -180,7 +186,9 @@ available native operation's error never triggers a command retry. See
|
|
|
180
186
|
### Supported native platforms
|
|
181
187
|
|
|
182
188
|
Prebuilt bindings cover Linux x64/arm64 (GNU glibc **2.28 or newer**, or musl),
|
|
183
|
-
macOS x64/arm64,
|
|
189
|
+
macOS x64/arm64, Windows x64/arm64, and FreeBSD 14.4+ x64/arm64. FreeBSD provides the
|
|
190
|
+
[documented subset](native.md#freebsd-14-4-and-newer); its other operations retain
|
|
191
|
+
guarded fallbacks in `auto`. The GNU baseline includes RHEL 8, Rocky Linux 8,
|
|
184
192
|
and AlmaLinux 8. A compatible Node 22+ runtime and the kernel/filesystem features
|
|
185
193
|
required by each operation are still necessary; a loadable addon alone does not
|
|
186
194
|
guarantee every native capability. Systems older than glibc 2.28 are outside the
|
|
@@ -16,11 +16,11 @@ Current releases install the matching exact-version optional platform package.
|
|
|
16
16
|
- Run on Node.js 22 or newer.
|
|
17
17
|
- Update `@openclaw/fs-safe` and regenerate every lock or shrinkwrap file your
|
|
18
18
|
deployment consumes.
|
|
19
|
-
- Keep optional dependencies enabled
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
- Keep optional dependencies enabled for the matching native package and the
|
|
20
|
+
JSZip fallback. Current TAR/gzip/zstd/bzip2 fallbacks are bundled and work
|
|
21
|
+
with optional dependencies omitted. Native loading no longer depends on
|
|
22
|
+
Python. See [runtime dependencies](install.md#runtime-dependencies) for the
|
|
23
|
+
current installation contract.
|
|
24
24
|
|
|
25
25
|
If you call `resolveRootPath()` or `resolveRootPathSync()` directly, upgrade to
|
|
26
26
|
0.5: versions through 0.4.7 could approve an in-root symlink traversal that
|
|
@@ -5,8 +5,10 @@ description: "How fs-safe loads its platform-specific native filesystem primitiv
|
|
|
5
5
|
|
|
6
6
|
# Native helper policy
|
|
7
7
|
|
|
8
|
-
`@openclaw/fs-safe` declares
|
|
9
|
-
x64/arm64 (glibc or musl), macOS x64/arm64, and
|
|
8
|
+
`@openclaw/fs-safe` declares exact-version optional packages for Linux
|
|
9
|
+
x64/arm64 (glibc or musl), macOS x64/arm64, Windows x64/arm64, and FreeBSD x64/arm64.
|
|
10
|
+
The FreeBSD 14.4+ bindings expose the [qualified subset](native.md#freebsd-14-4-and-newer).
|
|
11
|
+
Package-manager
|
|
10
12
|
OS, CPU, and libc filters install only the matching package. The loader requires
|
|
11
13
|
that package lazily, without runtime downloads, postinstall scripts, or a
|
|
12
14
|
consumer Rust build.
|
|
@@ -33,6 +35,12 @@ See [Archive extraction](archive.md) for native, bundled WASM, and ZIP backends.
|
|
|
33
35
|
Native archive-operation failures are terminal; `auto` does not retry them through a
|
|
34
36
|
fallback. `require` rejects missing bindings or required capabilities.
|
|
35
37
|
|
|
38
|
+
A loaded binding may provide only a subset of native operations. Each operation
|
|
39
|
+
checks its required capabilities before native dispatch: missing capabilities
|
|
40
|
+
select the existing guarded fallback in `auto`, or report `helper-unavailable`
|
|
41
|
+
in `require`. A failure from an available native method is still an operation
|
|
42
|
+
failure; it is not treated as a missing capability.
|
|
43
|
+
|
|
36
44
|
Windows owner/DACL inspection, private-directory creation, and secure reads can
|
|
37
45
|
use [PowerShell fallbacks](install.md#windows-security-fallback) in `auto` and
|
|
38
46
|
`off`; `require` stays strict, and native operation failures remain terminal.
|
|
@@ -109,10 +117,12 @@ is authoritative for operation and platform guarantees.
|
|
|
109
117
|
|
|
110
118
|
## Migration from the Python helper
|
|
111
119
|
|
|
112
|
-
The
|
|
113
|
-
|
|
120
|
+
The Python configuration bridge has been removed. Old Python environment
|
|
121
|
+
settings are ignored without a warning, so an old `require` or `off` setting
|
|
122
|
+
does not select the corresponding native policy. Configure
|
|
123
|
+
`FS_SAFE_NATIVE_MODE` or `configureFsSafeNative()` explicitly. Follow the
|
|
114
124
|
[0.5 migration checklist](migrating-to-0.5.md#2-replace-python-helper-configuration)
|
|
115
|
-
for
|
|
125
|
+
for the removed settings and current precedence.
|
|
116
126
|
|
|
117
127
|
## Related pages
|
|
118
128
|
|
|
@@ -5,6 +5,9 @@ description: "The platform-specific native bindings, fd-relative beneath model,
|
|
|
5
5
|
|
|
6
6
|
# Native architecture
|
|
7
7
|
|
|
8
|
+
See [platform filesystem capabilities](platform-capabilities.md) for Linux
|
|
9
|
+
write leases, public Darwin ACL facts, and Windows test fixtures.
|
|
10
|
+
|
|
8
11
|
`@openclaw/fs-safe` uses native bindings that supply mechanisms Node does
|
|
9
12
|
not expose directly. The Rust layer is deliberately not a second policy engine.
|
|
10
13
|
TypeScript owns trusted-root selection, path validation, archive filtering,
|
|
@@ -14,12 +17,46 @@ platform syscall sequence that can preserve the boundary.
|
|
|
14
17
|
|
|
15
18
|
Every operation that has an equivalent safe Node implementation keeps that
|
|
16
19
|
guarded JavaScript path. Native loading is lazy; installs do not compile Rust,
|
|
17
|
-
run postinstall code, or fetch binaries at runtime.
|
|
20
|
+
run postinstall code, or fetch binaries at runtime. Exact-version optional
|
|
18
21
|
packages are filtered by OS, CPU, and Linux libc, so an installation receives
|
|
19
|
-
only its matching prebuilt binding.
|
|
22
|
+
only its matching prebuilt binding. Windows ships both x64 and ARM64 MSVC
|
|
23
|
+
bindings; selection follows the Node process architecture. An x64 Node process
|
|
24
|
+
on Windows ARM64 uses the x64 binding under emulation.
|
|
20
25
|
Native-only operations fail explicitly
|
|
21
26
|
instead of substituting a weaker implementation.
|
|
22
27
|
|
|
28
|
+
## FreeBSD 14.4 and newer
|
|
29
|
+
|
|
30
|
+
The FreeBSD x64 and arm64 packages provide native anonymous pipes, descriptor
|
|
31
|
+
close and POSIX canonicalization. The larger Linux/macOS/Windows filesystem backend is excluded
|
|
32
|
+
from these binaries: its Unix gates contain platform-specific resolver, clone,
|
|
33
|
+
copy, observation and cleanup implementations. FreeBSD does not export stubs for
|
|
34
|
+
those operations. In `auto`, each operation selects its existing guarded JavaScript
|
|
35
|
+
or WASM backend; in `require`, a missing required capability fails with
|
|
36
|
+
`helper-unavailable`. Pure JavaScript APIs retain their ordinary behavior.
|
|
37
|
+
|
|
38
|
+
| Native capability | FreeBSD binding |
|
|
39
|
+
|---|---|
|
|
40
|
+
| `createPipe`, `closeOwnedFd`, `canonicalizePath` | Implemented; real pipe, descriptor and pathname syscalls |
|
|
41
|
+
| Beneath open/create/mkdir/link, replace/no-replace rename and identity-fenced rename | Absent; guarded fallback where supported |
|
|
42
|
+
| Directory observations, retained files/symlinks, entry publication, owned-tree and root removal | Absent; guarded fallback or explicit native-only rejection |
|
|
43
|
+
| File/tree clone, native copy/hash, archive inspection/extraction and buffer readers | Absent; JavaScript/WASM fallback where supported |
|
|
44
|
+
| Native watch | Absent; polling fallback in `auto` |
|
|
45
|
+
| Darwin ACL and Windows security/identity methods | Not applicable |
|
|
46
|
+
|
|
47
|
+
The release workflow builds inside FreeBSD 14.4 VMs and checks installed-package
|
|
48
|
+
behavior on the main thread and a real Worker. ARM64 uses QEMU CPU emulation
|
|
49
|
+
with a real FreeBSD kernel. This is not a Linux cross-build runtime test. Build
|
|
50
|
+
locally on FreeBSD with `pnpm native:build:freebsd`; the JavaScript/WASM distribution
|
|
51
|
+
can be prepared separately with `pnpm build`. There is no qualified FreeBSD Bun
|
|
52
|
+
artifact in the runtime matrix. FreeBSD x64 installed-package proof covers npm
|
|
53
|
+
and pnpm. FreeBSD arm64 covers npm only because pnpm does not publish a native
|
|
54
|
+
binary for that target. CI prepares the ARM64 proof harness dependencies on Linux
|
|
55
|
+
and syncs them into the VM; consumer installations and runtime proof run inside
|
|
56
|
+
FreeBSD, without running pnpm there.
|
|
57
|
+
Reopening pipe descriptors through `/dev/fd` requires the standard `fdescfs`
|
|
58
|
+
mount there; the VM proof mounts it before testing reopen, inheritance and EOF.
|
|
59
|
+
|
|
23
60
|
## The beneath model
|
|
24
61
|
|
|
25
62
|
A trusted directory descriptor is the capability. Native operations accept
|
|
@@ -75,6 +112,11 @@ whether a path, archive entry, mode, owner, or cleanup policy is acceptable.
|
|
|
75
112
|
this layer only through the host executable's paired libuv descriptor bridge;
|
|
76
113
|
missing or partial exports fail with `ENOTSUP` instead of trying a raw HANDLE
|
|
77
114
|
or add-on CRT descriptor namespace.
|
|
115
|
+
`Root.copyIn` uses the same ReFS integrity, sparse-file, and cluster-aligned
|
|
116
|
+
block-clone operations as tree cloning, through retained source and destination
|
|
117
|
+
parent handles. The exclusive stage enters the existing guarded publication
|
|
118
|
+
path; transfer failures retain its cleanup receipt. It does not inherit the
|
|
119
|
+
tree API's source metadata policy.
|
|
78
120
|
|
|
79
121
|
The internal macOS `inspectDarwinAcl(fd)` capability reports `absent`, `empty`,
|
|
80
122
|
or `present` for the opened object's extended ACL. It synchronously borrows the
|
|
@@ -375,6 +417,13 @@ silently selects the JavaScript fallback in `auto`, throws typed
|
|
|
375
417
|
`helper-unavailable` in `require`, and is never inspected in `off`. Tests reject
|
|
376
418
|
`child_process`, `exec`, or `spawn` usage in the loader.
|
|
377
419
|
|
|
420
|
+
## Anonymous pipes
|
|
421
|
+
|
|
422
|
+
The lean [`pipe` subpath](pipe.md) creates native-owned anonymous pipes. Linux and
|
|
423
|
+
FreeBSD use atomic close-on-exec creation; Darwin reports its non-atomic flag
|
|
424
|
+
setup explicitly. Each end must close through its native owner, including when
|
|
425
|
+
a Node stream uses it in a Worker.
|
|
426
|
+
|
|
378
427
|
## Related pages
|
|
379
428
|
|
|
380
429
|
- [Native helper policy](native-helper.md)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Anonymous pipes
|
|
2
|
+
|
|
3
|
+
`@openclaw/fs-safe/pipe` exposes a synchronous, native anonymous pipe for
|
|
4
|
+
one-shot input to a child process. Both ends are reopenable through
|
|
5
|
+
`/proc/self/fd/N` on Linux and `/dev/fd/N` on Darwin and FreeBSD. This supports
|
|
6
|
+
programs that open an inherited descriptor as a pathname.
|
|
7
|
+
|
|
8
|
+
On FreeBSD, reopening through `/dev/fd/N` requires `fdescfs` mounted at `/dev/fd`.
|
|
9
|
+
An administrator can mount it with `mount -t fdescfs fdesc /dev/fd`; pipe creation
|
|
10
|
+
itself does not require that mount.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { createPipe, type OwnedPipeSync } from "@openclaw/fs-safe/pipe";
|
|
14
|
+
|
|
15
|
+
const pipe: OwnedPipeSync = createPipe();
|
|
16
|
+
try {
|
|
17
|
+
// Pass pipe.reader.fd as a numeric child_process spawn stdio entry.
|
|
18
|
+
// Keep both owners alive until their respective users finish.
|
|
19
|
+
} finally {
|
|
20
|
+
pipe.reader.close();
|
|
21
|
+
pipe.writer.close();
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The frozen result has `reader` and `writer` members of the existing
|
|
26
|
+
`OwnedFileDescriptorSync` type (`readonly fd: number`, `close(): void`, and
|
|
27
|
+
`[Symbol.dispose](): void`) and `readonly atomicCloseOnExec: boolean`.
|
|
28
|
+
Each end closes idempotently through its native owner. A close attempt consumes
|
|
29
|
+
ownership even if it throws; do not retry with a raw close or use the fd again.
|
|
30
|
+
The pair itself does not have a `close` or disposal method.
|
|
31
|
+
|
|
32
|
+
Linux and FreeBSD create both ends atomically with close-on-exec set.
|
|
33
|
+
Darwin sets the flag on both ends immediately after creation and reports
|
|
34
|
+
`atomicCloseOnExec: false`: a concurrent native fork/exec can inherit an end
|
|
35
|
+
in that short window. No JavaScript async work intervenes, but this is not an
|
|
36
|
+
atomic inheritance guarantee. Partial setup failure closes both ends.
|
|
37
|
+
|
|
38
|
+
Importing the subpath is lazy and does not load the addon or the secret-file
|
|
39
|
+
modules. Calling `createPipe()` requires a compatible native helper; disabled
|
|
40
|
+
or missing helpers throw `FsSafeError` with `helper-unavailable`. Windows and
|
|
41
|
+
other unsupported platforms throw `unsupported-platform`. Native creation
|
|
42
|
+
failures throw `helper-failed` with the original error as `cause`.
|
|
43
|
+
The cause's `code` preserves the native errno, including `EMFILE` (the process
|
|
44
|
+
descriptor limit) and `ENFILE` (the system-wide limit).
|
|
45
|
+
|
|
46
|
+
## Handing the writer to a Node stream
|
|
47
|
+
|
|
48
|
+
A native-created fd must close through its owner, including in Workers.
|
|
49
|
+
Provide the stream's custom close hook; do not let Node close it directly.
|
|
50
|
+
This is the writer handoff contract: retain the owner in the hook rather than
|
|
51
|
+
detaching its descriptor.
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { createWriteStream, write, writev } from "node:fs";
|
|
55
|
+
import { createPipe } from "@openclaw/fs-safe/pipe";
|
|
56
|
+
|
|
57
|
+
const pipe = createPipe();
|
|
58
|
+
const stream = createWriteStream("", {
|
|
59
|
+
fd: pipe.writer.fd,
|
|
60
|
+
fs: {
|
|
61
|
+
write,
|
|
62
|
+
writev,
|
|
63
|
+
close(_fd, callback) {
|
|
64
|
+
try {
|
|
65
|
+
pipe.writer.close();
|
|
66
|
+
callback(null);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
callback(error instanceof Error ? error : new Error(String(error)));
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
// After spawning with pipe.reader.fd in the child's stdio:
|
|
74
|
+
pipe.reader.close();
|
|
75
|
+
stream.end("one-shot input");
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Once the stream is created, its lifetime owns use of the writer: keep an error
|
|
79
|
+
listener, destroy it on cancellation, and wait for `close` before considering
|
|
80
|
+
the fd released. If stream construction fails, close both owners. Closing the
|
|
81
|
+
last writer delivers EOF; unread bytes remain available to the reader.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Platform filesystem capabilities
|
|
2
|
+
|
|
3
|
+
These synchronous capabilities load the native helper only when called. All
|
|
4
|
+
three entry points import on every supported platform.
|
|
5
|
+
|
|
6
|
+
## Linux write leases
|
|
7
|
+
|
|
8
|
+
`tryAcquireWriteLease(fd)` from `@openclaw/fs-safe/file-lock` returns a frozen
|
|
9
|
+
`FileWriteLease`, or `null` when another open descriptor prevents acquisition
|
|
10
|
+
(`EAGAIN` or `EBUSY`). Other failures throw `FsSafeError`; unsupported systems
|
|
11
|
+
throw `unsupported-platform` and unavailable helpers throw `helper-unavailable`.
|
|
12
|
+
|
|
13
|
+
The caller owns the descriptor, must keep it open until release, and must install
|
|
14
|
+
its own process-wide `SIGIO` handler **before** acquiring a lease. Prefer a
|
|
15
|
+
disposable child process when an application cannot own that signal. The API
|
|
16
|
+
does not install a signal handler. A competing open starts the kernel's lease
|
|
17
|
+
break; `isHeld()` then returns false, including during a pending downgrade.
|
|
18
|
+
Release promptly so the competing opener can proceed.
|
|
19
|
+
|
|
20
|
+
`lease.fd` is the borrowed descriptor. `lease.release()` and
|
|
21
|
+
`lease[Symbol.dispose]()` settle once without closing it; `isHeld()` returns
|
|
22
|
+
false after release. Never close or reuse the fd before settling the lease.
|
|
23
|
+
Lease acquisition does not replace the caller's path identity and age checks.
|
|
24
|
+
|
|
25
|
+
## Darwin ACL inspection
|
|
26
|
+
|
|
27
|
+
`inspectDarwinAcl(path)` from `@openclaw/fs-safe/permissions` opens the final
|
|
28
|
+
component without following symlinks, then inspects a descriptor-bound security
|
|
29
|
+
snapshot. Its `DarwinAclInspection` result is one of:
|
|
30
|
+
|
|
31
|
+
- `{ kind: "none" }` for a proven absent or empty extended ACL.
|
|
32
|
+
- `{ kind: "present", inheritsToFiles, inheritsToDirectories }` for an ACL with
|
|
33
|
+
entries, including when both inheritance flags are false.
|
|
34
|
+
- `{ kind: "unknown", reason }` when opening or inspection fails, the helper
|
|
35
|
+
is unavailable, or the native facts are incomplete. Other platforms return
|
|
36
|
+
`reason: "unsupported-platform"`.
|
|
37
|
+
|
|
38
|
+
Unknown is never evidence of absence. The two inheritance booleans report flag
|
|
39
|
+
presence, not effective permissions or volume ownership enforcement. Intermediate
|
|
40
|
+
path components follow ordinary path resolution; this is inspection, not a Root
|
|
41
|
+
confinement capability.
|
|
42
|
+
|
|
43
|
+
## Windows test fixtures
|
|
44
|
+
|
|
45
|
+
The following exports from `@openclaw/fs-safe/test-hooks` are for tests, not
|
|
46
|
+
production policy. They require the Windows native helper and reject final
|
|
47
|
+
reparse points. Other platforms throw `unsupported-platform`.
|
|
48
|
+
|
|
49
|
+
- `holdWindowsSharingLock(path)` returns a frozen disposable with idempotent
|
|
50
|
+
`close()`. Its native owner holds a non-inheritable handle with read/write
|
|
51
|
+
sharing, omitting delete sharing, until closed or collected.
|
|
52
|
+
- `setWindowsFileAttributes(path, { readOnly?, hidden?, system? })` updates the
|
|
53
|
+
supplied bits through the opened handle and preserves unspecified attributes.
|
|
54
|
+
- `readWindowsFileExtents(path)` returns `{ vcn, lcn, clusters }[]`, all bigint.
|
|
55
|
+
Empty or resident files may have no extents; `lcn: -1n` denotes sparse clusters.
|
|
56
|
+
Enumeration validates each response and fails on incomplete or invalid data.
|
|
57
|
+
It is an observation, not a snapshot against concurrent file modification.
|
|
58
|
+
|
|
59
|
+
Use Node's `fs.statfsSync(path).bsize` for Windows cluster size. Windows CI
|
|
60
|
+
compares it directly against `GetDiskFreeSpaceW`'s sectors-per-cluster times
|
|
61
|
+
bytes-per-sector on NTFS. CI does not provide ReFS; this does not establish ReFS
|
|
62
|
+
clone sharing. The extent reader reports mappings independently of the clone
|
|
63
|
+
implementation.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Quickstart
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build a `root()` and use it to read, write, atomically replace, and unpack an
|
|
4
|
+
archive under a trusted workspace. Confinement strength and concurrent-mutation
|
|
5
|
+
limits depend on the operation and platform; see the [security model](security-model.md).
|
|
4
6
|
|
|
5
7
|
If you have used Go's `os.Root` / `OpenInRoot` or Rust's [`cap-std`](https://github.com/bytecodealliance/cap-std), this is the same shape: a capability-style handle that carries the boundary across every operation. The first thing to internalize is that you stop reasoning about *paths* and start reasoning about *the handle*.
|
|
6
8
|
|
|
@@ -31,7 +33,9 @@ await fs.write("notes/today.txt", "hello\n");
|
|
|
31
33
|
const text = await fs.readText("notes/today.txt");
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
Replacement writes use a sibling temp file plus `rename`, so a partial write
|
|
37
|
+
never appears at the destination. Reads open with `O_NOFOLLOW` where available
|
|
38
|
+
and verify the opened fd matches the path identity before returning the buffer.
|
|
35
39
|
|
|
36
40
|
`create()` is the don't-clobber variant of `write()` and throws `already-exists` when the target is already there:
|
|
37
41
|
|
|
@@ -39,6 +43,13 @@ Writes use a sibling temp file plus `rename`, so a partial write never appears a
|
|
|
39
43
|
await fs.create("notes/README.md", "seed\n"); // throws if it already exists
|
|
40
44
|
```
|
|
41
45
|
|
|
46
|
+
Default create-only writes can expose incomplete content on the JavaScript
|
|
47
|
+
fallback. Pass `{ atomic: true }` to stage complete content before publication.
|
|
48
|
+
When hardlinks are refused, staged publication can still expose an empty
|
|
49
|
+
destination placeholder before replacing it with the completed file. See
|
|
50
|
+
[atomic creation](writing.md#atomic-buffered-creation) and
|
|
51
|
+
[publication without hardlinks](writing.md#publication-without-hardlinks).
|
|
52
|
+
|
|
42
53
|
## 3. JSON, with parsing
|
|
43
54
|
|
|
44
55
|
```ts
|
|
@@ -60,7 +71,16 @@ await fs.move("notes/today.txt", "notes/archive/today.txt", { overwrite: true })
|
|
|
60
71
|
await fs.remove("notes/archive/today.txt");
|
|
61
72
|
```
|
|
62
73
|
|
|
63
|
-
`move()` defaults to no clobber
|
|
74
|
+
`move()` defaults to no clobber and requires native support. Linux `auto` can
|
|
75
|
+
fall back when no-replace rename is unsupported; its directory fallback can
|
|
76
|
+
replace a concurrently created empty directory. Use native `require` when
|
|
77
|
+
that must fail closed. See the [move contract](writing.md#fs-move-from-to-options).
|
|
78
|
+
Pass `{ overwrite: true }` when replacement is intended.
|
|
79
|
+
|
|
80
|
+
`remove()` removes files and empty directories by default. For a non-empty
|
|
81
|
+
directory, pass `{ recursive: true }`; use `maxEntries`, `maxDepth`, and `signal`
|
|
82
|
+
to bound the work. See [`root()`](root.md) for removal ordering, limits, and
|
|
83
|
+
partial-removal semantics.
|
|
64
84
|
|
|
65
85
|
## 5. Inspect
|
|
66
86
|
|
|
@@ -81,6 +81,12 @@ For tighter control over malformed-or-missing JSON, use the standalone helpers i
|
|
|
81
81
|
|
|
82
82
|
Returns a `FileHandle` plus `containment: "best-effort"`, the verified `realPath`, and `stat`. Use this for streaming or partial reads, and **always close the handle**:
|
|
83
83
|
|
|
84
|
+
`open()` accepts `RootOpenOptions`: the read symlink and hardlink policies,
|
|
85
|
+
without `maxBytes`. It does not consume bytes or apply the Root's read-size
|
|
86
|
+
budget to later handle or stream operations. Bound that I/O in the caller, or
|
|
87
|
+
use `read()` / `readBytes()` when the library should enforce the whole-file cap.
|
|
88
|
+
The result also supports `await using` for automatic handle cleanup.
|
|
89
|
+
|
|
84
90
|
```ts
|
|
85
91
|
const opened = await fs.open("large.log");
|
|
86
92
|
try {
|
|
@@ -103,7 +109,7 @@ type RootReadOptions = {
|
|
|
103
109
|
};
|
|
104
110
|
```
|
|
105
111
|
|
|
106
|
-
`maxBytes` is enforced eagerly: the library reads up to `maxBytes + 1` and throws `too-large` if there is more, so a hostile target cannot silently exhaust memory. Values must be non-negative safe integers or positive `Infinity`; zero is an active cap, while `Infinity` disables it. Explicitly forwarding `undefined` preserves the Root default.
|
|
112
|
+
For the byte-consuming read methods, `maxBytes` is enforced eagerly: the library reads up to `maxBytes + 1` and throws `too-large` if there is more, so a hostile target cannot silently exhaust memory. Values must be non-negative safe integers or positive `Infinity`; zero is an active cap, while `Infinity` disables it. Explicitly forwarding `undefined` preserves the Root default.
|
|
107
113
|
|
|
108
114
|
Safe reads always add the platform's nonblocking open flag where available so a raced FIFO cannot pin a worker indefinitely; regular-file descriptor reads retain normal Node behavior.
|
|
109
115
|
|
|
@@ -27,11 +27,11 @@ import {
|
|
|
27
27
|
|
|
28
28
|
## Constants
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
| Exported constant | Value |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `DEFAULT_SECRET_FILE_MAX_BYTES` | `16 * 1024` (16 KiB) |
|
|
33
|
+
| `PRIVATE_SECRET_DIR_MODE` | `0o700` |
|
|
34
|
+
| `PRIVATE_SECRET_FILE_MODE` | `0o600` |
|
|
35
35
|
|
|
36
36
|
The 16 KiB cap is intentionally aggressive — credentials should be small. If you need bigger, pass `maxBytes` explicitly.
|
|
37
37
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# File lock
|
|
2
2
|
|
|
3
|
+
For [Linux kernel write leases](platform-capabilities.md#linux-write-leases), `FileWriteLease.isHeld() === false` means “do not act on the file,” including while the kernel is still processing a lease break. The caller’s `SIGIO` handler still owns break notification.
|
|
4
|
+
|
|
3
5
|
`acquireFileLock()` and `withFileLock()` provide a cross-process file lock with retry and process-exit cleanup. The lock is implemented as a sidecar file (e.g. `state.json` ↔ `state.json.lock`) — only one acquirer can create the sidecar with `O_CREAT | O_EXCL` at a time.
|
|
4
6
|
|
|
5
7
|
On Windows, both the target and an explicitly supplied `lockPath` reject NTFS
|
|
@@ -72,21 +74,29 @@ The raw sidecar bytes are not a canonical JSON representation: tools that trim o
|
|
|
72
74
|
## API
|
|
73
75
|
|
|
74
76
|
```ts
|
|
75
|
-
|
|
77
|
+
import type {
|
|
78
|
+
FileLockAcquireOptions,
|
|
79
|
+
FileLockHandle,
|
|
80
|
+
FileLockManager,
|
|
81
|
+
FileLockSyncAcquireOptions,
|
|
82
|
+
FileLockSyncHandle,
|
|
83
|
+
} from "@openclaw/fs-safe/file-lock";
|
|
84
|
+
|
|
85
|
+
declare function acquireFileLock<TPayload extends Record<string, unknown>>(
|
|
76
86
|
targetPath: string,
|
|
77
87
|
options: FileLockAcquireOptions<TPayload>,
|
|
78
88
|
): Promise<FileLockHandle>;
|
|
79
89
|
|
|
80
|
-
function withFileLock<T, TPayload
|
|
90
|
+
declare function withFileLock<T, TPayload extends Record<string, unknown>>(
|
|
81
91
|
targetPath: string,
|
|
82
92
|
options: FileLockAcquireOptions<TPayload>,
|
|
83
93
|
fn: () => Promise<T>,
|
|
84
94
|
): Promise<T>;
|
|
85
95
|
|
|
86
|
-
function createFileLockManager(key: string): FileLockManager;
|
|
96
|
+
declare function createFileLockManager(key: string): FileLockManager;
|
|
87
97
|
|
|
88
|
-
function acquireFileLockSync<TPayload
|
|
89
|
-
function withFileLockSync<T, TPayload
|
|
98
|
+
declare function acquireFileLockSync<TPayload extends Record<string, unknown>>(targetPath: string, options: FileLockSyncAcquireOptions<TPayload>): FileLockSyncHandle;
|
|
99
|
+
declare function withFileLockSync<T, TPayload extends Record<string, unknown>>(targetPath: string, options: FileLockSyncAcquireOptions<TPayload>, fn: () => T): T;
|
|
90
100
|
```
|
|
91
101
|
|
|
92
102
|
`managerKey` is an optional identifier used to keep state isolated across multiple lock domains in the same process. Use distinct keys for distinct domains (`"snapshot"`, `"compact"`, `"build"`). If omitted, fs-safe derives one from the target path.
|
|
@@ -141,7 +151,7 @@ type FileLockAcquireOptions<TPayload extends Record<string, unknown>> = {
|
|
|
141
151
|
shouldReclaim?: (params: {
|
|
142
152
|
lockPath: string;
|
|
143
153
|
normalizedTargetPath: string;
|
|
144
|
-
payload:
|
|
154
|
+
payload: unknown;
|
|
145
155
|
staleMs: number;
|
|
146
156
|
nowMs: number;
|
|
147
157
|
heldByThisProcess: boolean;
|
|
@@ -150,7 +160,7 @@ type FileLockAcquireOptions<TPayload extends Record<string, unknown>> = {
|
|
|
150
160
|
lockPath: string;
|
|
151
161
|
normalizedTargetPath: string;
|
|
152
162
|
raw: string;
|
|
153
|
-
payload:
|
|
163
|
+
payload: unknown;
|
|
154
164
|
}) => boolean | Promise<boolean>;
|
|
155
165
|
metadata?: Record<string, unknown>; // attached to heldEntries() output for diagnostics
|
|
156
166
|
parsePayload?: (raw: string) => unknown;
|
|
@@ -542,24 +552,32 @@ holder still alive":
|
|
|
542
552
|
|
|
543
553
|
```ts
|
|
544
554
|
import { kill } from "node:process";
|
|
555
|
+
import { acquireFileLock } from "@openclaw/fs-safe/file-lock";
|
|
545
556
|
|
|
546
557
|
const handle = await acquireFileLock(targetPath, {
|
|
547
558
|
staleMs: 60_000,
|
|
548
559
|
payload: () => ({ pid: process.pid }),
|
|
549
|
-
shouldReclaim: ({ payload
|
|
550
|
-
if (!payload) return true;
|
|
551
|
-
const pid =
|
|
552
|
-
if (!Number.
|
|
560
|
+
shouldReclaim: ({ payload }) => {
|
|
561
|
+
if (!payload || typeof payload !== "object" || !("pid" in payload)) return true;
|
|
562
|
+
const pid = payload.pid;
|
|
563
|
+
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0) return true;
|
|
553
564
|
try {
|
|
554
565
|
kill(pid, 0);
|
|
555
566
|
return false; // process still alive — keep waiting
|
|
556
|
-
} catch {
|
|
557
|
-
return
|
|
567
|
+
} catch (error) {
|
|
568
|
+
return error !== null && typeof error === "object" &&
|
|
569
|
+
"code" in error && error.code === "ESRCH"; // only a missing process is stale
|
|
558
570
|
}
|
|
559
571
|
},
|
|
560
572
|
});
|
|
561
573
|
```
|
|
562
574
|
|
|
575
|
+
The observed payload is `unknown`, even when this caller writes a typed payload.
|
|
576
|
+
Validate it before reading fields. Permission failures such as `EPERM` do not
|
|
577
|
+
prove that the holder exited. PID checks assume a shared local PID namespace;
|
|
578
|
+
PID reuse can keep a stale lock waiting. This callback classifies staleness,
|
|
579
|
+
not ownership or permission to remove another holder's lock.
|
|
580
|
+
|
|
563
581
|
`heldByThisProcess` is true when this manager already holds the lock. A `true` result marks the observed sidecar as stale; `staleRecovery` then decides whether acquisition fails closed or attempts caller-approved removal.
|
|
564
582
|
|
|
565
583
|
## Stale recovery: guarded `remove-if-unchanged`
|
|
@@ -84,6 +84,17 @@ Batch loading skips invalid entry names, malformed, oversized, or unreadable ent
|
|
|
84
84
|
|
|
85
85
|
Failed destinations are create-only. Quarantine publishes the claimed file by hardlink, so the queue and failed directories must share a filesystem with hardlink support. If `failed/<id>.json` already exists, quarantine rejects while preserving both that earlier evidence and the current claimed entry instead of overwriting either file. The `read` callback continues to receive the logical `.json` path even though bytes are read and migrations are written through the claimed path.
|
|
86
86
|
|
|
87
|
+
Claim, quarantine, and retirement recovery require hardlinks. If a link syscall
|
|
88
|
+
is refused with `EACCES`, `EPERM`, `EXDEV`, `ENOTSUP`, `EOPNOTSUPP`, or `ENOSYS`,
|
|
89
|
+
the operation rejects with `FsSafeError("helper-unavailable")` and retains the
|
|
90
|
+
original error in `cause`. This includes Android/Termux environments that deny
|
|
91
|
+
hardlinks. The refusal leaves the pending entry, processing claim, or retirement
|
|
92
|
+
record intact for retry after the capability or permission problem is resolved;
|
|
93
|
+
it does not acknowledge delivery. Batch loading propagates this capability
|
|
94
|
+
failure too. The queue does not fall back to copying or overwriting rename:
|
|
95
|
+
those operations cannot preserve its shared-inode recovery and create-only
|
|
96
|
+
collision evidence. Enqueue alone does not prove that an entry can be claimed.
|
|
97
|
+
|
|
87
98
|
Migrations stay bound to the exact processing file opened for that load. The
|
|
88
99
|
read descriptor remains pinned while the callback runs outside the transfer
|
|
89
100
|
lock; after the callback returns, migration reacquires the lock and rechecks the
|