@christang/keel 5.185.0 → 5.186.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.185.0",
3
+ "version": "5.186.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,4 +1,4 @@
1
- <!-- keel:start version=5.185.0 -->
1
+ <!-- keel:start version=5.186.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.185.0",
3
+ "version": "5.186.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.185.0",
9
+ "version": "5.186.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.185.0",
5
+ "version": "5.186.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.185.0",
3
+ "version": "5.186.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.185.0",
3
+ "version": "5.186.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",
@@ -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.185.0"
38
+ PACKAGE_VERSION = "5.186.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.185.0"
41
+ PROTOCOL_VERSION = "5.186.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -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
+ ])
@@ -478,6 +478,7 @@ SCENARIOS: tuple = (
478
478
  ("repo-action-mode", guard.validate_repo_action_mode_scenario),
479
479
  ("runner-skip-accounting", selfcheck.validate_runner_skip_accounting_scenario),
480
480
  ("runner-runs-one-group", selfcheck.validate_runner_runs_one_group_scenario),
481
+ ("release-evidence-classes", selfcheck.validate_release_evidence_classes_scenario),
481
482
  ("self-checks-read-every-module", selfcheck.validate_self_checks_read_every_module_scenario),
482
483
  ("resident-topic-matching", selfcheck.validate_resident_topic_matching_scenario),
483
484
  ("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