@feigi/fleet-ctl 3.23.33 → 3.23.34

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.23.33",
3
+ "version": "3.23.34",
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": {
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
3
3
  import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
4
4
  import { tmpdir } from "node:os";
5
5
  import { join } from "node:path";
6
+ import { stripComments } from "./strip-comments.mjs";
6
7
 
7
8
  // #516. A scan over every tracked `.mjs`/`.sh`/`.js`/`.yml` file for
8
9
  // `path.ext:NNN` found 22 line-numbered citations (plus two bare `(:NNN)`
@@ -41,7 +42,8 @@ import { join } from "node:path";
41
42
  // construct the citation names must still be named. Neither reads the cited
42
43
  // file, so nothing in this table notices the TARGET losing the construct — the
43
44
  // direction #870 closes for probe 3's citation, in
44
- // inflight-citation-prose.test.mjs, and leaves open for every entry below.
45
+ // inflight-citation-prose.test.mjs, and leaves open for every entry below
46
+ // except where the next two paragraphs say otherwise.
45
47
  //
46
48
  // One target-side check runs here, for one citation shape only (#1757): a
47
49
  // `live` needle that names an ADR by number (`ADR 0010`) is a pointer, and the
@@ -51,8 +53,14 @@ import { join } from "node:path";
51
53
  // WTROOT gives: renumber or move the ADR and this reds; repoint the needle
52
54
  // alone and the needle reds against the citing file's unchanged prose. The
53
55
  // pointer names the ADR by number, so a retitle that keeps the number keeps
54
- // the pointer true and stays green. A construct needle is still never checked
55
- // against its target.
56
+ // the pointer true and stays green.
57
+ //
58
+ // One construct needle is checked against its target too: ledger.mjs's
59
+ // "runDispatch's `keyNum` check", a pointer that names a function and a
60
+ // variable inside it. Rename either in the code and the comment points at
61
+ // nothing while its needle stays satisfied by the comment's own words, so
62
+ // runDispatchKeyNumFault reads comment-stripped ledger.mjs for both. Every
63
+ // other construct needle is still never checked against its target.
56
64
  //
57
65
  // And two claims are held by what they say, not by how they were spelled:
58
66
  // ADR 0010's security release (#1928) and its count of releases in the 43
@@ -529,7 +537,8 @@ const FILES = [
529
537
  // #2516. The `filed` subcommand's isDigits() comment pointed at
530
538
  // "(line ~1527)" for the `keyNum` check it mirrors — a line that had
531
539
  // already drifted into an unrelated comment. It names the check by its
532
- // enclosing function now.
540
+ // enclosing function now. runDispatchKeyNumFault below holds the cited
541
+ // side: the function and the check still exist under those names.
533
542
  stale: [/fleet-plugin-design\.md:200/, /candidates\.mjs:279/, /\blines?\s+~?\d+/],
534
543
  live: ["refuseIfCapped", "runDispatch's `keyNum` check"],
535
544
  },
@@ -846,6 +855,58 @@ for (const { path, stale, live } of FILES) {
846
855
  }
847
856
  }
848
857
 
858
+ // The cited side of ledger.mjs's "runDispatch's `keyNum` check" pointer: a
859
+ // top-level `function runDispatch(` (`async` or not) whose body, up to the
860
+ // first line that starts with `}`, still calls `isDigits(keyNum)`. Comments
861
+ // are stripped first, so the pointer's own comment, or the check left behind
862
+ // as a whole-line `//` or `/* */` comment, cannot stand in for the code, and
863
+ // KEYNUM_CHECK refuses a check that follows a `//` on its line. Two forms
864
+ // still can, because strip-comments.mjs blanks whole-line comments only and
865
+ // nothing here tokenizes: the check's text inside a string literal, and
866
+ // inside a block comment opened after code on the same line. Null when the
867
+ // function and the call both hold, else the reason.
868
+ const RUN_DISPATCH = /^(?:async\s+)?function\s+runDispatch\s*\(/m;
869
+ const KEYNUM_CHECK = /^(?:(?!\/\/).)*\bisDigits\(\s*keyNum\s*\)/m;
870
+
871
+ function runDispatchKeyNumFault(source) {
872
+ const code = stripComments(source);
873
+ const start = code.search(RUN_DISPATCH);
874
+ if (start === -1) return "no `function runDispatch(` outside comments";
875
+ const end = code.indexOf("\n}", start);
876
+ const body = code.slice(start, end === -1 ? undefined : end);
877
+ return KEYNUM_CHECK.test(body) ? null : "runDispatch() no longer calls `isDigits(keyNum)` outside comments";
878
+ }
879
+
880
+ test("ledger.mjs's pointer to runDispatch's `keyNum` check still lands on code", () => {
881
+ const fault = runDispatchKeyNumFault(read("scripts", "ledger.mjs"));
882
+ assert.equal(fault, null, `ledger.mjs's \`filed\` comment points at "runDispatch's \`keyNum\` check", but ${fault} — rename the pointer with its target, and RUN_DISPATCH and KEYNUM_CHECK in citation-sweep-prose.test.mjs with it`);
883
+ });
884
+
885
+ test("the runDispatch pointer reds once the function, the variable or the check's place changes", () => {
886
+ const check = " const keyNum = key;\n if (!isDigits(keyNum)) die();\n";
887
+ for (const source of [
888
+ `function runDispatchRow() {\n${check}}\n`,
889
+ "function runDispatch() {\n const keyDigits = key;\n if (!isDigits(keyDigits)) die();\n}\n",
890
+ `function runDispatch() {\n}\n\nfunction validate() {\n${check}}\n`,
891
+ "function runDispatch() {\n const keyNum = key;\n // if (!isDigits(keyNum)) die();\n}\n",
892
+ "function runDispatch() {\n const keyNum = key;\n void 0; // if (!isDigits(keyNum)) die();\n}\n",
893
+ `/*\nfunction runDispatch() {\n${check}}\n*/\n`,
894
+ `function wrapper() {\n function runDispatch() {\n${check} }\n}\n`,
895
+ `const x = 1; function runDispatch() {\n${check}}\n`,
896
+ ]) {
897
+ assert.notEqual(runDispatchKeyNumFault(source), null, source);
898
+ }
899
+ });
900
+
901
+ test("the runDispatch pointer accepts a reflowed check and ignores the comment that cites it", () => {
902
+ for (const source of [
903
+ "// isDigits() gates id the same way runDispatch's `keyNum` check gates\nasync function runDispatch() {\n if (keyNum !== null && !isDigits( keyNum )) die();\n}\n",
904
+ "function runDispatch() {\n const keyNum = key;\n if (!isDigits(keyNum)) die();\n}\n",
905
+ ]) {
906
+ assert.equal(runDispatchKeyNumFault(source), null, source);
907
+ }
908
+ });
909
+
849
910
  test("an ADR pointer resolves by number alone, so a retitled ADR still answers to it", () => {
850
911
  assert.equal(adrFault("0010", ["0009-supported-platforms-are-macos-linux-wsl.md", "0010-a-retitled-ruling.md"]), null);
851
912
  });