@feigi/fleet-ctl 3.110.0 → 3.110.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.
@@ -13,8 +13,8 @@ against your `bash` cwd, which they share no `cwd` parameter with. Give them
13
13
  the absolute worktree path on every call, mutation-probe copies included.**
14
14
  The main checkout is the parent of `git rev-parse --path-format=absolute
15
15
  --git-common-dir`. A `member-write-guard` refusal means the path hit the
16
- main checkout — for `bash`, a missing or main-checkout `cwd` — so re-issue
17
- it absolute, under your worktree.
16
+ main checkout or the Install root — for `bash`, a missing or main-checkout
17
+ `cwd` — so re-issue it absolute, under your worktree.
18
18
 
19
19
  **Every factual claim your diff restates needs a settling command run
20
20
  against the tree first** — the issue body is a lead, never a citation.
@@ -27,9 +27,9 @@ substitutes it for you.
27
27
  So: prefix every `edit` and `read` path with an absolute path — the
28
28
  worktree `<abs-path>` for repo files, `<scratch>/impl-<N>/` for scratch —
29
29
  never a bare relative one, and never `plugin/scripts/foo.mjs` on its own.
30
- A `member-write-guard` refusal means the path hit the main checkout — for
31
- `bash`, a missing or main-checkout `cwd` — so re-issue it absolute, under
32
- your worktree.
30
+ A `member-write-guard` refusal means the path hit the main checkout or the
31
+ Install root — for `bash`, a missing or main-checkout `cwd` — so re-issue it
32
+ absolute, under your worktree.
33
33
 
34
34
  Here is the ticket's distilled brief, already read once at the Pull —
35
35
  title, plus whichever of the `## Agent Brief` comment or the issue body
@@ -27,9 +27,9 @@ substitutes it for you.
27
27
  So: prefix every `edit` and `read` path with an absolute path — the
28
28
  worktree `<abs-path>` for repo files, `<scratch>/impl-<N>/` for scratch —
29
29
  never a bare relative one, and never `plugin/scripts/foo.mjs` on its own.
30
- A `member-write-guard` refusal means the path hit the main checkout — for
31
- `bash`, a missing or main-checkout `cwd` — so re-issue it absolute, under
32
- your worktree.
30
+ A `member-write-guard` refusal means the path hit the main checkout or the
31
+ Install root — for `bash`, a missing or main-checkout `cwd` — so re-issue it
32
+ absolute, under your worktree.
33
33
 
34
34
  Here is the ticket's distilled brief, already read once at the Pull —
35
35
  title, plus whichever of the `## Agent Brief` comment or the issue body
@@ -27,9 +27,9 @@ substitutes it for you.
27
27
  So: prefix every `edit` and `read` path with an absolute path — the
28
28
  worktree `<abs-path>` for repo files, `<scratch>/impl-<N>/` for scratch —
29
29
  never a bare relative one, and never `plugin/scripts/foo.mjs` on its own.
30
- A `member-write-guard` refusal means the path hit the main checkout — for
31
- `bash`, a missing or main-checkout `cwd` — so re-issue it absolute, under
32
- your worktree.
30
+ A `member-write-guard` refusal means the path hit the main checkout or the
31
+ Install root — for `bash`, a missing or main-checkout `cwd` — so re-issue it
32
+ absolute, under your worktree.
33
33
 
34
34
  Here is the ticket's distilled brief, already read once at the Pull —
35
35
  title, plus whichever of the `## Agent Brief` comment or the issue body
@@ -27,9 +27,9 @@ substitutes it for you.
27
27
  So: prefix every `edit` and `read` path with an absolute path — the
28
28
  worktree `<abs-path>` for repo files, `<scratch>/impl-<N>/` for scratch —
29
29
  never a bare relative one, and never `plugin/scripts/foo.mjs` on its own.
30
- A `member-write-guard` refusal means the path hit the main checkout — for
31
- `bash`, a missing or main-checkout `cwd` — so re-issue it absolute, under
32
- your worktree.
30
+ A `member-write-guard` refusal means the path hit the main checkout or the
31
+ Install root — for `bash`, a missing or main-checkout `cwd` — so re-issue it
32
+ absolute, under your worktree.
33
33
 
34
34
  Here is the ticket's distilled brief, already read once at the Pull —
