@tablation/crew 0.137.7 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +26 -17
  2. 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(".poll-watermark"), "utf8").trim();
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(".poll-watermark"), `${at}
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;
@@ -17868,10 +17869,15 @@ async function runStalledSweep(o, stalled) {
17868
17869
  o.dryRun ?? false
17869
17870
  );
17870
17871
  if (o.dryRun) return r;
17871
- const keep = new Set(r.attention.map((i) => i.key));
17872
- for (const item of r.attention) await raiseShipAttention({ state: o.state, emit: o.emit, route: o.route, ship: o.ship }, item);
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);
17873
17877
  for (const open of o.state.shipAttention().previous()) {
17874
- if (open.kind === "stalled" && !keep.has(open.key)) clearShipAttention(o.state, open.key);
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);
17875
17881
  }
17876
17882
  return r;
17877
17883
  }
@@ -18022,7 +18028,7 @@ async function decideCycle(o) {
18022
18028
  emit.warn("could not mint a record-link URL for at least one attention event this cycle", { step: "sweep" });
18023
18029
  }
18024
18030
  emit.enter("select");
18025
- const watermark = state.watermark();
18031
+ const watermark = state.watermark(routeSlug(route2.route));
18026
18032
  for (const repo of recheckBaseStops(state, route2)) {
18027
18033
  emit.emit(`${repo}: primary checkout is level again \u2014 building lanes resume for that repo`, { step: "select" });
18028
18034
  }
@@ -18068,7 +18074,7 @@ async function decideCycle(o) {
18068
18074
  attention: attentionCurrent,
18069
18075
  unroutable
18070
18076
  };
18071
- const advanced = state.advanceWatermark([...comments, ...tickets]);
18077
+ const advanced = state.advanceWatermark([...comments, ...tickets], routeSlug(route2.route));
18072
18078
  if (advanced !== watermark) {
18073
18079
  emit.emit(`watermark ${watermark.slice(0, 19)} -> ${advanced.slice(0, 19)}`, {
18074
18080
  step: "poll",
@@ -20859,9 +20865,10 @@ function clearNoopRuns(stateDir, recordId) {
20859
20865
  delete state[recordId];
20860
20866
  writeNoopRuns(stateDir, state);
20861
20867
  }
20862
- function noopAttentionMessage(tag, role, count, nextAt, lastComment2) {
20868
+ function noopAttentionMessage(tag, role, count, nextAt, lastComment2, waitingOnPerson = false) {
20863
20869
  const mins = Math.max(1, Math.round((nextAt - Date.now()) / 6e4));
20864
- return `${tag}: ${role} run ended ${count} time${count === 1 ? "" : "s"} in a row with nothing pushed and no hand-off; next attempt in about ${mins} minutes` + (lastComment2 ? `. Its last comment: ${lastComment2.slice(0, 300)}` : "");
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)}` : "");
20865
20872
  }
20866
20873
  function noopBounceComment(count, lastComment2) {
20867
20874
  return `${NOOP_BOUNCED_MARKER}
@@ -20875,7 +20882,9 @@ ${lastComment2}
20875
20882
  async function settleNoopRun(o) {
20876
20883
  const tag = o.before.issue_tag ?? o.before.issue_id;
20877
20884
  const after = await o.tracker.ticket(o.ticketId);
20878
- 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;
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;
20879
20888
  if (!noop) {
20880
20889
  clearNoopRuns(o.stateDir, o.ticketId);
20881
20890
  o.clear(noopRunsKey(o.before.issue_id));
@@ -20893,7 +20902,7 @@ async function settleNoopRun(o) {
20893
20902
  kind: "noop_runs",
20894
20903
  key: noopRunsKey(o.before.issue_id),
20895
20904
  since: (/* @__PURE__ */ new Date()).toISOString(),
20896
- 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))
20897
20906
  });
20898
20907
  return "backoff";
20899
20908
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.137.7",
3
+ "version": "0.137.8",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",