@christang/keel 5.83.0 → 5.84.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/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/plugins/keel/skills/keel-review-checklist/SKILL.md +1 -2
- package/scripts/validate_plugin.py +203 -13
- package/src/core/gates.js +150 -2
- package/src/core/task-contract.js +4 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.84.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.84.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.84.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.84.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",
|
|
@@ -18,9 +18,8 @@ Read the selected OpenSpec proposal, design, specs, tasks, diff, and command evi
|
|
|
18
18
|
## Deterministic gate check
|
|
19
19
|
|
|
20
20
|
- Confirm the appropriate shared Core gate was run and its versioned result is `pass`.
|
|
21
|
-
- Confirm the task's Evidence `Contract` line records the task-start capsule fingerprint and that completion recompiled the same fingerprint; a drift result returns the task to authoring for explicit reauthorization instead of review.
|
|
22
21
|
- A behavioral task's checks must prove observable Acceptance through the public interface, not build-only or shape-only evidence.
|
|
23
|
-
-
|
|
22
|
+
- `task-complete` itself refuses a missing or drifted Contract anchor and missing `.red`/`.green` Evidence; a drift result returns the task to authoring for explicit reauthorization instead of review. What it cannot see is whether the evidence proves anything: evidence-first tasks name their observable proof.
|
|
24
23
|
- A failure message must **name the actual cause** of what it reports. Watch for one condition guarding **two distinct failures** — `if result is None or result["status"] != expected` reports the first failure's message when the second one happened, sending the reader to a place with no problem in it. Split the condition. No gate can judge this: deciding whether a sentence misleads needs a model, so it stays here.
|
|
25
24
|
- When two tasks in the change declared the same Touch set under a red-green strategy — `keel gate task-start` warns about this — ask whether they turned out to be **one behavior** split in half. The tell is that the first task's minimal implementation was wrong in the field, or that the second had no honest red left because the first already made its checks pass. The gate can only see the shape; by completion you can see the outcome, which is the only point at which this is answerable.
|
|
26
25
|
- Scope attribution is now the gate's job by default: `keel gate task-complete` compares the worktree against the dirty set `task-start` recorded and refuses a path outside Touch, so a `pass` is evidence about scope rather than silence about it. Two cases still need you. When the gate reports paths as *unattributed* — no recorded set, because the manifest predates the field or the guard was cleared — nothing was checked and the review is the only scope evidence. And a path already dirty when the task started stays unattributed only while its content matches what was recorded then; if the task changed it again, the gate attributes it — so read the gate's silence about such a path as evidence its content was never touched again, not as an unconditional exemption.
|
|
@@ -38,8 +38,8 @@ REQUIRED_SCRIPTS = [
|
|
|
38
38
|
"scripts/validate_plugin.py",
|
|
39
39
|
]
|
|
40
40
|
|
|
41
|
-
PACKAGE_VERSION = "5.
|
|
42
|
-
PROTOCOL_VERSION = "5.
|
|
41
|
+
PACKAGE_VERSION = "5.84.0"
|
|
42
|
+
PROTOCOL_VERSION = "5.84.0"
|
|
43
43
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
44
44
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
45
45
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -2460,6 +2460,182 @@ def validate_mailbox_claude_hooks_scenario() -> int:
|
|
|
2460
2460
|
return 0
|
|
2461
2461
|
|
|
2462
2462
|
|
|
2463
|
+
def validate_record_derives_skeleton_scenario() -> int:
|
|
2464
|
+
"""Issue #179: `--record` writes the record slots a capsule implies.
|
|
2465
|
+
|
|
2466
|
+
Every slot it writes is a placeholder the gates still refuse as unfilled,
|
|
2467
|
+
so this changes who types the bookkeeping and not what completion needs.
|
|
2468
|
+
"""
|
|
2469
|
+
label = "record-derives-skeleton:"
|
|
2470
|
+
fixture = task_capsule_compact_fixture()
|
|
2471
|
+
no_evidence = fixture.replace(
|
|
2472
|
+
" - Evidence:\n - Contract: pending\n - M1: pending\n", ""
|
|
2473
|
+
)
|
|
2474
|
+
red_green = no_evidence.replace(
|
|
2475
|
+
" - Strategy: evidence-first\n"
|
|
2476
|
+
" - Reason: this is a gate fixture; it exercises contract structure and has no executable behavior that can fail first\n"
|
|
2477
|
+
" - M1: node test.js\n",
|
|
2478
|
+
" - Strategy: vertical-tdd\n"
|
|
2479
|
+
" - M1: node test.js asserts the feature. Fails with: `boom`\n"
|
|
2480
|
+
" - M2 (regression): node old.js stays green\n"
|
|
2481
|
+
" - M3: node edge.js asserts the edge. Fails with: `edge` Detects: `drop the guard` -> `edge`\n",
|
|
2482
|
+
)
|
|
2483
|
+
if red_green == no_evidence:
|
|
2484
|
+
report(f"{label} the fixture's Verify block moved; update this scenario.")
|
|
2485
|
+
return 1
|
|
2486
|
+
expected_slots = [
|
|
2487
|
+
" - M1: pending",
|
|
2488
|
+
" - M1.red: pending",
|
|
2489
|
+
" - M1.green: pending",
|
|
2490
|
+
" - M2: pending",
|
|
2491
|
+
" - M3: pending",
|
|
2492
|
+
" - M3.red: pending",
|
|
2493
|
+
" - M3.green: pending",
|
|
2494
|
+
" - M3.detects: pending",
|
|
2495
|
+
" - Review:",
|
|
2496
|
+
" - Status: pending",
|
|
2497
|
+
" - Acceptance check: pending",
|
|
2498
|
+
" - Scope check: pending",
|
|
2499
|
+
" - Findings: pending",
|
|
2500
|
+
" - Blocker: none",
|
|
2501
|
+
" - Reauthorizations: none",
|
|
2502
|
+
]
|
|
2503
|
+
with tempfile.TemporaryDirectory(prefix="keel-skeleton-") as raw:
|
|
2504
|
+
repo = Path(raw)
|
|
2505
|
+
tasks = repo / "openspec/changes/demo/tasks.md"
|
|
2506
|
+
|
|
2507
|
+
def record(*extra: str) -> tuple[int, dict]:
|
|
2508
|
+
result = run_keel(
|
|
2509
|
+
repo, "gate", "task-start", "--change", "demo", "--task", "1.1",
|
|
2510
|
+
*extra, "--json",
|
|
2511
|
+
)
|
|
2512
|
+
return result.returncode, json.loads(result.stdout)
|
|
2513
|
+
|
|
2514
|
+
write_text(tasks, red_green)
|
|
2515
|
+
code, payload = record("--record", "--no-guard")
|
|
2516
|
+
if code != 0:
|
|
2517
|
+
report(f"{label} --record refused a valid task with no Evidence: {payload.get('problems')!r}")
|
|
2518
|
+
return 1
|
|
2519
|
+
if payload.get("record", {}).get("status") != "recorded":
|
|
2520
|
+
report(f"{label} the outcome was {payload.get('record')!r}, not recorded.")
|
|
2521
|
+
return 1
|
|
2522
|
+
fingerprint = payload["contract"]["fingerprint"]["value"]
|
|
2523
|
+
after = tasks.read_text(encoding="utf-8")
|
|
2524
|
+
before_lines, after_lines = red_green.splitlines(), after.splitlines()
|
|
2525
|
+
added = [line for line in after_lines if line not in before_lines]
|
|
2526
|
+
want = [" - Evidence:", f" - Contract: keel-task-capsule/v1 sha256:{fingerprint}", *expected_slots]
|
|
2527
|
+
if added != want:
|
|
2528
|
+
report(f"{label} --record added {added!r}, expected {want!r}.")
|
|
2529
|
+
return 1
|
|
2530
|
+
if [line for line in before_lines if line not in after_lines]:
|
|
2531
|
+
report(f"{label} --record removed or rewrote a line outside the Evidence it added.")
|
|
2532
|
+
return 1
|
|
2533
|
+
code, again = record("--record", "--no-guard")
|
|
2534
|
+
if code != 0 or tasks.read_text(encoding="utf-8") != after:
|
|
2535
|
+
report(f"{label} a second --record was not byte-identical.")
|
|
2536
|
+
return 1
|
|
2537
|
+
if again.get("record", {}).get("status") != "unchanged":
|
|
2538
|
+
report(f"{label} a second --record reported {again.get('record')!r}, not unchanged.")
|
|
2539
|
+
return 1
|
|
2540
|
+
completion = run_keel(repo, "gate", "task-complete", "--change", "demo", "--task", "1.1", "--json")
|
|
2541
|
+
if completion.returncode == 0:
|
|
2542
|
+
report(f"{label} task-complete accepted a task whose slots were only filled with pending.")
|
|
2543
|
+
return 1
|
|
2544
|
+
|
|
2545
|
+
kept = red_green.replace(
|
|
2546
|
+
" - Stop if:\n",
|
|
2547
|
+
" - Evidence:\n - M1: pass. node test.js printed ok.\n - Stop if:\n",
|
|
2548
|
+
)
|
|
2549
|
+
write_text(tasks, kept)
|
|
2550
|
+
code, payload = record("--record", "--no-guard")
|
|
2551
|
+
text = tasks.read_text(encoding="utf-8")
|
|
2552
|
+
if code != 0:
|
|
2553
|
+
report(f"{label} --record refused a task with a partial Evidence block: {payload.get('problems')!r}")
|
|
2554
|
+
return 1
|
|
2555
|
+
if " - M1: pass. node test.js printed ok." not in text:
|
|
2556
|
+
report(f"{label} --record rewrote an existing concrete M1 line.")
|
|
2557
|
+
return 1
|
|
2558
|
+
if " - M1: pending" in text:
|
|
2559
|
+
report(f"{label} --record added a second M1 slot beside the kept one.")
|
|
2560
|
+
return 1
|
|
2561
|
+
if " - M1.red: pending" not in text:
|
|
2562
|
+
report(f"{label} --record did not add the missing M1.red slot beside the kept M1.")
|
|
2563
|
+
return 1
|
|
2564
|
+
|
|
2565
|
+
write_text(tasks, no_evidence)
|
|
2566
|
+
code, payload = record("--record", "--no-guard")
|
|
2567
|
+
text = tasks.read_text(encoding="utf-8")
|
|
2568
|
+
if code != 0:
|
|
2569
|
+
report(f"{label} --record refused a valid evidence-first task: {payload.get('problems')!r}")
|
|
2570
|
+
return 1
|
|
2571
|
+
if ".red:" in text or ".green:" in text:
|
|
2572
|
+
report(f"{label} an evidence-first task was given .red/.green slots.")
|
|
2573
|
+
return 1
|
|
2574
|
+
|
|
2575
|
+
broken = red_green.replace(" - Strategy: vertical-tdd\n", "")
|
|
2576
|
+
write_text(tasks, broken)
|
|
2577
|
+
code, payload = record("--record")
|
|
2578
|
+
if code == 0:
|
|
2579
|
+
report(f"{label} --record filled slots around a task with no Strategy.")
|
|
2580
|
+
return 1
|
|
2581
|
+
if tasks.read_text(encoding="utf-8") != broken:
|
|
2582
|
+
report(f"{label} a refused --record wrote to tasks.md.")
|
|
2583
|
+
return 1
|
|
2584
|
+
if (repo / "keel/guard.json").exists():
|
|
2585
|
+
report(f"{label} a refused --record wrote the guard manifest.")
|
|
2586
|
+
return 1
|
|
2587
|
+
|
|
2588
|
+
write_text(tasks, fixture.replace(" - M1: pending\n", ""))
|
|
2589
|
+
code, payload = record()
|
|
2590
|
+
messages = [item.get("message", "") for item in payload.get("problems", [])]
|
|
2591
|
+
if code == 0:
|
|
2592
|
+
report(f"{label} task-start without --record accepted a missing M1 slot.")
|
|
2593
|
+
return 1
|
|
2594
|
+
if not any("--record" in message for message in messages):
|
|
2595
|
+
report(f"{label} the evidence-label-mismatch refusal does not name --record: {messages!r}")
|
|
2596
|
+
return 1
|
|
2597
|
+
|
|
2598
|
+
if "record-derives-skeleton" not in {name for name, _ in SCENARIOS}:
|
|
2599
|
+
report(f"{label} scenario is not registered.")
|
|
2600
|
+
return 1
|
|
2601
|
+
report("record-derives-skeleton scenario passed.")
|
|
2602
|
+
return 0
|
|
2603
|
+
|
|
2604
|
+
|
|
2605
|
+
def validate_review_checklist_defers_to_gate_scenario() -> int:
|
|
2606
|
+
"""Issue #179: Review guidance keeps what no gate can judge, and only that.
|
|
2607
|
+
|
|
2608
|
+
`task-complete` refuses a missing or drifted Contract anchor and missing
|
|
2609
|
+
`.red`/`.green` Evidence on its own, so asking the agent to confirm them
|
|
2610
|
+
again is reading cost without a criterion. What stays is the judgment.
|
|
2611
|
+
"""
|
|
2612
|
+
label = "review-checklist-defers-to-gate:"
|
|
2613
|
+
for root in ("src/skills", f"{PLUGIN_ROOT}/skills"):
|
|
2614
|
+
text = (ROOT / root / "keel-review-checklist" / "SKILL.md").read_text(encoding="utf-8")
|
|
2615
|
+
flat = " ".join(text.split())
|
|
2616
|
+
for restated in (
|
|
2617
|
+
"Evidence `Contract` line records the task-start capsule fingerprint",
|
|
2618
|
+
"confirm concrete per-label `.red` and `.green` Evidence exists",
|
|
2619
|
+
):
|
|
2620
|
+
if restated in flat:
|
|
2621
|
+
report(f"{label} {root} keel-review-checklist still restates a gate refusal: {restated!r}")
|
|
2622
|
+
return 1
|
|
2623
|
+
for kept in (
|
|
2624
|
+
"evidence-first tasks",
|
|
2625
|
+
"observable proof",
|
|
2626
|
+
"through the public interface",
|
|
2627
|
+
"not build-only or shape-only",
|
|
2628
|
+
):
|
|
2629
|
+
if kept not in flat:
|
|
2630
|
+
report(f"{label} {root} keel-review-checklist lost the judgment {kept!r}.")
|
|
2631
|
+
return 1
|
|
2632
|
+
if "review-checklist-defers-to-gate" not in {name for name, _ in SCENARIOS}:
|
|
2633
|
+
report(f"{label} scenario is not registered.")
|
|
2634
|
+
return 1
|
|
2635
|
+
report("review-checklist-defers-to-gate scenario passed.")
|
|
2636
|
+
return 0
|
|
2637
|
+
|
|
2638
|
+
|
|
2463
2639
|
def validate_covers_annotation_entry_scenario() -> int:
|
|
2464
2640
|
"""Issue #49 Section 1's fail-open half, owner-decided 2026-08-17: a Covers
|
|
2465
2641
|
entry that opens with a critical-statement identifier and a dash
|
|
@@ -14380,6 +14556,13 @@ def validate_core_gates_scenario() -> int:
|
|
|
14380
14556
|
" - Evidence:\n"
|
|
14381
14557
|
f" - Contract: {anchor}\n"
|
|
14382
14558
|
" - M1: pending\n"
|
|
14559
|
+
" - Review:\n"
|
|
14560
|
+
" - Status: pending\n"
|
|
14561
|
+
" - Acceptance check: pending\n"
|
|
14562
|
+
" - Scope check: pending\n"
|
|
14563
|
+
" - Findings: pending\n"
|
|
14564
|
+
" - Blocker: none\n"
|
|
14565
|
+
" - Reauthorizations: none\n"
|
|
14383
14566
|
" - Report:\n"
|
|
14384
14567
|
" - Summary\n"
|
|
14385
14568
|
)
|
|
@@ -14527,24 +14710,23 @@ def validate_core_gates_scenario() -> int:
|
|
|
14527
14710
|
write_text(record_tasks, record_task("pending").replace(
|
|
14528
14711
|
" - Contract: pending\n", ""
|
|
14529
14712
|
))
|
|
14713
|
+
# Issue #179: a missing anchor is a missing record slot, which
|
|
14714
|
+
# `--record` now derives instead of refusing; refusal is kept for an
|
|
14715
|
+
# authoring error (see `record-derives-skeleton`).
|
|
14530
14716
|
missing_anchor = run_keel(
|
|
14531
14717
|
record_repo, "gate", "task-start",
|
|
14532
|
-
"--change", "demo", "--task", "1.1", "--record", "--json",
|
|
14718
|
+
"--change", "demo", "--task", "1.1", "--record", "--no-guard", "--json",
|
|
14533
14719
|
)
|
|
14534
|
-
if
|
|
14535
|
-
missing_anchor.returncode != 3
|
|
14536
|
-
or not any(
|
|
14537
|
-
problem.get("code") == "record-refused"
|
|
14538
|
-
for problem in json.loads(missing_anchor.stdout).get("problems", [])
|
|
14539
|
-
)
|
|
14540
|
-
or (record_repo / "keel/guard.json").exists()
|
|
14541
|
-
):
|
|
14720
|
+
if missing_anchor.returncode != 0:
|
|
14542
14721
|
report(
|
|
14543
|
-
"core-gates scenario --record with a missing anchor must "
|
|
14544
|
-
"
|
|
14722
|
+
"core-gates scenario --record with a missing anchor must add "
|
|
14723
|
+
"the anchor and pass."
|
|
14545
14724
|
)
|
|
14546
14725
|
report((missing_anchor.stderr or missing_anchor.stdout).strip())
|
|
14547
14726
|
return 1
|
|
14727
|
+
if " - Contract: keel-task-capsule/v1 sha256:" not in record_tasks.read_text(encoding="utf-8"):
|
|
14728
|
+
report("core-gates scenario --record did not write the missing Contract anchor.")
|
|
14729
|
+
return 1
|
|
14548
14730
|
|
|
14549
14731
|
invalid_base = run_keel(
|
|
14550
14732
|
completion_repo,
|
|
@@ -32237,6 +32419,14 @@ SCENARIOS: tuple = (
|
|
|
32237
32419
|
"mailbox-claude-hooks",
|
|
32238
32420
|
validate_mailbox_claude_hooks_scenario,
|
|
32239
32421
|
),
|
|
32422
|
+
(
|
|
32423
|
+
"record-derives-skeleton",
|
|
32424
|
+
validate_record_derives_skeleton_scenario,
|
|
32425
|
+
),
|
|
32426
|
+
(
|
|
32427
|
+
"review-checklist-defers-to-gate",
|
|
32428
|
+
validate_review_checklist_defers_to_gate_scenario,
|
|
32429
|
+
),
|
|
32240
32430
|
(
|
|
32241
32431
|
"covers-annotation-entry",
|
|
32242
32432
|
validate_covers_annotation_entry_scenario,
|
package/src/core/gates.js
CHANGED
|
@@ -401,7 +401,154 @@ function equivalenceEscapeProblems(repo, selection, task, compiled) {
|
|
|
401
401
|
return problems;
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
+
// `--record` derives the record slots a valid capsule implies (issue #179):
|
|
405
|
+
// the Contract anchor, each bare `M<n>`, `.red`/`.green` for every red-green
|
|
406
|
+
// check not tagged `(regression)`, `.detects` where a check declares one, the
|
|
407
|
+
// Review block, and the Blocker and Reauthorizations defaults. All of it
|
|
408
|
+
// followed mechanically from the capsule and was typed by hand. Each slot
|
|
409
|
+
// reads `pending` (or the template's `none`), which every completion gate
|
|
410
|
+
// still refuses as unfilled, so this moves typing, never a verdict. Existing
|
|
411
|
+
// lines are never rewritten, nothing outside the selected task's Evidence is
|
|
412
|
+
// touched, and a task that does not compile apart from its missing slots is
|
|
413
|
+
// left exactly as it was.
|
|
414
|
+
const EVIDENCE_FIELD = /^ {2}- Evidence:\s*$/;
|
|
415
|
+
const TASK_FIELD = /^ {2}- [A-Za-z][A-Za-z /-]+:/;
|
|
416
|
+
|
|
417
|
+
function evidenceSlotKeys(lines) {
|
|
418
|
+
return new Set(
|
|
419
|
+
lines
|
|
420
|
+
.map((line) => line.match(/^ {4}- ([A-Za-z][\w.]*(?: [a-z]+)*):/))
|
|
421
|
+
.filter(Boolean)
|
|
422
|
+
.map((match) => match[1])
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function withEvidenceSlots(content, task, slots) {
|
|
427
|
+
const eol = content.includes("\r\n") ? "\r\n" : "\n";
|
|
428
|
+
const lines = content.split(/\r?\n/);
|
|
429
|
+
const end = task.endLine !== undefined ? task.endLine : lines.length;
|
|
430
|
+
let header = -1;
|
|
431
|
+
for (let cursor = task.line + 1; cursor < end; cursor += 1) {
|
|
432
|
+
if (EVIDENCE_FIELD.test(lines[cursor])) {
|
|
433
|
+
header = cursor;
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
let blockEnd = end;
|
|
438
|
+
if (header >= 0) {
|
|
439
|
+
for (let cursor = header + 1; cursor < end; cursor += 1) {
|
|
440
|
+
if (TASK_FIELD.test(lines[cursor])) {
|
|
441
|
+
blockEnd = cursor;
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const scanFrom = header >= 0 ? header + 1 : end;
|
|
447
|
+
const present = evidenceSlotKeys(lines.slice(scanFrom, blockEnd));
|
|
448
|
+
const added = [];
|
|
449
|
+
for (const slot of slots) {
|
|
450
|
+
if (present.has(slot.key)) continue;
|
|
451
|
+
added.push(...slot.lines);
|
|
452
|
+
}
|
|
453
|
+
if (added.length === 0) return { content, added };
|
|
454
|
+
let insertAt = header >= 0 ? blockEnd : end;
|
|
455
|
+
while (insertAt > task.line + 1 && !lines[insertAt - 1].trim()) insertAt -= 1;
|
|
456
|
+
const insertion = header >= 0 ? added : [" - Evidence:", ...added];
|
|
457
|
+
lines.splice(insertAt, 0, ...insertion);
|
|
458
|
+
return { content: lines.join(eol), added: insertion };
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function basicSlots(task) {
|
|
462
|
+
const verify = field(task, "Verify") || field(task, "Commands");
|
|
463
|
+
const labels = [
|
|
464
|
+
...verify.matchAll(/^\s*-\s*(M[1-9]\d*)\b/gm),
|
|
465
|
+
].map((match) => match[1]);
|
|
466
|
+
return [
|
|
467
|
+
{ key: "Contract", lines: [" - Contract: pending"] },
|
|
468
|
+
...[...new Set(labels)].map((label) => ({
|
|
469
|
+
key: label,
|
|
470
|
+
lines: [` - ${label}: pending`],
|
|
471
|
+
})),
|
|
472
|
+
];
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// The full slot list in template order: Contract, then each check's bare,
|
|
476
|
+
// `.red`, `.green`, and `.detects` slots together, then Review and the logs.
|
|
477
|
+
function capsuleSlots(compiled) {
|
|
478
|
+
const verification = compiled.capsule.verification;
|
|
479
|
+
const redGreen = RED_GREEN_VERIFICATION_STRATEGIES.has(
|
|
480
|
+
verification.strategy.toLowerCase()
|
|
481
|
+
);
|
|
482
|
+
const slots = [{ key: "Contract", lines: [" - Contract: pending"] }];
|
|
483
|
+
for (const command of verification.commands) {
|
|
484
|
+
if (!command.label) continue;
|
|
485
|
+
const keys = [command.label];
|
|
486
|
+
if (redGreen && !command.regression) {
|
|
487
|
+
keys.push(`${command.label}.red`, `${command.label}.green`);
|
|
488
|
+
}
|
|
489
|
+
if (command.detects) keys.push(`${command.label}.detects`);
|
|
490
|
+
for (const key of keys) slots.push({ key, lines: [` - ${key}: pending`] });
|
|
491
|
+
}
|
|
492
|
+
slots.push(
|
|
493
|
+
{
|
|
494
|
+
key: "Review",
|
|
495
|
+
lines: [
|
|
496
|
+
" - Review:",
|
|
497
|
+
" - Status: pending",
|
|
498
|
+
" - Acceptance check: pending",
|
|
499
|
+
" - Scope check: pending",
|
|
500
|
+
" - Findings: pending",
|
|
501
|
+
],
|
|
502
|
+
},
|
|
503
|
+
{ key: "Blocker", lines: [" - Blocker: none"] },
|
|
504
|
+
{ key: "Reauthorizations", lines: [" - Reauthorizations: none"] }
|
|
505
|
+
);
|
|
506
|
+
return slots;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function fillRecordSlots(repo, options) {
|
|
510
|
+
const first = loadSelection(repo, options);
|
|
511
|
+
const original = first.content;
|
|
512
|
+
const tasksPath = first.tasksPath;
|
|
513
|
+
// A trial write of the bare slots only, so the task can compile: the
|
|
514
|
+
// capsule is the authority for everything else, and it compiles from disk.
|
|
515
|
+
const trial = withEvidenceSlots(original, first.selected[0], basicSlots(first.selected[0]));
|
|
516
|
+
if (trial.added.length > 0) fs.writeFileSync(tasksPath, trial.content, "utf8");
|
|
517
|
+
const second = loadSelection(repo, options);
|
|
518
|
+
const compiled = compileTaskContract(repo, second.change, second.selected[0]);
|
|
519
|
+
if (trial.added.length > 0) fs.writeFileSync(tasksPath, original, "utf8");
|
|
520
|
+
if (compiled.diagnostics.length > 0) {
|
|
521
|
+
// The capsule has an authoring error of its own; slots would only hide it.
|
|
522
|
+
return { original, tasksPath, added: [] };
|
|
523
|
+
}
|
|
524
|
+
const full = withEvidenceSlots(original, first.selected[0], capsuleSlots(compiled));
|
|
525
|
+
if (full.added.length > 0) fs.writeFileSync(tasksPath, full.content, "utf8");
|
|
526
|
+
return {
|
|
527
|
+
original,
|
|
528
|
+
tasksPath,
|
|
529
|
+
added: full.added.filter((line) => line !== " - Evidence:"),
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
404
533
|
function taskStart(repo, options) {
|
|
534
|
+
if (!options.record) return taskStartChecked(repo, options);
|
|
535
|
+
const filled = fillRecordSlots(repo, options);
|
|
536
|
+
const result = taskStartChecked(repo, options);
|
|
537
|
+
if (filled.added.length > 0) {
|
|
538
|
+
if (result.status !== "pass") {
|
|
539
|
+
// A refused start writes nothing, derived slots included.
|
|
540
|
+
fs.writeFileSync(filled.tasksPath, filled.original, "utf8");
|
|
541
|
+
} else if (result.record) {
|
|
542
|
+
result.record.filled = filled.added
|
|
543
|
+
.map((line) => line.match(/^\s*- ([^:]+):/))
|
|
544
|
+
.filter((match) => match && !/^(Status|Acceptance check|Scope check|Findings)$/.test(match[1]))
|
|
545
|
+
.map((match) => match[1]);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return result;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function taskStartChecked(repo, options) {
|
|
405
552
|
const selection = loadSelection(repo, options);
|
|
406
553
|
const task = selection.selected[0];
|
|
407
554
|
const compiled = compileTaskContract(repo, selection.change, task);
|
|
@@ -455,8 +602,9 @@ function taskStart(repo, options) {
|
|
|
455
602
|
problem(
|
|
456
603
|
"record-refused",
|
|
457
604
|
"--record needs a \"- Contract:\" Evidence line on the selected "
|
|
458
|
-
+ "task to anchor, and
|
|
459
|
-
+
|
|
605
|
+
+ "task to anchor, and none could be placed, so nothing was "
|
|
606
|
+
+ "written. Check that the task's Evidence field is a "
|
|
607
|
+
+ "two-space-indented \"- Evidence:\" line."
|
|
460
608
|
)
|
|
461
609
|
);
|
|
462
610
|
}
|
|
@@ -561,7 +561,10 @@ function commandLabelProblems(task) {
|
|
|
561
561
|
message:
|
|
562
562
|
`Evidence labels must map one-to-one to Commands; missing: `
|
|
563
563
|
+ `${missing.join(", ") || "none"}; unexpected or duplicate: `
|
|
564
|
-
+ `${unexpected.join(", ") || "none"}
|
|
564
|
+
+ `${unexpected.join(", ") || "none"}.`
|
|
565
|
+
+ (missing.length > 0 && unexpected.length === 0
|
|
566
|
+
? " `keel gate task-start --record` adds the missing record slots."
|
|
567
|
+
: ""),
|
|
565
568
|
});
|
|
566
569
|
}
|
|
567
570
|
}
|