@christang/keel 5.136.1 → 5.138.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,4 +1,4 @@
1
- <!-- keel:start version=5.136.1 -->
1
+ <!-- keel:start version=5.138.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.136.1",
3
+ "version": "5.138.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.136.1",
9
+ "version": "5.138.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.136.1",
5
+ "version": "5.138.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.136.1",
3
+ "version": "5.138.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.136.1",
3
+ "version": "5.138.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",
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
47
47
  "scripts/validate_plugin.py",
48
48
  ]
49
49
 
50
- PACKAGE_VERSION = "5.136.1"
51
- PROTOCOL_VERSION = "5.136.1"
50
+ PACKAGE_VERSION = "5.138.0"
51
+ PROTOCOL_VERSION = "5.138.0"
52
52
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
53
53
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
54
54
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -6965,6 +6965,168 @@ def validate_shift_await_clear_scenario() -> int:
6965
6965
  return 0
6966
6966
 
6967
6967
 
6968
+ def validate_chat_park_role_scenario() -> int:
6969
+ """A role parked on purpose is left alone, and posters are told (#316).
6970
+
6971
+ `keel chat role --park` records the park; posts naming the role say it is
6972
+ parked; the patrol neither nudges it nor reports it; `--unpark` summarizes
6973
+ what waited; a session running as the role ends the park (chat-park-role
6974
+ D1-D5).
6975
+ """
6976
+ label = "chat-park-role:"
6977
+ with tempfile.TemporaryDirectory(prefix="keel-chat-park-role-") as raw:
6978
+ base = Path(raw)
6979
+ rtl, verify, env, _ = shift_scratch(base)
6980
+ run_keel(rtl, "chat", "group", "create", "soc", "verify", env=env)
6981
+ ghost = run_keel(rtl, "chat", "role", "--park", "ghost", env=env)
6982
+ if ghost.returncode == 0:
6983
+ report(f"{label} parking an unbound role was accepted: {ghost.stdout.strip()}")
6984
+ return 1
6985
+ run_keel(rtl, "chat", "post", "soc", "@verify please rerun R007", env=env)
6986
+ time.sleep(1.2)
6987
+ parked = run_keel(rtl, "chat", "role", "--park", "verify", "--reason", "until R040", env=env)
6988
+ made = run_keel(rtl, "chat", "todo", "soc", "--assignee", "verify", "R041 rerun", env=env)
6989
+ if made.returncode != 0:
6990
+ report(f"{label} a todo for a parked role failed: {made.stderr.strip()}")
6991
+ return 1
6992
+ if "verify is parked" not in made.stdout:
6993
+ report(f"{label} a todo for a parked role does not say verify is parked: {made.stdout.strip()} (--park: {parked.stderr.strip() or parked.stdout.strip()})")
6994
+ return 1
6995
+ if "until R040" not in made.stdout:
6996
+ report(f"{label} a todo for a parked role does not give the reason: {made.stdout.strip()}")
6997
+ return 1
6998
+ as_json = run_keel(rtl, "chat", "todo", "soc", "--assignee", "verify", "R042 rerun", "--json", env=env)
6999
+ entries = json.loads(as_json.stdout).get("parked") if as_json.returncode == 0 else None
7000
+ if not entries or entries[0].get("role") != "verify" or entries[0].get("reason") != "until R040":
7001
+ report(f"{label} --json does not carry parked: {as_json.stdout.strip()}")
7002
+ return 1
7003
+
7004
+ def patrol() -> subprocess.CompletedProcess[str]:
7005
+ return run_keel(rtl, "patrol", "--nudge", "--idle", "1s", env=env)
7006
+
7007
+ for attempt in (1, 2):
7008
+ time.sleep(1.2)
7009
+ run = patrol()
7010
+ lines = run.stdout.splitlines()
7011
+ if any(line.startswith("nudged verify") for line in lines):
7012
+ report(f"{label} patrol run {attempt} nudged the parked role: {run.stdout.strip()}")
7013
+ return 1
7014
+ if any(line.startswith(("risk:", "drift:")) and "verify" in line for line in lines):
7015
+ report(f"{label} patrol run {attempt} reported the parked role: {run.stdout.strip()}")
7016
+ return 1
7017
+ if not any(line.startswith("role verify:") and "parked" in line for line in lines):
7018
+ report(f"{label} patrol run {attempt} does not show verify as parked: {run.stdout.strip()}")
7019
+ return 1
7020
+ unparked = run_keel(rtl, "chat", "role", "--unpark", "verify", env=env)
7021
+ if unparked.returncode != 0:
7022
+ report(f"{label} --unpark failed: {unparked.stderr.strip()}")
7023
+ return 1
7024
+ if "waited" not in unparked.stdout:
7025
+ report(f"{label} --unpark does not report what waited: {unparked.stdout.strip()}")
7026
+ return 1
7027
+ time.sleep(1.2)
7028
+ after = patrol()
7029
+ if "nudged verify: unread" not in after.stdout:
7030
+ report(f"{label} after --unpark the patrol did not nudge verify: {after.stdout.strip()}")
7031
+ return 1
7032
+ plain = run_keel(rtl, "chat", "todo", "soc", "--assignee", "verify", "R043 rerun", env=env)
7033
+ if "parked" in plain.stdout:
7034
+ report(f"{label} a todo after --unpark still says parked: {plain.stdout.strip()}")
7035
+ return 1
7036
+ run_keel(rtl, "chat", "role", "--park", "verify", env=env)
7037
+ time.sleep(1.2)
7038
+ subprocess.run(
7039
+ ["node", str(ROOT / "bin" / "keel.js"), "chat", "hook", "session-start"],
7040
+ cwd=verify, env=env, text=True, capture_output=True, check=False,
7041
+ input=json.dumps({"cwd": str(verify), "hook_event_name": "SessionStart", "source": "startup"}),
7042
+ )
7043
+ resumed = run_keel(rtl, "chat", "todo", "soc", "--assignee", "verify", "R044 rerun", env=env)
7044
+ if "parked" in resumed.stdout:
7045
+ report(f"{label} a session running as verify did not end the park: {resumed.stdout.strip()}")
7046
+ return 1
7047
+ for relative in ("docs/chat-slack-setup.md", "docs/chat-slack-setup.zh-CN.md"):
7048
+ if "--park" not in (ROOT / relative).read_text(encoding="utf-8"):
7049
+ report(f"{label} {relative} does not mention --park.")
7050
+ return 1
7051
+ if "chat-park-role" not in {name for name, _ in SCENARIOS}:
7052
+ report(f"{label} scenario is not registered.")
7053
+ return 1
7054
+ report("chat-park-role scenario passed.")
7055
+ return 0
7056
+
7057
+
7058
+ def validate_chat_wake_idle_desktop_scenario() -> int:
7059
+ """A record for an idle desktop session names the step that wakes it (#331).
7060
+
7061
+ On the Claude desktop app a session with no running Claude process reads
7062
+ no chat record, so a todo or a patrol nudge alone wakes nothing there
7063
+ (chat-wake-idle-desktop D1-D4). Outside the desktop app nothing changes.
7064
+ """
7065
+ label = "chat-wake-idle-desktop:"
7066
+ with tempfile.TemporaryDirectory(prefix="keel-chat-wake-idle-desktop-") as raw:
7067
+ base = Path(raw)
7068
+ rtl, verify, env, _ = shift_scratch(base)
7069
+ gone = subprocess.Popen(["node", "-e", ""])
7070
+ gone.wait()
7071
+ desktop = {**env, "CLAUDE_CODE_ENTRYPOINT": "claude-desktop", "CLAUDE_CODE_HOST_SESSION_ID": "local_test-331", "KEEL_SHIFT_DESKTOP_PID": str(gone.pid)}
7072
+
7073
+ def hook(environment: dict) -> subprocess.CompletedProcess[str]:
7074
+ return subprocess.run(
7075
+ ["node", str(ROOT / "bin" / "keel.js"), "chat", "hook", "session-start"],
7076
+ cwd=verify, env=environment, text=True, capture_output=True, check=False,
7077
+ input=json.dumps({"cwd": str(verify), "hook_event_name": "SessionStart", "source": "startup"}),
7078
+ )
7079
+
7080
+ steps = ("send_message", "get_session", "unarchive_session", "local_test-331")
7081
+ started = hook(desktop)
7082
+ if started.returncode != 0:
7083
+ report(f"{label} the desktop session-start hook failed: {started.stderr.strip()}")
7084
+ return 1
7085
+ run_keel(rtl, "chat", "group", "create", "soc", "verify", env=env)
7086
+ made = run_keel(rtl, "chat", "todo", "soc", "--assignee", "verify", "R031 rerun", env=env)
7087
+ if made.returncode != 0:
7088
+ report(f"{label} todo failed: {made.stderr.strip()}")
7089
+ return 1
7090
+ for needle in steps:
7091
+ if needle not in made.stdout:
7092
+ report(f"{label} a todo for an idle desktop session does not name {needle}: {made.stdout.strip()}")
7093
+ return 1
7094
+ as_json = run_keel(rtl, "chat", "todo", "soc", "--assignee", "verify", "R032 rerun", "--json", env=env)
7095
+ asleep = json.loads(as_json.stdout).get("asleep") if as_json.returncode == 0 else None
7096
+ if asleep != [{"role": "verify", "session": "local_test-331"}]:
7097
+ report(f"{label} --json does not carry asleep: {as_json.stdout.strip()} {as_json.stderr.strip()}")
7098
+ return 1
7099
+ stored = run_keel(verify, "chat", "todos", "--mine", env=desktop)
7100
+ if "R031 rerun" not in stored.stdout:
7101
+ report(f"{label} the todo was not stored: {stored.stdout.strip()}")
7102
+ return 1
7103
+ time.sleep(1.2)
7104
+ patrol = run_keel(rtl, "patrol", "--nudge", "--idle", "1s", env=env)
7105
+ if "nudged verify" not in patrol.stdout:
7106
+ report(f"{label} the patrol did not nudge verify: {patrol.stdout.strip()} {patrol.stderr.strip()}")
7107
+ return 1
7108
+ risks = [line for line in patrol.stdout.splitlines() if line.startswith("risk:")]
7109
+ if not any("local_test-331" in line and "send_message" in line for line in risks):
7110
+ report(f"{label} the first nudge to an idle desktop session reports no risk naming its wake step: {patrol.stdout.strip()}")
7111
+ return 1
7112
+ if hook(env).returncode != 0:
7113
+ report(f"{label} the plain session-start hook failed.")
7114
+ return 1
7115
+ plain = run_keel(rtl, "chat", "todo", "soc", "--assignee", "verify", "R033 rerun", env=env)
7116
+ if any(needle in plain.stdout for needle in steps):
7117
+ report(f"{label} a todo for a session outside the desktop app still names a wake step: {plain.stdout.strip()}")
7118
+ return 1
7119
+ for relative in ("docs/chat-slack-setup.md", "docs/chat-slack-setup.zh-CN.md"):
7120
+ if "#331" not in (ROOT / relative).read_text(encoding="utf-8"):
7121
+ report(f"{label} {relative} does not mention #331.")
7122
+ return 1
7123
+ if "chat-wake-idle-desktop" not in {name for name, _ in SCENARIOS}:
7124
+ report(f"{label} scenario is not registered.")
7125
+ return 1
7126
+ report("chat-wake-idle-desktop scenario passed.")
7127
+ return 0
7128
+
7129
+
6968
7130
  def validate_shift_start_desktop_scenario() -> int:
