@christang/keel 5.214.0 → 5.215.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.214.0",
3
+ "version": "5.215.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.214.0 -->
1
+ <!-- keel:start version=5.215.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.
package/bin/keel.js CHANGED
@@ -26,6 +26,7 @@ const {
26
26
  const {
27
27
  GuardInputError,
28
28
  clearGuard,
29
+ guardHolds,
29
30
  guardStatus,
30
31
  renderGuard,
31
32
  startGuard,
@@ -1489,7 +1490,7 @@ function adoptClaudeSessions(options) {
1489
1490
  left.push(`${named(row)}, ${row.status}`);
1490
1491
  continue;
1491
1492
  }
1492
- if (row.cwd && fs.existsSync(path.join(row.cwd, "keel", "guard.json"))) {
1493
+ if (row.cwd && guardHolds(row.cwd)) {
1493
1494
  left.push(`${named(row)}, under a task's write guard`);
1494
1495
  continue;
1495
1496
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.214.0",
3
+ "version": "5.215.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.214.0",
9
+ "version": "5.215.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.214.0",
5
+ "version": "5.215.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.214.0",
3
+ "version": "5.215.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.214.0",
3
+ "version": "5.215.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.214.0"
38
+ PACKAGE_VERSION = "5.215.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.214.0"
41
+ PROTOCOL_VERSION = "5.215.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -868,6 +868,22 @@ def chat_records_with(repo: Path, group: str, needle: str) -> list[str]:
868
868
  return [p.read_text(encoding="utf-8") for p in sorted(log.glob("*.md")) if needle in p.read_text(encoding="utf-8")]
869
869
 
870
870
 
871
+ def archived_guard(repo: Path, change: str = "demo", task: str = "1.1") -> None:
872
+ """A shape-valid `keel/guard.json` over `change#task`, checked and archived (#496).
873
+
874
+ `keel guard status` reads it as `archived`: the change directory is gone and
875
+ its archived copy shows the task checked, so the manifest enforces nothing.
876
+ """
877
+ tasks = f"openspec/changes/archive/2026-10-28-{change}/tasks.md"
878
+ write_text(repo / tasks, f"# Tasks\n\n- [x] {task} Done\n")
879
+ zero = "0" * 64
880
+ write_text(repo / "keel" / "guard.json", json.dumps({
881
+ "schema": "keel-write-guard/v1", "change": change, "task": task,
882
+ "fingerprint": {"algorithm": "sha256", "value": zero},
883
+ "touch": ["src/a.txt"], "authority": [{"path": tasks, "sha256": zero}],
884
+ }) + "\n")
885
+
886
+
871
887
  def shift_scratch(base: Path) -> tuple[Path, Path, dict, Path]:
872
888
  """`rtl` and `verify` worktrees pushed to a bare remote, for shift scenarios."""
873
889
  rtl, verify, env = chat_scratch_group(base)
@@ -22,6 +22,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
22
22
  from pathlib import Path
23
23
 
24
24
  from validation.common import (
25
+ archived_guard,
25
26
  portable_projection_bytes,
26
27
  HANDOFF_STUB,
27
28
  OPENSPEC_CONFIG_PATH,
@@ -2798,6 +2799,9 @@ def validate_update_adopts_idle_sessions_scenario() -> int:
2798
2799
  npm.chmod(0o755)
2799
2800
  guarded = tmp / "guarded"
2800
2801
  write_text(guarded / "keel" / "guard.json", "{}\n")
2802
+ # Only a checked, archived task's manifest, which enforces nothing (#496).
2803
+ finished = tmp / "finished"
2804
+ archived_guard(finished)
2801
2805
  sleepers: list[int] = []
2802
2806
 
2803
2807
  def row(name: str, sid: str, status: str, started: int, cwd: Path) -> dict:
@@ -2818,6 +2822,7 @@ def validate_update_adopts_idle_sessions_scenario() -> int:
2818
2822
  row("rtl · old guarded", "cccccccc-0000-0000-0000-000000000003", "idle", t0 - 3600000, guarded),
2819
2823
  row("pm · fresh idle", "dddddddd-0000-0000-0000-000000000004", "idle", t0 + 3600000, tmp),
2820
2824
  row("maint · this session", "eeeeeeee-0000-0000-0000-000000000005", "busy", t0 - 3600000, tmp),
2825
+ row("ip · old finished", "ffffffff-0000-0000-0000-000000000006", "idle", t0 - 3600000, finished),
2821
2826
  ]
2822
2827
  (tmp / "state.json").write_text(json.dumps({"version": "5.0.0", "lastUpdated": "2026-10-21T00:00:00.000Z", "rows": rows}))
2823
2828
  env = dict(os.environ)
@@ -2840,11 +2845,15 @@ def validate_update_adopts_idle_sessions_scenario() -> int:
2840
2845
  if adopted.returncode != 0:
2841
2846
  report(f"{label} keel --update --adopt exited {adopted.returncode}: {adopted.stdout!r} {adopted.stderr!r}")
2842
2847
  return 1
2843
- if stops != ["aaaaaaaa"]:
2844
- report(f"{label} --adopt stopped {stops!r}, not only the idle session started before the update.")
2848
+ if "ffffffff" not in stops:
2849
+ report(f"{label} --adopt left alone the session whose worktree holds only an archived manifest: {line!r}")
2845
2850
  return 1
2846
- if len(resumes) != 1 or resumes[0]["args"] != ["--bg", "--resume", "aaaaaaaa-0000-0000-0000-000000000001"]:
2847
- report(f"{label} --adopt did not resume the stopped session with exactly `--bg --resume <id>`: {resumes!r}")
2851
+ if stops != ["aaaaaaaa", "ffffffff"]:
2852
+ report(f"{label} --adopt stopped {stops!r}, not only the idle sessions started before the update.")
2853
+ return 1
2854
+ if [r["args"] for r in resumes] != [["--bg", "--resume", "aaaaaaaa-0000-0000-0000-000000000001"],
2855
+ ["--bg", "--resume", "ffffffff-0000-0000-0000-000000000006"]]:
2856
+ report(f"{label} --adopt did not resume the stopped sessions with exactly `--bg --resume <id>`: {resumes!r}")
2848
2857
  return 1
2849
2858
  if resumes[0]["cwd"] != os.path.realpath(tmp) and resumes[0]["cwd"] != str(tmp):
2850
2859
  report(f"{label} the resume ran in {resumes[0]['cwd']!r}, not the session's worktree {str(tmp)!r}.")
@@ -4346,6 +4355,31 @@ def validate_context_names_the_protocol_refresh_scenario() -> int:
4346
4355
  return 0
4347
4356
 
4348
4357
 
4358
+ def validate_context_archived_guard_does_not_defer_refresh_scenario() -> int:
4359
+ """Issue #496: a manifest over a checked, archived task defers nothing."""
4360
+ label = "context-archived-guard-does-not-defer-refresh:"
4361
+ with tempfile.TemporaryDirectory(prefix="keel-protocol-496-") as raw:
4362
+ repo = _installed_repo(Path(raw), "archived", "claude", "5.0.0")
4363
+ write_text(repo / "keel/config.yaml", "authorize:\n - protocol-refresh\n")
4364
+ archived_guard(repo)
4365
+ status = run_keel(repo, "guard", "status")
4366
+ if "Status: archived" not in status.stdout:
4367
+ report(f"{label} the fixture manifest does not read as archived: {status.stdout.strip()!r}")
4368
+ return 1
4369
+ lines = _protocol_lines(repo)
4370
+ if len(lines) != 1:
4371
+ report(f"{label} context printed {len(lines)} Protocol lines, not one: {lines!r}")
4372
+ return 1
4373
+ if "deferred" in lines[0]:
4374
+ report(f"{label} an archived manifest deferred the refresh: {lines!r}")
4375
+ return 1
4376
+ if "standing-authorized" not in lines[0]:
4377
+ report(f"{label} the refresh is not read as standing-authorized: {lines!r}")
4378
+ return 1
4379
+ report(f"{label.rstrip(':')} scenario passed.")
4380
+ return 0
4381
+
4382
+
4349
4383
  def validate_native_plugin_marketplaces_scenario() -> int:
4350
4384
  codex = shutil.which("codex")
4351
4385
  claude = claude_cli()
@@ -415,6 +415,7 @@ SCENARIOS: tuple = (
415
415
  ("directory-tree-is-the-package-renamed", hosts.validate_directory_tree_is_the_package_renamed_scenario),
416
416
  ("init-declares-plugin-auto-update", hosts.validate_init_declares_plugin_auto_update_scenario),
417
417
  ("context-names-the-protocol-refresh", hosts.validate_context_names_the_protocol_refresh_scenario),
418
+ ("context-archived-guard-does-not-defer-refresh", hosts.validate_context_archived_guard_does_not_defer_refresh_scenario),
418
419
  ("collected-feedback-is-recorded", chat.validate_collected_feedback_is_recorded_scenario),
419
420
  ("shift-change", shift.validate_shift_change_scenario),
420
421
  ("shift-role-elsewhere", shift.validate_shift_role_elsewhere_scenario),
@@ -488,6 +489,7 @@ SCENARIOS: tuple = (
488
489
  ("launchd-stable-node", shift.validate_launchd_stable_node_scenario),
489
490
  ("shift-slash-command", shift.validate_shift_slash_command_scenario),
490
491
  ("shift-check-skips-host-keep-awake", shift.validate_shift_check_skips_host_keep_awake_scenario),
492
+ ("shift-check-archived-guard-is-not-in-progress", shift.validate_shift_check_archived_guard_is_not_in_progress_scenario),
491
493
  ("patrol-exit-says-who-acts", shift.validate_patrol_exit_says_who_acts_scenario),
492
494
  ("patrol-nudge", shift.validate_patrol_nudge_scenario),
493
495
  ("patrol-escalate", shift.validate_patrol_escalate_scenario),
@@ -22,6 +22,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
22
22
  from pathlib import Path
23
23
 
24
24
  from validation.common import (
25
+ archived_guard,
25
26
  BOOTSTRAP_BLOCK_BYTE_BUDGET,
26
27
  ROOT,
27
28
  extract_managed_block,
@@ -829,6 +830,59 @@ def validate_shift_check_skips_host_keep_awake_scenario() -> int:
829
830
  return 0
830
831
 
831
832
 
833
+ def validate_shift_check_archived_guard_is_not_in_progress_scenario() -> int:
834
+ """Issue #496: a manifest over a checked, archived task is not a loose end.
835
+
836
+ `keel guard status` reads it as `archived` and the hook enforces nothing
837
+ under it, so the check names it as a note with `keel guard clear`. The same
838
+ manifest over a live change still blocks.
839
+ """
840
+ label = "shift-check-archived-guard-is-not-in-progress:"
841
+ with tempfile.TemporaryDirectory(prefix="keel-shift-496-") as raw:
842
+ base = Path(raw)
843
+ _rtl, verify, env, _ = shift_scratch(base)
844
+ # keel/.gitignore ignores the manifest, as a Keel repository's does.
845
+ write_text(verify / "keel" / ".gitignore", "guard.json\n")
846
+ subprocess.run(["git", "add", "keel/.gitignore"], cwd=verify, check=True, capture_output=True)
847
+ subprocess.run(["git", "commit", "-q", "-m", "ignore guard"], cwd=verify, check=True, capture_output=True)
848
+ subprocess.run(["git", "push", "-q"], cwd=verify, check=True, capture_output=True)
849
+ archived_guard(verify)
850
+ subprocess.run(["git", "add", "openspec"], cwd=verify, check=True, capture_output=True)
851
+ subprocess.run(["git", "commit", "-q", "-m", "archive demo"], cwd=verify, check=True, capture_output=True)
852
+ subprocess.run(["git", "push", "-q"], cwd=verify, check=True, capture_output=True)
853
+ status = run_keel(verify, "guard", "status", env=env)
854
+ if "Status: archived" not in status.stdout:
855
+ report(f"{label} the fixture manifest does not read as archived: {status.stdout.strip()!r}")
856
+ return 1
857
+ checked = run_keel(verify, "shift", "check", "--json", env=env)
858
+ found = chat_json(checked)
859
+ kinds = [item["kind"] for item in found.get("items", [])]
860
+ if "task-in-progress" in kinds:
861
+ report(f"{label} an archived manifest is reported as task-in-progress: {checked.stdout.strip()[:600]}")
862
+ return 1
863
+ if checked.returncode != 0:
864
+ report(f"{label} with only an archived manifest, keel shift check exited {checked.returncode}: {checked.stdout.strip()[:600]}")
865
+ return 1
866
+ if not any("keel guard clear" in note for note in found.get("notes", [])):
867
+ report(f"{label} no note names `keel guard clear` for the archived manifest: {found.get('notes')!r}")
868
+ return 1
869
+ # The same manifest over a live change of that name still holds.
870
+ live = verify / "openspec" / "changes" / "demo"
871
+ write_text(live / "tasks.md", "# Tasks\n\n- [ ] 1.1 Not yet\n")
872
+ subprocess.run(["git", "add", "openspec"], cwd=verify, check=True, capture_output=True)
873
+ subprocess.run(["git", "commit", "-q", "-m", "live demo"], cwd=verify, check=True, capture_output=True)
874
+ subprocess.run(["git", "push", "-q"], cwd=verify, check=True, capture_output=True)
875
+ held = run_keel(verify, "shift", "check", "--json", env=env)
876
+ if "task-in-progress" not in [item["kind"] for item in chat_json(held).get("items", [])]:
877
+ report(f"{label} a manifest over a live change is not reported as task-in-progress: {held.stdout.strip()[:600]}")
878
+ return 1
879
+ if held.returncode != 1:
880
+ report(f"{label} with a manifest over a live change, keel shift check exited {held.returncode}: {held.stdout.strip()[:600]}")
881
+ return 1
882
+ report("shift-check-archived-guard-is-not-in-progress scenario passed.")
883
+ return 0
884
+
885
+
832
886
  def validate_shift_slash_command_scenario() -> int:
833
887
  """Issue #386: a session changes its own shift with one slash command.
834
888
 
@@ -23,6 +23,7 @@ const {
23
23
  ownerLanguageRule,
24
24
  } = require("./config");
25
25
  const { isKeelSourceRepo } = require("./capabilities");
26
+ const { guardHolds } = require("./guard");
26
27
  const { diagnoseDrift, driftCause } = require("./drift");
27
28
 
28
29
  const NEXT_ACTIONS = new Set([
@@ -1000,7 +1001,7 @@ function protocolRefresh(repo, running, authorization) {
1000
1001
  file: stamped.file,
1001
1002
  command: `keel --install --target ${installedTarget(repo)}`,
1002
1003
  authorized: authorization.scopes.has("protocol-refresh"),
1003
- deferred: fs.existsSync(path.join(repo, "keel", "guard.json")),
1004
+ deferred: guardHolds(repo),
1004
1005
  };
1005
1006
  }
1006
1007
 
package/src/core/guard.js CHANGED
@@ -424,6 +424,15 @@ function guardStatus(repo) {
424
424
  return guardResult("status", "active", { manifest });
425
425
  }
426
426
 
427
+ // Whether a manifest is in force: every state but `absent` and `archived`
428
+ // still has the hook deny writes, so only those two hold nothing (#496 D1).
429
+ // The shift check, the protocol refresh, and `--update --adopt` ask this
430
+ // rather than whether the file exists.
431
+ function guardHolds(repo) {
432
+ const { status } = guardStatus(repo);
433
+ return status !== "absent" && status !== "archived";
434
+ }
435
+
427
436
  function clearGuard(repo) {
428
437
  const file = manifestFile(repo);
429
438
  if (!fs.existsSync(file)) {
@@ -456,6 +465,7 @@ module.exports = {
456
465
  clearGuard,
457
466
  contentSignature,
458
467
  gitPaths,
468
+ guardHolds,
459
469
  guardStatus,
460
470
  readManifest,
461
471
  renderGuard,
package/src/core/shift.js CHANGED
@@ -18,6 +18,7 @@ const path = require("path");
18
18
  const { spawn, spawnSync } = require("child_process");
19
19
  const store = require("./chat/store");
20
20
  const locks = require("./lock");
21
+ const guard = require("./guard");
21
22
 
22
23
  const REF = "keel-shift";
23
24
  const USAGE = [
@@ -197,7 +198,13 @@ function check(where, role) {
197
198
  }
198
199
 
199
200
  if (fs.existsSync(path.join(where.worktree, "keel", "guard.json"))) {
200
- items.push({ kind: "task-in-progress", detail: "keel/guard.json: a task's write guard is still active; complete the task or clear the guard" });
201
+ if (guard.guardHolds(where.worktree)) {
202
+ items.push({ kind: "task-in-progress", detail: "keel/guard.json: a task's write guard is still active; complete the task or clear the guard" });
203
+ } else {
204
+ // Checked and archived: the hook lets every write through (#496 D2).
205
+ const { manifest } = guard.guardStatus(where.worktree);
206
+ notes.push(`keel/guard.json guards ${manifest.change}#${manifest.task}, which is checked and archived, so it enforces nothing; \`keel guard clear\` removes it`);
207
+ }
201
208
  }
202
209
 
203
210
  for (const row of liveProcesses(where.worktree)) {