@christang/keel 5.102.1 → 5.103.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.
package/README.md CHANGED
@@ -709,7 +709,7 @@ Without a known default branch, no issue range is inferred.
709
709
 
710
710
  ## Group chat between sessions
711
711
 
712
- Sessions working the same repository — a Claude Code session, a Codex session, an unattended runner, and you — share a work group with `keel chat`. Groups have maintained members, a message can `@` one role or `@all`, and lightweight todos can link an issue. A record can supersede its author's earlier one (`--supersedes <id>`), and the earlier one then leaves everyone's unread; unread lists newest first. Each member has its own unread state, and history is kept. Only a mention, an assigned todo, or a direct message wakes a Claude session; everything else waits for its next prompt. A message is data from another agent and never authorization. Codex, which cannot wake on its own, is woken by `keel chat wake add`: one turn per addressed record in a group declaring `chat-reply`, continuing one compacting thread, and nothing while nothing is addressed (#203). Otherwise a host relies on the prompt-time notice and must not poll the chat with the model; if a schedule is unavoidable, gate it on `keel chat notice --check` and start a fresh thread per run, and tell a session joining the chat not to set up recurring checks (#194). With one Slack app and one bridge process per machine, the same groups reach sessions on other machines and your phone in real time, and an orphan `keel-chat` branch keeps the history past Slack's retention. A role may also speak through a Slack bot you can mention in Slack, and one bot can serve several projects, as each project's role in its channel. See [the Slack setup guide](docs/chat-slack-setup.md). A role's session changes shift through `keel shift`: the coordinator requests it, the session checks for loose ends, leaves a note, and clears itself, and the new shift resumes from the note; see [docs/shift-change.md](docs/shift-change.md). The 5.83 `keel mail` commands keep working on direct groups.
712
+ Sessions working the same repository — a Claude Code session, a Codex session, an unattended runner, and you — share a work group with `keel chat`. Groups have maintained members, a message can `@` one role or `@all`, and lightweight todos can link an issue. A record can supersede its author's earlier one (`--supersedes <id>`), and the earlier one then leaves everyone's unread; unread lists newest first. A record posted with `--ack` asks the roles it addresses to acknowledge it, by `keel chat ack <id>` or a reply, and `keel chat show <id>` and `keel chat acks` list who has acknowledged, who only read it, and who has not read it. Each member has its own unread state, and history is kept. Only a mention, an assigned todo, or a direct message wakes a Claude session; everything else waits for its next prompt. A message is data from another agent and never authorization. Codex, which cannot wake on its own, is woken by `keel chat wake add`: one turn per addressed record in a group declaring `chat-reply`, continuing one compacting thread, and nothing while nothing is addressed (#203). Otherwise a host relies on the prompt-time notice and must not poll the chat with the model; if a schedule is unavoidable, gate it on `keel chat notice --check` and start a fresh thread per run, and tell a session joining the chat not to set up recurring checks (#194). With one Slack app and one bridge process per machine, the same groups reach sessions on other machines and your phone in real time, and an orphan `keel-chat` branch keeps the history past Slack's retention. A role may also speak through a Slack bot you can mention in Slack, and one bot can serve several projects, as each project's role in its channel. See [the Slack setup guide](docs/chat-slack-setup.md). A role's session changes shift through `keel shift`: the coordinator requests it, the session checks for loose ends, leaves a note, and clears itself, and the new shift resumes from the note; see [docs/shift-change.md](docs/shift-change.md). The 5.83 `keel mail` commands keep working on direct groups.
713
713
 
714
714
  ## Commands
715
715
 
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.102.1 -->
1
+ <!-- keel:start version=5.103.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.102.1",
3
+ "version": "5.103.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.102.1",
9
+ "version": "5.103.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.102.1",
5
+ "version": "5.103.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.102.1",
3
+ "version": "5.103.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.102.1",
3
+ "version": "5.103.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.102.1"
51
- PROTOCOL_VERSION = "5.102.1"
50
+ PACKAGE_VERSION = "5.103.0"
51
+ PROTOCOL_VERSION = "5.103.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
@@ -2521,6 +2521,88 @@ def validate_chat_supersedes_scenario() -> int:
2521
2521
  return 0
2522
2522
 
2523
2523
 
2524
+ def validate_chat_ack_scenario() -> int:
2525
+ """Issue #253: a record asks for an acknowledgement and the sender sees who gave it.
2526
+
2527
+ An acknowledgement is `keel chat ack <id>` or a reply from an addressed
2528
+ role; it marks the record read, wakes nobody, and is refused where it means
2529
+ nothing; `show` and `acks` split the addressed roles three ways.
2530
+ """
2531
+ label = "chat-ack:"
2532
+ with tempfile.TemporaryDirectory(prefix="keel-chat-ack-") as raw:
2533
+ base = Path(raw)
2534
+ rtl, verify, env = chat_scratch_group(base)
2535
+ spec = chat_worktree(rtl, base / "spec")
2536
+ run_keel(spec, "chat", "role", "--set", "spec", env=env)
2537
+ run_keel(rtl, "chat", "group", "add", "soc", "spec", env=env)
2538
+
2539
+ def chat(cwd: Path, *args: str) -> subprocess.CompletedProcess[str]:
2540
+ return run_keel(cwd, "chat", *args, env=env)
2541
+
2542
+ asked = chat_json(chat(rtl, "post", "soc", "@verify @spec rerun R007 on 1b64e8c", "--ack", "--json")).get("id", "")
2543
+ if not asked:
2544
+ report(f"{label} a post with --ack returned no id.")
2545
+ return 1
2546
+ acked = chat(verify, "ack", asked)
2547
+ if acked.returncode != 0:
2548
+ report(f"{label} verify could not acknowledge: {acked.stderr}")
2549
+ return 1
2550
+ view = chat(spec, "soc").stdout
2551
+ if "(ack requested)" not in view:
2552
+ report(f"{label} spec's group view does not mark the record (ack requested): {view!r}")
2553
+ return 1
2554
+ acks = chat_json(chat(rtl, "show", asked, "--json")).get("acks", {})
2555
+ if acks.get("acknowledged") != ["verify"]:
2556
+ report(f"{label} show lists acknowledged {acks.get('acknowledged')!r}, not ['verify'].")
2557
+ return 1
2558
+ if acks.get("readNotAcknowledged") != ["spec"]:
2559
+ report(f"{label} show lists read-not-acknowledged {acks.get('readNotAcknowledged')!r}, not ['spec'].")
2560
+ return 1
2561
+ if acks.get("unread") != []:
2562
+ report(f"{label} show lists unread {acks.get('unread')!r}, not [].")
2563
+ return 1
2564
+ waiting = chat_json(chat(rtl, "acks", "--mine", "--json")).get("records", [])
2565
+ if [r.get("id") for r in waiting] != [asked]:
2566
+ report(f"{label} acks --mine lists {[r.get('id') for r in waiting]!r}, not [{asked}].")
2567
+ return 1
2568
+ rtl_unread = chat_json(chat(rtl, "unread", "--json")).get("unread", [])
2569
+ if rtl_unread:
2570
+ report(f"{label} the acknowledgement left rtl something unread: {rtl_unread!r}")
2571
+ return 1
2572
+
2573
+ chat(spec, "post", "soc", "on it", "--reply-to", asked)
2574
+ acks = chat_json(chat(rtl, "show", asked, "--json")).get("acks", {})
2575
+ if acks.get("acknowledged") != ["spec", "verify"]:
2576
+ report(f"{label} a reply did not acknowledge: acknowledged {acks.get('acknowledged')!r}.")
2577
+ return 1
2578
+ if chat_json(chat(rtl, "acks", "--json")).get("records", []):
2579
+ report(f"{label} a fully acknowledged record is still listed by acks.")
2580
+ return 1
2581
+
2582
+ later = chat_json(chat(rtl, "post", "soc", "@spec check the clock", "--ack", "--json")).get("id", "")
2583
+ notice = chat_json(chat(spec, "notice", "--json")).get("notice", "")
2584
+ if "(ack requested)" not in notice:
2585
+ report(f"{label} spec's wake notice does not mark {later} (ack requested): {notice!r}")
2586
+ return 1
2587
+ plain = chat_json(chat(rtl, "post", "soc", "@spec fyi", "--json")).get("id", "")
2588
+ refusals = [
2589
+ ("a record that does not ask", chat(spec, "ack", plain), "does not ask"),
2590
+ ("a record that does not address the role", chat(verify, "ack", later), "does not address"),
2591
+ ("a record already acknowledged", chat(verify, "ack", asked), "already acknowledged"),
2592
+ ("--ack on a record addressing nobody", chat(rtl, "post", "soc", "note to self", "--ack"), "addresses no one"),
2593
+ ]
2594
+ for what, result, needle in refusals:
2595
+ if result.returncode == 0:
2596
+ report(f"{label} {what} was accepted: {result.stdout}")
2597
+ return 1
2598
+ if needle not in result.stderr:
2599
+ report(f"{label} {what} was refused without saying {needle!r}: {result.stderr}")
2600
+ return 1
2601
+
2602
+ report("chat-ack scenario passed.")
2603
+ return 0
2604
+
2605
+
2524
2606
  def validate_chat_records_scenario() -> int:
2525
2607
  """Issue #187: todos, edits, retractions, search, and local-time display.
2526
2608
 
@@ -3191,6 +3273,8 @@ def validate_chat_bridge_outbound_scenario() -> int:
3191
3273
  chat(rtl, "edit", root_id, "Clock fix is in (v2)")
3192
3274
  gone_id = chat_json(chat(rtl, "post", "soc", "wrong group", "--json")).get("id", "")
3193
3275
  chat(rtl, "retract", gone_id)
3276
+ asked_id = chat_json(chat(rtl, "post", "soc", "@verify confirm the clock", "--ack", "--json")).get("id", "")
3277
+ ack_id = chat_json(chat(verify, "ack", asked_id, "--json")).get("id", "")
3194
3278
  old_rule_id = chat_json(chat(rtl, "post", "soc", "verify owns integration", "--json")).get("id", "")
3195
3279
  new_rule_id = chat_json(chat(rtl, "post", "soc", "design owns integration", "--supersedes", old_rule_id, "--json")).get("id", "")
3196
3280
  slack.rate_limit("chat.postMessage", 1)
@@ -3276,6 +3360,14 @@ def validate_chat_bridge_outbound_scenario() -> int:
3276
3360
  if not any(c["params"].get("ts") == gone_ts for c in slack.calls_to("chat.delete")):
3277
3361
  report(f"{label} the retraction did not call chat.delete.")
3278
3362
  return 1
3363
+ # Issue #253: an acknowledgement stays local.
3364
+ if not ack_id:
3365
+ report(f"{label} the acknowledgement returned no id.")
3366
+ return 1
3367
+ carried = [c for c in slack.calls if ack_id in json.dumps(c.get("params", {}))]
3368
+ if carried:
3369
+ report(f"{label} the acknowledgement {ack_id} reached Slack: {carried!r}")
3370
+ return 1
3279
3371
  # Issue #252: a superseded record's Slack copy says so.
3280
3372
  if not new_rule_id:
3281
3373
  report(f"{label} the superseding post returned no id.")
@@ -37991,6 +38083,7 @@ SCENARIOS: tuple = (
37991
38083
  ("shift-without-role", validate_shift_without_role_scenario),
37992
38084
  ("resource-lock", validate_resource_lock_scenario),
37993
38085
  ("chat-supersedes", validate_chat_supersedes_scenario),
38086
+ ("chat-ack", validate_chat_ack_scenario),
37994
38087
  ("worktree-overview", validate_worktree_overview_scenario),
37995
38088
  ("init-never-downgrades-openspec", validate_init_never_downgrades_openspec_scenario),
37996
38089
  ("native-plugin-marketplaces", validate_native_plugin_marketplaces_scenario),
@@ -311,6 +311,8 @@ function pendingOutbound(project) {
311
311
  for (const [group, channel] of Object.entries(settings.channels)) {
312
312
  for (const record of store.readLog(where, group)) {
313
313
  if (!OUTBOUND_ORIGINS.has(record.origin || "local")) continue;
314
+ // An acknowledgement stays local (#253 D3): Slack shows the reply, if any.
315
+ if (record.kind === "ack") continue;
314
316
  if (readPosted(where, record.id)) continue;
315
317
  pending.push({ record, channel });
316
318
  }
@@ -20,7 +20,9 @@ const USAGE = [
20
20
  "keel chat group add|remove <group> <role>",
21
21
  "keel chat group archive <group>",
22
22
  "keel chat group list [--all] [--json] (also: keel chat list)",
23
- "keel chat post <group> <text...> [--reply-to <id>] [--supersedes <id>] [--json] (also: keel chat <group> <text...>)",
23
+ "keel chat post <group> <text...> [--reply-to <id>] [--supersedes <id>] [--ack] [--json] (also: keel chat <group> <text...>)",
24
+ "keel chat ack <id> acknowledge a record that asks (a reply also counts)",
25
+ "keel chat acks [--mine] [--json] records still waiting on an acknowledgement",
24
26
  "keel chat dm <role> <text...> [--json]",
25
27
  "keel chat <group> [--since <90s|15m|2h|3d|date>] [--follow] [--peek] [--json] (view; advances your read position unless --peek)",
26
28
  "keel chat unread [--json]",
@@ -66,10 +68,10 @@ const VALUED = {
66
68
  "--compact-at": "compactAt",
67
69
  };
68
70
  const REPEATED = { "--member": "members" };
69
- const SWITCHES = { "--json": "json", "--peek": "peek", "--all": "all", "--mine": "mine", "--follow": "follow", "--once": "once", "--mail": "mail", "--check": "check" };
71
+ const SWITCHES = { "--json": "json", "--peek": "peek", "--all": "all", "--mine": "mine", "--follow": "follow", "--once": "once", "--mail": "mail", "--check": "check", "--ack": "ack" };
70
72
 
71
73
  function parseChatArgs(argv) {
72
- const options = { positionals: [], members: [], json: false, peek: false, all: false, mine: false, follow: false, once: false, mail: false, check: false };
74
+ const options = { positionals: [], members: [], json: false, peek: false, all: false, mine: false, follow: false, once: false, mail: false, check: false, ack: false };
73
75
  for (const key of Object.values(VALUED)) options[key] = null;
74
76
  for (let index = 0; index < argv.length; index += 1) {
75
77
  const arg = argv[index];
@@ -120,6 +122,15 @@ function readStdin() {
120
122
  }
121
123
  }
122
124
 
125
+ function ackLines(acks) {
126
+ const list = (roles) => roles.join(", ") || "none";
127
+ return [
128
+ `acknowledged: ${list(acks.acknowledged)}`,
129
+ `read, not acknowledged: ${list(acks.readNotAcknowledged)}`,
130
+ `not read: ${list(acks.unread)}`,
131
+ ];
132
+ }
133
+
123
134
  function publicRecord(record) {
124
135
  const { refs, ...rest } = record;
125
136
  return refs && refs.length ? record : rest;
@@ -260,7 +271,22 @@ function dispatch(where, options) {
260
271
  case "post": {
261
272
  const [group, ...words] = rest;
262
273
  if (!group) throw new ChatError("keel chat post needs a group.");
263
- postResult(where, store.post(where, { group, text: textFrom(words), replyTo: options.replyTo, supersedes: options.supersedes }), options.json);
274
+ postResult(where, store.post(where, { group, text: textFrom(words), replyTo: options.replyTo, supersedes: options.supersedes, ack: options.ack }), options.json);
275
+ return 0;
276
+ }
277
+ case "ack": {
278
+ const id = rest[0];
279
+ if (!id) throw new ChatError("keel chat ack needs a record id.");
280
+ const record = store.ack(where, id);
281
+ out(options.json ? JSON.stringify({ id: record.id, target: id }) : `Acknowledged ${id}.`);
282
+ return 0;
283
+ }
284
+ case "acks": {
285
+ const from = options.mine ? store.requireRole(where) : null;
286
+ const rows = store.openAcks(where, { from });
287
+ if (options.json) out(JSON.stringify({ records: rows.map(({ record, acks }) => ({ ...publicRecord(record), acks })) }));
288
+ else if (!rows.length) out("keel chat: no record is waiting on an acknowledgement.");
289
+ else out(rows.map(({ record, acks }) => [`${record.group} ${formatLine(record)}`, ...ackLines(acks).map((line) => ` ${line}`)].join("\n")).join("\n"));
264
290
  return 0;
265
291
  }
266
292
  case "dm": {
@@ -291,15 +317,16 @@ function dispatch(where, options) {
291
317
  const record = store.findRecord(where, id);
292
318
  if (!record) throw new ChatError(`No record ${id}.`);
293
319
  const readers = store.readersOf(where, record);
294
- if (options.json) out(JSON.stringify({ record: publicRecord(record), readers }));
295
- else out([`${record.group} ${formatLine(record)}`, `read by: ${readers.join(", ") || "nobody yet"}`].join("\n"));
320
+ const acks = record.ack === "requested" ? store.ackStatus(where, record) : null;
321
+ if (options.json) out(JSON.stringify({ record: publicRecord(record), readers, ...(acks ? { acks } : {}) }));
322
+ else out([`${record.group} ${formatLine(record)}`, `read by: ${readers.join(", ") || "nobody yet"}`, ...(acks ? ackLines(acks) : [])].join("\n"));
296
323
  return 0;
297
324
  }
298
325
  case "todo": {
299
326
  const [group, ...words] = rest;
300
327
  if (!group) throw new ChatError("keel chat todo needs a group.");
301
328
  if (options.assignee === null) throw new ChatError("keel chat todo needs --assignee <role>.");
302
- postResult(where, store.todo(where, { group, assignee: options.assignee, issue: options.issue, text: textFrom(words), replyTo: options.replyTo }), options.json);
329
+ postResult(where, store.todo(where, { group, assignee: options.assignee, issue: options.issue, text: textFrom(words), replyTo: options.replyTo, ack: options.ack }), options.json);
303
330
  return 0;
304
331
  }
305
332
  case "todos": {
@@ -365,7 +392,7 @@ function dispatch(where, options) {
365
392
  default: {
366
393
  // `keel chat <group>` views; `keel chat <group> <text...>` posts.
367
394
  if (rest.length) {
368
- postResult(where, store.post(where, { group: command, text: rest.join(" "), replyTo: options.replyTo, supersedes: options.supersedes }), options.json);
395
+ postResult(where, store.post(where, { group: command, text: rest.join(" "), replyTo: options.replyTo, supersedes: options.supersedes, ack: options.ack }), options.json);
369
396
  return 0;
370
397
  }
371
398
  return runView(where, command, options);
@@ -39,7 +39,8 @@ function noticeText(where, role, now = Date.now()) {
39
39
  `keel chat: ${records.length} unread for role \`${role}\`, ${waking.length} addressed to you.`,
40
40
  ];
41
41
  for (const record of waking.slice(0, NOTICE_LIMIT)) {
42
- lines.push(`- ${record.id} in ${record.group} from \`${record.from}\`, ${relativeAge(record.created, now)}: ${firstLine(record.text)}`);
42
+ const asks = record.ack === "requested" ? " (ack requested)" : "";
43
+ lines.push(`- ${record.id} in ${record.group} from \`${record.from}\`${asks}, ${relativeAge(record.created, now)}: ${firstLine(record.text)}`);
43
44
  }
44
45
  if (waking.length > NOTICE_LIMIT) lines.push(`- and ${waking.length - NOTICE_LIMIT} more addressed to you.`);
45
46
  if (others.size) {
@@ -40,7 +40,7 @@ const DATA_NOTICE =
40
40
  const READABLE_KINDS = new Set(["message", "todo", "system"]);
41
41
  const LIST_FIELDS = new Set(["mentions", "refs"]);
42
42
  const FIELD_ORDER = [
43
- "id", "group", "kind", "from", "created", "mentions", "reply_to", "supersedes",
43
+ "id", "group", "kind", "from", "created", "mentions", "reply_to", "supersedes", "ack",
44
44
  "assignee", "issue", "target", "refs", "origin", "slack_channel", "slack_ts",
45
45
  ];
46
46
 
@@ -560,6 +560,12 @@ function post(where, options) {
560
560
  parent = findRecord(where, options.replyTo);
561
561
  }
562
562
  if (options.supersedes) checkSupersedes(where, from, group, records, options.supersedes);
563
+ if (options.ack) {
564
+ const draft = { kind: options.kind || "message", from, group, mentions, assignee: options.assignee || null };
565
+ if (!addressedRoles(state, draft).length) {
566
+ throw new ChatError("--ack asks the roles a record addresses, and this one addresses no one: mention a role, assign a todo, or post in a direct group.");
567
+ }
568
+ }
563
569
  const record = writeRecord(where, {
564
570
  group,
565
571
  kind: options.kind || "message",
@@ -567,6 +573,7 @@ function post(where, options) {
567
573
  mentions,
568
574
  reply_to: options.replyTo || null,
569
575
  supersedes: options.supersedes || null,
576
+ ack: options.ack ? ACK_REQUESTED : null,
570
577
  assignee: options.assignee || null,
571
578
  issue: options.issue || null,
572
579
  refs: options.refs || [],
@@ -607,6 +614,66 @@ function checkSupersedes(where, from, group, records, id) {
607
614
  }
608
615
  }
609
616
 
617
+ const ACK_REQUESTED = "requested";
618
+
619
+ // The roles a record asks to acknowledge it (#253 D1): the group's other
620
+ // members it would wake, and every other member for `@all`.
621
+ function addressedRoles(state, record) {
622
+ const everyone = (record.mentions || []).includes(ALL);
623
+ return [...state.members]
624
+ .filter((role) => role !== record.from && (everyone || wakes(record, role)))
625
+ .sort();
626
+ }
627
+
628
+ // Who of the addressed roles acknowledged — by `keel chat ack` or by replying —
629
+ // who only read the record, and who has not read it (#253 D4).
630
+ function ackStatus(where, record) {
631
+ const { records, state } = loadGroup(where, record.group);
632
+ const addressed = addressedRoles(state, record);
633
+ const given = new Set(records
634
+ .filter((r) => (r.kind === "ack" && r.target === record.id) || (READABLE_KINDS.has(r.kind) && r.reply_to === record.id))
635
+ .map((r) => r.from));
636
+ const readers = new Set(readersOf(where, record));
637
+ return {
638
+ acknowledged: addressed.filter((role) => given.has(role)),
639
+ readNotAcknowledged: addressed.filter((role) => !given.has(role) && readers.has(role)),
640
+ unread: addressed.filter((role) => !given.has(role) && !readers.has(role)),
641
+ };
642
+ }
643
+
644
+ function ack(where, id) {
645
+ const from = requireRole(where);
646
+ const target = targetFor(where, id, from, ["message", "todo"]);
647
+ if (target.ack !== ACK_REQUESTED) throw new ChatError(`Record ${id} does not ask for an acknowledgement.`);
648
+ const { state } = loadGroup(where, target.group);
649
+ const addressed = addressedRoles(state, target);
650
+ if (!addressed.includes(from)) {
651
+ throw new ChatError(`Record ${id} does not address ${from}; it asks ${addressed.join(", ")}.`);
652
+ }
653
+ if (ackStatus(where, target).acknowledged.includes(from)) {
654
+ throw new ChatError(`${from} already acknowledged ${id}.`);
655
+ }
656
+ const record = writeRecord(where, { group: target.group, kind: "ack", from, target: id });
657
+ advanceCursor(where, from, target.group, id);
658
+ return record;
659
+ }
660
+
661
+ // Records in open groups that ask and still wait on an addressed role.
662
+ function openAcks(where, { from = null } = {}) {
663
+ const result = [];
664
+ for (const group of listGroupNames(where)) {
665
+ const records = readLog(where, group);
666
+ const state = groupState(records);
667
+ if (!state.exists || state.archived) continue;
668
+ for (const record of records) {
669
+ if (record.ack !== ACK_REQUESTED || (from && record.from !== from)) continue;
670
+ const status = ackStatus(where, record);
671
+ if (status.readNotAcknowledged.length || status.unread.length) result.push({ record, acks: status });
672
+ }
673
+ }
674
+ return result;
675
+ }
676
+
610
677
  // Ids a later record of the same author supersedes, in one group's log.
611
678
  function supersededIds(records) {
612
679
  const byId = new Map(records.map((record) => [record.id, record]));
@@ -791,6 +858,9 @@ function readGroups(where, role, group) {
791
858
  }
792
859
 
793
860
  module.exports = {
861
+ ack,
862
+ ackStatus,
863
+ openAcks,
794
864
  checkName,
795
865
  worktreeSignalPath,
796
866
  ALL,
@@ -85,6 +85,7 @@ function markers(record) {
85
85
  if (record.reply_to) parts.push(`↳ ${record.reply_to}`);
86
86
  if (record.superseded_by) parts.push(`(superseded by ${record.superseded_by})`);
87
87
  if (record.supersedes) parts.push(`(supersedes ${record.supersedes})`);
88
+ if (record.ack === "requested") parts.push("(ack requested)");
88
89
  // A mention the text already spells out is not repeated; one written as an
89
90
  // alias (`@cb`) still shows the role it resolved to (#196).
90
91
  const text = String(record.text || "").toLowerCase();