@jc_stack/ez-library 0.1.0-beta.23 → 0.1.0-beta.24

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0-beta.24
4
+
5
+ - `put --from-file ABSOLUTE_PATH` writes a file above the host's 1 MiB stdin cap: the service now declares `workspace: true` (read-only agent workspace) and the plugin streams the file from there. The path must be absolute and resolve to a regular file inside the workspace root named by `EZ_AGENT_WORKSPACE`; a relative or outside path, a directory, an unreadable file, a symlink leaving the workspace, or a host that does not set the variable fail with exit 2 before anything is written. The file is the only source and stdin is ignored (never read). The check applies to the open handle: the kernel's path for it (`/proc/self/fd/N`) must be a regular file inside the workspace, so a directory swapped for a symlink meanwhile is refused; where `/proc/self/fd` does not exist (not Linux) the flag is refused and stdin remains. `--expected`, `--key`, the writer lock, the receipt and the 512 MiB limit are unchanged. Reads of large files use `get --offset/--length`; the 1 MiB limit applies to stdin and command output. Requires a core that sets `EZ_AGENT_WORKSPACE` (jdorado/ez-agents#390); the service now mounts the workspace, so installing needs the manager's normal activation. Closes #58.
6
+
3
7
  ## 0.1.0-beta.23
4
8
 
5
9
  - `put` and `replace` that wait out the writer lock (60 seconds, including a running sync) now fail `BUSY` as JSON on stdout with `written: false` and, while a live writer or sync holds the lock, `retryAfterSeconds`, exit 3. Nothing was written and the same `--key` can be retried. Other commands keep errors on stderr.
package/README.md CHANGED
@@ -68,7 +68,7 @@ ez library qmd search 'passport' -c library --json -n 5
68
68
  ez library qmd get qmd://library/notes/travel.md
69
69
  ```
70
70
 
71
- `get` returns the content hash and size; `get --raw` emits exact bytes, including binary attachments. Files enter on stdin, so the plugin does not mount the agent workspace or infer host file access. Readback proves local storage only. Each agent's registry provides a separate data volume; never share it across identities merely to share search.
71
+ `get` returns the content hash and size; `get --raw` emits exact bytes, including binary attachments. Files enter on stdin, or, above the host's 1 MiB stdin cap, by `put --from-file ABSOLUTE_PATH`: the service mounts the agent workspace read-only (`workspace: true`) and the plugin reads the file there, only inside the workspace root the host names in `EZ_AGENT_WORKSPACE`. Readback proves local storage only. Each agent's registry provides a separate data volume; never share it across identities merely to share search.
72
72
 
73
73
  For files larger than the executor's output allowance, first read metadata,
74
74
  then use `get --path RELATIVE --offset 0 --length 524288 --expected SHA256`.
@@ -145,7 +145,7 @@ When the owner asks to enable Drive backup and sync, the onboarded agent copies
145
145
 
146
146
  Intake stages a private hidden temporary file beside its destination and atomically renames it under the Library writer lock, including when `/state/files` is a separate mount. No storage migration is needed.
147
147
 
148
- Maximum intake is 512 MiB per file; the plugin applies no smaller limit to `put`. A caller that reaches the plugin through a transport with its own stdin or output cap (Ez's plugin broker caps stdin and stdout at 1 MiB per call) is bounded by that cap, not by this plugin. Hidden paths, traversal, symlinks and special files are unsupported. `move --path SOURCE --to DEST --expected HASH --key KEY` and `remove --path SOURCE --expected HASH --key KEY` preserve recovery bytes and reject stale revisions. Their operation receipts live in the plugin volume, so child tasks do not need to edit a parent workspace manifest. `list --prefix notes/ --limit 100` is bounded and reports truncation; it is not a full backup manifest. All local commands emit JSON except `get --raw`; errors use stderr, except `BUSY` from `put` and `replace`, which is JSON on stdout (below). `CONFLICT` stays on stderr with the same exit code 3, so a caller that sees exit 3 reads stdout for `BUSY` and stderr for `CONFLICT`. Exit codes: 2 invalid input, 3 conflict/busy, 4 unavailable/uncertain. QMD preserves its native codes.
148
+ Maximum intake is 512 MiB per file; the plugin applies no smaller limit to `put`. Ez's plugin broker caps stdin and command output at 1 MiB each per call, so stdin carries at most 1 MiB. Write a larger file with `put --path RELATIVE --expected new --key KEY --from-file /absolute/workspace/path` (the file is the only source and stdin is ignored; everything else about `put` is unchanged), and read it back with `get --offset/--length`. A `--from-file` path must be absolute, resolve to a regular file inside the workspace root (symlinks that leave it are refused) and the host must provide `EZ_AGENT_WORKSPACE`; otherwise the call fails before anything is written. An installer must declare the service's workspace mount, which core applies on install. Hidden paths, traversal, symlinks and special files are unsupported. `move --path SOURCE --to DEST --expected HASH --key KEY` and `remove --path SOURCE --expected HASH --key KEY` preserve recovery bytes and reject stale revisions. Their operation receipts live in the plugin volume, so child tasks do not need to edit a parent workspace manifest. `list --prefix notes/ --limit 100` is bounded and reports truncation; it is not a full backup manifest. All local commands emit JSON except `get --raw`; errors use stderr, except `BUSY` from `put` and `replace`, which is JSON on stdout (below). `CONFLICT` stays on stderr with the same exit code 3, so a caller that sees exit 3 reads stdout for `BUSY` and stderr for `CONFLICT`. Exit codes: 2 invalid input, 3 conflict/busy, 4 unavailable/uncertain. QMD preserves its native codes.
149
149
 
150
150
  ## State, lifecycle and limits
151
151
 
@@ -6,6 +6,7 @@
6
6
  "volumes": {
7
7
  "data": "/state"
8
8
  },
9
+ "workspace": true,
9
10
  "healthcheck": [
10
11
  "node",
11
12
  "/app/bin/ez-library.mjs",
package/ez-plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "id": "library",
4
- "version": "0.1.0-beta.23",
4
+ "version": "0.1.0-beta.24",
5
5
  "description": "Dockerized agent library files, QMD retrieval and explicit persistence settings",
6
6
  "example": "library search 'quarterly budget' --all --limit 5",
7
7
  "commands": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jc_stack/ez-library",
3
- "version": "0.1.0-beta.23",
3
+ "version": "0.1.0-beta.24",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "tag": "latest"
@@ -17,6 +17,8 @@ for(const [alias,command] of Object.entries(manifest.commands||{})) {
17
17
  }
18
18
  assert.deepEqual(manifest.commands.library?.exposure,expectedExposure,'library exposure must conservatively describe its broad read/write/sync surface');
19
19
  for(const alias of ['library-file','library-query']) assert.deepEqual(manifest.commands[alias]?.exposure,readOnlyExposure,`${alias} must remain read-only`);
20
+ const deployment=JSON.parse(readFileSync('ez-deployment.json','utf8'));
21
+ assert.equal(deployment.services.library?.workspace,true,'The library service must mount the agent workspace read-only for put --from-file');
20
22
  const [pack]=JSON.parse(execFileSync('npm',['pack','--dry-run','--ignore-scripts','--json'],{encoding:'utf8'}));
21
23
  const names=pack.files.map(f=>f.path);
22
24
  for(const required of ['LICENSE','README.md','SECURITY.md','CONTRIBUTING.md','CHANGELOG.md','THIRD_PARTY_NOTICES.md','Dockerfile','.dockerignore','docker/pnpm-lock.yaml']) assert(names.includes(required),`Missing ${required}`);
@@ -51,7 +51,7 @@ Refresh the appropriate QMD collection after saving derived text (`qmd update`);
51
51
 
52
52
  ## Onboarding and retrieval
53
53
 
54
- Choose the smallest authorized collection. Input files enter through stdin (`put --path notes/example.md --expected new --key stable-key < source.md`); no host workspace is mounted. Use `get --path ...` for current hashes and `get --raw` for exact bytes. Choose operation keys per logical write and retain them until its outcome is known. Updates require the latest hash; a conflict means re-read and reconsider the update, not force overwrite. `operation --key ...` reconciles current bytes after interruption; on a Git-bound Library it also says whether the remote has the write (`git.state` `pushed` with `git.commit`, or `pending` until the next sync). A `put` or `replace` that waited 60 seconds for the writer lock fails with JSON on stdout (`BUSY`, `written: false`, and `retryAfterSeconds` while a live writer or sync holds the lock); nothing was written and the same key can be retried.
54
+ Choose the smallest authorized collection. Input files enter through stdin (`put --path notes/example.md --expected new --key stable-key < source.md`) up to the host's 1 MiB stdin cap. For a larger file, give its absolute path in the read-only agent workspace: `put --path big/example.pdf --expected new --key stable-key --from-file /absolute/workspace/example.pdf` (the file is the only source and stdin is ignored; refused before any write if the path is relative, outside the workspace, not a regular file, or the host does not provide the workspace root). Read large files back with `get --offset/--length`; stdin and command output are both capped at 1 MiB. Use `get --path ...` for current hashes and `get --raw` for exact bytes. Choose operation keys per logical write and retain them until its outcome is known. Updates require the latest hash; a conflict means re-read and reconsider the update, not force overwrite. `operation --key ...` reconciles current bytes after interruption; on a Git-bound Library it also says whether the remote has the write (`git.state` `pushed` with `git.commit`, or `pending` until the next sync). A `put` or `replace` that waited 60 seconds for the writer lock fails with JSON on stdout (`BUSY`, `written: false`, and `retryAfterSeconds` while a live writer or sync holds the lock); nothing was written and the same key can be retried.
55
55
 
56
56
  If exact raw output exceeds the executor allowance, read metadata, then call
57
57
  `get --path ... --offset 0 --length 524288 --expected SHA256`. Each response
package/src/cli.mjs CHANGED
@@ -31,6 +31,11 @@ Local library files, QMD retrieval, and persistence settings.
31
31
  settings Show settings and revision hash
32
32
  configure --expected HASH|new --key KEY < settings.json
33
33
  put --path RELATIVE --expected HASH|new --key KEY < file
34
+ put --path RELATIVE --expected HASH|new --key KEY --from-file ABSOLUTE_WORKSPACE_PATH
35
+ Same write from a file in the agent workspace (read-only mount),
36
+ for files above the host's 1 MiB stdin cap. The file is the only
37
+ source; stdin is ignored. A relative or outside path, a directory
38
+ or a symlink out of the workspace is refused before any write
34
39
  Waits up to 60 s for the writer lock (or a running sync).
35
40
  BUSY: JSON on stdout, written:false (retryAfterSeconds while a live writer holds it); the same --key may be retried
36
41
  replace --path RELATIVE --key KEY < replacement.json
@@ -62,7 +67,8 @@ Local library files, QMD retrieval, and persistence settings.
62
67
  git ... Native Git in the bound Library working tree
63
68
 
64
69
  Local commands emit JSON (--json is also accepted); get --raw and qmd preserve
65
- native output. Files are limited to 512 MiB. Existing files require their current
70
+ native output. Files are limited to 512 MiB. The host caps stdin and command output
71
+ at 1 MiB each: write larger files with put --from-file; read them with get --offset/--length. Existing files require their current
66
72
  SHA-256. Stable operation keys cannot be reused for different writes.
67
73
  State: EZ_LIBRARY_STATE (absolute), default /state. Production uses the agent's
68
74
  registered Docker plugin. Credentials belong to provider tools, never settings.
@@ -102,6 +108,39 @@ async function readSettingsInput() {
102
108
  catch { fail('INVALID', 'Settings must be valid JSON'); }
103
109
  return validateSettings(parsed);
104
110
  }
111
+ // A file larger than the host's 1 MiB stdin cap arrives by its path in the read-only workspace mount.
112
+ // Core names that workspace in EZ_AGENT_WORKSPACE; the root is never guessed. Stdin is not read.
113
+ // The check applies to the open handle, not to a name: after the open the kernel's own path for that
114
+ // descriptor (/proc/self/fd/N) must be a regular file inside the workspace, so no later rename or symlink
115
+ // swap can change the answer. The runtime is a Linux container; without /proc/self/fd the flag is refused.
116
+ // `hooks` lets a test change the tree between the steps or move the probe; the CLI passes none.
117
+ const inside = (root, file) => file.startsWith(root + path.sep);
118
+ async function workspaceFile(from, hooks = {}) {
119
+ const workspace = process.env.EZ_AGENT_WORKSPACE, procFd = hooks.procFd ?? '/proc/self/fd';
120
+ if (!workspace) fail('INVALID', '--from-file needs the host to provide the workspace root (EZ_AGENT_WORKSPACE), which this host does not; send the file on stdin (at most 1 MiB through the host) or upgrade the host');
121
+ if (!path.isAbsolute(from)) fail('INVALID', '--from-file must be an absolute path inside the workspace');
122
+ if (!await fs.stat(procFd).then(stat => stat.isDirectory(), () => false)) fail('INVALID', '--from-file needs /proc/self/fd, which exists only on Linux (the plugin runs in a Linux container); send the file on stdin instead');
123
+ const unreadable = () => fail('INVALID', '--from-file cannot be read inside the workspace');
124
+ let root, real;
125
+ try { root = await fs.realpath(workspace); real = await fs.realpath(from); } catch { unreadable(); }
126
+ if (!inside(root, real)) fail('UNSAFE_PATH', '--from-file must stay inside the workspace');
127
+ await hooks.beforeOpen?.();
128
+ let handle;
129
+ try { handle = await fs.open(real, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK); } catch { unreadable(); }
130
+ try {
131
+ await hooks.afterOpen?.();
132
+ let opened;
133
+ try { opened = await fs.realpath(`${procFd}/${handle.fd}`); } catch { unreadable(); }
134
+ if (!inside(root, opened)) fail('UNSAFE_PATH', '--from-file must stay inside the workspace');
135
+ if (!(await handle.stat()).isFile()) fail('UNSAFE_PATH', '--from-file must be a regular file');
136
+ return handle;
137
+ } catch (error) { await handle.close(); throw error; }
138
+ }
139
+ export async function putFromFile(root, relative, from, options, hooks) {
140
+ const source = await workspaceFile(from, hooks);
141
+ try { return await put(root, relative, source.createReadStream({ autoClose: false }), options); }
142
+ finally { await source.close(); }
143
+ }
105
144
  export async function main(argv = process.argv.slice(2)) {
106
145
  const command = argv[0];
107
146
  try {
@@ -182,7 +221,7 @@ export async function main(argv = process.argv.slice(2)) {
182
221
  return (await rclone(root, rest, { inherit: true })).code;
183
222
  }); return;
184
223
  }
185
- const allowed = { doctor: [], settings: [], configure: ['expected', 'key'], put: ['path', 'expected', 'key'], replace: ['path', 'key'],
224
+ const allowed = { doctor: [], settings: [], configure: ['expected', 'key'], put: ['path', 'expected', 'key', 'from-file'], replace: ['path', 'key'],
186
225
  get: ['path', 'raw', 'offset', 'length', 'expected'], 'pdf-text': ['path'], list: ['prefix', 'limit'], operation: ['key'],
187
226
  'sync-plan': ['remote'], 'sync-adopt': ['remote'], 'sync-status': [], 'sync-run': [],
188
227
  move: ['path', 'to', 'expected', 'key'], remove: ['path', 'expected', 'key'], gzip: ['path', 'to', 'expected', 'key'],
@@ -211,7 +250,8 @@ export async function main(argv = process.argv.slice(2)) {
211
250
  }
212
251
  if (command === 'put') {
213
252
  if (!opts.path) fail('INVALID', 'Supply --path');
214
- emit(await put(root, opts.path, process.stdin, { key: opts.key, expected: opts.expected })); return;
253
+ if (opts['from-file'] === undefined) { emit(await put(root, opts.path, process.stdin, { key: opts.key, expected: opts.expected })); return; }
254
+ emit(await putFromFile(root, opts.path, opts['from-file'], { key: opts.key, expected: opts.expected })); return;
215
255
  }
216
256
  if (command === 'gzip') { emit(await gzipFile(root, opts)); return; }
217
257
  if (command === 'replace') {
@@ -6,7 +6,9 @@ import { tmpdir } from 'node:os';
6
6
  import { Readable } from 'node:stream';
7
7
  import { spawnSync } from 'node:child_process';
8
8
  import { locked, put, operation, settings, defaults, validateSettings, list, digest, readRange, MAX_READ_BYTES, hash } from '../src/store.mjs';
9
- import { qmdEnvironment } from '../src/cli.mjs';
9
+ import { qmdEnvironment, putFromFile } from '../src/cli.mjs';
10
+ import { spawn } from 'node:child_process';
11
+ import { existsSync } from 'node:fs';
10
12
 
11
13
  const cli = new URL('../bin/ez-library.mjs', import.meta.url).pathname;
12
14
  async function fixture(t) {
@@ -326,3 +328,77 @@ test('put and replace that cannot get the writer lock say so as JSON on stdout,
326
328
  const retried = run(root, ['put', '--path', 'a.md', '--expected', 'new', '--key', 'busy:1'], 'data');
327
329
  assert.equal(retried.status, 0, retried.stderr); assert.equal(JSON.parse(retried.stdout).data.state, 'stored');
328
330
  });
331
+
332
+ const linux = existsSync('/proc/self/fd') ? {} : { skip: '--from-file needs /proc/self/fd (Linux); the plugin runs in a Linux container' };
333
+ test('put --from-file streams a workspace file above 1 MiB and refuses unsafe sources before writing', linux, async t => {
334
+ const root = await fixture(t), workspace = await fs.realpath(await fixture(t)), outside = await fs.realpath(await fixture(t));
335
+ const env = { ...process.env, EZ_LIBRARY_STATE: root, EZ_AGENT_WORKSPACE: workspace };
336
+ const invoke = (args, { stdin, environment = env } = {}) => spawnSync(process.execPath, [cli, 'put', '--expected', 'new', ...args], { input: stdin, env: environment, encoding: 'utf8' });
337
+ const data = Buffer.alloc(3 * 1024 * 1024 + 11); for (let i = 0; i < data.length; i++) data[i] = (i * 31) % 251;
338
+ const big = path.join(workspace, 'big.bin'); await fs.writeFile(big, data);
339
+ const ok = invoke(['--path', 'big/a.bin', '--key', 'ff:1', '--from-file', big]);
340
+ assert.equal(ok.status, 0, ok.stderr); const receipt = JSON.parse(ok.stdout).data;
341
+ assert.equal(receipt.state, 'stored'); assert.equal(receipt.bytes, data.length); assert.equal(receipt.sha256, hash(data));
342
+ assert.deepEqual(await fs.readFile(path.join(root, 'files/big/a.bin')), data);
343
+ assert.equal((await digest(path.join(root, 'files/big/a.bin'))).sha256, hash(data));
344
+ const link = path.join(workspace, 'leaves'); await fs.symlink(outside, link);
345
+ await fs.writeFile(path.join(outside, 'secret'), 'x'); await fs.symlink(path.join(outside, 'secret'), path.join(workspace, 'out-link'));
346
+ await fs.mkdir(path.join(workspace, 'dir')); await fs.writeFile(path.join(workspace, 'locked'), 'x'); await fs.chmod(path.join(workspace, 'locked'), 0);
347
+ const refusals = {
348
+ relative: [['--from-file', 'big.bin']], outside: [['--from-file', path.join(outside, 'secret')]],
349
+ directory: [['--from-file', path.join(workspace, 'dir')]], 'symlink out': [['--from-file', path.join(workspace, 'out-link')]],
350
+ 'dir symlink out': [['--from-file', path.join(link, 'secret')]], missing: [['--from-file', path.join(workspace, 'absent')]],
351
+ unset: [['--from-file', big], { environment: { ...env, EZ_AGENT_WORKSPACE: '' } }],
352
+ ...(process.getuid?.() === 0 ? {} : { unreadable: [['--from-file', path.join(workspace, 'locked')]] }),
353
+ };
354
+ let n = 0;
355
+ for (const [name, [flag, options]] of Object.entries(refusals)) {
356
+ const r = invoke(['--path', `refused/${n}.bin`, '--key', `ff:r${n++}`, ...flag], options);
357
+ assert.equal(r.status, 2, `${name}: ${r.stdout}${r.stderr}`); assert.equal(JSON.parse(r.stderr).ok, false, name);
358
+ }
359
+ assert.deepEqual(await fs.readdir(path.join(root, 'files')), ['big']);
360
+ assert.match(invoke(['--path', 'x', '--key', 'ff:u', '--from-file', big], { environment: { ...env, EZ_AGENT_WORKSPACE: '' } }).stderr, /stdin/);
361
+ const viaStdin = invoke(['--path', 'small.txt', '--key', 'ff:s'], { stdin: 'hello' });
362
+ assert.equal(viaStdin.status, 0, viaStdin.stderr); assert.equal(JSON.parse(viaStdin.stdout).data.sha256, hash('hello'));
363
+ });
364
+
365
+ test('put --from-file does not read stdin and returns with an open, silent pipe', linux, async t => {
366
+ const root = await fixture(t), workspace = await fs.realpath(await fixture(t));
367
+ await fs.writeFile(path.join(workspace, 'f.txt'), 'abc');
368
+ const child = spawn(process.execPath, [cli, 'put', '--path', 'f.txt', '--expected', 'new', '--key', 'ff:p', '--from-file', path.join(workspace, 'f.txt')],
369
+ { env: { ...process.env, EZ_LIBRARY_STATE: root, EZ_AGENT_WORKSPACE: workspace }, stdio: ['pipe', 'pipe', 'pipe'] });
370
+ const timer = setTimeout(() => child.kill('SIGKILL'), 20000); let out = '';
371
+ child.stdout.on('data', d => { out += d; });
372
+ const status = await new Promise(resolve => child.on('exit', resolve)); clearTimeout(timer);
373
+ assert.equal(status, 0); assert.equal(JSON.parse(out).data.sha256, hash('abc'));
374
+ });
375
+
376
+ test('put --from-file refuses a path whose directory is swapped around the open, and stores nothing', linux, async t => {
377
+ const root = await fixture(t), workspace = await fs.realpath(await fixture(t)), outside = await fs.realpath(await fixture(t));
378
+ process.env.EZ_AGENT_WORKSPACE = workspace; t.after(() => { delete process.env.EZ_AGENT_WORKSPACE; });
379
+ await fs.mkdir(path.join(workspace, 'd')); await fs.mkdir(path.join(outside, 'd'));
380
+ const inner = path.join(workspace, 'd', 'f'); await fs.writeFile(inner, 'inside'); await fs.writeFile(path.join(outside, 'd', 'f'), 'secret');
381
+ const away = path.join(workspace, 'd.orig'), dir = path.join(workspace, 'd');
382
+ const swap = () => fs.rename(dir, away).then(() => fs.symlink(path.join(outside, 'd'), dir));
383
+ const revert = () => fs.rm(dir).then(() => fs.rename(away, dir));
384
+ const options = n => ({ key: `race:${n}`, expected: 'new' });
385
+ const into = () => fs.rm(dir).then(() => fs.mkdir(dir)).then(() => fs.writeFile(inner, 'inside'));
386
+ await assert.rejects(putFromFile(root, 'a', inner, options(1), { beforeOpen: swap }), code('UNSAFE_PATH'));
387
+ await revert();
388
+ await assert.rejects(putFromFile(root, 'b', inner, options(2), { beforeOpen: swap, afterOpen: revert }), code('UNSAFE_PATH'));
389
+ // symlink at the open, then a real directory (and again a symlink if the path were read by name once more)
390
+ await assert.rejects(putFromFile(root, 'd', inner, options(4), { beforeOpen: swap, afterOpen: into }), code('UNSAFE_PATH'));
391
+ await fs.rm(dir, { recursive: true, force: true }); await fs.rename(away, dir).catch(() => {});
392
+ assert.equal((await fs.stat(dir)).isDirectory() && !(await fs.lstat(dir)).isSymbolicLink(), true);
393
+ assert.deepEqual(await fs.readdir(path.join(root, 'files')).catch(() => []), []);
394
+ assert.equal((await putFromFile(root, 'c', inner, options(3))).sha256, hash('inside'));
395
+ });
396
+
397
+ test('put --from-file refuses cleanly where /proc/self/fd is absent', async t => {
398
+ const root = await fixture(t), workspace = await fs.realpath(await fixture(t));
399
+ process.env.EZ_AGENT_WORKSPACE = workspace; t.after(() => { delete process.env.EZ_AGENT_WORKSPACE; });
400
+ await fs.writeFile(path.join(workspace, 'f'), 'x');
401
+ await assert.rejects(putFromFile(root, 'f', path.join(workspace, 'f'), { key: 'np:1', expected: 'new' }, { procFd: path.join(workspace, 'no-proc') }),
402
+ error => error.code === 'INVALID' && /Linux/.test(error.message));
403
+ assert.deepEqual(await fs.readdir(path.join(root, 'files')).catch(() => []), []);
404
+ });