@tablation/crew 0.155.0 → 0.156.1
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/dist/cli.js +282 -40
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -569,13 +569,13 @@ function ensureMainIndex(d, s) {
|
|
|
569
569
|
const p = serenaPaths(s.stateDir, s.route, String(s.ticket));
|
|
570
570
|
const head = d.headOf(s.mainCheckout);
|
|
571
571
|
if (!head) return "unavailable";
|
|
572
|
-
const
|
|
573
|
-
if (d.read(
|
|
572
|
+
const stamp2 = join5(p.mainProject, "indexed-commit");
|
|
573
|
+
if (d.read(stamp2)?.trim() === head) return "fresh";
|
|
574
574
|
const pidFile = join5(p.mainProject, "indexing.pid");
|
|
575
575
|
const running = Number(d.read(pidFile));
|
|
576
576
|
if (running > 0 && d.alive(running)) return "running";
|
|
577
577
|
prepareFolder(d, p.mainHome, p.mainProject, s.mainCheckout);
|
|
578
|
-
const pid = d.spawnIndex(serenaIndexArgs(s.mainCheckout), { SERENA_HOME: p.mainHome }, join5(p.mainProject, "index.log"),
|
|
578
|
+
const pid = d.spawnIndex(serenaIndexArgs(s.mainCheckout), { SERENA_HOME: p.mainHome }, join5(p.mainProject, "index.log"), stamp2, head);
|
|
579
579
|
d.write(pidFile, String(pid));
|
|
580
580
|
return "started";
|
|
581
581
|
}
|
|
@@ -638,7 +638,7 @@ function realSerenaDeps(onPath2, extraEnv = process.env) {
|
|
|
638
638
|
},
|
|
639
639
|
spawnDetached: detached,
|
|
640
640
|
// `&&` so the stamp exists only for an index that finished; a killed one is retried next start.
|
|
641
|
-
spawnIndex: (args, env, log,
|
|
641
|
+
spawnIndex: (args, env, log, stamp2, stampText) => detached("sh", ["-c", 'serena "$@" && printf %s "$STAMP_TEXT" > "$STAMP_FILE"', "serena", ...args], { ...env, STAMP_FILE: stamp2, STAMP_TEXT: stampText }, log),
|
|
642
642
|
link: (target, path) => symlinkSync(target, path),
|
|
643
643
|
alive: (pid) => {
|
|
644
644
|
try {
|
|
@@ -1222,9 +1222,9 @@ function rotateEventsFile(file, maxBytes, now = /* @__PURE__ */ new Date()) {
|
|
|
1222
1222
|
}
|
|
1223
1223
|
try {
|
|
1224
1224
|
if (statSync2(file).size <= maxBytes) return void 0;
|
|
1225
|
-
const
|
|
1226
|
-
let dest = join8(dirname4(file), `events.${
|
|
1227
|
-
for (let n = 1; existsSync9(dest); n++) dest = join8(dirname4(file), `events.${
|
|
1225
|
+
const stamp2 = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
1226
|
+
let dest = join8(dirname4(file), `events.${stamp2}.jsonl`);
|
|
1227
|
+
for (let n = 1; existsSync9(dest); n++) dest = join8(dirname4(file), `events.${stamp2}-${n}.jsonl`);
|
|
1228
1228
|
renameSync(file, dest);
|
|
1229
1229
|
return dest;
|
|
1230
1230
|
} finally {
|
|
@@ -10402,6 +10402,168 @@ function materializeBranchForTicket(dir, cfg, t, role, onProblem, onReset) {
|
|
|
10402
10402
|
return loc.branch;
|
|
10403
10403
|
}
|
|
10404
10404
|
|
|
10405
|
+
// src/footprint.ts
|
|
10406
|
+
var FOOTPRINT_DECLARED_EVENT = "footprint_declared";
|
|
10407
|
+
var LOCKFILES = /* @__PURE__ */ new Set([
|
|
10408
|
+
"package-lock.json",
|
|
10409
|
+
"npm-shrinkwrap.json",
|
|
10410
|
+
"pnpm-lock.yaml",
|
|
10411
|
+
"yarn.lock",
|
|
10412
|
+
"bun.lock",
|
|
10413
|
+
"bun.lockb",
|
|
10414
|
+
"Cargo.lock",
|
|
10415
|
+
"Gemfile.lock",
|
|
10416
|
+
"poetry.lock",
|
|
10417
|
+
"Pipfile.lock",
|
|
10418
|
+
"composer.lock",
|
|
10419
|
+
"go.sum",
|
|
10420
|
+
"uv.lock",
|
|
10421
|
+
"pdm.lock",
|
|
10422
|
+
"Podfile.lock",
|
|
10423
|
+
"Package.resolved"
|
|
10424
|
+
]);
|
|
10425
|
+
var normalizePath = (p) => p.trim().replace(/\\/g, "/").replace(/^\.\//, "");
|
|
10426
|
+
function isIgnoredPath(path, extra = /* @__PURE__ */ new Set()) {
|
|
10427
|
+
const p = normalizePath(path);
|
|
10428
|
+
return extra.has(p) || LOCKFILES.has(p.slice(p.lastIndexOf("/") + 1));
|
|
10429
|
+
}
|
|
10430
|
+
function countedPaths(raw, extra) {
|
|
10431
|
+
const list = Array.isArray(raw) ? raw : typeof raw === "string" ? raw.split(/[\n,]/) : [];
|
|
10432
|
+
return [...new Set(list.map((p) => normalizePath(String(p))).filter((p) => p && !isIgnoredPath(p, extra)))];
|
|
10433
|
+
}
|
|
10434
|
+
var stamp = (e) => e.occurred_at ?? e.created_at ?? "";
|
|
10435
|
+
function declarations(events) {
|
|
10436
|
+
const out = /* @__PURE__ */ new Map();
|
|
10437
|
+
for (const e of events) {
|
|
10438
|
+
if (out.has(e.record_id)) continue;
|
|
10439
|
+
out.set(e.record_id, { paths: countedPaths(e.metadata?.paths), at: stamp(e) });
|
|
10440
|
+
}
|
|
10441
|
+
return out;
|
|
10442
|
+
}
|
|
10443
|
+
function pushes(events) {
|
|
10444
|
+
const out = /* @__PURE__ */ new Map();
|
|
10445
|
+
for (const e of events) {
|
|
10446
|
+
if (out.has(e.record_id)) continue;
|
|
10447
|
+
const raw = e.metadata?.paths;
|
|
10448
|
+
out.set(e.record_id, { at: stamp(e), ...Array.isArray(raw) ? { paths: raw.map((p) => normalizePath(String(p))).filter(Boolean) } : {} });
|
|
10449
|
+
}
|
|
10450
|
+
return out;
|
|
10451
|
+
}
|
|
10452
|
+
function isActive(t) {
|
|
10453
|
+
const s = String(t.status);
|
|
10454
|
+
return s === "in_progress" || s === "fixed" || s === "qa" || s === "verified" && !t.merged_at;
|
|
10455
|
+
}
|
|
10456
|
+
var isWaiting = (t) => t.status === "accepted" || t.status === "blocked";
|
|
10457
|
+
function footprintOf(t, declared, pushed, extra) {
|
|
10458
|
+
const actual = countedPaths(pushed.get(t.id)?.paths, extra);
|
|
10459
|
+
if (t.status === "in_progress") return [.../* @__PURE__ */ new Set([...countedPaths(declared.get(t.id)?.paths, extra), ...actual])];
|
|
10460
|
+
if (isWaiting(t)) return countedPaths(declared.get(t.id)?.paths, extra);
|
|
10461
|
+
return actual;
|
|
10462
|
+
}
|
|
10463
|
+
function byAge(a, b) {
|
|
10464
|
+
const n = (t) => Number(String(t.issue_id).replace(/\D/g, "")) || 0;
|
|
10465
|
+
return n(a) - n(b) || displayKey(a).localeCompare(displayKey(b));
|
|
10466
|
+
}
|
|
10467
|
+
var repoOf = (t) => t.repo_id ?? "";
|
|
10468
|
+
function planFootprints(input) {
|
|
10469
|
+
const waits = /* @__PURE__ */ new Map();
|
|
10470
|
+
const byRepo = /* @__PURE__ */ new Map();
|
|
10471
|
+
for (const t of input.tickets) byRepo.set(repoOf(t), [...byRepo.get(repoOf(t)) ?? [], t]);
|
|
10472
|
+
for (const [repoId, tickets] of byRepo) {
|
|
10473
|
+
const extra = input.ignoreByRepo?.get(repoId);
|
|
10474
|
+
const held = tickets.filter(isActive).map((t) => ({ ticket: t, files: new Set(footprintOf(t, input.declared, input.pushed, extra)) }));
|
|
10475
|
+
const candidates2 = tickets.filter((t) => isWaiting(t) && !input.dependencyBlocked?.has(t.id)).sort(byAge);
|
|
10476
|
+
for (const t of candidates2) {
|
|
10477
|
+
const mine = footprintOf(t, input.declared, input.pushed, extra);
|
|
10478
|
+
const hits = held.filter((h) => h.ticket.id !== t.id && mine.some((f) => h.files.has(f)));
|
|
10479
|
+
if (mine.length === 0 || hits.length === 0) {
|
|
10480
|
+
if (mine.length) held.push({ ticket: t, files: new Set(mine) });
|
|
10481
|
+
continue;
|
|
10482
|
+
}
|
|
10483
|
+
waits.set(t.id, {
|
|
10484
|
+
ticket: t,
|
|
10485
|
+
waitingFor: hits.map((h) => displayKey(h.ticket)),
|
|
10486
|
+
files: [...new Set(hits.flatMap((h) => mine.filter((f) => h.files.has(f))))].sort()
|
|
10487
|
+
});
|
|
10488
|
+
}
|
|
10489
|
+
}
|
|
10490
|
+
return { waits };
|
|
10491
|
+
}
|
|
10492
|
+
function mustYieldTo(self, input) {
|
|
10493
|
+
const extra = input.ignoreByRepo?.get(repoOf(self));
|
|
10494
|
+
const mine = footprintOf(self, input.declared, input.pushed, extra);
|
|
10495
|
+
if (mine.length === 0) return null;
|
|
10496
|
+
const newly = (t) => t.status === "in_progress" && input.declared.has(t.id) && !input.pushed.has(t.id);
|
|
10497
|
+
const number = (t) => Number(String(t.issue_id).replace(/\D/g, "")) || 0;
|
|
10498
|
+
const earlier = (a, b) => {
|
|
10499
|
+
const x = input.declared.get(a.id).at, y = input.declared.get(b.id).at;
|
|
10500
|
+
return x !== y ? x < y : number(a) < number(b);
|
|
10501
|
+
};
|
|
10502
|
+
const hits = input.tickets.filter((o) => o.id !== self.id && repoOf(o) === repoOf(self) && isActive(o)).filter((o) => !(newly(self) && newly(o) && earlier(self, o))).map((o) => ({ o, shared: footprintOf(o, input.declared, input.pushed, extra).filter((f) => mine.includes(f)) })).filter((h) => h.shared.length > 0);
|
|
10503
|
+
if (hits.length === 0) return null;
|
|
10504
|
+
return { waitingFor: hits.map((h) => displayKey(h.o)), files: [...new Set(hits.flatMap((h) => h.shared))].sort() };
|
|
10505
|
+
}
|
|
10506
|
+
function describeFiles(files, shown = 3) {
|
|
10507
|
+
const head = files.slice(0, shown).map((f) => `\`${f}\``).join(", ");
|
|
10508
|
+
return files.length > shown ? `${head} and ${files.length - shown} more` : head;
|
|
10509
|
+
}
|
|
10510
|
+
function footprintWaitNote(w) {
|
|
10511
|
+
return `waiting for ${w.waitingFor.join(", ")}, which changes the same ${w.files.length === 1 ? "file" : "files"}: ${describeFiles(w.files)}`;
|
|
10512
|
+
}
|
|
10513
|
+
function footprintDigestSection(recorded) {
|
|
10514
|
+
const lines2 = recorded.length ? recorded.map((r) => `- ${r.ticket}: ${r.paths.length ? describeFiles(r.paths, 8) : "none"}`).join("\n") : "- none recorded yet";
|
|
10515
|
+
return `### Footprint \u2014 declare before you build
|
|
10516
|
+
|
|
10517
|
+
The crew keeps tickets that would change the same files from being built at the same time. When you pick up a ticket that has **no branch or worktree yet**, before you cut a worktree or change anything:
|
|
10518
|
+
|
|
10519
|
+
1. Read the ticket and the code and list the repo-relative files you expect to change, including files you expect to create. A guess is fine; an empty list is allowed when you cannot tell.
|
|
10520
|
+
2. Run \`crew footprint <ticket number> <path>...\` (just \`crew footprint <ticket number>\` when a footprint is already recorded below). It records the list once, then checks it against the active work.
|
|
10521
|
+
3. If it prints \`YIELD\`, stop there: set the ticket back to \`accepted\`, clear \`assignee_id\`, comment in one line that you declared a footprint and yielded, and end the run without a worktree. The crew parks the ticket as \`blocked\` and restores it when the tickets it waits for are released. If it prints \`PROCEED\`, or the command fails or is not available, go on: a ticket with no footprint simply runs.
|
|
10522
|
+
|
|
10523
|
+
Footprints already recorded:
|
|
10524
|
+
|
|
10525
|
+
${lines2}
|
|
10526
|
+
`;
|
|
10527
|
+
}
|
|
10528
|
+
var MAX_PUSHED_PATHS = 2e3;
|
|
10529
|
+
function pushedMetadata(diffNameOnly) {
|
|
10530
|
+
if (diffNameOnly === null) return void 0;
|
|
10531
|
+
return { paths: [...new Set(diffNameOnly.split("\n").map(normalizePath).filter(Boolean))].slice(0, MAX_PUSHED_PATHS) };
|
|
10532
|
+
}
|
|
10533
|
+
function footprintVerdictText(ticket, y) {
|
|
10534
|
+
return y ? `YIELD ${ticket}: ${footprintWaitNote(y)}. Set the ticket back to accepted, clear assignee_id, comment in one line and end the run without a worktree; the crew parks it and restores it when they are released.` : `PROCEED ${ticket}: no active ticket shares its files.`;
|
|
10535
|
+
}
|
|
10536
|
+
|
|
10537
|
+
// src/footprint-run.ts
|
|
10538
|
+
async function readFootprintEvents(tracker) {
|
|
10539
|
+
return {
|
|
10540
|
+
declared: declarations(await tracker.events(FOOTPRINT_DECLARED_EVENT)),
|
|
10541
|
+
pushed: pushes(await tracker.events("pushed"))
|
|
10542
|
+
};
|
|
10543
|
+
}
|
|
10544
|
+
function ignoreByRepo(route2) {
|
|
10545
|
+
const out = /* @__PURE__ */ new Map();
|
|
10546
|
+
const names = route2.resolved?.repoNames ?? {};
|
|
10547
|
+
for (const target of reposOf(route2)) {
|
|
10548
|
+
let ignored;
|
|
10549
|
+
try {
|
|
10550
|
+
const cfg = resolveRepoConfig(loadRepoConfigTolerant(target.dir), void 0, target.dir);
|
|
10551
|
+
ignored = new Set([...cfg.release.versionFiles, ...cfg.release.changelog ? [cfg.release.changelog] : []].map(normalizePath));
|
|
10552
|
+
} catch {
|
|
10553
|
+
continue;
|
|
10554
|
+
}
|
|
10555
|
+
const ids = Object.entries(names).filter(([, n]) => n === target.name).map(([id]) => id);
|
|
10556
|
+
for (const id of ids.length ? ids : [""]) out.set(id, ignored);
|
|
10557
|
+
}
|
|
10558
|
+
return out;
|
|
10559
|
+
}
|
|
10560
|
+
function planFootprintsFor(route2, tickets, ev, dependencyBlocked) {
|
|
10561
|
+
return planFootprints({ tickets, ...ev, ignoreByRepo: ignoreByRepo(route2), dependencyBlocked });
|
|
10562
|
+
}
|
|
10563
|
+
function pushedEventExtra(dir, remote, base, sha) {
|
|
10564
|
+
return pushedMetadata(gitOk(dir, ["diff", "--no-renames", "--name-only", `${remote}/${base}...${sha}`]));
|
|
10565
|
+
}
|
|
10566
|
+
|
|
10405
10567
|
// src/pending-handoff.ts
|
|
10406
10568
|
import { existsSync as existsSync22, mkdirSync as mkdirSync17, readdirSync as readdirSync7, readFileSync as readFileSync24, rmSync as rmSync13, writeFileSync as writeFileSync18 } from "fs";
|
|
10407
10569
|
import { join as join25 } from "path";
|
|
@@ -10471,7 +10633,7 @@ async function replayPendingHandoffs(i) {
|
|
|
10471
10633
|
});
|
|
10472
10634
|
if (!seen) await i.writer.postComment(t.id, text2, seatId);
|
|
10473
10635
|
}
|
|
10474
|
-
await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), seatId, "pushed");
|
|
10636
|
+
await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), seatId, "pushed", co ? pushedEventExtra(co.dir, v.remote, co.cfg.branch.base, v.sha) : void 0);
|
|
10475
10637
|
await i.writer.updateTicket(t.id, rec.patch);
|
|
10476
10638
|
removePendingHandoff(i.stateDir, rec.ticketRecordId);
|
|
10477
10639
|
i.log.emit(`${displayKey(t)}: replayed a pending hand-off at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, at);
|
|
@@ -10943,7 +11105,7 @@ async function deliverNote(i, ticketId, note, type, log) {
|
|
|
10943
11105
|
}
|
|
10944
11106
|
}
|
|
10945
11107
|
async function postPushed(i, ticketId, sha, remote, branch, log) {
|
|
10946
|
-
await i.writer.postEvent(ticketId, pushedEventBody(sha, remote, branch), i.seatId, "pushed");
|
|
11108
|
+
await i.writer.postEvent(ticketId, pushedEventBody(sha, remote, branch), i.seatId, "pushed", pushedEventExtra(i.dir, remote, i.cfg.branch.base, sha));
|
|
10947
11109
|
const url = i.branchLink?.url(branch);
|
|
10948
11110
|
if (!i.branchLink || !url) return;
|
|
10949
11111
|
try {
|
|
@@ -11300,7 +11462,7 @@ ${i.shipName ? `${i.shipName}'s ` : "A "}${i.role} run set it to \`${st.handoff}
|
|
|
11300
11462
|
const v = inspectHandoff(co.dir, co.cfg, t, i.role);
|
|
11301
11463
|
i.log.warn(`${displayKey(t)} was handed off by a run that did not claim it`, at);
|
|
11302
11464
|
if (v.kind === "pushed") {
|
|
11303
|
-
await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), i.seatId, "pushed");
|
|
11465
|
+
await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), i.seatId, "pushed", pushedEventExtra(co.dir, v.remote, co.cfg.branch.base, v.sha));
|
|
11304
11466
|
} else if (v.kind === "bounce") {
|
|
11305
11467
|
if (v.origin && v.local && !isAncestor(co.dir, v.origin, v.local)) {
|
|
11306
11468
|
i.log.warn(`${displayKey(t)}: \`${v.remote}/${v.branch}\` is at ${v.origin.slice(0, 7)}, not a tip this checkout built \u2014 left alone`, at);
|
|
@@ -13051,10 +13213,20 @@ async function linkReleaseSeat(route2, client2, agentsModel, userAgent, readOnly
|
|
|
13051
13213
|
if (e instanceof CrewAgentFieldMissing) return { note: `Release: ${CREW_FIELD_MISSING_NOTE}` };
|
|
13052
13214
|
throw e;
|
|
13053
13215
|
}
|
|
13054
|
-
const seatRow = await client2
|
|
13216
|
+
const seatRow = await getSeatRow(client2, crewModelId, seatId);
|
|
13217
|
+
if (!seatRow) return { note: `Release: ${SEAT_MISSING_NOTE}` };
|
|
13055
13218
|
if (seatRow[CREW_AGENT_COLUMN] !== agentId) await client2.records.update(crewModelId, seatId, { [columnName]: agentId });
|
|
13056
13219
|
return { agentId };
|
|
13057
13220
|
}
|
|
13221
|
+
var SEAT_MISSING_NOTE = "the configured Crew row no longer exists (deleted?) \u2014 re-run `crew connect` to pick a seat";
|
|
13222
|
+
async function getSeatRow(client2, crewModelId, seatId) {
|
|
13223
|
+
try {
|
|
13224
|
+
return await client2.records.get(crewModelId, seatId);
|
|
13225
|
+
} catch (e) {
|
|
13226
|
+
if (e instanceof TablationApiError && e.status === 404) return null;
|
|
13227
|
+
throw e;
|
|
13228
|
+
}
|
|
13229
|
+
}
|
|
13058
13230
|
var NO_WRITE_NOTE = "this key has no write access to the Agents table";
|
|
13059
13231
|
var CREW_FIELD_MISSING_NOTE = "Crew table has no Agent field yet \u2014 a workspace admin's `crew agents sync` adds it";
|
|
13060
13232
|
var CrewAgentFieldMissing = class extends Error {
|
|
@@ -13089,7 +13261,11 @@ async function linkCrewSeats(route2, client2, agentsModelId, agentPersonas, user
|
|
|
13089
13261
|
outcomes.push({ role, action: readOnly ? "no_agents_row" : "persona_diverged" });
|
|
13090
13262
|
continue;
|
|
13091
13263
|
}
|
|
13092
|
-
const seatRow = await client2
|
|
13264
|
+
const seatRow = await getSeatRow(client2, crewModelId, seatId);
|
|
13265
|
+
if (!seatRow) {
|
|
13266
|
+
outcomes.push({ role, action: "seat_missing" });
|
|
13267
|
+
continue;
|
|
13268
|
+
}
|
|
13093
13269
|
if (seatRow[CREW_AGENT_COLUMN] === agentId) {
|
|
13094
13270
|
outcomes.push({ role, action: "already_linked" });
|
|
13095
13271
|
continue;
|
|
@@ -13166,6 +13342,8 @@ function describeCrewLink(o) {
|
|
|
13166
13342
|
return `${label}: ${CREW_FIELD_MISSING_NOTE}`;
|
|
13167
13343
|
case "no_agents_row":
|
|
13168
13344
|
return `${label}: no Agents row to link yet \u2014 a workspace admin's \`crew agents sync\` creates it; run it here afterwards to link this seat`;
|
|
13345
|
+
case "seat_missing":
|
|
13346
|
+
return `${label}: ${SEAT_MISSING_NOTE}`;
|
|
13169
13347
|
case "persona_diverged":
|
|
13170
13348
|
return `${label}: persona has local edits and was not synced this pass \u2014 skipped linking until it's resolved`;
|
|
13171
13349
|
}
|
|
@@ -18215,11 +18393,19 @@ function sweepDiagnostics(tickets, info) {
|
|
|
18215
18393
|
return { dangling, selfBlocked: [...new Set(selfBlocked)] };
|
|
18216
18394
|
}
|
|
18217
18395
|
var describeBlockers = (t, info) => (t.blocked_by ?? []).map((id) => `${info[id]?.issue_tag ?? info[id]?.issue_id ?? "?"} (${info[id]?.status ?? "unknown"})`).join(", ");
|
|
18218
|
-
function planSweep(tickets, info, blocked, wm) {
|
|
18396
|
+
function planSweep(tickets, info, blocked, wm, footprintWaits) {
|
|
18219
18397
|
const steps = [];
|
|
18220
18398
|
for (const t of withinWorkMode(tickets, wm)) {
|
|
18221
18399
|
if (t.status === "accepted" && blocked.has(t.id)) {
|
|
18222
|
-
|
|
18400
|
+
const fw = footprintWaits?.get(t.id);
|
|
18401
|
+
const byFiles = fw && unresolvedBlockers(t, info).length === 0;
|
|
18402
|
+
steps.push({
|
|
18403
|
+
action: "park",
|
|
18404
|
+
ticket: t,
|
|
18405
|
+
blockers: byFiles ? footprintWaitNote(fw) : describeBlockers(t, info),
|
|
18406
|
+
to: "blocked",
|
|
18407
|
+
...byFiles ? { footprint: { waitingFor: fw.waitingFor, files: fw.files } } : {}
|
|
18408
|
+
});
|
|
18223
18409
|
} else if (t.status === "blocked" && !blocked.has(t.id)) {
|
|
18224
18410
|
steps.push({ action: "restore", ticket: t, blockers: describeBlockers(t, info), to: "accepted" });
|
|
18225
18411
|
}
|
|
@@ -18276,9 +18462,14 @@ function unroutableChanges(unroutable, previous, tickets, externalIdColumn) {
|
|
|
18276
18462
|
};
|
|
18277
18463
|
}
|
|
18278
18464
|
function sweepComment(step) {
|
|
18465
|
+
if (step.action === "park" && step.footprint) {
|
|
18466
|
+
return `Parked as **Blocked** by the crew \u2014 ${footprintWaitNote(step.footprint)}.
|
|
18467
|
+
|
|
18468
|
+
This is automatic and reversible: a ticket that would change a file another active ticket changes waits for it instead of being built in parallel and conflicting at release. The oldest waiting ticket starts first, and this one is restored on the first poll after the tickets it waits for are released, closed or parked for a person. Nothing else about the ticket changes.`;
|
|
18469
|
+
}
|
|
18279
18470
|
return step.action === "park" ? `Parked as **Blocked** by the crew \u2014 waiting on: ${step.blockers}.
|
|
18280
18471
|
|
|
18281
|
-
This is automatic and reversible: an approved ticket whose \`Blocked by\` entries are not all resolved is parked out of the queue, and restored on the first poll after the last one resolves. Nothing else about the ticket changes. A blocker counts as resolved at \`closed_deployed\`, \`closed_wont_fix\` or \`closed_duplicate\`, or at \`verified\` when it is in a different repository or already merged (\`merged_at\` set) \u2014 not at \`fixed\`, which is still an unmerged branch awaiting QA, and not at \`verified\` for a blocker in this ticket's own repository until the release has merged it, so nothing gets built stacked on an unmerged branch.` : `Restored to **Approved** by the crew \u2014 every blocker has resolved${step.blockers && step.blockers !== "\u2014" ? ` (${step.blockers})` : ""}.
|
|
18472
|
+
This is automatic and reversible: an approved ticket whose \`Blocked by\` entries are not all resolved is parked out of the queue, and restored on the first poll after the last one resolves. Nothing else about the ticket changes. A blocker counts as resolved at \`closed_deployed\`, \`closed_wont_fix\` or \`closed_duplicate\`, or at \`verified\` when it is in a different repository or already merged (\`merged_at\` set) \u2014 not at \`fixed\`, which is still an unmerged branch awaiting QA, and not at \`verified\` for a blocker in this ticket's own repository until the release has merged it, so nothing gets built stacked on an unmerged branch.` : `Restored to **Approved** by the crew \u2014 ${step.blockers ? "every blocker has resolved" : "nothing holds it back now (the tickets it waited for no longer hold its files)"}${step.blockers && step.blockers !== "\u2014" ? ` (${step.blockers})` : ""}.
|
|
18282
18473
|
|
|
18283
18474
|
This restores the status it was approved at before being parked; it is back in the queue and a role may pick it up. If a blocker resolved as \`closed_wont_fix\` or \`closed_duplicate\` this ticket may still not be buildable as written \u2014 that is a call for a human, not the crew.`;
|
|
18284
18475
|
}
|
|
@@ -19248,6 +19439,9 @@ async function decideCycle(o) {
|
|
|
19248
19439
|
const extra = await tracker.ticketsByIds(missingBlockerIds(tickets));
|
|
19249
19440
|
const info = blockerInfoMap(tickets, extra);
|
|
19250
19441
|
const blocked = computeBlockedIds(tickets, info);
|
|
19442
|
+
const footprintEvents = await optional("footprint events", readFootprintEvents(tracker), { declared: /* @__PURE__ */ new Map(), pushed: /* @__PURE__ */ new Map() });
|
|
19443
|
+
const footprintPlan = planFootprintsFor(route2, tickets, footprintEvents, new Set(blocked));
|
|
19444
|
+
for (const id of footprintPlan.waits.keys()) blocked.add(id);
|
|
19251
19445
|
emit.enter("sweep");
|
|
19252
19446
|
const roster = buildRoster(configuredMembers(route2), crewRows);
|
|
19253
19447
|
const holds2 = new Set(holdIds(roster));
|
|
@@ -19257,7 +19451,7 @@ async function decideCycle(o) {
|
|
|
19257
19451
|
if (diag.selfBlocked.length) {
|
|
19258
19452
|
emit.warn(`ticket(s) blocking themselves, parked permanently: ${diag.selfBlocked.join(", ")}`);
|
|
19259
19453
|
}
|
|
19260
|
-
const sweep = planSweep(tickets, info, blocked, workModes);
|
|
19454
|
+
const sweep = planSweep(tickets, info, blocked, workModes, footprintPlan.waits);
|
|
19261
19455
|
const holdReleases = planHoldReleases(tickets, tracker.contract);
|
|
19262
19456
|
const stalled = planStalled(tickets, comments, ships, tracker.contract, holds2, Date.now(), workModes, stalledEvents);
|
|
19263
19457
|
const skipped = skippedByMode(tickets, workModes);
|
|
@@ -19372,6 +19566,8 @@ async function decideCycle(o) {
|
|
|
19372
19566
|
roster,
|
|
19373
19567
|
ships,
|
|
19374
19568
|
blocked,
|
|
19569
|
+
footprints: footprintPlan,
|
|
19570
|
+
footprintEvents,
|
|
19375
19571
|
info,
|
|
19376
19572
|
sweep,
|
|
19377
19573
|
epicSync,
|
|
@@ -19487,7 +19683,11 @@ function writeDigest(o, d, role, stateDir, runId, own) {
|
|
|
19487
19683
|
blocked: d.blocked,
|
|
19488
19684
|
blockerInfo: d.info
|
|
19489
19685
|
};
|
|
19490
|
-
const
|
|
19686
|
+
const fp = d.footprintEvents;
|
|
19687
|
+
const recorded = fp ? d.tickets.filter((t) => fp.declared.has(t.id) && !["fixed", "qa", "verified"].includes(String(t.status))).map((t) => ({ ticket: displayKey(t), paths: footprintOf(t, fp.declared, fp.pushed) })) : [];
|
|
19688
|
+
const body = role === "qa" ? qaDigest(input) : `${buildingDigest(input)}
|
|
19689
|
+
|
|
19690
|
+
${footprintDigestSection(recorded)}`;
|
|
19491
19691
|
const text2 = own ? `${ownRunBanner(own)}
|
|
19492
19692
|
|
|
19493
19693
|
${body}` : body;
|
|
@@ -19569,11 +19769,11 @@ async function resolveOne(tracker, t, seat, approvedStatus, buildingStatus, affi
|
|
|
19569
19769
|
return { ticket: t, claimed: false, contended, unservable, held, reaccepted: false, tookOverFrom: null };
|
|
19570
19770
|
}
|
|
19571
19771
|
if (affinity && t[affinity.column] !== affinity.shipId) {
|
|
19572
|
-
const
|
|
19573
|
-
if (
|
|
19574
|
-
return { ticket:
|
|
19772
|
+
const stamp2 = await stampResumption(tracker, t, affinity);
|
|
19773
|
+
if (stamp2.outcome === "stamped") {
|
|
19774
|
+
return { ticket: stamp2.ticket, claimed: false, contended, unservable, held, reaccepted: false, tookOverFrom: displacedHolder(t, affinity) };
|
|
19575
19775
|
}
|
|
19576
|
-
(
|
|
19776
|
+
(stamp2.outcome === "held" ? held : contended).push(t.issue_id);
|
|
19577
19777
|
return "walk";
|
|
19578
19778
|
}
|
|
19579
19779
|
return { ticket: t, claimed: false, contended, unservable, held, reaccepted: false, tookOverFrom: null };
|
|
@@ -19756,9 +19956,9 @@ function worktreeForBranch(cwd, branch) {
|
|
|
19756
19956
|
var stampOf = (e) => e.occurred_at ?? e.created_at ?? "";
|
|
19757
19957
|
var priorBounces = (ticket, events) => {
|
|
19758
19958
|
const mine = events.filter((e) => e.record_id === ticket.id);
|
|
19759
|
-
const
|
|
19959
|
+
const pushes2 = mine.filter((e) => e.event_type === "pushed").map(stampOf);
|
|
19760
19960
|
return mine.filter(
|
|
19761
|
-
(e) => e.event_type === "conflict_handed_back" &&
|
|
19961
|
+
(e) => e.event_type === "conflict_handed_back" && pushes2.some((p) => p > stampOf(e))
|
|
19762
19962
|
).length;
|
|
19763
19963
|
};
|
|
19764
19964
|
var baseShaOf = (e) => {
|
|
@@ -19768,8 +19968,8 @@ var baseShaOf = (e) => {
|
|
|
19768
19968
|
};
|
|
19769
19969
|
var lastActedHandBack = (ticket, events) => {
|
|
19770
19970
|
const mine = events.filter((e) => e.record_id === ticket.id);
|
|
19771
|
-
const
|
|
19772
|
-
return mine.filter((e) => e.event_type === "conflict_handed_back" &&
|
|
19971
|
+
const pushes2 = mine.filter((e) => e.event_type === "pushed").map(stampOf);
|
|
19972
|
+
return mine.filter((e) => e.event_type === "conflict_handed_back" && pushes2.some((p) => p > stampOf(e))).sort((a, b) => stampOf(b).localeCompare(stampOf(a)))[0];
|
|
19773
19973
|
};
|
|
19774
19974
|
var MAX_ABSORBED_HANDBACKS = 2;
|
|
19775
19975
|
function planConflictBounce(cwd, ticket, branch, base, paths, events, merged = []) {
|
|
@@ -19969,14 +20169,14 @@ ${b.tail.trimEnd()}
|
|
|
19969
20169
|
Nothing was written to \`${b.base}\` for this ticket; the rest of the release shipped without it.`;
|
|
19970
20170
|
}
|
|
19971
20171
|
function priorBuildFailures(ticket, events) {
|
|
19972
|
-
const
|
|
20172
|
+
const stamp2 = (e) => e.occurred_at ?? e.created_at ?? "";
|
|
19973
20173
|
const mine = events.filter((e) => e.record_id === ticket.id);
|
|
19974
|
-
const
|
|
19975
|
-
return mine.filter((e) => e.event_type === "build_failed" &&
|
|
20174
|
+
const pushes2 = mine.filter((e) => e.event_type === "pushed").map(stamp2);
|
|
20175
|
+
return mine.filter((e) => e.event_type === "build_failed" && pushes2.some((p) => p > stamp2(e))).length;
|
|
19976
20176
|
}
|
|
19977
20177
|
function priorFailureNote(ticket, events) {
|
|
19978
|
-
const
|
|
19979
|
-
return events.filter((e) => e.record_id === ticket.id && e.event_type === "build_failed").sort((a, b) =>
|
|
20178
|
+
const stamp2 = (e) => e.occurred_at ?? e.created_at ?? "";
|
|
20179
|
+
return events.filter((e) => e.record_id === ticket.id && e.event_type === "build_failed").sort((a, b) => stamp2(a).localeCompare(stamp2(b))).map((e) => e.message ?? "").pop();
|
|
19980
20180
|
}
|
|
19981
20181
|
function failureComparison(b, previousNote) {
|
|
19982
20182
|
const now = b.failingFiles ?? failingPaths(b.tail, b.cwd ?? "/\0");
|
|
@@ -20994,8 +21194,8 @@ async function discoverPullRequests(i) {
|
|
|
20994
21194
|
for (const t of candidates2) {
|
|
20995
21195
|
const mine = pushed.filter((e) => e.record_id === t.id);
|
|
20996
21196
|
if (mine.length === 0) continue;
|
|
20997
|
-
const
|
|
20998
|
-
const ordered = [...mine].sort((a, b) => Date.parse(
|
|
21197
|
+
const stamp2 = (e) => e.occurred_at ?? e.created_at ?? "";
|
|
21198
|
+
const ordered = [...mine].sort((a, b) => Date.parse(stamp2(a)) - Date.parse(stamp2(b)));
|
|
20999
21199
|
const branch = pushedBranchOf(ordered[ordered.length - 1].message);
|
|
21000
21200
|
if (!branch) continue;
|
|
21001
21201
|
const target = repoTargetFor(i.route, t.repo_id);
|
|
@@ -21009,7 +21209,7 @@ async function discoverPullRequests(i) {
|
|
|
21009
21209
|
}
|
|
21010
21210
|
if (!token) continue;
|
|
21011
21211
|
try {
|
|
21012
|
-
const pull = selectPull(await listPulls(host, remote, branch, token, i.fetcher),
|
|
21212
|
+
const pull = selectPull(await listPulls(host, remote, branch, token, i.fetcher), stamp2(ordered[0]) || null);
|
|
21013
21213
|
if (!pull) continue;
|
|
21014
21214
|
const patch2 = { [cols.prUrl]: pull.url };
|
|
21015
21215
|
if (have.prRef && blank(t[cols.prRef])) patch2[cols.prRef] = pull.url;
|
|
@@ -25615,6 +25815,9 @@ function renderStatus(v, opts) {
|
|
|
25615
25815
|
for (const t of shown) out.push(` ${waitingLine(t)}`);
|
|
25616
25816
|
if (shown.length < sorted2.length) out.push(` \u2026 ${sorted2.length - shown.length} more (\`crew status --verbose\` lists all)`);
|
|
25617
25817
|
}
|
|
25818
|
+
for (const w of v.waits ?? []) {
|
|
25819
|
+
out.push(`waiting: ${w.ticket} \u2014 for ${w.waitingFor.join(", ")} on ${describeFiles(w.files)}`);
|
|
25820
|
+
}
|
|
25618
25821
|
const notable = v.repos.filter((r) => verbose || r.notable);
|
|
25619
25822
|
for (const r of notable) out.push(`releaser: ${r.name} \u2014 ${r.releaser}`);
|
|
25620
25823
|
const rest = v.repos.length - notable.length;
|
|
@@ -27834,7 +28037,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
27834
28037
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
27835
28038
|
import { join as join60 } from "path";
|
|
27836
28039
|
function builtVersion() {
|
|
27837
|
-
return true ? "0.
|
|
28040
|
+
return true ? "0.156.1" : null;
|
|
27838
28041
|
}
|
|
27839
28042
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
27840
28043
|
function newestMtime(path) {
|
|
@@ -30064,6 +30267,7 @@ function usage(problem, requested = false) {
|
|
|
30064
30267
|
crew shell-init [--shell zsh|bash|fish] print the periscope shell function (install: eval "$(crew shell-init)")
|
|
30065
30268
|
crew worktree [route] NNN cut (or refresh) this run's worktree for a ticket from the remote; prints its path
|
|
30066
30269
|
crew unassign [route] NNN hand back a session's ticket \u2014 clears assignee, next cycle picks it up
|
|
30270
|
+
crew footprint [route] NNN [path...] record the files a ticket will change (once), then print PROCEED or YIELD against active work
|
|
30067
30271
|
crew sandbox cache [--refresh|--prune|--reset] [--json] list the sandbox cache volume's mirrors; --refresh runs the daemon's cache pass once (creates missing mirrors), --prune drops unserved repositories, --reset recreates the volume
|
|
30068
30272
|
crew sync [route] fast-forward the checkout and its worktrees from the remote
|
|
30069
30273
|
crew pause|resume [route] [R|release] pause everything, one role, or releases only (merge/deploy/release; passengers keeps running).
|
|
@@ -30193,6 +30397,7 @@ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
30193
30397
|
"status",
|
|
30194
30398
|
"sync",
|
|
30195
30399
|
"unassign",
|
|
30400
|
+
"footprint",
|
|
30196
30401
|
"uninstall",
|
|
30197
30402
|
"watch",
|
|
30198
30403
|
"whoami",
|
|
@@ -34737,7 +34942,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
34737
34942
|
}
|
|
34738
34943
|
await trD.updateTicket(id, patch2);
|
|
34739
34944
|
},
|
|
34740
|
-
postPushed: (id, sha, rem, branch) => trD.postEvent(id, pushedEventBody(sha, rem, branch), memberD, "pushed"),
|
|
34945
|
+
postPushed: (id, sha, rem, branch) => trD.postEvent(id, pushedEventBody(sha, rem, branch), memberD, "pushed", pushedEventExtra(repoD.dir, rem, base, sha)),
|
|
34741
34946
|
stopTunnel: (id) => {
|
|
34742
34947
|
const sc = readPeriscopeSidecars(cfg.ship.stateDir).find((x) => x.ticketRecordId === id);
|
|
34743
34948
|
return sc && stopRecordedTunnel(sc) ? 1 : 0;
|
|
@@ -35074,6 +35279,43 @@ ${where.join("\n")}`);
|
|
|
35074
35279
|
}
|
|
35075
35280
|
break;
|
|
35076
35281
|
}
|
|
35282
|
+
case "footprint": {
|
|
35283
|
+
const args = positional.slice(1);
|
|
35284
|
+
const at = args.findIndex((a) => parseTicketNumber(a) !== null);
|
|
35285
|
+
const n = at >= 0 ? parseTicketNumber(args[at]) : null;
|
|
35286
|
+
if (!n) {
|
|
35287
|
+
die("crew footprint", "need a ticket number (326, ISSUE-326, or TABL-326)", "`crew footprint 326 src/a.ts src/b.ts`");
|
|
35288
|
+
}
|
|
35289
|
+
const trF = new Tracker(route2, cfg.ship);
|
|
35290
|
+
const cF = trF.contract;
|
|
35291
|
+
const openF = await trF.openTickets();
|
|
35292
|
+
const ticketF = openF.find((t) => t[cF.columns.key] === `ISSUE-${n}`);
|
|
35293
|
+
if (!ticketF) {
|
|
35294
|
+
die("crew footprint", `no open ticket ISSUE-${n} on ${route2.route}`, "`crew inbox` to list open tickets");
|
|
35295
|
+
}
|
|
35296
|
+
let evF = await readFootprintEvents(trF);
|
|
35297
|
+
if (!evF.declared.has(ticketF.id)) {
|
|
35298
|
+
const listed = countedPaths(args.slice(at + 1));
|
|
35299
|
+
if (dryRun) {
|
|
35300
|
+
emit.emit(`would record a footprint of ${listed.length} file(s) on ${displayKey(ticketF)}`);
|
|
35301
|
+
break;
|
|
35302
|
+
}
|
|
35303
|
+
const seatF = route2.resolved?.seats.dev ?? route2.resolved?.operator ?? "";
|
|
35304
|
+
await trF.postEvent(
|
|
35305
|
+
ticketF.id,
|
|
35306
|
+
`footprint: ${listed.length ? listed.join(", ") : "none given"}`,
|
|
35307
|
+
seatF,
|
|
35308
|
+
FOOTPRINT_DECLARED_EVENT,
|
|
35309
|
+
{ paths: listed }
|
|
35310
|
+
);
|
|
35311
|
+
evF = await readFootprintEvents(trF);
|
|
35312
|
+
if (!evF.declared.has(ticketF.id)) evF.declared.set(ticketF.id, { paths: listed, at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
35313
|
+
}
|
|
35314
|
+
const verdictF = mustYieldTo(ticketF, { tickets: openF, ...evF, ignoreByRepo: ignoreByRepo(route2) });
|
|
35315
|
+
process.stdout.write(`${footprintVerdictText(displayKey(ticketF), verdictF)}
|
|
35316
|
+
`);
|
|
35317
|
+
break;
|
|
35318
|
+
}
|
|
35077
35319
|
case "sync": {
|
|
35078
35320
|
emit.enter("worktree");
|
|
35079
35321
|
let tracked2 = 0;
|
|
@@ -35787,14 +36029,13 @@ ${where.join("\n")}`);
|
|
|
35787
36029
|
}
|
|
35788
36030
|
const shipAttention = openShipAttention(state);
|
|
35789
36031
|
let heldReleases = [];
|
|
36032
|
+
let waitViews = [];
|
|
35790
36033
|
let deferredReleases = [];
|
|
35791
36034
|
try {
|
|
35792
36035
|
const open = await statusTracker.openTickets();
|
|
35793
|
-
|
|
35794
|
-
|
|
35795
|
-
|
|
35796
|
-
blockerInfoMap(open, await statusTracker.ticketsByIds(missingBlockerIds(open)))
|
|
35797
|
-
));
|
|
36036
|
+
const blockerInfo = blockerInfoMap(open, await statusTracker.ticketsByIds(missingBlockerIds(open)));
|
|
36037
|
+
heldReleases = describeHeld(heldByBlockers(open, statusTracker.contract.statuses.verified, blockerInfo));
|
|
36038
|
+
waitViews = [...planFootprintsFor(route2, open, await readFootprintEvents(statusTracker), computeBlockedIds(open, blockerInfo)).waits.values()].map((w) => ({ ticket: displayKey(w.ticket), waitingFor: w.waitingFor, files: w.files }));
|
|
35798
36039
|
const minutes = Math.min(...(await resolvedRepos(route2)).map((r) => r.config.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES), DEFAULT_RIGHT_OF_WAY_MINUTES);
|
|
35799
36040
|
if (open.some((t) => t.status === statusTracker.contract.statuses.verified)) {
|
|
35800
36041
|
deferredReleases = deferredFromLog(
|
|
@@ -35845,6 +36086,7 @@ ${where.join("\n")}`);
|
|
|
35845
36086
|
})),
|
|
35846
36087
|
repos: repoViews,
|
|
35847
36088
|
heldReleases,
|
|
36089
|
+
waits: waitViews,
|
|
35848
36090
|
deferredReleases,
|
|
35849
36091
|
starved: waiting ? { ticket: waiting.ticket, since: waiting.since, streak: fairness.streak() } : void 0,
|
|
35850
36092
|
ships: shipRows.map((s) => ({
|
package/package.json
CHANGED