@christang/keel 5.186.0 → 5.188.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.186.0",
3
+ "version": "5.188.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,7 +1,8 @@
1
- <!-- keel:start version=5.186.0 -->
1
+ <!-- keel:start version=5.188.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.
5
+ - Memory: write only what the next session would get wrong without it and the repository cannot answer, never a one-off slip; one fact per entry. Recheck it after a fix, at a release, and at a shift change.
5
6
  - Obey the selected task capsule: `keel gate task-start` before implementing, `--record` its fingerprint to Evidence `Contract`, which `task-complete` requires, before checking complete. Touch bounds product writes; the change's own dir is exempt. On Claude a passing `task-start` guards it by default (`--no-guard` opts out).
6
7
  - Work through an approved `tasks.md` in order, each task through its own gates. A subagent is the model's choice and is treated as the main agent is. No commit, push, sync, or archive unless the task, the owner, or `keel/config.yaml` authorizes it.
7
8
  - Route Full (the OpenSpec flow) for new features, interface or protocol changes, cross-module work, or over ~3 files / 100 lines; Lite for local fixes with no interface change. No gate checks routing; a project corrects the size bar with `full_mode_paths:` in `keel/config.yaml`, which `keel context` reports.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.186.0",
3
+ "version": "5.188.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.186.0",
9
+ "version": "5.188.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.186.0",
5
+ "version": "5.188.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.186.0",
3
+ "version": "5.188.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.186.0",
3
+ "version": "5.188.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",
@@ -15,6 +15,8 @@ Exit 0 means ready. Exit 1 lists items. Deal with each before going on, or stop
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
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.
17
17
 
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
+
18
20
  A shift in the middle of a task throws away working state that compaction would have kept. If the task is not at a boundary, say so to the owner before going on.
19
21
 
20
22
  ## 2. Write the hand-off note
@@ -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.186.0"
38
+ PACKAGE_VERSION = "5.188.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.186.0"
41
+ PROTOCOL_VERSION = "5.188.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -131,7 +131,14 @@ TEMPLATE_CHECKSUM_SUFFIX = " -->"
131
131
  #
132
132
  # 1400 rather than a round 1536: the headroom is "current content plus one short
133
133
  # clause", so the next addition has to argue for itself the way this one did.
134
- BOOTSTRAP_BLOCK_BYTE_BUDGET = 1400
134
+ #
135
+ # Raised from 1400 to 1700 in 5.187.0 for the memory rule (#416). The owner put
136
+ # memory hygiene into the protocol on 2026-10-21, and memory argues the way
137
+ # routing did: it is never inert. Any session may write to memory whether or not
138
+ # a project declares anything, and the bootstrap is the only text that reaches a
139
+ # consuming repository. The headroom is again current content plus one short
140
+ # clause.
141
+ BOOTSTRAP_BLOCK_BYTE_BUDGET = 1700
135
142
 
136
143
 
