@taskless-app/swarm 0.6.94 → 0.6.96

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 CHANGED
@@ -4486,7 +4486,7 @@ var init_package = __esm({
4486
4486
  "package.json"() {
4487
4487
  package_default = {
4488
4488
  name: "@taskless-app/swarm",
4489
- version: "0.6.94",
4489
+ version: "0.6.96",
4490
4490
  type: "module",
4491
4491
  description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
4492
4492
  keywords: [
@@ -4538,7 +4538,7 @@ var init_package = __esm({
4538
4538
  undici: "^7.30.1",
4539
4539
  zod: "3.25.76"
4540
4540
  },
4541
- gitHead: "13b73c18b8d1cf42c57af487920be0bd0b919d86"
4541
+ gitHead: "cba7bb70bda3b613705151ec1734f048f72ad8d3"
4542
4542
  };
4543
4543
  }
4544
4544
  });
package/dist/overmind.js CHANGED
@@ -14826,7 +14826,7 @@ function parkReasonUnretriable(reason) {
14826
14826
  // package.json
14827
14827
  var package_default = {
14828
14828
  name: "@taskless-app/swarm",
14829
- version: "0.6.94",
14829
+ version: "0.6.96",
14830
14830
  type: "module",
14831
14831
  description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
14832
14832
  keywords: [
@@ -14878,7 +14878,7 @@ var package_default = {
14878
14878
  undici: "^7.30.1",
14879
14879
  zod: "3.25.76"
14880
14880
  },
14881
- gitHead: "13b73c18b8d1cf42c57af487920be0bd0b919d86"
14881
+ gitHead: "cba7bb70bda3b613705151ec1734f048f72ad8d3"
14882
14882
  };
14883
14883
 
14884
14884
  // src/version.ts
@@ -17444,6 +17444,8 @@ var AnomalyTracker = class {
17444
17444
  fires = /* @__PURE__ */ new Map();
17445
17445
  /** TAS-485: очередь «уже звонили, а условие ушло» — к гашению в инбоксе. */
17446
17446
  resolved = /* @__PURE__ */ new Set();
17447
+ /** TAS-1100: когда последний раз спрашивали gh по ключу. Только память, см. pollDue. */
17448
+ polledAt = /* @__PURE__ */ new Map();
17447
17449
  maxRepeats;
17448
17450
  io;
17449
17451
  /** Кандидаты, готовые к сигналу (отлежали minDurationMs, не в кулдауне) — НИЧЕГО не коммитит. */
@@ -17490,6 +17492,27 @@ var AnomalyTracker = class {
17490
17492
  pendingResolved() {
17491
17493
  return [...this.resolved];
17492
17494
  }
17495
+ /**
17496
+ * Новый эпизод ТОГО ЖЕ ключа (TAS-1100). Потолок `once` (и обычный счётчик повторов)
17497
+ * сбрасывается, кулдаун последнего сигнала остаётся — раньше renotifyCooldownMs
17498
+ * повтор не уйдёт. Ключ не меняем: на диске у прогонов, уже стоящих на лимите кругов,
17499
+ * лежит `needs_human:<id>`, и выкатка не открывает им свежий эпизод сама.
17500
+ */
17501
+ rearm(key) {
17502
+ if (!this.fires.has(key)) return;
17503
+ this.fires.delete(key);
17504
+ this.persist();
17505
+ }
17506
+ /**
17507
+ * Пора ли снова спросить внешний мир (gh) про ключ (TAS-1100): не чаще everyMs.
17508
+ * Только память: после рестарта первый вопрос уйдёт сразу — один вызов на прогон, не поток.
17509
+ */
17510
+ pollDue(key, now, everyMs) {
17511
+ const at = this.polledAt.get(key);
17512
+ if (at != null && now - at < everyMs) return false;
17513
+ this.polledAt.set(key, now);
17514
+ return true;
17515
+ }
17493
17516
  /** Гашение по этим ключам доставлено — забываем их. */
17494
17517
  forgetResolved(keys) {
17495
17518
  let changed = false;
@@ -17765,7 +17788,7 @@ function buildAnomalyCandidates(db, now, thresholds, opts) {
17765
17788
  ...hrefOf(run2.task_url)
17766
17789
  })
17767
17790
  });
17768
- } else if (autoReviewOnFor(opts.autoReviewEnabled, run2.repo) && run2.review_verdict == null && db.reviewerCountFor(run2.id) === 0) {
17791
+ } else if (autoReviewOnFor(opts.autoReviewEnabled, run2.repo) && run2.review_verdict == null && db.reviewerCountFor(run2.id) === 0 && !reviewCyclesExhausted(run2)) {
17769
17792
  candidates.push({
17770
17793
  key: `pr_no_reviewer:${run2.id}`,
17771
17794
  minDurationMs: thresholds.prNoReviewerMs,
@@ -17783,7 +17806,7 @@ function buildAnomalyCandidates(db, now, thresholds, opts) {
17783
17806
  };
17784
17807
  }
17785
17808
  });
17786
- } else if (run2.review_verdict === "changes" && db.activeReviewersFor(run2.id).length === 0) {
17809
+ } else if (run2.review_verdict === "changes" && db.activeReviewersFor(run2.id).length === 0 && !reviewCyclesExhausted(run2)) {
17787
17810
  candidates.push({
17788
17811
  key: `pr_stuck_changes:${run2.id}`,
17789
17812
  minDurationMs: thresholds.prNoReviewerMs,
@@ -25119,25 +25142,55 @@ async function answerFixBudget(deps, run2, q, answer, verdict) {
25119
25142
  backToReview();
25120
25143
  narrate(deps, `${droneLabel(run2)}: \u043D\u0430 \u043F\u0440\u0430\u0432\u043A\u0438 \u0434\u0430\u043B\u0438 \u0431\u044E\u0434\u0436\u0435\u0442 \u2014 \u0432\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u044E \u043D\u0430 \u0440\u0435\u0432\u044C\u044E, \u043F\u0440\u0430\u0432\u043A\u0430 \u043F\u043E\u0434\u043D\u0438\u043C\u0435\u0442\u0441\u044F \u0441\u0432\u043E\u0438\u043C \u0445\u043E\u0434\u043E\u043C.`);
25121
25144
  }
25122
- function buildEscalationCandidates(db) {
25145
+ async function buildEscalationCandidates(deps, now, episodes) {
25123
25146
  const candidates = [];
25124
- for (const run2 of db.listRuns("review")) {
25125
- const hit = db.events(run2.id).findLast((e) => isEscalationText(e.text ?? "", run2, "supervision"));
25147
+ for (const run2 of deps.db.listRuns("review")) {
25148
+ const hit = deps.db.events(run2.id).findLast(
25149
+ (e) => e.kind !== "anomaly" && isEscalationText(e.text ?? "", run2, "supervision")
25150
+ );
25126
25151
  if (!hit) continue;
25152
+ const cycleStop = (hit.text ?? "").includes(REVIEW_CYCLE_ESCALATION_MARK);
25153
+ if (cycleStop && !reviewCyclesExhausted(run2)) continue;
25154
+ const key = `needs_human:${run2.id}`;
25155
+ if (cycleStop) {
25156
+ try {
25157
+ await maybeRearmCycleStop(deps, run2, now, key, episodes);
25158
+ } catch (e) {
25159
+ console.error(`[overmind] \u043D\u0430\u0434\u0437\u043E\u0440: \u044D\u043F\u0438\u0437\u043E\u0434 \u043B\u0438\u043C\u0438\u0442\u0430 \u043A\u0440\u0443\u0433\u043E\u0432 \u043F\u0440\u043E\u0433\u043E\u043D\u0430 #${run2.id} \u043D\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D:`, e);
25160
+ }
25161
+ }
25162
+ const raw = hit.text ?? "\u044D\u0441\u043A\u0430\u043B\u0430\u0446\u0438\u044F \u0431\u0435\u0437 \u0442\u0435\u043A\u0441\u0442\u0430";
25127
25163
  candidates.push({
25128
- key: `needs_human:${run2.id}`,
25164
+ key,
25129
25165
  minDurationMs: 0,
25130
25166
  // маркер сам по себе УЖЕ прошёл свой RESOLVE_LIMIT/REVIEW_SPAWN_LIMIT/…
25167
+ ...cycleStop ? { once: true } : {},
25131
25168
  build: () => ({
25132
25169
  runId: run2.id,
25133
25170
  title: signalTitle(run2, "\u043D\u0443\u0436\u0435\u043D \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440"),
25134
- body: `${run2.task_slug}: ${hit.text ?? "\u044D\u0441\u043A\u0430\u043B\u0430\u0446\u0438\u044F \u0431\u0435\u0437 \u0442\u0435\u043A\u0441\u0442\u0430"} \u2014 ${run2.pr_url ?? "?"}.`,
25171
+ body: `${run2.task_slug}: ${raw} \u2014 ${run2.pr_url ?? "?"}.`,
25135
25172
  ...hrefOf(run2.task_url)
25136
25173
  })
25137
25174
  });
25138
25175
  }
25139
25176
  return candidates;
25140
25177
  }
25178
+ async function maybeRearmCycleStop(deps, run2, now, key, episodes) {
25179
+ if (!deps.commitsSince || !run2.pr_url) return;
25180
+ const last = deps.db.events(run2.id).findLast(
25181
+ (e) => e.kind === "anomaly" && (e.text ?? "").includes(REVIEW_CYCLE_ESCALATION_MARK)
25182
+ );
25183
+ if (!last) return;
25184
+ if (now - sqliteMs(last.at) < SWARM_ANOMALY_RENOTIFY_MS) return;
25185
+ if (!episodes.pollDue(key, now, SWARM_ANOMALY_RENOTIFY_MS)) return;
25186
+ let moved = false;
25187
+ try {
25188
+ moved = await deps.commitsSince(run2.pr_url, last.at);
25189
+ } catch {
25190
+ moved = false;
25191
+ }
25192
+ if (moved) episodes.rearm(key);
25193
+ }
25141
25194
  async function tickOnce(deps) {
25142
25195
  const now = deps.now ? deps.now() : Date.now();
25143
25196
  beginGhMergePass(deps.ghMerges);
@@ -25951,7 +26004,7 @@ async function tickOnce(deps) {
25951
26004
  // Рестарт не переигрывает падения (TAS-485) — см. closedBeforeStart в anomalies.ts.
25952
26005
  ...az.startedAt != null ? { daemonStartedAt: az.startedAt } : {}
25953
26006
  }),
25954
- ...buildEscalationCandidates(deps.db),
26007
+ ...await buildEscalationCandidates(deps, now, az.tracker),
25955
26008
  ...stormAnomalyCandidates(deps, now),
25956
26009
  // ЦЕНА РАЗГРУЗКИ (TASWM-316): «машина не тянет» с числами и рекомендацией — та же
25957
26010
  // труба, тот же дедуп «один раз на эпизод». Пустой список при нормальной работе.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taskless-app/swarm",
3
- "version": "0.6.94",
3
+ "version": "0.6.96",
4
4
  "type": "module",
5
5
  "description": "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
6
6
  "keywords": [
@@ -40,7 +40,7 @@
40
40
  "undici": "^7.30.1",
41
41
  "zod": "3.25.76"
42
42
  },
43
- "gitHead": "13b73c18b8d1cf42c57af487920be0bd0b919d86",
43
+ "gitHead": "cba7bb70bda3b613705151ec1734f048f72ad8d3",
44
44
  "scripts": {
45
45
  "overmind": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --conditions=development\" tsx src/overmind.ts",
46
46
  "swarm": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --conditions=development\" tsx src/cli.ts",