@christang/keel 5.134.0 → 5.135.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.134.0 -->
1
+ <!-- keel:start version=5.135.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.134.0",
3
+ "version": "5.135.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.134.0",
9
+ "version": "5.135.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.134.0",
5
+ "version": "5.135.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.134.0",
3
+ "version": "5.135.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.134.0",
3
+ "version": "5.135.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.134.0"
51
- PROTOCOL_VERSION = "5.134.0"
50
+ PACKAGE_VERSION = "5.135.0"
51
+ PROTOCOL_VERSION = "5.135.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
@@ -6909,6 +6909,52 @@ def validate_shift_restore_authorization_scenario() -> int:
6909
6909
  return 0
6910
6910
 
6911
6911
 
6912
+ def validate_shift_desktop_wake_overdue_scenario() -> int:
6913
+ """`keel shift status` flags a desktop note whose wake is overdue.
6914
+
6915
+ A wake task that never runs leaves no trace anywhere else; the waiting
6916
+ note with its recorded desktop session is the one place a coordinator or
6917
+ patrol can see it (D2 of shift-desktop-wake-confirm).
6918
+ """
6919
+ label = "shift-desktop-wake-overdue:"
6920
+ with tempfile.TemporaryDirectory(prefix="keel-shift-overdue-") as raw:
6921
+ base = Path(raw)
6922
+ _rtl, verify, env, _ = shift_scratch(base)
6923
+ env = {**env, "KEEL_SHIFT_WAKE_TIMEOUT_MS": "2000"}
6924
+ desktop = {**env, "CLAUDE_CODE_ENTRYPOINT": "claude-desktop", "CLAUDE_CODE_HOST_SESSION_ID": "local_test-319"}
6925
+ armed = run_keel(verify, "shift", "ready", "--wake", "verify note: next is R021", env=desktop)
6926
+ if armed.returncode != 0:
6927
+ report(f"{label} ready --wake on the desktop app failed: {armed.stderr.strip()}")
6928
+ return 1
6929
+ young = run_keel(verify, "shift", "status", env={**env, "KEEL_SHIFT_WAKE_OVERDUE_MS": "3600000"})
6930
+ if "overdue" in young.stdout:
6931
+ report(f"{label} a note written just now is already called overdue: {young.stdout.strip()}")
6932
+ return 1
6933
+ late = run_keel(verify, "shift", "status", env={**env, "KEEL_SHIFT_WAKE_OVERDUE_MS": "0"})
6934
+ for needle in ("overdue", "local_test-319", "list_task_runs", "send_message"):
6935
+ if needle not in late.stdout:
6936
+ report(f"{label} status past the overdue time does not name {needle}: {late.stdout.strip()}")
6937
+ return 1
6938
+ run_keel(verify, "shift", "resume", env=env)
6939
+ plain = run_keel(verify, "shift", "ready", "--wake", "verify note: next is R022", env=env)
6940
+ if plain.returncode != 0:
6941
+ report(f"{label} ready --wake outside the desktop app failed: {plain.stderr.strip()}")
6942
+ return 1
6943
+ other = run_keel(verify, "shift", "status", env={**env, "KEEL_SHIFT_WAKE_OVERDUE_MS": "0"})
6944
+ if "overdue" in other.stdout:
6945
+ report(f"{label} a note with no desktop session is called overdue: {other.stdout.strip()}")
6946
+ return 1
6947
+ for relative, word in (("docs/shift-change.md", "overdue"), ("docs/shift-change.zh-CN.md", "超时")):
6948
+ if word not in (ROOT / relative).read_text(encoding="utf-8"):
6949
+ report(f"{label} {relative} does not say {word}.")
6950
+ return 1
6951
+ if "shift-desktop-wake-overdue" not in {name for name, _ in SCENARIOS}:
6952
+ report(f"{label} scenario is not registered.")
6953
+ return 1
6954
+ report("shift-desktop-wake-overdue scenario passed.")
6955
+ return 0
6956
+
6957
+
6912
6958
  def validate_shift_desktop_wake_scenario() -> int:
