@feigi/fleet-ctl 3.158.14 → 3.158.16
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/dispatch-prompt.mjs +45 -18
- package/scripts/ledger-grammar.mjs +36 -3
- package/scripts/ledger.mjs +4 -9
- package/scripts/pull.mjs +82 -47
- package/scripts/ticket-text.mjs +0 -5
- package/skills/run-team/SKILL.md +1 -1
- package/skills/run-team/briefs/fix-applier.md +2 -1
- package/skills/run-team/briefs/implementer.md +4 -1
- package/skills/run-team/references/pull.md +16 -0
package/package.json
CHANGED
|
@@ -48,9 +48,11 @@
|
|
|
48
48
|
// holds one directive per line:
|
|
49
49
|
// arg <flag> <placeholder> the argument `--<flag>` fills `<placeholder>`
|
|
50
50
|
// path <flag> that argument must be an absolute path
|
|
51
|
+
// free <flag> that argument is free text (THE LEFTOVER CHECK)
|
|
51
52
|
// literal <text> `<text>` is carried to the member as written
|
|
52
53
|
// ticket <placeholder> the renderer fills `<placeholder>` with the
|
|
53
|
-
// ticket of the PR `--pr` names (THE TICKET)
|
|
54
|
+
// ticket of the PR `--pr` names (THE TICKET),
|
|
55
|
+
// which is free text
|
|
54
56
|
// A placeholder is `<` + a letter + anything but `<`, `>` and a newline +
|
|
55
57
|
// `>`, matched by its inner text exactly; it may hold spaces. No flag and
|
|
56
58
|
// no placeholder is declared twice, and --member, --json and --kind are
|
|
@@ -66,10 +68,19 @@
|
|
|
66
68
|
// with newlines and ended by one. Sections may repeat and interleave, which
|
|
67
69
|
// is how kinds share text without a copy.
|
|
68
70
|
// - Substitution is one pass over the template: a value is never rescanned,
|
|
69
|
-
// so a value holding another placeholder's spelling is not substituted into
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
71
|
+
// so a value holding another placeholder's spelling is not substituted into,
|
|
72
|
+
// and reaches the member as written.
|
|
73
|
+
//
|
|
74
|
+
// THE LEFTOVER CHECK. A caller passing an unfilled value like `<branch>` would
|
|
75
|
+
// leave the member a placeholder, so a value that spells one is refused, naming
|
|
76
|
+
// it — but what counts as spelling one depends on what the argument carries. An
|
|
77
|
+
// argument that carries an identifier or a path is refused when its value
|
|
78
|
+
// contains the spelling of any placeholder this brief fills. An argument the
|
|
79
|
+
// template marks `free`, and the ticket, carry text someone else wrote, which
|
|
80
|
+
// may spell placeholders as part of what it says: those are refused only when
|
|
81
|
+
// the value, trimmed, is exactly its own placeholder's spelling, an unfilled
|
|
82
|
+
// copy. This script holds no list of which arguments those are; the template
|
|
83
|
+
// says.
|
|
73
84
|
//
|
|
74
85
|
// THE TICKET. A `ticket` placeholder in the selected text is filled with the
|
|
75
86
|
// ticket the PR's implementer was dispatched with, which the renderer finds
|
|
@@ -78,8 +89,7 @@
|
|
|
78
89
|
// `<scratch>` the `--scratch` value — so a template declaring `ticket`
|
|
79
90
|
// declares `--pr` and `--scratch` too, and a kind carrying the placeholder
|
|
80
91
|
// carries theirs. It is composed by ticket-text.mjs's ticketText(), as the
|
|
81
|
-
// implementer's was, and
|
|
82
|
-
// implementer template's argument placeholders and this template's own. Two
|
|
92
|
+
// implementer's was, and inserted as it comes, unmodified. Two
|
|
83
93
|
// tickets naming one PR are each rendered, in row order. An issue file that
|
|
84
94
|
// is missing or unreadable refuses, naming its path; nothing asks the tracker
|
|
85
95
|
// in its place. No ledger, or no settled token naming the PR, fills it with a
|
|
@@ -99,7 +109,7 @@ import { FleetDirUnresolvable, fleetFile } from "./fleet-dir.mjs";
|
|
|
99
109
|
import { gitEnv } from "./git-env.mjs";
|
|
100
110
|
import { ROWS, ledgerSection, memberTokens } from "./ledger-grammar.mjs";
|
|
101
111
|
import { runnerScratchRefusal } from "./review-core.mjs";
|
|
102
|
-
import {
|
|
112
|
+
import { ticketText } from "./ticket-text.mjs";
|
|
103
113
|
|
|
104
114
|
const NAME = "dispatch-prompt";
|
|
105
115
|
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
@@ -124,15 +134,18 @@ function parseTemplate(role, text) {
|
|
|
124
134
|
|
|
125
135
|
const args = [];
|
|
126
136
|
const paths = new Set();
|
|
137
|
+
const free = new Set();
|
|
127
138
|
const literals = new Set();
|
|
128
139
|
let ticket = null;
|
|
129
140
|
for (const line of lines.slice(1, close)) {
|
|
130
|
-
const m = /^(arg|path|literal|ticket) (.+)$/.exec(line);
|
|
141
|
+
const m = /^(arg|path|free|literal|ticket) (.+)$/.exec(line);
|
|
131
142
|
if (m === null) refuse(`has a frontmatter line that is no directive: ${line}`);
|
|
132
143
|
if (m[1] === "literal") {
|
|
133
144
|
literals.add(m[2]);
|
|
134
145
|
} else if (m[1] === "path") {
|
|
135
146
|
paths.add(m[2]);
|
|
147
|
+
} else if (m[1] === "free") {
|
|
148
|
+
free.add(m[2]);
|
|
136
149
|
} else if (m[1] === "ticket") {
|
|
137
150
|
if (ticket !== null) refuse(`declares a ticket placeholder twice: <${ticket}> and <${m[2]}>`);
|
|
138
151
|
ticket = m[2];
|
|
@@ -146,6 +159,8 @@ function parseTemplate(role, text) {
|
|
|
146
159
|
}
|
|
147
160
|
}
|
|
148
161
|
for (const flag of paths) if (!args.some((a) => a.flag === flag)) refuse(`marks --${flag} as a path but never declares it`);
|
|
162
|
+
for (const flag of free) if (!args.some((a) => a.flag === flag)) refuse(`marks --${flag} as free text but never declares it`);
|
|
163
|
+
for (const flag of free) if (paths.has(flag)) refuse(`marks --${flag} as both a path and free text`);
|
|
149
164
|
for (const a of args) if (literals.has(a.placeholder)) refuse(`declares <${a.placeholder}> as both an argument and a literal`);
|
|
150
165
|
if (ticket !== null && (literals.has(ticket) || args.some((a) => a.placeholder === ticket))) {
|
|
151
166
|
refuse(`declares <${ticket}> as the ticket and as an argument or a literal`);
|
|
@@ -168,7 +183,7 @@ function parseTemplate(role, text) {
|
|
|
168
183
|
const whole = sections.flatMap((s) => s.lines).join("\n");
|
|
169
184
|
for (const p of [...args.map((a) => a.placeholder), ...(ticket === null ? [] : [ticket])]) if (!whole.includes(`<${p}>`)) refuse(`declares <${p}> but never carries it`);
|
|
170
185
|
if (ticket !== null) for (const flag of TICKET_FLAGS) if (!args.some((a) => a.flag === flag)) refuse(`declares the ticket <${ticket}> but no --${flag} to find it by`);
|
|
171
|
-
return { args, paths, literals, ticket, sections, kinds };
|
|
186
|
+
return { args, paths, free, literals, ticket, sections, kinds };
|
|
172
187
|
}
|
|
173
188
|
|
|
174
189
|
function loadTemplate(role) {
|
|
@@ -190,8 +205,8 @@ const TICKET_FLAGS = ["pr", "scratch"];
|
|
|
190
205
|
// The text a `ticket` placeholder is filled with, for PR `pr` under scratch
|
|
191
206
|
// root `scratch` (THE TICKET above): each ticket a settled `impl-<N>=PR#<pr>`
|
|
192
207
|
// token on the ledger's rows names, once, in row order, composed by
|
|
193
|
-
// ticketText()
|
|
194
|
-
function ticketFor(pr, scratch
|
|
208
|
+
// ticketText().
|
|
209
|
+
function ticketFor(pr, scratch) {
|
|
195
210
|
let ledger;
|
|
196
211
|
try {
|
|
197
212
|
ledger = fleetFile("ledger.md");
|
|
@@ -223,7 +238,7 @@ function ticketFor(pr, scratch, names) {
|
|
|
223
238
|
if (typeof issue?.title !== "string") {
|
|
224
239
|
return die(`cannot read ticket #${n}, the ticket PR #${pr}'s implementer was dispatched with, from ${path}: it holds no issue with a title`);
|
|
225
240
|
}
|
|
226
|
-
return
|
|
241
|
+
return ticketText(issue);
|
|
227
242
|
}).join("\n\n");
|
|
228
243
|
}
|
|
229
244
|
|
|
@@ -340,15 +355,27 @@ if (carriesTicket) {
|
|
|
340
355
|
die(`template ${role}.md carries the ticket <${template.ticket}> in kind ${kind} without ${TICKET_FLAGS.map((f) => `--${f}`).join(" and ")} to find it by`);
|
|
341
356
|
}
|
|
342
357
|
const [pr, scratch] = by.map((a) => values.get(a.placeholder));
|
|
343
|
-
|
|
344
|
-
values.set(template.ticket, ticketFor(pr, scratch, names));
|
|
358
|
+
values.set(template.ticket, ticketFor(pr, scratch));
|
|
345
359
|
}
|
|
346
360
|
|
|
347
|
-
|
|
361
|
+
// THE LEFTOVER CHECK, once every value is in: an unfilled copy of a free text
|
|
362
|
+
// value is refused, and so is an identifier or a path spelling a placeholder
|
|
363
|
+
// this brief fills.
|
|
348
364
|
const filled = [...required.map((a) => a.placeholder), ...(carriesTicket ? [template.ticket] : [])];
|
|
349
|
-
|
|
350
|
-
|
|
365
|
+
const unfilled = (placeholder) => die(`the rendered brief still carries <${placeholder}> — its value is the unfilled placeholder`);
|
|
366
|
+
for (const a of required) {
|
|
367
|
+
const value = values.get(a.placeholder);
|
|
368
|
+
if (template.free.has(a.flag)) {
|
|
369
|
+
if (value.trim() === `<${a.placeholder}>`) unfilled(a.placeholder);
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
for (const p of filled) {
|
|
373
|
+
if (value.includes(`<${p}>`)) die(`the rendered brief still carries <${p}> — an argument value spells it`);
|
|
374
|
+
}
|
|
351
375
|
}
|
|
376
|
+
if (carriesTicket && values.get(template.ticket).trim() === `<${template.ticket}>`) unfilled(template.ticket);
|
|
377
|
+
|
|
378
|
+
const brief = `${body.replace(PLACEHOLDER, (whole, inner) => (values.has(inner) ? values.get(inner) : whole))}\n`;
|
|
352
379
|
|
|
353
380
|
const payload = {
|
|
354
381
|
role,
|
|
@@ -120,6 +120,12 @@ function isSettledToken(word) {
|
|
|
120
120
|
return t !== null && t.error === null && t.outcome !== null;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/** Every settled member token of a row's text, in the row's order, duplicates
|
|
124
|
+
* kept: the tokens a rewrite of the row must carry (settledMemberRefusal). */
|
|
125
|
+
export function settledMemberTokens(text) {
|
|
126
|
+
return text.split(/\s+/).filter(isSettledToken);
|
|
127
|
+
}
|
|
128
|
+
|
|
123
129
|
/** The dispatch-prompt.mjs role a member of `family` is rendered as. */
|
|
124
130
|
export function memberRole(family) {
|
|
125
131
|
return FAMILIES[family].role;
|
|
@@ -529,8 +535,7 @@ export function gateVerdictRefusal(oldLine, line) {
|
|
|
529
535
|
* own malformed-token check), so a row can still be repaired.
|
|
530
536
|
*/
|
|
531
537
|
export function settledMemberRefusal(oldLine, line) {
|
|
532
|
-
const
|
|
533
|
-
const lost = added(settled(line), settled(oldLine))[0];
|
|
538
|
+
const lost = added(settledMemberTokens(line ?? ""), settledMemberTokens(oldLine ?? ""))[0];
|
|
534
539
|
if (lost === undefined) return null;
|
|
535
540
|
return `drops settled member token '${lost}' — a rewrite must carry every settled member token as the row holds it; `
|
|
536
541
|
+ "pass the complete reconstructed line, use `ledger.mjs token` to add a non-member token, and `ledger.mjs read` to look a row up";
|
|
@@ -943,7 +948,8 @@ export function nextMergeBot(dispatched, names = []) {
|
|
|
943
948
|
* one retry letter past the HIGHEST any of `names` on that number has used,
|
|
944
949
|
* `name` itself included — not past `name`'s own, since a controller can
|
|
945
950
|
* dispatch `-c` before `-b`. No suffix is the `a` attempt; `-z` is the
|
|
946
|
-
* grammar's last, past which there is no legal name, so null.
|
|
951
|
+
* grammar's last, past which there is no legal name, so null. `name` must
|
|
952
|
+
* already parse as a member name: parseMember's null is not guarded. */
|
|
947
953
|
export function nextRetry(name, names) {
|
|
948
954
|
const { family, number } = parseMember(name);
|
|
949
955
|
const top = [name, ...names].map(parseMember).filter((m) => m !== null && m.family === family && m.number === number)
|
|
@@ -951,6 +957,33 @@ export function nextRetry(name, names) {
|
|
|
951
957
|
return top === "z" ? null : `${family}-${number}-${String.fromCharCode(top.charCodeAt(0) + 1)}`;
|
|
952
958
|
}
|
|
953
959
|
|
|
960
|
+
/** Every name this omp session has used beyond `## Dispatched`: each member
|
|
961
|
+
* token on any row, live or settled, and each name `## Retired` holds
|
|
962
|
+
* (`retired`, read through readRetired().names). */
|
|
963
|
+
export function sessionMemberNames(rows, retired) {
|
|
964
|
+
return [...rows.flatMap(memberTokens).map((t) => t.name), ...retired];
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/** How `name` was already used this session, as `ledger.mjs dispatch` words it
|
|
968
|
+
* in its refusal, or undefined when no place holds it: a `## Dispatched`
|
|
969
|
+
* entry, a settled token on a row, or a `## Retired` line. `dispatched` is
|
|
970
|
+
* `## Dispatched` as its tokens. A row token whose outcome is out of
|
|
971
|
+
* vocabulary still counts as a use here, so its name is burnt, while
|
|
972
|
+
* isSettledToken leaves it out of the tokens a row rewrite carries. */
|
|
973
|
+
export function priorUse(name, rows, dispatched, retired) {
|
|
974
|
+
const settledOnRow = rows.flatMap(memberTokens).find((t) => t.name === name && t.outcome !== null);
|
|
975
|
+
return dispatched.find((e) => parseToken(e).name === name) ??
|
|
976
|
+
(settledOnRow ? `${settledOnRow.name}=${settledOnRow.outcome}` : retired.includes(name) ? "retired by rotate" : undefined);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/** The replacement name `ledger.mjs dispatch` spells out for `name`, one retry
|
|
980
|
+
* letter past the highest this session has used on its number wherever that
|
|
981
|
+
* name sits, or null when `-z` is used. `name` must already parse as a member
|
|
982
|
+
* name, as nextRetry requires. */
|
|
983
|
+
export function replacementName(name, rows, dispatched, retired) {
|
|
984
|
+
return nextRetry(name, [...dispatched.map((e) => parseToken(e).name), ...sessionMemberNames(rows, retired)]);
|
|
985
|
+
}
|
|
986
|
+
|
|
954
987
|
// An implementer cell is `<role>-<level>` — an omp role and a thinking
|
|
955
988
|
// level — and each cell is one definition, `fleet-implementer-<cell>`, whose
|
|
956
989
|
// `model:` is `@<role>:<level>`. Nothing is named
|
package/scripts/ledger.mjs
CHANGED
|
@@ -74,7 +74,7 @@ import { spawnSync, execFileSync } from "node:child_process";
|
|
|
74
74
|
import { makeDie, isFlagLike, hasEqualsForm, isDigits, writeAll } from "./arg.mjs";
|
|
75
75
|
import { fleetFile, FleetDirUnresolvable } from "./fleet-dir.mjs";
|
|
76
76
|
import { readReceipt } from "./phase0-receipt.mjs";
|
|
77
|
-
import { parseMember, parseToken, memberTokens, nextMergeBot,
|
|
77
|
+
import { parseMember, parseToken, memberTokens, nextMergeBot, sessionMemberNames, priorUse, replacementName, 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";
|
|
78
78
|
import { deriveRun, foldLedger, liveFixers, LedgerError, labelOffMember, CONFLICT_HOLD, PARKED } from "./fleet-tick.mjs";
|
|
79
79
|
import { stateFileIn, readState, writeState, assessBeat, stallsAt } from "./fleet-state.mjs";
|
|
80
80
|
import { processSource, ancestry, controllerOf, judgeController, ProcUnreadable } from "./proc.mjs";
|
|
@@ -2416,7 +2416,7 @@ async function runDispatch() {
|
|
|
2416
2416
|
// `## Dispatched`, on a row or in `## Retired` — so the controller never
|
|
2417
2417
|
// counts. An explicit `merge-bot-<n>` is accepted only when it is that one.
|
|
2418
2418
|
// `sessionNames` is every name beyond `## Dispatched` the session has used.
|
|
2419
|
-
const sessionNames =
|
|
2419
|
+
const sessionNames = sessionMemberNames(data.rows, retired);
|
|
2420
2420
|
const member = parseMember(name === "merge-bot" ? nextMergeBot(data.dispatched, sessionNames) : name);
|
|
2421
2421
|
if (!member) die(unknownMember(name));
|
|
2422
2422
|
if (member.bound === null) {
|
|
@@ -2443,16 +2443,11 @@ async function runDispatch() {
|
|
|
2443
2443
|
// and omp still holds that peer under the name (see runRotate()). The
|
|
2444
2444
|
// replacement's name is spelled out: one letter past the highest this
|
|
2445
2445
|
// session has used on the number, wherever that name sits.
|
|
2446
|
-
const
|
|
2447
|
-
const prior =
|
|
2448
|
-
data.dispatched.find((e) => parseToken(e).name === member.name) ??
|
|
2449
|
-
(settledOnRow && `${settledOnRow.name}=${settledOnRow.outcome}`) ??
|
|
2450
|
-
(retired.includes(member.name) ? "retired by rotate" : undefined);
|
|
2446
|
+
const prior = priorUse(member.name, data.rows, data.dispatched, retired);
|
|
2451
2447
|
if (prior !== undefined) {
|
|
2452
2448
|
// Never a merge bot: it is accepted only as the number past every name
|
|
2453
2449
|
// the session holds, so none of the three places above can name it.
|
|
2454
|
-
const
|
|
2455
|
-
const next = nextRetry(member.name, used);
|
|
2450
|
+
const next = replacementName(member.name, data.rows, data.dispatched, retired);
|
|
2456
2451
|
die(`${member.name} was already dispatched this session (${prior}) — a replacement takes a name of its own`
|
|
2457
2452
|
+ (next === null ? `, and ${member.name} has no retry letter left` : ` (${next})`));
|
|
2458
2453
|
}
|
package/scripts/pull.mjs
CHANGED
|
@@ -104,8 +104,16 @@
|
|
|
104
104
|
// the brief's Out of scope section are printed as the
|
|
105
105
|
// behind-issue candidates. Then `clear`, `behind-pr:#M`,
|
|
106
106
|
// `behind-issue:#M`, or `paths <p>…`, which scans again and
|
|
107
|
-
// asks again. An exclusion is a ledger row
|
|
108
|
-
//
|
|
107
|
+
// asks again. An exclusion is a ledger row, and the row's settled
|
|
108
|
+
// member tokens follow its `excluded · <token>`.
|
|
109
|
+
// 6 claim `claim-ticket.sh <N> impl-<N> implementer --apply`. The claim, the
|
|
110
|
+
// worktree and the branch always take the `impl-<N>` pair; the
|
|
111
|
+
// member that works the ticket is named first, from `ledger.mjs
|
|
112
|
+
// read`, the way `ledger.mjs dispatch` names a replacement:
|
|
113
|
+
// `impl-<N>` when this omp session has not used it (not
|
|
114
|
+
// dispatched, settled on a row or retired), else the next free
|
|
115
|
+
// retry name (`impl-<N>-b`, `-c`, …). With no retry letter left
|
|
116
|
+
// the Pull is left, exit 1, before anything is claimed.
|
|
109
117
|
// 7 route `ticket-router.mjs route …`, which routes by the Objective
|
|
110
118
|
// the phase-0 receipt records; a router that refuses releases
|
|
111
119
|
// the claim, and a release that fails is exit 2 with the claim
|
|
@@ -113,11 +121,10 @@
|
|
|
113
121
|
// `excluded · behind-issue:#<N>`: another open ticket
|
|
114
122
|
// sequences after this one.
|
|
115
123
|
// 8 row, render, dispatch `ledger.mjs row … --routing <line>`, the row and
|
|
116
|
-
// the router's line in one write
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
// refuses a value that spells one.
|
|
124
|
+
// the router's line in one write — the row's settled member
|
|
125
|
+
// tokens carried, then the member —, `dispatch-prompt.mjs render
|
|
126
|
+
// implementer --member <member>`, `ledger.mjs dispatch`. The
|
|
127
|
+
// brief and the staleness text are given as they are.
|
|
121
128
|
//
|
|
122
129
|
// THE STATE is `<scratch>/impl-<N>/pull.json`: every command run (script, its
|
|
123
130
|
// arguments, exit status, bounded stdout, time), every question asked and every
|
|
@@ -139,9 +146,9 @@ import { FleetDirUnresolvable, fleetFile } from "./fleet-dir.mjs";
|
|
|
139
146
|
import { gitEnv } from "./git-env.mjs";
|
|
140
147
|
import { isCLI } from "./is-cli.mjs";
|
|
141
148
|
import { LabelMapUnreadable, readLabelMap } from "./label-map.mjs";
|
|
142
|
-
import { EXCLUDED_REASON, POLICY_CELL, memberTokens, parseRouting, premisesOf, pullEnded, tierValues } from "./ledger-grammar.mjs";
|
|
149
|
+
import { EXCLUDED_REASON, POLICY_CELL, memberTokens, parseRouting, parseToken, premisesOf, priorUse, pullEnded, readRetired, replacementName, settledMemberTokens, tierValues } from "./ledger-grammar.mjs";
|
|
143
150
|
import { sessionFromReceipt } from "./phase0-receipt.mjs";
|
|
144
|
-
import { LINE_REF, briefPaths, briefText,
|
|
151
|
+
import { LINE_REF, briefPaths, briefText, outOfScope, strandedRuling, ticketText } from "./ticket-text.mjs";
|
|
145
152
|
|
|
146
153
|
const NAME = "pull";
|
|
147
154
|
const SCRIPTS = dirname(fileURLToPath(import.meta.url));
|
|
@@ -217,6 +224,24 @@ export function closeComment(commit, subject) {
|
|
|
217
224
|
const rowKey = (row) => row.split(/\s/)[0];
|
|
218
225
|
const isImplRow = (row) => memberTokens(row).some((t) => t.family === "impl");
|
|
219
226
|
|
|
227
|
+
/**
|
|
228
|
+
* The name a ticket is claimed under, and its worktree and branch are named
|
|
229
|
+
* for: the claim belongs to the ticket, whichever member works it.
|
|
230
|
+
*/
|
|
231
|
+
const pairOf = (ticket) => `impl-${ticket}`;
|
|
232
|
+
|
|
233
|
+
/** `ticket`'s row in `rows`, or undefined. */
|
|
234
|
+
const rowOf = (rows, ticket) => rows.find((r) => rowKey(r) === `#${ticket}`);
|
|
235
|
+
|
|
236
|
+
/** The settled member tokens a rewrite of `ticket`'s row must carry, in the row's order. */
|
|
237
|
+
const carriedTokens = (rows, ticket) => {
|
|
238
|
+
const row = rowOf(rows, ticket);
|
|
239
|
+
return row === undefined ? [] : settledMemberTokens(row);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/** Whether `x` is an array of strings, the shape `ledger.mjs read` prints `rows`, `dispatched` and `retired` in. */
|
|
243
|
+
const strings = (x) => Array.isArray(x) && x.every((s) => typeof s === "string");
|
|
244
|
+
|
|
220
245
|
/**
|
|
221
246
|
* The `--impl-row` the router is given: the row count the Pull creates — or,
|
|
222
247
|
* while an exploration assignment is rolling (the latest row 5k and every row
|
|
@@ -384,23 +409,6 @@ export function sectionsOf(hs, from, to) {
|
|
|
384
409
|
return [above === undefined ? "(no heading above)" : above.text, ...within.map((h) => h.text)].join(" → ");
|
|
385
410
|
}
|
|
386
411
|
|
|
387
|
-
// The placeholders the implementer's brief template declares. dispatch-prompt.mjs
|
|
388
|
-
// refuses a value that spells one, and a ticket's text is a value: one that
|
|
389
|
-
// names `<N>` would stop every render, with the claim standing.
|
|
390
|
-
const TEMPLATE = join(SCRIPTS, "..", "skills", "run-team", "briefs", "implementer.md");
|
|
391
|
-
|
|
392
|
-
function declaredPlaceholders() {
|
|
393
|
-
const lines = readFileSync(TEMPLATE, "utf8").split("\n");
|
|
394
|
-
if (lines[0] !== "---") return [];
|
|
395
|
-
const names = [];
|
|
396
|
-
for (const line of lines.slice(1)) {
|
|
397
|
-
if (line === "---") break;
|
|
398
|
-
const m = /^arg \S+ (.+)$/.exec(line);
|
|
399
|
-
if (m !== null) names.push(m[1]);
|
|
400
|
-
}
|
|
401
|
-
return names;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
412
|
// ── children ─────────────────────────────────────────────────────────────────
|
|
405
413
|
|
|
406
414
|
const trimmed = (s) => String(s ?? "").trim();
|
|
@@ -445,7 +453,7 @@ function goneBranches(out) {
|
|
|
445
453
|
function fresh(ticket, session) {
|
|
446
454
|
return {
|
|
447
455
|
ticket,
|
|
448
|
-
member:
|
|
456
|
+
member: null,
|
|
449
457
|
started: now(),
|
|
450
458
|
status: "running",
|
|
451
459
|
stage: "inflight",
|
|
@@ -651,16 +659,36 @@ class Pull {
|
|
|
651
659
|
return result(10, block(qid, this.st.ticket, context));
|
|
652
660
|
}
|
|
653
661
|
|
|
654
|
-
|
|
662
|
+
// `ledger.mjs read`'s JSON, refused when it is unreadable or carries no `rows`.
|
|
663
|
+
readLedger() {
|
|
655
664
|
const r = this.script("ledger", "ledger.mjs", ["read"]);
|
|
656
665
|
if (r.status !== 0) throw new Refusal(withText(`ledger.mjs read ${r.how}`, r));
|
|
666
|
+
let data = null;
|
|
657
667
|
try {
|
|
658
|
-
|
|
659
|
-
if (Array.isArray(rows) && rows.every((x) => typeof x === "string")) return rows;
|
|
668
|
+
data = JSON.parse(r.stdout);
|
|
660
669
|
} catch {
|
|
661
670
|
// Falls through to the refusal below.
|
|
662
671
|
}
|
|
663
|
-
throw new Refusal("ledger.mjs read printed no {rows}");
|
|
672
|
+
if (!strings(data?.rows)) throw new Refusal("ledger.mjs read printed no {rows}");
|
|
673
|
+
return data;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// The ledger as `ledger.mjs read` prints it, the parts the member's name is picked from: `rows`, `dispatched`
|
|
677
|
+
// (`## Dispatched` as its tokens) and `retired` (the names `## Retired` holds). An entry or line the grammar cannot
|
|
678
|
+
// read is a refusal, as `ledger.mjs dispatch` refuses it, before anything is claimed.
|
|
679
|
+
ledger() {
|
|
680
|
+
const data = this.readLedger();
|
|
681
|
+
if (!strings(data.dispatched) || !strings(data.retired)) throw new Refusal("ledger.mjs read printed no {dispatched, retired}");
|
|
682
|
+
const bad = data.dispatched.find((e) => parseToken(e) === null);
|
|
683
|
+
if (bad !== undefined) throw new Refusal(`ledger.mjs read: ## Dispatched has an entry '${bad}' this grammar cannot parse — fix the ledger by hand`);
|
|
684
|
+
const { names, malformed } = readRetired(data.retired);
|
|
685
|
+
if (malformed.length > 0) throw new Refusal(`ledger.mjs read: ## Retired has a line '${malformed[0]}' that names no member or reviewer — fix the ledger by hand`);
|
|
686
|
+
return { rows: data.rows, dispatched: data.dispatched, retired: names };
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// The rows alone, for the readers that write a row or route: a section only the name needs cannot block them.
|
|
690
|
+
ledgerRows() {
|
|
691
|
+
return this.readLedger().rows;
|
|
664
692
|
}
|
|
665
693
|
|
|
666
694
|
// ── the ticket, as read ──
|
|
@@ -927,7 +955,15 @@ class Pull {
|
|
|
927
955
|
} catch (e) {
|
|
928
956
|
return this.stop(e.message);
|
|
929
957
|
}
|
|
930
|
-
|
|
958
|
+
// The claim belongs to the ticket, so it is made under the `impl-<N>` pair; the member that works it is the
|
|
959
|
+
// next name this session has not used on the number, and is chosen before anything is claimed.
|
|
960
|
+
const base = pairOf(st.ticket);
|
|
961
|
+
const { rows, dispatched, retired } = this.ledger();
|
|
962
|
+
const prior = priorUse(base, rows, dispatched, retired);
|
|
963
|
+
const member = prior === undefined ? base : replacementName(base, rows, dispatched, retired);
|
|
964
|
+
if (member === null) return this.leave(`no retry letter is left: ${base} was already used this session (${prior}) and every retry letter after it is taken`);
|
|
965
|
+
st.member = member;
|
|
966
|
+
const r = this.script("claim", "claim-ticket.sh", [String(st.ticket), base, "implementer", "--apply"]);
|
|
931
967
|
if (r.status === 0) {
|
|
932
968
|
st.stage = "route";
|
|
933
969
|
return null;
|
|
@@ -950,7 +986,7 @@ class Pull {
|
|
|
950
986
|
const routing = r.status === 0 ? parseRouting(line) : null;
|
|
951
987
|
if (routing === null) {
|
|
952
988
|
const said = r.status === 0 ? `printed no routing line: ${r.stdout}` : withText(`refused (${r.how})`, r);
|
|
953
|
-
const rel = this.script("release", "release-ticket.sh", [String(st.ticket), st.
|
|
989
|
+
const rel = this.script("release", "release-ticket.sh", [String(st.ticket), pairOf(st.ticket), "implementer", "--apply"]);
|
|
954
990
|
if (rel.status !== 0) {
|
|
955
991
|
// The claim stands, so the Pull is not over: it stays at this step, and running it again routes, or refuses and releases, again.
|
|
956
992
|
return this.stop(`ticket-router.mjs ${said}\n${withText(`its claim is STILL STANDING: release-ticket.sh failed (${rel.how})`, rel)}`);
|
|
@@ -969,9 +1005,12 @@ class Pull {
|
|
|
969
1005
|
const { cell, draw } = st.route;
|
|
970
1006
|
// `tier=` marks a draw; a Pull routed without one still dispatches at the
|
|
971
1007
|
// cell the router printed, carried as `cell=` so the row reads as undrawn.
|
|
972
|
-
// The Routing itself goes to `## Routed` in the same write.
|
|
1008
|
+
// The Routing itself goes to `## Routed` in the same write. The row's
|
|
1009
|
+
// settled member tokens are carried ahead of the member: a rewrite drops
|
|
1010
|
+
// none, and the earlier `tier=` and `cell=` words are the earlier member's.
|
|
973
1011
|
const carrier = draw !== "-" ? ` · tier=${cell}` : cell !== POLICY_CELL ? ` · cell=${cell}` : "";
|
|
974
|
-
const
|
|
1012
|
+
const text = [...carriedTokens(this.ledgerRows(), st.ticket), `${st.member}${carrier}`].join(" · ");
|
|
1013
|
+
const r = this.script("row", "ledger.mjs", ["row", String(st.ticket), text, "--routing", st.route.line]);
|
|
975
1014
|
if (r.status !== 0) return this.stop(withText(`ledger.mjs row failed (${r.how})`, r));
|
|
976
1015
|
st.stage = "render";
|
|
977
1016
|
return null;
|
|
@@ -979,18 +1018,12 @@ class Pull {
|
|
|
979
1018
|
|
|
980
1019
|
stage_render() {
|
|
981
1020
|
const { st } = this;
|
|
982
|
-
const worktree = join(this.p.cwd, ".worktrees", `${st.ticket}-${st.
|
|
1021
|
+
const worktree = join(this.p.cwd, ".worktrees", `${st.ticket}-${pairOf(st.ticket)}`);
|
|
983
1022
|
const staleness = st.staleness.length === 0 ? "no probe was run" : st.staleness.join("; ");
|
|
984
|
-
let names;
|
|
985
|
-
try {
|
|
986
|
-
names = declaredPlaceholders();
|
|
987
|
-
} catch (e) {
|
|
988
|
-
return this.stop(`cannot read the brief template ${TEMPLATE} (${e.code ?? e.message})`);
|
|
989
|
-
}
|
|
990
1023
|
const r = this.script("render", "dispatch-prompt.mjs", [
|
|
991
1024
|
"render", "implementer", "--member", st.member, "--ticket", String(st.ticket), "--worktree", worktree,
|
|
992
|
-
"--branch", `implementer/${st.ticket}-${st.
|
|
993
|
-
"--brief",
|
|
1025
|
+
"--branch", `implementer/${st.ticket}-${pairOf(st.ticket)}`, "--scratch", this.p.scratch,
|
|
1026
|
+
"--brief", ticketText(this.issue()), "--staleness", staleness,
|
|
994
1027
|
]);
|
|
995
1028
|
if (r.status !== 0) return this.stop(withText(`dispatch-prompt.mjs render refused (${r.how}) — the claim stands`, r));
|
|
996
1029
|
st.stage = "dispatch";
|
|
@@ -1129,7 +1162,9 @@ class Pull {
|
|
|
1129
1162
|
for (const p of text.split(/\s+/)) if (!st.addedPaths.includes(p)) st.addedPaths.push(p);
|
|
1130
1163
|
return null;
|
|
1131
1164
|
}
|
|
1132
|
-
|
|
1165
|
+
// An Exclusion still carries the row's settled member tokens: the rewrite drops none.
|
|
1166
|
+
const excluded = [`${EXCLUDED_REASON} ${token}`, ...carriedTokens(this.ledgerRows(), st.ticket)].join(" · ");
|
|
1167
|
+
const r = this.script("exclude", "ledger.mjs", ["row", String(st.ticket), excluded]);
|
|
1133
1168
|
if (r.status !== 0) return this.stop(withText(`ledger.mjs row failed (${r.how})`, r));
|
|
1134
1169
|
return this.leave(`${EXCLUDED_REASON} ${token}`);
|
|
1135
1170
|
}
|
|
@@ -1185,7 +1220,7 @@ function readLedgerRows(p) {
|
|
|
1185
1220
|
* could not read is a refusal (exit 2) that says the exclusion stands.
|
|
1186
1221
|
*/
|
|
1187
1222
|
function heldOut(p, n) {
|
|
1188
|
-
const row = readLedgerRows(p)
|
|
1223
|
+
const row = rowOf(readLedgerRows(p), n);
|
|
1189
1224
|
const premises = row === undefined ? null : premisesOf(row);
|
|
1190
1225
|
if (premises === null) return null;
|
|
1191
1226
|
const standing = standingPremise(premises, p.cwd);
|
|
@@ -1224,7 +1259,7 @@ function shortlistHead(p, run) {
|
|
|
1224
1259
|
// empty one.
|
|
1225
1260
|
const unreadable = [];
|
|
1226
1261
|
for (const { n } of list.shortlist) {
|
|
1227
|
-
const row = rows
|
|
1262
|
+
const row = rowOf(rows, n);
|
|
1228
1263
|
if (row !== undefined && isImplRow(row)) continue;
|
|
1229
1264
|
const premises = row === undefined ? null : premisesOf(row);
|
|
1230
1265
|
const standing = premises === null ? null : standingPremise(premises, p.cwd);
|
package/scripts/ticket-text.mjs
CHANGED
|
@@ -70,11 +70,6 @@ export function ticketText(issue) {
|
|
|
70
70
|
return [`Title: ${issue.title}`, text, ...(outside === null ? [] : [outside])].join("\n\n");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/** `text` with each declared placeholder's spelling `<name>` written `‹name›`, which dispatch-prompt.mjs does not read. */
|
|
74
|
-
export function defang(text, names) {
|
|
75
|
-
return names.reduce((t, n) => t.split(`<${n}>`).join(`‹${n}›`), text);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
73
|
/** A brief path's trailing line reference, `:N` or `:N-M`. */
|
|
79
74
|
export const LINE_REF = /:(\d+)(?:-(\d+))?$/;
|
|
80
75
|
|
package/skills/run-team/SKILL.md
CHANGED
|
@@ -511,7 +511,7 @@ worktree re-created for an already-open PR is in references/isolation.md.
|
|
|
511
511
|
A dispatch is done when its `task` call is made, in the background, with the `agent` and the name `ledger.mjs dispatch` printed, and — for an implementer — the tier check has written its verdict: dispatch nothing on top of an unchecked one.
|
|
512
512
|
|
|
513
513
|
- **One claim, one dispatch, no queue.** Claim one ticket, then dispatch one new member at once, under a name no member has held; nothing holds a queue. Record `ledger.mjs dispatch` before the call.
|
|
514
|
-
- **The implementer.** Dispatch with the printed `agent`, omit `model`, keep `name
|
|
514
|
+
- **The implementer.** Dispatch with the printed `agent`, omit `model`, keep the `name` `DISPATCH` printed. **No per-call tier or effort anywhere on this path**: tier stays the agent definition's own frontmatter, whichever `fleet-implementer-<cell>` definition the Pull names, and a member's Resolved tier stays readable from its transcript. The prompt carries only what varies, and the Pull's own read of the ticket is pasted, never a request to re-fetch. A member settling with nothing is not a bail. Confirm death first, exactly as the Member-killed row does (Failure handling, below) — its mtime discriminator, never silence alone. Only the member's own bail report counts. A confirmed-dead member recovers exactly as the Member-killed row says — new member, new name, the SAME ticket — never a demotion.
|
|
515
515
|
- **The tier check.** **Run the check right after the dispatch, and never reinstall the plugin or change `modelRoles` while any member is unchecked.** `tick --apply`, or `tier-check.mjs --batch <path>`, runs it. Dispatch nothing on top of an unchecked or mismatched member. **The tick holds the next Pull until that verdict exists.** Clear a mismatch by fixing the definition or the dispatch and dispatching the replacement at the right tier. A mismatch on a ticket whose issue is already CLOSED holds nothing. **After `/resume`, a carried implementer can hold the whole tick** with `HOLD (tier unchecked impl-<N>)` until it settles; reconcile its carried token meanwhile. See references/member-lifecycle.md.
|
|
516
516
|
- **The exploration rule.** **Every 5th Pull by ledger count goes at an exploration cell.** See references/pull.md. The printed CELL line is the whole routing decision: never re-derive `CELL`, and never label a cell anywhere — the dispatch record already carries it. **The readout counts DELIBERATE comparisons.** See references/pull.md.
|
|
517
517
|
|
|
@@ -86,7 +86,8 @@ the definitions of `closed_own_ticket` and `minted_false_claim` in the header
|
|
|
86
86
|
of `docs/metrics/tier-outcomes.tsv`, and charge each standing entry by them,
|
|
87
87
|
against the ticket below as its implementer was dispatched with it.
|
|
88
88
|
|
|
89
|
-
The ticket
|
|
89
|
+
The ticket. Any name it writes between angle brackets is the ticket's own
|
|
90
|
+
spelling, not a placeholder of this brief:
|
|
90
91
|
|
|
91
92
|
<ticket>
|
|
92
93
|
## kind: conflict
|
|
@@ -7,6 +7,8 @@ arg brief distilled brief
|
|
|
7
7
|
arg staleness staleness
|
|
8
8
|
path worktree
|
|
9
9
|
path scratch
|
|
10
|
+
free brief
|
|
11
|
+
free staleness
|
|
10
12
|
literal your name
|
|
11
13
|
literal that path
|
|
12
14
|
literal outcome
|
|
@@ -24,7 +26,8 @@ write nowhere else but your report file below.
|
|
|
24
26
|
|
|
25
27
|
The ticket, pasted verbatim from the controller's own read — its title, the
|
|
26
28
|
`## Agent Brief` comment or the issue body, whichever carries the brief, and its
|
|
27
|
-
`Out of scope
|
|
29
|
+
`Out of scope`. Any name the ticket writes between angle brackets is the ticket's
|
|
30
|
+
own spelling, not a placeholder of this brief:
|
|
28
31
|
|
|
29
32
|
<distilled brief>
|
|
30
33
|
|
|
@@ -691,6 +691,22 @@ after a router refusal `next --head <N>` starts the ticket over; exit 3 is a
|
|
|
691
691
|
usage mistake, or an answer the question does not take, and records nothing.
|
|
692
692
|
The record is `<scratch>/impl-<N>/pull.json`.
|
|
693
693
|
|
|
694
|
+
**The Pull's member is named before anything is claimed, and the claim keeps the
|
|
695
|
+
pair.** The claim, the worktree and the branch always take the `impl-<N>` pair,
|
|
696
|
+
because the claim belongs to the ticket; only the member that works it is
|
|
697
|
+
named, from `ledger.mjs read`, the way `ledger.mjs dispatch` names a
|
|
698
|
+
replacement. When this omp session has not used `impl-<N>` — not dispatched,
|
|
699
|
+
not a settled token on a row, not under `## Retired` — the member is `impl-<N>`.
|
|
700
|
+
When it has, the member is the next free name (`impl-<N>-b`, `-c`, …), and a
|
|
701
|
+
replacement works in the same worktree and branch. A ticket whose retry letters
|
|
702
|
+
are all used leaves the Pull, exit 1, with a reason saying so, before any claim.
|
|
703
|
+
The row, the render's `--member`, `ledger.mjs dispatch`, the `DISPATCH` line's
|
|
704
|
+
`name` and the Routing under `## Routed` all carry that name. A row rewrite
|
|
705
|
+
carries the row's settled member tokens — `impl-<N>=released`, `=bailed`,
|
|
706
|
+
`=PR#<M>` — ahead of the member, in row order, and drops the earlier `tier=` and
|
|
707
|
+
`cell=` words; a `behind-*` answer writes `excluded · <token>` followed by the
|
|
708
|
+
same tokens, so no rewrite drops one.
|
|
709
|
+
|
|
694
710
|
## No multi-select, no maintainer tick
|
|
695
711
|
|
|
696
712
|
**No multi-select, no maintainer tick.** Selection and ordering are batched —
|