@christang/keel 5.149.0 → 5.150.0

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.149.0",
3
+ "version": "5.150.0",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
package/README.md CHANGED
@@ -842,15 +842,16 @@ keel patrol --issues /tmp/issues.json # as the coordinator's role
842
842
  as met and sends the waiting role one direct message, which wakes it. It lists every role's
843
843
  presence, last activity, and open todos, marking those idle beyond `--idle` (default `30m`). It
844
844
  fetches nothing, schedules nothing, calls no model, and writes nothing when nothing is new; it exits
845
- 0 then, 2 when it sent something, and 1 on an error, so a cheap scheduler — cron, `/loop`, CI — can
846
- wake the model only on 2. `keel chat waits` lists what is still awaited.
845
+ 0 then, 2 when the coordinator has something to act on — a risk, or its own wait met — 3 when it only
846
+ recorded something or told other roles, and 1 on an error, so a cheap scheduler — cron, `/loop`, CI —
847
+ can wake the model only on 2 (#350). `keel chat waits` lists what is still awaited.
847
848
 
848
849
  A patrol on an hourly schedule should report change, not state, or it wakes the coordinator every
849
850
  hour for a note deliberately left parked (#295). `keel patrol --since-last` keeps a snapshot per role
850
851
  — shift status, the remote default branch tip, the main checkout's uncommitted paths, each role's
851
852
  idleness and open todos, and the coordinator's addressed records unread beyond `--idle` — and prints
852
853
  only `changed:` lines for what differs from the previous run; the first run records a baseline. It
853
- writes that snapshot on every run, and exits 2 only when something changed. Add `--notify` and the
854
+ writes that snapshot on every run, and exits 3 when something changed and 2 only when a risk did. Add `--notify` and the
854
855
  coordinator gets one direct message from `keel-patrol`, which wakes its session, carrying only risks
855
856
  (#307): the shared checkout gaining uncommitted paths after a clean run, free disk the host reports with
856
857
  `--disk-free-gb` dropping below `--disk-min-gb` (default 20), and a role that left two nudges in a row
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.149.0 -->
1
+ <!-- keel:start version=5.150.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the only durable authority — never native memory, goals, or transcripts.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.149.0",
3
+ "version": "5.150.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.149.0",
9
+ "version": "5.150.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "^1.4.1"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.149.0",
5
+ "version": "5.150.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.149.0",
3
+ "version": "5.150.0",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.149.0",
3
+ "version": "5.150.0",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -49,8 +49,8 @@ REQUIRED_SCRIPTS = [
49
49
  "scripts/validate_plugin.py",
50
50
  ]
51
51
 
52
- PACKAGE_VERSION = "5.149.0"
53
- PROTOCOL_VERSION = "5.149.0"
52
+ PACKAGE_VERSION = "5.150.0"
53
+ PROTOCOL_VERSION = "5.150.0"
54
54
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
55
55
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
56
56
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -2858,7 +2858,7 @@ def validate_patrol_since_last_scenario() -> int:
2858
2858
  for args in (["commit", "-q", "--allow-empty", "-m", "landed"], ["push", "-q", "origin", "HEAD"]):
2859
2859
  subprocess.run(["git", *args], cwd=rtl, check=True, capture_output=True)
2860
2860
  second = patrol("--since-last", "--notify")
2861
- if second.returncode != 2:
2861
+ if second.returncode != 3:
2862
2862
  report(f"{label} the run after a change exited {second.returncode}: {second.stdout!r} {second.stderr!r}")
2863
2863
  return 1
2864
2864
  changed = [line for line in second.stdout.splitlines() if line.startswith("changed:")]
@@ -2886,6 +2886,65 @@ def validate_patrol_since_last_scenario() -> int:
2886
2886
  return 0
2887
2887
 
2888
2888
 
2889
+ def validate_patrol_exit_says_who_acts_scenario() -> int:
2890
+ """Issue #350: `keel patrol` exited 2 on pure state changes too.
2891
+
2892
+ A coordinator's schedule wakes its model on exit 2, so a run that only
2893
+ moved state or told other roles cost a model turn for nothing. Exit 2 now
2894
+ means the coordinator has something to act on — a risk, or its own wait
2895
+ met — and exit 3 means patrol recorded or delivered something for others.
2896
+ """
2897
+ label = "patrol-exit-says-who-acts:"
2898
+ with tempfile.TemporaryDirectory(prefix="keel-patrol-350-") as raw:
2899
+ base = Path(raw)
2900
+ rtl, verify, env, _ = shift_scratch(base)
2901
+
2902
+ def patrol(*args: str) -> subprocess.CompletedProcess[str]:
2903
+ return run_keel(rtl, "patrol", *args, env=env)
2904
+
2905
+ def push() -> str:
2906
+ for args in (["commit", "-q", "--allow-empty", "-m", "landed"], ["push", "-q", "origin", "HEAD"]):
2907
+ subprocess.run(["git", *args], cwd=rtl, check=True, capture_output=True)
2908
+ return subprocess.run(["git", "rev-parse", "HEAD"], cwd=rtl, text=True, capture_output=True, check=True).stdout.strip()
2909
+
2910
+ if patrol("--since-last", "--notify").returncode != 0:
2911
+ report(f"{label} the baseline run did not exit 0.")
2912
+ return 1
2913
+ push()
2914
+ moved = patrol("--since-last", "--notify")
2915
+ if moved.returncode != 3:
2916
+ report(f"{label} a run whose only news is the remote tip exited {moved.returncode}, not 3: {moved.stdout!r}")
2917
+ return 1
2918
+ (rtl / "stray.txt").write_text("x\n")
2919
+ risky = patrol("--since-last", "--notify")
2920
+ if risky.returncode != 2:
2921
+ report(f"{label} a run that found a risk exited {risky.returncode}, not 2: {risky.stdout!r}")
2922
+ return 1
2923
+ (rtl / "stray.txt").unlink()
2924
+
2925
+ sha = push()
2926
+ run_keel(verify, "chat", "wait", "soc", "--commit", sha, "rerun when it lands", env=env)
2927
+ theirs = patrol()
2928
+ if theirs.returncode != 3:
2929
+ report(f"{label} a run that met another role's wait exited {theirs.returncode}, not 3: {theirs.stdout!r}")
2930
+ return 1
2931
+ sha = push()
2932
+ run_keel(rtl, "chat", "wait", "soc", "--commit", sha, "merge the next slice", env=env)
2933
+ mine = patrol()
2934
+ if mine.returncode != 2:
2935
+ report(f"{label} a run that met the coordinator's own wait exited {mine.returncode}, not 2: {mine.stdout!r}")
2936
+ return 1
2937
+ helped = run_keel(rtl, "patrol", "--help", env=env)
2938
+ if "3:" not in helped.stdout:
2939
+ report(f"{label} --help does not document exit 3: {helped.stdout!r}")
2940
+ return 1
2941
+ if "patrol-exit-says-who-acts" not in {name for name, _ in SCENARIOS}:
2942
+ report(f"{label} scenario is not registered.")
2943
+ return 1
2944
+ report("patrol-exit-says-who-acts scenario passed.")
2945
+ return 0
2946
+
2947
+
2889
2948
  def validate_patrol_nudge_scenario() -> int:
2890
2949
  """Issues #307 part 1 and #313: the patrol nudges idle roles directly.
2891
2950
 
@@ -2929,8 +2988,8 @@ def validate_patrol_nudge_scenario() -> int:
2929
2988
  if any(line.startswith("nudged lint") for line in nudged(first)):
2930
2989
  report(f"{label} lint was nudged before any task closed: {nudged(first)!r}")
2931
2990
  return 1
2932
- if first.returncode != 2:
2933
- report(f"{label} a run that nudged exited {first.returncode}.")
2991
+ if first.returncode != 3:
2992
+ report(f"{label} a run that nudged exited {first.returncode}, not 3.")
2934
2993
  return 1
2935
2994
  if run_keel(verify, "chat", "notice", "--check", env=env).returncode != 0:
2936
2995
  report(f"{label} the nudge does not wake verify.")
@@ -3168,8 +3227,8 @@ def validate_coordinator_patrol_scenario() -> int:
3168
3227
 
3169
3228
  subprocess.run(["git", "push", "-q", "origin", "feature"], cwd=rtl, check=True, capture_output=True)
3170
3229
  landed = patrol()
3171
- if landed.returncode != 2:
3172
- report(f"{label} patrol after the push exited {landed.returncode}, not 2: {landed.stdout} {landed.stderr}")
3230
+ if landed.returncode != 3:
3231
+ report(f"{label} patrol after the push exited {landed.returncode}, not 3: {landed.stdout} {landed.stderr}")
3173
3232
  return 1
3174
3233
  if chat_json(chat(rtl, "waits", "--json")).get("waits"):
3175
3234
  report(f"{label} the met wait is still listed.")
@@ -3198,8 +3257,8 @@ def validate_coordinator_patrol_scenario() -> int:
3198
3257
  issues = base / "issues.json"
3199
3258
  issues.write_text(json.dumps([{"number": 42, "title": "clock fix", "state": "CLOSED", "labels": [], "updatedAt": "2026-10-11T00:00:00Z"}]), encoding="utf-8")
3200
3259
  closed = patrol("--issues", str(issues))
3201
- if closed.returncode != 2:
3202
- report(f"{label} patrol with issue 42 closed exited {closed.returncode}, not 2: {closed.stdout} {closed.stderr}")
3260
+ if closed.returncode != 3:
3261
+ report(f"{label} patrol with issue 42 closed exited {closed.returncode}, not 3: {closed.stdout} {closed.stderr}")
3203
3262
  return 1
3204
3263
  report("coordinator-patrol scenario passed.")
3205
3264
  return 0
@@ -3229,8 +3288,8 @@ def validate_patrol_issue_routing_scenario() -> int:
3229
3288
  return [r.get("text", "") for r in chat_json(run_keel(verify, "chat", "unread", "--json", env=env)).get("unread", []) if "#157" in r.get("text", "")]
3230
3289
 
3231
3290
  first = patrol("2026-10-11T01:00:00Z")
3232
- if first.returncode != 2:
3233
- report(f"{label} the first patrol exited {first.returncode}, not 2: {first.stdout} {first.stderr}")
3291
+ if first.returncode != 3:
3292
+ report(f"{label} the first patrol exited {first.returncode}, not 3: {first.stdout} {first.stderr}")
3234
3293
  return 1
3235
3294
  if len(notices()) != 1:
3236
3295
  report(f"{label} verify has {len(notices())} notices about #157, not 1.")
@@ -3247,8 +3306,8 @@ def validate_patrol_issue_routing_scenario() -> int:
3247
3306
  report(f"{label} the same update was sent again.")
3248
3307
  return 1
3249
3308
  later = patrol("2026-10-11T02:00:00Z")
3250
- if later.returncode != 2:
3251
- report(f"{label} a later update exited {later.returncode}, not 2.")
3309
+ if later.returncode != 3:
3310
+ report(f"{label} a later update exited {later.returncode}, not 3.")
3252
3311
  return 1
3253
3312
  if len(notices()) != 2:
3254
3313
  report(f"{label} a later update left {len(notices())} notices, not 2.")
@@ -41845,6 +41904,7 @@ SCENARIOS: tuple = (
41845
41904
  ("chat-ack", validate_chat_ack_scenario),
41846
41905
  ("coordinator-patrol", validate_coordinator_patrol_scenario),
41847
41906
  ("patrol-since-last", validate_patrol_since_last_scenario),
41907
+ ("patrol-exit-says-who-acts", validate_patrol_exit_says_who_acts_scenario),
41848
41908
  ("patrol-nudge", validate_patrol_nudge_scenario),
41849
41909
  ("patrol-escalate", validate_patrol_escalate_scenario),
41850
41910
  ("patrol-quota", validate_patrol_quota_scenario),
@@ -14,9 +14,14 @@ const { parseSince } = require("./chat/view");
14
14
 
15
15
  const USAGE = "keel patrol [--issues <file>] [--idle <90s|15m|2h|3d>] [--since-last [--notify]] [--nudge] [--json] [--repo <path>]\n keel patrol task [--json] [--repo <path>] print the host scheduled task for `patrol:`";
16
16
  const NOTIFY_SENDER = "keel-patrol";
17
+ // 2 asks the coordinator to act — a risk, or a wait of its own now met — and
18
+ // 3 says patrol recorded or delivered something only other roles need: a
19
+ // coordinator's schedule wakes its model on 2, so a run that merely moved
20
+ // state no longer costs a turn (#350).
17
21
  const EXIT_QUIET = 0;
18
22
  const EXIT_ERROR = 1;
19
- const EXIT_WROTE = 2;
23
+ const EXIT_ACT = 2;
24
+ const EXIT_RECORDED = 3;
20
25
 
21
26
  class PatrolError extends Error {}
22
27
 
@@ -402,7 +407,7 @@ function hostTask(where) {
402
407
  "",
403
408
  `1. Run \`git -C ${at} fetch -q origin\`. If it fails, keep its error and continue.`,
404
409
  `2. Run \`keel patrol --repo ${at} --since-last --notify\`.`,
405
- `3. Exit 0: nothing changed. Exit 2: keel has already told ${role}. In both cases end without output. `
410
+ `3. Exit 0: nothing changed. Exit 2: keel has already told ${role} what to act on. Exit 3: keel recorded or told other roles only. In these cases end without output. `
406
411
  + "Exit 1: end with one line, `keel patrol failed: <its error output>`, adding the fetch error from step 1 if there was one.",
407
412
  ].join("\n");
408
413
  return {
@@ -465,7 +470,7 @@ function runPatrol(argv) {
465
470
  else if (arg === "--quota-alerts") options.quotaAlerts = String(argv[++index] || "").split(",").map(Number);
466
471
  else if (arg === "--quota-quiet-at") options.quotaQuietAt = Number(argv[++index]);
467
472
  else if (arg === "--help" || arg === "-h") {
468
- process.stdout.write(`${USAGE}\nExit 0: wrote nothing. 2: sent a notice or marked a wait met. 1: error.\n`);
473
+ process.stdout.write(`${USAGE}\nExit 0: wrote nothing. 2: something for you to act on (a risk, or your own wait met). 3: recorded or told other roles only. 1: error.\n`);
469
474
  return EXIT_QUIET;
470
475
  } else if (["--repo", "--issues", "--idle"].includes(arg)) {
471
476
  const value = argv[++index];
@@ -504,7 +509,9 @@ function runPatrol(argv) {
504
509
  }
505
510
  process.stdout.write(`${options.json ? JSON.stringify(result, null, 2) : render(result)}\n`);
506
511
  const changed = result.sinceLast && result.sinceLast.changes.length;
507
- const code = result.notices.length || result.held.length || changed || (result.nudges || []).length || result.risks.length ? EXIT_WROTE : EXIT_QUIET;
512
+ const own = result.held.some((held) => held.from === role);
513
+ const recorded = result.notices.length || result.held.length || changed || (result.nudges || []).length;
514
+ const code = result.risks.length || own ? EXIT_ACT : recorded ? EXIT_RECORDED : EXIT_QUIET;
508
515
  appendRunLog(where, role, code, result);
509
516
  return code;
510
517
  } catch (error) {