@christang/keel 5.94.0 → 5.94.1

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.94.0 -->
1
+ <!-- keel:start version=5.94.1 -->
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.94.0",
3
+ "version": "5.94.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.94.0",
9
+ "version": "5.94.1",
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.94.0",
5
+ "version": "5.94.1",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.94.0",
3
+ "version": "5.94.1",
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.94.0",
3
+ "version": "5.94.1",
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.94.0"
51
- PROTOCOL_VERSION = "5.94.0"
50
+ PACKAGE_VERSION = "5.94.1"
51
+ PROTOCOL_VERSION = "5.94.1"
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
@@ -2663,15 +2663,43 @@ def validate_chat_claude_hooks_scenario() -> int:
2663
2663
  if not script.is_file():
2664
2664
  report(f"{label} {script.relative_to(ROOT)} does not exist.")
2665
2665
  return 1
2666
+ late_watch: list[str] = []
2666
2667
  for cwd in (unbound, plain):
2667
2668
  for event, host_event in events:
2668
2669
  quiet = hook(cwd, event, host_event)
2669
2670
  if quiet.returncode != 0:
2670
2671
  report(f"{label} {event} exited {quiet.returncode} in {cwd.name}, which has no role.")
2671
2672
  return 1
2673
+ if cwd == unbound and event == "session-start":
2674
+ # A session may start before its worktree's role is bound;
2675
+ # it still watches the worktree's signal, and nothing else.
2676
+ output = chat_json(quiet).get("hookSpecificOutput", {})
2677
+ watched = output.get("watchPaths") or []
2678
+ if len(watched) != 1:
2679
+ report(f"{label} session-start in a worktree with no role does not watch exactly one path: {quiet.stdout.strip()!r}")
2680
+ return 1
2681
+ if "/signal/worktree/" not in watched[0]:
2682
+ report(f"{label} session-start in a worktree with no role watches something other than the worktree signal: {watched!r}")
2683
+ return 1
2684
+ if output.get("additionalContext"):
2685
+ report(f"{label} session-start in a worktree with no role printed notice text: {quiet.stdout.strip()!r}")
2686
+ return 1
2687
+ late_watch = watched
2688
+ continue
2672
2689
  if quiet.stdout.strip() or quiet.stderr.strip():
2673
2690
  report(f"{label} {event} wrote output in {cwd.name}, which has no role: {(quiet.stdout + quiet.stderr).strip()!r}")
2674
2691
  return 1
2692
+ chat(unbound, "role", "--set", "late")
2693
+ chat(unbound, "group", "create", "side", "--member", "poster")
2694
+ run_keel(unbound, "chat", "post", "side", "@late please look", env={**env, "KEEL_CHAT_ROLE": "poster"})
2695
+ late_signal = Path(late_watch[0])
2696
+ if not late_signal.exists() or not late_signal.stat().st_size:
2697
+ report(f"{label} a mention of a role bound after session start did not touch the worktree signal that session watches.")
2698
+ return 1
2699
+ late_wake = hook(unbound, "file-changed", "FileChanged")
2700
+ if late_wake.returncode != 2:
2701
+ report(f"{label} file-changed exited {late_wake.returncode} for a role bound after session start, not 2.")
2702
+ return 1
2675
2703
 
2676
2704
  signal = mailbox_common_dir(rtl) / "keel-chat" / "signal" / "verify"
2677
2705
 
@@ -2717,8 +2745,12 @@ def validate_chat_claude_hooks_scenario() -> int:
2717
2745
  if mention_id not in start_output.get("additionalContext", ""):
2718
2746
  report(f"{label} the session-start notice does not name the mention: {start.stdout.strip()} {start.stderr.strip()}")
2719
2747
  return 1
2720
- if start_output.get("watchPaths") != [str(signal)]:
2721
- report(f"{label} session-start watchPaths is {start_output.get('watchPaths')!r}, not [{str(signal)!r}].")
2748
+ watch = start_output.get("watchPaths") or []
2749
+ if watch[:1] != [str(signal)]:
2750
+ report(f"{label} session-start does not watch the role's signal first: {watch!r}, not starting with {str(signal)!r}.")
2751
+ return 1
2752
+ if [path for path in watch[1:] if "/signal/worktree/" in path] != watch[1:2] or len(watch) != 2:
2753
+ report(f"{label} session-start does not also watch exactly the worktree signal: {watch!r}.")
2722
2754
  return 1