6969
7131
  """`keel shift start` names the wake step for a note written on the desktop app.
6970
7132
 
@@ -40749,6 +40911,8 @@ SCENARIOS: tuple = (
40749
40911
  ("shift-desktop-wake", validate_shift_desktop_wake_scenario),
40750
40912
  ("shift-desktop-wake-overdue", validate_shift_desktop_wake_overdue_scenario),
40751
40913
  ("shift-start-desktop", validate_shift_start_desktop_scenario),
40914
+ ("chat-wake-idle-desktop", validate_chat_wake_idle_desktop_scenario),
40915
+ ("chat-park-role", validate_chat_park_role_scenario),
40752
40916
  ("shift-await-clear", validate_shift_await_clear_scenario),
40753
40917
  ("shift-restore-authorization", validate_shift_restore_authorization_scenario),
40754
40918
  ("self-shift-authorization", validate_self_shift_authorization_scenario),
@@ -16,6 +16,7 @@ const { ChatError } = store;
16
16
 
17
17
  const USAGE = [
18
18
  "keel chat role [--set <name>] [--alias <alias>] [--prune] [--json] (--prune: drop bindings to removed worktrees)",
19
+ "keel chat role --park <role> [--reason <text>] | --unpark <role> (a role parked on purpose is not nudged or reported by the patrol)",
19
20
  "keel chat group create <group> [--member <role>]...",
20
21
  "keel chat group add|remove <group> <role> [--listen] (--listen: receives the group, may ack and close its todos, does not post)",
21
22
  "keel chat group archive <group>",
@@ -57,6 +58,9 @@ const USAGE = [
57
58
  const VALUED = {
58
59
  "--set": "set",
59
60
  "--alias": "alias",
61
+ "--park": "park",
62
+ "--unpark": "unpark",
63
+ "--reason": "reason",
60
64
  "--reply-to": "replyTo",
61
65
  "--supersedes": "supersedes",
62
66
  "--not-a-loop": "notALoop",
@@ -177,14 +181,68 @@ function offlineMentions(where, record) {
177
181
  .filter((role) => notice.presenceOf(where, role).state === "offline");
178
182
  }
179
183
 
184
+ // A woken role whose desktop session has no running process reads nothing
185
+ // until something resumes it (#331 D3), so the poster is given the step.
186
+ function asleepTargets(where, record) {
187
+ return wokenRoles(where, record).map((role) => notice.asleep(where, role)).filter(Boolean);
188
+ }
189
+
190
+ function wokenRoles(where, record) {
191
+ const bound = Object.values(store.readJsonFile(path.join(where.root, "roles.json"))).filter(Boolean);
192
+ const candidates = [...new Set([...bound, ...(record.mentions || []), ...(record.assignee ? [record.assignee] : [])])];
193
+ return candidates.filter((role) => store.wakes(record, role)).sort();
194
+ }
195
+
196
+ function boundRoles(where) {
197
+ return new Set(Object.values(store.readJsonFile(path.join(where.root, "roles.json"))).filter(Boolean));
198
+ }
199
+
200
+ // `keel chat role --park/--unpark` (#316 D1, D3).
201
+ function runPark(where, options) {
202
+ if (options.park !== null && options.unpark !== null) throw new ChatError("Give --park or --unpark, not both.");
203
+ const role = options.park !== null ? options.park : options.unpark;
204
+ if (options.park !== null) {
205
+ if (!boundRoles(where).has(role)) {
206
+ throw new ChatError(`No worktree is bound to ${role}, so there is nothing to park; \`keel chat role\` in its worktree shows its name.`);
207
+ }
208
+ const record = notice.park(where, role, store.currentRole(where), options.reason);
209
+ if (options.json) out(JSON.stringify(record));
210
+ else out(`Parked ${role}${options.reason ? `: ${options.reason}` : ""}. The patrol leaves it alone and posters are told, until \`keel chat role --unpark ${role}\` or its session runs again.`);
211
+ return 0;
212
+ }
213
+ const removed = notice.unpark(where, role);
214
+ const waiting = store.unread(where, role).filter((record) => store.wakes(record, role)).sort((a, b) => (a.id < b.id ? -1 : 1));
215
+ if (options.json) {
216
+ out(JSON.stringify({ role, unparked: removed, waiting: waiting.length, since: waiting.length ? waiting[0].created : null }));
217
+ return 0;
218
+ }
219
+ const head = removed ? `Unparked ${role}.` : `${role} was not parked.`;
220
+ out(waiting.length
221
+ ? `${head} ${waiting.length} addressed record(s) waited since ${waiting[0].created}; ${role} reads them with \`keel chat unread\`.`
222
+ : `${head} Nothing addressed to it waited.`);
223
+ return 0;
224
+ }
225
+
180
226
  function postResult(where, record, json) {
181
- const offline = offlineMentions(where, record);
227
+ const parked = wokenRoles(where, record).map((role) => notice.parkOf(where, role)).filter(Boolean);
228
+ const isParked = (role) => parked.some((entry) => entry.role === role);
229
+ const asleep = asleepTargets(where, record).filter((entry) => !isParked(entry.role));
230
+ const offline = offlineMentions(where, record).filter((role) => !isParked(role) && !asleep.some((entry) => entry.role === role));
182
231
  if (json) {
183
- out(JSON.stringify({ id: record.id, group: record.group, from: record.from, mentions: record.mentions, offline }));
232
+ out(JSON.stringify({ id: record.id, group: record.group, from: record.from, mentions: record.mentions, offline, asleep, parked }));
184
233
  return;
185
234
  }
186
235
  const lines = [`Posted ${record.id} to ${record.group}.`];
236
+ // A parked role is told nothing new by the post; the poster is (#316 D5).
237
+ for (const entry of parked) {
238
+ lines.push(`${entry.role} is parked since ${entry.at}${entry.by ? ` by ${entry.by}` : ""}${entry.reason ? `: ${entry.reason}` : ""}; `
239
+ + "this waits until it is unparked or its session runs again — route anything urgent through the coordinator.");
240
+ }
187
241
  for (const role of offline) lines.push(`Queued for ${role}: offline; it will see this when its session next starts.`);
242
+ for (const entry of asleep) {
243
+ lines.push(`${entry.role}'s desktop session ${entry.session} has no running process, so this record alone wakes nothing (#331). `
244
+ + notice.wakeStep(entry.session, "You have unread keel chat records; run `keel chat unread`."));
245
+ }
188
246
  out(lines.join("\n"));
189
247
  }
190
248
 
@@ -286,6 +344,7 @@ function dispatch(where, options) {
286
344
  const [command, ...rest] = options.positionals;
287
345
  switch (command) {
288
346
  case "role": {
347
+ if (options.park !== null || options.unpark !== null) return runPark(where, options);
289
348
  if (options.prune) {
290
349
  // Bindings to removed worktrees (#301 D4).
291
350
  const pruned = require("./drift").pruneBindings(where);
@@ -37,10 +37,12 @@ function removedBindings(where) {
37
37
  }
38
38
 
39
39
  function roleDrift(where, now = Date.now()) {
40
- const { presenceFile } = require("./notice");
40
+ const { presenceFile, parkOf } = require("./notice");
41
41
  const roles = [...new Set(Object.values(store.readJsonFile(path.join(where.root, "roles.json"))).filter(Boolean))].sort();
42
42
  const unattended = [];
43
43
  for (const role of roles) {
44
+ // A role parked on purpose is not unattended (#316 D4).
45
+ if (parkOf(where, role)) continue;
44
46
  const waiting = [];
45
47
  let unread = [];
46
48
  try {
@@ -91,6 +91,11 @@ function touchPresence(where, role, state = "online", host = null, started = nul
91
91
  // start in the same second as the `ready` still orders after it.
92
92
  session_started: started ? new Date().toISOString() : previous.session_started || null,
93
93
  session_source: started ? started.source : previous.session_source || null,
94
+ // The desktop app's session and its Claude process (#331 D1): an ended
95
+ // session keeps them, since it is the one that needs waking.
96
+ ...(state === "offline"
97
+ ? { desktop_session: previous.desktop_session || null, desktop_pid: previous.desktop_pid || null }
98
+ : desktopFields()),
94
99
  };
95
100
  try {
96
101
  store.writeJsonAtomic(where, presenceFile(where, role), record);
@@ -99,6 +104,66 @@ function touchPresence(where, role, state = "online", host = null, started = nul
99
104
  }
100
105
  }
101
106
 
107
+ function desktopFields() {
108
+ const id = process.env.CLAUDE_CODE_HOST_SESSION_ID;
109
+ if (process.env.CLAUDE_CODE_ENTRYPOINT !== "claude-desktop" || !id) return { desktop_session: null, desktop_pid: null };
110
+ return { desktop_session: id, desktop_pid: require("../shift").desktopProcess() };
111
+ }
112
+
113
+ function running(pid) {
114
+ try {
115
+ process.kill(pid, 0);
116
+ return true;
117
+ } catch (error) {
118
+ return error.code === "EPERM";
119
+ }
120
+ }
121
+
122
+ // A role whose desktop session has no running Claude process reads no chat
123
+ // record until something resumes it (#331 D2, measured in #320).
124
+ function asleep(where, role) {
125
+ const record = store.readJsonFile(presenceFile(where, role));
126
+ if (!record.desktop_session) return null;
127
+ // With no process found when it was recorded, Keel cannot tell, and says nothing.
128
+ const pid = Number(record.desktop_pid);
129
+ return Number.isInteger(pid) && pid > 1 && !running(pid) ? { role, session: record.desktop_session } : null;
130
+ }
131
+
132
+ // The step that wakes it (#331 D3), as the shift start names it (#320).
133
+ function wakeStep(session, text) {
134
+ return `Wake it: call \`get_session\` on \`${session}\`; when it reports the session archived, call \`unarchive_session\` on it; `
135
+ + `then call \`send_message\` to \`${session}\` with ${JSON.stringify(text)}.`;
136
+ }
137
+
138
+ // --- parked roles (#316) ------------------------------------------------------------
139
+
140
+ function parkFile(where, role) {
141
+ return path.join(where.root, "parked", `${role}.json`);
142
+ }
143
+
144
+ function park(where, role, by, reason) {
145
+ const record = { role, reason: reason || null, by: by || null, at: new Date().toISOString() };
146
+ store.writeJsonAtomic(where, parkFile(where, role), record);
147
+ return record;
148
+ }
149
+
150
+ function unpark(where, role) {
151
+ const file = parkFile(where, role);
152
+ const existed = fs.existsSync(file);
153
+ fs.rmSync(file, { force: true });
154
+ return existed;
155
+ }
156
+
157
+ // A park is in effect until a session runs as the role after it (D2).
158
+ function parkOf(where, role) {
159
+ const record = store.readJsonFile(parkFile(where, role));
160
+ const at = Date.parse(record.at || "");
161
+ if (Number.isNaN(at)) return null;
162
+ const last = Date.parse(store.readJsonFile(presenceFile(where, role)).last_active || "");
163
+ if (!Number.isNaN(last) && last > at) return null;
164
+ return { role, at: store.isoLocal(new Date(at)), by: record.by || null, reason: record.reason || null };
165
+ }
166
+
102
167
  const ONLINE_WINDOW_MS = 24 * 60 * 60 * 1000;
103
168
 
104
169
  // `online`, `idle`, or `offline`, with the time of last activity (D10).
@@ -381,6 +446,11 @@ function check(cwd) {
381
446
 
382
447
  module.exports = {
383
448
  NOTICE_LIMIT,
449
+ asleep,
450
+ park,
451
+ parkOf,
452
+ unpark,
453
+ wakeStep,
384
454
  check,
385
455
  bridgeLine,
386
456
  hook,
@@ -91,6 +91,7 @@ function patrol(where, role, options) {
91
91
  presence: presence.state,
92
92
  lastActive: presence.last_active,
93
93
  idle: Number.isNaN(last) || last < threshold,
94
+ parked: Boolean(notice.parkOf(where, name)),
94
95
  openTodos: store.openTodos(where, { assignee: name }).length,
95
96
  });
96
97
  }
@@ -155,7 +156,7 @@ function currentSnapshot(where, role, result, options) {
155
156
  // Free disk as the host measured it (#307 part 3 D1).
156
157
  if (options.diskFreeGb !== null) entries.disk = options.diskFreeGb < options.diskMinGb ? "low" : "ok";
157
158
  for (const row of result.roles) {
158
- entries[`role ${row.role}`] = `${row.idle ? "idle" : "active"}, ${row.openTodos} open todo${row.openTodos === 1 ? "" : "s"}`;
159
+ entries[`role ${row.role}`] = `${row.parked ? "parked" : row.idle ? "idle" : "active"}, ${row.openTodos} open todo${row.openTodos === 1 ? "" : "s"}`;
159
160
  }
160
161
  const threshold = parseSince(options.idle);
161
162
  const unread = store.unread(where, role)
@@ -244,6 +245,8 @@ function nudgeRoles(where, patroller, options) {
244
245
  .filter((role) => role !== patroller).sort();
245
246
  const closures = closedTodos(where);
246
247
  for (const role of roles) {
248
+ // A role parked on purpose is left alone, its state kept (#316 D4).
249
+ if (notice.parkOf(where, role)) continue;
247
250
  // The first look only records the tasks already closed (#313 D1).
248
251
  if (!state[role] || !Array.isArray(state[role].closedSeen)) {
249
252
  state[role] = { ...(state[role] || {}), closedSeen: (closures.get(role) || []).map((entry) => entry.done) };
@@ -297,6 +300,13 @@ function nudgeRoles(where, patroller, options) {
297
300
  mine.resume = stamp;
298
301
  }
299
302
  }
303
+ // A nudge to a desktop session with no running process wakes nothing,
304
+ // so the coordinator hears it on the first one (#331 D4).
305
+ const sleeping = sent.some((entry) => entry.role === role) ? notice.asleep(where, role) : null;
306
+ if (sleeping) {
307
+ escalations.push(`${role}'s desktop session ${sleeping.session} has no running process, so the nudge wakes nothing: `
308
+ + notice.wakeStep(sleeping.session, "You have unread keel chat records; run `keel chat unread`."));
309
+ }
300
310
  state[role] = mine;
301
311
  }
302
312
  store.writeJsonAtomic(where, stateFile, state);
@@ -344,7 +354,7 @@ function render(result) {
344
354
  for (const line of result.sinceLast ? [] : result.drift) lines.push(`drift: ${line.text}`);
345
355
  // A scheduled run reports roles only through what changed (D1).
346
356
  for (const row of result.sinceLast ? [] : result.roles) {
347
- lines.push(`role ${row.role}: ${row.presence}${row.idle ? " (idle)" : ""}, last active ${row.lastActive || "unknown"}, ${row.openTodos} open todo${row.openTodos === 1 ? "" : "s"}`);
357
+ lines.push(`role ${row.role}: ${row.presence}${row.idle ? " (idle)" : ""}${row.parked ? ", parked" : ""}, last active ${row.lastActive || "unknown"}, ${row.openTodos} open todo${row.openTodos === 1 ? "" : "s"}`);
348
358
  }
349
359
  return lines.join("\n");
350
360
  }