@christang/keel 5.183.0 → 5.184.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 +6 -0
- package/README.zh-CN.md +5 -0
- package/assets/bootstrap/AGENTS.md +1 -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/scripts/bump_version.js +1 -1
- package/scripts/validate_plugin.py +69 -42863
- package/scripts/validation/__init__.py +1 -0
- package/scripts/validation/baseline.py +509 -0
- package/scripts/validation/chat.py +4441 -0
- package/scripts/validation/common.py +1529 -0
- package/scripts/validation/contract.py +13824 -0
- package/scripts/validation/docs.py +1815 -0
- package/scripts/validation/guard.py +5594 -0
- package/scripts/validation/hosts.py +5688 -0
- package/scripts/validation/install.py +3802 -0
- package/scripts/validation/registry.py +637 -0
- package/scripts/validation/selfcheck.py +1466 -0
- package/scripts/validation/shift.py +4316 -0
|
@@ -0,0 +1,1815 @@
|
|
|
1
|
+
"""Keel validation: docs (split from validate_plugin.py, #409)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import contextlib
|
|
5
|
+
import json
|
|
6
|
+
import gzip
|
|
7
|
+
import hashlib
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
import shutil
|
|
11
|
+
import subprocess
|
|
12
|
+
import sys
|
|
13
|
+
import tarfile
|
|
14
|
+
import tempfile
|
|
15
|
+
import threading
|
|
16
|
+
import time
|
|
17
|
+
import ast
|
|
18
|
+
import atexit
|
|
19
|
+
import signal
|
|
20
|
+
from datetime import datetime, timedelta, timezone
|
|
21
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
24
|
+
from validation.common import (
|
|
25
|
+
OPENSPEC_SEARCH_ORDER,
|
|
26
|
+
OPENSPEC_SURFACE_OVERLAY_END,
|
|
27
|
+
OPENSPEC_SURFACE_OVERLAY_START,
|
|
28
|
+
PLUGIN_ROOT,
|
|
29
|
+
ROOT,
|
|
30
|
+
config_header_paragraph,
|
|
31
|
+
config_header_problem,
|
|
32
|
+
extract_managed_block,
|
|
33
|
+
report,
|
|
34
|
+
run_keel,
|
|
35
|
+
run_node_expression,
|
|
36
|
+
run_openspec,
|
|
37
|
+
task_capsule_compact_fixture,
|
|
38
|
+
write_text,
|
|
39
|
+
)
|
|
40
|
+
from validation import registry
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def validate_decisions_are_selectable_scenario() -> int:
|
|
44
|
+
"""Issue #174: an enumerable decision is offered as selectable options.
|
|
45
|
+
|
|
46
|
+
The owner asked (2026-09-28) that a decision be something the user can
|
|
47
|
+
pick, not type, wherever the host offers a structured choice. No gate can
|
|
48
|
+
observe presentation, so this checks only that both carriers say so — the
|
|
49
|
+
resident protocol and the alignment skill's deep path, in source and in
|
|
50
|
+
the shipped copy — and that the portable skill names no host tool.
|
|
51
|
+
"""
|
|
52
|
+
label = "decisions-are-selectable:"
|
|
53
|
+
|
|
54
|
+
def section(text: str, heading: str) -> str:
|
|
55
|
+
start = text.find(heading)
|
|
56
|
+
if start < 0:
|
|
57
|
+
return ""
|
|
58
|
+
rest = text[start + len(heading):]
|
|
59
|
+
end = rest.find("\n## ")
|
|
60
|
+
return rest if end < 0 else rest[:end]
|
|
61
|
+
|
|
62
|
+
def offers_choices(text: str) -> bool:
|
|
63
|
+
lowered = " ".join(text.lower().split())
|
|
64
|
+
return (
|
|
65
|
+
"structured-choice surface" in lowered
|
|
66
|
+
and "recommend" in lowered
|
|
67
|
+
and "first" in lowered
|
|
68
|
+
and "open question" in lowered
|
|
69
|
+
and "prose" in lowered
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
block = extract_managed_block((ROOT / "AGENTS.md").read_text(encoding="utf-8")) or ""
|
|
73
|
+
if not offers_choices(section(block, "## User-facing communication")):
|
|
74
|
+
report(
|
|
75
|
+
f"{label} AGENTS.md User-facing communication does not offer "
|
|
76
|
+
"decisions as selectable options."
|
|
77
|
+
)
|
|
78
|
+
return 1
|
|
79
|
+
for root in ("src/skills", f"{PLUGIN_ROOT}/skills"):
|
|
80
|
+
path = ROOT / root / "keel-align-expectations" / "SKILL.md"
|
|
81
|
+
text = path.read_text(encoding="utf-8")
|
|
82
|
+
if not offers_choices(section(text, "## Deep path")):
|
|
83
|
+
report(
|
|
84
|
+
f"{label} {root} keel-align-expectations Deep path does not "
|
|
85
|
+
"offer decisions as selectable options."
|
|
86
|
+
)
|
|
87
|
+
return 1
|
|
88
|
+
if "AskUserQuestion" in text:
|
|
89
|
+
report(f"{label} {root} keel-align-expectations names a host tool.")
|
|
90
|
+
return 1
|
|
91
|
+
if "decisions-are-selectable" not in {name for name, _ in registry.SCENARIOS}:
|
|
92
|
+
report(f"{label} scenario is not registered.")
|
|
93
|
+
return 1
|
|
94
|
+
report("decisions-are-selectable scenario passed.")
|
|
95
|
+
return 0
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def validate_chat_role_apps_are_documented_scenario() -> int:
|
|
99
|
+
"""Issue #187: the setup guides and READMEs describe shared bots.
|
|
100
|
+
|
|
101
|
+
Both guides carry the bot section — `keel chat bot add`, the Keychain
|
|
102
|
+
accounts named by bot, the `slack.bots` mapping, that one bot serves a role
|
|
103
|
+
in each of several projects, and that such a bot takes no direct messages
|
|
104
|
+
— and neither still ties a token to a role or equates the app limit with a
|
|
105
|
+
machine count.
|
|
106
|
+
"""
|
|
107
|
+
label = "chat-role-apps-are-documented:"
|
|
108
|
+
guides = {
|
|
109
|
+
"docs/chat-slack-setup.md": ("serve a role in each of several projects", "takes no direct messages"),
|
|
110
|
+
"docs/chat-slack-setup.zh-CN.md": ("在多个项目里各当一个角色", "不接私聊"),
|
|
111
|
+
}
|
|
112
|
+
for relative, phrases in guides.items():
|
|
113
|
+
text = (ROOT / relative).read_text(encoding="utf-8")
|
|
114
|
+
for needle in ('"bots"', "keel chat bot add", "bot:<name>", "app:<name>", "chat:write.public", "im:history", *phrases):
|
|
115
|
+
if needle not in text:
|
|
116
|
+
report(f"{label} {relative} does not carry {needle!r}.")
|
|
117
|
+
return 1
|
|
118
|
+
for stale in ("bot:<role>", "which means 10 machines", "也就是最多 10 台电脑"):
|
|
119
|
+
if stale in text:
|
|
120
|
+
report(f"{label} {relative} still says {stale!r}.")
|
|
121
|
+
return 1
|
|
122
|
+
readmes = {"README.md": "one bot can serve several projects", "README.zh-CN.md": "一个 bot 可以服务多个项目"}
|
|
123
|
+
for relative, needle in readmes.items():
|
|
124
|
+
if needle not in (ROOT / relative).read_text(encoding="utf-8"):
|
|
125
|
+
report(f"{label} {relative} does not say {needle!r}.")
|
|
126
|
+
return 1
|
|
127
|
+
if "chat-role-apps-are-documented" not in {name for name, _ in registry.SCENARIOS}:
|
|
128
|
+
report(f"{label} scenario is not registered.")
|
|
129
|
+
return 1
|
|
130
|
+
report("chat-role-apps-are-documented scenario passed.")
|
|
131
|
+
return 0
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def validate_guidance_names_openspec_skills_scenario() -> int:
|
|
135
|
+
"""Issue #406: guidance names no `/opsx:` command, since Keel generates none.
|
|
136
|
+
|
|
137
|
+
With the workflows delivered as skills only, a sentence telling the reader
|
|
138
|
+
to run `/opsx:sync` points at a command that does not exist.
|
|
139
|
+
"""
|
|
140
|
+
label = "guidance-names-openspec-skills:"
|
|
141
|
+
shipped = [ROOT / "README.md", ROOT / "README.zh-CN.md",
|
|
142
|
+
ROOT / "assets/openspec/schemas/keel-spec-driven/schema.yaml",
|
|
143
|
+
*sorted((ROOT / "src/skills").rglob("SKILL.md")),
|
|
144
|
+
*sorted((ROOT / "plugins/keel/skills").rglob("SKILL.md"))]
|
|
145
|
+
naming = [str(p.relative_to(ROOT)) for p in shipped if "/opsx:" in p.read_text(encoding="utf-8")]
|
|
146
|
+
if naming:
|
|
147
|
+
report(f"{label} shipped guidance still names `/opsx:` commands: {naming!r}")
|
|
148
|
+
return 1
|
|
149
|
+
block = extract_managed_block((ROOT / "AGENTS.md").read_text(encoding="utf-8")) or ""
|
|
150
|
+
if not block:
|
|
151
|
+
report(f"{label} AGENTS.md has no managed protocol block to read.")
|
|
152
|
+
return 1
|
|
153
|
+
for needle in ("/opsx:", "commands/opsx"):
|
|
154
|
+
if needle in block:
|
|
155
|
+
report(f"{label} the AGENTS.md protocol block still names {needle!r}.")
|
|
156
|
+
return 1
|
|
157
|
+
|
|
158
|
+
with tempfile.TemporaryDirectory(prefix="keel-406-guidance-") as raw_tmp:
|
|
159
|
+
repo = Path(raw_tmp)
|
|
160
|
+
init = run_keel(repo, "--init", "--target", "claude")
|
|
161
|
+
if init.returncode != 0:
|
|
162
|
+
report(f"{label} keel --init --target claude failed: {(init.stderr or init.stdout).strip()}")
|
|
163
|
+
return 1
|
|
164
|
+
archive = (repo / ".claude/skills/openspec-archive-change/SKILL.md").read_text(encoding="utf-8")
|
|
165
|
+
overlay = archive[archive.find(OPENSPEC_SURFACE_OVERLAY_START):archive.find(OPENSPEC_SURFACE_OVERLAY_END)]
|
|
166
|
+
if not overlay:
|
|
167
|
+
report(f"{label} the archive skill carries no Keel overlay to read.")
|
|
168
|
+
return 1
|
|
169
|
+
if "/opsx:" in overlay:
|
|
170
|
+
report(f"{label} the archive overlay still names an `/opsx:` command.")
|
|
171
|
+
return 1
|
|
172
|
+
if "openspec-sync-specs" not in overlay:
|
|
173
|
+
report(f"{label} the archive overlay does not name `openspec-sync-specs`.")
|
|
174
|
+
return 1
|
|
175
|
+
|
|
176
|
+
if "guidance-names-openspec-skills" not in {name for name, _ in registry.SCENARIOS}:
|
|
177
|
+
report(f"{label} scenario is not registered.")
|
|
178
|
+
return 1
|
|
179
|
+
report("guidance-names-openspec-skills scenario passed.")
|
|
180
|
+
return 0
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def validate_the_spec_names_the_managed_set_scenario() -> int:
|
|
184
|
+
"""Issue #86: the spec's summary named two of the four actions it covers.
|
|
185
|
+
|
|
186
|
+
`propose` and `sync` joined the managed set as new requirements appended to
|
|
187
|
+
the overlay spec, and the `## Purpose` and the requirement that says which
|
|
188
|
+
actions carry an overlay were never rewritten — so the top of the file
|
|
189
|
+
disagreed with the requirements below it.
|
|
190
|
+
|
|
191
|
+
The Purpose line survived issue #79's sweep for a structural reason:
|
|
192
|
+
OpenSpec's delta operations are Requirement-scoped, so no change can carry
|
|
193
|
+
a Purpose edit, and the line is written once when the capability is
|
|
194
|
+
created. It is therefore the location most likely to drift and the one
|
|
195
|
+
least likely to be noticed, which is why it is checked by name here.
|
|
196
|
+
|
|
197
|
+
Two named locations, not a scan. Statements in the published specs name a
|
|
198
|
+
proper subset of the managed set and are correct — the doctor's
|
|
199
|
+
command-surface label, which excludes the authoring action on purpose, and
|
|
200
|
+
`authoring/apply/archive/sync`, which spells `propose` as authoring. A
|
|
201
|
+
check that refused those would cost more than the drift it catches.
|
|
202
|
+
"""
|
|
203
|
+
label = "the-spec-names-the-managed-set"
|
|
204
|
+
|
|
205
|
+
source = (ROOT / "bin" / "keel.js").read_text(encoding="utf-8")
|
|
206
|
+
declaration = re.search(
|
|
207
|
+
r"const OPENSPEC_OVERLAY_ACTIONS = \[([^\]]*)\];", source
|
|
208
|
+
)
|
|
209
|
+
if declaration is None:
|
|
210
|
+
report(
|
|
211
|
+
f"{label}: bin/keel.js declares no OPENSPEC_OVERLAY_ACTIONS, so the "
|
|
212
|
+
"check has no managed set to compare against. Restating the set "
|
|
213
|
+
"here would be the same defect one layer out."
|
|
214
|
+
)
|
|
215
|
+
return 1
|
|
216
|
+
managed = re.findall(r'"([a-z]+)"', declaration.group(1))
|
|
217
|
+
if not managed:
|
|
218
|
+
report(f"{label}: OPENSPEC_OVERLAY_ACTIONS parsed to an empty set.")
|
|
219
|
+
return 1
|
|
220
|
+
|
|
221
|
+
spec_path = ROOT / "openspec/specs/keel-openspec-surface-overlay/spec.md"
|
|
222
|
+
REQUIREMENT = "### Requirement: Keel overlays every action in the managed set"
|
|
223
|
+
|
|
224
|
+
def locations(text: str) -> tuple[str, str] | None:
|
|
225
|
+
purpose = re.search(r"^## Purpose\s*\n+(.+?)\n", text, re.M)
|
|
226
|
+
if purpose is None:
|
|
227
|
+
return None
|
|
228
|
+
start = text.find(REQUIREMENT)
|
|
229
|
+
if start < 0:
|
|
230
|
+
return None
|
|
231
|
+
end = text.find("\n### Requirement:", start + len(REQUIREMENT))
|
|
232
|
+
body = text[start : end if end > 0 else len(text)]
|
|
233
|
+
return purpose.group(1), body
|
|
234
|
+
|
|
235
|
+
# Two distinct failures, kept apart on purpose: a location the check
|
|
236
|
+
# cannot find is not a location that names the wrong thing, and reporting
|
|
237
|
+
# the second when the first happened sends the reader to a paragraph with
|
|
238
|
+
# nothing wrong in it.
|
|
239
|
+
NOT_FOUND = "__not-found__"
|
|
240
|
+
|
|
241
|
+
def missing(text: str) -> list[tuple[str, list[str]]]:
|
|
242
|
+
found = locations(text)
|
|
243
|
+
if found is None:
|
|
244
|
+
return [(NOT_FOUND, list(managed))]
|
|
245
|
+
purpose, body = found
|
|
246
|
+
gaps = []
|
|
247
|
+
for name, region in (("## Purpose", purpose), (REQUIREMENT, body)):
|
|
248
|
+
absent = [
|
|
249
|
+
action for action in managed
|
|
250
|
+
if not re.search(rf"\b{action}\b", region)
|
|
251
|
+
]
|
|
252
|
+
if absent:
|
|
253
|
+
gaps.append((name, absent))
|
|
254
|
+
return gaps
|
|
255
|
+
|
|
256
|
+
published = spec_path.read_text(encoding="utf-8")
|
|
257
|
+
gaps = missing(published)
|
|
258
|
+
if gaps:
|
|
259
|
+
for name, absent in gaps:
|
|
260
|
+
if name == NOT_FOUND:
|
|
261
|
+
report(
|
|
262
|
+
f"{label}: keel-openspec-surface-overlay has no `## Purpose` "
|
|
263
|
+
f"line or no `{REQUIREMENT}` heading, so this check found "
|
|
264
|
+
"nothing to compare against the managed set. Nothing about "
|
|
265
|
+
"the action names is being reported here — the location is "
|
|
266
|
+
"what is missing."
|
|
267
|
+
)
|
|
268
|
+
continue
|
|
269
|
+
report(
|
|
270
|
+
f"{label}: the `{name}` of keel-openspec-surface-overlay does "
|
|
271
|
+
f"not name {', '.join(absent)}, which bin/keel.js manages an "
|
|
272
|
+
"overlay for. The file's summary and the requirements under it "
|
|
273
|
+
"disagree, and a reader takes the summary."
|
|
274
|
+
)
|
|
275
|
+
return 1
|
|
276
|
+
|
|
277
|
+
# The check fails on a drifted copy, and names the location that drifted.
|
|
278
|
+
drifted = published.replace(
|
|
279
|
+
REQUIREMENT, "### Requirement: Keel overlays apply and archive surfaces", 1
|
|
280
|
+
)
|
|
281
|
+
if missing(drifted) == []:
|
|
282
|
+
report(
|
|
283
|
+
f"{label}: a copy whose requirement heading is gone was reported "
|
|
284
|
+
"clean. A check that cannot find what it looks for must fail, not "
|
|
285
|
+
"pass — a vacuous pass is how the drift got here."
|
|
286
|
+
)
|
|
287
|
+
return 1
|
|
288
|
+
|
|
289
|
+
for action in managed:
|
|
290
|
+
reduced = published
|
|
291
|
+
found = locations(published)
|
|
292
|
+
assert found is not None
|
|
293
|
+
purpose_line = found[0]
|
|
294
|
+
reduced = reduced.replace(
|
|
295
|
+
purpose_line, re.sub(rf"\b{action}\b[,/ ]*", "", purpose_line), 1
|
|
296
|
+
)
|
|
297
|
+
gaps = missing(reduced)
|
|
298
|
+
if not any(name == "## Purpose" and action in absent for name, absent in gaps):
|
|
299
|
+
report(
|
|
300
|
+
f"{label}: the Purpose line with `{action}` removed was not "
|
|
301
|
+
"reported. Each managed action is checked on its own, so an "
|
|
302
|
+
"action that joins the set later is not covered by the others."
|
|
303
|
+
)
|
|
304
|
+
return 1
|
|
305
|
+
|
|
306
|
+
# The three subset spellings that are correct stay correct: the check is
|
|
307
|
+
# two named locations in one file, not a scan for action words.
|
|
308
|
+
diagnostics = (
|
|
309
|
+
ROOT / "openspec/specs/keel-target-surface-diagnostics/spec.md"
|
|
310
|
+
).read_text(encoding="utf-8")
|
|
311
|
+
for correct in (
|
|
312
|
+
"apply/archive/sync overlay markers",
|
|
313
|
+
"it names sync alongside apply and archive",
|
|
314
|
+
):
|
|
315
|
+
if correct not in diagnostics:
|
|
316
|
+
report(
|
|
317
|
+
f"{label}: the diagnostics spec no longer carries the correct "
|
|
318
|
+
f"subset spelling `{correct}`. This scenario asserts the check "
|
|
319
|
+
"leaves it alone; if the wording moved, the assertion has to "
|
|
320
|
+
"move with it rather than be dropped."
|
|
321
|
+
)
|
|
322
|
+
return 1
|
|
323
|
+
# `sync/archive decisions` left the overlay spec with the ownership
|
|
324
|
+
# requirements (#414); `authoring/apply/archive/sync` is the correct subset
|
|
325
|
+
# spelling that remains in it.
|
|
326
|
+
if "authoring/apply/archive/sync" not in published:
|
|
327
|
+
report(
|
|
328
|
+
f"{label}: the overlay spec no longer carries "
|
|
329
|
+
"`authoring/apply/archive/sync`, the correct subset spelling this "
|
|
330
|
+
"check must not refuse."
|
|
331
|
+
)
|
|
332
|
+
return 1
|
|
333
|
+
|
|
334
|
+
if label not in {name for name, _ in registry.SCENARIOS}:
|
|
335
|
+
report(f"{label}: the scenario registry does not include it.")
|
|
336
|
+
return 1
|
|
337
|
+
report(f"{label} scenario passed.")
|
|
338
|
+
return 0
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
SPEC_TEMPLATE_RELATIVE = "schemas/keel-spec-driven/templates/spec.md"
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
SLOT_FILLER = "the recorded feed status"
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
# The filler must be a strategy the generic task can use as written.
|
|
348
|
+
# `evidence-first` no longer is: it carries a `Reason:` the generic task
|
|
349
|
+
# has no slot for, and giving it one would put a line there that is wrong
|
|
350
|
+
# for every other strategy the slot can take.
|
|
351
|
+
SLOT_VOCABULARY = {"<strategy>": "vertical-tdd"}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def fill_template_slots(text: str) -> str:
|
|
355
|
+
"""Fill a shipped template's author-facing slots the way an author would.
|
|
356
|
+
|
|
357
|
+
Deliberately mechanical, so a slot added to the template later is handled
|
|
358
|
+
without touching the scenario: what is asserted is the template's structure
|
|
359
|
+
rather than a hand-maintained copy of it.
|
|
360
|
+
|
|
361
|
+
One rule for both templates. An own-line comment is an instruction to the
|
|
362
|
+
author and goes; a comment with text before it on the line is that line's
|
|
363
|
+
slot — a requirement name, a task title — and is filled, because stripping
|
|
364
|
+
it would leave a heading the parser cannot read.
|
|
365
|
+
|
|
366
|
+
The spec template used to take a mode that replaced every comment, and it
|
|
367
|
+
stopped being correct the moment that template gained an own-line
|
|
368
|
+
instruction (`ed1388d`, the change that fixed issue #28). The instruction
|
|
369
|
+
became a bare paragraph of slot text above `The system SHALL …`, and
|
|
370
|
+
`openspec validate` reported the requirement as lacking a modal verb —
|
|
371
|
+
the fixture failing the template rather than the template failing.
|
|
372
|
+
"""
|
|
373
|
+
text = re.sub(r"^[ \t]*<!--[\s\S]*?-->[ \t]*\r?\n", "", text, flags=re.M)
|
|
374
|
+
text = re.sub(r"<!--[\s\S]*?-->", SLOT_FILLER, text)
|
|
375
|
+
# A slot whose value comes from a fixed vocabulary needs a member of it, so
|
|
376
|
+
# those are named. Everything else takes the generic filler.
|
|
377
|
+
for slot, value in SLOT_VOCABULARY.items():
|
|
378
|
+
text = text.replace(slot, value)
|
|
379
|
+
# Innermost-first to a fixed point: a slot may quote an identifier shape such
|
|
380
|
+
# as `Q<n>`, and the inner brackets would otherwise block the outer match and
|
|
381
|
+
# leave the whole slot unfilled.
|
|
382
|
+
while True:
|
|
383
|
+
collapsed = re.sub(r"<[^<>\n]*>", SLOT_FILLER, text)
|
|
384
|
+
if collapsed == text:
|
|
385
|
+
return text
|
|
386
|
+
text = collapsed
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
TASKS_TEMPLATE_RELATIVE = "schemas/keel-spec-driven/templates/tasks.md"
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def validate_tasks_template_red_green_example_scenario() -> int:
|
|
393
|
+
"""Issue #28 items 2 and 3: the red-green shape was described, never shown.
|
|
394
|
+
|
|
395
|
+
The template's prose has said since 5.3.4 that the `.red`/`.green` entries
|
|
396
|
+
come in addition to the bare `M<n>` entry, but it showed only the flat form.
|
|
397
|
+
The reporter tried annotated labels, was refused, landed on the flat form,
|
|
398
|
+
and was refused again for the missing bare entry. One worked example closes
|
|
399
|
+
both attempts — and it is asserted by gating it, so it cannot drift from the
|
|
400
|
+
rule it illustrates.
|
|
401
|
+
"""
|
|
402
|
+
shipped = ROOT / "openspec" / TASKS_TEMPLATE_RELATIVE
|
|
403
|
+
packaged = ROOT / "assets" / "openspec" / TASKS_TEMPLATE_RELATIVE
|
|
404
|
+
for path in (shipped, packaged):
|
|
405
|
+
if not path.is_file():
|
|
406
|
+
report(f"tasks-template-red-green-example: missing template {path}.")
|
|
407
|
+
return 1
|
|
408
|
+
if shipped.read_bytes() != packaged.read_bytes():
|
|
409
|
+
report(
|
|
410
|
+
"tasks-template-red-green-example: the two shipped copies of the "
|
|
411
|
+
"tasks template have diverged."
|
|
412
|
+
)
|
|
413
|
+
return 1
|
|
414
|
+
|
|
415
|
+
source = shipped.read_text(encoding="utf-8")
|
|
416
|
+
red_green = [
|
|
417
|
+
block
|
|
418
|
+
for block in re.split(r"^## ", source, flags=re.MULTILINE)
|
|
419
|
+
if re.search(r"^\s*-\s*Strategy:\s*(vertical-tdd|regression-first)", block, re.M)
|
|
420
|
+
]
|
|
421
|
+
if not red_green:
|
|
422
|
+
report(
|
|
423
|
+
"tasks-template-red-green-example: the template defines no task "
|
|
424
|
+
"group with a red-green strategy, so it still only describes one."
|
|
425
|
+
)
|
|
426
|
+
return 1
|
|
427
|
+
group = red_green[0]
|
|
428
|
+
untagged = re.findall(r"^\s*-\s*(M[1-9]\d*):\s*(?!pending)", group, re.M)
|
|
429
|
+
tagged = re.findall(r"^\s*-\s*(M[1-9]\d*)\s*\([^)]*regression[^)]*\):", group, re.M)
|
|
430
|
+
if not untagged:
|
|
431
|
+
report(
|
|
432
|
+
"tasks-template-red-green-example: the red-green group has no "
|
|
433
|
+
"untagged check, which task-start refuses as regression-only."
|
|
434
|
+
)
|
|
435
|
+
return 1
|
|
436
|
+
if not tagged:
|
|
437
|
+
report(
|
|
438
|
+
"tasks-template-red-green-example: the red-green group shows no "
|
|
439
|
+
"(regression)-tagged check, so the exemption is still unillustrated."
|
|
440
|
+
)
|
|
441
|
+
return 1
|
|
442
|
+
label = untagged[0]
|
|
443
|
+
for suffix in ("", ".red", ".green"):
|
|
444
|
+
if not re.search(rf"^\s*-\s*{label}{re.escape(suffix)}:", group, re.M):
|
|
445
|
+
report(
|
|
446
|
+
"tasks-template-red-green-example: the untagged check is missing "
|
|
447
|
+
f"its `{label}{suffix}` Evidence entry."
|
|
448
|
+
)
|
|
449
|
+
return 1
|
|
450
|
+
for suffix in (".red", ".green"):
|
|
451
|
+
if re.search(rf"^\s*-\s*{tagged[0]}{re.escape(suffix)}:", group, re.M):
|
|
452
|
+
report(
|
|
453
|
+
"tasks-template-red-green-example: the (regression)-tagged check "
|
|
454
|
+
f"carries a `{suffix}` entry it is exempt from."
|
|
455
|
+
)
|
|
456
|
+
return 1
|
|
457
|
+
|
|
458
|
+
# Gating the filled template is what keeps the example from drifting from
|
|
459
|
+
# the rule it illustrates.
|
|
460
|
+
filled = fill_template_slots(source)
|
|
461
|
+
with tempfile.TemporaryDirectory(prefix="keel-tasks-template-") as raw:
|
|
462
|
+
repo = Path(raw)
|
|
463
|
+
write_text(repo / "openspec/changes/from-template/tasks.md", filled)
|
|
464
|
+
ids = re.findall(r"^\s*-\s*\[[ xX]\]\s+(\d+(?:\.\d+)+)\s", filled, re.M)
|
|
465
|
+
if not ids:
|
|
466
|
+
report(
|
|
467
|
+
"tasks-template-red-green-example: the filled template defines "
|
|
468
|
+
"no task the gate can read."
|
|
469
|
+
)
|
|
470
|
+
return 1
|
|
471
|
+
for task_id in ids:
|
|
472
|
+
result = run_keel(
|
|
473
|
+
repo,
|
|
474
|
+
"gate",
|
|
475
|
+
"task-start",
|
|
476
|
+
"--change",
|
|
477
|
+
"from-template",
|
|
478
|
+
"--task",
|
|
479
|
+
task_id,
|
|
480
|
+
"--json",
|
|
481
|
+
)
|
|
482
|
+
payload = json.loads(result.stdout)
|
|
483
|
+
if payload.get("status") != "pass":
|
|
484
|
+
report(
|
|
485
|
+
"tasks-template-red-green-example: task "
|
|
486
|
+
f"{task_id} written from the shipped template did not pass "
|
|
487
|
+
"task-start."
|
|
488
|
+
)
|
|
489
|
+
for problem in payload.get("problems", []):
|
|
490
|
+
report(f" {problem.get('code')}: {problem.get('message')}")
|
|
491
|
+
return 1
|
|
492
|
+
if "tasks-template-red-green-example" not in {name for name, _ in registry.SCENARIOS}:
|
|
493
|
+
report(
|
|
494
|
+
"tasks-template-red-green-example: the scenario registry does not "
|
|
495
|
+
"include it."
|
|
496
|
+
)
|
|
497
|
+
return 1
|
|
498
|
+
report("tasks-template-red-green-example scenario passed.")
|
|
499
|
+
return 0
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
def validate_spec_template_validates_scenario() -> int:
|
|
503
|
+
"""Issue #28 item 7: following the spec template guaranteed a first failure.
|
|
504
|
+
|
|
505
|
+
The template's requirement body is a comment with no modal verb, and
|
|
506
|
+
`openspec validate` requires SHALL or MUST, so the reporter's 16 requirements
|
|
507
|
+
produced 16 errors. Asserted by running the filled template through the
|
|
508
|
+
validator rather than by matching the template's prose, because a template
|
|
509
|
+
that only mentions the requirement in a comment would satisfy the latter.
|
|
510
|
+
"""
|
|
511
|
+
shipped = ROOT / "openspec" / SPEC_TEMPLATE_RELATIVE
|
|
512
|
+
packaged = ROOT / "assets" / "openspec" / SPEC_TEMPLATE_RELATIVE
|
|
513
|
+
for path in (shipped, packaged):
|
|
514
|
+
if not path.is_file():
|
|
515
|
+
report(f"spec-template-validates: missing shipped template {path}.")
|
|
516
|
+
return 1
|
|
517
|
+
if shipped.read_bytes() != packaged.read_bytes():
|
|
518
|
+
report(
|
|
519
|
+
"spec-template-validates: the two shipped copies of the spec "
|
|
520
|
+
"template have diverged."
|
|
521
|
+
)
|
|
522
|
+
return 1
|
|
523
|
+
if run_openspec(ROOT, "--version") is None:
|
|
524
|
+
report(
|
|
525
|
+
"spec-template-validates skipped: the openspec CLI could not be "
|
|
526
|
+
"found. Searched " + ", then ".join(OPENSPEC_SEARCH_ORDER) + "."
|
|
527
|
+
)
|
|
528
|
+
return 0
|
|
529
|
+
|
|
530
|
+
filled = fill_template_slots(shipped.read_text(encoding="utf-8"))
|
|
531
|
+
# A line that is slot text and nothing else is an author instruction the
|
|
532
|
+
# filler treated as a slot. It reads as a requirement body with no modal
|
|
533
|
+
# verb, so the fixture would be handing the validator something no author
|
|
534
|
+
# would ever write and reporting the template for it.
|
|
535
|
+
stray = [
|
|
536
|
+
index + 1
|
|
537
|
+
for index, line in enumerate(filled.splitlines())
|
|
538
|
+
if line.strip() == SLOT_FILLER
|
|
539
|
+
]
|
|
540
|
+
if stray:
|
|
541
|
+
report(
|
|
542
|
+
"spec-template-validates: the filled template has slot text alone "
|
|
543
|
+
f"on line(s) {stray}, so an own-line author instruction was filled "
|
|
544
|
+
"rather than stripped and the fixture is malforming the template."
|
|
545
|
+
)
|
|
546
|
+
return 1
|
|
547
|
+
with tempfile.TemporaryDirectory(prefix="keel-spec-template-") as raw:
|
|
548
|
+
repo = Path(raw)
|
|
549
|
+
write_text(repo / "openspec/project.md", "# Project\n\nA fixture.\n")
|
|
550
|
+
change = repo / "openspec/changes/from-template"
|
|
551
|
+
write_text(
|
|
552
|
+
change / "proposal.md",
|
|
553
|
+
"# from-template\n\n## Why\n\nExercise the shipped spec template.\n"
|
|
554
|
+
"\n## What Changes\n\n- One requirement written from the template.\n",
|
|
555
|
+
)
|
|
556
|
+
write_text(change / "specs/demo-capability/spec.md", filled)
|
|
557
|
+
result = run_openspec(repo, "validate", "from-template")
|
|
558
|
+
if result is None:
|
|
559
|
+
report(
|
|
560
|
+
"spec-template-validates skipped: the openspec CLI vanished "
|
|
561
|
+
"mid-scenario."
|
|
562
|
+
)
|
|
563
|
+
return 0
|
|
564
|
+
if result.returncode != 0:
|
|
565
|
+
report(
|
|
566
|
+
"spec-template-validates: a requirement written from the "
|
|
567
|
+
"shipped template did not validate."
|
|
568
|
+
)
|
|
569
|
+
report((result.stdout or result.stderr).strip())
|
|
570
|
+
return 1
|
|
571
|
+
if "spec-template-validates" not in {name for name, _ in registry.SCENARIOS}:
|
|
572
|
+
report("spec-template-validates: the scenario registry does not include it.")
|
|
573
|
+
return 1
|
|
574
|
+
report("spec-template-validates scenario passed.")
|
|
575
|
+
return 0
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
def validate_verification_layering_docs_scenario() -> int:
|
|
579
|
+
en = (ROOT / "README.md").read_text(encoding="utf-8")
|
|
580
|
+
for needle in (
|
|
581
|
+
"## Verification layering",
|
|
582
|
+
"inner-loop",
|
|
583
|
+
"Full gate",
|
|
584
|
+
"pre-push",
|
|
585
|
+
"change-close",
|
|
586
|
+
):
|
|
587
|
+
if needle not in en:
|
|
588
|
+
report(
|
|
589
|
+
"verification-layering-docs: README.md lacks the fast/full "
|
|
590
|
+
f"verification split marker: {needle}"
|
|
591
|
+
)
|
|
592
|
+
return 1
|
|
593
|
+
|
|
594
|
+
zh = (ROOT / "README.zh-CN.md").read_text(encoding="utf-8")
|
|
595
|
+
for needle in ("## 验证分层", "快速内环", "全量门禁", "pre-push", "change-close"):
|
|
596
|
+
if needle not in zh:
|
|
597
|
+
report(
|
|
598
|
+
"verification-layering-docs: README.zh-CN.md lacks the fast/full "
|
|
599
|
+
f"verification split marker: {needle}"
|
|
600
|
+
)
|
|
601
|
+
return 1
|
|
602
|
+
|
|
603
|
+
if "verification-layering-docs" not in {name for name, _ in registry.SCENARIOS}:
|
|
604
|
+
report("verification-layering-docs: the scenario registry does not include it.")
|
|
605
|
+
return 1
|
|
606
|
+
|
|
607
|
+
report("verification-layering-docs scenario passed.")
|
|
608
|
+
return 0
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
ACCEPTED_AUTHORIZE_NAMES = (
|
|
612
|
+
"commit, push, push:<branch glob>[@<role>], release, archive, continuation, "
|
|
613
|
+
"issue:<owner>/<repo>[@<role>], protocol-refresh, chat-reply:<group>[@<role>], "
|
|
614
|
+
"issue-close:<owner>/<repo>[@<role>], cleanup:scratch[@<role>], push-protected:<branch glob>[@<role>], shift-restore, self-shift"
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
def validate_continuation_docs_scenario() -> int:
|
|
619
|
+
"""Every text an agent reads at the between-task boundary names the word (#94).
|
|
620
|
+
|
|
621
|
+
The README and the config comment are where an owner learns the
|
|
622
|
+
vocabulary, and the resident protocol is what the agent holds in context.
|
|
623
|
+
The goal skill's stop rule was the third reader until the skill was
|
|
624
|
+
removed in 5.173.0 (#414).
|
|
625
|
+
"""
|
|
626
|
+
label = "continuation-docs"
|
|
627
|
+
|
|
628
|
+
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
|
629
|
+
# Since #414 crossing the boundary needs no confirmation by default, and the
|
|
630
|
+
# README says so where it names the word.
|
|
631
|
+
for needle in (
|
|
632
|
+
"next unchecked task of the same change",
|
|
633
|
+
"needs no confirmation by default",
|
|
634
|
+
):
|
|
635
|
+
if needle not in readme:
|
|
636
|
+
report(f"{label}: README.md lacks: {needle}")
|
|
637
|
+
return 1
|
|
638
|
+
# The seventh name (#164). Each surface that spells the vocabulary out has
|
|
639
|
+
# to spell all of it: a reader copies from the list they are shown.
|
|
640
|
+
for needle in (
|
|
641
|
+
f"accepted names: {ACCEPTED_AUTHORIZE_NAMES}",
|
|
642
|
+
"The thirteen names above are the whole vocabulary.",
|
|
643
|
+
"`protocol-refresh`, the seventh name",
|
|
644
|
+
):
|
|
645
|
+
if needle not in readme:
|
|
646
|
+
report(f"{label}: README.md lacks: protocol-refresh, as {needle!r}")
|
|
647
|
+
return 1
|
|
648
|
+
|
|
649
|
+
config_text = (ROOT / "keel/config.yaml").read_text(encoding="utf-8")
|
|
650
|
+
if "commit, push, push:<branch glob>[@<role>],\n# release, archive, continuation, issue:<owner>/<repo>[@<role>], protocol-refresh,\n# chat-reply:<group>[@<role>], issue-close:<owner>/<repo>[@<role>], cleanup:scratch[@<role>],\n# push-protected:<branch glob>[@<role>], shift-restore, self-shift" not in config_text:
|
|
651
|
+
report(
|
|
652
|
+
f"{label}: keel/config.yaml's comment lacks: protocol-refresh in the "
|
|
653
|
+
"seven-name vocabulary."
|
|
654
|
+
)
|
|
655
|
+
return 1
|
|
656
|
+
|
|
657
|
+
agents = (ROOT / "AGENTS.md").read_text(encoding="utf-8")
|
|
658
|
+
# M2 — the rule an agent follows when `keel context` names a refresh. The
|
|
659
|
+
# consumer bootstrap has no room for it (its byte budget is spent), and
|
|
660
|
+
# needs none: it opens with `keel context`, whose `Protocol:` line states
|
|
661
|
+
# the same rule in whichever state applies.
|
|
662
|
+
session = agents.split("## Session Start", 1)[-1].split("\n## ", 1)[0]
|
|
663
|
+
for needle in ("`protocol-refresh`", "write guard", "uncommitted"):
|
|
664
|
+
if needle not in session:
|
|
665
|
+
report(
|
|
666
|
+
f"{label}: AGENTS.md Session Start does not carry the "
|
|
667
|
+
f"protocol-refresh rule; it lacks {needle!r}."
|
|
668
|
+
)
|
|
669
|
+
return 1
|
|
670
|
+
bootstrap = (ROOT / "assets/bootstrap/AGENTS.md").read_text(encoding="utf-8")
|
|
671
|
+
if "Start every session with `keel context`" not in bootstrap:
|
|
672
|
+
report(
|
|
673
|
+
f"{label}: the bootstrap does not carry the protocol-refresh rule's "
|
|
674
|
+
"route to a consumer: it no longer opens with `keel context`."
|
|
675
|
+
)
|
|
676
|
+
return 1
|
|
677
|
+
parts = agents.split("## Execution boundary", 1)
|
|
678
|
+
if len(parts) != 2:
|
|
679
|
+
report(f"{label}: AGENTS.md lost its Execution boundary section.")
|
|
680
|
+
return 1
|
|
681
|
+
section = parts[1].split("\n## ", 1)[0]
|
|
682
|
+
for needle in (
|
|
683
|
+
"declared `continuation` is accepted and changes nothing",
|
|
684
|
+
"next unchecked task of the same approved change needs no confirmation",
|
|
685
|
+
"its own recorded fingerprint",
|
|
686
|
+
):
|
|
687
|
+
if needle not in section:
|
|
688
|
+
report(f"{label}: AGENTS.md Execution boundary lacks: {needle}")
|
|
689
|
+
return 1
|
|
690
|
+
|
|
691
|
+
report("continuation-docs scenario passed.")
|
|
692
|
+
return 0
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
def validate_plan_funnel_guidance_scenario() -> int:
|
|
696
|
+
skill_copies = (
|
|
697
|
+
ROOT / "src/skills/keel-review-checklist/SKILL.md",
|
|
698
|
+
ROOT / PLUGIN_ROOT / "skills/keel-review-checklist/SKILL.md",
|
|
699
|
+
)
|
|
700
|
+
for copy in skill_copies:
|
|
701
|
+
text = copy.read_text(encoding="utf-8")
|
|
702
|
+
for needle in (
|
|
703
|
+
"Planning artifact funnel",
|
|
704
|
+
"never execution authority",
|
|
705
|
+
"returns to OpenSpec authoring",
|
|
706
|
+
):
|
|
707
|
+
if needle not in text:
|
|
708
|
+
report(
|
|
709
|
+
f"plan-funnel-guidance: {copy.name} in {copy.parent.parent.name} "
|
|
710
|
+
f"lacks the funnel check ({needle!r})."
|
|
711
|
+
)
|
|
712
|
+
return 1
|
|
713
|
+
if skill_copies[0].read_bytes() != skill_copies[1].read_bytes():
|
|
714
|
+
report(
|
|
715
|
+
"plan-funnel-guidance: shipped keel-review-checklist copy diverges "
|
|
716
|
+
"from the canonical source."
|
|
717
|
+
)
|
|
718
|
+
return 1
|
|
719
|
+
|
|
720
|
+
for name in ("README.md", "README.zh-CN.md"):
|
|
721
|
+
readme = (ROOT / name).read_text(encoding="utf-8")
|
|
722
|
+
if "plan mode" not in readme or "proposal/design/specs/tasks" not in readme:
|
|
723
|
+
report(f"plan-funnel-guidance: {name} lacks the plan-mode funnel rule.")
|
|
724
|
+
return 1
|
|
725
|
+
|
|
726
|
+
if "plan-funnel-guidance" not in {name for name, _ in registry.SCENARIOS}:
|
|
727
|
+
report("plan-funnel-guidance: the scenario registry does not include it.")
|
|
728
|
+
return 1
|
|
729
|
+
|
|
730
|
+
report("plan-funnel-guidance scenario passed.")
|
|
731
|
+
return 0
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
def validate_published_specs_validate_strictly_scenario() -> int:
|
|
735
|
+
"""Issue #46: the store Keel publishes was validated by nothing.
|
|
736
|
+
|
|
737
|
+
Every change's closing task runs `openspec validate <change> --strict`,
|
|
738
|
+
which reads the change directory and stays green. The published store under
|
|
739
|
+
`openspec/specs/` was read by no check at all — measured at 5.16.0,
|
|
740
|
+
`--specs` appeared zero times in this file. Issue #46 found 8 of 21 specs
|
|
741
|
+
failing strict validation, every one on `Requirement must contain SHALL or
|
|
742
|
+
MUST keyword`, because the requirement opened with a context paragraph and
|
|
743
|
+
the strict validator reads only the block under the heading. Those failures
|
|
744
|
+
had never appeared in front of anyone.
|
|
745
|
+
|
|
746
|
+
They are gone now, removed by spec rewrites made for other reasons. That is
|
|
747
|
+
what makes this the moment to assert it absolutely rather than as the
|
|
748
|
+
ratchet #46 proposed: at a count of 8 a ratchet was the honest shape, and at
|
|
749
|
+
0 the same mechanism becomes a budget for failures to hide in.
|
|
750
|
+
"""
|
|
751
|
+
label = "published-specs-validate-strictly"
|
|
752
|
+
|
|
753
|
+
# The pinned binary, not whatever `openspec` PATH happens to offer. This is
|
|
754
|
+
# not fussiness: measured here, PATH answers 1.4.1 and reports 8 failures
|
|
755
|
+
# while the version this repository resolves answers 1.6.0 and reports
|
|
756
|
+
# none. Issue #46 recorded those 8 failures as an openspec 1.6.0 result;
|
|
757
|
+
# they are 1.4.1's, and the store has always passed under the version the
|
|
758
|
+
# repository pins. A check that reads PATH would re-record the same
|
|
759
|
+
# mistake, which is exactly what `keel-target-surface-diagnostics` means by
|
|
760
|
+
# a suite that silently changes which program it runs reporting facts about
|
|
761
|
+
# a different program.
|
|
762
|
+
pinned = ROOT / "node_modules" / ".bin" / (
|
|
763
|
+
"openspec.cmd" if os.name == "nt" else "openspec"
|
|
764
|
+
)
|
|
765
|
+
if not pinned.exists():
|
|
766
|
+
report(
|
|
767
|
+
f"{label}: the pinned openspec is not installed "
|
|
768
|
+
"(node_modules/.bin/openspec); reporting the skip rather than "
|
|
769
|
+
"falling back to PATH, which would answer for a different program."
|
|
770
|
+
)
|
|
771
|
+
return 0
|
|
772
|
+
|
|
773
|
+
def pinned_openspec(*args: str) -> subprocess.CompletedProcess[str]:
|
|
774
|
+
return subprocess.run(
|
|
775
|
+
[str(pinned), *args],
|
|
776
|
+
cwd=ROOT,
|
|
777
|
+
text=True,
|
|
778
|
+
encoding="utf-8",
|
|
779
|
+
errors="replace",
|
|
780
|
+
capture_output=True,
|
|
781
|
+
check=False,
|
|
782
|
+
)
|
|
783
|
+
|
|
784
|
+
version = pinned_openspec("--version")
|
|
785
|
+
exercised = re.search(r"\d+\.\d+\.\d+", version.stdout or "")
|
|
786
|
+
result = pinned_openspec("validate", "--specs", "--strict")
|
|
787
|
+
|
|
788
|
+
output = f"{result.stdout or ''}{result.stderr or ''}"
|
|
789
|
+
# Two independent readings. The exit status alone would pass if the command
|
|
790
|
+
# stopped validating; the per-spec lines alone would pass if it started
|
|
791
|
+
# exiting non-zero for an unrelated reason. Neither is trusted on its own.
|
|
792
|
+
failed = [
|
|
793
|
+
line.strip()
|
|
794
|
+
for line in output.splitlines()
|
|
795
|
+
if line.strip().startswith("✗")
|
|
796
|
+
]
|
|
797
|
+
totals = re.search(r"Totals:\s*(\d+) passed,\s*(\d+) failed", output)
|
|
798
|
+
if not totals:
|
|
799
|
+
report(
|
|
800
|
+
f"{label} the validator produced no totals line, so the result "
|
|
801
|
+
"cannot be read. The output shape it reports may have moved."
|
|
802
|
+
)
|
|
803
|
+
report(output.strip()[:600])
|
|
804
|
+
return 1
|
|
805
|
+
passed_count, failed_count = int(totals.group(1)), int(totals.group(2))
|
|
806
|
+
|
|
807
|
+
if failed:
|
|
808
|
+
report(
|
|
809
|
+
f"{label} {len(failed)} published spec(s) fail strict validation "
|
|
810
|
+
f"against openspec {exercised.group(0) if exercised else 'unknown'}. "
|
|
811
|
+
"A published spec that the validator Keel ships refuses is one "
|
|
812
|
+
"every consumer sees refused. The usual cause is a requirement "
|
|
813
|
+
"whose modal verb sits below its first paragraph — the strict "
|
|
814
|
+
"validator reads only the block directly under the heading."
|
|
815
|
+
)
|
|
816
|
+
for line in failed:
|
|
817
|
+
report(f" {line}")
|
|
818
|
+
return 1
|
|
819
|
+
if failed_count != 0:
|
|
820
|
+
report(
|
|
821
|
+
f"{label} the totals line reports {failed_count} failing spec(s) "
|
|
822
|
+
"while no per-spec failure line was emitted. The two readings "
|
|
823
|
+
"disagree, so the result is not trustworthy either way."
|
|
824
|
+
)
|
|
825
|
+
report(output.strip()[:600])
|
|
826
|
+
return 1
|
|
827
|
+
if result.returncode != 0:
|
|
828
|
+
report(
|
|
829
|
+
f"{label} the validator reported {passed_count} passed and 0 "
|
|
830
|
+
f"failed but exited {result.returncode}. The verdict and the exit "
|
|
831
|
+
"status disagree."
|
|
832
|
+
)
|
|
833
|
+
report(output.strip()[:600])
|
|
834
|
+
return 1
|
|
835
|
+
if passed_count == 0:
|
|
836
|
+
report(
|
|
837
|
+
f"{label} the validator reports zero specs. An empty store passes "
|
|
838
|
+
"every assertion about it, which is the shape "
|
|
839
|
+
"`A derived assertion set that collapses to empty fails instead of "
|
|
840
|
+
"passing` exists to refuse."
|
|
841
|
+
)
|
|
842
|
+
return 1
|
|
843
|
+
|
|
844
|
+
if label not in {name for name, _ in registry.SCENARIOS}:
|
|
845
|
+
report(f"{label}: the scenario registry does not include it.")
|
|
846
|
+
return 1
|
|
847
|
+
report(
|
|
848
|
+
f"{label} scenario passed: {passed_count} published specs validate "
|
|
849
|
+
f"strictly against openspec "
|
|
850
|
+
f"{exercised.group(0) if exercised else 'unknown'}."
|
|
851
|
+
)
|
|
852
|
+
return 0
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
def validate_a_count_is_derived_from_what_it_counts_scenario() -> int:
|
|
856
|
+
"""Issue #143: the header assertion restated a set as an English numeral.
|
|
857
|
+
|
|
858
|
+
It had been hand-bumped twice, and the second bump was discovered by a red
|
|
859
|
+
suite run in a scenario whose name has nothing to do with what was changed.
|
|
860
|
+
An assertion about a set belongs to the set: read it from the module that
|
|
861
|
+
defines it, and name the member that is missing rather than a count.
|
|
862
|
+
"""
|
|
863
|
+
label = "a-count-is-derived-from-what-it-counts"
|
|
864
|
+
|
|
865
|
+
def declared_names(root: Path) -> list[str]:
|
|
866
|
+
result = run_node_expression(
|
|
867
|
+
root,
|
|
868
|
+
"process.stdout.write("
|
|
869
|
+
"require('./src/core/config.js').CONFIG_DECLARATIONS.join(','))",
|
|
870
|
+
)
|
|
871
|
+
return [name for name in result.strip().split(",") if name]
|
|
872
|
+
|
|
873
|
+
names = declared_names(ROOT)
|
|
874
|
+
if not names:
|
|
875
|
+
report(
|
|
876
|
+
f"{label}: the assertion is a literal — `src/core/config.js` exports "
|
|
877
|
+
"no declaration list, so nothing the header is checked against comes "
|
|
878
|
+
"from the code that reads it."
|
|
879
|
+
)
|
|
880
|
+
return 1
|
|
881
|
+
for expected in (
|
|
882
|
+
"fast_check",
|
|
883
|
+
"authorize",
|
|
884
|
+
"precedents",
|
|
885
|
+
"triage",
|
|
886
|
+
"full_mode_paths",
|
|
887
|
+
):
|
|
888
|
+
if expected not in names:
|
|
889
|
+
report(
|
|
890
|
+
f"{label}: the exported declaration list omits {expected!r}, so "
|
|
891
|
+
f"the header is not checked for it; got {names!r}."
|
|
892
|
+
)
|
|
893
|
+
return 1
|
|
894
|
+
|
|
895
|
+
header = (ROOT / "keel/config.yaml").read_text(encoding="utf-8")
|
|
896
|
+
flat_header = config_header_paragraph(header)
|
|
897
|
+
for name in names:
|
|
898
|
+
if name not in flat_header:
|
|
899
|
+
report(
|
|
900
|
+
f"{label}: keel/config.yaml's header does not name {name!r}, "
|
|
901
|
+
"which is the declaration a new project would never learn it may "
|
|
902
|
+
"write."
|
|
903
|
+
)
|
|
904
|
+
return 1
|
|
905
|
+
|
|
906
|
+
# The derivation is proved by feeding the check a member the header cannot
|
|
907
|
+
# contain. Without this the whole scenario is satisfied by a list that
|
|
908
|
+
# happens to agree with a header nobody compared it to.
|
|
909
|
+
missing = config_header_problem(names + ["invented_declaration"], header)
|
|
910
|
+
if not missing:
|
|
911
|
+
report(
|
|
912
|
+
f"{label}: the assertion is a literal — a declaration absent from "
|
|
913
|
+
"the header produced no failure, so the check is not reading the "
|
|
914
|
+
"exported list."
|
|
915
|
+
)
|
|
916
|
+
return 1
|
|
917
|
+
if "invented_declaration" not in missing:
|
|
918
|
+
report(
|
|
919
|
+
f"{label}: the failure does not name the missing declaration; got "
|
|
920
|
+
f"{missing!r}."
|
|
921
|
+
)
|
|
922
|
+
return 1
|
|
923
|
+
if re.search(r"\b(?:four|five|six|seven)\b", missing, re.IGNORECASE):
|
|
924
|
+
report(
|
|
925
|
+
f"{label}: still says six declarations — the failure reports a "
|
|
926
|
+
f"count rather than the missing name; got {missing!r}."
|
|
927
|
+
)
|
|
928
|
+
return 1
|
|
929
|
+
|
|
930
|
+
# The header is the opening paragraph, not the file. A declaration name that
|
|
931
|
+
# appears only in the body — a comment elsewhere happening to use the word —
|
|
932
|
+
# does not tell a new project it may write that key. Found when `merge` was
|
|
933
|
+
# added in 5.71.0: the triage section's "never authorizes a merge" satisfied
|
|
934
|
+
# the rule before the header said anything (#155).
|
|
935
|
+
body_only = header.replace(
|
|
936
|
+
"# delegation, which names who runs a task;",
|
|
937
|
+
"# delegation, which names who runs a task;",
|
|
938
|
+
) + "\n# a body comment that mentions body_only_declaration in passing\n"
|
|
939
|
+
if not config_header_problem(names + ["body_only_declaration"], body_only):
|
|
940
|
+
report(
|
|
941
|
+
f"{label}: a declaration named only in the file body was accepted as "
|
|
942
|
+
"named in the header — the rule reads the whole file, so any common "
|
|
943
|
+
"word used anywhere satisfies it."
|
|
944
|
+
)
|
|
945
|
+
return 1
|
|
946
|
+
|
|
947
|
+
# A header naming every declaration while miscounting them in prose passes:
|
|
948
|
+
# membership is the checkable property, and a count is a lossy restatement.
|
|
949
|
+
# The numeral is located by shape, not by its current value. Pinning the
|
|
950
|
+
# word here would reintroduce the literal this scenario exists to remove,
|
|
951
|
+
# one level down: adding `executor_tier` moved the header to "Seven" and the
|
|
952
|
+
# mutation stopped finding anything to vary.
|
|
953
|
+
miscounted, varied = re.subn(
|
|
954
|
+
r"\b\w+ independent declarations\b",
|
|
955
|
+
"Zero independent declarations",
|
|
956
|
+
header,
|
|
957
|
+
count=1,
|
|
958
|
+
)
|
|
959
|
+
if not varied:
|
|
960
|
+
report(f"{label}: the header's prose count could not be located to vary it.")
|
|
961
|
+
return 1
|
|
962
|
+
if config_header_problem(names, miscounted):
|
|
963
|
+
report(
|
|
964
|
+
f"{label}: still says six declarations — a header naming all of them "
|
|
965
|
+
"while miscounting them in prose was refused."
|
|
966
|
+
)
|
|
967
|
+
return 1
|
|
968
|
+
|
|
969
|
+
if label not in {name for name, _ in registry.SCENARIOS}:
|
|
970
|
+
report(f"{label}: the scenario registry does not include it.")
|
|
971
|
+
return 1
|
|
972
|
+
report(f"{label} scenario passed.")
|
|
973
|
+
return 0
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
def validate_a_tier_declares_what_is_skipped_scenario() -> int:
|
|
977
|
+
"""Issue #135: which guidance an executor skips is a declaration, not a judgement.
|
|
978
|
+
|
|
979
|
+
A strong executor gets no value from stepwise how-to prose and pays for it on
|
|
980
|
+
every activation. The report's own argument against letting the executor
|
|
981
|
+
decide is that "do I need this?" is the judgement it is worst at, so the skip
|
|
982
|
+
is written down by the repository. The tier reaches guidance and nothing else:
|
|
983
|
+
a reader who takes it for a relaxation of the gates is worse off than one who
|
|
984
|
+
never saw it, which is why every surface that reports it says so.
|
|
985
|
+
"""
|
|
986
|
+
label = "a-tier-declares-what-is-skipped"
|
|
987
|
+
|
|
988
|
+
with tempfile.TemporaryDirectory(prefix="keel-tier-") as raw:
|
|
989
|
+
root = Path(raw)
|
|
990
|
+
|
|
991
|
+
def fixture(name: str, body: str) -> Path:
|
|
992
|
+
repo = root / name
|
|
993
|
+
repo.mkdir()
|
|
994
|
+
(repo / "keel").mkdir()
|
|
995
|
+
(repo / "keel" / "config.yaml").write_text(body, encoding="utf-8")
|
|
996
|
+
return repo
|
|
997
|
+
|
|
998
|
+
def context(repo: Path) -> str:
|
|
999
|
+
return run_keel(repo, "context").stdout
|
|
1000
|
+
|
|
1001
|
+
# M1 — the declared tier is reported, an absent one reports the default,
|
|
1002
|
+
# and both say guidance is all the tier reaches.
|
|
1003
|
+
for name, body, expected in (
|
|
1004
|
+
("high", "fast_check: echo high\nexecutor_tier: high\n", "high"),
|
|
1005
|
+
("absent", "fast_check: echo absent\n", "standard"),
|
|
1006
|
+
):
|
|
1007
|
+
repo = fixture(name, body)
|
|
1008
|
+
out = context(repo)
|
|
1009
|
+
line = next(
|
|
1010
|
+
(l for l in out.splitlines() if l.startswith("Executor tier:")), None
|
|
1011
|
+
)
|
|
1012
|
+
if line is None:
|
|
1013
|
+
report(
|
|
1014
|
+
f"{label}: no executor tier reported — the {name} repository "
|
|
1015
|
+
"is told nothing about which guidance its skills load."
|
|
1016
|
+
)
|
|
1017
|
+
report(out)
|
|
1018
|
+
return 1
|
|
1019
|
+
if expected not in line:
|
|
1020
|
+
report(
|
|
1021
|
+
f"{label}: the {name} repository reports {line!r} rather than "
|
|
1022
|
+
f"the {expected!r} tier."
|
|
1023
|
+
)
|
|
1024
|
+
return 1
|
|
1025
|
+
if "guidance" not in line:
|
|
1026
|
+
report(
|
|
1027
|
+
f"{label}: no executor tier reported as affecting guidance "
|
|
1028
|
+
f"only; {line!r} leaves a reader free to take it for a "
|
|
1029
|
+
"relaxation of the gates."
|
|
1030
|
+
)
|
|
1031
|
+
return 1
|
|
1032
|
+
|
|
1033
|
+
# M2 — a value Keel cannot read fails closed to reading the guidance.
|
|
1034
|
+
# The author of a typo believes they declared what they typed, so a
|
|
1035
|
+
# misspelling must not silently buy the skip it asked for, and the
|
|
1036
|
+
# refusal names the value and the alternatives rather than the key.
|
|
1037
|
+
typo = fixture("typo", "fast_check: echo typo\nexecutor_tier: aggressive\n")
|
|
1038
|
+
out = context(typo)
|
|
1039
|
+
line = next(
|
|
1040
|
+
(l for l in out.splitlines() if l.startswith("Executor tier:")), None
|
|
1041
|
+
)
|
|
1042
|
+
if line is None:
|
|
1043
|
+
report(
|
|
1044
|
+
f"{label}: accepted a tier outside the set — the projection "
|
|
1045
|
+
"reported no tier at all for an unreadable value, so the "
|
|
1046
|
+
"fallback is invisible."
|
|
1047
|
+
)
|
|
1048
|
+
report(out)
|
|
1049
|
+
return 1
|
|
1050
|
+
if "standard" not in line:
|
|
1051
|
+
report(
|
|
1052
|
+
f"{label}: accepted a tier outside the set — an unreadable value "
|
|
1053
|
+
f"did not fall back to reading the guidance; got {line!r}."
|
|
1054
|
+
)
|
|
1055
|
+
report(out)
|
|
1056
|
+
return 1
|
|
1057
|
+
if "aggressive" not in out:
|
|
1058
|
+
report(
|
|
1059
|
+
f"{label}: the rejected value is not named, so the author is "
|
|
1060
|
+
"left believing they declared what they typed."
|
|
1061
|
+
)
|
|
1062
|
+
report(out)
|
|
1063
|
+
return 1
|
|
1064
|
+
if "high" not in out:
|
|
1065
|
+
report(
|
|
1066
|
+
f"{label}: the refusal does not name the accepted tiers, so the "
|
|
1067
|
+
"reader learns their value is wrong and not what is right."
|
|
1068
|
+
)
|
|
1069
|
+
report(out)
|
|
1070
|
+
return 1
|
|
1071
|
+
doctor = run_keel(typo, "--doctor").stdout
|
|
1072
|
+
if "executor_tier" not in doctor or "aggressive" not in doctor:
|
|
1073
|
+
report(
|
|
1074
|
+
f"{label}: the doctor does not report the declaration as failed "
|
|
1075
|
+
"and name the entry, so it reports health the projection "
|
|
1076
|
+
"contradicts."
|
|
1077
|
+
)
|
|
1078
|
+
report(doctor)
|
|
1079
|
+
return 1
|
|
1080
|
+
healthy = run_keel(fixture("ok", "executor_tier: high\n"), "--doctor").stdout
|
|
1081
|
+
if "executor_tier: high" not in healthy:
|
|
1082
|
+
report(
|
|
1083
|
+
f"{label}: the doctor does not report a readable declaration, so "
|
|
1084
|
+
"the only tier it ever mentions is a broken one."
|
|
1085
|
+
)
|
|
1086
|
+
report(healthy)
|
|
1087
|
+
return 1
|
|
1088
|
+
|
|
1089
|
+
if label not in {name for name, _ in registry.SCENARIOS}:
|
|
1090
|
+
report(f"{label}: the scenario registry does not include it.")
|
|
1091
|
+
return 1
|
|
1092
|
+
report(f"{label} scenario passed.")
|
|
1093
|
+
return 0
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
# The words Keel states a criterion in. A guidance file is asserted to contain
|
|
1097
|
+
# none of them, which is what makes "the executor tier removes no criterion" a
|
|
1098
|
+
# property of the repository rather than a promise in a design document: a tier
|
|
1099
|
+
# can only skip a file that decides nothing.
|
|
1100
|
+
CRITERION_VOCABULARY = ("MUST", "SHOULD", "refuses", "rejects", "hard-stops")
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
def guidance_criterion_problem(name: str, text: str) -> str | None:
|
|
1104
|
+
"""Return the problem a guidance file's text has, or None.
|
|
1105
|
+
|
|
1106
|
+
Takes the text rather than reading the path, so the rule can be exercised on
|
|
1107
|
+
a planted copy. A rule that could only ever see files already known to be
|
|
1108
|
+
clean would pass forever without anyone learning whether it fires.
|
|
1109
|
+
"""
|
|
1110
|
+
for word in CRITERION_VOCABULARY:
|
|
1111
|
+
if word in text:
|
|
1112
|
+
return (
|
|
1113
|
+
f"{name}'s guidance.md states a criterion — it contains "
|
|
1114
|
+
f"{word!r}, and a criterion in the file the executor tier skips "
|
|
1115
|
+
"would let `executor_tier: high` relax a rule rather than skip "
|
|
1116
|
+
"an explanation. Move the sentence back into SKILL.md."
|
|
1117
|
+
)
|
|
1118
|
+
return None
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
def validate_guidance_is_referenced_and_carries_no_criterion_scenario() -> int:
|
|
1122
|
+
"""Issue #135: stepwise guidance is referenced, and it decides nothing.
|
|
1123
|
+
|
|
1124
|
+
Keel is not on the delivery path for a skill body — the host reads
|
|
1125
|
+
`plugins/keel/skills/*/SKILL.md` directly — so the only way the resident cost
|
|
1126
|
+
falls is for the body to be smaller. What leaves it is how-to prose; every
|
|
1127
|
+
criterion stays, and that is checked here by planting one rather than
|
|
1128
|
+
promised, because a tier that could remove a criterion would be a relaxation
|
|
1129
|
+
of the gates wearing a capability label.
|
|
1130
|
+
"""
|
|
1131
|
+
label = "guidance-is-referenced-and-carries-no-criterion"
|
|
1132
|
+
skills_root = ROOT / "src/skills"
|
|
1133
|
+
guidance_files = sorted(skills_root.glob("*/guidance.md"))
|
|
1134
|
+
|
|
1135
|
+
# Two skills carry one today (#135, #389). An empty glob would satisfy every loop
|
|
1136
|
+
# below without reading anything, so the count is asserted first.
|
|
1137
|
+
if not guidance_files:
|
|
1138
|
+
report(
|
|
1139
|
+
f"{label}: no skill has a guidance.md, so every assertion below is "
|
|
1140
|
+
"vacuous — the split this scenario checks did not happen."
|
|
1141
|
+
)
|
|
1142
|
+
return 1
|
|
1143
|
+
|
|
1144
|
+
for guidance in guidance_files:
|
|
1145
|
+
skill = guidance.parent / "SKILL.md"
|
|
1146
|
+
body = skill.read_text(encoding="utf-8")
|
|
1147
|
+
text = guidance.read_text(encoding="utf-8")
|
|
1148
|
+
if "guidance.md" not in body:
|
|
1149
|
+
report(
|
|
1150
|
+
f"{label}: guidance file is not referenced — "
|
|
1151
|
+
f"{guidance.parent.name}'s SKILL.md never names guidance.md, so "
|
|
1152
|
+
"the prose that left the body is unreachable from it."
|
|
1153
|
+
)
|
|
1154
|
+
return 1
|
|
1155
|
+
if "executor_tier" not in body:
|
|
1156
|
+
report(
|
|
1157
|
+
f"{label}: {guidance.parent.name}'s SKILL.md names guidance.md "
|
|
1158
|
+
"without the condition under which it is read, which leaves the "
|
|
1159
|
+
"skip to the executor's own judgement — the judgement #135 says "
|
|
1160
|
+
"it gets most wrong."
|
|
1161
|
+
)
|
|
1162
|
+
return 1
|
|
1163
|
+
if "high" not in body:
|
|
1164
|
+
report(
|
|
1165
|
+
f"{label}: {guidance.parent.name}'s SKILL.md does not name the "
|
|
1166
|
+
"tier that skips the read, so the condition it states cannot be "
|
|
1167
|
+
"evaluated."
|
|
1168
|
+
)
|
|
1169
|
+
return 1
|
|
1170
|
+
# "Measurably smaller than before the split" is checkable only as a
|
|
1171
|
+
# property of what is on disk now: the guidance carries real content,
|
|
1172
|
+
# and that content is no longer duplicated in the body it left.
|
|
1173
|
+
if len(text) < 500:
|
|
1174
|
+
report(
|
|
1175
|
+
f"{label}: {guidance.parent.name}'s guidance.md holds "
|
|
1176
|
+
f"{len(text)} bytes, too few for the split to have moved "
|
|
1177
|
+
"anything; a pointer to an almost-empty file costs a read and "
|
|
1178
|
+
"saves nothing."
|
|
1179
|
+
)
|
|
1180
|
+
return 1
|
|
1181
|
+
criterion = guidance_criterion_problem(guidance.parent.name, text)
|
|
1182
|
+
if criterion:
|
|
1183
|
+
report(f"{label}: {criterion}")
|
|
1184
|
+
return 1
|
|
1185
|
+
for heading in [
|
|
1186
|
+
line for line in text.splitlines() if line.startswith("## ")
|
|
1187
|
+
]:
|
|
1188
|
+
if heading in body:
|
|
1189
|
+
report(
|
|
1190
|
+
f"{label}: {guidance.parent.name}'s body still carries "
|
|
1191
|
+
f"{heading!r}, so the section was copied rather than moved "
|
|
1192
|
+
"and the resident cost did not fall."
|
|
1193
|
+
)
|
|
1194
|
+
return 1
|
|
1195
|
+
|
|
1196
|
+
# M2 — the property is held by the suite, not promised by the design. A
|
|
1197
|
+
# guidance file that stated a criterion would let the tier skip one, which
|
|
1198
|
+
# would make `executor_tier: high` a relaxation of the gates wearing a
|
|
1199
|
+
# capability label. Planting one is the only way to know the rule fires.
|
|
1200
|
+
sample = guidance_files[0]
|
|
1201
|
+
planted = (
|
|
1202
|
+
sample.read_text(encoding="utf-8")
|
|
1203
|
+
+ "\nAn executor MUST record the fingerprint before implementing.\n"
|
|
1204
|
+
)
|
|
1205
|
+
problem = guidance_criterion_problem(sample.parent.name, planted)
|
|
1206
|
+
if not problem:
|
|
1207
|
+
report(
|
|
1208
|
+
f"{label}: states a criterion — a guidance file carrying `MUST` was "
|
|
1209
|
+
"accepted, so nothing stops a criterion from moving into the file "
|
|
1210
|
+
"the tier skips."
|
|
1211
|
+
)
|
|
1212
|
+
return 1
|
|
1213
|
+
if sample.parent.name not in problem:
|
|
1214
|
+
report(
|
|
1215
|
+
f"{label}: the refusal does not name the file that states the "
|
|
1216
|
+
f"criterion; got {problem!r}."
|
|
1217
|
+
)
|
|
1218
|
+
return 1
|
|
1219
|
+
if "MUST" not in problem:
|
|
1220
|
+
report(
|
|
1221
|
+
f"{label}: the refusal does not name the word it objected to, so the "
|
|
1222
|
+
f"author has to guess which sentence to move; got {problem!r}."
|
|
1223
|
+
)
|
|
1224
|
+
return 1
|
|
1225
|
+
|
|
1226
|
+
if label not in {name for name, _ in registry.SCENARIOS}:
|
|
1227
|
+
report(f"{label}: the scenario registry does not include it.")
|
|
1228
|
+
return 1
|
|
1229
|
+
report(f"{label} scenario passed.")
|
|
1230
|
+
return 0
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
def validate_native_projections_removed_scenario() -> int:
|
|
1234
|
+
"""Issue #414: Keel projects no goal, helper, task view, or subagent brief.
|
|
1235
|
+
|
|
1236
|
+
The owner removed the tooling built for the stance that subagents and native
|
|
1237
|
+
goals had to be shaped by Keel. Each surface is checked from the outside: the
|
|
1238
|
+
command a model would type, the doctor line it would read, and the plugin
|
|
1239
|
+
files a host would load. `keel project --event startup` is the control —
|
|
1240
|
+
a `keel project` that refused everything would pass the rest.
|
|
1241
|
+
"""
|
|
1242
|
+
label = "native-projections-removed"
|
|
1243
|
+
with tempfile.TemporaryDirectory(prefix="keel-414-", ignore_cleanup_errors=True) as raw:
|
|
1244
|
+
repo = Path(raw)
|
|
1245
|
+
init = run_keel(repo, "--init", "--target", "claude")
|
|
1246
|
+
if init.returncode != 0:
|
|
1247
|
+
report(f"{label}: keel --init failed: {(init.stderr or init.stdout).strip()}")
|
|
1248
|
+
return 1
|
|
1249
|
+
for args in (
|
|
1250
|
+
("project", "goal"),
|
|
1251
|
+
("project", "tasks"),
|
|
1252
|
+
("project", "helper"),
|
|
1253
|
+
("project", "--event", "subagent-start"),
|
|
1254
|
+
):
|
|
1255
|
+
result = run_keel(repo, *args)
|
|
1256
|
+
said = (result.stdout + result.stderr).lower()
|
|
1257
|
+
if result.returncode == 0:
|
|
1258
|
+
report(f"{label}: keel {' '.join(args)} exited 0.")
|
|
1259
|
+
return 1
|
|
1260
|
+
if "unknown" not in said and "unsupported" not in said:
|
|
1261
|
+
report(f"{label}: keel {' '.join(args)} was not refused as unknown: {(result.stdout or result.stderr).strip()[:120]!r}")
|
|
1262
|
+
return 1
|
|
1263
|
+
control = run_keel(repo, "project", "--event", "startup", "--target", "claude")
|
|
1264
|
+
if control.returncode != 0:
|
|
1265
|
+
report(f"{label}: keel project --event startup no longer works: {(control.stderr or control.stdout).strip()}")
|
|
1266
|
+
return 1
|
|
1267
|
+
doctor = run_keel(repo, "--doctor", "--target", "claude")
|
|
1268
|
+
for prefix in ("execution.goal", "execution.task-view", "delegation.", "helper "):
|
|
1269
|
+
hit = [line for line in doctor.stdout.splitlines() if line.strip().startswith(prefix)]
|
|
1270
|
+
if hit:
|
|
1271
|
+
report(f"{label}: doctor still prints {hit[0].strip()!r}.")
|
|
1272
|
+
return 1
|
|
1273
|
+
for gone in (
|
|
1274
|
+
ROOT / PLUGIN_ROOT / "skills/keel-run-single-task-goal",
|
|
1275
|
+
ROOT / "src/skills/keel-run-single-task-goal",
|
|
1276
|
+
ROOT / PLUGIN_ROOT / "agents",
|
|
1277
|
+
):
|
|
1278
|
+
if gone.exists():
|
|
1279
|
+
report(f"{label}: {gone.relative_to(ROOT)} still ships.")
|
|
1280
|
+
return 1
|
|
1281
|
+
for manifest in (ROOT / ".claude-plugin/plugin.json", ROOT / PLUGIN_ROOT / ".codex-plugin/plugin.json"):
|
|
1282
|
+
if "agents" in json.loads(manifest.read_text(encoding="utf-8")):
|
|
1283
|
+
report(f"{label}: {manifest.relative_to(ROOT)} still names agents.")
|
|
1284
|
+
return 1
|
|
1285
|
+
if label not in {name for name, _ in registry.SCENARIOS}:
|
|
1286
|
+
report(f"{label}: the scenario registry does not include it.")
|
|
1287
|
+
return 1
|
|
1288
|
+
report(f"{label} scenario passed.")
|
|
1289
|
+
return 0
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
NATIVE_CAPABILITY_SUPPRESSIONS = (
|
|
1293
|
+
"unbounded subagent",
|
|
1294
|
+
"bounded helpers return read-only",
|
|
1295
|
+
"Implementation delegation is refused",
|
|
1296
|
+
"Delegation is refused with no active guard",
|
|
1297
|
+
"Target-native subagent gate",
|
|
1298
|
+
"One agent owns decisions",
|
|
1299
|
+
"may help with bounded assessment",
|
|
1300
|
+
"goal/task-view projection requires explicit authorization",
|
|
1301
|
+
"small contiguous task group",
|
|
1302
|
+
"in the current agent conversation",
|
|
1303
|
+
"inside the current agent session",
|
|
1304
|
+
"never infer continuity",
|
|
1305
|
+
"never native memory",
|
|
1306
|
+
"at most 2 attempts",
|
|
1307
|
+
"Read only the documents needed",
|
|
1308
|
+
"minimal read list",
|
|
1309
|
+
"load only that one",
|
|
1310
|
+
"do not load unrelated lenses",
|
|
1311
|
+
"read only the returned paths",
|
|
1312
|
+
)
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
NATIVE_SUBAGENT_SENTENCE = "the model's choice and is treated as the main agent is"
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
NATIVE_CONTINUATION_SENTENCE = "approved `tasks.md` in order"
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
def validate_native_capabilities_unrestricted_scenario() -> int:
|
|
1322
|
+
"""Issue #414: Keel neither suppresses nor steers the host's native capabilities.
|
|
1323
|
+
|
|
1324
|
+
The owner reviewed each sentence that told the model to stay in one session,
|
|
1325
|
+
take one task, keep subagents to a read-only role, read a minimal list, or
|
|
1326
|
+
stop after two attempts, and removed them. This holds every one of them out
|
|
1327
|
+
of every model-facing surface, and requires the two sentences that replaced
|
|
1328
|
+
the subagent and continuation rules where the agent reads them first.
|
|
1329
|
+
"""
|
|
1330
|
+
label = "native-capabilities-unrestricted"
|
|
1331
|
+
surfaces = [
|
|
1332
|
+
ROOT / "AGENTS.md",
|
|
1333
|
+
ROOT / "assets/bootstrap/AGENTS.md",
|
|
1334
|
+
ROOT / "assets/openspec/schemas/keel-spec-driven/schema.yaml",
|
|
1335
|
+
ROOT / "openspec/schemas/keel-spec-driven/schema.yaml",
|
|
1336
|
+
]
|
|
1337
|
+
for name in ("apply-change", "archive-change", "sync-specs", "propose"):
|
|
1338
|
+
surfaces.append(ROOT / f".claude/skills/openspec-{name}/SKILL.md")
|
|
1339
|
+
surfaces.append(ROOT / f".codex/skills/openspec-{name}/SKILL.md")
|
|
1340
|
+
surfaces.extend(sorted((ROOT / "src/skills").glob("*/SKILL.md")))
|
|
1341
|
+
surfaces.extend(sorted((ROOT / PLUGIN_ROOT / "skills").glob("*/SKILL.md")))
|
|
1342
|
+
for surface in surfaces:
|
|
1343
|
+
if not surface.is_file():
|
|
1344
|
+
report(f"{label}: {surface.relative_to(ROOT)} is missing, so it cannot be checked.")
|
|
1345
|
+
return 1
|
|
1346
|
+
text = surface.read_text(encoding="utf-8")
|
|
1347
|
+
for phrase in NATIVE_CAPABILITY_SUPPRESSIONS:
|
|
1348
|
+
if phrase in text:
|
|
1349
|
+
report(f"{label}: {surface.relative_to(ROOT)} still says {phrase!r}.")
|
|
1350
|
+
return 1
|
|
1351
|
+
for first_read in (
|
|
1352
|
+
ROOT / "AGENTS.md",
|
|
1353
|
+
ROOT / "assets/bootstrap/AGENTS.md",
|
|
1354
|
+
ROOT / ".claude/skills/openspec-apply-change/SKILL.md",
|
|
1355
|
+
ROOT / ".codex/skills/openspec-apply-change/SKILL.md",
|
|
1356
|
+
):
|
|
1357
|
+
text = first_read.read_text(encoding="utf-8")
|
|
1358
|
+
if NATIVE_SUBAGENT_SENTENCE not in text:
|
|
1359
|
+
report(f"{label}: {first_read.relative_to(ROOT)} does not say a subagent is {NATIVE_SUBAGENT_SENTENCE!r}.")
|
|
1360
|
+
return 1
|
|
1361
|
+
if NATIVE_CONTINUATION_SENTENCE not in text:
|
|
1362
|
+
report(f"{label}: {first_read.relative_to(ROOT)} does not say the agent works through an {NATIVE_CONTINUATION_SENTENCE!r}.")
|
|
1363
|
+
return 1
|
|
1364
|
+
if label not in {name for name, _ in registry.SCENARIOS}:
|
|
1365
|
+
report(f"{label}: the scenario registry does not include it.")
|
|
1366
|
+
return 1
|
|
1367
|
+
report(f"{label} scenario passed.")
|
|
1368
|
+
return 0
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
# Sentences the surfaces said after the code stopped saying them (#413).
|
|
1372
|
+
STALE_SURFACE_SENTENCES = (
|
|
1373
|
+
"Owner is the current Keel agent",
|
|
1374
|
+
"retry counting",
|
|
1375
|
+
"Keel Hook completion gate",
|
|
1376
|
+
"unless Touch authorizes diagnostics",
|
|
1377
|
+
"explicitly allows it",
|
|
1378
|
+
"without explicit authorization",
|
|
1379
|
+
"Commands prove Acceptance",
|
|
1380
|
+
"Acceptance, Commands, and Stop/Autonomy",
|
|
1381
|
+
"not a failed attempt",
|
|
1382
|
+
"skills and agents after",
|
|
1383
|
+
"Invoke OpenSpec through",
|
|
1384
|
+
"Remote Control off, the wake task",
|
|
1385
|
+
)
|
|
1386
|
+
|
|
1387
|
+
|
|
1388
|
+
def validate_surfaces_agree_with_code_scenario() -> int:
|
|
1389
|
+
"""Issue #413: what the model reads states what the code does.
|
|
1390
|
+
|
|
1391
|
+
#414 removed the protocol's old stance and the capsule kept it: every
|
|
1392
|
+
task-start still printed "must not continue to another task". The other
|
|
1393
|
+
sentences here contradicted the code they describe — a diagnose-only task
|
|
1394
|
+
the parser refuses unless its Touch is `none`, a completion hook no plugin
|
|
1395
|
+
declares, an authorization list ten names long beside a code list of
|
|
1396
|
+
thirteen. The names are read from `src/core/config.js`, so a name added
|
|
1397
|
+
later without its spec line fails here.
|
|
1398
|
+
"""
|
|
1399
|
+
label = "surfaces-agree-with-code:"
|
|
1400
|
+
with tempfile.TemporaryDirectory(prefix="keel-surfaces-413-") as raw:
|
|
1401
|
+
repo = Path(raw)
|
|
1402
|
+
write_text(repo / "openspec/changes/demo/tasks.md", task_capsule_compact_fixture())
|
|
1403
|
+
started = run_keel(repo, "gate", "task-start", "--change", "demo", "--task", "1.1", "--no-guard", "--json")
|
|
1404
|
+
if started.returncode != 0:
|
|
1405
|
+
report(f"{label} task-start refused the compact fixture.")
|
|
1406
|
+
report((started.stderr or started.stdout).strip())
|
|
1407
|
+
return 1
|
|
1408
|
+
capsule = json.loads(started.stdout).get("contract", {}).get("capsule", {})
|
|
1409
|
+
if "owner" in capsule:
|
|
1410
|
+
report(f"{label} a task that authors no Owner compiled to owner {capsule['owner']!r}.")
|
|
1411
|
+
return 1
|
|
1412
|
+
kept = ["must not change Acceptance", "must not commit", "must not push", "must not sync or archive"]
|
|
1413
|
+
if capsule.get("prohibitions") != kept:
|
|
1414
|
+
report(f"{label} the capsule prohibits {capsule.get('prohibitions')!r}, not {kept!r}.")
|
|
1415
|
+
return 1
|
|
1416
|
+
|
|
1417
|
+
overlays = []
|
|
1418
|
+
for name in ("apply-change", "archive-change", "sync-specs"):
|
|
1419
|
+
overlays.append(ROOT / f".claude/skills/openspec-{name}/SKILL.md")
|
|
1420
|
+
overlays.append(ROOT / f".codex/skills/openspec-{name}/SKILL.md")
|
|
1421
|
+
schemas = [
|
|
1422
|
+
ROOT / "assets/openspec/schemas/keel-spec-driven",
|
|
1423
|
+
ROOT / "openspec/schemas/keel-spec-driven",
|
|
1424
|
+
]
|
|
1425
|
+
required = {
|
|
1426
|
+
ROOT / "AGENTS.md": [
|
|
1427
|
+
"with `Touch: none` and no worktree writes",
|
|
1428
|
+
"a standing authorization in `keel/config.yaml` allows it",
|
|
1429
|
+
"`Verify` checks MUST verify",
|
|
1430
|
+
],
|
|
1431
|
+
ROOT / "assets/bootstrap/AGENTS.md": [
|
|
1432
|
+
"No commit, push, sync, or archive unless the task, the owner, or `keel/config.yaml` authorizes it.",
|
|
1433
|
+
],
|
|
1434
|
+
ROOT / "src/skills/keel-debug-failure/SKILL.md": ["expected rather than a stop"],
|
|
1435
|
+
ROOT / PLUGIN_ROOT / "skills/keel-debug-failure/SKILL.md": ["expected rather than a stop"],
|
|
1436
|
+
ROOT / "bin/keel.js": [],
|
|
1437
|
+
ROOT / "src/core/config.js": [],
|
|
1438
|
+
}
|
|
1439
|
+
for schema in schemas:
|
|
1440
|
+
required[schema / "schema.yaml"] = [
|
|
1441
|
+
"equivalence (which also declares `Base:` and `Fields:`)",
|
|
1442
|
+
"`Resolved here:`",
|
|
1443
|
+
"No hook gates completion",
|
|
1444
|
+
]
|
|
1445
|
+
required[schema / "templates/tasks.md"] = ["equivalence", '"Resolved here:"']
|
|
1446
|
+
for overlay in overlays:
|
|
1447
|
+
required[overlay] = ["Invoke the OpenSpec CLI as `keel openspec"]
|
|
1448
|
+
if "apply" in overlay.as_posix():
|
|
1449
|
+
required[overlay].append("Verify checks prove Acceptance")
|
|
1450
|
+
for surface, sentences in required.items():
|
|
1451
|
+
if not surface.is_file():
|
|
1452
|
+
report(f"{label} {surface.relative_to(ROOT)} is missing, so it cannot be checked.")
|
|
1453
|
+
return 1
|
|
1454
|
+
text = surface.read_text(encoding="utf-8")
|
|
1455
|
+
for phrase in STALE_SURFACE_SENTENCES:
|
|
1456
|
+
if phrase in text:
|
|
1457
|
+
report(f"{label} {surface.relative_to(ROOT)} still says {phrase!r}.")
|
|
1458
|
+
return 1
|
|
1459
|
+
for sentence in sentences:
|
|
1460
|
+
if sentence not in text:
|
|
1461
|
+
report(f"{label} {surface.relative_to(ROOT)} does not say {sentence!r}.")
|
|
1462
|
+
return 1
|
|
1463
|
+
if surface in overlays and text.count("keel openspec …") != 1:
|
|
1464
|
+
report(f"{label} {surface.relative_to(ROOT)} tells the agent to use `keel openspec` {text.count('keel openspec …')} times, not once.")
|
|
1465
|
+
return 1
|
|
1466
|
+
|
|
1467
|
+
help_text = run_keel(ROOT, "--help").stdout
|
|
1468
|
+
for command in ("keel patrol", "keel tick"):
|
|
1469
|
+
if command not in help_text:
|
|
1470
|
+
report(f"{label} keel --help does not name {command!r}.")
|
|
1471
|
+
return 1
|
|
1472
|
+
chat_help = run_keel(ROOT, "chat", "help").stdout
|
|
1473
|
+
if "post-tool-use" not in chat_help:
|
|
1474
|
+
report(f"{label} keel chat help does not name the post-tool-use hook.")
|
|
1475
|
+
return 1
|
|
1476
|
+
|
|
1477
|
+
config = (ROOT / "src/core/config.js").read_text(encoding="utf-8")
|
|
1478
|
+
declared = re.search(r"const STANDING_AUTHORIZATION_ACTIONS = \[(.*?)\];", config, re.S)
|
|
1479
|
+
names = re.findall(r'^\s*"([a-z-]+)",', declared.group(1), re.M) if declared else []
|
|
1480
|
+
if len(names) < 13:
|
|
1481
|
+
report(f"{label} read {len(names)} standing-authorization names from config.js; expected at least 13.")
|
|
1482
|
+
return 1
|
|
1483
|
+
standing = (ROOT / "openspec/specs/keel-standing-authorization/spec.md").read_text(encoding="utf-8")
|
|
1484
|
+
vocabulary = re.search(r"(?s)### Requirement: A repository declares standing authorization in a closed vocabulary\n(.*?)\n#### ", standing)
|
|
1485
|
+
if not vocabulary:
|
|
1486
|
+
report(f"{label} keel-standing-authorization has no closed-vocabulary requirement to read.")
|
|
1487
|
+
return 1
|
|
1488
|
+
for name in names:
|
|
1489
|
+
if f"`{name}`" not in vocabulary.group(1):
|
|
1490
|
+
report(f"{label} keel-standing-authorization does not list `{name}` in its closed vocabulary.")
|
|
1491
|
+
return 1
|
|
1492
|
+
for spec, phrase in (
|
|
1493
|
+
("keel-domain-lenses", "reads only the lens"),
|
|
1494
|
+
("keel-domain-lenses", "no other lens is loaded"),
|
|
1495
|
+
("keel-task-capsule", "current-agent ownership"),
|
|
1496
|
+
):
|
|
1497
|
+
if phrase in (ROOT / f"openspec/specs/{spec}/spec.md").read_text(encoding="utf-8"):
|
|
1498
|
+
report(f"{label} {spec} still says {phrase!r}.")
|
|
1499
|
+
return 1
|
|
1500
|
+
if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
|
|
1501
|
+
report(f"{label} the scenario registry does not include it.")
|
|
1502
|
+
return 1
|
|
1503
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
1504
|
+
return 0
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
COUNT_WORDS = {13: "thirteen", 14: "fourteen", 15: "fifteen", 16: "sixteen"}
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
def readme_cli_problem(readme: Path, exit_label: str, count_phrase) -> str | None:
|
|
1511
|
+
"""What a README fails to state about the CLI, or None (#413).
|
|
1512
|
+
|
|
1513
|
+
Every list is read from the CLI or the code, so a command, flag, or
|
|
1514
|
+
authorization name added later without its README line fails here.
|
|
1515
|
+
"""
|
|
1516
|
+
text = readme.read_text(encoding="utf-8")
|
|
1517
|
+
usage = run_keel(ROOT, "--help").stdout.split("Usage:", 1)[-1].split("\n\n", 1)[0]
|
|
1518
|
+
commands = sorted(set(re.findall(r"^\s*keel ([a-z][a-z-]*)", usage, re.M)))
|
|
1519
|
+
flags = sorted(set(re.findall(r"(?<![\w-])(--[a-z][a-z-]*)", usage)))
|
|
1520
|
+
if len(commands) < 16 or len(flags) < 30:
|
|
1521
|
+
return f"read {len(commands)} commands and {len(flags)} flags from keel --help; expected at least 16 and 30."
|
|
1522
|
+
for command in commands:
|
|
1523
|
+
if f"keel {command}" not in text:
|
|
1524
|
+
return f"{readme.name} does not name `keel {command}`."
|
|
1525
|
+
for flag in flags:
|
|
1526
|
+
if not re.search(r"(?<![\w-])" + re.escape(flag) + r"(?![\w-])", text):
|
|
1527
|
+
return f"{readme.name} does not name `{flag}`."
|
|
1528
|
+
config = (ROOT / "src/core/config.js").read_text(encoding="utf-8")
|
|
1529
|
+
declared = re.search(r"const STANDING_AUTHORIZATION_ACTIONS = \[(.*?)\];", config, re.S)
|
|
1530
|
+
names = re.findall(r'^\s*"([a-z-]+)",', declared.group(1), re.M) if declared else []
|
|
1531
|
+
if len(names) < 13:
|
|
1532
|
+
return f"read {len(names)} standing-authorization names from config.js; expected at least 13."
|
|
1533
|
+
for name in names:
|
|
1534
|
+
if not re.search(r"(?<![\w-])" + re.escape(name) + r"(?![\w-])", text):
|
|
1535
|
+
return f"{readme.name} does not name the standing authorization `{name}`."
|
|
1536
|
+
phrase = count_phrase(len(names))
|
|
1537
|
+
if phrase not in text:
|
|
1538
|
+
return f"{readme.name} does not say {phrase!r}, the count of names config.js accepts."
|
|
1539
|
+
# The line that lists them, wherever else the word appears in prose.
|
|
1540
|
+
exit_lines = [line for line in text.splitlines() if exit_label in line]
|
|
1541
|
+
if not exit_lines:
|
|
1542
|
+
return f"{readme.name} has no line containing {exit_label!r}."
|
|
1543
|
+
listed = max(exit_lines, key=lambda line: sum(f"`{code}`" in line for code in range(5)))
|
|
1544
|
+
for code in range(5):
|
|
1545
|
+
if f"`{code}`" not in listed:
|
|
1546
|
+
return f"{readme.name} does not describe exit code {code} on its {exit_label!r} line."
|
|
1547
|
+
return None
|
|
1548
|
+
|
|
1549
|
+
|
|
1550
|
+
README_STALE_SENTENCES = (
|
|
1551
|
+
"skills and agents follow",
|
|
1552
|
+
"The eleven names",
|
|
1553
|
+
"load only that one lens",
|
|
1554
|
+
"(pick one task)",
|
|
1555
|
+
"`keel --init` writes only",
|
|
1556
|
+
"--doctor | --uninstall [--target <t>] [--dry-run]",
|
|
1557
|
+
"full command and workflow reference",
|
|
1558
|
+
)
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
def validate_readme_states_the_cli_scenario() -> int:
|
|
1562
|
+
"""Issue #413: the English README states what the CLI does."""
|
|
1563
|
+
label = "readme-states-the-cli:"
|
|
1564
|
+
readme = ROOT / "README.md"
|
|
1565
|
+
problem = readme_cli_problem(readme, "Exit codes", lambda n: f"{COUNT_WORDS.get(n, n)} names")
|
|
1566
|
+
if problem:
|
|
1567
|
+
report(f"{label} {problem}")
|
|
1568
|
+
return 1
|
|
1569
|
+
text = readme.read_text(encoding="utf-8")
|
|
1570
|
+
for phrase in README_STALE_SENTENCES:
|
|
1571
|
+
if phrase in text:
|
|
1572
|
+
report(f"{label} README.md still says {phrase!r}.")
|
|
1573
|
+
return 1
|
|
1574
|
+
if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
|
|
1575
|
+
report(f"{label} the scenario registry does not include it.")
|
|
1576
|
+
return 1
|
|
1577
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
1578
|
+
return 0
|
|
1579
|
+
|
|
1580
|
+
|
|
1581
|
+
def validate_readme_zh_matches_english_scenario() -> int:
|
|
1582
|
+
"""Issue #413: the Chinese README is the English one's counterpart.
|
|
1583
|
+
|
|
1584
|
+
It was 355 lines against 1000 and lacked thirteen sections, while the
|
|
1585
|
+
English README called it the full reference. The command and name checks
|
|
1586
|
+
are the English ones; section parity is a heading count, the one
|
|
1587
|
+
structural measure that needs no translation table.
|
|
1588
|
+
"""
|
|
1589
|
+
label = "readme-zh-matches-english:"
|
|
1590
|
+
zh = ROOT / "README.zh-CN.md"
|
|
1591
|
+
problem = readme_cli_problem(zh, "退出码", lambda n: f"{n} 个名字")
|
|
1592
|
+
if problem:
|
|
1593
|
+
report(f"{label} {problem}")
|
|
1594
|
+
return 1
|
|
1595
|
+
english = (ROOT / "README.md").read_text(encoding="utf-8")
|
|
1596
|
+
chinese = zh.read_text(encoding="utf-8")
|
|
1597
|
+
for level in ("## ", "### "):
|
|
1598
|
+
counts = [
|
|
1599
|
+
sum(1 for line in text.splitlines() if line.startswith(level))
|
|
1600
|
+
for text in (english, chinese)
|
|
1601
|
+
]
|
|
1602
|
+
if counts[0] != counts[1]:
|
|
1603
|
+
report(f"{label} README.md has {counts[0]} `{level.strip()}` headings and README.zh-CN.md has {counts[1]}.")
|
|
1604
|
+
return 1
|
|
1605
|
+
if "装配时的 `keel --init`" in chinese:
|
|
1606
|
+
report(f"{label} README.zh-CN.md still names `keel --init` as the one setup command.")
|
|
1607
|
+
return 1
|
|
1608
|
+
if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
|
|
1609
|
+
report(f"{label} the scenario registry does not include it.")
|
|
1610
|
+
return 1
|
|
1611
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
1612
|
+
return 0
|
|
1613
|
+
|
|
1614
|
+
|
|
1615
|
+
def validate_config_documents_in_declaration_order_scenario() -> int:
|
|
1616
|
+
"""Issue #413: the configuration file documents what it says it documents.
|
|
1617
|
+
|
|
1618
|
+
`CONFIG_DECLARATIONS` is "in the order the file documents them", and the
|
|
1619
|
+
file had drifted: owner_language first, patrol twice, executor_tier never.
|
|
1620
|
+
The order is read from the code, so a declaration added there without its
|
|
1621
|
+
block, or a block written out of place, fails here.
|
|
1622
|
+
"""
|
|
1623
|
+
label = "config-documents-in-declaration-order:"
|
|
1624
|
+
source = (ROOT / "src/core/config.js").read_text(encoding="utf-8")
|
|
1625
|
+
declared = re.search(r"const CONFIG_DECLARATIONS = \[(.*?)\];", source, re.S)
|
|
1626
|
+
names = re.findall(r'^\s*"([a-z_]+)",', declared.group(1), re.M) if declared else []
|
|
1627
|
+
if len(names) < 12:
|
|
1628
|
+
report(f"{label} read {len(names)} declarations from config.js; expected at least 12.")
|
|
1629
|
+
return 1
|
|
1630
|
+
config = (ROOT / "keel/config.yaml").read_text(encoding="utf-8")
|
|
1631
|
+
blocks = re.findall(r"^# ([a-z_]+) \(optional\):", config, re.M)
|
|
1632
|
+
if blocks != names:
|
|
1633
|
+
report(f"{label} keel/config.yaml documents {blocks}, not {names} in that order.")
|
|
1634
|
+
return 1
|
|
1635
|
+
if "`chat-reply`, and `push-protected` are the names" not in config:
|
|
1636
|
+
report(f"{label} keel/config.yaml's scoped-name sentence does not name `push-protected`.")
|
|
1637
|
+
return 1
|
|
1638
|
+
updating = (ROOT / "docs/updating.md").read_text(encoding="utf-8")
|
|
1639
|
+
if "skills and agents" in updating.lower():
|
|
1640
|
+
report(f"{label} docs/updating.md still says Claude reloads skills and agents.")
|
|
1641
|
+
return 1
|
|
1642
|
+
for needle in ("config.toml", "E404"):
|
|
1643
|
+
if needle not in updating:
|
|
1644
|
+
report(f"{label} docs/updating.md does not mention {needle!r}.")
|
|
1645
|
+
return 1
|
|
1646
|
+
for name in ("README.md", "README.zh-CN.md"):
|
|
1647
|
+
text = (ROOT / name).read_text(encoding="utf-8")
|
|
1648
|
+
for phrase in ("A clear there keeps no title", "noticed expiry"):
|
|
1649
|
+
if phrase in text:
|
|
1650
|
+
report(f"{label} {name} still says {phrase!r}.")
|
|
1651
|
+
return 1
|
|
1652
|
+
if "keel chat help" not in text:
|
|
1653
|
+
report(f"{label} {name} does not point to `keel chat help` for the full chat command list.")
|
|
1654
|
+
return 1
|
|
1655
|
+
if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
|
|
1656
|
+
report(f"{label} the scenario registry does not include it.")
|
|
1657
|
+
return 1
|
|
1658
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
1659
|
+
return 0
|
|
1660
|
+
|
|
1661
|
+
|
|
1662
|
+
def validate_docs_zh_match_english_scenario() -> int:
|
|
1663
|
+
"""Issue #413: each Chinese doc follows its English page.
|
|
1664
|
+
|
|
1665
|
+
`docs/shift-change.zh-CN.md` had five sections against eight and never
|
|
1666
|
+
mentioned `keel patrol` or `keel tick`. Every Chinese page that exists is
|
|
1667
|
+
checked, so a new one is held from the day it is written.
|
|
1668
|
+
"""
|
|
1669
|
+
label = "docs-zh-match-english:"
|
|
1670
|
+
pages = sorted((ROOT / "docs").glob("*.zh-CN.md"))
|
|
1671
|
+
if not pages:
|
|
1672
|
+
report(f"{label} found no docs/*.zh-CN.md to check.")
|
|
1673
|
+
return 1
|
|
1674
|
+
for zh_path in pages:
|
|
1675
|
+
en_path = zh_path.with_name(zh_path.name.replace(".zh-CN.md", ".md"))
|
|
1676
|
+
if not en_path.is_file():
|
|
1677
|
+
report(f"{label} {zh_path.name} has no English page {en_path.name}.")
|
|
1678
|
+
return 1
|
|
1679
|
+
en = en_path.read_text(encoding="utf-8").splitlines()
|
|
1680
|
+
zh = zh_path.read_text(encoding="utf-8").splitlines()
|
|
1681
|
+
for what, prefix in (("headings", "#"), ("code fences", "```")):
|
|
1682
|
+
counts = [sum(1 for line in lines if line.startswith(prefix)) for lines in (en, zh)]
|
|
1683
|
+
if counts[0] != counts[1]:
|
|
1684
|
+
report(f"{label} {en_path.name} has {counts[0]} {what} and {zh_path.name} has {counts[1]}.")
|
|
1685
|
+
return 1
|
|
1686
|
+
zh_text = "\n".join(zh)
|
|
1687
|
+
for command in sorted(set(re.findall(r"keel [a-z][a-z-]*", "\n".join(en)))):
|
|
1688
|
+
if command not in zh_text:
|
|
1689
|
+
report(f"{label} {zh_path.name} does not name `{command}`, which {en_path.name} names.")
|
|
1690
|
+
return 1
|
|
1691
|
+
slack = (ROOT / "docs/chat-slack-setup.zh-CN.md").read_text(encoding="utf-8")
|
|
1692
|
+
if "编辑和删除" not in slack:
|
|
1693
|
+
report(f"{label} chat-slack-setup.zh-CN.md does not say edits and deletions carry over.")
|
|
1694
|
+
return 1
|
|
1695
|
+
if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
|
|
1696
|
+
report(f"{label} the scenario registry does not include it.")
|
|
1697
|
+
return 1
|
|
1698
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
1699
|
+
return 0
|
|
1700
|
+
|
|
1701
|
+
|
|
1702
|
+
def validate_tdd_strategy_guide_scenario() -> int:
|
|
1703
|
+
"""Issue #389: the skill an executor loads to plan its checks says how to choose.
|
|
1704
|
+
|
|
1705
|
+
The strategy list is read from the parser, not repeated here, so a strategy
|
|
1706
|
+
added later without a selection row fails this scenario instead of passing
|
|
1707
|
+
a list that was never updated. The clauses are the ones the completion gate
|
|
1708
|
+
enforces; before #389 the skill named two of them and `AGENTS.md` the rest.
|
|
1709
|
+
"""
|
|
1710
|
+
label = "tdd-strategy-guide"
|
|
1711
|
+
skill_dir = ROOT / "src/skills/keel-tdd-or-test-first"
|
|
1712
|
+
plugin_dir = ROOT / PLUGIN_ROOT / "skills/keel-tdd-or-test-first"
|
|
1713
|
+
guidance = skill_dir / "guidance.md"
|
|
1714
|
+
if not guidance.is_file():
|
|
1715
|
+
report(f"{label}: keel-tdd-or-test-first has no guidance.md beside its SKILL.md.")
|
|
1716
|
+
return 1
|
|
1717
|
+
contract = (ROOT / "src/core/task-contract.js").read_text(encoding="utf-8")
|
|
1718
|
+
declared = re.search(
|
|
1719
|
+
r"const SUPPORTED_VERIFICATION_STRATEGIES = \[(.*?)\];", contract, re.S
|
|
1720
|
+
)
|
|
1721
|
+
if not declared:
|
|
1722
|
+
report(f"{label}: SUPPORTED_VERIFICATION_STRATEGIES not found in task-contract.js.")
|
|
1723
|
+
return 1
|
|
1724
|
+
strategies = re.findall(r'^\s*"([a-z-]+)",', declared.group(1), re.M)
|
|
1725
|
+
if len(strategies) < 7:
|
|
1726
|
+
report(f"{label}: read {len(strategies)} strategies from the parser; expected at least 7.")
|
|
1727
|
+
return 1
|
|
1728
|
+
rows = [
|
|
1729
|
+
line for line in guidance.read_text(encoding="utf-8").splitlines()
|
|
1730
|
+
if line.startswith("|")
|
|
1731
|
+
]
|
|
1732
|
+
for strategy in strategies:
|
|
1733
|
+
if not any(f"`{strategy}`" in row for row in rows):
|
|
1734
|
+
report(f"{label}: no selection row for {strategy} in the guidance table.")
|
|
1735
|
+
return 1
|
|
1736
|
+
body = (skill_dir / "SKILL.md").read_text(encoding="utf-8")
|
|
1737
|
+
for clause in (
|
|
1738
|
+
"Fails with:",
|
|
1739
|
+
"Detects:",
|
|
1740
|
+
"Measured:",
|
|
1741
|
+
"(regression)",
|
|
1742
|
+
"deferred to C",
|
|
1743
|
+
"artifact",
|
|
1744
|
+
):
|
|
1745
|
+
if clause not in body:
|
|
1746
|
+
report(f"{label}: the skill body does not name {clause!r}.")
|
|
1747
|
+
return 1
|
|
1748
|
+
if "what would make" not in body:
|
|
1749
|
+
report(f"{label}: the skill body does not say a strategy is chosen by what would make the Acceptance false.")
|
|
1750
|
+
return 1
|
|
1751
|
+
for name in ("SKILL.md", "guidance.md"):
|
|
1752
|
+
shipped = plugin_dir / name
|
|
1753
|
+
if not shipped.is_file():
|
|
1754
|
+
report(f"{label}: the plugin has no keel-tdd-or-test-first/{name}.")
|
|
1755
|
+
return 1
|
|
1756
|
+
if shipped.read_bytes() != (skill_dir / name).read_bytes():
|
|
1757
|
+
report(f"{label}: the plugin's keel-tdd-or-test-first/{name} diverges from the canonical source.")
|
|
1758
|
+
return 1
|
|
1759
|
+
if label not in {name for name, _ in registry.SCENARIOS}:
|
|
1760
|
+
report(f"{label}: the scenario registry does not include it.")
|
|
1761
|
+
return 1
|
|
1762
|
+
report(f"{label} scenario passed.")
|
|
1763
|
+
return 0
|
|
1764
|
+
|
|
1765
|
+
|
|
1766
|
+
def validate_external_agents_are_documented_scenario() -> int:
|
|
1767
|
+
"""The command reaches the protocol, the READMEs, and the privacy policy.
|
|
1768
|
+
|
|
1769
|
+
#219: an agent that never reads the README must still learn that external
|
|
1770
|
+
model CLIs are delegates with a compiled brief, so the bootstrap block and
|
|
1771
|
+
this repository's protocol name it. The privacy policy lists what leaves the
|
|
1772
|
+
machine, and handing a repository to codex or dsh is now one of those ways.
|
|
1773
|
+
"""
|
|
1774
|
+
label = "external-agents-are-documented:"
|
|
1775
|
+
|
|
1776
|
+
def flat(path: Path) -> str:
|
|
1777
|
+
return re.sub(r"\s+", " ", path.read_text(encoding="utf-8"))
|
|
1778
|
+
|
|
1779
|
+
protocol = flat(ROOT / "AGENTS.md")
|
|
1780
|
+
if "keel agents brief" not in protocol:
|
|
1781
|
+
report(f"{label} AGENTS.md does not name `keel agents brief`.")
|
|
1782
|
+
return 1
|
|
1783
|
+
if "launches nothing" not in protocol:
|
|
1784
|
+
report(f"{label} AGENTS.md does not say Keel launches nothing.")
|
|
1785
|
+
return 1
|
|
1786
|
+
# The installed bootstrap spends its byte budget only on rules every session
|
|
1787
|
+
# uses; `external_agents:` is inert until declared, as delegation is, so it
|
|
1788
|
+
# reaches an agent where it is declared instead (D9).
|
|
1789
|
+
if "keel agents" in flat(ROOT / "assets/bootstrap/AGENTS.md"):
|
|
1790
|
+
report(f"{label} the bootstrap block names `keel agents`, spending its budget on a "
|
|
1791
|
+
"declaration that is inert until a project makes it.")
|
|
1792
|
+
return 1
|
|
1793
|
+
for path in (ROOT / "README.md", ROOT / "README.zh-CN.md"):
|
|
1794
|
+
text = path.read_text(encoding="utf-8")
|
|
1795
|
+
blocks = re.findall(r"```bash\n(.*?)```", text, re.S)
|
|
1796
|
+
if not any("keel agents" in block for block in blocks):
|
|
1797
|
+
report(f"{label} {path.name} lists no `keel agents` in a command block.")
|
|
1798
|
+
return 1
|
|
1799
|
+
yaml_blocks = re.findall(r"```yaml\n(.*?)```", text, re.S)
|
|
1800
|
+
example = next((block for block in yaml_blocks if "external_agents:" in block), "")
|
|
1801
|
+
if not example:
|
|
1802
|
+
report(f"{label} {path.name} shows no `external_agents:` example.")
|
|
1803
|
+
return 1
|
|
1804
|
+
for key in ("allow:", "egress_deny:"):
|
|
1805
|
+
if key not in example:
|
|
1806
|
+
report(f"{label} {path.name}'s external_agents example has no {key}.")
|
|
1807
|
+
return 1
|
|
1808
|
+
privacy = (ROOT / "PRIVACY.md").read_text(encoding="utf-8")
|
|
1809
|
+
leaves = privacy.split("## What leaves your machine", 1)[-1].split("\n## ", 1)[0]
|
|
1810
|
+
if "External model CLIs" not in leaves:
|
|
1811
|
+
report(f"{label} PRIVACY.md does not list external model CLIs under what leaves the machine.")
|
|
1812
|
+
return 1
|
|
1813
|
+
|
|
1814
|
+
report("external-agents-are-documented scenario passed.")
|
|
1815
|
+
return 0
|