@christang/keel 5.99.3 → 5.99.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.99.3 -->
1
+ <!-- keel:start version=5.99.4 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the only durable authority — never native memory, goals, or transcripts.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.99.3",
3
+ "version": "5.99.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.99.3",
9
+ "version": "5.99.4",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "^1.4.1"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.99.3",
5
+ "version": "5.99.4",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.99.3",
3
+ "version": "5.99.4",
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.99.3",
3
+ "version": "5.99.4",
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",
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
47
47
  "scripts/validate_plugin.py",
48
48
  ]
49
49
 
50
- PACKAGE_VERSION = "5.99.3"
51
- PROTOCOL_VERSION = "5.99.3"
50
+ PACKAGE_VERSION = "5.99.4"
51
+ PROTOCOL_VERSION = "5.99.4"
52
52
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
53
53
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
54
54
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -5469,6 +5469,47 @@ def validate_record_derives_skeleton_scenario() -> int:
5469
5469
  report(f"{label} --record did not add the missing M1.red slot beside the kept M1.")
5470
5470
  return 1
5471
5471
 
5472
+ # Issue #236: added slots land in template order, not at the block's end.
5473
+ def evidence_lines(text: str) -> list[str]:
5474
+ lines = text.splitlines()
5475
+ start = lines.index(" - Evidence:") + 1
5476
+ end = next((i for i in range(start, len(lines)) if not lines[i].startswith(" ")), len(lines))
5477
+ return lines[start:end]
5478
+
5479
+ logs_first = red_green.replace(
5480
+ " - Stop if:\n",
5481
+ " - Evidence:\n - Contract: pending\n - Blocker: none\n - Reauthorizations: none\n - Stop if:\n",
5482
+ )
5483
+ write_text(tasks, logs_first)
5484
+ code, payload = record("--record", "--no-guard")
5485
+ if code != 0:
5486
+ report(f"{label} --record refused a block holding Contract, Blocker and Reauthorizations: "
5487
+ f"{payload.get('problems')!r}")
5488
+ return 1
5489
+ fingerprint = payload["contract"]["fingerprint"]["value"]
5490
+ got = evidence_lines(tasks.read_text(encoding="utf-8"))
5491
+ want = [f" - Contract: keel-task-capsule/v1 sha256:{fingerprint}", *expected_slots]
5492
+ if got != want:
5493
+ report(f"{label} --record over Contract, Blocker and Reauthorizations left the block out of "
5494
+ f"template order: {got!r}, expected {want!r}.")
5495
+ return 1
5496
+ before_review = red_green.replace(
5497
+ " - Stop if:\n",
5498
+ " - Evidence:\n - M1: pass. node test.js printed ok.\n - Review:\n - Status: pending\n"
5499
+ " - Acceptance check: pending\n - Scope check: pending\n - Findings: pending\n"
5500
+ " - Stop if:\n",
5501
+ )
5502
+ write_text(tasks, before_review)
5503
+ code, payload = record("--record", "--no-guard")
5504
+ if code != 0:
5505
+ report(f"{label} --record refused a block holding M1 and Review: {payload.get('problems')!r}")
5506
+ return 1
5507
+ got = evidence_lines(tasks.read_text(encoding="utf-8"))
5508
+ at = got.index(" - M1: pass. node test.js printed ok.")
5509
+ if got[at + 1:at + 3] != [" - M1.red: pending", " - M1.green: pending"]:
5510
+ report(f"{label} --record did not place M1.red and M1.green directly after the kept M1: {got!r}")
5511
+ return 1
5512
+
5472
5513
  write_text(tasks, no_evidence)
5473
5514
  code, payload = record("--record", "--no-guard")
5474
5515
  text = tasks.read_text(encoding="utf-8")
package/src/core/gates.js CHANGED
@@ -414,10 +414,12 @@ function equivalenceEscapeProblems(repo, selection, task, compiled) {
414
414
  const EVIDENCE_FIELD = /^ {2}- Evidence:\s*$/;
415
415
  const TASK_FIELD = /^ {2}- [A-Za-z][A-Za-z /-]+:/;
416
416
 
417
+ const EVIDENCE_SLOT = /^ {4}- ([A-Za-z][\w.]*(?: [a-z]+)*):/;
418
+
417
419
  function evidenceSlotKeys(lines) {
418
420
  return new Set(
419
421
  lines
420
- .map((line) => line.match(/^ {4}- ([A-Za-z][\w.]*(?: [a-z]+)*):/))
422
+ .map((line) => line.match(EVIDENCE_SLOT))
421
423
  .filter(Boolean)
422
424
  .map((match) => match[1])
423
425
  );
@@ -445,17 +447,35 @@ function withEvidenceSlots(content, task, slots) {
445
447
  }
446
448
  const scanFrom = header >= 0 ? header + 1 : end;
447
449
  const present = evidenceSlotKeys(lines.slice(scanFrom, blockEnd));
450
+ if (slots.every((slot) => present.has(slot.key))) return { content, added: [] };
451
+ if (header < 0) {
452
+ let insertAt = end;
453
+ while (insertAt > task.line + 1 && !lines[insertAt - 1].trim()) insertAt -= 1;
454
+ const insertion = [" - Evidence:", ...slots.flatMap((slot) => slot.lines)];
455
+ lines.splice(insertAt, 0, ...insertion);
456
+ return { content: lines.join(eol), added: insertion };
457
+ }
458
+ // Template order (#236): a missing slot goes directly after the last slot
459
+ // already placed, present or just added, or first in the block; present
460
+ // slots never move.
448
461
  const added = [];
462
+ let cursor = scanFrom;
449
463
  for (const slot of slots) {
450
- if (present.has(slot.key)) continue;
464
+ const at = lines.slice(scanFrom, blockEnd).findIndex((line) => {
465
+ const match = line.match(EVIDENCE_SLOT);
466
+ return match && match[1] === slot.key;
467
+ });
468
+ if (at >= 0) {
469
+ cursor = scanFrom + at + 1;
470
+ while (cursor < blockEnd && !EVIDENCE_SLOT.test(lines[cursor]) && /^ {5,}\S/.test(lines[cursor])) cursor += 1;
471
+ continue;
472
+ }
473
+ lines.splice(cursor, 0, ...slot.lines);
451
474
  added.push(...slot.lines);
475
+ cursor += slot.lines.length;
476
+ blockEnd += slot.lines.length;
452
477
  }
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 };
478
+ return { content: lines.join(eol), added };
459
479
  }
460
480
 
461
481
  function basicSlots(task) {