137
144
  RESIDENT_BLOCKS = [
@@ -153,6 +160,10 @@ RESIDENT_BLOCKS = [
153
160
  re.compile(r"Touch\b[^\n]*\bbound", re.IGNORECASE),
154
161
  # #414: subagents are the model's choice, treated as the main agent.
155
162
  "treated as the main agent is",
163
+ # #416: what memory may hold and when it is rechecked, as topics so
164
+ # the sentence can be reworded under the byte budget.
165
+ re.compile(r"memory[^\n]*repository cannot answer", re.IGNORECASE),
166
+ re.compile(r"memory[^\n]*shift change", re.IGNORECASE),
156
167
  "native plugin",
157
168
  "keel --init",
158
169
  # Routing is the one durable rule with no gate behind it, so the
@@ -6,8 +6,8 @@ directory, a hook payload — and none of it against a real one. Every
6
6
  registered scenario is classified as deterministic or stand-in host, from
7
7
  markers derived from Keel's own sources, through the validation helpers and
8
8
  scripts it reaches. The classification is static and over-approximates: a
9
- scenario that only mentions a marker counts as stand-in host, which claims
10
- less real evidence, never more.
9
+ scenario that sets a marker counts as stand-in host even when the value is
10
+ never used, which claims less real evidence, never more.
11
11
  """
12
12
  from __future__ import annotations
13
13
 
@@ -76,16 +76,25 @@ def reached_text(function: str, found: dict[str, tuple[set[str], str]]) -> tuple
76
76
  return text, seen
77
77
 
78
78
 
79
+ def sets(mark: str) -> re.Pattern:
80
+ """Where code sets a marker rather than names it: a dict key, an item
81
+ assignment, `NAME=` in shell or keyword form, or an attribute assignment.
82
+ Naming a variable to remove or read it is not a stand-in (5.188.0)."""
83
+ name = re.escape(mark)
84
+ return re.compile(r"[\"']" + name + r"[\"']\s*:|\[\s*[\"']" + name + r"[\"']\s*\]\s*=|\b" + name + r"=|\." + name + r"\s*=")
85
+
86
+
79
87
  def classify(scenarios) -> dict:
80
88
  """{"markers", "stand-in host", "deterministic", "can skip"} for the registered scenarios, in registry order."""
81
89
  marks = markers()
90
+ setters = [sets(mark) for mark in marks]
82
91
  found = definitions()
83
92
  standin, deterministic, skippable = [], [], []
84
93
  for name, function in scenarios:
85
94
  defined = getattr(function, "__name__", None)
86
95
  text, seen = reached_text(defined, found) if defined in found else ("", set())
87
96
  # A scenario whose code cannot be read cannot be shown deterministic.
88
- if defined not in found or any(mark in text for mark in marks) or SHADOWED_PROGRAM.search(text):
97
+ if defined not in found or any(setter.search(text) for setter in setters) or SHADOWED_PROGRAM.search(text):
89
98
  standin.append(name)
90
99
  else:
91
100
  deterministic.append(name)
@@ -418,6 +418,7 @@ SCENARIOS: tuple = (
418
418
  ("tick-retries-failed-wake", shift.validate_tick_retries_failed_wake_scenario),
419
419
  ("shift-cli-handover-claims-once", shift.validate_shift_cli_handover_claims_once_scenario),
420
420
  ("shift-cli-retries-failed-handover", shift.validate_shift_cli_retries_failed_handover_scenario),
421
+ ("memory-rule-reaches-every-repo", shift.validate_memory_rule_reaches_every_repo_scenario),
421
422
  ("owner-language", chat.validate_owner_language_scenario),
422
423
  ("owner-language-after-tools", chat.validate_owner_language_after_tools_scenario),
423
424
  ("shift-history", shift.validate_shift_history_scenario),
@@ -1497,6 +1497,11 @@ def validate_release_evidence_classes_scenario() -> int:
1497
1497
  if "version-alignment" not in deterministic:
1498
1498
  report(f"{label} version-alignment is not counted as deterministic.")
1499
1499
  return 1
1500
+ # chat-core reaches the host's variables only through chat_environment,
1501
+ # which names them to remove them: a mention is not a stand-in (5.188.0).
1502
+ if "chat-core" not in deterministic:
1503
+ report(f"{label} chat-core is counted as run against a stand-in host for removing host variables.")
1504
+ return 1
1500
1505
  registered = {name for name, _ in registry.SCENARIOS}
1501
1506
  if standin & deterministic:
1502
1507
  report(f"{label} scenarios are counted in both classes: {sorted(standin & deterministic)!r}")
@@ -22,7 +22,9 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
22
22
  from pathlib import Path
23
23
 
24
24
  from validation.common import (
25
+ BOOTSTRAP_BLOCK_BYTE_BUDGET,
25
26
  ROOT,
27
+ extract_managed_block,
26
28
  chat_environment,
27
29
  chat_json,
28
30
  chat_log,
@@ -4506,3 +4508,62 @@ def validate_stateless_continuity_scenario() -> int:
4506
4508
 
4507
4509
  report("stateless-continuity scenario passed.")
4508
4510
  return 0
4511
+
4512
+
4513
+ def validate_memory_rule_reaches_every_repo_scenario() -> int:
4514
+ """Issue #416 (owner, 2026-10-21): memory hygiene is part of the Keel protocol.
4515
+
4516
+ A consuming repository carries only the bootstrap block, so the rule goes
4517
+ there: memory holds only what the next session would get wrong without it
4518
+ and the repository cannot answer, one fact per entry, rechecked after a
4519
+ fix, at a release and at a shift change. `keel shift check` reminds the
4520
+ session before the hand-off note, as a note that never blocks readiness.
4521
+ Keel reads no memory.
4522
+ """
4523
+ label = "memory-rule-reaches-every-repo:"
4524
+ with tempfile.TemporaryDirectory(prefix="keel-memory-416-") as raw:
4525
+ base = Path(raw)
4526
+ repo = base / "fresh"
4527
+ repo.mkdir()
4528
+ installed = run_keel(repo, "--install")
4529
+ if installed.returncode != 0:
4530
+ report(f"{label} keel --install failed: {(installed.stderr or installed.stdout).strip()!r}")
4531
+ return 1
4532
+ block = extract_managed_block((repo / "AGENTS.md").read_text(encoding="utf-8")) or ""
4533
+ if not re.search(r"memory[^\n]*repository cannot answer", block, re.IGNORECASE):
4534
+ report(f"{label} the installed bootstrap does not say memory holds only what the repository cannot answer: {block!r}")
4535
+ return 1
4536
+ if not re.search(r"memory[^\n]*shift change", block, re.IGNORECASE):
4537
+ report(f"{label} the installed bootstrap does not name a memory recheck at a shift change.")
4538
+ return 1
4539
+ if len(block.encode("utf-8")) > BOOTSTRAP_BLOCK_BYTE_BUDGET:
4540
+ report(f"{label} the installed bootstrap is {len(block.encode('utf-8'))} bytes, over the {BOOTSTRAP_BLOCK_BYTE_BUDGET}-byte budget.")
4541
+ return 1
4542
+
4543
+ rtl, verify, env, _ = shift_scratch(base / "team")
4544
+ text = run_keel(verify, "shift", "check", env=env)
4545
+ if text.returncode != 0:
4546
+ report(f"{label} keel shift check exited {text.returncode} in a clean bound worktree: {text.stdout!r}")
4547
+ return 1
4548
+ if "keel shift check: ready" not in text.stdout:
4549
+ report(f"{label} a clean bound worktree is not reported ready: {text.stdout!r}")
4550
+ return 1
4551
+ if not re.search(r"^note: memory: .*hand-off note", text.stdout, re.MULTILINE):
4552
+ report(f"{label} keel shift check prints no memory note: {text.stdout!r}")
4553
+ return 1
4554
+ listed = json.loads(run_keel(verify, "shift", "check", "--json", env=env).stdout)
4555
+ if listed.get("ready") is not True or listed.get("items"):
4556
+ report(f"{label} the memory note changed readiness: {listed!r}")
4557
+ return 1
4558
+ if not any(note.startswith("memory:") for note in listed.get("notes", [])):
4559
+ report(f"{label} keel shift check --json carries no memory note: {listed.get('notes')!r}")
4560
+ return 1
4561
+ command = (ROOT / "plugins/keel/commands/shift.md").read_text(encoding="utf-8")
4562
+ if "memory" not in command.split("## 2.", 1)[0]:
4563
+ report(f"{label} /keel:shift step 1 does not tell the session to act on the memory note.")
4564
+ return 1
4565
+ if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
4566
+ report(f"{label} the scenario registry does not include it.")
4567
+ return 1
4568
+ report(f"{label.rstrip(':')} scenario passed.")
4569
+ return 0
package/src/core/shift.js CHANGED
@@ -230,6 +230,10 @@ function check(where, role) {
230
230
  } else {
231
231
  notes.push("this worktree has no chat role, so its chat was not checked");
232
232
  }
233
+ // Keel reads no memory, so it cannot tell whether there is anything to
234
+ // recheck: a reminder, never an item that holds the shift (#416 D5).
235
+ notes.push("memory: before the hand-off note, recheck what this session wrote to memory — keep only what the next session "
236
+ + "would get wrong without it and the repository cannot answer, and remove what this shift made untrue");
233
237
  return { ready: items.length === 0, worktree: where.worktree, role: role || null, items, notes };
234
238
  }
235
239