@tablation/crew 0.137.6 → 0.137.8
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 +27 -17
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6894,6 +6894,7 @@ import { createHash as createHash6, randomUUID } from "crypto";
|
|
|
6894
6894
|
import { readFileSync as readFileSync20, writeFileSync as writeFileSync15, existsSync as existsSync19, mkdirSync as mkdirSync14, rmSync as rmSync10, statSync as statSync7, readdirSync as readdirSync6 } from "fs";
|
|
6895
6895
|
import { join as join22 } from "path";
|
|
6896
6896
|
var EPOCH = "1970-01-01T00:00:00.000Z";
|
|
6897
|
+
var watermarkFile = (scope) => scope ? `.poll-watermark-${scope}` : ".poll-watermark";
|
|
6897
6898
|
var State = class _State {
|
|
6898
6899
|
dir;
|
|
6899
6900
|
constructor(dir) {
|
|
@@ -6910,16 +6911,16 @@ var State = class _State {
|
|
|
6910
6911
|
* evaluated: bumping it inside the first role's check would hide that
|
|
6911
6912
|
* role's new comments from the second.
|
|
6912
6913
|
*/
|
|
6913
|
-
watermark() {
|
|
6914
|
+
watermark(scope) {
|
|
6914
6915
|
try {
|
|
6915
|
-
const v = readFileSync20(this.path(
|
|
6916
|
+
const v = readFileSync20(this.path(watermarkFile(scope)), "utf8").trim();
|
|
6916
6917
|
return v || EPOCH;
|
|
6917
6918
|
} catch {
|
|
6918
6919
|
return EPOCH;
|
|
6919
6920
|
}
|
|
6920
6921
|
}
|
|
6921
|
-
setWatermark(at) {
|
|
6922
|
-
writeFileSync15(this.path(
|
|
6922
|
+
setWatermark(at, scope) {
|
|
6923
|
+
writeFileSync15(this.path(watermarkFile(scope)), `${at}
|
|
6923
6924
|
`);
|
|
6924
6925
|
}
|
|
6925
6926
|
/**
|
|
@@ -6929,10 +6930,10 @@ var State = class _State {
|
|
|
6929
6930
|
* and the write — a race that loses work rather than repeating it, which is
|
|
6930
6931
|
* the wrong way round. Repeating a cycle is free; missing one is not.
|
|
6931
6932
|
*/
|
|
6932
|
-
advanceWatermark(seen) {
|
|
6933
|
+
advanceWatermark(seen, scope) {
|
|
6933
6934
|
const stamps = seen.flatMap((s) => [s.created_at, s.updated_at]).filter((v) => typeof v === "string" && v.length > 0);
|
|
6934
|
-
const next = stamps.length ? stamps.reduce((a, b) => a > b ? a : b) : this.watermark();
|
|
6935
|
-
this.setWatermark(next);
|
|
6935
|
+
const next = stamps.length ? stamps.reduce((a, b) => a > b ? a : b) : this.watermark(scope);
|
|
6936
|
+
this.setWatermark(next, scope);
|
|
6936
6937
|
return next;
|
|
6937
6938
|
}
|
|
6938
6939
|
/** Whole-crew pause, and the per-role sentinels one level down. */
|
|
@@ -17785,7 +17786,7 @@ var STALLED_AFTER_CYCLES = 30;
|
|
|
17785
17786
|
var CYCLE_MS = 120 * 1e3;
|
|
17786
17787
|
var STALLED_AFTER_MS = STALLED_AFTER_CYCLES * CYCLE_MS;
|
|
17787
17788
|
var STALLED_MARKER = calloutHeader("WARNING", "Stalled");
|
|
17788
|
-
var stalledKey = (issueId) => `stalled:${issueId}`;
|
|
17789
|
+
var stalledKey = (issueId, routeScope) => routeScope ? `stalled:${routeScope}:${issueId}` : `stalled:${issueId}`;
|
|
17789
17790
|
var ms = (iso) => {
|
|
17790
17791
|
const n = iso ? Date.parse(iso) : NaN;
|
|
17791
17792
|
return Number.isFinite(n) ? n : 0;
|
|
@@ -17802,6 +17803,7 @@ function planStalled(tickets, comments, ships, contract, holds2 = /* @__PURE__ *
|
|
|
17802
17803
|
for (const t of withinWorkMode(tickets, wm)) {
|
|
17803
17804
|
if (!watched.has(t.status)) continue;
|
|
17804
17805
|
if (t.assignee_id && holds2.has(t.assignee_id)) continue;
|
|
17806
|
+
if (t.needs_review === true || t.needs_planning === true) continue;
|
|
17805
17807
|
const mine = byTicket.get(t.id) ?? [];
|
|
17806
17808
|
const lastMarker = Math.max(0, ...events.filter((e) => e.record_id === t.id && e.event_type === "stalled").map((e) => ms(e.occurred_at ?? e.created_at ?? "")));
|
|
17807
17809
|
const lastActivityAt = Math.max(
|
|
@@ -17867,10 +17869,15 @@ async function runStalledSweep(o, stalled) {
|
|
|
17867
17869
|
o.dryRun ?? false
|
|
17868
17870
|
);
|
|
17869
17871
|
if (o.dryRun) return r;
|
|
17870
|
-
const
|
|
17871
|
-
|
|
17872
|
+
const scope = o.route ? routeSlug(o.route.route) : void 0;
|
|
17873
|
+
const prefix = scope ? `stalled:${scope}:` : "stalled:";
|
|
17874
|
+
const scoped = r.attention.map((i) => scope ? { ...i, key: stalledKey(i.key.slice("stalled:".length), scope) } : i);
|
|
17875
|
+
const keep = new Set(scoped.map((i) => i.key));
|
|
17876
|
+
for (const item of scoped) await raiseShipAttention({ state: o.state, emit: o.emit, route: o.route, ship: o.ship }, item);
|
|
17872
17877
|
for (const open of o.state.shipAttention().previous()) {
|
|
17873
|
-
if (open.kind
|
|
17878
|
+
if (open.kind !== "stalled" || keep.has(open.key)) continue;
|
|
17879
|
+
const unscoped = !/^stalled:[^:]+:/.test(open.key);
|
|
17880
|
+
if (unscoped || open.key.startsWith(prefix)) clearShipAttention(o.state, open.key);
|
|
17874
17881
|
}
|
|
17875
17882
|
return r;
|
|
17876
17883
|
}
|
|
@@ -18021,7 +18028,7 @@ async function decideCycle(o) {
|
|
|
18021
18028
|
emit.warn("could not mint a record-link URL for at least one attention event this cycle", { step: "sweep" });
|
|
18022
18029
|
}
|
|
18023
18030
|
emit.enter("select");
|
|
18024
|
-
const watermark = state.watermark();
|
|
18031
|
+
const watermark = state.watermark(routeSlug(route2.route));
|
|
18025
18032
|
for (const repo of recheckBaseStops(state, route2)) {
|
|
18026
18033
|
emit.emit(`${repo}: primary checkout is level again \u2014 building lanes resume for that repo`, { step: "select" });
|
|
18027
18034
|
}
|
|
@@ -18067,7 +18074,7 @@ async function decideCycle(o) {
|
|
|
18067
18074
|
attention: attentionCurrent,
|
|
18068
18075
|
unroutable
|
|
18069
18076
|
};
|
|
18070
|
-
const advanced = state.advanceWatermark([...comments, ...tickets]);
|
|
18077
|
+
const advanced = state.advanceWatermark([...comments, ...tickets], routeSlug(route2.route));
|
|
18071
18078
|
if (advanced !== watermark) {
|
|
18072
18079
|
emit.emit(`watermark ${watermark.slice(0, 19)} -> ${advanced.slice(0, 19)}`, {
|
|
18073
18080
|
step: "poll",
|
|
@@ -20858,9 +20865,10 @@ function clearNoopRuns(stateDir, recordId) {
|
|
|
20858
20865
|
delete state[recordId];
|
|
20859
20866
|
writeNoopRuns(stateDir, state);
|
|
20860
20867
|
}
|
|
20861
|
-
function noopAttentionMessage(tag, role, count, nextAt, lastComment2) {
|
|
20868
|
+
function noopAttentionMessage(tag, role, count, nextAt, lastComment2, waitingOnPerson = false) {
|
|
20862
20869
|
const mins = Math.max(1, Math.round((nextAt - Date.now()) / 6e4));
|
|
20863
|
-
|
|
20870
|
+
const next = waitingOnPerson ? "waiting on a person to answer before it is picked up again" : `next attempt in about ${mins} minutes`;
|
|
20871
|
+
return `${tag}: ${role} run ended ${count} time${count === 1 ? "" : "s"} in a row with nothing pushed and no hand-off; ${next}` + (lastComment2 ? `. Its last comment: ${lastComment2.slice(0, 300)}` : "");
|
|
20864
20872
|
}
|
|
20865
20873
|
function noopBounceComment(count, lastComment2) {
|
|
20866
20874
|
return `${NOOP_BOUNCED_MARKER}
|
|
@@ -20874,7 +20882,9 @@ ${lastComment2}
|
|
|
20874
20882
|
async function settleNoopRun(o) {
|
|
20875
20883
|
const tag = o.before.issue_tag ?? o.before.issue_id;
|
|
20876
20884
|
const after = await o.tracker.ticket(o.ticketId);
|
|
20877
|
-
const
|
|
20885
|
+
const flagged = (k) => Boolean(after[k]) && !o.before[k];
|
|
20886
|
+
const noop = o.before[o.columns.status] === o.statuses.building && after[o.columns.status] === o.before[o.columns.status] && after[o.columns.assignee] === o.before[o.columns.assignee] && o.tipBefore === o.tipAfter && !flagged("needs_review") && !flagged("needs_planning") && // A person owes an answer, so an earlier stale entry for this ticket is not a repeat either.
|
|
20887
|
+
!after.needs_review;
|
|
20878
20888
|
if (!noop) {
|
|
20879
20889
|
clearNoopRuns(o.stateDir, o.ticketId);
|
|
20880
20890
|
o.clear(noopRunsKey(o.before.issue_id));
|
|
@@ -20892,7 +20902,7 @@ async function settleNoopRun(o) {
|
|
|
20892
20902
|
kind: "noop_runs",
|
|
20893
20903
|
key: noopRunsKey(o.before.issue_id),
|
|
20894
20904
|
since: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20895
|
-
message: noopAttentionMessage(tag, o.role, verdict.count, verdict.nextAt, last)
|
|
20905
|
+
message: noopAttentionMessage(tag, o.role, verdict.count, verdict.nextAt, last, Boolean(after.needs_planning))
|
|
20896
20906
|
});
|
|
20897
20907
|
return "backoff";
|
|
20898
20908
|
}
|
package/package.json
CHANGED