@christang/keel 5.195.0 → 5.196.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.195.0",
3
+ "version": "5.196.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.195.0 -->
1
+ <!-- keel:start version=5.196.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.195.0",
3
+ "version": "5.196.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.195.0",
9
+ "version": "5.196.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.195.0",
5
+ "version": "5.196.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.195.0",
3
+ "version": "5.196.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.195.0",
3
+ "version": "5.196.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",
@@ -13,7 +13,7 @@ keel shift check
13
13
  Exit 0 means ready. Exit 1 lists items. Deal with each before going on, or stop and ask the owner when one is not yours to settle:
14
14
 
15
15
  - Uncommitted changes, unpushed commits, a write guard, a lock lease, a linked worktree: commit and push, run `keel guard clear`, release the lease, or remove the worktree you made. Do not discard work to make the list empty.
16
- - A process: tell the host's from yours. A keep-awake the host started under this session, such as `caffeinate -i -t 300`, ends by itself, so it may stay. A server, watcher or job you started is yours: stop it, or ask the owner before leaving it running.
16
+ - A process: the check already leaves out the keep-awake the host runs under this session, such as `caffeinate -i -t 300`. A server, watcher or job you started is yours: stop it, or ask the owner before leaving it running.
17
17
 
18
18
  Then act on the `memory:` note: recheck what this session wrote to memory, and remove what this shift made untrue or what the repository can answer. It never blocks the shift.
19
19
 
@@ -32,7 +32,7 @@ Name commits and branches by id; `keel shift resume` checks them against the rem
32
32
 
33
33
  ## 3. Hand over
34
34
 
35
- Use a quoted heredoc, so backticks in the note are not run. When step 1 listed only the host's own processes, add `--force-reason "<which process, and that the host owns it>"`.
35
+ Use a quoted heredoc, so backticks in the note are not run. When the owner let a listed process stay, add `--force-reason "<which process, and that the owner let it stay>"`.
36
36
 
