@feigi/fleet-ctl 3.23.35 → 3.23.37
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/package.json +1 -1
- package/scripts/main-checkout.mjs +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
// member-write-guard.mjs, exercised the way omp runs it: the factory is handed
|
|
2
|
-
// a stand-in `pi`, and every call goes through the `tool_call` handler it
|
|
3
|
-
// registers — which resolves the main checkout with real git and hands it to
|
|
4
|
-
// `decide()`. The fixture is a real repository with a claimed-style worktree
|
|
5
|
-
// under `.worktrees/`, a `.gitignore` carrying the fleet's ignored
|
|
6
|
-
// directories, and a scratch directory outside it. On macOS `tmpdir()` lives
|
|
7
|
-
// behind the `/var` → `/private/var` symlink, so every row below also crosses
|
|
8
|
-
// the symlink the handler canonicalises away.
|
|
9
|
-
//
|
|
10
|
-
// Both halves are pinned: what the guard must refuse (a main-checkout write,
|
|
11
|
-
// relative or absolute, from a member or a member's child; an implementer's
|
|
12
|
-
// bash from the inherited cwd; a git that cannot answer) and what it must let
|
|
13
|
-
// through (the member's worktree, gitignored run state, scratch, internal
|
|
14
|
-
// URLs, every session that is not a fleet member's).
|
|
15
|
-
//
|
|
16
|
-
// Zero deps: `node --test plugin/scripts/member-write-guard.test.mjs`.
|
|
17
|
-
|
|
18
|
-
import { after, test } from "node:test";
|
|
19
|
-
import assert from "node:assert/strict";
|
|
20
|
-
import { execFileSync } from "node:child_process";
|
|
21
|
-
import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
22
|
-
import { tmpdir } from "node:os";
|
|
23
|
-
import { join } from "node:path";
|
|
24
|
-
import { gitEnv } from "./git-env.mjs";
|
|
25
|
-
import memberWriteGuard, { decide } from "./member-write-guard.mjs";
|
|
26
|
-
|
|
27
|
-
const ENV = gitEnv({
|
|
28
|
-
GIT_AUTHOR_NAME: "t", GIT_AUTHOR_EMAIL: "t@example.com", GIT_COMMITTER_NAME: "t", GIT_COMMITTER_EMAIL: "t@example.com",
|
|
29
|
-
});
|
|
30
|
-
const sh = (cwd, ...args) => execFileSync("git", args, { cwd, env: ENV, stdio: "pipe" });
|
|
31
|
-
|
|
32
|
-
function repo(dir) {
|
|
33
|
-
mkdirSync(dir, { recursive: true });
|
|
34
|
-
sh(dir, "init", "-q", "-b", "main");
|
|
35
|
-
writeFileSync(join(dir, ".gitignore"), ".worktrees/\n.fleet/\n.agent-brain/\n");
|
|
36
|
-
mkdirSync(join(dir, "plugin"));
|
|
37
|
-
writeFileSync(join(dir, "plugin", "tool.mjs"), "export {};\n");
|
|
38
|
-
sh(dir, "add", "-A");
|
|
39
|
-
sh(dir, "commit", "-q", "-m", "init");
|
|
40
|
-
assert.ok(existsSync(join(dir, ".git")), `fixture: ${dir} has no .git — git init answered for some other repository`);
|
|
41
|
-
return dir;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const BASE = mkdtempSync(join(tmpdir(), "member-write-guard-"));
|
|
45
|
-
after(() => rmSync(BASE, { recursive: true, force: true }));
|
|
46
|
-
// The spelling a session would carry: NOT canonicalised, so the /var symlink stays in it.
|
|
47
|
-
const ROOT = repo(join(BASE, "main"));
|
|
48
|
-
const REAL_ROOT = realpathSync(ROOT);
|
|
49
|
-
const WT = join(ROOT, ".worktrees", "42-slug");
|
|
50
|
-
sh(ROOT, "worktree", "add", "-q", WT, "-b", "implementer/42");
|
|
51
|
-
const SCRATCH = join(BASE, "scratch");
|
|
52
|
-
mkdirSync(SCRATCH);
|
|
53
|
-
const ELSEWHERE = repo(join(BASE, "elsewhere"));
|
|
54
|
-
|
|
55
|
-
const IMPL = { kind: "sub", id: "impl-42", name: "fleet-implementer-slow-high", depth: 1, parentId: "Main" };
|
|
56
|
-
const OTHER_CELLS = ["slow-medium", "task-high", "task-max", "smol-high"].map((cell) => ({ ...IMPL, name: `fleet-implementer-${cell}` }));
|
|
57
|
-
const REVIEWER = { kind: "sub", id: "review-pr-9.Correctness", name: "fleet-review-correctness", depth: 2, parentId: "review-pr-9" };
|
|
58
|
-
const FINISHER = { kind: "sub", id: "finisher-pr-9", name: "fleet-finisher", depth: 1, parentId: "Main" };
|
|
59
|
-
const CHILD = { kind: "sub", id: "impl-42.Probe", name: "task", depth: 2, parentId: "impl-42" };
|
|
60
|
-
const UNRELATED = { kind: "sub", id: "0-Explore", name: "explore", depth: 1, parentId: "Main" };
|
|
61
|
-
const MAIN = { kind: "main", id: "Main", name: "main", depth: 0 };
|
|
62
|
-
// A fix-applier: dispatched under the generic `task` definition (no `fleet-`
|
|
63
|
-
// prefix) directly by the controller, so only its own id names it.
|
|
64
|
-
const FIX_APPLIER = { kind: "sub", id: "fix-pr-2246", name: "task", depth: 0, parentId: "Main" };
|
|
65
|
-
|
|
66
|
-
let handler;
|
|
67
|
-
memberWriteGuard({ on: (event, fn) => { if (event === "tool_call") handler = fn; } });
|
|
68
|
-
const call = (agent, toolName, input, cwd) => handler({ type: "tool_call", toolCallId: "t", toolName, input }, { cwd, agent });
|
|
69
|
-
|
|
70
|
-
async function refused(agent, toolName, input, cwd, what) {
|
|
71
|
-
const r = await call(agent, toolName, input, cwd);
|
|
72
|
-
assert.equal(r?.block, true, `${what}: expected a refusal, got ${JSON.stringify(r)}`);
|
|
73
|
-
assert.match(r.reason, /member-write-guard/, `${what}: the refusal does not name the guard`);
|
|
74
|
-
assert.match(r.reason, /\.worktrees\/<n>-<slug>\//, `${what}: the refusal does not tell the member where to re-issue it`);
|
|
75
|
-
return r.reason;
|
|
76
|
-
}
|
|
77
|
-
async function allowed(agent, toolName, input, cwd, what) {
|
|
78
|
-
assert.equal(await call(agent, toolName, input, cwd), undefined, `${what}: expected the call to run`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
test("a member's relative and absolute writes into the main checkout are refused, naming the resolved path", async () => {
|
|
82
|
-
const rel = await refused(IMPL, "write", { path: "plugin/new.mjs", content: "x" }, ROOT, "relative write");
|
|
83
|
-
assert.ok(rel.includes(join(REAL_ROOT, "plugin", "new.mjs")), `the refusal does not name the resolved path: ${rel}`);
|
|
84
|
-
assert.match(rel, /"plugin\/new\.mjs" resolved against the session cwd/, "a relative refusal does not say what it resolved against");
|
|
85
|
-
await refused(IMPL, "write", { path: join(ROOT, "plugin", "tool.mjs"), content: "x" }, ROOT, "absolute write to a tracked file");
|
|
86
|
-
await refused(IMPL, "write", { path: join(ROOT, "README.md"), content: "x" }, ROOT, "absolute write to a new file at the root");
|
|
87
|
-
await refused(REVIEWER, "write", { path: "plugin/tool.mjs" }, ROOT, "a review specialist's relative write");
|
|
88
|
-
await refused(FINISHER, "write", { path: "plugin/tool.mjs" }, ROOT, "the finisher's relative write");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test("edit is refused on any target in the main checkout — header, omp's derived paths, a MV destination", async () => {
|
|
92
|
-
await refused(IMPL, "edit", { input: "[plugin/tool.mjs#ABCD]\nPUT 1.=1:\n+x\n" }, ROOT, "hashline header, unnormalised");
|
|
93
|
-
await refused(IMPL, "edit", { input: "…", path: "plugin/tool.mjs", paths: ["plugin/tool.mjs"] }, ROOT, "omp-normalised path");
|
|
94
|
-
await refused(IMPL, "edit", { input: `[${join(WT, "plugin", "tool.mjs")}#ABCD]\nMV "plugin/moved.mjs"\n` }, ROOT, "a worktree file moved into the main checkout");
|
|
95
|
-
await refused(IMPL, "edit", { input: "*** Begin Patch\n*** Update File: plugin/tool.mjs\n*** End Patch\n" }, ROOT, "apply_patch-mode header");
|
|
96
|
-
await refused(IMPL, "edit", { _path: join(ROOT, "plugin", "tool.mjs") }, ROOT, "a host-added _path key, un-normalised");
|
|
97
|
-
await refused(IMPL, "edit", { _input: `[${join(ROOT, "plugin", "tool.mjs")}#ABCD]\nPUT 1.=1:\n+x\n` }, ROOT, "a host-added _input key, un-normalised");
|
|
98
|
-
await allowed(IMPL, "edit", { input: `[${join(WT, "plugin", "tool.mjs")}#ABCD]\nPUT 1.=1:\n+x\n` }, ROOT, "a worktree edit");
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test("ast_edit is refused on a main-checkout path or glob and allowed in the worktree", async () => {
|
|
102
|
-
await refused(IMPL, "ast_edit", { ops: [{ pat: "a", out: "b" }], paths: ["plugin/**/*.mjs"] }, ROOT, "a relative glob");
|
|
103
|
-
await refused(IMPL, "ast_edit", { ops: [{ pat: "a", out: "b" }], paths: [join(WT, "plugin"), "plugin/tool.mjs"] }, ROOT, "one bad path among good ones");
|
|
104
|
-
await allowed(IMPL, "ast_edit", { ops: [{ pat: "a", out: "b" }], paths: [join(WT, "plugin", "**", "*.mjs")] }, ROOT, "a worktree glob");
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test("writes the guard must let through: the worktree, gitignored run state, scratch, internal URLs", async () => {
|
|
108
|
-
await allowed(IMPL, "write", { path: join(WT, "plugin", "new.mjs") }, ROOT, "absolute write into the worktree");
|
|
109
|
-
await allowed(IMPL, "write", { path: ".worktrees/42-slug/plugin/new.mjs" }, ROOT, "relative write into the worktree");
|
|
110
|
-
await allowed(IMPL, "write", { path: ".fleet/ledger.md" }, ROOT, "gitignored .fleet/");
|
|
111
|
-
await allowed(IMPL, "write", { path: join(ROOT, ".agent-brain", "index.md") }, ROOT, "gitignored .agent-brain/");
|
|
112
|
-
await allowed(IMPL, "write", { path: join(SCRATCH, "impl-42", "probe.mjs") }, ROOT, "scratch outside the repository");
|
|
113
|
-
await allowed(IMPL, "write", { path: "local://notes.md" }, ROOT, "a local:// artifact");
|
|
114
|
-
await allowed(IMPL, "write", { path: "xd://ast_edit", content: "{}" }, ROOT, "an xd:// device");
|
|
115
|
-
// From the worktree itself — the cwd a member would have if omp ever gave it one.
|
|
116
|
-
await allowed(IMPL, "write", { path: "plugin/new.mjs" }, WT, "relative write from a worktree cwd");
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test("only fleet members and their children are guarded — nothing else in the session", async () => {
|
|
120
|
-
await allowed(UNRELATED, "write", { path: "plugin/tool.mjs" }, ROOT, "a non-fleet subagent");
|
|
121
|
-
await allowed(MAIN, "write", { path: "plugin/tool.mjs" }, ROOT, "the top-level session");
|
|
122
|
-
await allowed(MAIN, "bash", { command: "true" }, ROOT, "the top-level session's bash");
|
|
123
|
-
await allowed(undefined, "write", { path: "plugin/tool.mjs" }, ROOT, "a context with no agent");
|
|
124
|
-
await refused(CHILD, "write", { path: "plugin/tool.mjs" }, ROOT, "a child of impl-42");
|
|
125
|
-
await refused({ ...CHILD, parentId: "impl-42-b" }, "write", { path: "plugin/tool.mjs" }, ROOT, "a child of a recovery member");
|
|
126
|
-
for (const parentId of ["fix-pr-7", "review-pr-2245", "finisher-pr-3"]) {
|
|
127
|
-
await refused({ ...CHILD, parentId }, "write", { path: "plugin/tool.mjs" }, ROOT, `a child of ${parentId}`);
|
|
128
|
-
}
|
|
129
|
-
// The pattern is anchored at both ends: near-misses are someone else's agents.
|
|
130
|
-
for (const parentId of ["impl-42x", "impl-", "myimpl-42", "impl-42.Probe", "Main"]) {
|
|
131
|
-
await allowed({ ...CHILD, parentId }, "write", { path: "plugin/tool.mjs" }, ROOT, `a subagent whose parent is ${parentId}`);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test("a fix-applier dispatched under the generic `task` definition is guarded by its own id, not its definition name", async () => {
|
|
136
|
-
await refused(FIX_APPLIER, "write", { path: "plugin/tool.mjs" }, ROOT, "a fix-applier's relative write");
|
|
137
|
-
await refused(FIX_APPLIER, "edit", { input: "[plugin/tool.mjs#ABCD]\nPUT 1.=1:\n+x\n" }, ROOT, "a fix-applier's edit");
|
|
138
|
-
await refused(FIX_APPLIER, "bash", { command: "true" }, ROOT, "a fix-applier's bash with no cwd");
|
|
139
|
-
await refused(FIX_APPLIER, "bash", { command: "true", cwd: ROOT }, WT, "a fix-applier's bash at the main checkout root");
|
|
140
|
-
await allowed(FIX_APPLIER, "write", { path: "plugin/tool.mjs" }, WT, "a fix-applier's write from its worktree");
|
|
141
|
-
await allowed(FIX_APPLIER, "bash", { command: "true", cwd: WT }, ROOT, "a fix-applier's bash cwd set to its worktree");
|
|
142
|
-
// The pattern is anchored: a generic `task` agent whose own id does not
|
|
143
|
-
// match `fix-pr-<n>` is nobody's fix-applier and stays unguarded — the
|
|
144
|
-
// existing UNRELATED/CHILD near-miss rows above already cover this shape.
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test("bash: an implementer is refused from the main checkout, never from its worktree; nobody else is", async () => {
|
|
148
|
-
const r = await refused(IMPL, "bash", { command: "git status" }, ROOT, "implementer bash with no cwd");
|
|
149
|
-
assert.ok(r.includes(REAL_ROOT), `the bash refusal does not name the cwd it resolved: ${r}`);
|
|
150
|
-
for (const cell of OTHER_CELLS) await refused(cell, "bash", { command: "true" }, ROOT, `${cell.name} bash with no cwd`);
|
|
151
|
-
// The bash rule is closed to the `CELL` grammar: a `fleet-implementer-`
|
|
152
|
-
// name outside it is no implementer definition, and keeps the inherited cwd.
|
|
153
|
-
await allowed({ ...IMPL, id: "probe-1", name: "fleet-implementer-probe" }, "bash", { command: "true" }, ROOT, "a non-cell fleet-implementer- name");
|
|
154
|
-
await refused(IMPL, "bash", { command: "true", cwd: "plugin" }, ROOT, "a relative cwd inside the main checkout");
|
|
155
|
-
await refused(IMPL, "bash", { command: "true", cwd: ROOT }, WT, "an explicit cwd at the main checkout root");
|
|
156
|
-
await refused(IMPL, "bash", { command: "true", cwd: join(ROOT, ".worktrees") }, ROOT, "cwd at the bare .worktrees directory itself, not a worktree under it");
|
|
157
|
-
await allowed(IMPL, "bash", { command: "true", cwd: WT }, ROOT, "cwd set to the worktree");
|
|
158
|
-
await allowed(IMPL, "bash", { command: "true", cwd: SCRATCH }, ROOT, "cwd set to scratch");
|
|
159
|
-
await allowed(IMPL, "bash", { command: "true" }, WT, "no cwd, session already in the worktree");
|
|
160
|
-
await allowed(REVIEWER, "bash", { command: "pwd" }, ROOT, "a review specialist's pwd-first bash");
|
|
161
|
-
await allowed(FINISHER, "bash", { command: "sh worktree-audit.sh" }, ROOT, "the finisher's audit");
|
|
162
|
-
await allowed(CHILD, "bash", { command: "true" }, ROOT, "a member's child");
|
|
163
|
-
await allowed(IMPL, "read", { path: "plugin/tool.mjs" }, ROOT, "a relative read");
|
|
164
|
-
await allowed(IMPL, "eval", { code: "open('x','w')" }, ROOT, "eval");
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test("when git cannot answer, the guard refuses; when there is no repository at all, it allows", async () => {
|
|
168
|
-
await allowed(IMPL, "write", { path: "x.txt" }, SCRATCH, "cwd outside any repository");
|
|
169
|
-
await allowed(IMPL, "bash", { command: "true" }, SCRATCH, "implementer bash outside any repository");
|
|
170
|
-
|
|
171
|
-
const broken = join(BASE, "broken");
|
|
172
|
-
mkdirSync(broken);
|
|
173
|
-
writeFileSync(join(broken, ".git"), `gitdir: ${join(BASE, "gone")}\n`);
|
|
174
|
-
const r = await refused(IMPL, "write", { path: "x.txt" }, broken, "a gitfile naming a missing git dir");
|
|
175
|
-
assert.match(r, /git rev-parse --git-common-dir exited/, `the refusal does not name the git failure: ${r}`);
|
|
176
|
-
await refused(IMPL, "write", { path: "x.txt" }, join(BASE, "no-such-dir"), "a session cwd that does not exist");
|
|
177
|
-
|
|
178
|
-
const failing = await decide({
|
|
179
|
-
toolName: "write", input: { path: "plugin/tool.mjs" }, cwd: REAL_ROOT, agent: IMPL, mainRoot: REAL_ROOT,
|
|
180
|
-
isIgnored: async () => { throw new Error("git check-ignore exited 128: fatal: boom"); },
|
|
181
|
-
});
|
|
182
|
-
assert.equal(failing?.block, true, "a check-ignore failure let the write through");
|
|
183
|
-
assert.match(failing.reason, /fatal: boom/, "the refusal does not carry the check-ignore failure");
|
|
184
|
-
|
|
185
|
-
// decide() is exported and callable directly (as this test does), so a
|
|
186
|
-
// mainRoot outside its null/Error/non-empty-string contract must fail
|
|
187
|
-
// closed rather than let `within()`'s empty-prefix match everything.
|
|
188
|
-
const emptyRoot = await decide({
|
|
189
|
-
toolName: "write", input: { path: "/etc/passwd" }, cwd: "/tmp", agent: IMPL, mainRoot: "",
|
|
190
|
-
isIgnored: async () => false,
|
|
191
|
-
});
|
|
192
|
-
assert.equal(emptyRoot?.block, true, "an empty-string mainRoot let an arbitrary absolute path through");
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
test("an ambient GIT_DIR naming another repository does not change the answer", async () => {
|
|
196
|
-
const saved = process.env.GIT_DIR;
|
|
197
|
-
process.env.GIT_DIR = join(ELSEWHERE, ".git");
|
|
198
|
-
try {
|
|
199
|
-
await refused(IMPL, "write", { path: "plugin/tool.mjs" }, ROOT, "main-checkout write under an ambient GIT_DIR");
|
|
200
|
-
await allowed(IMPL, "write", { path: ".fleet/ledger.md" }, ROOT, "ignored write under an ambient GIT_DIR");
|
|
201
|
-
await refused(IMPL, "bash", { command: "true" }, ROOT, "implementer bash under an ambient GIT_DIR");
|
|
202
|
-
} finally {
|
|
203
|
-
if (saved === undefined) delete process.env.GIT_DIR;
|
|
204
|
-
else process.env.GIT_DIR = saved;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
test("a symlinked route into the main checkout is the main checkout", async () => {
|
|
209
|
-
const link = join(BASE, "link");
|
|
210
|
-
symlinkSync(ROOT, link);
|
|
211
|
-
await refused(IMPL, "write", { path: "plugin/tool.mjs" }, link, "relative write from a symlinked cwd");
|
|
212
|
-
await refused(IMPL, "write", { path: join(link, "plugin", "tool.mjs") }, ROOT, "absolute write through the symlink");
|
|
213
|
-
await allowed(IMPL, "write", { path: join(link, ".worktrees", "42-slug", "a.mjs") }, ROOT, "worktree write through the symlink");
|
|
214
|
-
});
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
// #911. `run-team/SKILL.md`'s five-condition note sends the fix-applier to
|
|
2
|
-
// measure the merge-commit condition by hand, because `ci.yml`'s `rebase-check`
|
|
3
|
-
// exits on the staleness condition before the merge-commit one is evaluated, so
|
|
4
|
-
// the job log cannot name it. That hand-run probe is the whole of the evidence,
|
|
5
|
-
// and it shipped broken.
|
|
6
|
-
//
|
|
7
|
-
// `376c19c` wrote it as `git rev-list --merges --count "$BASE..HEAD"`. `$BASE`
|
|
8
|
-
// is assigned nowhere — `grep -rIn --exclude-dir=.git -E '(^|[^A-Z_])BASE=' .`
|
|
9
|
-
// prints nothing against this tree — so it expanded to `..HEAD`, which git
|
|
10
|
-
// reads as `HEAD..HEAD`: `git rev-list --merges --count "..HEAD"` prints `0` and
|
|
11
|
-
// exits 0. The broken probe returned the "no merge commits" answer, silently, at
|
|
12
|
-
// success, which is precisely the benign misreading the note exists to deny.
|
|
13
|
-
// `7b48720`, landed in the same PR #881 as the bug it fixes, corrected it to
|
|
14
|
-
// the angle-bracket placeholder form
|
|
15
|
-
// this file pins; that commit also edited
|
|
16
|
-
// `staleness-qualifier-prose.test.mjs`, but added no assertion on the command.
|
|
17
|
-
//
|
|
18
|
-
// WHY A PIN AND NOT A COMMENT: nothing pinned the corrected form. Measured:
|
|
19
|
-
// with this file's own test removed from the suite and the `$BASE` range
|
|
20
|
-
// reinstated in `SKILL.md`, the full suite
|
|
21
|
-
// (`node --test plugin/scripts/*.test.mjs`) still passes at 2202/2202 —
|
|
22
|
-
// nothing else in the suite catches the regression. The corrected form had
|
|
23
|
-
// no guard, so a dedup pass, a reword, or a "let's make this copy-pasteable"
|
|
24
|
-
// edit could restore the silent-zero probe with the suite green.
|
|
25
|
-
//
|
|
26
|
-
// ONE EXACT SPAN, NOT TWO REGEXES. Both halves of the command are load-bearing
|
|
27
|
-
// and they fail in OPPOSITE directions:
|
|
28
|
-
// - the `origin/<base>..HEAD` placeholder shape. A `$VAR` range reads as a
|
|
29
|
-
// variable the reader has already set, and when it is not set the probe is
|
|
30
|
-
// the silent false negative above.
|
|
31
|
-
// - the `git fetch origin &&` prefix. The document states the consequence of
|
|
32
|
-
// dropping it: a stale local `origin/<base>` widens the range over the
|
|
33
|
-
// base's own merge commits, turning the false negative into a false
|
|
34
|
-
// positive.
|
|
35
|
-
// Pinned as a single contiguous span because the invariant lives in the JOIN.
|
|
36
|
-
// Separate `git fetch origin` and `origin/<base>..HEAD` matches over this slice
|
|
37
|
-
// would pin two facts and not their adjacency: a rewrite mentioning the fetch in
|
|
38
|
-
// the surrounding prose while leaving the command fetch-less satisfies both and
|
|
39
|
-
// says neither. The command's own correctness is #881's, settled there and not
|
|
40
|
-
// re-argued here; this asserts only that the corrected text is still the text.
|
|
41
|
-
//
|
|
42
|
-
// SLICE SIZE IS THE PIN, as in `staleness-qualifier-prose.test.mjs`. The note
|
|
43
|
-
// sits inside the fix-applier's blockquoted prompt, and this same document
|
|
44
|
-
// carries a near-miss at SKILL.md:149 — `git fetch origin && git rev-list
|
|
45
|
-
// --count main..origin/main`, same command family, no `--merges` — so a copy
|
|
46
|
-
// of this command left anywhere in the document would satisfy a file-wide
|
|
47
|
-
// match with the live one gutted. Measured: with the command replaced by the
|
|
48
|
-
// `$BASE` form in place AND a correct copy appended elsewhere in the
|
|
49
|
-
// document, in a genuinely separate paragraph with its `>` separator intact,
|
|
50
|
-
// this still reds. What it does NOT close is that separator deleted outright
|
|
51
|
-
// — the paragraphs then merge and the slice takes both, a hole that predates
|
|
52
|
-
// this bound and is open still (#1377).
|
|
53
|
-
//
|
|
54
|
-
// `stripQuoteGutter` before `paragraph`, which is what makes the shared
|
|
55
|
-
// paragraph bound reach into a blockquote at all: the `>`-only lines that fence
|
|
56
|
-
// this note become genuinely blank, so `paragraph`'s `\n[ \t]*\n` search finds
|
|
57
|
-
// them. It is also the reflow guard. `phrase()` joins on `\s+` and `\s+` does
|
|
58
|
-
// not span a `>`, so a rewrap that moved a word of the command onto the next
|
|
59
|
-
// blockquote line would red an untouched document without the strip.
|
|
60
|
-
//
|
|
61
|
-
// REFLOW CONTROL, measured on a scratch copy: the note rewrapped at 60, 72 and
|
|
62
|
-
// 100 columns (Python `textwrap.fill`, `break_on_hyphens=False`,
|
|
63
|
-
// `break_long_words=False`, `>` gutter re-applied) stays green — and at all
|
|
64
|
-
// three the command itself is split across blockquote lines, so this control
|
|
65
|
-
// exercises the gutter strip rather than passing on an unchanged line.
|
|
66
|
-
//
|
|
67
|
-
// THE CEILING is the hyphen-break one `staleness-qualifier-prose.test.mjs`
|
|
68
|
-
// records, and here it has exactly ONE carrier: `rev-list` is the only
|
|
69
|
-
// hyphenated token inside the pinned span, so it is the only one a wrapper can
|
|
70
|
-
// break where `\s+` cannot rejoin. Measured over widths 40-120 with
|
|
71
|
-
// `break_on_hyphens` on, this reds at 45, 46, 77, 78, 87 and 88 — precisely the
|
|
72
|
-
// widths that split `rev-list`, set-equal, not merely overlapping. The slice's
|
|
73
|
-
// other hyphenated tokens are NOT a mechanism: `gh pr update-branch` splits at
|
|
74
|
-
// 47, 48, 50 and 94 and this stays green there, because it sits in the note but
|
|
75
|
-
// outside the pinned span. `--merges` and `--count` never split — a leading
|
|
76
|
-
// double hyphen is not a break point. So the ceiling is a property of the
|
|
77
|
-
// wrapper and of one token, not a width to memorise; a Markdown wrapper does
|
|
78
|
-
// not break hyphenated words.
|
|
79
|
-
//
|
|
80
|
-
// THE CEILING on the assertion itself: it pins this command's text and nothing
|
|
81
|
-
// else in the note — not the five-condition claim, not the `solely` qualifier
|
|
82
|
-
// (`staleness-qualifier-prose.test.mjs` holds that, on a different paragraph of
|
|
83
|
-
// this document), not the server-side-rebase consequence. A deliberate reword of
|
|
84
|
-
// the command reds this; re-anchor PROBE here rather than deleting the
|
|
85
|
-
// assertion, and keep whichever form replaces it honest about both halves.
|
|
86
|
-
|
|
87
|
-
import { test } from "node:test";
|
|
88
|
-
import assert from "node:assert/strict";
|
|
89
|
-
import { readFileSync } from "node:fs";
|
|
90
|
-
import { join } from "node:path";
|
|
91
|
-
import { paragraph, phrase, stripQuoteGutter } from "./prose-pin.mjs";
|
|
92
|
-
|
|
93
|
-
const REPO = join(import.meta.dirname, "..");
|
|
94
|
-
const SKILL = "skills/run-team/SKILL.md";
|
|
95
|
-
|
|
96
|
-
// The note, and no more of the document than that. A moved anchor throws rather
|
|
97
|
-
// than widening the slice back to the file, which is the false green the bound
|
|
98
|
-
// exists to prevent.
|
|
99
|
-
const note = () =>
|
|
100
|
-
paragraph(
|
|
101
|
-
stripQuoteGutter(readFileSync(join(REPO, ...SKILL.split("/")), "utf8")),
|
|
102
|
-
"The CI facts in that file apply to you",
|
|
103
|
-
SKILL,
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
// Backticks included: they are what keeps this a code span the reader can run,
|
|
107
|
-
// rather than a sentence describing one.
|
|
108
|
-
const PROBE = '`git fetch origin && git rev-list --merges --count "origin/<base>..HEAD"`';
|
|
109
|
-
|
|
110
|
-
test("the five-condition note measures merge commits with a fetched, origin-relative range", () => {
|
|
111
|
-
assert.match(
|
|
112
|
-
note(),
|
|
113
|
-
phrase(PROBE),
|
|
114
|
-
`${SKILL}'s five-condition note no longer spells the merge-commit probe ${PROBE}.
|
|
115
|
-
|
|
116
|
-
Both halves are load-bearing, and dropping either is silent:
|
|
117
|
-
- a \`$VAR\` range (the \`"$BASE..HEAD"\` form \`376c19c\` shipped and \`7b48720\` fixed) expands to \`..HEAD\` when unset, which git reads as \`HEAD..HEAD\` — count \`0\`, exit 0, the "no merge commits" answer this note exists to deny.
|
|
118
|
-
- without \`git fetch origin &&\`, a stale local \`origin/<base>\` widens the range over the base's own merge commits and reports one this branch never added.
|
|
119
|
-
|
|
120
|
-
If the command was reworded on purpose, re-anchor PROBE in this file to the new wording — and keep the angle-bracket placeholder and the fetch, or say in the commit which of the two failure modes you are accepting.`,
|
|
121
|
-
);
|
|
122
|
-
});
|