@feigi/fleet-ctl 3.158.8 → 3.158.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.158.8",
3
+ "version": "3.158.9",
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": {
@@ -45,6 +45,7 @@
45
45
 
46
46
  import { lstatSync } from "node:fs";
47
47
  import { isAbsolute, posix } from "node:path";
48
+ import { inspect } from "node:util";
48
49
  import { isDigits } from "./arg.mjs";
49
50
  import { evictTrees } from "./evict-tree.mjs";
50
51
  import { FleetDirUnresolvable, scratchRoot, scratchRootRefusal } from "./fleet-dir.mjs";
@@ -920,7 +921,33 @@ export function digestOf(result) {
920
921
  // module already consumes the digits rule on the review path. Null when `pr`
921
922
  // is a PR number.
922
923
  export function runnerPrRefusal(pr) {
923
- return isDigits(pr) ? null : `args.pr must be a PR number, got ${JSON.stringify(pr)}`;
924
+ return isPrNumber(pr) ? null : `args.pr must be a PR number, got ${describeValue(pr)}`;
925
+ }
926
+
927
+ // A value as the refusals below print it: `JSON.stringify`'s text wherever it
928
+ // has one, `inspect`'s where it throws (a BigInt, a circular object) or answers
929
+ // `undefined` (a Symbol, a function). `String(value)` would print `1n` as `1`.
930
+ // `inspect` skips the value's own `[inspect.custom]`, which could throw.
931
+ // Never throws, so a refusal is always the message and never a bare TypeError.
932
+ function describeValue(value) {
933
+ try {
934
+ const text = JSON.stringify(value);
935
+ if (typeof text === "string") return text;
936
+ } catch {
937
+ // fall through to inspect
938
+ }
939
+ return inspect(value, { customInspect: false });
940
+ }
941
+
942
+ // `isDigits` coerces its argument, and a Symbol or a null-prototype object
943
+ // cannot be coerced: it throws where a refusal is owed. Such a value is not a
944
+ // PR number.
945
+ function isPrNumber(pr) {
946
+ try {
947
+ return isDigits(pr);
948
+ } catch {
949
+ return false;
950
+ }
924
951
  }
925
952
 
926
953
  // `runReview` owns the review side's `pr<N>/` partition — it appends
@@ -942,10 +969,10 @@ export function runnerPrRefusal(pr) {
942
969
  export function runnerScratchRefusal(scratch) {
943
970
  if (typeof scratch !== "string") return null;
944
971
  if (scratch.split("/").includes("..")) {
945
- return `args.scratch ${JSON.stringify(scratch)} has a ".." segment — pass the scratch root as a path without one`;
972
+ return `args.scratch ${describeValue(scratch)} has a ".." segment — pass the scratch root as a path without one`;
946
973
  }
947
974
  if (!/(?:^|\/)pr\d+\/*$/.test(posix.normalize(scratch))) return null;
948
- return `args.scratch ${JSON.stringify(scratch)} already ends in a pr<N> directory — pass the scratch root; the review creates <root>/pr<N>/ itself`;
975
+ return `args.scratch ${describeValue(scratch)} already ends in a pr<N> directory — pass the scratch root; the review creates <root>/pr<N>/ itself`;
949
976
  }
950
977
 
951
978
  // The Test entrypoint refusal `runReview` and review-eval.mjs's
@@ -956,7 +983,7 @@ export function runnerScratchRefusal(scratch) {
956
983
  // command.
957
984
  export function runnerTestCmdRefusal(testCmd) {
958
985
  if (typeof testCmd === "string" && testCmd.trim() !== "") return null;
959
- return `args.testCmd is required — the Test entrypoint the shared run executes, got ${JSON.stringify(testCmd)}`;
986
+ return `args.testCmd is required — the Test entrypoint the shared run executes, got ${describeValue(testCmd)}`;
960
987
  }
961
988
 
962
989
  // The worktree refusal the two share, for the reason the rules above are: the
@@ -966,7 +993,18 @@ export function runnerTestCmdRefusal(testCmd) {
966
993
  // Refused, never trimmed or coerced. Null when `worktree` is acceptable.
967
994
  export function runnerWorktreeRefusal(worktree) {
968
995
  if (typeof worktree === "string" && worktree.trim() !== "") return null;
969
- return `args.worktree is required — the checkout the review snapshots, got ${JSON.stringify(worktree)}`;
996
+ return `args.worktree is required — the checkout the review snapshots, got ${describeValue(worktree)}`;
997
+ }
998
+
999
+ // The absolute-path refusal the two share, for the reason the rules above
1000
+ // are: `scratch` is interpolated into the snapshot prompt's paths and the
1001
+ // result file's path, so a value that is not an absolute path names the
1002
+ // wrong directory or none, and only the runner's refusal, before its first
1003
+ // attempt, keeps that from being retried. Refused, never coerced. Null when
1004
+ // `scratch` is an absolute path.
1005
+ export function runnerScratchAbsoluteRefusal(scratch) {
1006
+ if (typeof scratch === "string" && isAbsolute(scratch)) return null;
1007
+ return `args.scratch must be an absolute path, got ${describeValue(scratch)}`;
970
1008
  }
971
1009
 
972
1010
  // --- Orchestration ----------------------------------------------------
@@ -1089,10 +1127,6 @@ async function reviewRun(host, args, run) {
1089
1127
  const pr = A.pr;
1090
1128
  const branch = A.branch;
1091
1129
  const worktree = A.worktree;
1092
- // Every dispatch label ends in `:pr${pr}`: the member id the harness derives
1093
- // from a label is all a transcript keeps of it, and member-record.mjs's
1094
- // parseMemberName reads the PR back out of that id to book its cost.
1095
- const forPr = `:pr${pr}`;
1096
1130
  const verifiersForRun = verifiersFor(A);
1097
1131
 
1098
1132
  if (!pr || !worktree) throw new Error("review-pr: args.pr and args.worktree are required");
@@ -1121,7 +1155,8 @@ async function reviewRun(host, args, run) {
1121
1155
  // shape) and one passing "42" both pass, and `null`/`undefined` answer false
1122
1156
  // — which is why this sits BELOW the required-args throw and never merged
1123
1157
  // into it: an absent `pr` is owed "required", not a complaint about digits.
1124
- if (!isDigits(pr)) throw new Error(`review-pr: args.pr must be a PR number, got ${JSON.stringify(pr)}`);
1158
+ const prRefusal = runnerPrRefusal(pr);
1159
+ if (prRefusal) throw new Error(`review-pr: ${prRefusal}`);
1125
1160
 
1126
1161
  // Nothing in the review derives a test command: every caller reads the Test
1127
1162
  // entrypoint off the Recipe cache and passes it. Refused here, beside the
@@ -1134,8 +1169,6 @@ async function reviewRun(host, args, run) {
1134
1169
  // Resolved only now: the default spawns git, so a missing or malformed `pr`
1135
1170
  // is refused on its own terms before anything is resolved or spawned.
1136
1171
  const scratch = A.scratch === undefined ? standaloneScratchRoot() : A.scratch;
1137
- const runRootParent = `${scratch}/pr${pr}`;
1138
- const runRootPrefix = `${runRootParent}/run-`;
1139
1172
 
1140
1173
  const scratchRefusal = runnerScratchRefusal(scratch);
1141
1174
  if (scratchRefusal) throw new Error(`review-pr: ${scratchRefusal}`);
@@ -1146,9 +1179,17 @@ async function reviewRun(host, args, run) {
1146
1179
  // takes the default above, so a falsy one (`0`, `false`, `""`, `null`) is
1147
1180
  // refused here like any other value that is not an absolute path. Below the
1148
1181
  // suffix check so a relative `pr<N>` still hears that it is partitioned.
1149
- if (typeof scratch !== "string" || !isAbsolute(scratch)) {
1150
- throw new Error(`review-pr: args.scratch must be an absolute path, got ${JSON.stringify(scratch)}`);
1151
- }
1182
+ const absoluteRefusal = runnerScratchAbsoluteRefusal(scratch);
1183
+ if (absoluteRefusal) throw new Error(`review-pr: ${absoluteRefusal}`);
1184
+
1185
+ // Built only now, below every refusal of `pr` and `scratch`: a Symbol cannot
1186
+ // be interpolated, and the refusals above are owed their message.
1187
+ const runRootParent = `${scratch}/pr${pr}`;
1188
+ const runRootPrefix = `${runRootParent}/run-`;
1189
+ // Every dispatch label ends in `:pr${pr}`: the member id the harness derives
1190
+ // from a label is all a transcript keeps of it, and member-record.mjs's
1191
+ // parseMemberName reads the PR back out of that id to book its cost.
1192
+ const forPr = `:pr${pr}`;
1152
1193
 
1153
1194
  // A given scratch is held to the same rule as the default: the controller
1154
1195
  // hands over the path scratch-root.mjs vetted, but nothing on this side can
@@ -32,7 +32,7 @@
32
32
  // strings are.
33
33
  import { mkdir, unlink, writeFile } from "node:fs/promises";
34
34
  import { basename, dirname, isAbsolute, join, normalize } from "node:path";
35
- import { digestOf, runReview, runnerPrRefusal, runnerScratchRefusal, runnerTestCmdRefusal, runnerWorktreeRefusal } from "./review-core.mjs";
35
+ import { digestOf, runReview, runnerPrRefusal, runnerScratchAbsoluteRefusal, runnerScratchRefusal, runnerTestCmdRefusal, runnerWorktreeRefusal } from "./review-core.mjs";
36
36
 
37
37
  // eval's `agent()` returns a HANDLE, not data: `agent(prompt,
38
38
  // opts)` resolves near-instantly to an `AgentHandle` with `.wait()`, and only
@@ -168,9 +168,8 @@ export async function runReviewToFile(args, run = runReviewOnOmp) {
168
168
  const scratch = args?.scratch;
169
169
  const prRefusal = runnerPrRefusal(pr);
170
170
  if (prRefusal) throw new Error(`review-runner: ${prRefusal}`);
171
- if (typeof scratch !== "string" || !isAbsolute(scratch)) {
172
- throw new Error(`review-runner: args.scratch must be an absolute path, got ${JSON.stringify(scratch)}`);
173
- }
171
+ const absoluteRefusal = runnerScratchAbsoluteRefusal(scratch);
172
+ if (absoluteRefusal) throw new Error(`review-runner: ${absoluteRefusal}`);
174
173
  const scratchRefusal = runnerScratchRefusal(scratch);
175
174
  if (scratchRefusal) throw new Error(`review-runner: ${scratchRefusal}`);
176
175
  const testCmdRefusal = runnerTestCmdRefusal(args.testCmd);