37
37
  ```bash
38
38
  keel shift ready --wake --file - <<'EOF'
@@ -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.195.0"
38
+ PACKAGE_VERSION = "5.196.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.195.0"
41
+ PROTOCOL_VERSION = "5.196.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -461,6 +461,7 @@ SCENARIOS: tuple = (
461
461
  ("tick-runs-each-patrol", shift.validate_tick_runs_each_patrol_scenario),
462
462
  ("launchd-stable-node", shift.validate_launchd_stable_node_scenario),
463
463
  ("shift-slash-command", shift.validate_shift_slash_command_scenario),
464
+ ("shift-check-skips-host-keep-awake", shift.validate_shift_check_skips_host_keep_awake_scenario),
464
465
  ("patrol-exit-says-who-acts", shift.validate_patrol_exit_says_who_acts_scenario),
465
466
  ("patrol-nudge", shift.validate_patrol_nudge_scenario),
466
467
  ("patrol-escalate", shift.validate_patrol_escalate_scenario),
@@ -710,6 +710,65 @@ def validate_launchd_stable_node_scenario() -> int:
710
710
  return 0
711
711
 
712
712
 
713
+ def validate_shift_check_skips_host_keep_awake_scenario() -> int:
714
+ """Issue #447: the host's own keep-awake is not a loose end of the shift.
715
+
716
+ Claude Code runs `caffeinate` as a child of the session's host process,
717
+ an ancestor of the check. That one is left out; a `caffeinate` with any
718
+ other parent, and any other program, are still named.
719
+ """
720
+ label = "shift-check-skips-host-keep-awake:"
721
+ with tempfile.TemporaryDirectory(prefix="keel-shift-447-") as raw:
722
+ base = Path(raw)
723
+ _rtl, verify, env, _ = shift_scratch(base)
724
+ # A stand-in named `caffeinate` by its argv[0]: macOS kills a copied
725
+ # system binary, and `ps` shows the name a process was exec'd under.
726
+ # This process is an ancestor of the `keel shift check` it runs, as the
727
+ # session's claude process is of the shell that runs the check.
728
+ host = subprocess.Popen(["bash", "-c", "exec -a caffeinate sleep 90"], cwd=verify, start_new_session=True)
729
+ # Orphaned in a process group of its own, as a keep-awake another
730
+ # session or a script left behind would be.
731
+ subprocess.run(["bash", "-c", "bash -c 'exec -a caffeinate sleep 91' >/dev/null 2>&1 &"], cwd=verify, check=True,
732
+ start_new_session=True)
733
+ found: list[str] = []
734
+ for _ in range(50):
735
+ found = subprocess.run(["pgrep", "-f", "^caffeinate 91"], capture_output=True, text=True).stdout.split()
736
+ if found:
737
+ break
738
+ time.sleep(0.1)
739
+ if not found:
740
+ report(f"{label} the orphaned stand-in caffeinate did not start.")
741
+ host.kill()
742
+ return 1
743
+ orphan = int(found[0])
744
+ sleeper = subprocess.Popen(["sleep", "92"], cwd=verify, start_new_session=True)
745
+ try:
746
+ listed = run_keel(verify, "shift", "check", env=env)
747
+ if f"PID {host.pid}," in listed.stdout:
748
+ report(f"{label} keel shift check names the host's own keep-awake: {listed.stdout.strip()}")
749
+ return 1
750
+ for name, pid in (("an orphaned caffeinate", orphan), ("a sleep", sleeper.pid)):
751
+ if f"PID {pid}," not in listed.stdout:
752
+ report(f"{label} keel shift check does not name {name} (PID {pid}): {listed.stdout.strip()}")
753
+ return 1
754
+ os.kill(orphan, signal.SIGKILL)
755
+ sleeper.kill()
756
+ sleeper.wait()
757
+ time.sleep(0.3)
758
+ clean = run_keel(verify, "shift", "check", env=env)
759
+ if clean.returncode != 0:
760
+ report(f"{label} with only the host's keep-awake running, keel shift check exited {clean.returncode}: {clean.stdout.strip()}")
761
+ return 1
762
+ finally:
763
+ for proc in (host, sleeper):
764
+ proc.kill()
765
+ proc.wait()
766
+ with contextlib.suppress(ProcessLookupError):
767
+ os.kill(orphan, signal.SIGKILL)
768
+ report("shift-check-skips-host-keep-awake scenario passed.")
769
+ return 0
770
+
771
+
713
772
  def validate_shift_slash_command_scenario() -> int:
714
773
  """Issue #386: a session changes its own shift with one slash command.
715
774
 
package/src/core/shift.js CHANGED
@@ -133,6 +133,8 @@ function processDirectories() {
133
133
 
134
134
  // An interactive shell open in the worktree, such as a terminal tab, is not
135
135
  // work in progress; what it runs is, and is listed by its own entry.
136
+ const HOST_KEEP_AWAKE = /^(?:\S*\/)?caffeinate(?:\s|$)/;
137
+
136
138
  const IDLE_SHELL = /^-?(?:\S*\/)?(?:zsh|bash|sh|dash|fish)(?:\s+-[il]+)*\s*$/;
137
139
 
138
140
  function liveProcesses(worktree) {
@@ -147,6 +149,10 @@ function liveProcesses(worktree) {
147
149
  if (own.has(pid) || !inside(realpath(cwd), worktree)) continue;
148
150
  const row = table.get(pid);
149
151
  if (!row || row.pgid === group || IDLE_SHELL.test(row.command)) continue;
152
+ // The keep-awake the session's host runs under it (#447 D1): its parent is
153
+ // one of the checker's ancestors, the host process itself. Not init, which
154
+ // every orphan has for a parent and every process for an ancestor.
155
+ if (row.ppid > 1 && own.has(row.ppid) && HOST_KEEP_AWAKE.test(row.command)) continue;
150
156
  found.push(row);
151
157
  }
152
158
  return found.sort((a, b) => a.pid - b.pid);