neurastream 0.2.60 → 0.2.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neurastream",
3
- "version": "0.2.60",
3
+ "version": "0.2.61",
4
4
  "description": "Guardrails for running many AI coding agents at once: plan queue, blockers, call budgets, provider caps, scoring, merge-verified close.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -1967,18 +1967,28 @@ export function checkStop(e: StopEvent, cfg: Config): Decision {
1967
1967
  }
1968
1968
  // P5 (plan 20261031_0911): a landed open plan whose auto-close failed holds the stop until a
1969
1969
  // running subagent's brief names it (staffing ∩ live ledger); unrelated live subagents release
1970
- // nothing, and there is no idle-stop valve — the lock lifts when the plan closes or is staffed.
1970
+ // nothing. Valve (20261031_2320): like the incident block above, empty stops count toward
1971
+ // cfg.guards.idle_stops; a stop with calls in between resets the count and re-locks.
1971
1972
  const locked = q.activePlans().filter(p => p.status === "open" && q.autoCloseCandidate(p) && q.lastCloseFailed(p.file));
1972
1973
  if (locked.length) {
1973
1974
  const staffed = staffedPlans(readStaffing(), liveSubagents(e.ledgerText));
1974
1975
  const unworked = locked.filter(s => !staffed.includes(s.file));
1975
1976
  if (unworked.length) {
1977
+ if (state.callsSinceStop === 0) state.idleStops++;
1978
+ else state.idleStops = 0;
1979
+ state.callsSinceStop = 0;
1980
+ if (state.idleStops >= cfg.guards.idle_stops) {
1981
+ log(cfg.paths.guard_log, `ALLOW stop after ${state.idleStops} idle stop attempts; locked: ${unworked.map(s => s.file).join(", ")}`);
1982
+ return { allow: true, reason: "", state: { callsSinceStop: 0, idleStops: 0 } };
1983
+ }
1984
+ const left = cfg.guards.idle_stops - state.idleStops;
1976
1985
  log(cfg.paths.guard_log, `BLOCK stop: landed but not closed: ${unworked.map(s => s.file).join(", ")}`);
1977
1986
  return {
1978
1987
  allow: false,
1979
1988
  reason:
1980
1989
  `main-guard: ${unworked.map(s => `${s.file} landed but its auto-close failed (${(q.lastCloseResult(s.file) ?? "").replace(/^queue-close: /, "")})`).join("; ")}. ` +
1981
- "The stop stays locked: spawn an agent whose brief names the plan, or fix the close.",
1990
+ "The stop stays locked: spawn an agent whose brief names the plan, or fix the close. " +
1991
+ `${left} idle stop ${left === 1 ? "attempt" : "attempts"} left before the stop is allowed.`,
1982
1992
  state,
1983
1993
  };
1984
1994
  }
@@ -65,10 +65,11 @@ function originBase(repo: string): string {
65
65
  return head.ok && head.out ? `refs/remotes/${head.out}` : "refs/remotes/origin/main";
66
66
  }
67
67
 
68
- /** P4: an open plan auto-close starts for — its branch exists and has landed, or it names no branch (a Main-only plan) and every phase is ticked. Shared by the adapter's autoClose filter and queueProblems' landed lock (P5); queue-close --auto re-checks authoritatively. */
68
+ /** P4 (plan 20261031_0911), tightened by 20261031_2320: an open plan auto-close starts for only when every phase is ticked AND (its branch exists and has landed, or it names no branch — a Main-only plan). An empty landed branch is not done: 0.2.60 held the queue on 0/N plans. Shared by the adapter's autoClose filter and queueProblems' landed lock (P5); queue-close --auto re-checks authoritatively. */
69
69
  export function autoCloseCandidate(p: Plan): boolean {
70
70
  if (p.status !== "open" || p.errors.length) return false;
71
- if (!p.branch) return p.phases.total > 0 && p.phases.done === p.phases.total;
71
+ if (!(p.phases.total > 0 && p.phases.done === p.phases.total)) return false;
72
+ if (!p.branch) return true;
72
73
  if (!gitOut(p.repo, "rev-parse", "--verify", "-q", `refs/heads/${p.branch}`).ok) return false;
73
74
  return landed(p.repo, p.branch, originBase(p.repo), p.text);
74
75
  }