35
35
  title, plus whichever of the `## Agent Brief` comment or the issue body
@@ -27,9 +27,9 @@ substitutes it for you.
27
27
  So: prefix every `edit` and `read` path with an absolute path — the
28
28
  worktree `<abs-path>` for repo files, `<scratch>/impl-<N>/` for scratch —
29
29
  never a bare relative one, and never `plugin/scripts/foo.mjs` on its own.
30
- A `member-write-guard` refusal means the path hit the main checkout — for
31
- `bash`, a missing or main-checkout `cwd` — so re-issue it absolute, under
32
- your worktree.
30
+ A `member-write-guard` refusal means the path hit the main checkout or the
31
+ Install root — for `bash`, a missing or main-checkout `cwd` — so re-issue it
32
+ absolute, under your worktree.
33
33
 
34
34
  Here is the ticket's distilled brief, already read once at the Pull —
35
35
  title, plus whichever of the `## Agent Brief` comment or the issue body
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.110.0",
3
+ "version": "3.110.2",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -5,10 +5,9 @@
5
5
  # the Install root — the realpath of
6
6
  # `~/.omp/plugins/node_modules/@feigi/fleet-ctl`, the tree fleet-run executes
7
7
  # and omp loads the runbooks from — and every member can write to that tree.
8
- # member-write-guard.mjs refuses a `write`/`edit`/`ast_edit` inside the MAIN
9
- # checkout only, which is the Install root only when that checkout is linked;
10
- # a `bash` or `eval` write lands either way, and under a package install
11
- # nothing refuses any of them. Worktree isolation
8
+ # member-write-guard.mjs refuses a `write`/`edit`/`ast_edit` inside the Install
9
+ # root, whatever the install kind, but a `bash` or `eval` write lands there
10
+ # anyway and nothing refuses it. Worktree isolation
12
11
  # and `./agent-test` port derivation protect members from each other; neither
13
12
  # protects the tree the controller measures from. Measured: a member edited two
14
13
  # files in the main checkout instead of its worktree while the CI monitor was
@@ -39,7 +39,7 @@
39
39
  // cause instead (see `headMove`).
40
40
  //
41
41
  // THE PROTECTED SET is the non-ignored paths of the main checkout — what the
42
- // member-write-guard protects — and its HEAD. `.fleet/`, `.worktrees/` and
42
+ // member-write-guard protects there — and its HEAD. `.fleet/`, `.worktrees/` and
43
43
  // `.agent-brain/` are gitignored in a fleet repo, so run state, members'
44
44
  // worktrees and agent-brain's cache never appear in porcelain and never trip
45
45
  // this.
@@ -396,7 +396,7 @@ export function parseTsv(text) {
396
396
  });
397
397
  }
398
398
 
399
- import { writeFileSync, existsSync, renameSync } from "node:fs";
399
+ import { writeFileSync, existsSync, mkdirSync, renameSync } from "node:fs";
400
400
  import { isCLI } from "./is-cli.mjs";
401
401
  import { makeDie, isFlagLike } from "./arg.mjs";
402
402
 