2723
2755
 
2724
2756
  before_dm = signal_size()
@@ -114,6 +114,13 @@ function ensureSignal(where, role) {
114
114
  return signal;
115
115
  }
116
116
 
117
+ function ensureWorktreeSignal(where) {
118
+ const signal = store.worktreeSignalPath(where.root, where.worktree);
119
+ fs.mkdirSync(path.dirname(signal), { recursive: true });
120
+ if (!fs.existsSync(signal)) fs.writeFileSync(signal, "");
121
+ return signal;
122
+ }
123
+
117
124
  // For a Slack-enabled project, whether this machine's bridge is carrying the
118
125
  // chat, so a session does not assume the owner's phone can reach it (D18).
119
126
  function bridgeLine(where) {
@@ -161,6 +168,13 @@ function hook(event, input, { mail = false } = {}) {
161
168
  } catch {
162
169
  role = null;
163
170
  }
171
+ // A session's watch list is fixed at SessionStart, so a worktree with no role
172
+ // yet still watches its own signal, which a role bound later will touch
173
+ // (chat-wake-late-binding D1). Nothing else is said until there is a role.
174
+ if (where && !role && event === "session-start") {
175
+ const watched = ensureWorktreeSignal(where);
176
+ return { code: 0, stdout: `${JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", watchPaths: [watched] } })}\n` };
177
+ }
164
178
  if (!where || !role) return { code: 0 };
165
179
  if (event === "session-end") {
166
180
  touchPresence(where, role, "offline");
@@ -171,7 +185,7 @@ function hook(event, input, { mail = false } = {}) {
171
185
  const text = chatText && mail ? `${chatText}\n${MAIL_POINTER}` : chatText;
172
186
  if (event === "session-start") {
173
187
  const output = {
174
- hookSpecificOutput: { hookEventName: "SessionStart", watchPaths: [ensureSignal(where, role)] },
188
+ hookSpecificOutput: { hookEventName: "SessionStart", watchPaths: [ensureSignal(where, role), ensureWorktreeSignal(where)] },
175
189
  };
176
190
  const context = [bridgeLine(where), text].filter(Boolean).join("\n");
177
191
  if (context) output.hookSpecificOutput.additionalContext = context;
@@ -345,14 +345,31 @@ function writeRecord(where, fields, date = new Date()) {
345
345
  writeAtomic(where.root, target, renderRecord(record));
346
346
  refreshTranscript(where, record.group);
347
347
  // After the rename, so a host woken by the signal always finds the record.
348
- for (const role of signalTargets(record)) {
349
- const signal = path.join(where.root, "signal", role);
350
- fs.mkdirSync(path.dirname(signal), { recursive: true });
351
- fs.appendFileSync(signal, `${record.id}\n`);
348
+ // Each worktree bound to a woken role gets its own signal too, which a
349
+ // session watches from its start whether or not a role was bound yet
350
+ // (chat-wake-late-binding D2).
351
+ const targets = signalTargets(record);
352
+ const bound = targets.length ? readRoles(where.root) : {};
353
+ for (const role of targets) {
354
+ const signals = [path.join(where.root, "signal", role)];
355
+ for (const [worktree, name] of Object.entries(bound)) {
356
+ if (name === role) signals.push(worktreeSignalPath(where.root, worktree));
357
+ }
358
+ for (const signal of signals) {
359
+ fs.mkdirSync(path.dirname(signal), { recursive: true });
360
+ fs.appendFileSync(signal, `${record.id}\n`);
361
+ }
352
362
  }
353
363
  return record;
354
364
  }
355
365
 
366
+ // A worktree's own signal file: the first 16 hex digits of the SHA-256 of its
367
+ // path, so it names the worktree whatever role it later binds.
368
+ function worktreeSignalPath(root, worktree) {
369
+ const id = require("crypto").createHash("sha256").update(worktree).digest("hex").slice(0, 16);
370
+ return path.join(root, "signal", "worktree", id);
371
+ }
372
+
356
373
  // The transcript is derived and local (D1): regenerated whole after each
357
374
  // write, and never a source of anything. A failure to write it fails nothing.
358
375
  function refreshTranscript(where, group) {
@@ -737,6 +754,7 @@ function readGroups(where, role, group) {
737
754
 
738
755
  module.exports = {
739
756
  checkName,
757
+ worktreeSignalPath,
740
758
  ALL,
741
759
  ChatError,
742
760
  DATA_NOTICE,