@christang/keel 5.212.0 → 5.213.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.212.0",
3
+ "version": "5.213.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,4 +1,4 @@
1
- <!-- keel:start version=5.212.0 -->
1
+ <!-- keel:start version=5.213.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the durable authority, and memory or transcripts may only inform.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.212.0",
3
+ "version": "5.213.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.212.0",
9
+ "version": "5.213.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.212.0",
5
+ "version": "5.213.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.212.0",
3
+ "version": "5.213.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.212.0",
3
+ "version": "5.213.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",
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
35
35
  os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
36
36
 
37
37
 
38
- PACKAGE_VERSION = "5.212.0"
38
+ PACKAGE_VERSION = "5.213.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.212.0"
41
+ PROTOCOL_VERSION = "5.213.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -459,6 +459,7 @@ SCENARIOS: tuple = (
459
459
  ("chat-supersedes", chat.validate_chat_supersedes_scenario),
460
460
  ("chat-mention-skips-code", chat.validate_chat_mention_skips_code_scenario),
461
461
  ("two-live-sessions-on-one-role", shift.validate_two_live_sessions_on_one_role_scenario),
462
+ ("moved-session-is-not-a-twin", shift.validate_moved_session_is_not_a_twin_scenario),
462
463
  ("chat-role-rename", chat.validate_chat_role_rename_scenario),
463
464
  ("chat-wake-now-cli", chat.validate_chat_wake_now_cli_scenario),
464
465
  ("chat-hook-follows-session-worktree", chat.validate_chat_hook_follows_session_worktree_scenario),
@@ -112,6 +112,66 @@ def validate_two_live_sessions_on_one_role_scenario() -> int:
112
112
  return 0
113
113
 
114
114
 
115
+ def validate_moved_session_is_not_a_twin_scenario() -> int:
116
+ """Issue #490: a session that bound another role is not a twin of the first.
117
+
118
+ In ChipSTRIDE three sessions started in the main checkout, bound to
119
+ `chipstride`; two then entered their own worktrees and ran `keel chat role
120
+ --set`. `chipstride.sessions.json` kept all three, so every command warned
121
+ of three live `chipstride` sessions when there was one.
122
+ """
123
+ label = "moved-session-is-not-a-twin:"
124
+ with tempfile.TemporaryDirectory(prefix="keel-twins-490-") as raw:
125
+ base = Path(raw)
126
+ rtl, verify, env, _ = shift_scratch(base)
127
+ write_text(verify / "openspec/specs/.keep", "")
128
+ fe = base / "fe"
129
+ subprocess.run(["git", "worktree", "add", "-q", "-b", "fe", str(fe)], cwd=rtl, check=True, capture_output=True)
130
+ # Each session's transcript starts in the worktree it started in;
131
+ # `EnterWorktree` later gives sess-b one in fe as well.
132
+ config = base / "claude-config"
133
+ for sid in ("sess-a", "sess-b"):
134
+ write_text(config / "projects" / host_project_name(verify) / f"{sid}.jsonl", "{}\n")
135
+ other = subprocess.Popen(["sleep", "300"])
136
+ try:
137
+ def as_session(sid: str, pid: int) -> dict:
138
+ return {**env, "CLAUDE_CODE_ENTRYPOINT": "cli", "CLAUDE_CODE_SESSION_ID": sid, "CLAUDE_PID": str(pid),
139
+ "CLAUDE_CONFIG_DIR": str(config)}
140
+
141
+ for sid, pid in (("sess-a", os.getpid()), ("sess-b", other.pid)):
142
+ subprocess.run(["node", str(ROOT / "bin" / "keel.js"), "chat", "hook", "session-start"], cwd=verify,
143
+ env=as_session(sid, pid), text=True, capture_output=True, check=False,
144
+ input=json.dumps({"cwd": str(verify), "hook_event_name": "SessionStart", "session_id": sid, "source": "startup"}))
145
+ before = json.loads(run_keel(verify, "context", "--json", env=as_session("sess-a", os.getpid())).stdout)
146
+ if not any("live sessions" in w for w in before.get("warnings", [])):
147
+ report(f"{label} the fixture does not list two live verify sessions before sess-b moves: {before.get('warnings')!r}")
148
+ return 1
149
+ write_text(config / "projects" / host_project_name(fe) / "sess-b.jsonl", "{}\n")
150
+ moved = run_keel(fe, "chat", "role", "--set", "fe", env=as_session("sess-b", other.pid))
151
+ if moved.returncode != 0:
152
+ report(f"{label} keel chat role --set fe exited {moved.returncode}: {moved.stderr!r}")
153
+ return 1
154
+ if "Recorded this session" not in moved.stdout:
155
+ report(f"{label} sess-b's --set fe did not record it as fe's session: {moved.stdout!r}")
156
+ return 1
157
+ context = json.loads(run_keel(verify, "context", "--json", env=as_session("sess-a", os.getpid())).stdout)
158
+ twins = [w for w in context.get("warnings", []) if "live sessions" in w]
159
+ if twins:
160
+ report(f"{label} sess-b, now fe's, is still reported as a second verify session: {twins!r}")
161
+ return 1
162
+ if other.poll() is not None:
163
+ report(f"{label} sess-b's process ended before the check, so it proves nothing.")
164
+ return 1
165
+ finally:
166
+ if other.poll() is None:
167
+ other.kill()
168
+ if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
169
+ report(f"{label} the scenario registry does not include it.")
170
+ return 1
171
+ report(f"{label.rstrip(':')} scenario passed.")
172
+ return 0
173
+
174
+
115
175
  def validate_patrol_rearm_scenario() -> int:
116
176
  """Issue #260: the patrolling role is reminded to re-arm its schedule.
117
177
 
@@ -154,9 +154,21 @@ function touchSession(where, role, state) {
154
154
  store.writeJsonAtomic(where, file, sessions);
155
155
  }
156
156
 
157
+ // Whether a listed session is still the role's: one whose own record names
158
+ // another role has bound that one since, and is no twin here (#490 D1). With
159
+ // no record it cannot be told from a twin, so it counts (D2).
160
+ function sessionStillRole(where, role, id) {
161
+ if (!/^[A-Za-z0-9._-]{1,128}$/.test(id)) return true;
162
+ const file = path.join(where.root, "sessions", `${id}.json`);
163
+ if (!fs.existsSync(file)) return true;
164
+ const recorded = store.readJsonFile(file).role;
165
+ return !recorded || recorded === role;
166
+ }
167
+
157
168
  // The warning for two or more live sessions on a role (D3), or null.
158
169
  function twinWarning(where, role, now = Date.now()) {
159
- const live = Object.entries(store.readJsonFile(sessionsFile(where, role))).filter(([, entry]) => sessionLive(entry, now));
170
+ const live = Object.entries(store.readJsonFile(sessionsFile(where, role)))
171
+ .filter(([id, entry]) => sessionLive(entry, now) && sessionStillRole(where, role, id));
160
172
  if (live.length < 2) return null;
161
173
  const named = live.map(([id, entry]) => `${id} (pid ${entry.pid || "unknown"}, ${entry.worktree || "unknown worktree"})`).join(", ");
162
174
  return `${live.length} live sessions are bound to role ${role}: ${named}. They post under one name and share one read cursor, `