6913
6959
  """Issue #319: on the desktop app a clear starts no session until a prompt.
6914
6960
 
@@ -6969,6 +7015,13 @@ def validate_shift_desktop_wake_scenario() -> int:
6969
7015
  if not look < armed.stdout.find("unarchive_session") < armed.stdout.find("send_message", look):
6970
7016
  report(f"{label} the wake does not check get_session, then unarchive_session, then send_message: {armed.stdout.strip()}")
6971
7017
  return 1
7018
+ # The wake confirms delivery: anything but delivered or queued after the
7019
+ # archived retry is a failed wake the owner hears about (D1 of
7020
+ # shift-desktop-wake-confirm).
7021
+ for needle in ("PushNotification", "WAKE FAILED", "delivered"):
7022
+ if needle not in armed.stdout[armed.stdout.find("send_message"):]:
7023
+ report(f"{label} the desktop wake does not say {needle} after send_message: {armed.stdout.strip()}")
7024
+ return 1
6972
7025
  if "archived copy" in armed.stdout:
6973
7026
  report(f"{label} the desktop clear hint still says the rename tells an archived copy apart: {armed.stdout.strip()}")
6974
7027
  return 1
@@ -7016,7 +7069,7 @@ def validate_shift_desktop_wake_scenario() -> int:
7016
7069
  report(f"{label} {relative} still says {stale}.")
7017
7070
  return 1
7018
7071
  for needle in ("send_message", "set_remote_control", "set_session_title", "shift-restore",
7019
- "get_session", "unarchive_session"):
7072
+ "get_session", "unarchive_session", "PushNotification", "WAKE FAILED"):
7020
7073
  if needle not in text:
7021
7074
  report(f"{label} {relative} does not name {needle} for the desktop app.")
7022
7075
  return 1
@@ -40555,6 +40608,7 @@ SCENARIOS: tuple = (
40555
40608
  ("host-run-session", validate_host_run_session_scenario),
40556
40609
  ("shift-without-role", validate_shift_without_role_scenario),
40557
40610
  ("shift-desktop-wake", validate_shift_desktop_wake_scenario),
40611
+ ("shift-desktop-wake-overdue", validate_shift_desktop_wake_overdue_scenario),
40558
40612
  ("shift-restore-authorization", validate_shift_restore_authorization_scenario),
40559
40613
  ("self-shift-authorization", validate_self_shift_authorization_scenario),
40560
40614
  ("resource-lock", validate_resource_lock_scenario),
package/src/core/shift.js CHANGED
@@ -435,6 +435,12 @@ function ready(where, options) {
435
435
  const WAKE_SENDER = "keel-shift";
436
436
  const WAKE_SOURCES = new Set(["clear", "startup"]);
437
437
 
438
+ // Zero is a valid overdue time: it flags every desktop note at once.
439
+ function overdueMs() {
440
+ const value = Number(process.env.KEEL_SHIFT_WAKE_OVERDUE_MS);
441
+ return process.env.KEEL_SHIFT_WAKE_OVERDUE_MS && Number.isFinite(value) && value >= 0 ? value : 15 * 60 * 1000;
442
+ }
443
+
438
444
  function envMs(name, fallback) {
439
445
  const value = Number(process.env[name]);
440
446
  return Number.isFinite(value) && value > 0 ? value : fallback;
@@ -566,6 +572,12 @@ function status(where) {
566
572
  const stat = fs.statSync(path.join(folder, file));
567
573
  const row = entry(`${prefix}${file.slice(0, -3)}`);
568
574
  row.note = store.isoLocal(stat.mtime);
575
+ // A desktop wake that never ran leaves no trace but the waiting note
576
+ // (D2 of shift-desktop-wake-confirm).
577
+ const desktop = fs.readFileSync(path.join(folder, file), "utf8").match(/^Desktop session: (\S+)\.$/m);
578
+ if (desktop && Date.now() - stat.mtime.getTime() >= overdueMs()) {
579
+ row.overdueDesktop = desktop[1];
580
+ }
569
581
  if (prefix) {
570
582
  // The note's header names the worktree it was written in (#291 D6).
571
583
  const header = fs.readFileSync(path.join(folder, file), "utf8").match(/^Written \S+ in (.+)\.$/m);
@@ -708,6 +720,13 @@ function safeList(dir) {
708
720
  }
709
721
 
710
722
  function describe(row) {
723
+ const line = describeState(row);
724
+ if (!row.note || !row.overdueDesktop) return line;
725
+ return `${line}\n desktop wake overdue: nothing has resumed it; check the wake task's run with \`list_task_runs\`, `
726
+ + `and if it did not deliver, \`send_message\` session ${row.overdueDesktop} to run \`keel context\` and \`keel shift resume\``;
727
+ }
728
+
729
+ function describeState(row) {
711
730
  if (row.note && row.role.startsWith("worktree ")) {
712
731
  return `${row.role}: note waiting since ${row.note}; no chat role there, so tell the session in ${row.path || "that worktree"} to run \`keel shift resume\``;
713
732
  }
@@ -758,6 +777,11 @@ function clearHint(result) {
758
777
  + `then calls \`send_message\` to it with: "${result.role}: your new shift starts now. `
759
778
  + "Run `keel context` and `keel shift resume`, then restore Remote Control and this session's title as `keel shift resume` says.\" "
760
779
  + "If that send is still refused because the session is archived, it unarchives it and sends once more, and it says which path it took. "
780
+ // The run's summary is the only trace a wake leaves, so a send that did
781
+ // not deliver must say so there and reach the owner (D1 of
782
+ // shift-desktop-wake-confirm).
783
+ + "A send result of `delivered` or `queued` is a delivered wake; any other result after that retry is a failed wake: "
784
+ + "the task then calls `PushNotification` naming the session and the result, and starts its reply with `WAKE FAILED`. "
761
785
  + "The app's auto-archive can archive the cleared session before the wake (#326); unarchiving brings back its worktree. "
762
786
  + "A task that fires before the clear gets the clear refused, so take the next two steps at once.",
763
787
  `2. Rename this session with \`set_session_title\` (for example "${result.role} · shifted ${store.isoLocal(new Date()).slice(0, 16)}"), so it reads as between shifts until the woken session renames it back.`,