@tablation/crew 0.164.0 → 0.164.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.
Files changed (2) hide show
  1. package/dist/cli.js +57 -21
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7567,16 +7567,16 @@ var State = class _State {
7567
7567
  reason: roleMax === 1 ? `${role} is already running (pid ${roleHolders[0]})` : `${role} is already running ${roleMax} agents (its roleConcurrency cap; pid${roleHolders.length > 1 ? "s" : ""} ${[...new Set(roleHolders)].join(", ")})`
7568
7568
  };
7569
7569
  }
7570
- const slot = this.acquireN("crew-slot", max);
7571
- if (!slot.ok) {
7570
+ const slot2 = this.acquireN("crew-slot", max);
7571
+ if (!slot2.ok) {
7572
7572
  roleLock.release();
7573
7573
  return {
7574
7574
  ok: false,
7575
- reason: `at capacity \u2014 ${max} agent(s) already running (pid${slot.heldBy.length > 1 ? "s" : ""} ${slot.heldBy.join(", ")})`
7575
+ reason: `at capacity \u2014 ${max} agent(s) already running (pid${slot2.heldBy.length > 1 ? "s" : ""} ${slot2.heldBy.join(", ")})`
7576
7576
  };
7577
7577
  }
7578
7578
  return { ok: true, release: () => {
7579
- slot.release();
7579
+ slot2.release();
7580
7580
  roleLock.release();
7581
7581
  } };
7582
7582
  }
@@ -18893,12 +18893,12 @@ function sweepDiagnostics(tickets, info) {
18893
18893
  return { dangling, selfBlocked: [...new Set(selfBlocked)] };
18894
18894
  }
18895
18895
  var describeBlockers = (t, info) => (t.blocked_by ?? []).map((id) => `${info[id]?.issue_tag ?? info[id]?.issue_id ?? "?"} (${info[id]?.status ?? "unknown"})`).join(", ");
