@feigi/fleet-ctl 3.158.4 → 3.158.6
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
|
@@ -113,6 +113,13 @@ export function memberTokens(text) {
|
|
|
113
113
|
return text.split(/\s+/).filter(Boolean).map(parseToken).filter(Boolean);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/** Whether `word` is a settled member token: one parseToken() reads with no
|
|
117
|
+
* error and an outcome. */
|
|
118
|
+
function isSettledToken(word) {
|
|
119
|
+
const t = parseToken(word);
|
|
120
|
+
return t !== null && t.error === null && t.outcome !== null;
|
|
121
|
+
}
|
|
122
|
+
|
|
116
123
|
/** The dispatch-prompt.mjs role a member of `family` is rendered as. */
|
|
117
124
|
export function memberRole(family) {
|
|
118
125
|
return FAMILIES[family].role;
|
|
@@ -511,6 +518,24 @@ export function gateVerdictRefusal(oldLine, line) {
|
|
|
511
518
|
return `reorders its Gate verdicts — ${carried}`;
|
|
512
519
|
}
|
|
513
520
|
|
|
521
|
+
/**
|
|
522
|
+
* Why `ledger.mjs row` must not write `line` over `oldLine` (null for a new
|
|
523
|
+
* row), or null when it may: every settled member token the row holds — a
|
|
524
|
+
* token parseToken() reads with no error and an outcome — must be on the
|
|
525
|
+
* rewrite as the row holds it, duplicates counted. A token whose outcome
|
|
526
|
+
* changed is a dropped one, since its old text is gone. The reason names the
|
|
527
|
+
* first dropped token, in the row's order. A live member token may come or go,
|
|
528
|
+
* and a malformed one may be dropped (adding one is refused by the caller's
|
|
529
|
+
* own malformed-token check), so a row can still be repaired.
|
|
530
|
+
*/
|
|
531
|
+
export function settledMemberRefusal(oldLine, line) {
|
|
532
|
+
const settled = (text) => (text === null ? [] : text.split(/\s+/).filter(isSettledToken));
|
|
533
|
+
const lost = added(settled(line), settled(oldLine))[0];
|
|
534
|
+
if (lost === undefined) return null;
|
|
535
|
+
return `drops settled member token '${lost}' — a rewrite must carry every settled member token as the row holds it; `
|
|
536
|
+
+ "pass the complete reconstructed line, use `ledger.mjs token` to add a non-member token, and `ledger.mjs read` to look a row up";
|
|
537
|
+
}
|
|
538
|
+
|
|
514
539
|
// Every row key a ledger's rows map to each PR number under rowNums(), in
|
|
515
540
|
// ledger order.
|
|
516
541
|
function prRowKeys(rows) {
|
|
@@ -634,8 +659,7 @@ export function rowWriteRefusal(before, after, oldLine, line, retired = []) {
|
|
|
634
659
|
export function settledOnLedger(rows, dispatched) {
|
|
635
660
|
const settled = new Set();
|
|
636
661
|
for (const e of dispatched) {
|
|
637
|
-
|
|
638
|
-
if (t !== null && t.error === null && t.outcome !== null) settled.add(t.name);
|
|
662
|
+
if (isSettledToken(e)) settled.add(parseToken(e).name);
|
|
639
663
|
}
|
|
640
664
|
for (const text of rows) {
|
|
641
665
|
const { pr } = rowNums(text);
|
package/scripts/ledger.mjs
CHANGED
|
@@ -45,9 +45,12 @@
|
|
|
45
45
|
// and `review --result` for the third, which it derives from the review's
|
|
46
46
|
// result file and refuses as an argument. `token`
|
|
47
47
|
// refuses all three, and `row` carries every Gate verdict exactly as the row
|
|
48
|
-
// holds it, so no other verb adds, changes or drops one. `
|
|
49
|
-
//
|
|
50
|
-
//
|
|
48
|
+
// holds it, so no other verb adds, changes or drops one. `row` likewise
|
|
49
|
+
// carries every settled member token — a member token with an outcome — as
|
|
50
|
+
// the row holds it, so a `row` call made as a lookup cannot erase the row's
|
|
51
|
+
// PR mapping; a live or malformed member token it may still drop. `filed`
|
|
52
|
+
// appends filings, and all writes are serialized by `<file>.lock`; the other
|
|
53
|
+
// tokens of a row are freeform to the writers that have them (`row`/`token`/
|
|
51
54
|
// `settle`/`dispatch`/`drain`/`ruled`/`rotate`). Every write subcommand
|
|
52
55
|
// except `rotate` — which moves the file whole and never loads it, see
|
|
53
56
|
// runRotate() — rewrites the WHOLE file
|
|
@@ -71,7 +74,7 @@ import { spawnSync, execFileSync } from "node:child_process";
|
|
|
71
74
|
import { makeDie, isFlagLike, hasEqualsForm, isDigits, writeAll } from "./arg.mjs";
|
|
72
75
|
import { fleetFile, FleetDirUnresolvable } from "./fleet-dir.mjs";
|
|
73
76
|
import { readReceipt } from "./phase0-receipt.mjs";
|
|
74
|
-
import { parseMember, parseToken, memberTokens, nextMergeBot, nextRetry, liveOnLedger, settledOnLedger, retiredOnLedger, retiredName, readRetired, agentDefinition, expectedDefinition, CELL, POLICY_CELL, tierValues, cellValues, decidingCell, rowPr, rowNums, rowWriteRefusal, isReviewToken, addedReviewToken, isDispositionsWord, gateVerdictWriter, gateVerdictRefusal, newSplitRow, splitRowClause, added, premisesOf, MEMBER_FAMILIES, HALT_CAUSES, ROWS, DISPATCHED, ROUTED, FILED, RULED, DRAIN, RETIRED, RECEIPT, archiveStamp, receiptArchiveName, CLOSEOUT_RECEIPT, closeoutArchiveName, BRIEFS, briefsArchiveName, memberRole, parseDispatchedEntry, dispatchedEntry, parseRouting, parseRoutedEntry, routedEntry, headerRe, escapeText, ledgerSection, nextReviewerName, isOmpSessionDirName } from "./ledger-grammar.mjs";
|
|
77
|
+
import { parseMember, parseToken, memberTokens, nextMergeBot, nextRetry, liveOnLedger, settledOnLedger, retiredOnLedger, retiredName, readRetired, agentDefinition, expectedDefinition, CELL, POLICY_CELL, tierValues, cellValues, decidingCell, rowPr, rowNums, rowWriteRefusal, isReviewToken, addedReviewToken, isDispositionsWord, gateVerdictWriter, gateVerdictRefusal, settledMemberRefusal, newSplitRow, splitRowClause, added, premisesOf, MEMBER_FAMILIES, HALT_CAUSES, ROWS, DISPATCHED, ROUTED, FILED, RULED, DRAIN, RETIRED, RECEIPT, archiveStamp, receiptArchiveName, CLOSEOUT_RECEIPT, closeoutArchiveName, BRIEFS, briefsArchiveName, memberRole, parseDispatchedEntry, dispatchedEntry, parseRouting, parseRoutedEntry, routedEntry, headerRe, escapeText, ledgerSection, nextReviewerName, isOmpSessionDirName } from "./ledger-grammar.mjs";
|
|
75
78
|
import { deriveRun, LedgerError, labelOffMember, CONFLICT_HOLD, PARKED } from "./fleet-tick.mjs";
|
|
76
79
|
import { stateFileIn, readState, writeState, assessBeat, stallsAt } from "./fleet-state.mjs";
|
|
77
80
|
import { processSource, ancestry, controllerOf, judgeController, ProcUnreadable } from "./proc.mjs";
|
|
@@ -812,6 +815,11 @@ if (cmd === "read") {
|
|
|
812
815
|
// also refuses a whole-row wipe of a row that holds one.
|
|
813
816
|
const gateWhy = gateVerdictRefusal(oldRow, line);
|
|
814
817
|
if (gateWhy !== null) die(`row ${key}: ${gateWhy}`);
|
|
818
|
+
// Every settled member token is the PR's mapping and the member's record, so
|
|
819
|
+
// a rewrite carries each as the row holds it — a `row` call made as a lookup
|
|
820
|
+
// would otherwise sever the PR from its ticket.
|
|
821
|
+
const settledWhy = settledMemberRefusal(oldRow, line);
|
|
822
|
+
if (settledWhy !== null) die(`row ${key}: ${settledWhy}`);
|
|
815
823
|
// Every token about a PR lives on the PR's row, so a write that makes a PR
|
|
816
824
|
// map to a second row splits its history across two rows the tick reads in
|
|
817
825
|
// row order, not write order. Added only: a split already on disk is
|
|
@@ -2777,13 +2785,19 @@ function recordFiled(id, subject) {
|
|
|
2777
2785
|
// impl-N=blocked nothing to check: report-schema.mjs already
|
|
2778
2786
|
// refuses a block that names a bailCause, a pr or
|
|
2779
2787
|
// a head, or gives no reason in bailDetail
|
|
2780
|
-
// fix-pr-M=applied:<head>
|
|
2781
|
-
//
|
|
2782
|
-
//
|
|
2783
|
-
//
|
|
2784
|
-
//
|
|
2785
|
-
//
|
|
2786
|
-
//
|
|
2788
|
+
// fix-pr-M=applied:<head> the report's branch is PR M's head branch, as
|
|
2789
|
+
// GitHub names it (PR M need not read OPEN, and
|
|
2790
|
+
// its head SHA is not compared: a rebase moves
|
|
2791
|
+
// it); then, only once that and every other check
|
|
2792
|
+
// passed: origin's refs/heads/<branch> is <head>,
|
|
2793
|
+
// fetched by verify-sha.sh; the Check-step record
|
|
2794
|
+
// (below) holds for <head>
|
|
2795
|
+
// fix-pr-M=no-op the report's branch is PR M's head branch, as
|
|
2796
|
+
// above; then, only once that and every other
|
|
2797
|
+
// check passed: origin's refs/heads/<branch> is
|
|
2798
|
+
// PR M's fleet head, as the tick folds it: the
|
|
2799
|
+
// head of the applied:<head> the fix-applier with
|
|
2800
|
+
// the greatest retry suffix landed since PR M's
|
|
2787
2801
|
// latest reviewed=, else the head that reviewed=
|
|
2788
2802
|
// names
|
|
2789
2803
|
// finisher-pr-M=labelled PR M's labels carry ready-to-merge, and so does
|
|
@@ -2987,18 +3001,22 @@ async function runSettleFromReport() {
|
|
|
2987
3001
|
check(`bailCause: ${report.bailCause}`, report.bailCause !== null);
|
|
2988
3002
|
}
|
|
2989
3003
|
} else if (live.family === "fix-pr") {
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
}
|
|
3000
|
-
|
|
3001
|
-
|
|
3004
|
+
// `applied` and `no-op` claim the state of a pushed branch; `failed`
|
|
3005
|
+
// claims none and is settled unchecked.
|
|
3006
|
+
const claimsBranch = report.outcome === "applied" || report.outcome === "no-op";
|
|
3007
|
+
if (claimsBranch) {
|
|
3008
|
+
// The branch the report names must be the one PR M is headed on, so the
|
|
3009
|
+
// head read from origin below is the PR's own. GitHub is asked first and
|
|
3010
|
+
// nothing is read from git: a report naming another branch is refused
|
|
3011
|
+
// whatever origin holds. A replacement fix-pr-M-x checks against the same
|
|
3012
|
+
// PR M, and PR M need not read OPEN: only its head branch is asked.
|
|
3013
|
+
const { headRefName } = prView(live.number, "headRefName");
|
|
3014
|
+
check(`the report's branch is PR #${live.number}'s head branch (report: ${report.branch}, GitHub: ${headRefName})`, report.branch === headRefName);
|
|
3015
|
+
}
|
|
3016
|
+
outcome = report.outcome === "applied" ? `applied:${report.head}` : report.outcome;
|
|
3017
|
+
// The head origin must hold for a `no-op`, with the reason it is that one.
|
|
3018
|
+
let required = null;
|
|
3019
|
+
if (report.outcome === "no-op") {
|
|
3002
3020
|
let fold;
|
|
3003
3021
|
try {
|
|
3004
3022
|
fold = deriveRun({ rows: data.rows, dispatched: data.dispatched, drain: data.drain }, []);
|
|
@@ -3014,16 +3032,11 @@ async function runSettleFromReport() {
|
|
|
3014
3032
|
if (review === undefined) {
|
|
3015
3033
|
check(`PR #${live.number}'s row names a reviewed= head`, false);
|
|
3016
3034
|
} else {
|
|
3017
|
-
const
|
|
3018
|
-
const required = review.fleetHead;
|
|
3019
|
-
const why = required === review.head
|
|
3035
|
+
const why = review.fleetHead === review.head
|
|
3020
3036
|
? `the head PR #${live.number}'s latest reviewed= names`
|
|
3021
3037
|
: `the head PR #${live.number}'s latest applied: names, landed since its latest reviewed= ${review.head}`;
|
|
3022
|
-
|
|
3023
|
-
head !== null && head.toLowerCase().startsWith(required));
|
|
3038
|
+
required = { head: review.fleetHead, why };
|
|
3024
3039
|
}
|
|
3025
|
-
} else {
|
|
3026
|
-
outcome = "failed";
|
|
3027
3040
|
}
|
|
3028
3041
|
const refuted = report.deferred.filter((d) => d.bucket === "refuted");
|
|
3029
3042
|
if (refuted.length > 0) {
|
|
@@ -3043,6 +3056,21 @@ async function runSettleFromReport() {
|
|
|
3043
3056
|
}
|
|
3044
3057
|
}
|
|
3045
3058
|
}
|
|
3059
|
+
// git is read last, and only once every check above has passed.
|
|
3060
|
+
if (claimsBranch && checks.every((c) => c.ok)) {
|
|
3061
|
+
const head = remoteHead(report.branch);
|
|
3062
|
+
if (report.outcome === "applied") {
|
|
3063
|
+
if (check(`origin refs/heads/${report.branch} is ${report.head}`, head === report.head)) {
|
|
3064
|
+
// verify-sha.sh is the fetch that puts the head's commit object here,
|
|
3065
|
+
// which the tree read needs; its exit 2 is a fetch that failed or an
|
|
3066
|
+
// object that is not there, so it could not look.
|
|
3067
|
+
recipeGate(report.head, () => verifyShaOf(report.branch, report.head));
|
|
3068
|
+
}
|
|
3069
|
+
} else {
|
|
3070
|
+
check(`origin refs/heads/${report.branch} is ${required.head}, ${required.why}`,
|
|
3071
|
+
head !== null && head.toLowerCase().startsWith(required.head));
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3046
3074
|
} else if (live.family === "finisher-pr") {
|
|
3047
3075
|
if (report.outcome === "labelled") {
|
|
3048
3076
|
outcome = "labelled";
|
package/skills/run-team/SKILL.md
CHANGED
|
@@ -213,7 +213,7 @@ Write each state change through `ledger.mjs` before you act on it, never by hand
|
|
|
213
213
|
|
|
214
214
|
Compaction parks every in-flight member and nothing reports it, so on resume take the registry census first (**Member unaccounted**, in **Failure handling**) before you trust a live token.
|
|
215
215
|
|
|
216
|
-
`ledger.mjs token <key> <token>…` adds a token and keeps every token already on the row but a `tier=` it replaces; `row` drops
|
|
216
|
+
`ledger.mjs token <key> <token>…` adds a token and keeps every token already on the row but a `tier=` it replaces; `row` drops tokens you omit but refuses to drop a settled member token. Write member and `review=` tokens only through `ledger.mjs`.
|
|
217
217
|
|
|
218
218
|
Never rotate the ledger mid-run: it is phase 0's step alone.
|
|
219
219
|
|
|
@@ -118,4 +118,4 @@ The ledger half reports its own readability as its own field, `ledger.ok`, the p
|
|
|
118
118
|
|
|
119
119
|
## Adding a token
|
|
120
120
|
|
|
121
|
-
Token additions go through `ledger.mjs token`. `ledger.mjs token <key> <token>…` adds a token and keeps every token already on the row. A `tier=` replaces the row's `tier=` instead and keeps every other token, a `cell=` beside it included, which the `tier=` then overrides; while the row's implementer has not settled, `token` and `row` both refuse a write that changes the row's cell. Re-typing the row with `row` replaces the whole line, so it drops the tokens you do not restate.
|
|
121
|
+
Token additions go through `ledger.mjs token`. `ledger.mjs token <key> <token>…` adds a token and keeps every token already on the row. A `tier=` replaces the row's `tier=` instead and keeps every other token, a `cell=` beside it included, which the `tier=` then overrides; while the row's implementer has not settled, `token` and `row` both refuse a write that changes the row's cell. Re-typing the row with `row` replaces the whole line, so it drops the tokens you do not restate — except a settled member token (`impl-<N>=PR#<M>`, `fix-pr-<M>=applied:<head>`, `finisher-pr-<M>=labelled`, any well-formed member token carrying an outcome), which `row` refuses to drop: it exits 2 and writes nothing for a rewrite that omits one or changes its outcome, naming the first, so a rewrite carries every settled member token as the row holds it, in any order. A live member token, and a malformed one, may still be dropped; every other dropped token is written and listed on stderr. `row` is not a lookup: read a row with `ledger.mjs read`, which writes nothing.
|
|
@@ -659,8 +659,12 @@ files under `<scratch>/impl-<N>/`). Record it the ordinary way —
|
|
|
659
659
|
"impl-<N>-b"`, then `dispatch-prompt.mjs render implementer --member
|
|
660
660
|
impl-<N>-b …`, then `ledger.mjs dispatch <N> impl-<N>-b`, then the `task`
|
|
661
661
|
call naming the `agent` it printed, then the tier check — and never
|
|
662
|
-
`claim-ticket.sh`: the claim already stands. A
|
|
663
|
-
|
|
662
|
+
`claim-ticket.sh`: the claim already stands. A `replace #N` writes onto a
|
|
663
|
+
row that already stands, holding the closed PR's settled `impl-<N>=PR#<M>`,
|
|
664
|
+
which `row` refuses to drop, so its row write carries the row whole, the
|
|
665
|
+
way `release #N`'s does: `ledger.mjs row <N> "<text> · impl-<N>-b"`,
|
|
666
|
+
`<text>` the row as `ledger.mjs read` prints it, past its leading `#<N>`.
|
|
667
|
+
A re-run finds the need met once its row is written. A `report` goes to the
|
|
664
668
|
maintainer as `#<N> — <why>` and nothing else: no dispatch, no label change,
|
|
665
669
|
no release. One whose `why` reads `PR #<M> closed unmerged` waits on the
|
|
666
670
|
maintainer's `replace #<N>` or `release #<N>`, the two words the tick's
|