@christang/keel 5.185.0 → 5.187.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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +2 -1
- package/README.zh-CN.md +2 -1
- package/assets/bootstrap/AGENTS.md +2 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/plugins/keel/commands/shift.md +2 -0
- package/scripts/validate_plugin.py +12 -0
- package/scripts/validation/common.py +14 -3
- package/scripts/validation/evidence.py +139 -0
- package/scripts/validation/registry.py +2 -0
- package/scripts/validation/selfcheck.py +86 -0
- package/scripts/validation/shift.py +61 -0
- package/src/core/shift.js +4 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.187.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",
|
package/README.md
CHANGED
|
@@ -1028,7 +1028,8 @@ distribution copies under `plugins/keel/skills/` must stay byte-identical (enfor
|
|
|
1028
1028
|
validation).
|
|
1029
1029
|
|
|
1030
1030
|
```bash
|
|
1031
|
-
npm test # one validate_plugin.py --all run: baseline + all scenarios in parallel (--jobs N sets concurrency)
|
|
1031
|
+
npm test # one validate_plugin.py --all run: baseline + all scenarios in parallel (--jobs N sets concurrency), ending with an evidence: line
|
|
1032
|
+
node scripts/run_python.js scripts/validate_plugin.py --evidence # which scenarios are deterministic and which run against a stand-in host; --markdown for release notes
|
|
1032
1033
|
node scripts/run_python.js scripts/validate_plugin.py --scenario <name> # one scenario
|
|
1033
1034
|
node scripts/run_python.js scripts/validate_plugin.py --group <module> # one module's scenarios, e.g. --group chat
|
|
1034
1035
|
node scripts/bump_version.js <patch|minor|major> # bump every version pin at once
|
package/README.zh-CN.md
CHANGED
|
@@ -868,7 +868,8 @@ target,后续每次 `--install` / `--check` / `--doctor` / `--uninstall` 都
|
|
|
868
868
|
(由校验强制)。
|
|
869
869
|
|
|
870
870
|
```bash
|
|
871
|
-
npm test # 一次 validate_plugin.py --all:baseline + 全部场景并行(--jobs N
|
|
871
|
+
npm test # 一次 validate_plugin.py --all:baseline + 全部场景并行(--jobs N 控制并发),最后一行是 evidence: 证据分类
|
|
872
|
+
node scripts/run_python.js scripts/validate_plugin.py --evidence # 哪些场景是确定性的、哪些对着替身宿主跑;--markdown 给发布说明用
|
|
872
873
|
node scripts/run_python.js scripts/validate_plugin.py --scenario <name> # 单个场景
|
|
873
874
|
node scripts/run_python.js scripts/validate_plugin.py --group <module> # 一个模块的场景,例如 --group chat
|
|
874
875
|
node scripts/bump_version.js <patch|minor|major> # 一次改齐所有版本 pin
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
<!-- keel:start version=5.
|
|
1
|
+
<!-- keel:start version=5.187.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.
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.187.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.187.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.187.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.
|
|
3
|
+
"version": "5.187.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
|
|
@@ -48,6 +48,7 @@ from validation.baseline import (
|
|
|
48
48
|
validate_templates,
|
|
49
49
|
)
|
|
50
50
|
from validation.registry import SCENARIOS
|
|
51
|
+
from validation import evidence
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
def run_baseline() -> int:
|
|
@@ -104,6 +105,7 @@ def run_all(jobs: int) -> int:
|
|
|
104
105
|
if skipped:
|
|
105
106
|
summary += f", {len(skipped)} skipped: {', '.join(skipped)}"
|
|
106
107
|
report(f"{summary}.")
|
|
108
|
+
report(evidence.evidence_line(evidence.classify(SCENARIOS), {name for name, _ in SCENARIOS} - set(skipped)))
|
|
107
109
|
return 0
|
|
108
110
|
|
|
109
111
|
|
|
@@ -138,6 +140,7 @@ def run_group(group: str, jobs: int) -> int:
|
|
|
138
140
|
if skipped:
|
|
139
141
|
summary += f", {len(skipped)} skipped: {', '.join(skipped)}"
|
|
140
142
|
report(f"{summary}.")
|
|
143
|
+
report(evidence.evidence_line(evidence.classify(SCENARIOS), set(names) - set(skipped)))
|
|
141
144
|
return 0
|
|
142
145
|
|
|
143
146
|
|
|
@@ -170,6 +173,15 @@ def main() -> int:
|
|
|
170
173
|
return 2
|
|
171
174
|
return run_group(sys.argv[2], jobs)
|
|
172
175
|
|
|
176
|
+
if sys.argv[1:2] == ["--evidence"]:
|
|
177
|
+
rest = sys.argv[2:]
|
|
178
|
+
if rest not in ([], ["--markdown"]):
|
|
179
|
+
report(f"usage: validate_plugin.py --evidence [--markdown], got: {' '.join(rest)}")
|
|
180
|
+
return 2
|
|
181
|
+
classes = evidence.classify(SCENARIOS)
|
|
182
|
+
print(evidence.render_markdown(classes) if rest else evidence.render(classes))
|
|
183
|
+
return 0
|
|
184
|
+
|
|
173
185
|
return run_baseline()
|
|
174
186
|
|
|
175
187
|
|
|
@@ -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.
|
|
38
|
+
PACKAGE_VERSION = "5.187.0"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.
|
|
41
|
+
PROTOCOL_VERSION = "5.187.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
|
-
|
|
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
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Keel validation: what kind of evidence each scenario is (#408).
|
|
2
|
+
|
|
3
|
+
A green summary reads as more than it proves when much of the suite runs Keel
|
|
4
|
+
against a stand-in host — a fake `claude`, the host's environment, a host data
|
|
5
|
+
directory, a hook payload — and none of it against a real one. Every
|
|
6
|
+
registered scenario is classified as deterministic or stand-in host, from
|
|
7
|
+
markers derived from Keel's own sources, through the validation helpers and
|
|
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.
|
|
11
|
+
"""
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import ast
|
|
15
|
+
import re
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
from validation.common import ROOT
|
|
19
|
+
|
|
20
|
+
# A program or service Keel calls, overridable for a test: `process.env.X ||`
|
|
21
|
+
# a program name, a constant, `npmCommand(…)`, or a platform conditional.
|
|
22
|
+
# Path and identity overrides (`path.join(…)`, `os.hostname()`) are not hosts.
|
|
23
|
+
PROGRAM_OVERRIDE = re.compile(r"process\.env\.(KEEL_[A-Z_]+) \|\| (\"[^\"]+\"|[A-Z][A-Z_]+\b|npmCommand\(|\(process\.platform)")
|
|
24
|
+
HOST_VARIABLE = re.compile(r"\b((?:CLAUDE|CODEX)_[A-Z0-9_]+)\b")
|
|
25
|
+
HOST_PROGRAMS = ("claude", "codex", "npm", "gh", "launchctl", "security")
|
|
26
|
+
SHADOWED_PROGRAM = re.compile(r"/ \"(" + "|".join(HOST_PROGRAMS) + r")\"")
|
|
27
|
+
HOOK_PAYLOAD = "hook_event_name"
|
|
28
|
+
SCRIPT_PATH = re.compile(r"scripts/([a-z_]+\.py)")
|
|
29
|
+
CONTRACT = "docs/host-contract.md"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def keel_sources() -> str:
|
|
33
|
+
files = [*sorted((ROOT / "src").rglob("*.js")), ROOT / "bin" / "keel.js", *sorted((ROOT / "plugins" / "keel" / "scripts").rglob("*.js"))]
|
|
34
|
+
return "\n".join(path.read_text(encoding="utf-8") for path in files)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def markers() -> list[str]:
|
|
38
|
+
text = keel_sources()
|
|
39
|
+
found = {match.group(1) for match in PROGRAM_OVERRIDE.finditer(text)} | set(HOST_VARIABLE.findall(text))
|
|
40
|
+
return sorted(found | {HOOK_PAYLOAD})
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def definitions() -> dict[str, tuple[set[str], str]]:
|
|
44
|
+
"""Each module-level function or assignment under scripts/validation/: the names it references and its source."""
|
|
45
|
+
found: dict[str, tuple[set[str], str]] = {}
|
|
46
|
+
for module in sorted((ROOT / "scripts" / "validation").glob("*.py")):
|
|
47
|
+
source = module.read_text(encoding="utf-8")
|
|
48
|
+
for node in ast.parse(source).body:
|
|
49
|
+
if isinstance(node, ast.FunctionDef):
|
|
50
|
+
names = [node.name]
|
|
51
|
+
elif isinstance(node, ast.Assign):
|
|
52
|
+
names = [target.id for target in node.targets if isinstance(target, ast.Name)]
|
|
53
|
+
else:
|
|
54
|
+
continue
|
|
55
|
+
refs = {item.id for item in ast.walk(node) if isinstance(item, ast.Name)}
|
|
56
|
+
refs |= {item.attr for item in ast.walk(node) if isinstance(item, ast.Attribute)}
|
|
57
|
+
for name in names:
|
|
58
|
+
found[name] = (refs, ast.get_source_segment(source, node) or "")
|
|
59
|
+
return found
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def reached_text(function: str, found: dict[str, tuple[set[str], str]]) -> tuple[str, set[str]]:
|
|
63
|
+
seen: set[str] = set()
|
|
64
|
+
todo = [function]
|
|
65
|
+
while todo:
|
|
66
|
+
name = todo.pop()
|
|
67
|
+
if name in seen or name not in found:
|
|
68
|
+
continue
|
|
69
|
+
seen.add(name)
|
|
70
|
+
todo.extend(ref for ref in found[name][0] if ref in found)
|
|
71
|
+
text = "\n".join(found[name][1] for name in sorted(seen))
|
|
72
|
+
for script in sorted(set(SCRIPT_PATH.findall(text))):
|
|
73
|
+
path = ROOT / "scripts" / script
|
|
74
|
+
if path.is_file() and script != "validate_plugin.py":
|
|
75
|
+
text += "\n" + path.read_text(encoding="utf-8")
|
|
76
|
+
return text, seen
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def classify(scenarios) -> dict:
|
|
80
|
+
"""{"markers", "stand-in host", "deterministic", "can skip"} for the registered scenarios, in registry order."""
|
|
81
|
+
marks = markers()
|
|
82
|
+
found = definitions()
|
|
83
|
+
standin, deterministic, skippable = [], [], []
|
|
84
|
+
for name, function in scenarios:
|
|
85
|
+
defined = getattr(function, "__name__", None)
|
|
86
|
+
text, seen = reached_text(defined, found) if defined in found else ("", set())
|
|
87
|
+
# 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):
|
|
89
|
+
standin.append(name)
|
|
90
|
+
else:
|
|
91
|
+
deterministic.append(name)
|
|
92
|
+
if "skip_scenario" in seen:
|
|
93
|
+
skippable.append(name)
|
|
94
|
+
return {"markers": marks, "stand-in host": standin, "deterministic": deterministic, "can skip": skippable}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def evidence_line(classes: dict, ran: set[str]) -> str:
|
|
98
|
+
"""The line after a passing run: the classes of the scenarios that ran."""
|
|
99
|
+
deterministic = sum(1 for name in classes["deterministic"] if name in ran)
|
|
100
|
+
standin = sum(1 for name in classes["stand-in host"] if name in ran)
|
|
101
|
+
return (f"evidence: {deterministic} deterministic, {standin} against a stand-in host, "
|
|
102
|
+
f"none on a real host (host measurements: {CONTRACT})")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def measured_rows() -> int:
|
|
106
|
+
"""Rows of the host contract whose evidence cell records a real-host measurement."""
|
|
107
|
+
text = (ROOT / CONTRACT).read_text(encoding="utf-8")
|
|
108
|
+
return sum(1 for line in text.splitlines()
|
|
109
|
+
if line.startswith("|") and "measured" in line.rstrip().rstrip("|").rsplit("|", 1)[-1])
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def render(classes: dict) -> str:
|
|
113
|
+
return "\n".join([
|
|
114
|
+
f"evidence: {len(classes['deterministic'])} deterministic, {len(classes['stand-in host'])} against a stand-in host, "
|
|
115
|
+
f"none on a real host (host measurements: {CONTRACT})",
|
|
116
|
+
f"stand-in markers: {', '.join(classes['markers'])}",
|
|
117
|
+
f"stand-in host: {', '.join(classes['stand-in host'])}",
|
|
118
|
+
f"deterministic: {', '.join(classes['deterministic'])}",
|
|
119
|
+
f"can skip: {', '.join(classes['can skip'])}",
|
|
120
|
+
])
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def render_markdown(classes: dict) -> str:
|
|
124
|
+
skips = ", ".join(f"`{name}`" for name in classes["can skip"]) or "none"
|
|
125
|
+
return "\n".join([
|
|
126
|
+
"",
|
|
127
|
+
"## Evidence",
|
|
128
|
+
"",
|
|
129
|
+
"What the full gate ran for this release, by kind (`validate_plugin.py --evidence`):",
|
|
130
|
+
"",
|
|
131
|
+
f"- **Deterministic:** {len(classes['deterministic'])} scenarios run Keel's own code against real git, Node and files.",
|
|
132
|
+
f"- **Stand-in host:** {len(classes['stand-in host'])} scenarios run Keel against a stand-in for a host program, "
|
|
133
|
+
"the host's environment, a host data directory or a hook payload. They show what Keel does with the shapes they "
|
|
134
|
+
"model, not that a host still produces them.",
|
|
135
|
+
f"- **Real host:** none. CI has no Claude Code or Codex. `{CONTRACT}` records {measured_rows()} conditions "
|
|
136
|
+
"measured on a real host, each with its version and date.",
|
|
137
|
+
f"- **Can skip:** {skips} skip when the runtime they need is missing; the full gate's log names any that did.",
|
|
138
|
+
"",
|
|
139
|
+
])
|
|
@@ -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),
|
|
@@ -478,6 +479,7 @@ SCENARIOS: tuple = (
|
|
|
478
479
|
("repo-action-mode", guard.validate_repo_action_mode_scenario),
|
|
479
480
|
("runner-skip-accounting", selfcheck.validate_runner_skip_accounting_scenario),
|
|
480
481
|
("runner-runs-one-group", selfcheck.validate_runner_runs_one_group_scenario),
|
|
482
|
+
("release-evidence-classes", selfcheck.validate_release_evidence_classes_scenario),
|
|
481
483
|
("self-checks-read-every-module", selfcheck.validate_self_checks_read_every_module_scenario),
|
|
482
484
|
("resident-topic-matching", selfcheck.validate_resident_topic_matching_scenario),
|
|
483
485
|
("task-start-invalidation", contract.validate_task_start_invalidation_scenario),
|
|
@@ -1464,3 +1464,89 @@ def validate_the_routing_rule_reaches_the_decision_scenario() -> int:
|
|
|
1464
1464
|
return 1
|
|
1465
1465
|
report(f"{label} scenario passed.")
|
|
1466
1466
|
return 0
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
def validate_release_evidence_classes_scenario() -> int:
|
|
1470
|
+
"""Issue #408 (owner, 2026-10-21): the suite and each release say what kind of evidence ran.
|
|
1471
|
+
|
|
1472
|
+
A green summary read as more than it proved: much of the suite runs Keel
|
|
1473
|
+
against a stand-in host — a fake `claude`, the host's environment, a host
|
|
1474
|
+
data directory, a hook payload — and none of it against a real one. Each
|
|
1475
|
+
scenario is classified from markers derived from Keel's own sources,
|
|
1476
|
+
through the helpers and scripts it reaches; a passing run and each
|
|
1477
|
+
release's notes give the counts.
|
|
1478
|
+
"""
|
|
1479
|
+
label = "release-evidence-classes:"
|
|
1480
|
+
plain = subprocess.run([sys.executable, str(ROOT / "scripts/validate_plugin.py"), "--evidence"],
|
|
1481
|
+
cwd=ROOT, text=True, capture_output=True)
|
|
1482
|
+
if plain.returncode != 0:
|
|
1483
|
+
report(f"{label} `--evidence` exited {plain.returncode}: {(plain.stderr or plain.stdout).strip()!r}")
|
|
1484
|
+
return 1
|
|
1485
|
+
lines = {line.split(":", 1)[0]: line.split(":", 1)[1].strip() for line in plain.stdout.splitlines() if ":" in line}
|
|
1486
|
+
standin = set(filter(None, (name.strip() for name in lines.get("stand-in host", "").split(","))))
|
|
1487
|
+
deterministic = set(filter(None, (name.strip() for name in lines.get("deterministic", "").split(","))))
|
|
1488
|
+
markers = set(filter(None, (name.strip() for name in lines.get("stand-in markers", "").split(","))))
|
|
1489
|
+
for name in ("KEEL_CLAUDE", "CLAUDE_CODE_SESSION_ID"):
|
|
1490
|
+
if name not in markers:
|
|
1491
|
+
report(f"{label} the markers derived from Keel's sources do not include {name}: {sorted(markers)!r}")
|
|
1492
|
+
return 1
|
|
1493
|
+
for name in ("shift-cli-self-shift", "chat-claude-hooks", "codex-receiving", "update-pack-install"):
|
|
1494
|
+
if name not in standin:
|
|
1495
|
+
report(f"{label} {name} is not counted as run against a stand-in host.")
|
|
1496
|
+
return 1
|
|
1497
|
+
if "version-alignment" not in deterministic:
|
|
1498
|
+
report(f"{label} version-alignment is not counted as deterministic.")
|
|
1499
|
+
return 1
|
|
1500
|
+
registered = {name for name, _ in registry.SCENARIOS}
|
|
1501
|
+
if standin & deterministic:
|
|
1502
|
+
report(f"{label} scenarios are counted in both classes: {sorted(standin & deterministic)!r}")
|
|
1503
|
+
return 1
|
|
1504
|
+
if standin | deterministic != registered:
|
|
1505
|
+
report(f"{label} the two classes do not cover the registry: missing {sorted(registered - standin - deterministic)!r}, "
|
|
1506
|
+
f"unknown {sorted((standin | deterministic) - registered)!r}")
|
|
1507
|
+
return 1
|
|
1508
|
+
|
|
1509
|
+
contract = (ROOT / "docs/host-contract.md").read_text(encoding="utf-8")
|
|
1510
|
+
measured = sum(1 for line in contract.splitlines()
|
|
1511
|
+
if line.startswith("|") and "measured" in line.rstrip().rstrip("|").rsplit("|", 1)[-1])
|
|
1512
|
+
skippable = set(filter(None, (name.strip() for name in lines.get("can skip", "").split(","))))
|
|
1513
|
+
if "output-survives-the-pipe" not in skippable:
|
|
1514
|
+
report(f"{label} `--evidence` does not name output-survives-the-pipe among the scenarios that can skip: {sorted(skippable)!r}")
|
|
1515
|
+
return 1
|
|
1516
|
+
markdown = subprocess.run([sys.executable, str(ROOT / "scripts/validate_plugin.py"), "--evidence", "--markdown"],
|
|
1517
|
+
cwd=ROOT, text=True, capture_output=True)
|
|
1518
|
+
section = markdown.stdout
|
|
1519
|
+
for needle in ("## Evidence", f"{len(deterministic)} scenarios", f"{len(standin)} scenarios",
|
|
1520
|
+
f"{measured} conditions", "docs/host-contract.md", *sorted(skippable)):
|
|
1521
|
+
if needle not in section:
|
|
1522
|
+
report(f"{label} the release notes section does not carry {needle!r}: {section!r}")
|
|
1523
|
+
return 1
|
|
1524
|
+
|
|
1525
|
+
workflow = (ROOT / ".github/workflows/publish.yml").read_text(encoding="utf-8")
|
|
1526
|
+
start = workflow.find("- name: Tag and release the landed version")
|
|
1527
|
+
following = workflow.find("\n - name:", start + 1)
|
|
1528
|
+
step = workflow[start:] if following < 0 else workflow[start:following]
|
|
1529
|
+
if "validate_plugin.py --evidence --markdown >> notes.md" not in step:
|
|
1530
|
+
report(f"{label} the publish release step does not append `validate_plugin.py --evidence --markdown` to notes.md.")
|
|
1531
|
+
return 1
|
|
1532
|
+
|
|
1533
|
+
grouped = subprocess.run([sys.executable, str(ROOT / "scripts/validate_plugin.py"), "--group", "docs"],
|
|
1534
|
+
cwd=ROOT, text=True, capture_output=True)
|
|
1535
|
+
tail = grouped.stdout.strip().splitlines()[-2:]
|
|
1536
|
+
verified = re.search(r"validation --group docs passed: (\d+) scenario", tail[0]) if tail else None
|
|
1537
|
+
counts = re.match(r"evidence: (\d+) deterministic, (\d+) against a stand-in host, none on a real host .*docs/host-contract\.md",
|
|
1538
|
+
tail[-1]) if tail else None
|
|
1539
|
+
if grouped.returncode != 0 or not verified:
|
|
1540
|
+
report(f"{label} `--group docs` did not pass: {grouped.stdout[-400:]!r}")
|
|
1541
|
+
return 1
|
|
1542
|
+
if not counts:
|
|
1543
|
+
report(f"{label} a passing `--group docs` does not end with an evidence line: {tail!r}")
|
|
1544
|
+
return 1
|
|
1545
|
+
if int(counts.group(1)) + int(counts.group(2)) != int(verified.group(1)):
|
|
1546
|
+
report(f"{label} the evidence line's counts do not add up to the {verified.group(1)} verified: {tail[-1]!r}")
|
|
1547
|
+
return 1
|
|
1548
|
+
if label.rstrip(":") not in registered:
|
|
1549
|
+
report(f"{label} the scenario registry does not include it.")
|
|
1550
|
+
return 1
|
|
1551
|
+
report(f"{label.rstrip(':')} scenario passed: {len(deterministic)} deterministic, {len(standin)} stand-in host.")
|
|
1552
|
+
return 0
|
|
@@ -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
|
|