@feigi/fleet-ctl 3.59.0 → 3.60.0
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/fleet-tick.mjs +124 -9
- package/skills/run-team/SKILL.md +3 -1
package/package.json
CHANGED
package/scripts/fleet-tick.mjs
CHANGED
|
@@ -78,6 +78,17 @@
|
|
|
78
78
|
// take the registry census, never an action: it resets no
|
|
79
79
|
// `quiet`, changes no row and frees no slot, and the tick never
|
|
80
80
|
// settles or kills anything.
|
|
81
|
+
// reports `<scratch>/reports/<member>.json`, the report file a member
|
|
82
|
+
// writes beside the message it sends, for every live member
|
|
83
|
+
// token. `<scratch>` is the phase-0 receipt's `scratch`, else
|
|
84
|
+
// `--scratch`; with neither the check is skipped with one stderr
|
|
85
|
+
// line. A file on disk prints one `SETTLE <member>` line naming
|
|
86
|
+
// the `ledger.mjs settle <member> --from-report` it is for, and
|
|
87
|
+
// one whose `member` is not its filename's prints REPORT-MISMATCH
|
|
88
|
+
// instead; one that is there but cannot be read prints
|
|
89
|
+
// REPORT-UNREADABLE. Advice, like CHECK-LIVENESS: the tick
|
|
90
|
+
// settles nothing. A review runner has no report schema and files
|
|
91
|
+
// none, so no `review=` token is looked up.
|
|
81
92
|
//
|
|
82
93
|
// The pure half below is `reconcile()` over the counts `deriveRun()` reads off
|
|
83
94
|
// the ledger; main() does the I/O. Split so the guard table and the reading are
|
|
@@ -883,6 +894,7 @@ export function deriveRun({ rows, dispatched, drain }, prs, closed = new Set(),
|
|
|
883
894
|
// PR nobody has asked about keeps its review live.
|
|
884
895
|
const reviewing = [...byPr.entries()].filter(([, st]) => st.inFlight);
|
|
885
896
|
const liveReviews = reviewing.filter(([n]) => open.has(n) || !finished.has(n));
|
|
897
|
+
const unsettled = all.filter((m) => m.outcome === null).map((m) => m.name);
|
|
886
898
|
return {
|
|
887
899
|
implLive: live("impl"),
|
|
888
900
|
fixLive: live("fix-pr"),
|
|
@@ -967,9 +979,13 @@ export function deriveRun({ rows, dispatched, drain }, prs, closed = new Set(),
|
|
|
967
979
|
// member token, then each in-flight review by its PR — a `review=wf:`
|
|
968
980
|
// run carries no member token of its own.
|
|
969
981
|
live: [
|
|
970
|
-
...
|
|
982
|
+
...unsettled,
|
|
971
983
|
...liveReviews.map(([n]) => `review:PR#${n}`),
|
|
972
984
|
],
|
|
985
|
+
// Who may have a report file on disk, by the name it is filed under: every
|
|
986
|
+
// unsettled member token. A review runner has no report schema and a
|
|
987
|
+
// `review=wf:` run no member, so neither files one.
|
|
988
|
+
reporters: unsettled,
|
|
973
989
|
};
|
|
974
990
|
}
|
|
975
991
|
|
|
@@ -1077,6 +1093,45 @@ export function livenessLines({ live, seen, thresholds, now }) {
|
|
|
1077
1093
|
return out;
|
|
1078
1094
|
}
|
|
1079
1095
|
|
|
1096
|
+
// The report lines: one per name in `reporters` with a report file on disk, as
|
|
1097
|
+
// `{member, settle, line, key}`. `reports` maps a name to what main() read off
|
|
1098
|
+
// its file — `{path, since, member}`, `since` the file's mtime in ms and
|
|
1099
|
+
// `member` the file's own `member` field, undefined when it has none or is
|
|
1100
|
+
// not JSON, or `{path, unreadable}`, `unreadable` the error code of a file
|
|
1101
|
+
// that is there and cannot be read — and has no entry for a name with no file.
|
|
1102
|
+
// A file that names a member other than the one it is filed under prints
|
|
1103
|
+
// REPORT-MISMATCH instead, once, and an unreadable one REPORT-UNREADABLE; for
|
|
1104
|
+
// both `settle` is false. `reportsFrom`, when set, is the directory the
|
|
1105
|
+
// printed settle reads its file from: ledger.mjs reads the default scratch
|
|
1106
|
+
// root's `reports/` unless told otherwise. `key` is the line without its age,
|
|
1107
|
+
// what the digest `--fold-unchanged` compares takes, so a report waiting on
|
|
1108
|
+
// disk folds rather than moving the digest every minute.
|
|
1109
|
+
export function reportLines({ reporters, reports, now, reportsFrom = null }) {
|
|
1110
|
+
const out = [];
|
|
1111
|
+
const from = reportsFrom === null ? "" : ` --reports ${/^[\w./@%+=:,-]+$/.test(reportsFrom) ? reportsFrom : `'${reportsFrom.replaceAll("'", "'\\''")}'`}`;
|
|
1112
|
+
for (const member of new Set(reporters)) {
|
|
1113
|
+
const r = reports.get(member);
|
|
1114
|
+
if (r === undefined) continue;
|
|
1115
|
+
if (r.unreadable !== undefined) {
|
|
1116
|
+
const line = `REPORT-UNREADABLE ${r.path} (${r.unreadable})`;
|
|
1117
|
+
out.push({ member, settle: false, line, key: line });
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
if (r.member !== member) {
|
|
1121
|
+
const named = typeof r.member === "string" ? r.member : JSON.stringify(r.member) ?? "none";
|
|
1122
|
+
const line = `REPORT-MISMATCH ${r.path} (member: ${named})`;
|
|
1123
|
+
out.push({ member, settle: false, line, key: line });
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
const age = Math.floor(Math.max(0, now - r.since) / 60_000);
|
|
1127
|
+
out.push({
|
|
1128
|
+
member, settle: true, key: `SETTLE ${member}`,
|
|
1129
|
+
line: `SETTLE ${member} (report on disk since ${age}m — ledger.mjs settle ${member} --from-report${from})`,
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
return out;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1080
1135
|
// --apply's pure half. The merge-bot numbers `applied.reapAfter` names for
|
|
1081
1136
|
// THIS run: none when its `run` is not the controller record's `at`, since
|
|
1082
1137
|
// merge-bot numbering restarts with a run and the state file outlives it
|
|
@@ -1139,7 +1194,7 @@ export function reclaimSummary(stdout) {
|
|
|
1139
1194
|
|
|
1140
1195
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
1141
1196
|
import { createHash } from "node:crypto";
|
|
1142
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
1197
|
+
import { mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
1143
1198
|
import { tmpdir } from "node:os";
|
|
1144
1199
|
import { dirname, join } from "node:path";
|
|
1145
1200
|
import { fileURLToPath } from "node:url";
|
|
@@ -1152,6 +1207,7 @@ import { statePath, readState, writeState, assessBeat, isStalled, isReported, st
|
|
|
1152
1207
|
import { checkMainCheckout, describe } from "./main-checkout.mjs";
|
|
1153
1208
|
import { readRunReceipt, phase0Gate } from "./phase0-receipt.mjs";
|
|
1154
1209
|
import { judgeRecord, ProcUnreadable } from "./proc.mjs";
|
|
1210
|
+
import { reportPath, reportsDir } from "./report-files.mjs";
|
|
1155
1211
|
|
|
1156
1212
|
const NAME = "fleet-tick";
|
|
1157
1213
|
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
@@ -1221,6 +1277,10 @@ const OPTIONS = {
|
|
|
1221
1277
|
// under parseArgs, and no path is legitimately empty, so empty resolves to
|
|
1222
1278
|
// the default.
|
|
1223
1279
|
state: { type: "string", default: "" },
|
|
1280
|
+
// The scratch root the report files are under, for a run whose phase-0
|
|
1281
|
+
// receipt names none; the receipt's `scratch` wins when it does. Empty is
|
|
1282
|
+
// absent, as with --state.
|
|
1283
|
+
scratch: { type: "string", default: "" },
|
|
1224
1284
|
// Minutes a live token of each family may run before CHECK-LIVENESS names it.
|
|
1225
1285
|
...Object.fromEntries(Object.entries(LIVENESS_FLAGS).map(([family, flag]) => [flag, { type: "string", default: String(LIVENESS_DEFAULTS[family]) }])),
|
|
1226
1286
|
};
|
|
@@ -1252,7 +1312,7 @@ function options() {
|
|
|
1252
1312
|
return {
|
|
1253
1313
|
implCap: positive("implementer-cap"), reviewerCap,
|
|
1254
1314
|
maxReviews: values["max-reviews"] === undefined ? reviewerCap : positive("max-reviews"),
|
|
1255
|
-
fold: values["fold-unchanged"], apply: values.apply, state: values.state || statePath(NAME),
|
|
1315
|
+
fold: values["fold-unchanged"], apply: values.apply, state: values.state || statePath(NAME), scratch: values.scratch,
|
|
1256
1316
|
liveness: Object.fromEntries(Object.entries(LIVENESS_FLAGS).map(([family, flag]) => [family, positive(flag)])),
|
|
1257
1317
|
};
|
|
1258
1318
|
}
|
|
@@ -1621,8 +1681,48 @@ function readRun(prs) {
|
|
|
1621
1681
|
}
|
|
1622
1682
|
}
|
|
1623
1683
|
|
|
1684
|
+
// The scratch root the report files are under, and whether it came from
|
|
1685
|
+
// `--scratch`: the phase-0 receipt's `scratch`, else `--scratch`, else null —
|
|
1686
|
+
// no root, no check. `ledger.mjs settle --from-report` reads the root
|
|
1687
|
+
// scratch-root.mjs prints unless given `--reports`, so a root named by the
|
|
1688
|
+
// flag is one the printed settle must be told.
|
|
1689
|
+
function reportsScratch(receipt, flag) {
|
|
1690
|
+
const named = receipt.read.state === "ok" ? receipt.read.receipt.scratch : undefined;
|
|
1691
|
+
if (typeof named === "string" && named !== "") return { root: named, flagged: false };
|
|
1692
|
+
return flag === "" ? null : { root: flag, flagged: true };
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
// The report file of each name in `reporters`, as reportLines() takes them:
|
|
1696
|
+
// `{path, since, member}` per file on disk, `{path, unreadable}` for one that
|
|
1697
|
+
// cannot be read, nothing for a name with none. Only `member` is read out of a
|
|
1698
|
+
// file, and a file that is not JSON carries none.
|
|
1699
|
+
function readReports(scratch, reporters) {
|
|
1700
|
+
const out = new Map();
|
|
1701
|
+
for (const member of reporters) {
|
|
1702
|
+
const path = reportPath(scratch, member);
|
|
1703
|
+
let since, text;
|
|
1704
|
+
try {
|
|
1705
|
+
since = statSync(path).mtimeMs;
|
|
1706
|
+
text = readFileSync(path, "utf8");
|
|
1707
|
+
} catch (e) {
|
|
1708
|
+
if (e.code === "ENOENT" || e.code === "ENOTDIR") continue;
|
|
1709
|
+
out.set(member, { path, unreadable: e.code ?? "unknown error" });
|
|
1710
|
+
continue;
|
|
1711
|
+
}
|
|
1712
|
+
let named;
|
|
1713
|
+
try {
|
|
1714
|
+
const d = JSON.parse(text);
|
|
1715
|
+
named = d !== null && typeof d === "object" && !Array.isArray(d) ? d.member : undefined;
|
|
1716
|
+
} catch {
|
|
1717
|
+
named = undefined;
|
|
1718
|
+
}
|
|
1719
|
+
out.set(member, { path, since, member: named });
|
|
1720
|
+
}
|
|
1721
|
+
return out;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1624
1724
|
function main() {
|
|
1625
|
-
const { fold, apply, state: path, liveness, ...caps } = options();
|
|
1725
|
+
const { fold, apply, state: path, liveness, scratch: scratchFlag, ...caps } = options();
|
|
1626
1726
|
const listPath = shortlistPath();
|
|
1627
1727
|
const current = readShortlist(listPath);
|
|
1628
1728
|
// Beside the shortlist, off the same git probe rather than a second one.
|
|
@@ -1734,6 +1834,12 @@ function main() {
|
|
|
1734
1834
|
...caps, ...run, heads, supply, dropped, shortlistStatus: current.status, refresh: fresh, mainCheckout, phase0, router,
|
|
1735
1835
|
});
|
|
1736
1836
|
const said = describe(mainCheckout, run.live);
|
|
1837
|
+
// The report files of the live members, read before the state file for the
|
|
1838
|
+
// reason given below. A member's report on disk is the outcome its message
|
|
1839
|
+
// was to carry, whether or not that message arrived.
|
|
1840
|
+
const scratch = reportsScratch(receipt, scratchFlag);
|
|
1841
|
+
if (scratch === null) console.error(`${NAME}: report files not checked — no scratch in the phase-0 receipt and no --scratch`);
|
|
1842
|
+
const reports = scratch === null ? new Map() : readReports(scratch.root, run.reporters);
|
|
1737
1843
|
// Re-read rather than reusing priorState: this must be the freshest
|
|
1738
1844
|
// snapshot, or this tick reverts whatever the heartbeat wrote while the
|
|
1739
1845
|
// reads above were in flight. Read before the lines are built because the
|
|
@@ -1746,18 +1852,24 @@ function main() {
|
|
|
1746
1852
|
// and frees no slot — and nothing here settles, kills or writes the ledger.
|
|
1747
1853
|
const seen = stampSeen({ live: run.live, prev: prev.seen, controller: prev.controller, now });
|
|
1748
1854
|
const stale = livenessLines({ live: run.live, seen, thresholds: liveness, now });
|
|
1749
|
-
|
|
1855
|
+
// Advisory the same way: a report on disk prints the settle it is for, and
|
|
1856
|
+
// nothing here runs it.
|
|
1857
|
+
const reported = reportLines({ reporters: run.reporters, reports, now, reportsFrom: scratch?.flagged ? reportsDir(scratch.root) : null });
|
|
1858
|
+
const above = [...(phase0.line === null ? [] : [phase0.line]), ...(said === null ? [] : [said]), ...stale.map((s) => s.line)];
|
|
1859
|
+
const rowLines = formatLines(rows);
|
|
1750
1860
|
// The run is over once it is draining and nothing is left in flight: no
|
|
1751
1861
|
// open PR and no implementer still holding a claim. Printed last and read
|
|
1752
1862
|
// as actionable, so it never folds away: the stop it names is the run's
|
|
1753
1863
|
// last act, and only the controller can write it.
|
|
1754
1864
|
const over = run.draining !== null && prs.length === 0 && run.implLive === 0;
|
|
1755
|
-
if (over)
|
|
1865
|
+
if (over) rowLines.push(RUN_OVER);
|
|
1866
|
+
const lines = [...above, ...reported.map((r) => r.line), ...rowLines];
|
|
1756
1867
|
|
|
1757
1868
|
// The back-off streak and the fold digest, written on EVERY tick: an edge
|
|
1758
1869
|
// tick that dispatched is the clearest possible "there is work here". Digest,
|
|
1759
|
-
// not the lines themselves, so the file stays readable.
|
|
1760
|
-
|
|
1870
|
+
// not the lines themselves, so the file stays readable. A report line goes in
|
|
1871
|
+
// without its age.
|
|
1872
|
+
const digest = createHash("sha256").update([...above, ...reported.map((r) => r.key), ...rowLines].join("\n")).digest("hex");
|
|
1761
1873
|
const acts = actionable(rows) || over;
|
|
1762
1874
|
// `seen` is pruned to the live set on the same write; an empty one removes
|
|
1763
1875
|
// the key. A file that was degraded at this read is left byte-identical, so
|
|
@@ -1784,11 +1896,14 @@ function main() {
|
|
|
1784
1896
|
// `quiet`, and named on the folded line for as long as it stays live
|
|
1785
1897
|
// past its threshold. The digest already moves when its bucket does.
|
|
1786
1898
|
const aged = stale.map((s) => `; CHECK-LIVENESS ${s.member} persists`).join("");
|
|
1899
|
+
// A report waiting on disk persists the same way, for as long as its
|
|
1900
|
+
// member stays live.
|
|
1901
|
+
const settle = reported.filter((r) => r.settle).map((r) => `; SETTLE ${r.member} persists`).join("");
|
|
1787
1902
|
// The to-spec drops the same way: advice, and the one reason an empty
|
|
1788
1903
|
// shortlist is not "no work".
|
|
1789
1904
|
const specs = specsDropped(dropped);
|
|
1790
1905
|
const drops = specs ? `; ${specs} persists` : "";
|
|
1791
|
-
console.log(`fleet-tick: unchanged, nothing to act on (quiet=${prev.quiet + 1})${held}${aged}${drops} — full rows on the next change`);
|
|
1906
|
+
console.log(`fleet-tick: unchanged, nothing to act on (quiet=${prev.quiet + 1})${held}${aged}${settle}${drops} — full rows on the next change`);
|
|
1792
1907
|
return;
|
|
1793
1908
|
}
|
|
1794
1909
|
for (const line of lines) console.log(line);
|
package/skills/run-team/SKILL.md
CHANGED
|
@@ -52,7 +52,9 @@ attribute the gap to the member until it answers.** A member re-sending on a
|
|
|
52
52
|
named request should state the original's msg_id and that it is a re-send, which
|
|
53
53
|
is what distinguishes a lost message from a member that never sent one; a
|
|
54
54
|
controller that skips the ask cannot tell those apart and will guess wrong in
|
|
55
|
-
whichever direction its expectations point.
|
|
55
|
+
whichever direction its expectations point. The tick prints `SETTLE <member>`
|
|
56
|
+
for a report file on disk, so a missing message is read off that line before
|
|
57
|
+
anyone is pinged.
|
|
56
58
|
|
|
57
59
|
Note this cuts against the paragraph above only in appearance: the default stays
|
|
58
60
|
*send once*, because unprompted re-sends were measured 2-to-1 false. The ask is
|