18896
- function planSweep(tickets, info, blocked, wm, footprintWaits) {
18896
+ function planSweep(tickets, info, blocked, wm, footprintWaits, resolved) {
18897
18897
  const steps = [];
18898
18898
  for (const t of withinWorkMode(tickets, wm)) {
18899
18899
  if (t.status === "accepted" && blocked.has(t.id)) {
18900
18900
  const fw = footprintWaits?.get(t.id);
18901
- const byFiles = fw && unresolvedBlockers(t, info).length === 0;
18901
+ const byFiles = fw && unresolvedBlockers(t, info, { resolved }).length === 0;
18902
18902
  steps.push({
18903
18903
  action: "park",
18904
18904
  ticket: t,
@@ -20090,7 +20090,8 @@ async function decideCycle(o) {
20090
20090
  const extra = await tracker.ticketsByIds(missingBlockerIds(tickets));
20091
20091
  const info = blockerInfoMap(tickets, extra);
20092
20092
  await reportTruncated(tracker, route2.route, state, emit);
20093
- const blocked = computeBlockedIds(tickets, info, { resolved: new Set(tracker.contract.statuses.resolved) });
20093
+ const resolvedStatuses = new Set(tracker.contract.statuses.resolved);
20094
+ const blocked = computeBlockedIds(tickets, info, { resolved: resolvedStatuses });
20094
20095
  const footprintEvents = await optional("footprint events", readFootprintEvents(tracker), { declared: /* @__PURE__ */ new Map(), pushed: /* @__PURE__ */ new Map() });
20095
20096
  const footprintPlan = planFootprintsFor(route2, tickets, footprintEvents, new Set(blocked));
20096
20097
  for (const id of footprintPlan.waits.keys()) blocked.add(id);
@@ -20103,7 +20104,7 @@ async function decideCycle(o) {
20103
20104
  if (diag.selfBlocked.length) {
20104
20105
  emit.warn(`ticket(s) blocking themselves, parked permanently: ${diag.selfBlocked.join(", ")}`);
20105
20106
  }
20106
- const sweep = planSweep(tickets, info, blocked, workModes, footprintPlan.waits);
20107
+ const sweep = planSweep(tickets, info, blocked, workModes, footprintPlan.waits, resolvedStatuses);
20107
20108
  const holdReleases = planHoldReleases(tickets, tracker.contract);
20108
20109
  const stalled = planStalled(tickets, comments, ships, tracker.contract, holds2, Date.now(), workModes, stalledEvents);
20109
20110
  const skipped = await skippedCounts(tracker, tickets, projectModes);
@@ -20126,7 +20127,7 @@ async function decideCycle(o) {
20126
20127
  reportTypeColumn: tracker.contract.columns.reportType,
20127
20128
  coordinatingValue: tracker.contract.coordinatingValue
20128
20129
  };
20129
- for (const r of rollUpParents(tickets, void 0, coordinating)) {
20130
+ for (const r of rollUpParents(tickets, resolvedStatuses, coordinating)) {
20130
20131
  if (r.complete) {
20131
20132
  emit.note(`every child is done \u2014 this coordinating ticket is too`, { ticket: r.parent.issue_id });
20132
20133
  }
@@ -23398,6 +23399,30 @@ Passed: ${passed}.${willClose ? " Closing this alert." : ""}`,
23398
23399
  return out;
23399
23400
  }
23400
23401
 
23402
+ // src/run-tags.ts
23403
+ var slot = (route2, key) => `${route2}\0${key}`;
23404
+ async function resolveRunTags(refs, sourceFor) {
23405
+ const byRoute2 = /* @__PURE__ */ new Map();
23406
+ for (const r of refs) {
23407
+ if (!r.route) continue;
23408
+ const want = byRoute2.get(r.route) ?? { ids: /* @__PURE__ */ new Set(), keys: /* @__PURE__ */ new Set() };
23409
+ if (r.ticketRecordId) want.ids.add(r.ticketRecordId);
23410
+ if (r.ticket) want.keys.add(r.ticket);
23411
+ byRoute2.set(r.route, want);
23412
+ }
23413
+ const tags = /* @__PURE__ */ new Map();
23414
+ await Promise.all([...byRoute2].map(async ([route2, want]) => {
23415
+ const source = sourceFor(route2);
23416
+ if (!source) return;
23417
+ const found = [
23418
+ ...want.ids.size ? await source.ticketsByIds([...want.ids]).catch(() => []) : [],
23419
+ ...want.keys.size ? await source.ticketsByKeys([...want.keys]).catch(() => []) : []
23420
+ ];
23421
+ for (const t of found) tags.set(slot(route2, t.issue_id), displayKey(t));
23422
+ }));
23423
+ return (route2, key) => key ? (route2 ? tags.get(slot(route2, key)) : void 0) ?? key : null;
23424
+ }
23425
+
23401
23426
  // src/comment-delivery.ts
23402
23427
  import { basename as basename11 } from "path";
23403
23428
  var MESSAGE_MAX_CHARS = 4e3;
@@ -29180,7 +29205,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29180
29205
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29181
29206
  import { join as join60 } from "path";
29182
29207
  function builtVersion() {
29183
- return true ? "0.164.0" : null;
29208
+ return true ? "0.164.1" : null;
29184
29209
  }
29185
29210
  var REBUILD_HINT = "rebuild with npm run build";
29186
29211
  function newestMtime(path) {
@@ -37207,13 +37232,24 @@ ${where.join("\n")}`);
37207
37232
  (await statusTracker.ticketsByIds([...new Set(runs.map((x) => x.ticketRecordId).filter((id) => !!id))]).catch(() => [])).map((t) => [t.id, t.title ?? null])
37208
37233
  );
37209
37234
  const lastRuns = lastRunsBySeat(cfg.ship.stateDir);
37210
- const wantedKeys = [...new Set([...runs.map((x) => x.ticket), ...[...lastRuns.values()].map((l) => l.ticket)].filter((k) => !!k))];
37211
- const tagByKey = /* @__PURE__ */ new Map();
37212
- for (const t of [
37213
- ...await statusTracker.ticketsByIds([...new Set(runs.map((x) => x.ticketRecordId).filter((id) => !!id))]).catch(() => []),
37214
- ...await statusTracker.ticketsByKeys(wantedKeys).catch(() => [])
37215
- ]) tagByKey.set(t.issue_id, displayKey(t));
37216
- const tagOf = (k) => k ? tagByKey.get(k) ?? k : null;
37235
+ const thisSlug = routeSlug(route2.route);
37236
+ const otherSources = /* @__PURE__ */ new Map();
37237
+ const sourceFor = (slug2) => {
37238
+ if (slug2 === thisSlug) return statusTracker;
37239
+ if (!otherSources.has(slug2)) {
37240
+ const rt = cfg.routes.find((x) => routeSlug(x.route) === slug2);
37241
+ let t;
37242
+ try {
37243
+ t = rt ? new Tracker(rt, cfg.ship) : void 0;
37244
+ } catch (e) {
37245
+ if (!(e instanceof ConfigError)) throw e;
37246
+ }
37247
+ otherSources.set(slug2, t);
37248
+ }
37249
+ return otherSources.get(slug2);
37250
+ };
37251
+ const resolvedTag = await resolveRunTags([...runs, ...lastRuns.values()], sourceFor);
37252
+ const tagOf = (route3, k) => resolvedTag(route3, k);
37217
37253
  const periscopes = await periscopesForStatus(cfg.ship.stateDir);
37218
37254
  const runPreviews = new Map(periscopes.filter((p) => p.serving).map((p) => [p.ticketRecordId, p.url]));
37219
37255
  if (flag("json")) {
@@ -37241,7 +37277,7 @@ ${where.join("\n")}`);
37241
37277
  // Additive (CREW-2822): how many runs this seat has live right now.
37242
37278
  running: runs.filter((x) => x.role === r && x.route === routeSlug(route2.route)).length,
37243
37279
  // Additive (CREW-3247): this seat's newest finished run on this ship, or null.
37244
- lastRun: ((l) => l ? { ticket: tagOf(l.ticket), startedAt: l.startedAt, finishedAt: l.finishedAt, outcome: l.outcome, exitCode: l.exitCode } : null)(lastRuns.get(`${routeSlug(route2.route)}/${r}`))
37280
+ lastRun: ((l) => l ? { ticket: tagOf(l.route, l.ticket), startedAt: l.startedAt, finishedAt: l.finishedAt, outcome: l.outcome, exitCode: l.exitCode } : null)(lastRuns.get(`${routeSlug(route2.route)}/${r}`))
37245
37281
  };
37246
37282
  });
37247
37283
  process.stdout.write(`${JSON.stringify({
@@ -37291,7 +37327,7 @@ ${where.join("\n")}`);
37291
37327
  seats: seats2
37292
37328
  },
37293
37329
  // Additive (CREW-2822): every live run on this ship. `version` stays 1.
37294
- runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles, previews: runPreviews, tags: tagByKey })),
37330
+ runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles, previews: runPreviews, tags: new Map(x.ticket ? [[x.ticket, tagOf(x.route, x.ticket) ?? x.ticket]] : []) })),
37295
37331
  // Additive (CREW-2857): every live periscope on this ship, from its local record. `version` stays 1.
37296
37332
  periscopes,
37297
37333
  watermark: state.watermark(routeSlug(route2.route)),
@@ -37388,7 +37424,7 @@ ${where.join("\n")}`);
37388
37424
  });
37389
37425
  }
37390
37426
  const reloadWaitingAt = readReloadRequestedAt(cfg.ship.stateDir);
37391
- const lastRunView = [...lastRuns.values()].filter((l) => l.route === routeSlug(route2.route)).map((l) => ({ role: l.role, ticket: tagOf(l.ticket), finishedAt: l.finishedAt, outcome: l.outcome }));
37427
+ const lastRunView = [...lastRuns.values()].filter((l) => l.route === routeSlug(route2.route)).map((l) => ({ role: l.role, ticket: tagOf(l.route, l.ticket), finishedAt: l.finishedAt, outcome: l.outcome }));
37392
37428
  for (const line of renderStatus({
37393
37429
  ship: { name: cfg.ship.name, platform: cfg.ship.platform },
37394
37430
  route: { name: route2.route, dir: route2.dir, enabled: route2.enabled },
@@ -37403,7 +37439,7 @@ ${where.join("\n")}`);
37403
37439
  watermark: String(state.watermark(routeSlug(route2.route))),
37404
37440
  projects: projects.map((p) => p.label),
37405
37441
  reloadRequestedSecondsAgo: reloadWaitingAt === null ? null : Math.max(0, Math.round((Date.now() - reloadWaitingAt) / 1e3)),
37406
- runs: runs.map((x) => ({ role: x.role, ticket: tagOf(x.ticket), repo: x.repo, pid: x.pid, spawnedAt: x.spawnedAt, deadline: x.deadline })),
37442
+ runs: runs.map((x) => ({ role: x.role, ticket: tagOf(x.route, x.ticket), repo: x.repo, pid: x.pid, spawnedAt: x.spawnedAt, deadline: x.deadline })),
37407
37443
  lastRuns: lastRunView,
37408
37444
  attention: shipAttention.map((i) => ({ kind: i.kind, message: i.message, since: i.since })),
37409
37445
  waiting: todo.map((i) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.164.0",
3
+ "version": "0.164.1",
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",