@@ -499,6 +499,7 @@ if (isCLI(import.meta.url)) {
499
499
  // Write-then-rename: writeFileSync truncates before it writes, so an interrupt
500
500
  // over the committed corpus left a torn file that the NEXT scrape read, merged
501
501
  // and rewrote — losing every other session's rows for good.
502
+ mkdirSync(dirname(file), { recursive: true });
502
503
  writeFileSync(file + ".tmp", (header ? header + "\n" : "") + formatTsv(merged));
503
504
  renameSync(file + ".tmp", file);
504
505
  // Report the SCRAPE, not just the file. `merged.length` is the whole corpus,
@@ -26,7 +26,7 @@
26
26
  // A top-level (`kind: "main"`) session is never guarded: that is the
27
27
  // controller, whose own writes into its checkout are its job.
28
28
  //
29
- // TWO RULES.
29
+ // THREE RULES.
30
30
  // - Path writers (`write`, `edit`, `ast_edit`), for everyone guarded: refuse
31
31
  // when a target resolves inside the main checkout and `git check-ignore`
32
32
  // says it is not ignored. `.worktrees/`, `.fleet/` and `.agent-brain/` are
@@ -34,6 +34,14 @@
34
34
  // stay writable, and what is protected is exactly what the main
35
35
  // checkout's `git status` would show dirty (main-checkout.mjs watches the
36
36
  // same set, and the checkout's HEAD besides).
37
+ // - The Install root, for the same path writers and the same agents: refuse
38
+ // when a target resolves inside the live Install root — the realpath of
39
+ // `~/.omp/plugins/node_modules/@feigi/fleet-ctl`, the installed plugin
40
+ // fleet-run executes scripts from and omp loads the runbooks from — the
41
+ // root itself included. No gitignore exemption: nothing under it is a
42
+ // member's to write. It holds whichever repository the session runs in,
43
+ // or none, and for every install kind; under a linked checkout the
44
+ // Install root is that checkout's `plugin/`.
37
45
  // - `bash` cwd, for every `fleet-implementer-<cell>` (ledger-grammar.mjs's
38
46
  // `CELL_DEF`), and for a fix-applier's own id (`fix-pr-<n>`) directly,
39
47
  // since its definition, `fleet-fix-applier`, is no implementer cell and
@@ -45,17 +53,28 @@
45
53
  // `git worktree add` from there, and children follow ad-hoc briefs — so
46
54
  // none of them gets this rule.
47
55
  // Never a rewrite: a refusal names the resolved path and tells the member to
48
- // re-issue it absolute under its worktree. Relative READS and `eval` are not
49
- // guarded here; main-checkout.mjs's dirty detection covers `eval`.
56
+ // re-issue it absolute under its worktree — save one for an Install root that
57
+ // does not resolve, which no path the member picks clears, so it says the
58
+ // package entry needs repair instead. Relative READS and `eval` are not
59
+ // guarded here; main-checkout.mjs's dirty detection covers `eval`. A `bash` or
60
+ // `eval` write into the Install root lands, by design: the `bash` cwd rule is
61
+ // the main checkout's only, since members read from the Install root with a
62
+ // `cwd` there, and instruments.sh's re-check is what detects such a write.
50
63
  //
51
- // WHEN IT CANNOT DECIDE. A cwd outside any git repository is allowed — there
52
- // is no main checkout to protect. A git that fails while resolving the main
53
- // checkout or answering `check-ignore` BLOCKS, naming the failure: a guard
54
- // that fails open on "could not look" protects nothing. omp fails closed the
55
- // same way on a handler that throws or times out.
64
+ // WHEN IT CANNOT DECIDE. A cwd outside any git repository is allowed by the
65
+ // main-checkout rules — there is no main checkout to protect. No package entry
66
+ // at all turns the Install-root rule off. A git that fails while resolving
67
+ // the main checkout or answering `check-ignore`, a package entry that exists
68
+ // but does not resolve (a dangling link, any other lstat or realpath error),
69
+ // and a path-writer target that cannot be canonicalised (EACCES, ELOOP,
70
+ // ENOTDIR), BLOCK, naming the failure: a guard that fails open on "could not
71
+ // look" protects nothing. omp fails closed the same way on a handler that
72
+ // throws or times out.
56
73
  //
57
74
  // `decide()` is the whole policy and touches nothing: the handler resolves the
58
- // main checkout, then hands it and a `check-ignore` probe in. The main
75
+ // main checkout and, for a path writer, the Install root, then hands them and
76
+ // a `check-ignore` probe in. The Install root is resolved on every such call,
77
+ // so a relink or reinstall mid-run is followed. The main
59
78
  // checkout is the parent of `git rev-parse --git-common-dir` (git-env.mjs's
60
79
  // `mainCheckoutDirFromGitCommonDir`) — the work tree, which a symlinked `.git`
61
80
  // does not move, never git-env.mjs's store rule — and never `--show-toplevel`,
@@ -65,7 +84,7 @@
65
84
  // Zero deps: node builtins and sibling scripts only.
66
85
 
67
86
  import { spawn } from "node:child_process";
68
- import { realpathSync } from "node:fs";
87
+ import { lstatSync, realpathSync } from "node:fs";
69
88
  import { homedir } from "node:os";
70
89
  import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
71
90
  import { fileURLToPath } from "node:url";
@@ -78,6 +97,10 @@ const FIX_APPLIER_ID = /^fix-pr-\d+(-[a-z])?$/;
78
97
  const PATH_WRITERS = new Set(["write", "edit", "ast_edit"]);
79
98
  const GIT_TIMEOUT_MS = 10_000;
80
99
  const REISSUE = "Re-issue it with an absolute path under your worktree `.worktrees/<n>-<slug>/`.";
100
+ /** What a refusal for an unresolvable Install root says instead of REISSUE: no path the member picks clears it. */
101
+ const REPAIR = "No re-issue clears this, whatever path it names: the package entry needs repair (a relink or a reinstall), so report this refusal rather than retry it.";
102
+ /** omp's package entry for this plugin, under the home directory: its realpath is the Install root. */
103
+ const INSTALL_ENTRY = [".omp", "plugins", "node_modules", "@feigi", "fleet-ctl"];
81
104
 
82
105
  /** Whether `decide()` could refuse this call — the handler's cheap gate before it spends a git call. Never throws: it runs for every tool call in every session. */
83
106
  function applies(agent, toolName) {
@@ -131,10 +154,12 @@ function targets(toolName, input) {
131
154
  // A raw path as omp's own resolver reads it (path-utils.ts `expandPath`): a
132
155
  // stray `:` or `@` ahead of an absolute or `~` path is dropped, `file://` is a
133
156
  // path, `~` is home. Any other `scheme://` is an internal URL (`local://`,
134
- // `xd://`, `agent://`) and names no file in any checkout: null. An ast_edit
135
- // glob needs no cutting: its literal spelling lies inside or outside the main
136
- // checkout exactly as the directory it scans from does, and `check-ignore`
137
- // reads it as a plain pathname.
157
+ // `xd://`, `agent://`) and names no file in any checkout: null. For the
158
+ // main-checkout rule an ast_edit glob needs no cutting: its literal spelling
159
+ // lies inside the main checkout exactly when the directory it scans from
160
+ // does, and `check-ignore` reads it as a plain pathname. A scan from above a
161
+ // root reaches into it, though, so the Install-root rule also reads the
162
+ // directory an ast_edit scans from (`scanRoot`).
138
163
  function fsPath(raw, cwd) {
139
164
  let p = raw;
140
165
  if (/^:(?=[/\\~]|\.\.?[/\\])/.test(p)) p = p.slice(1);
@@ -150,28 +175,81 @@ function fsPath(raw, cwd) {
150
175
 
151
176
  const within = (root, p) => p === root || p.startsWith(root.endsWith(sep) ? root : root + sep);
152
177
 
178
+ /** The directory an ast_edit target scans from: its path up to the first segment holding a glob character, or the whole path when none does. */
179
+ function scanRoot(abs) {
180
+ const segs = abs.split(sep);
181
+ const i = segs.findIndex((s) => /[*?[\]{}]/.test(s));
182
+ return i === -1 ? abs : segs.slice(0, i).join(sep) || sep;
183
+ }
184
+
185
+ /** A refusal for a root `decide()` was handed as neither a usable path nor the "no root" null, ending with what the member is to do about it. */
186
+ function unusable(toolName, what, root, remedy = REISSUE) {
187
+ if (root instanceof Error) {
188
+ return { block: true, reason: `member-write-guard: refused ${toolName} — could not resolve ${what} (${root.message}), and a guard that cannot look does not let the call through. ${remedy}` };
189
+ }
190
+ if (typeof root !== "string" || root === "") {
191
+ return { block: true, reason: `member-write-guard: refused ${toolName} — ${what} resolved to an unusable value, and a guard that cannot look does not let the call through. ${remedy}` };
192
+ }
193
+ return undefined;
194
+ }
195
+
153
196
  /**
154
197
  * The policy: `undefined` to let the call run, `{block: true, reason}` to
155
198
  * refuse it. Pure — every effect is passed in:
156
199
  * - `mainRoot`: the main checkout's absolute path, `null` when `cwd` is in
157
- * no git repository (allow), or an `Error` when git could not say (block);
200
+ * no git repository (the main-checkout rule is off), or an `Error` when
201
+ * git could not say (block);
202
+ * - `installRoot`: the Install root's realpath, `null` when there is no
203
+ * package entry (the Install-root rule is off), or an `Error` naming the
204
+ * entry when it exists but does not resolve (block). Read for path
205
+ * writers only;
158
206
  * - `isIgnored(absPath)`: resolves true/false from `git check-ignore`, and
159
207
  * rejects when git fails (block);
160
- * - `canonical(absPath)`: the symlink-free spelling of a path that may not
161
- * exist yet, so `/var/…` and `/private/var/…` compare equal. Identity by
162
- * default; the handler passes the real one.
208
+ * - `canonical(absPath)`: the symlink-free, on-disk spelling of a path that
209
+ * may not exist yet, so `/var/…` and `/private/var/…` compare equal, and
210
+ * so do two letter cases of one path on a case-insensitive filesystem.
211
+ * Identity by default; the handler passes the real one. A target it
212
+ * throws on is refused, naming the error.
163
213
  * `cwd` is the session cwd relative paths resolve against, `path.resolve(cwd, p)`.
164
214
  */
165
- export async function decide({ toolName, input, cwd, agent, mainRoot, isIgnored, canonical = (p) => p }) {
215
+ export async function decide({ toolName, input, cwd, agent, mainRoot, installRoot = null, isIgnored, canonical = (p) => p }) {
166
216
  if (!applies(agent, toolName)) return undefined;
167
- if (mainRoot === null) return undefined;
168
- if (mainRoot instanceof Error) {
169
- return { block: true, reason: `member-write-guard: refused ${toolName} — could not resolve the main checkout from ${cwd} (${mainRoot.message}), and a guard that cannot look does not let the call through. ${REISSUE}` };
170
- }
171
- if (typeof mainRoot !== "string" || mainRoot === "") {
172
- return { block: true, reason: `member-write-guard: refused ${toolName} — the main checkout resolved to an unusable value, and a guard that cannot look does not let the call through. ${REISSUE}` };
217
+ let located;
218
+ // Each target: `at` its canonical spelling, and for an ast_edit `scan` the
219
+ // canonical directory it scans from; `error` when canonicalising threw.
220
+ const writes = () => (located ??= targets(toolName, input).flatMap((raw) => {
221
+ const abs = fsPath(raw, cwd);
222
+ if (abs === null) return [];
223
+ try {
224
+ return [{ raw, at: canonical(abs), scan: toolName === "ast_edit" ? canonical(scanRoot(abs)) : null }];
225
+ } catch (error) {
226
+ return [{ raw, at: abs, error }];
227
+ }
228
+ }));
229
+ const said = ({ raw, at }) => (isAbsolute(raw) ? at : `${at} ("${raw}" resolved against the session cwd ${cwd})`);
230
+ const unresolved = (t) => ({ block: true, reason: `member-write-guard: refused ${toolName} to ${said(t)} — could not resolve it (${t.error?.code ?? t.error?.message ?? t.error}), and a guard that cannot look does not let the call through. ${REISSUE}` });
231
+
232
+ // The Install root, for path writers: whatever repository the session runs
233
+ // in, or none, and with no gitignore exemption — nothing under it is a
234
+ // member's to write.
235
+ if (toolName !== "bash" && installRoot !== null) {
236
+ const cannot = unusable(toolName, "the Install root", installRoot, REPAIR);
237
+ if (cannot) return cannot;
238
+ for (const t of writes()) {
239
+ if (t.error) return unresolved(t);
240
+ if (within(installRoot, t.at)) {
241
+ return { block: true, reason: `member-write-guard: refused ${toolName} to ${said(t)} — it is inside the Install root ${installRoot}, the installed plugin the fleet executes, and nothing under it is a member's to write. ${REISSUE}` };
242
+ }
243
+ if (t.scan !== null && within(t.scan, installRoot)) {
244
+ return { block: true, reason: `member-write-guard: refused ${toolName} over ${said(t)} — it scans from ${t.scan}, which holds the Install root ${installRoot}, the installed plugin the fleet executes, and nothing under it is a member's to write. ${REISSUE}` };
245
+ }
246
+ }
173
247
  }
174
248
 
249
+ if (mainRoot === null) return undefined;
250
+ const cannot = unusable(toolName, mainRoot instanceof Error ? `the main checkout from ${cwd}` : "the main checkout", mainRoot);
251
+ if (cannot) return cannot;
252
+
175
253
  if (toolName === "bash") {
176
254
  const asked = typeof input?.cwd === "string" && input.cwd.trim() !== "" ? input.cwd : cwd;
177
255
  const at = canonical(fsPath(asked, cwd) ?? resolve(cwd, asked));
@@ -181,20 +259,17 @@ export async function decide({ toolName, input, cwd, agent, mainRoot, isIgnored,
181
259
  return undefined;
182
260
  }
183
261
 
184
- for (const raw of targets(toolName, input)) {
185
- const abs = fsPath(raw, cwd);
186
- if (abs === null) continue;
187
- const at = canonical(abs);
188
- if (!within(mainRoot, at)) continue;
189
- const said = isAbsolute(raw) ? at : `${at} ("${raw}" resolved against the session cwd ${cwd})`;
262
+ for (const t of writes()) {
263
+ if (t.error) return unresolved(t);
264
+ if (!within(mainRoot, t.at)) continue;
190
265
  let ignored;
191
266
  try {
192
- ignored = await isIgnored(at);
267
+ ignored = await isIgnored(t.at);
193
268
  } catch (e) {
194
- return { block: true, reason: `member-write-guard: refused ${toolName} to ${said} — could not tell whether it is gitignored (${e?.message ?? e}), and a guard that cannot look does not let the call through. ${REISSUE}` };
269
+ return { block: true, reason: `member-write-guard: refused ${toolName} to ${said(t)} — could not tell whether it is gitignored (${e?.message ?? e}), and a guard that cannot look does not let the call through. ${REISSUE}` };
195
270
  }
196
271
  if (!ignored) {
197
- return { block: true, reason: `member-write-guard: refused ${toolName} to ${said} — it is inside the main checkout ${mainRoot} and not gitignored. ${REISSUE}` };
272
+ return { block: true, reason: `member-write-guard: refused ${toolName} to ${said(t)} — it is inside the main checkout ${mainRoot} and not gitignored. ${REISSUE}` };
198
273
  }
199
274
  }
200
275
  return undefined;
@@ -238,8 +313,10 @@ async function resolveMainRoot(cwd) {
238
313
  // by the dead path rather than "(or any …": that is a broken repo, and blocks.
239
314
  if (!r.error && r.status !== 0 && /not a git repository \(or any/i.test(r.stderr)) return null;
240
315
  if (r.error || r.status !== 0) return new Error(failure(r, "git rev-parse --git-common-dir"));
241
- return mainCheckoutDirFromGitCommonDir(r.stdout, cwd, { canonicalise: true })
242
- ?? new Error("git rev-parse --git-common-dir answered nothing");
316
+ const dir = mainCheckoutDirFromGitCommonDir(r.stdout, cwd, { canonicalise: true });
317
+ if (dir === null) return new Error("git rev-parse --git-common-dir answered nothing");
318
+ // In the on-disk letter case canonicalPath gives every target compared against it.
319
+ try { return realpathSync.native(dir); } catch { return dir; }
243
320
  }
244
321
 
245
322
  /** `git check-ignore` from `mainRoot`: true ignored, false not; rejects on anything else. */
@@ -250,10 +327,38 @@ async function checkIgnored(mainRoot, absPath) {
250
327
  throw new Error(failure(r, "git check-ignore"));
251
328
  }
252
329
 
253
- /** The symlink-free spelling of `p`, whose tail need not exist yet. */
330
+ // The Install root, resolved the way fleet-run's Resolver resolves it — lstat,
331
+ // then realpath, of the package entry under the home directory — on every
332
+ // guarded path-writer call, so a relink or reinstall mid-run is followed. Not
333
+ // this module's own location: that names the copy omp loaded at session start.
334
+ // The realpath is the native one, which answers in the on-disk letter case,
335
+ // as canonicalPath does for every target compared against it.
336
+ /** The live Install root: its realpath, `null` when there is no package entry, or an `Error` naming the entry. */
337
+ function resolveInstallRoot() {
338
+ const entry = join(homedir(), ...INSTALL_ENTRY);
339
+ let isLink;
340
+ try {
341
+ isLink = lstatSync(entry).isSymbolicLink();
342
+ } catch (e) {
343
+ if (e?.code === "ENOENT") return null;
344
+ return new Error(`cannot read the omp plugin entry ${entry}: ${e?.code ?? e?.message ?? e}`);
345
+ }
346
+ try {
347
+ return realpathSync.native(entry);
348
+ } catch (e) {
349
+ const code = e?.code ?? e?.message ?? e;
350
+ return new Error(isLink ? `the omp plugin link ${entry} is dangling: ${code}` : `cannot resolve the omp plugin entry ${entry}: ${code}`);
351
+ }
352
+ }
353
+
354
+ // The native realpath, not the JS one: on a case-insensitive filesystem
355
+ // (macOS's default) the JS realpath keeps the caller's letter case, so
356
+ // `…/@FEIGI/fleet-ctl` would name the Install root's files while comparing
357
+ // unequal to it.
358
+ /** The symlink-free, on-disk spelling of `p`, whose tail need not exist yet. */
254
359
  function canonicalPath(p) {
255
360
  try {
256
- return realpathSync(p);
361
+ return realpathSync.native(p);
257
362
  } catch (e) {
258
363
  if (e?.code !== "ENOENT") throw e;
259
364
  const parent = dirname(p);
@@ -274,6 +379,7 @@ export default function memberWriteGuard(pi) {
274
379
  cwd,
275
380
  agent,
276
381
  mainRoot,
382
+ installRoot: PATH_WRITERS.has(event.toolName) ? resolveInstallRoot() : null,
277
383
  isIgnored: (p) => checkIgnored(mainRoot, p),
278
384
  canonical: canonicalPath,
279
385
  });
@@ -113,7 +113,7 @@
113
113
  // verdict flags is derived when its evidence is still in scratch, and
114
114
  // otherwise refused with the flags to give.
115
115
 
116
- import { appendFileSync, existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
116
+ import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
117
117
  import { execFileSync } from "node:child_process";
118
118
  import { dirname, join } from "node:path";
119
119
  import { fileURLToPath } from "node:url";
@@ -889,8 +889,10 @@ function append(pr, paths) {
889
889
  }
890
890
 
891
891
  const line = formatRow({ ...fields, run_date: today(), pr, ticket, tier: resolved.tier });
892
- if (text === null) writeFileSync(paths.file, `# ${COLUMNS.join("\t")}\n${line}\n`);
893
- else appendFileSync(paths.file, `${text === "" || text.endsWith("\n") ? "" : "\n"}${line}\n`);
892
+ if (text === null) {
893
+ mkdirSync(dirname(paths.file), { recursive: true });
894
+ writeFileSync(paths.file, `# ${COLUMNS.join("\t")}\n${line}\n`);
895
+ } else appendFileSync(paths.file, `${text === "" || text.endsWith("\n") ? "" : "\n"}${line}\n`);
894
896
  console.log(line);
895
897
  }
896
898
 
@@ -9,10 +9,10 @@ them before every gate decision.** Per-member worktrees and `./agent-test`'s por
9
9
  derivation protect members from each other; neither protects the Install root,
10
10
  the tree you run every gate probe out of and read these runbooks from. It is
11
11
  the main checkout only when that checkout is linked as the install. The
12
- `member-write-guard` extension refuses a `write`/`edit`/`ast_edit` inside the
13
- main checkout only, and a `bash` or `eval` write lands anyway; under a package
14
- install nothing prevents a write to the Install root, and this re-check is
15
- what catches one. Measured: a
12
+ `member-write-guard` extension refuses a `write`/`edit`/`ast_edit` into the
13
+ Install root, as it does into the main checkout, but a `bash` or `eval` write
14
+ into the Install root still lands, and this re-check is what catches one.
15
+ Measured: a
16
16
  member edited two files in the main checkout instead of in its worktree while
17
17
  the CI monitor was polling one of them every 120s and a live finisher was using
18
18
  it to decide a label. It caught itself; nothing in the fleet would have. That is
@@ -185,8 +185,9 @@ practice: the recipe is the absolute-path discipline above, not a placeholder
185
185
  for a `cwd` field that does not exist. The gap is now enforced rather than only
186
186
  written down: the plugin's `member-write-guard` omp extension
187
187
  refuses a fleet member's `write`/`edit`/`ast_edit` into the main checkout's
188
- non-ignored tree and an implementer's `bash` from a main-checkout cwd, and the
189
- missing field itself is requested upstream in `can1357/oh-my-pi`.
188
+ non-ignored tree or into the Install root, and an implementer's `bash` from a
189
+ main-checkout cwd, and the missing field itself is requested upstream in
190
+ `can1357/oh-my-pi`.
190
191
 
191
192
  ## `task`-dispatched members share one `eval` kernel
192
193