@christang/keel 5.172.0 → 5.173.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.
@@ -51,8 +51,8 @@ REQUIRED_SCRIPTS = [
51
51
  "scripts/validate_plugin.py",
52
52
  ]
53
53
 
54
- PACKAGE_VERSION = "5.172.0"
55
- PROTOCOL_VERSION = "5.172.0"
54
+ PACKAGE_VERSION = "5.173.0"
55
+ PROTOCOL_VERSION = "5.173.0"
56
56
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
57
57
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
58
58
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -80,7 +80,6 @@ CORE_KEEL_SKILLS = {
80
80
  "keel-debug-failure",
81
81
  "keel-handoff",
82
82
  "keel-review-checklist",
83
- "keel-run-single-task-goal",
84
83
  "keel-tdd-or-test-first",
85
84
  }
86
85
  LEGACY_PROFILE_SKILLS = (
@@ -1236,10 +1235,7 @@ def validate_target_surface_scenario() -> int:
1236
1235
  or "native plugin runtime: manual" not in claude_doctor.stdout
1237
1236
  or "Target capabilities (claude):" not in claude_doctor.stdout
1238
1237
  or "gate.change-close: manual" not in claude_doctor.stdout
1239
- or "execution.goal: manual" not in claude_doctor.stdout
1240
- or "helper byteStability: enforced" not in claude_doctor.stdout
1241
- or "helper nestedDelegationPrevention: enforced" not in claude_doctor.stdout
1242
- or "helper execution: manual" not in claude_doctor.stdout
1238
+ or "execution.worktree: manual" not in claude_doctor.stdout
1243
1239
  ):
1244
1240
  report("target-surface scenario Claude doctor did not report full surface.")
1245
1241
  report((claude_doctor.stderr or claude_doctor.stdout).strip())
@@ -1266,10 +1262,7 @@ def validate_target_surface_scenario() -> int:
1266
1262
  or "native plugin runtime: manual" not in codex_doctor.stdout
1267
1263
  or "Target capabilities (codex):" not in codex_doctor.stdout
1268
1264
  or "gate.change-close: manual" not in codex_doctor.stdout
1269
- or "execution.goal: manual" not in codex_doctor.stdout
1270
- or "helper byteStability: enforced" not in codex_doctor.stdout
1271
- or "helper nestedDelegationPrevention: enforced" not in codex_doctor.stdout
1272
- or "helper execution: manual" not in codex_doctor.stdout
1265
+ or "execution.worktree: manual" not in codex_doctor.stdout
1273
1266
  ):
1274
1267
  report("target-surface scenario Codex doctor did not report full surface.")
1275
1268
  report((codex_doctor.stderr or codex_doctor.stdout).strip())
@@ -18050,10 +18043,6 @@ def validate_guard_containment_is_resolved_scenario() -> int:
18050
18043
  looked like a path outside it, and the guard returned before reading the
18051
18044
  manifest at all. Measured 2026-08-02: the same out-of-Touch file was denied
18052
18045
  by its resolved path and allowed through a link to the same directory.
18053
-
18054
- `src/core/helper.js` had the mirror image, calling a path inside the
18055
- worktree external, which is why `native-helper-read-only` was red on macOS
18056
- — where `/tmp` is a link — and green on Linux CI.
18057
18046
  """
18058
18047
  label = "guard-containment-is-resolved"
18059
18048
  with tempfile.TemporaryDirectory(prefix="keel-containment-") as raw:
@@ -18148,38 +18137,6 @@ def validate_guard_containment_is_resolved_scenario() -> int:
18148
18137
  ]):
18149
18138
  return 1
18150
18139
 
18151
- # M4 — the same question, asked by the helper about its baseline.
18152
- def capture(target: Path) -> subprocess.CompletedProcess[str]:
18153
- return run_keel(
18154
- repo, "project", "helper", "--target", "codex",
18155
- "--capture-baseline", "--baseline", str(target), "--json",
18156
- )
18157
-
18158
- inside_via_link = capture(link / "baseline.json")
18159
- if inside_via_link.returncode == 0:
18160
- report(
18161
- f"{label} M4 captured a helper baseline at a path that resolves "
18162
- "inside the worktree, because it was named through a symlink. "
18163
- "The baseline must live outside the repository it snapshots."
18164
- )
18165
- return 1
18166
- if (repo / "baseline.json").exists():
18167
- report(
18168
- f"{label} M4 refused the capture but the baseline file was "
18169
- "written into the repository anyway."
18170
- )
18171
- return 1
18172
- outside = capture(root / "outside.json")
18173
- if outside.returncode != 0:
18174
- report(
18175
- f"{label} M4 refused a baseline that genuinely resolves outside "
18176
- "the worktree, so the containment fix blocks correct use."
18177
- )
18178
- report((outside.stderr or outside.stdout).strip())
18179
- return 1
18180
- if not (root / "outside.json").is_file():
18181
- report(f"{label} M4 reported a capture that wrote no baseline.")
18182
- return 1
18183
18140
  if label not in {name for name, _ in SCENARIOS}:
18184
18141
  report(f"{label}: the scenario registry does not include it.")
18185
18142
  return 1
@@ -22937,11 +22894,7 @@ def validate_target_capability_adapters_scenario() -> int:
22937
22894
  "gate.task-start",
22938
22895
  "gate.task-complete",
22939
22896
  "gate.change-close",
22940
- "execution.goal",
22941
- "execution.task-view",
22942
22897
  "execution.worktree",
22943
- "delegation.context",
22944
- "delegation.return",
22945
22898
  )
22946
22899
  with tempfile.TemporaryDirectory(prefix="keel-capabilities-") as raw_tmp:
22947
22900
  root = Path(raw_tmp)
@@ -23000,14 +22953,8 @@ def validate_target_capability_adapters_scenario() -> int:
23000
22953
  report(doctor.stdout.strip())
23001
22954
  return 1
23002
22955
  # Native target capabilities never claim enforced behavior without
23003
- # runtime evidence; the deterministic Keel Core helper dimensions
23004
- # (byte-stability, nested-delegation prevention) are a separate,
23005
- # legitimately enforced surface reported on their own helper lines.
23006
- native_surface = "\n".join(
23007
- line
23008
- for line in doctor.stdout.splitlines()
23009
- if not line.startswith("helper ")
23010
- )
22956
+ # runtime evidence.
22957
+ native_surface = doctor.stdout
23011
22958
  if "enforced" in native_surface:
23012
22959
  report(
23013
22960
  f"target-capability-adapters {target} invented enforced behavior."
@@ -23378,7 +23325,6 @@ PLUGIN_SKILLS = (
23378
23325
  "keel-debug-failure",
23379
23326
  "keel-handoff",
23380
23327
  "keel-review-checklist",
23381
- "keel-run-single-task-goal",
23382
23328
  "keel-tdd-or-test-first",
23383
23329
  )
23384
23330
 
@@ -27547,8 +27493,6 @@ def validate_native_runtime_projection_scenario() -> int:
27547
27493
  payload.get("contract") != gate_contract
27548
27494
  or projection.get("fingerprint")
27549
27495
  != gate_contract.get("fingerprint")
27550
- or projection.get("helperAuthority")
27551
- != "read-only-evidence-only"
27552
27496
  or projection.get("prohibitions")
27553
27497
  != gate_contract.get("capsule", {}).get("prohibitions")
27554
27498
  ):
@@ -27558,179 +27502,7 @@ def validate_native_runtime_projection_scenario() -> int:
27558
27502
  report(json.dumps(payload, indent=2))
27559
27503
  return 1
27560
27504
 
27561
- unauthorized_goal = run_keel(
27562
- repo,
27563
- "project",
27564
- "--target",
27565
- target,
27566
- "--event",
27567
- "goal",
27568
- "--change",
27569
- "demo",
27570
- "--task",
27571
- "1.1",
27572
- "--json",
27573
- env=env,
27574
- )
27575
- if (
27576
- unauthorized_goal.returncode != 0
27577
- or json.loads(unauthorized_goal.stdout).get("status") != "blocked"
27578
- ):
27579
- report(f"native-runtime-projection {target} enabled goal implicitly.")
27580
- return 1
27581
-
27582
- authorized_task_view = run_keel(
27583
- repo,
27584
- "project",
27585
- "--target",
27586
- target,
27587
- "--event",
27588
- "task-view",
27589
- "--authorize",
27590
- "task-view",
27591
- "--change",
27592
- "demo",
27593
- "--task",
27594
- "1.1",
27595
- "--json",
27596
- env=env,
27597
- )
27598
- if (
27599
- authorized_task_view.returncode != 0
27600
- or json.loads(authorized_task_view.stdout).get("status") != "ready"
27601
- or "[ ] 1.1" not in tasks_path.read_text(encoding="utf-8")
27602
- ):
27603
- report(
27604
- f"native-runtime-projection {target} task view was not one-way."
27605
- )
27606
- return 1
27607
-
27608
- authorized_goal = run_keel(
27609
- repo,
27610
- "project",
27611
- "--target",
27612
- target,
27613
- "--event",
27614
- "goal",
27615
- "--authorize",
27616
- "goal",
27617
- "--change",
27618
- "demo",
27619
- "--task",
27620
- "1.1",
27621
- "--native-complete",
27622
- "--json",
27623
- env=env,
27624
- )
27625
- goal_payload = json.loads(authorized_goal.stdout)
27626
- if (
27627
- authorized_goal.returncode != 0
27628
- or goal_payload.get("status") != "ready"
27629
- or goal_payload.get("projection", {}).get("acceptance")
27630
- != ["observable result"]
27631
- or not goal_payload.get("projection", {}).get("stopBoundary")
27632
- or not any(
27633
- "ignored" in warning.lower()
27634
- for warning in goal_payload.get("warnings", [])
27635
- )
27636
- or "[ ] 1.1" not in tasks_path.read_text(encoding="utf-8")
27637
- ):
27638
- report(
27639
- f"native-runtime-projection {target} authorized goal violated "
27640
- "one-way projection."
27641
- )
27642
- report((authorized_goal.stderr or authorized_goal.stdout).strip())
27643
- return 1
27644
-
27645
- unauthorized_subagent = run_keel(
27646
- repo,
27647
- "project",
27648
- "--target",
27649
- target,
27650
- "--event",
27651
- "subagent-start",
27652
- "--change",
27653
- "demo",
27654
- "--task",
27655
- "1.1",
27656
- "--json",
27657
- env=env,
27658
- )
27659
- if json.loads(unauthorized_subagent.stdout).get("status") != "ready":
27660
- report(
27661
- f"native-runtime-projection {target} requires extra helper activation."
27662
- )
27663
- return 1
27664
-
27665
- authorized_subagent = run_keel(
27666
- repo,
27667
- "project",
27668
- "--target",
27669
- target,
27670
- "--event",
27671
- "subagent-start",
27672
- "--authorize",
27673
- "subagent",
27674
- "--change",
27675
- "demo",
27676
- "--task",
27677
- "1.1",
27678
- "--json",
27679
- env=env,
27680
- )
27681
- subagent_payload = json.loads(authorized_subagent.stdout)
27682
- bounded = subagent_payload.get("projection", {})
27683
- if (
27684
- authorized_subagent.returncode != 0
27685
- or bounded.get("read")
27686
- != subagent_payload.get("contract", {}).get("capsule", {}).get("read")
27687
- or "README.md" not in bounded.get("read", [])
27688
- or "openspec/changes/demo/tasks.md" not in bounded.get("read", [])
27689
- or bounded.get("touch") != ["src/feature.js"]
27690
- or "M1: node test.js" not in bounded.get("evidenceContract", [])
27691
- or not any(
27692
- "must not mark tasks complete" in item
27693
- for item in bounded.get("prohibitions", [])
27694
- )
27695
- ):
27696
- report(
27697
- f"native-runtime-projection {target} subagent context was unbounded."
27698
- )
27699
- report(
27700
- (authorized_subagent.stderr or authorized_subagent.stdout).strip()
27701
- )
27702
- return 1
27703
-
27704
- subagent_return = run_keel(
27705
- repo,
27706
- "project",
27707
- "--target",
27708
- target,
27709
- "--event",
27710
- "subagent-stop",
27711
- "--authorize",
27712
- "subagent",
27713
- "--change",
27714
- "demo",
27715
- "--task",
27716
- "1.1",
27717
- "--native-complete",
27718
- "--json",
27719
- env=env,
27720
- )
27721
- if (
27722
- subagent_return.returncode != 0
27723
- or json.loads(subagent_return.stdout)
27724
- .get("projection", {})
27725
- .get("returnAuthority")
27726
- != "report-and-evidence-only"
27727
- or "[ ] 1.1" not in tasks_path.read_text(encoding="utf-8")
27728
- ):
27729
- report(
27730
- f"native-runtime-projection {target} accepted subagent completion."
27731
- )
27732
- return 1
27733
- completion_after_subagent = run_keel(
27505
+ completion_without_evidence = run_keel(
27734
27506
  repo,
27735
27507
  "gate",
27736
27508
  "task-complete",
@@ -27742,12 +27514,12 @@ def validate_native_runtime_projection_scenario() -> int:
27742
27514
  env=env,
27743
27515
  )
27744
27516
  if (
27745
- completion_after_subagent.returncode != 3
27746
- or json.loads(completion_after_subagent.stdout).get("status")
27517
+ completion_without_evidence.returncode != 3
27518
+ or json.loads(completion_without_evidence.stdout).get("status")
27747
27519
  != "fail"
27748
27520
  ):
27749
27521
  report(
27750
- f"native-runtime-projection {target} subagent result satisfied "
27522
+ f"native-runtime-projection {target} a projection satisfied "
27751
27523
  "task-complete."
27752
27524
  )
27753
27525
  return 1
@@ -27986,9 +27758,6 @@ def validate_native_runtime_projection_scenario() -> int:
27986
27758
  return 0
27987
27759
 
27988
27760
 
27989
- NATIVE_GOAL_VERSION = "keel-native-goal/v1"
27990
-
27991
-
27992
27761
  def _goal_tasks_file(blocks: list[str]) -> str:
27993
27762
  return "# Tasks\n\n## Invalidates\n\n- None.\n\n" + "\n\n".join(blocks) + "\n"
27994
27763
 
@@ -28075,311 +27844,6 @@ def _goal_task_block(
28075
27844
  return "\n".join(lines)
28076
27845
 
28077
27846
 
28078
- def validate_native_goal_projection_scenario() -> int:
28079
- with tempfile.TemporaryDirectory(prefix="keel-native-goal-") as raw_tmp:
28080
- root = Path(raw_tmp)
28081
- goals: dict[str, dict] = {}
28082
- for target in ("codex", "claude"):
28083
- repo = root / target
28084
- repo.mkdir()
28085
- env = dict(os.environ)
28086
- if target == "codex":
28087
- env["CODEX_HOME"] = str(root / "codex-home")
28088
- if run_keel(repo, "--install", "--target", target, env=env).returncode != 0:
28089
- report("native-goal-projection %s install failed." % target)
28090
- return 1
28091
- write_text(
28092
- repo / "openspec/changes/sample-change/tasks.md",
28093
- _goal_tasks_file([_goal_task_block(strategy="vertical-tdd")]),
28094
- )
28095
- # A native "already complete" signal must never be treated as authority.
28096
- write_text(
28097
- repo / (".%s/transcripts/session.json" % target),
28098
- '{"complete": true}\n',
28099
- )
28100
- before = snapshot_files(repo)
28101
- projected = run_keel(
28102
- repo, "project", "goal",
28103
- "--target", target,
28104
- "--change", "sample-change",
28105
- "--task", "1.1",
28106
- "--json",
28107
- env=env,
28108
- )
28109
- if projected.returncode != 0:
28110
- report("native-goal-projection %s did not compile a ready goal." % target)
28111
- report((projected.stderr or projected.stdout).strip())
28112
- return 1
28113
- payload = json.loads(projected.stdout)
28114
- goal = payload.get("goal") or {}
28115
- gate = run_keel(
28116
- repo, "gate", "task-start",
28117
- "--change", "sample-change", "--task", "1.1", "--no-guard",
28118
- "--json",
28119
- env=env,
28120
- )
28121
- fingerprint = json.loads(gate.stdout).get("contract", {}).get("fingerprint", {})
28122
- if gate.returncode != 0 or not fingerprint:
28123
- report("native-goal-projection %s could not compile the gate fingerprint." % target)
28124
- return 1
28125
- if (
28126
- payload.get("version") != NATIVE_GOAL_VERSION
28127
- or payload.get("status") != "ready"
28128
- or payload.get("target") != target
28129
- or goal.get("version") != NATIVE_GOAL_VERSION
28130
- or goal.get("change") != "sample-change"
28131
- or goal.get("task") != "1.1"
28132
- or goal.get("fingerprint") != fingerprint
28133
- or goal.get("objective") != "Deliver one bounded behavior"
28134
- or goal.get("acceptance") != ["Observable result is proven by M1."]
28135
- or goal.get("commands") != ["M1: node test.js"]
28136
- or goal.get("verificationStrategy") != "vertical-tdd"
28137
- or goal.get("touch") != ["src/feature.js"]
28138
- or goal.get("ownership") != "current-agent-sole-writer"
28139
- or goal.get("terminalStates") != ["complete", "blocked", "paused"]
28140
- or not goal.get("stopBoundary")
28141
- or not goal.get("condition")
28142
- or goal.get("authorizationEvidence", {}).get("fingerprint")
28143
- != fingerprint.get("value")
28144
- ):
28145
- report("native-goal-projection %s payload was incomplete." % target)
28146
- report(json.dumps(payload, indent=2))
28147
- return 1
28148
- if "task-complete passes" not in goal.get("condition", ""):
28149
- report("native-goal-projection %s omitted the terminal completion condition." % target)
28150
- return 1
28151
- # The projection is disposable: no Keel-owned goal/cursor state is written.
28152
- if before != snapshot_files(repo):
28153
- report("native-goal-projection %s mutated durable state." % target)
28154
- return 1
28155
- if target == "claude" and goal.get("conditionLength", 0) > 4000:
28156
- report("native-goal-projection claude exceeded the 4,000-character budget.")
28157
- return 1
28158
- goals[target] = goal
28159
-
28160
- # Codex and Claude normalize to the same semantic fields.
28161
- def _semantic(goal: dict) -> dict:
28162
- copy = dict(goal)
28163
- copy.pop("target", None)
28164
- copy.pop("authorizationEvidence", None)
28165
- return copy
28166
-
28167
- if _semantic(goals["codex"]) != _semantic(goals["claude"]):
28168
- report("native-goal-projection codex and claude diverged on semantic fields.")
28169
- return 1
28170
-
28171
- # Rejections never write task, goal, or session state.
28172
- repo = root / "codex"
28173
- env = dict(os.environ)
28174
- env["CODEX_HOME"] = str(root / "codex-home")
28175
-
28176
- def _reject(args: list[str], label: str) -> bool:
28177
- before = snapshot_files(repo)
28178
- result = run_keel(repo, "project", "goal", *args, "--json", env=env)
28179
- if result.returncode == 0:
28180
- report("native-goal-projection accepted %s." % label)
28181
- return False
28182
- payload = json.loads(result.stdout)
28183
- if payload.get("status") != "blocked" or payload.get("goal") is not None:
28184
- report("native-goal-projection %s was not a clean block." % label)
28185
- return False
28186
- if before != snapshot_files(repo):
28187
- report("native-goal-projection %s mutated state." % label)
28188
- return False
28189
- return True
28190
-
28191
- # Unsupported OpenCode target.
28192
- if not _reject(
28193
- ["--target", "opencode", "--change", "sample-change", "--task", "1.1"],
28194
- "opencode target",
28195
- ):
28196
- return 1
28197
- # Missing explicit task selection.
28198
- if not _reject(
28199
- ["--target", "codex", "--change", "sample-change"],
28200
- "missing task selection",
28201
- ):
28202
- return 1
28203
- # Task-group / ambiguous selection (a section id, not one executable task).
28204
- if not _reject(
28205
- ["--target", "codex", "--change", "sample-change", "--task", "1"],
28206
- "task-group selection",
28207
- ):
28208
- return 1
28209
-
28210
- # A completed task never re-activates.
28211
- write_text(
28212
- repo / "openspec/changes/sample-change/tasks.md",
28213
- _goal_tasks_file(
28214
- [
28215
- _goal_task_block(task_id="1.1", checked=True, filled=True),
28216
- _goal_task_block(task_id="1.2", title="Second bounded behavior"),
28217
- ]
28218
- ),
28219
- )
28220
- if not _reject(
28221
- ["--target", "codex", "--change", "sample-change", "--task", "1.1"],
28222
- "completed task",
28223
- ):
28224
- return 1
28225
-
28226
- # An invalid task-start contract never compiles a goal.
28227
- write_text(
28228
- repo / "openspec/changes/sample-change/tasks.md",
28229
- _goal_tasks_file([_goal_task_block(strategy="teleport")]),
28230
- )
28231
- if not _reject(
28232
- ["--target", "codex", "--change", "sample-change", "--task", "1.1"],
28233
- "invalid task-start contract",
28234
- ):
28235
- return 1
28236
-
28237
- # A projection that could not fit executable authority on Claude is refused
28238
- # rather than silently truncated; Codex, without the limit, still compiles.
28239
- huge = ("Acceptance " + ("A" * 4200) + " is proven by M1.",)
28240
- oversized = _goal_tasks_file([_goal_task_block(acceptance=huge, strategy="vertical-tdd")])
28241
- write_text(repo / "openspec/changes/sample-change/tasks.md", oversized)
28242
- write_text((root / "claude") / "openspec/changes/sample-change/tasks.md", oversized)
28243
- claude_over = run_keel(
28244
- root / "claude", "project", "goal",
28245
- "--target", "claude",
28246
- "--change", "sample-change", "--task", "1.1", "--json",
28247
- env=dict(os.environ),
28248
- )
28249
- claude_payload = json.loads(claude_over.stdout)
28250
- if claude_over.returncode == 0 or claude_payload.get("status") != "blocked":
28251
- report("native-goal-projection claude accepted an oversized condition.")
28252
- return 1
28253
- if "4,000" not in " ".join(claude_payload.get("reasons", [])) and "4000" not in " ".join(
28254
- claude_payload.get("reasons", [])
28255
- ):
28256
- report("native-goal-projection claude blocked without citing the character budget.")
28257
- return 1
28258
- codex_over = run_keel(
28259
- repo, "project", "goal",
28260
- "--target", "codex",
28261
- "--change", "sample-change", "--task", "1.1", "--json",
28262
- env=env,
28263
- )
28264
- if codex_over.returncode != 0 or json.loads(codex_over.stdout).get("status") != "ready":
28265
- report("native-goal-projection codex rejected a valid oversized-for-claude condition.")
28266
- return 1
28267
-
28268
- report("native-goal-projection scenario passed.")
28269
- return 0
28270
-
28271
-
28272
- NATIVE_TASKS_VIEW_VERSION = "keel-native-tasks/v1"
28273
-
28274
-
28275
- def validate_native_tasks_view_scenario() -> int:
28276
- with tempfile.TemporaryDirectory(prefix="keel-native-tasks-") as raw_tmp:
28277
- repo = Path(raw_tmp) / "repo"
28278
- repo.mkdir()
28279
- write_text(
28280
- repo / "openspec/changes/sample-change/tasks.md",
28281
- _goal_tasks_file(
28282
- [
28283
- _goal_task_block(
28284
- task_id="1.1", checked=True, filled=True,
28285
- strategy="vertical-tdd",
28286
- ),
28287
- _goal_task_block(
28288
- task_id="1.2", title="Second bounded behavior",
28289
- strategy="vertical-tdd",
28290
- ),
28291
- ]
28292
- ),
28293
- )
28294
-
28295
- # E1: the view compiles the whole checklist without writing anything.
28296
- before = snapshot_files(repo)
28297
- compiled = run_keel(
28298
- repo, "project", "tasks",
28299
- "--target", "claude", "--change", "sample-change", "--json",
28300
- )
28301
- if compiled.returncode != 0:
28302
- report("native-tasks-view did not compile a ready view.")
28303
- report((compiled.stderr or compiled.stdout).strip())
28304
- return 1
28305
- payload = json.loads(compiled.stdout)
28306
- view = payload.get("view") or {}
28307
- gate = run_keel(
28308
- repo, "gate", "task-start",
28309
- "--change", "sample-change", "--task", "1.2", "--no-guard", "--json",
28310
- )
28311
- fingerprint = json.loads(gate.stdout).get("contract", {}).get("fingerprint", {})
28312
- if gate.returncode != 0 or not fingerprint:
28313
- report("native-tasks-view could not compile the gate fingerprint.")
28314
- return 1
28315
- if (
28316
- payload.get("version") != NATIVE_TASKS_VIEW_VERSION
28317
- or payload.get("status") != "ready"
28318
- or payload.get("target") != "claude"
28319
- or payload.get("source", {}).get("authority") != "OpenSpec"
28320
- or view.get("version") != NATIVE_TASKS_VIEW_VERSION
28321
- or view.get("change") != "sample-change"
28322
- or view.get("tasks") != [
28323
- {
28324
- "id": "1.1",
28325
- "title": "Deliver one bounded behavior",
28326
- "checked": True,
28327
- },
28328
- {
28329
- "id": "1.2",
28330
- "title": "Second bounded behavior",
28331
- "checked": False,
28332
- },
28333
- ]
28334
- or view.get("defaultTask") != "1.2"
28335
- or view.get("fingerprint") != fingerprint
28336
- or view.get("mirroring") != "current-agent-manual"
28337
- ):
28338
- report("native-tasks-view payload was incomplete.")
28339
- report(json.dumps(payload, indent=2))
28340
- return 1
28341
- if before != snapshot_files(repo):
28342
- report("native-tasks-view mutated durable state.")
28343
- return 1
28344
-
28345
- # Non-Claude targets are refused without writing anything.
28346
- for target in ("codex", "opencode"):
28347
- refused = run_keel(
28348
- repo, "project", "tasks",
28349
- "--target", target, "--change", "sample-change", "--json",
28350
- )
28351
- if refused.returncode == 0:
28352
- report("native-tasks-view accepted the %s target." % target)
28353
- return 1
28354
- refusal = json.loads(refused.stdout)
28355
- if refusal.get("status") != "blocked" or refusal.get("view") is not None:
28356
- report("native-tasks-view %s refusal was not a clean block." % target)
28357
- return 1
28358
- if before != snapshot_files(repo):
28359
- report("native-tasks-view %s refusal mutated state." % target)
28360
- return 1
28361
-
28362
- # The view projects a change checklist, never one task selection.
28363
- singled = run_keel(
28364
- repo, "project", "tasks",
28365
- "--target", "claude", "--change", "sample-change", "--task", "1.2",
28366
- )
28367
- if singled.returncode == 0:
28368
- report("native-tasks-view accepted a --task selection.")
28369
- return 1
28370
-
28371
- readme = (ROOT / "README.zh-CN.md").read_text(encoding="utf-8")
28372
- if "keel project tasks" not in readme:
28373
- report("native-tasks-view: README lacks the tasks-view command.")
28374
- return 1
28375
- if "native-tasks-view" not in {name for name, _ in SCENARIOS}:
28376
- report("native-tasks-view: the scenario registry does not include it.")
28377
- return 1
28378
-
28379
- report("native-tasks-view scenario passed.")
28380
- return 0
28381
-
28382
-
28383
27847
  def validate_verification_layering_docs_scenario() -> int:
28384
27848
  en = (ROOT / "README.md").read_text(encoding="utf-8")
28385
27849
  for needle in (
@@ -29526,158 +28990,6 @@ def validate_triage_admits_from_the_repository_scenario() -> int:
29526
28990
  return 0
29527
28991
 
29528
28992
 
29529
- def validate_delegation_declaration_scenario() -> int:
29530
- """Who runs a task is a declaration, never an inference from its size.
29531
-
29532
- The tier names a capability the work requires. It is never derived from
29533
- Touch size, diff size, or apparent difficulty, because that is the agent's
29534
- guess about difficulty — the judgement 5.7.0 already refused for triage.
29535
- """
29536
-
29537
- def declare(repo: Path, body: str | None) -> None:
29538
- (repo / "keel").mkdir(parents=True, exist_ok=True)
29539
- text = "fast_check: echo check\n"
29540
- if body is not None:
29541
- text += body
29542
- (repo / "keel" / "config.yaml").write_text(text, encoding="utf-8")
29543
-
29544
- # Two distinct failures live here — the reader threw, or it returned
29545
- # something that is not JSON — and they send a reader to different places.
29546
- # Collapsing both into one `None` would report whichever message the caller
29547
- # happened to write, which is the defect the review checklist names.
29548
- def resolve(repo: Path, label: str) -> dict | None:
29549
- probe = subprocess.run(
29550
- [
29551
- "node", "-e",
29552
- "const {readDelegationPolicy}=require(process.argv[1]);"
29553
- "process.stdout.write("
29554
- "JSON.stringify(readDelegationPolicy(process.argv[2])));",
29555
- str(ROOT / "src/core/config.js"),
29556
- str(repo),
29557
- ],
29558
- text=True, encoding="utf-8", capture_output=True, check=False,
29559
- )
29560
- if probe.returncode != 0:
29561
- report(f"delegation: reading the {label} repo threw.")
29562
- report((probe.stderr or probe.stdout).strip())
29563
- return None
29564
- try:
29565
- return json.loads(probe.stdout)
29566
- except json.JSONDecodeError:
29567
- report(
29568
- f"delegation: the {label} repo returned non-JSON: "
29569
- f"{probe.stdout!r}"
29570
- )
29571
- return None
29572
-
29573
- with tempfile.TemporaryDirectory(prefix="keel-delegation-") as raw_tmp:
29574
- root = Path(raw_tmp)
29575
-
29576
- # M1 — a declared tier resolves; absence in any of its three shapes
29577
- # leaves delegation unauthorized.
29578
- declared = root / "declared"
29579
- declared.mkdir()
29580
- declare(declared, "delegation:\n tier: standard\n")
29581
- resolved = resolve(declared, "declared")
29582
- if resolved is None:
29583
- return 1
29584
- if resolved.get("tier") != "standard":
29585
- report(f"delegation: a declared tier did not resolve: {resolved}")
29586
- return 1
29587
- if resolved.get("declared") is not True:
29588
- report(f"delegation: a declared block did not report declared: {resolved}")
29589
- return 1
29590
-
29591
- for label, body in (
29592
- ("absent", None),
29593
- ("empty", "delegation:\n"),
29594
- ("other-keys-only", "triage:\n - auto\n"),
29595
- ):
29596
- silent = root / f"silent-{label}"
29597
- silent.mkdir()
29598
- declare(silent, body)
29599
- quiet = resolve(silent, label)
29600
- if quiet is None:
29601
- return 1
29602
- if quiet.get("tier") is not None:
29603
- report(f"delegation: the {label} repo resolved a tier: {quiet}")
29604
- return 1
29605
- if quiet.get("declared") is not False:
29606
- report(f"delegation: the {label} repo reported a declaration: {quiet}")
29607
- return 1
29608
-
29609
- # M2 — an unrecognized tier is reported by name, carries the accepted
29610
- # set so a caller can name it too, and authorizes nothing.
29611
- typo = root / "typo"
29612
- typo.mkdir()
29613
- declare(typo, "delegation:\n tier: turbo\n")
29614
- rejected = resolve(typo, "unrecognized-tier")
29615
- if rejected is None:
29616
- return 1
29617
- if rejected.get("tier") is not None:
29618
- report(f"delegation: an unrecognized tier still resolved: {rejected}")
29619
- return 1
29620
- if "turbo" not in (rejected.get("unknown") or []):
29621
- report(f"delegation: the offending entry is not named: {rejected}")
29622
- return 1
29623
- accepted = rejected.get("accepted") or []
29624
- for name in ("routine", "standard", "deep"):
29625
- if name not in accepted:
29626
- report(f"delegation: the accepted tier {name} is not reported: {rejected}")
29627
- return 1
29628
- # The vocabulary is closed, so a name outside it must not appear.
29629
- if len(accepted) != 3:
29630
- report(f"delegation: the accepted set is not the closed three: {rejected}")
29631
- return 1
29632
-
29633
- # M3 — `authorize:` is not a delegation channel. Listing `delegate`
29634
- # there is reported against that block's own closed set, and delegation
29635
- # stays unauthorized because it is a different declaration entirely.
29636
- misplaced = root / "misplaced"
29637
- misplaced.mkdir()
29638
- declare(misplaced, "authorize:\n - commit\n - delegate\n")
29639
- standing = subprocess.run(
29640
- [
29641
- "node", "-e",
29642
- "const c=require(process.argv[1]);"
29643
- "process.stdout.write(JSON.stringify({"
29644
- "standing:c.readStandingAuthorization(process.argv[2]),"
29645
- "delegation:c.readDelegationPolicy(process.argv[2]),"
29646
- "actions:c.STANDING_AUTHORIZATION_ACTIONS}));",
29647
- str(ROOT / "src/core/config.js"),
29648
- str(misplaced),
29649
- ],
29650
- text=True, encoding="utf-8", capture_output=True, check=False,
29651
- )
29652
- if standing.returncode != 0:
29653
- report("delegation: the misplaced-entry repo could not be read.")
29654
- report((standing.stderr or standing.stdout).strip())
29655
- return 1
29656
- try:
29657
- both = json.loads(standing.stdout)
29658
- except json.JSONDecodeError:
29659
- report(f"delegation: the misplaced-entry probe returned no JSON: {standing.stdout!r}")
29660
- return 1
29661
- if "delegate" not in (both["standing"].get("unknown") or []):
29662
- report(f"delegation: `delegate` was not reported by authorize: {both['standing']}")
29663
- return 1
29664
- if both["standing"].get("declared"):
29665
- report(f"delegation: a rejected authorize block still granted actions: {both['standing']}")
29666
- return 1
29667
- if "delegate" in both["actions"]:
29668
- report("delegation: `delegate` leaked into the authorize vocabulary.")
29669
- return 1
29670
- if both["delegation"].get("declared") is not False:
29671
- report(f"delegation: authorize granted a delegation: {both['delegation']}")
29672
- return 1
29673
- if both["delegation"].get("tier") is not None:
29674
- report(f"delegation: authorize resolved a tier: {both['delegation']}")
29675
- return 1
29676
-
29677
- report("delegation-declaration scenario passed.")
29678
- return 0
29679
-
29680
-
29681
28993
  def validate_delegation_resident_text_scenario() -> int:
29682
28994
  """The resident protocol, the config header, and both templates agree.
29683
28995
 
@@ -29752,9 +29064,6 @@ def validate_delegation_resident_text_scenario() -> int:
29752
29064
  if header_problem:
29753
29065
  report(f"delegation-resident-text: {header_problem}")
29754
29066
  return 1
29755
- if "delegation" not in cfg:
29756
- report("delegation-resident-text: the config header does not document delegation.")
29757
- return 1
29758
29067
 
29759
29068
  # M2 — both task templates state the new default, and the source and its
29760
29069
  # installed copy stay byte-identical.
@@ -29762,14 +29071,13 @@ def validate_delegation_resident_text_scenario() -> int:
29762
29071
  installed = ROOT / "openspec/schemas/keel-spec-driven/templates/tasks.md"
29763
29072
  for path in (source, installed):
29764
29073
  body = flat(path)
29765
- # The helper clause stays true and is deliberately not removed — a
29766
- # helper is still read-only. What was wrong was the sentence stopping
29767
- # there, so the assertion is that it now continues.
29768
- if re.sub(r"\s+", " ", "helpers stay read-only/evidence-only") not in body:
29769
- report(f"delegation-resident-text: {path.relative_to(ROOT)} dropped the helper default.")
29074
+ # Since #414 the template states the subagent sentence and the default
29075
+ # continuation, and no longer limits helpers or delegates.
29076
+ if re.sub(r"\s+", " ", "subagent is the model's choice, treated as the main agent is") not in body:
29077
+ report(f"delegation-resident-text: {path.relative_to(ROOT)} does not state the subagent default.")
29770
29078
  return 1
29771
- if re.sub(r"\s+", " ", "matching active guard") not in body:
29772
- report(f"delegation-resident-text: {path.relative_to(ROOT)} does not state the implementation guard boundary.")
29079
+ if "cross-task continuation stay unauthorized" in body:
29080
+ report(f"delegation-resident-text: {path.relative_to(ROOT)} still says continuing needs authorization.")
29773
29081
  return 1
29774
29082
  if source.read_bytes() != installed.read_bytes():
29775
29083
  report("delegation-resident-text: the template source and its installed copy diverged.")
@@ -29860,128 +29168,6 @@ def validate_delegation_overlay_scenario() -> int:
29860
29168
  return 0
29861
29169
 
29862
29170
 
29863
- def validate_delegation_never_weakens_scenario() -> int:
29864
- """Declaring who runs a task changes nothing about proving it was done.
29865
-
29866
- Same shape as the standing-authorization and precedent inertness
29867
- scenarios, and for the same reason: every check passes when two
29868
- repositories agree, so a declaration that silently failed to load would
29869
- make each comparison trivially true. The positive control asserts the
29870
- difference exists before asserting it is inert.
29871
- """
29872
-
29873
- complete_task = (
29874
- "- [ ] 1.1 Behavior\n"
29875
- " - Covers:\n"
29876
- " - E1: public behavior\n"
29877
- " - Touch:\n"
29878
- " - src/feature.js\n"
29879
- " - Verify:\n"
29880
- " - Strategy: evidence-first\n"
29881
- " - Reason: this is a gate fixture; it exercises contract structure and has no executable behavior that can fail first\n"
29882
- " - M1: node test.js proves the public behavior\n"
29883
- " - Evidence:\n"
29884
- " - Contract: pending\n"
29885
- " - M1: node test.js printed ok\n"
29886
- " - Review:\n"
29887
- " - Status: pass\n"
29888
- " - Acceptance check: reviewed\n"
29889
- " - Scope check: reviewed\n"
29890
- " - Findings: none\n"
29891
- " - Blocker: none\n"
29892
- )
29893
- missing_evidence_task = complete_task.replace(
29894
- " - M1: node test.js printed ok\n", " - M1: pending\n"
29895
- )
29896
-
29897
- def gate(repo: Path, stage: str) -> dict | None:
29898
- result = run_keel(
29899
- repo, "gate", stage, "--change", "demo", "--task", "1.1",
29900
- "--json", "--no-guard",
29901
- )
29902
- try:
29903
- payload = json.loads(result.stdout)
29904
- except json.JSONDecodeError:
29905
- report(f"delegation-never-weakens: {stage} returned no JSON: {result.stdout!r}")
29906
- return None
29907
- # The fingerprint legitimately differs between the two repositories,
29908
- # because a declared delegation is part of the compiled capsule. What
29909
- # must not differ is the verdict or the problems.
29910
- return {
29911
- "status": payload.get("status"),
29912
- "problems": [p.get("code") for p in (payload.get("problems") or [])],
29913
- }
29914
-
29915
- def build(root: Path, name: str, config: str, task: str) -> Path:
29916
- repo = root / name
29917
- repo.mkdir()
29918
- write_gate_fixture(repo, task)
29919
- write_authorize_config(repo, config)
29920
- return repo
29921
-
29922
- declaring = "fast_check: echo c\ndelegation:\n tier: standard\n"
29923
- silent = "fast_check: echo c\n"
29924
-
29925
- with tempfile.TemporaryDirectory(prefix="keel-delinert-") as raw_tmp:
29926
- root = Path(raw_tmp)
29927
-
29928
- # Positive control — the declaration reaches the capsule at all. If it
29929
- # did not, every comparison below would pass for the wrong reason.
29930
- control = build(root, "control", declaring, complete_task)
29931
- probe = run_keel(
29932
- control, "gate", "task-start", "--change", "demo", "--task", "1.1",
29933
- "--json", "--no-guard",
29934
- )
29935
- capsule = json.loads(probe.stdout)["contract"]["capsule"]
29936
- if (capsule.get("delegation") or {}).get("tier") != "standard":
29937
- report(
29938
- "delegation-never-weakens: the declaration never reached the "
29939
- f"capsule, so inertness would be trivially true: {capsule.get('delegation')}"
29940
- )
29941
- return 1
29942
-
29943
- # M1 — identical verdicts and problem sets, passing and failing alike.
29944
- for label, task in (("passing", complete_task), ("failing", missing_evidence_task)):
29945
- loud = build(root, f"loud-{label}", declaring, task)
29946
- quiet = build(root, f"quiet-{label}", silent, task)
29947
- for stage in ("task-start", "task-complete"):
29948
- a = gate(loud, stage)
29949
- b = gate(quiet, stage)
29950
- if a is None or b is None:
29951
- return 1
29952
- if a != b:
29953
- report(
29954
- f"delegation-never-weakens: {stage} differed on the {label} "
29955
- f"task: declaring={a} silent={b}"
29956
- )
29957
- return 1
29958
- # And the failing case must actually fail, or "identical" is a
29959
- # statement about two passes and proves nothing about refusals.
29960
- failed = gate(loud, "task-complete")
29961
- if label == "failing" and failed and failed["status"] == "pass":
29962
- report("delegation-never-weakens: the failing fixture passed, so the comparison is empty.")
29963
- return 1
29964
-
29965
- # M2 — context selection and triage are unchanged.
29966
- for stage_args, key in ((("context",), "nextAction"), (("triage", "--labels", "auto"), "status")):
29967
- loud = build(root, f"loud-{key}", declaring + "triage:\n - auto\n", complete_task)
29968
- quiet = build(root, f"quiet-{key}", silent + "triage:\n - auto\n", complete_task)
29969
- outs = []
29970
- for repo in (loud, quiet):
29971
- result = run_keel(repo, *stage_args, "--json")
29972
- try:
29973
- outs.append(json.loads(result.stdout).get(key))
29974
- except json.JSONDecodeError:
29975
- report(f"delegation-never-weakens: {stage_args[0]} returned no JSON: {result.stdout!r}")
29976
- return 1
29977
- if outs[0] != outs[1]:
29978
- report(f"delegation-never-weakens: {stage_args[0]} differed: {outs[0]} != {outs[1]}")
29979
- return 1
29980
-
29981
- report("delegation-never-weakens scenario passed.")
29982
- return 0
29983
-
29984
-
29985
29171
  def validate_delegation_guard_binds_scenario() -> int:
29986
29172
  """The guard binds a delegated writer identically, and always did.
29987
29173
 
@@ -30113,476 +29299,6 @@ def validate_delegation_guard_binds_scenario() -> int:
30113
29299
  return 0
30114
29300
 
30115
29301
 
30116
- def validate_delegation_goal_budget_scenario() -> int:
30117
- """The delegation fields live inside the activation budget, not beside it.
30118
-
30119
- A field that never reaches the condition cannot overflow it, so asserting
30120
- the refusal means first asserting the fields are actually carried.
30121
- """
30122
-
30123
- def goal(repo: Path) -> dict | None:
30124
- result = run_keel(
30125
- repo, "project", "goal", "--target", "claude",
30126
- "--change", "demo", "--task", "1.1", "--json",
30127
- )
30128
- try:
30129
- payload = json.loads(result.stdout)
30130
- except json.JSONDecodeError:
30131
- report(f"delegation-goal-budget: goal returned no JSON: {result.stdout!r}")
30132
- report((result.stderr or "").strip())
30133
- return None
30134
- # Two shapes share this command. A compiled goal is nested under
30135
- # `goal`; a refusal carries `goal: null` with the reason on the
30136
- # envelope. Reading only one of them would report a refusal as a
30137
- # missing field, which is a different problem in a different place.
30138
- nested = payload.get("goal") or {}
30139
- return {
30140
- **nested,
30141
- "status": payload.get("status"),
30142
- "reasons": payload.get("reasons") or [],
30143
- }
30144
-
30145
- def task(padding: str = "") -> str:
30146
- return (
30147
- "- [ ] 1.1 Behavior\n"
30148
- " - Covers:\n"
30149
- " - E1: public behavior\n"
30150
- " - Touch:\n"
30151
- " - src/feature.js\n"
30152
- + padding
30153
- + " - Verify:\n"
30154
- " - Strategy: evidence-first\n"
30155
- " - Reason: this is a gate fixture; it exercises contract structure and has no executable behavior that can fail first\n"
30156
- " - M1: node test.js proves the public behavior\n"
30157
- " - Evidence:\n"
30158
- " - Contract: pending\n"
30159
- " - M1: pending\n"
30160
- " - Review:\n"
30161
- " - Status: pending\n"
30162
- " - Acceptance check: pending\n"
30163
- " - Scope check: pending\n"
30164
- " - Findings: pending\n"
30165
- " - Blocker: none\n"
30166
- )
30167
-
30168
- with tempfile.TemporaryDirectory(prefix="keel-delbudget-") as raw_tmp:
30169
- root = Path(raw_tmp)
30170
-
30171
- # M1 — the declared tier reaches the compiled condition.
30172
- fits = root / "fits"
30173
- fits.mkdir()
30174
- write_gate_fixture(fits, task())
30175
- write_authorize_config(fits, "fast_check: echo c\ndelegation:\n tier: routine\n")
30176
- compiled = goal(fits)
30177
- if compiled is None:
30178
- return 1
30179
- if compiled.get("status") != "ready":
30180
- report(f"delegation-goal-budget: a fitting goal did not compile: {compiled.get('reasons')}")
30181
- return 1
30182
- condition = compiled.get("condition") or ""
30183
- if "routine" not in condition:
30184
- report("delegation-goal-budget: the declared tier is not in the goal condition.")
30185
- return 1
30186
-
30187
- # M1 — pushed past the budget, activation refuses and names it. The
30188
- # padding is Touch paths, so the overflow comes from real capsule
30189
- # content rather than from a string invented for the test.
30190
- over = root / "over"
30191
- over.mkdir()
30192
- padding = "".join(f" - src/generated/module_{i:03d}_long_enough_to_count.js\n" for i in range(90))
30193
- write_gate_fixture(over, task(padding))
30194
- write_authorize_config(over, "fast_check: echo c\ndelegation:\n tier: routine\n")
30195
- refused = goal(over)
30196
- if refused is None:
30197
- return 1
30198
- if refused.get("status") != "blocked":
30199
- length = len(refused.get("condition") or "")
30200
- report(f"delegation-goal-budget: an over-budget goal was not refused (condition {length} chars).")
30201
- return 1
30202
- reason = " ".join(refused.get("reasons") or [])
30203
- if "4000" not in reason:
30204
- report(f"delegation-goal-budget: the refusal does not name the budget: {reason}")
30205
- return 1
30206
- # Nothing is dropped to make it fit: the refusal is the whole response,
30207
- # and no truncated condition is offered in its place.
30208
- if refused.get("condition"):
30209
- report("delegation-goal-budget: a condition was still offered alongside the refusal.")
30210
- return 1
30211
-
30212
- report("delegation-goal-budget scenario passed.")
30213
- return 0
30214
-
30215
-
30216
- def validate_delegation_sole_authority_scenario() -> int:
30217
- """The invariant is restated, not removed.
30218
-
30219
- Its purpose was never that one process performs the writes — it was that
30220
- one party is answerable for them. A delegate writes inside a boundary that
30221
- authority already defined, and acquires none of the owned decisions.
30222
- """
30223
-
30224
- canonical = ROOT / "src/skills/keel-run-single-task-goal/SKILL.md"
30225
- packaged = ROOT / "plugins/keel/skills/keel-run-single-task-goal/SKILL.md"
30226
- claude = ROOT / "plugins/keel/agents/keel-single-task-goal-claude.md"
30227
- codex = ROOT / "plugins/keel/agents/keel-single-task-goal-codex.md"
30228
- goal = ROOT / "src/core/goal.js"
30229
- for path in (canonical, packaged, claude, codex, goal):
30230
- if not path.exists():
30231
- report(f"delegation-sole-authority: missing {path.relative_to(ROOT)}")
30232
- return 1
30233
-
30234
- def flat(path: Path) -> str:
30235
- return re.sub(r"\s+", " ", path.read_text(encoding="utf-8"))
30236
-
30237
- # M1 — the restatement, in the canonical skill and in the goal projection
30238
- # the adapters actually read.
30239
- for path in (canonical, goal):
30240
- text = flat(path)
30241
- if re.sub(r"\s+", " ", "sole holder of write authority") not in text:
30242
- report(f"delegation-sole-authority: {path.name} does not restate the invariant.")
30243
- return 1
30244
- if re.sub(r"\s+", " ", "re-runs each") not in text:
30245
- report(f"delegation-sole-authority: {path.name} does not say the current agent re-runs the checks.")
30246
- return 1
30247
-
30248
- # M1 — the stop list refuses an undeclared delegation and no longer
30249
- # refuses a declared one outright.
30250
- skill_text = flat(canonical)
30251
- if re.sub(r"\s+", " ", "matching active guard") not in skill_text:
30252
- report("delegation-sole-authority: the stop list omits guarded task authority.")
30253
- return 1
30254
- if re.sub(r"\s+", " ", "any request to delegate implementation to another agent") in skill_text:
30255
- report("delegation-sole-authority: the stop list still refuses every delegation outright.")
30256
- return 1
30257
-
30258
- # M1 — both adapters carry it, and neither still advertises read-only
30259
- # helpers as the whole of what a subagent may do.
30260
- for path in (claude, codex):
30261
- text = flat(path)
30262
- if re.sub(r"\s+", " ", "write authority") not in text:
30263
- report(f"delegation-sole-authority: {path.name} does not carry the restatement.")
30264
- return 1
30265
- if re.sub(r"\s+", " ", "read-only subagent helpers only") in text:
30266
- report(f"delegation-sole-authority: {path.name} still says read-only helpers only.")
30267
- return 1
30268
- if "matching active guard" not in text or "host policy" not in text.lower():
30269
- report(f"delegation-sole-authority: {path.name} omits guard or host boundary.")
30270
- return 1
30271
-
30272
- # M2 — the canonical source and its distribution copy stay byte-identical.
30273
- if canonical.read_bytes() != packaged.read_bytes():
30274
- report("delegation-sole-authority: the canonical and packaged skills diverged.")
30275
- return 1
30276
-
30277
- # M3 — a native evaluator declaring success still completes nothing.
30278
- for path in (canonical, claude, codex):
30279
- text = flat(path)
30280
- if "never" not in text or "complete" not in text:
30281
- report(f"delegation-sole-authority: {path.name} lost its evaluator-success rule.")
30282
- return 1
30283
-
30284
- report("delegation-sole-authority scenario passed.")
30285
- return 0
30286
-
30287
-
30288
- def validate_model_chosen_subagents_scenario() -> int:
30289
- label = "model-chosen-subagents:"
30290
- with tempfile.TemporaryDirectory(prefix="keel-model-subagents-") as raw:
30291
- repo = Path(raw)
30292
- write_gate_fixture(repo, standing_authorization_task())
30293
- def project(*extra: str) -> dict:
30294
- result = run_keel(repo, "project", "--target", "codex",
30295
- "--event", "subagent-start", "--change", "demo", "--task", "1.1", "--json", *extra)
30296
- return json.loads(result.stdout)
30297
- helper = project()
30298
- if helper.get("status") != "ready":
30299
- report(f"{label} ordinary helper still requires activation: {helper.get('reasons')}")
30300
- return 1
30301
- if helper["projection"].get("subagentMode") != "helper" or helper["projection"].get("delegation"):
30302
- report(f"{label} helper posture grants delegation")
30303
- return 1
30304
- write_authorize_config(repo, "delegation:\n tier: turbo\n")
30305
- if project().get("status") != "ready":
30306
- report(f"{label} helper depends on implementation tier metadata")
30307
- return 1
30308
- write_authorize_config(repo, "fast_check: echo ok\n")
30309
- if project("--subagent-mode", "implementation").get("status") == "ready":
30310
- report(f"{label} unguarded implementation allowed")
30311
- return 1
30312
- started = run_keel(repo, "gate", "task-start", "--change", "demo", "--task", "1.1", "--record", "--json")
30313
- if json.loads(started.stdout).get("status") != "pass":
30314
- report(f"{label} valid task did not start: {started.stdout}")
30315
- return 1
30316
- delegate = project("--subagent-mode", "implementation")
30317
- if delegate.get("status") != "ready":
30318
- report(f"{label} guarded implementation requires tier: {delegate.get('reasons')}")
30319
- return 1
30320
- brief = delegate["projection"]
30321
- if brief.get("delegation", {}).get("writeBoundary") != ["src/feature.js"] or brief["delegation"].get("tier") is not None:
30322
- report(f"{label} delegate boundary or absent tier incorrect")
30323
- return 1
30324
- if not all(any(term in p for p in brief["prohibitions"]) for term in ["Acceptance", "commit", "mark tasks complete", "task execution records", "Evidence", "Review"]):
30325
- report(f"{label} ownership prohibitions lost")
30326
- return 1
30327
- manifest_path = repo / "keel/guard.json"
30328
- saved = manifest_path.read_bytes()
30329
- manifest_path.write_text("{}")
30330
- if project().get("status") != "ready":
30331
- report(f"{label} malformed implementation guard blocked read-only help")
30332
- return 1
30333
- if project("--subagent-mode", "implementation").get("status") == "ready":
30334
- report(f"{label} malformed guard allowed implementation")
30335
- return 1
30336
- manifest_path.write_bytes(saved)
30337
- manifest = json.loads(saved)
30338
- manifest["fingerprint"]["value"] = "0" * 64
30339
- manifest_path.write_text(json.dumps(manifest))
30340
- if project("--subagent-mode", "implementation").get("status") == "ready":
30341
- report(f"{label} drifted guard allowed implementation")
30342
- return 1
30343
- manifest_path.write_bytes(saved)
30344
- manifest = json.loads(saved)
30345
- manifest["touch"].append("src/outside.js")
30346
- manifest_path.write_text(json.dumps(manifest))
30347
- if project("--subagent-mode", "implementation").get("status") == "ready":
30348
- report(f"{label} widened manifest Touch allowed implementation")
30349
- return 1
30350
- manifest = json.loads(saved)
30351
- manifest["task"] = "9.9"
30352
- manifest_path.write_text(json.dumps(manifest))
30353
- if project("--subagent-mode", "implementation").get("status") == "ready":
30354
- report(f"{label} different task guard allowed implementation")
30355
- return 1
30356
- manifest_path.write_bytes(saved)
30357
- shutil.copytree(repo / "openspec/changes/demo", repo / "openspec/changes/other")
30358
- other_start = run_keel(repo, "gate", "task-start", "--change", "other", "--task", "1.1", "--record", "--json")
30359
- if json.loads(other_start.stdout).get("status") != "pass":
30360
- report(f"{label} other task guard fixture did not start")
30361
- return 1
30362
- mismatch = project("--subagent-mode", "implementation")
30363
- if mismatch.get("status") == "ready":
30364
- report(f"{label} active guard for another owner allowed implementation")
30365
- return 1
30366
- if "matching" not in " ".join(mismatch.get("reasons", [])):
30367
- report(f"{label} other-owner refusal did not name guard mismatch")
30368
- return 1
30369
- manifest_path.write_bytes(saved)
30370
- task_path = repo / "openspec/changes/demo/tasks.md"
30371
- task_before = task_path.read_text()
30372
- task_path.write_text(task_before.replace("src/feature.js", "src/other.js"))
30373
- if project("--subagent-mode", "implementation").get("status") == "ready":
30374
- report(f"{label} authority drift allowed implementation")
30375
- return 1
30376
- task_path.write_text(task_before)
30377
- returned = run_keel(repo, "project", "--event", "subagent-stop", "--subagent-mode", "implementation", "--native-complete", "--change", "demo", "--task", "1.1", "--json")
30378
- returned_payload = json.loads(returned.stdout)
30379
- if task_path.read_text() != task_before:
30380
- report(f"{label} delegate completion modified task authority or records")
30381
- return 1
30382
- if returned_payload.get("projection", {}).get("returnAuthority") != "report-and-evidence-only":
30383
- report(f"{label} delegate return did not remain evidence-only")
30384
- return 1
30385
- goal = run_keel(repo, "project", "--event", "goal", "--change", "demo", "--task", "1.1", "--json")
30386
- if json.loads(goal.stdout).get("status") != "blocked":
30387
- report(f"{label} goal activation became implicit")
30388
- return 1
30389
- configured = repo / "configured"
30390
- configured.mkdir()
30391
- write_gate_fixture(configured, standing_authorization_task())
30392
- write_authorize_config(configured, "delegation:\n tier: deep\n")
30393
- explicit = run_keel(configured, "project", "--event", "subagent-start", "--authorize", "subagent", "--subagent-mode", "helper", "--change", "demo", "--task", "1.1", "--json")
30394
- payload = json.loads(explicit.stdout)
30395
- if payload.get("status") != "ready" or payload["projection"].get("delegation"):
30396
- report(f"{label} explicit helper became writer due to tier metadata")
30397
- return 1
30398
- for name,task,config in [
30399
- ("bad-task-tier", standing_authorization_task().replace(" - Covers:", " - Delegation: turbo\n - Covers:"), ""),
30400
- ("bad-config-tier", standing_authorization_task(), "delegation:\n tier: turbo\n"),
30401
- ("plan-first", standing_authorization_task().replace(" - Covers:", " - Mode: plan-first\n - Covers:"), ""),
30402
- ("diagnose-only", standing_authorization_task().replace(" - Covers:", " - Mode: diagnose-only\n - Covers:").replace(" - src/feature.js", " - none"), ""),
30403
- ("repo-action", standing_authorization_task().replace(" - Covers:", " - Mode: repo-action\n - Covers:").replace(" - src/feature.js", " - none"), ""),
30404
- ]:
30405
- other = repo / name
30406
- other.mkdir()
30407
- write_gate_fixture(other, task)
30408
- write_authorize_config(other, config)
30409
- result = run_keel(other, "project", "--event", "subagent-start", "--change", "demo", "--task", "1.1", "--json")
30410
- if json.loads(result.stdout).get("status") != "ready":
30411
- report(f"{label} read-only helper refused for {name}: {result.stdout}")
30412
- return 1
30413
- result = run_keel(other, "project", "--event", "subagent-start", "--subagent-mode", "implementation", "--change", "demo", "--task", "1.1", "--json")
30414
- rejected = json.loads(result.stdout)
30415
- if rejected.get("status") == "ready":
30416
- report(f"{label} implementation allowed for {name}")
30417
- return 1
30418
- expected = "turbo" if "tier" in name else "implementation task"
30419
- if expected not in " ".join(rejected.get("reasons", [])):
30420
- report(f"{label} {name} refusal named wrong cause: {rejected.get('reasons')}")
30421
- return 1
30422
- report("model-chosen-subagents scenario passed.")
30423
- return 0
30424
-
30425
-
30426
- def validate_delegation_projection_scenario() -> int:
30427
- """The projection Keel already publishes carries the delegation, and
30428
- refuses where the preconditions for one do not hold.
30429
-
30430
- No second carrier is built: the host spawns the subagent, and this is the
30431
- one-way view of OpenSpec it is handed.
30432
- """
30433
-
30434
- def project(repo: Path, *extra: str) -> dict | None:
30435
- result = run_keel(
30436
- repo, "project", "--target", "claude",
30437
- "--event", "subagent-start", "--authorize", "subagent",
30438
- "--change", "demo", "--task", "1.1", "--json", *extra,
30439
- )
30440
- try:
30441
- return json.loads(result.stdout)
30442
- except json.JSONDecodeError:
30443
- report(f"delegation-projection: project returned no JSON: {result.stdout!r}")
30444
- report((result.stderr or "").strip())
30445
- return None
30446
-
30447
- def guard_manifest(repo: Path) -> None:
30448
- contract = run_keel(
30449
- repo, "gate", "task-start", "--change", "demo",
30450
- "--task", "1.1", "--json", "--no-guard",
30451
- )
30452
- fingerprint = json.loads(contract.stdout)["contract"]["fingerprint"]["value"]
30453
- authority = repo / "openspec/changes/demo/tasks.md"
30454
- write_text(
30455
- repo / "keel/guard.json",
30456
- json.dumps({
30457
- "schema": "keel-write-guard/v1",
30458
- "change": "demo",
30459
- "task": "1.1",
30460
- "fingerprint": {"algorithm": "sha256", "value": fingerprint},
30461
- "touch": ["src/feature.js"],
30462
- "authority": [{
30463
- "path": "openspec/changes/demo/tasks.md",
30464
- "sha256": hashlib.sha256(authority.read_bytes()).hexdigest(),
30465
- }],
30466
- }, indent=2) + "\n",
30467
- )
30468
-
30469
- with tempfile.TemporaryDirectory(prefix="keel-delproj-") as raw_tmp:
30470
- root = Path(raw_tmp)
30471
-
30472
- # M1 — a declaring repository with an active manifest projects the
30473
- # write boundary and the declared tier.
30474
- ready = root / "ready"
30475
- ready.mkdir()
30476
- write_gate_fixture(ready, standing_authorization_task())
30477
- write_authorize_config(ready, "fast_check: echo c\ndelegation:\n tier: deep\n")
30478
- guard_manifest(ready)
30479
- got = project(ready)
30480
- if got is None:
30481
- return 1
30482
- if got.get("status") != "ready":
30483
- report(f"delegation-projection: a ready delegation did not project: {got.get('reasons')}")
30484
- return 1
30485
- projection = got.get("projection") or {}
30486
- delegation = projection.get("delegation")
30487
- if delegation is None:
30488
- report(f"delegation-projection: the brief carries no delegation: {sorted(projection)}")
30489
- return 1
30490
- if delegation.get("tier") != "deep":
30491
- report(f"delegation-projection: the declared tier is not carried: {delegation}")
30492
- return 1
30493
- if not projection.get("touch"):
30494
- report("delegation-projection: the brief carries no write boundary.")
30495
- return 1
30496
- note = json.dumps(delegation)
30497
- if "select" not in note or "observe" not in note:
30498
- report(
30499
- "delegation-projection: the brief does not say Keel neither "
30500
- f"selects nor observes a model: {delegation}"
30501
- )
30502
- return 1
30503
-
30504
- # M2 — no manifest refuses, and the refusal names what is missing.
30505
- (ready / "keel" / "guard.json").unlink()
30506
- unguarded = project(ready)
30507
- if unguarded is None:
30508
- return 1
30509
- if unguarded.get("status") == "ready":
30510
- report("delegation-projection: delegation projected with no active manifest.")
30511
- return 1
30512
- reasons = " ".join(unguarded.get("reasons") or [])
30513
- if "guard" not in reasons or "task-start" not in reasons:
30514
- report(f"delegation-projection: the refusal does not name the manifest: {reasons}")
30515
- return 1
30516
-
30517
- # M2 — an unprovidable tier refuses and reports the alternatives
30518
- # rather than quietly running at a tier nobody declared.
30519
- typo = root / "typo"
30520
- typo.mkdir()
30521
- write_gate_fixture(typo, standing_authorization_task())
30522
- write_authorize_config(typo, "fast_check: echo c\ndelegation:\n tier: turbo\n")
30523
- guard_manifest(typo)
30524
- bad = project(typo)
30525
- if bad is None:
30526
- return 1
30527
- if bad.get("status") == "ready":
30528
- report("delegation-projection: an unrecognized tier still projected.")
30529
- return 1
30530
- bad_reasons = " ".join(bad.get("reasons") or [])
30531
- if "turbo" not in bad_reasons:
30532
- report(f"delegation-projection: the refusal does not name the tier: {bad_reasons}")
30533
- return 1
30534
- for name in ("routine", "standard", "deep"):
30535
- if name not in bad_reasons:
30536
- report(f"delegation-projection: the refusal omits accepted tier {name}: {bad_reasons}")
30537
- return 1
30538
-
30539
- # M3 — a silent repository still projects, without a delegation, and
30540
- # the stop side still returns evidence-only.
30541
- silent = root / "silent"
30542
- silent.mkdir()
30543
- write_gate_fixture(silent, standing_authorization_task())
30544
- write_authorize_config(silent, "fast_check: echo c\n")
30545
- guard_manifest(silent)
30546
- plain = project(silent)
30547
- if plain is None:
30548
- return 1
30549
- if plain.get("status") != "ready":
30550
- report(f"delegation-projection: a silent repository stopped projecting: {plain.get('reasons')}")
30551
- return 1
30552
- if (plain.get("projection") or {}).get("delegation") is not None:
30553
- report("delegation-projection: a silent repository projected a delegation.")
30554
- return 1
30555
- stop = run_keel(
30556
- silent, "project", "--target", "claude",
30557
- "--event", "subagent-stop", "--authorize", "subagent",
30558
- "--change", "demo", "--task", "1.1", "--json",
30559
- )
30560
- try:
30561
- stopped = json.loads(stop.stdout)
30562
- except json.JSONDecodeError:
30563
- report(f"delegation-projection: subagent-stop returned no JSON: {stop.stdout!r}")
30564
- return 1
30565
- if (stopped.get("projection") or {}).get("returnAuthority") != "report-and-evidence-only":
30566
- report(f"delegation-projection: the stop side lost its return authority: {stopped.get('projection')}")
30567
- return 1
30568
- unauthorized = run_keel(
30569
- silent, "project", "--target", "claude",
30570
- "--event", "subagent-start", "--change", "demo",
30571
- "--task", "1.1", "--json",
30572
- )
30573
- try:
30574
- refused = json.loads(unauthorized.stdout)
30575
- except json.JSONDecodeError:
30576
- report(f"delegation-projection: unauthorized start returned no JSON: {unauthorized.stdout!r}")
30577
- return 1
30578
- if refused.get("status") != "ready":
30579
- report("delegation-projection: ordinary helper required extra authorization.")
30580
- return 1
30581
-
30582
- report("delegation-projection scenario passed.")
30583
- return 0
30584
-
30585
-
30586
29302
  def validate_native_capability_scope_scenario() -> int:
30587
29303
  """A capability the target provides natively is not Keel's to build.
30588
29304
 
@@ -30643,107 +29359,6 @@ def validate_native_capability_scope_scenario() -> int:
30643
29359
  return 0
30644
29360
 
30645
29361
 
30646
- def validate_delegation_inheritance_scenario() -> int:
30647
- """A task keeps what it authored and inherits only where it authored none.
30648
-
30649
- The capsule names the source of an inherited entry, so a tier the
30650
- repository supplied is never mistaken for one this task decided.
30651
- """
30652
-
30653
- def capsule(repo: Path) -> dict | None:
30654
- result = run_keel(
30655
- repo, "gate", "task-start",
30656
- "--change", "demo", "--task", "1.1", "--json", "--no-guard",
30657
- )
30658
- try:
30659
- payload = json.loads(result.stdout)
30660
- except json.JSONDecodeError:
30661
- report(f"delegation-inheritance: task-start returned no JSON: {result.stdout!r}")
30662
- report((result.stderr or "").strip())
30663
- return None
30664
- capsule_value = (payload.get("contract") or {}).get("capsule")
30665
- if capsule_value is None:
30666
- report(f"delegation-inheritance: task-start returned no capsule: {payload}")
30667
- return None
30668
- return capsule_value
30669
-
30670
- with tempfile.TemporaryDirectory(prefix="keel-delinherit-") as raw_tmp:
30671
- root = Path(raw_tmp)
30672
-
30673
- # M1 — a task authoring no entry inherits the declared tier, and the
30674
- # capsule says the repository supplied it.
30675
- inherits = root / "inherits"
30676
- inherits.mkdir()
30677
- write_gate_fixture(inherits, standing_authorization_task())
30678
- write_authorize_config(
30679
- inherits, "fast_check: echo c\ndelegation:\n tier: deep\n"
30680
- )
30681
- got = capsule(inherits)
30682
- if got is None:
30683
- return 1
30684
- delegation = got.get("delegation")
30685
- if delegation is None:
30686
- report(f"delegation-inheritance: the capsule carries no delegation: {got.keys()}")
30687
- return 1
30688
- if delegation.get("tier") != "deep":
30689
- report(f"delegation-inheritance: the declared tier did not reach the capsule: {delegation}")
30690
- return 1
30691
- if "config.yaml" not in (delegation.get("source") or ""):
30692
- report(f"delegation-inheritance: the inherited entry does not name its source: {delegation}")
30693
- return 1
30694
-
30695
- # M2 — a task authoring its own entry keeps it, and names itself, while
30696
- # the repository declares something different.
30697
- authored = root / "authored"
30698
- authored.mkdir()
30699
- write_gate_fixture(
30700
- authored, standing_authorization_task(" - Delegation: routine\n")
30701
- )
30702
- write_authorize_config(
30703
- authored, "fast_check: echo c\ndelegation:\n tier: deep\n"
30704
- )
30705
- own = capsule(authored)
30706
- if own is None:
30707
- return 1
30708
- mine = own.get("delegation") or {}
30709
- if mine.get("tier") != "routine":
30710
- report(f"delegation-inheritance: the authored tier was overridden: {mine}")
30711
- return 1
30712
- if "config.yaml" in (mine.get("source") or ""):
30713
- report(f"delegation-inheritance: an authored entry was attributed to the declaration: {mine}")
30714
- return 1
30715
-
30716
- # M2 control — a silent repository leaves the task undelegated, so the
30717
- # two comparisons above are not both trivially true.
30718
- silent = root / "silent"
30719
- silent.mkdir()
30720
- write_gate_fixture(silent, standing_authorization_task())
30721
- write_authorize_config(silent, "fast_check: echo c\n")
30722
- none_of_it = capsule(silent)
30723
- if none_of_it is None:
30724
- return 1
30725
- absent = none_of_it.get("delegation") or {}
30726
- if absent.get("tier") is not None:
30727
- report(f"delegation-inheritance: a silent repository delegated: {absent}")
30728
- return 1
30729
-
30730
- # M3 — a helper is still read-only. A delegate is a different role, not
30731
- # a helper with the restriction removed.
30732
- for label, repo in (("inherits", inherits), ("authored", authored), ("silent", silent)):
30733
- again = capsule(repo)
30734
- if again is None:
30735
- return 1
30736
- if again.get("helperAuthority") != "read-only-evidence-only":
30737
- report(
30738
- f"delegation-inheritance: {label} changed helper authority: "
30739
- f"{again.get('helperAuthority')}"
30740
- )
30741
- return 1
30742
-
30743
- report("delegation-inheritance scenario passed.")
30744
- return 0
30745
-
30746
-
30747
29362
  def validate_review_checks_content_scenario() -> int:
30748
29363
  """Both checks concern content a gate can only shape-check.
30749
29364
 
@@ -31579,41 +30194,13 @@ ACCEPTED_AUTHORIZE_NAMES = (
31579
30194
  def validate_continuation_docs_scenario() -> int:
31580
30195
  """Every text an agent reads at the between-task boundary names the word (#94).
31581
30196
 
31582
- The declaration only works if the boundary's readers know it exists: the
31583
- goal skill's stop rule is what an agent obeys at the boundary, the README
31584
- and the config comment are where an owner learns the vocabulary, and the
31585
- resident protocol is what the enforcing agent holds in context.
30197
+ The README and the config comment are where an owner learns the
30198
+ vocabulary, and the resident protocol is what the agent holds in context.
30199
+ The goal skill's stop rule was the third reader until the skill was
30200
+ removed in 5.173.0 (#414).
31586
30201
  """
31587
30202
  label = "continuation-docs"
31588
30203
 
31589
- src_skill = (
31590
- ROOT / "src/skills/keel-run-single-task-goal/SKILL.md"
31591
- ).read_text(encoding="utf-8")
31592
- plugin_skill = (
31593
- ROOT / "plugins/keel/skills/keel-run-single-task-goal/SKILL.md"
31594
- ).read_text(encoding="utf-8")
31595
- if src_skill != plugin_skill:
31596
- report(f"{label}: the src/ and plugins/ skill copies diverge.")
31597
- return 1
31598
-
31599
- step7 = next(
31600
- (line for line in plugin_skill.splitlines() if line.startswith("7. ")), ""
31601
- )
31602
- if not step7.startswith("7. Stop."):
31603
- report(f"{label}: the goal skill lost its stop step: {step7!r}")
31604
- return 1
31605
- for needle in (
31606
- "standing `continuation` authorization",
31607
- "keel/config.yaml",
31608
- "next unchecked task of the same change",
31609
- "its own recorded fingerprint",
31610
- "no hidden scheduler",
31611
- ):
31612
- if needle not in step7:
31613
- report(f"{label}: the stop rule lacks: {needle}")
31614
- report(step7)
31615
- return 1
31616
-
31617
30204
  readme = (ROOT / "README.md").read_text(encoding="utf-8")
31618
30205
  # Since #414 crossing the boundary needs no confirmation by default, and the
31619
30206
  # README says so where it names the word.
@@ -31940,984 +30527,6 @@ def validate_verify_layer_tag_scenario() -> int:
31940
30527
  return 0
31941
30528
 
31942
30529
 
31943
- def validate_native_goal_gate_order_scenario() -> int:
31944
- with tempfile.TemporaryDirectory(prefix="keel-goal-order-") as raw_tmp:
31945
- root = Path(raw_tmp)
31946
- repo = root / "codex"
31947
- repo.mkdir()
31948
- env = dict(os.environ)
31949
- env["CODEX_HOME"] = str(root / "codex-home")
31950
- if run_keel(repo, "--install", "--target", "codex", env=env).returncode != 0:
31951
- report("native-goal-gate-order install failed.")
31952
- return 1
31953
- tasks_path = repo / "openspec/changes/sample-change/tasks.md"
31954
- write_text(tasks_path, _goal_tasks_file([_goal_task_block()]))
31955
- # A native evaluator claiming success must never stand in for the gates.
31956
- write_text(repo / ".codex/transcripts/session.json", '{"complete": true}\n')
31957
-
31958
- goal_result = run_keel(
31959
- repo, "project", "goal",
31960
- "--target", "codex",
31961
- "--change", "sample-change", "--task", "1.1", "--json",
31962
- env=env,
31963
- )
31964
- goal = json.loads(goal_result.stdout).get("goal") or {}
31965
- presentation = goal.get("evidencePresentation") or []
31966
- if (
31967
- len(presentation) != 3
31968
- or "Done only when: task-complete passes" not in goal.get("condition", "")
31969
- or "durably checked" not in goal.get("condition", "")
31970
- ):
31971
- report("native-goal-gate-order goal did not encode the durable completion order.")
31972
- report(json.dumps(goal, indent=2))
31973
- return 1
31974
-
31975
- # 1. task-start passes and yields the fingerprint authorization.
31976
- start = run_keel(
31977
- repo, "gate", "task-start",
31978
- "--change", "sample-change", "--task", "1.1", "--json",
31979
- env=env,
31980
- )
31981
- if start.returncode != 0:
31982
- report("native-goal-gate-order task-start failed.")
31983
- return 1
31984
-
31985
- # 2. Premature completion is rejected before implementation/evidence exist,
31986
- # even with a native "complete" transcript present.
31987
- before_tasks = tasks_path.read_text(encoding="utf-8")
31988
- premature = run_keel(
31989
- repo, "gate", "task-complete",
31990
- "--change", "sample-change", "--task", "1.1", "--json",
31991
- env=env,
31992
- )
31993
- if premature.returncode == 0:
31994
- report("native-goal-gate-order allowed premature completion.")
31995
- return 1
31996
-
31997
- # 3. Compiling the goal never checks the box; the current agent owns it.
31998
- run_keel(
31999
- repo, "project", "goal",
32000
- "--target", "codex",
32001
- "--change", "sample-change", "--task", "1.1", "--json",
32002
- env=env,
32003
- )
32004
- if tasks_path.read_text(encoding="utf-8") != before_tasks:
32005
- report("native-goal-gate-order goal projection mutated the task owner.")
32006
- return 1
32007
-
32008
- # 4. With evidence and a passing Review recorded, task-complete passes.
32009
- write_text(tasks_path, _goal_tasks_file([_goal_task_block(filled=True)]))
32010
- record_contract_anchor(repo, "sample-change")
32011
- completed = run_keel(
32012
- repo, "gate", "task-complete",
32013
- "--change", "sample-change", "--task", "1.1", "--json",
32014
- env=env,
32015
- )
32016
- if completed.returncode != 0:
32017
- report("native-goal-gate-order rejected a completed task after evidence and Review.")
32018
- report((completed.stderr or completed.stdout).strip())
32019
- return 1
32020
-
32021
- # 5. A blocked state never satisfies completion.
32022
- write_text(
32023
- tasks_path,
32024
- _goal_tasks_file(
32025
- [_goal_task_block(filled=True, blocker="native runtime lost the goal condition")]
32026
- ),
32027
- )
32028
- blocked = run_keel(
32029
- repo, "gate", "task-complete",
32030
- "--change", "sample-change", "--task", "1.1", "--json",
32031
- env=env,
32032
- )
32033
- if blocked.returncode == 0:
32034
- report("native-goal-gate-order let a blocked task complete.")
32035
- return 1
32036
-
32037
- # 6. After the current agent durably checks the box, the goal stops.
32038
- write_text(tasks_path, _goal_tasks_file([_goal_task_block(checked=True, filled=True)]))
32039
- stopped = run_keel(
32040
- repo, "project", "goal",
32041
- "--target", "codex",
32042
- "--change", "sample-change", "--task", "1.1", "--json",
32043
- env=env,
32044
- )
32045
- stopped_payload = json.loads(stopped.stdout)
32046
- if stopped.returncode == 0 or stopped_payload.get("status") != "blocked":
32047
- report("native-goal-gate-order did not stop after completion.")
32048
- return 1
32049
-
32050
- report("native-goal-gate-order scenario passed.")
32051
- return 0
32052
-
32053
-
32054
- def validate_native_goal_continuity_scenario() -> int:
32055
- with tempfile.TemporaryDirectory(prefix="keel-goal-continuity-") as raw_tmp:
32056
- root = Path(raw_tmp)
32057
- repo = root / "codex"
32058
- repo.mkdir()
32059
- env = dict(os.environ)
32060
- env["CODEX_HOME"] = str(root / "codex-home")
32061
- if run_keel(repo, "--install", "--target", "codex", env=env).returncode != 0:
32062
- report("native-goal-continuity install failed.")
32063
- return 1
32064
- tasks_path = repo / "openspec/changes/sample-change/tasks.md"
32065
- write_text(
32066
- tasks_path,
32067
- _goal_tasks_file(
32068
- [
32069
- _goal_task_block(task_id="1.1"),
32070
- _goal_task_block(task_id="1.2", title="Second bounded behavior"),
32071
- ]
32072
- ),
32073
- )
32074
- owner = "openspec/changes/sample-change/tasks.md#1.1"
32075
-
32076
- def _goal(*args: str) -> subprocess.CompletedProcess[str]:
32077
- return run_keel(
32078
- repo, "project", "goal",
32079
- "--target", "codex",
32080
- "--change", "sample-change", "--task", "1.1",
32081
- *args,
32082
- "--json",
32083
- env=env,
32084
- )
32085
-
32086
- # Continuity is reconstructed from OpenSpec/Git, not a Keel cursor/cache.
32087
- before = snapshot_files(repo)
32088
- first = _goal()
32089
- second = _goal()
32090
- if before != snapshot_files(repo):
32091
- report("native-goal-continuity wrote a Keel cursor or cache.")
32092
- return 1
32093
- first_goal = json.loads(first.stdout).get("goal") or {}
32094
- second_goal = json.loads(second.stdout).get("goal") or {}
32095
- if not first_goal or first_goal != second_goal:
32096
- report("native-goal-continuity did not reconstruct an identical goal.")
32097
- return 1
32098
- recorded = first_goal.get("fingerprint", {}).get("value")
32099
-
32100
- # A matching authorized resume is accepted.
32101
- resume = _goal("--expected-fingerprint", recorded, "--expected-owner", owner)
32102
- if resume.returncode != 0 or json.loads(resume.stdout).get("status") != "ready":
32103
- report("native-goal-continuity rejected a matching authorized resume.")
32104
- return 1
32105
-
32106
- def _blocks(result: subprocess.CompletedProcess[str], label: str) -> bool:
32107
- if result.returncode == 0:
32108
- report("native-goal-continuity accepted %s." % label)
32109
- return False
32110
- payload = json.loads(result.stdout)
32111
- if payload.get("status") != "blocked" or payload.get("goal") is not None:
32112
- report("native-goal-continuity %s was not a clean block." % label)
32113
- return False
32114
- return True
32115
-
32116
- # Missing authorization (a resume with no explicit task) never auto-advances
32117
- # to the proposed next task.
32118
- missing = run_keel(
32119
- repo, "project", "goal",
32120
- "--target", "codex", "--change", "sample-change", "--json",
32121
- env=env,
32122
- )
32123
- if not _blocks(missing, "missing authorization"):
32124
- return 1
32125
-
32126
- # Checkout divergence: the recorded owner no longer matches.
32127
- if not _blocks(
32128
- _goal("--expected-owner", "openspec/changes/other/tasks.md#9.9"),
32129
- "checkout divergence",
32130
- ):
32131
- return 1
32132
-
32133
- # Fingerprint drift: a real source change makes the recompiled capsule
32134
- # diverge from the recorded authorization.
32135
- write_text(
32136
- tasks_path,
32137
- _goal_tasks_file(
32138
- [
32139
- _goal_task_block(
32140
- task_id="1.1",
32141
- acceptance=("A different observable result is proven by M1.",),
32142
- ),
32143
- _goal_task_block(task_id="1.2", title="Second bounded behavior"),
32144
- ]
32145
- ),
32146
- )
32147
- recompiled = json.loads(_goal().stdout).get("goal") or {}
32148
- if recompiled.get("fingerprint", {}).get("value") == recorded:
32149
- report("native-goal-continuity did not track the durable source change.")
32150
- return 1
32151
- if not _blocks(
32152
- _goal("--expected-fingerprint", recorded),
32153
- "fingerprint drift",
32154
- ):
32155
- return 1
32156
-
32157
- # Completed authorization stops; the next task is never auto-selected.
32158
- write_text(
32159
- tasks_path,
32160
- _goal_tasks_file(
32161
- [
32162
- _goal_task_block(task_id="1.1", checked=True, filled=True),
32163
- _goal_task_block(task_id="1.2", title="Second bounded behavior"),
32164
- ]
32165
- ),
32166
- )
32167
- if not _blocks(_goal(), "completed authorization"):
32168
- return 1
32169
- next_task = run_keel(
32170
- repo, "project", "goal",
32171
- "--target", "codex", "--change", "sample-change", "--json",
32172
- env=env,
32173
- )
32174
- if not _blocks(next_task, "auto-advance to the next task"):
32175
- return 1
32176
-
32177
- report("native-goal-continuity scenario passed.")
32178
- return 0
32179
-
32180
-
32181
- def validate_native_helper_brief_scenario() -> int:
32182
- with tempfile.TemporaryDirectory(prefix="keel-helper-brief-") as raw_tmp:
32183
- root = Path(raw_tmp)
32184
- repo = root / "repo"
32185
- (repo / "src").mkdir(parents=True)
32186
- write_text(repo / "src/goal.js", "// sample\n")
32187
-
32188
- def _helper(*args: str) -> subprocess.CompletedProcess[str]:
32189
- return run_keel(repo, "project", "helper", *args, "--json")
32190
-
32191
- # A bounded read-only question compiles a non-writing, non-delegating brief.
32192
- before = snapshot_files(repo)
32193
- question = _helper(
32194
- "--target", "codex",
32195
- "--brief", "Which function in src/goal.js renders the condition?",
32196
- "--read", "src/goal.js",
32197
- )
32198
- payload = json.loads(question.stdout)
32199
- brief = payload.get("brief") or {}
32200
- if (
32201
- question.returncode != 0
32202
- or payload.get("version") != "keel-helper-brief/v1"
32203
- or payload.get("status") != "ready"
32204
- or brief.get("mode") != "question"
32205
- or brief.get("authority") != "read-only-evidence-only"
32206
- or brief.get("writesProducts") is not False
32207
- or brief.get("delegates") is not False
32208
- or brief.get("completionAuthority") is not False
32209
- or brief.get("reads") != ["src/goal.js"]
32210
- or not brief.get("reportSchema")
32211
- ):
32212
- report("native-helper-brief did not compile a bounded question brief.")
32213
- report(json.dumps(payload, indent=2))
32214
- return 1
32215
-
32216
- # An exact repository-byte-stable verification command is also accepted.
32217
- command = _helper(
32218
- "--target", "claude",
32219
- "--command", "node scripts/run_python.js scripts/validate_plugin.py --scenario cli",
32220
- )
32221
- if (
32222
- command.returncode != 0
32223
- or json.loads(command.stdout).get("brief", {}).get("mode")
32224
- != "verification-command"
32225
- ):
32226
- report("native-helper-brief rejected a byte-stable verification command.")
32227
- return 1
32228
-
32229
- if before != snapshot_files(repo):
32230
- report("native-helper-brief mutated the repository while compiling briefs.")
32231
- return 1
32232
-
32233
- def _reject(args: list[str], label: str) -> bool:
32234
- snap = snapshot_files(repo)
32235
- result = _helper(*args)
32236
- if result.returncode == 0:
32237
- report("native-helper-brief accepted %s." % label)
32238
- return False
32239
- payload = json.loads(result.stdout)
32240
- if payload.get("status") != "blocked" or payload.get("brief") is not None:
32241
- report("native-helper-brief %s was not a clean block." % label)
32242
- return False
32243
- if snap != snapshot_files(repo):
32244
- report("native-helper-brief %s mutated state." % label)
32245
- return False
32246
- return True
32247
-
32248
- checks = [
32249
- (["--target", "codex", "--brief", "Implement the renderer in src/goal.js"],
32250
- "implementation delegation"),
32251
- (["--target", "codex", "--brief", "What is X? What is Y unrelated thing?"],
32252
- "multiple unrelated questions"),
32253
- (["--target", "codex", "--brief", "Ask a subagent to summarize src/goal.js"],
32254
- "nested delegation"),
32255
- (["--target", "codex", "--brief", "Please mark the task complete and sync"],
32256
- "completion-authority request"),
32257
- (["--target", "codex", "--command", "node build.js > dist/out.txt"],
32258
- "artifact-generating command"),
32259
- (["--target", "codex", "--command", "git commit -am done"],
32260
- "commit command"),
32261
- (["--target", "codex", "--command", "node test.js", "--external", "src/tmp.json"],
32262
- "in-repo declared output"),
32263
- (["--target", "opencode", "--brief", "Which file defines the gate?"],
32264
- "opencode target"),
32265
- (["--target", "codex"], "empty brief"),
32266
- ]
32267
- for args, label in checks:
32268
- if not _reject(args, label):
32269
- return 1
32270
-
32271
- report("native-helper-brief scenario passed.")
32272
- return 0
32273
-
32274
-
32275
- def validate_native_helper_read_only_scenario() -> int:
32276
- with tempfile.TemporaryDirectory(prefix="keel-helper-ro-") as raw_tmp:
32277
- root = Path(raw_tmp)
32278
- repo = root / "repo"
32279
- (repo / "src").mkdir(parents=True)
32280
- write_text(repo / "src/a.txt", "alpha\n")
32281
- write_text(repo / "src/b.txt", "beta\n")
32282
- baseline = root / "baseline.json"
32283
-
32284
- def _capture(target_baseline: Path) -> subprocess.CompletedProcess[str]:
32285
- return run_keel(
32286
- repo, "project", "helper",
32287
- "--target", "codex", "--capture-baseline",
32288
- "--baseline", str(target_baseline), "--json",
32289
- )
32290
-
32291
- def _verify() -> subprocess.CompletedProcess[str]:
32292
- return run_keel(
32293
- repo, "project", "helper",
32294
- "--target", "codex", "--verify",
32295
- "--baseline", str(baseline), "--json",
32296
- )
32297
-
32298
- # A baseline must live outside the worktree.
32299
- inside = _capture(repo / "baseline.json")
32300
- if inside.returncode == 0:
32301
- report("native-helper-read-only wrote a baseline inside the repository.")
32302
- return 1
32303
-
32304
- # Pre-existing dirty bytes are captured into the baseline and never
32305
- # attributed to the helper.
32306
- write_text(repo / "src/pre-existing.txt", "already changed by the current agent\n")
32307
- if _capture(baseline).returncode != 0:
32308
- report("native-helper-read-only could not capture an external baseline.")
32309
- return 1
32310
- clean = _verify()
32311
- if clean.returncode != 0 or json.loads(clean.stdout).get("status") != "verified":
32312
- report("native-helper-read-only rejected an unchanged repository.")
32313
- report((clean.stderr or clean.stdout).strip())
32314
- return 1
32315
- # The pre-existing file is preserved, not cleaned up or attributed.
32316
- if not (repo / "src/pre-existing.txt").exists():
32317
- report("native-helper-read-only removed a pre-existing path.")
32318
- return 1
32319
-
32320
- def _expect_reject(mutation, label: str, expected: dict[str, str]) -> bool:
32321
- mutation()
32322
- result = _verify()
32323
- payload = json.loads(result.stdout)
32324
- if result.returncode == 0 or payload.get("status") != "rejected":
32325
- report("native-helper-read-only accepted %s." % label)
32326
- return False
32327
- changes = {c["path"]: c["kind"] for c in payload.get("changes", [])}
32328
- for path_key, kind in expected.items():
32329
- if changes.get(path_key) != kind:
32330
- report(
32331
- "native-helper-read-only %s misreported changes: %s"
32332
- % (label, json.dumps(changes))
32333
- )
32334
- return False
32335
- if payload.get("cleanup") != "none":
32336
- report("native-helper-read-only %s attempted cleanup." % label)
32337
- return False
32338
- return True
32339
-
32340
- # modified
32341
- if not _expect_reject(
32342
- lambda: write_text(repo / "src/a.txt", "alpha-changed\n"),
32343
- "a modified path",
32344
- {"src/a.txt": "modified"},
32345
- ):
32346
- return 1
32347
- # restore for isolation, re-baseline
32348
- write_text(repo / "src/a.txt", "alpha\n")
32349
- if _capture(baseline).returncode != 0:
32350
- return 1
32351
- # added
32352
- if not _expect_reject(
32353
- lambda: write_text(repo / "src/c.txt", "added\n"),
32354
- "an added path",
32355
- {"src/c.txt": "added"},
32356
- ):
32357
- return 1
32358
- (repo / "src/c.txt").unlink()
32359
- if _capture(baseline).returncode != 0:
32360
- return 1
32361
- # deleted
32362
- if not _expect_reject(
32363
- lambda: (repo / "src/b.txt").unlink(),
32364
- "a deleted path",
32365
- {"src/b.txt": "removed"},
32366
- ):
32367
- return 1
32368
- write_text(repo / "src/b.txt", "beta\n")
32369
- if _capture(baseline).returncode != 0:
32370
- return 1
32371
- # renamed -> reported as removed + added
32372
- if not _expect_reject(
32373
- lambda: (repo / "src/b.txt").rename(repo / "src/b-renamed.txt"),
32374
- "a renamed path",
32375
- {"src/b.txt": "removed", "src/b-renamed.txt": "added"},
32376
- ):
32377
- return 1
32378
-
32379
- # A command whose byte stability cannot be established remains current-agent
32380
- # work rather than a silent pass.
32381
- missing = run_keel(
32382
- repo, "project", "helper",
32383
- "--target", "codex", "--verify",
32384
- "--baseline", str(root / "does-not-exist.json"), "--json",
32385
- )
32386
- if missing.returncode == 0 or json.loads(missing.stdout).get("status") != "unverifiable":
32387
- report("native-helper-read-only accepted an unestablished baseline.")
32388
- return 1
32389
-
32390
- report("native-helper-read-only scenario passed.")
32391
- return 0
32392
-
32393
-
32394
- def validate_native_goal_capabilities_scenario() -> int:
32395
- with tempfile.TemporaryDirectory(prefix="keel-helper-caps-") as raw_tmp:
32396
- root = Path(raw_tmp)
32397
- for target in ("codex", "claude"):
32398
- repo = root / target
32399
- repo.mkdir()
32400
- env = dict(os.environ)
32401
- if target == "codex":
32402
- env["CODEX_HOME"] = str(root / "codex-home")
32403
- if run_keel(repo, "--install", "--target", target, env=env).returncode != 0:
32404
- report("native-goal-capabilities %s install failed." % target)
32405
- return 1
32406
- probed = run_keel(repo, "capabilities", "--target", target, "--json", env=env)
32407
- payload = json.loads(probed.stdout)
32408
- helper = payload.get("helper") or {}
32409
- dimensions = (
32410
- "discovery",
32411
- "toolRestriction",
32412
- "nestedDelegationPrevention",
32413
- "byteStability",
32414
- "execution",
32415
- )
32416
- if any(dim not in helper for dim in dimensions):
32417
- report("native-goal-capabilities %s omitted a helper dimension." % target)
32418
- report(json.dumps(helper, indent=2))
32419
- return 1
32420
- levels = {helper[dim].get("level") for dim in dimensions}
32421
- # enforced, advisory, and manual are reported separately.
32422
- if not {"enforced", "advisory", "manual"}.issubset(levels):
32423
- report("native-goal-capabilities %s did not separate enforcement levels." % target)
32424
- return 1
32425
- if (
32426
- helper["nestedDelegationPrevention"].get("level") != "enforced"
32427
- or helper["byteStability"].get("level") != "enforced"
32428
- or helper["execution"].get("level") != "manual"
32429
- ):
32430
- report("native-goal-capabilities %s mislabeled a helper dimension." % target)
32431
- return 1
32432
- # Helper absence never disables current-agent goal execution.
32433
- if payload.get("capabilities", {}).get("execution.goal", {}).get("level") != "manual":
32434
- report("native-goal-capabilities %s dropped goal execution." % target)
32435
- return 1
32436
- if not any(
32437
- "Helper absence never disables" in warning
32438
- for warning in payload.get("warnings", [])
32439
- ):
32440
- report("native-goal-capabilities %s did not assert helper independence." % target)
32441
- return 1
32442
-
32443
- report("native-goal-capabilities scenario passed.")
32444
- return 0
32445
-
32446
-
32447
- # The referenced half of a split skill. Returns "" for a skill with one body, so
32448
- # every assertion about a skill's content reads the same shape whether or not it
32449
- # was split — a split must not be able to drop a required statement, and a
32450
- # scenario must not have to know which skills were split to stay correct.
32451
- def skill_guidance_text(skill_md: Path) -> str:
32452
- guidance = skill_md.parent / "guidance.md"
32453
- return guidance.read_text(encoding="utf-8") if guidance.is_file() else ""
32454
-
32455
-
32456
- SINGLE_TASK_GOAL_SKILL = "keel-run-single-task-goal"
32457
- OFFICIAL_GOAL_SOURCES = (
32458
- "https://learn.chatgpt.com/use-cases/follow-goals",
32459
- "https://developers.openai.com/codex/subagents",
32460
- "https://code.claude.com/docs/en/goal",
32461
- "https://code.claude.com/docs/en/sub-agents",
32462
- )
32463
-
32464
-
32465
- def validate_single_task_goal_skill_scenario() -> int:
32466
- canonical = ROOT / "src/skills" / SINGLE_TASK_GOAL_SKILL / "SKILL.md"
32467
- projection = ROOT / "plugins/keel/skills" / SINGLE_TASK_GOAL_SKILL / "SKILL.md"
32468
- if not canonical.is_file() or not projection.is_file():
32469
- report("single-task-goal-skill missing canonical skill or native projection.")
32470
- return 1
32471
- canonical_bytes = canonical.read_bytes()
32472
- if canonical_bytes != projection.read_bytes():
32473
- report("single-task-goal-skill projection is not byte-equal to the canonical source.")
32474
- return 1
32475
- # A skill split into a body and a referenced `guidance.md` carries its
32476
- # content across both files. What these assertions require is that the skill
32477
- # states the thing, not that SKILL.md does, so the split must not be able to
32478
- # drop a required statement by moving it — and must not be able to keep one
32479
- # only in a file the plugin does not ship, which `native-plugin-manifests`
32480
- # checks byte-for-byte alongside the body.
32481
- text = canonical_bytes.decode("utf-8") + skill_guidance_text(canonical)
32482
-
32483
- # Authoritative official sources are linked, and provenance/license is recorded.
32484
- for source in OFFICIAL_GOAL_SOURCES:
32485
- if source not in text:
32486
- report("single-task-goal-skill did not link official source: %s" % source)
32487
- return 1
32488
- lowered = text.lower()
32489
- if (
32490
- "provenance" not in lowered
32491
- or "license note" not in lowered
32492
- or "not copied" not in lowered
32493
- or "paraphrase" not in lowered
32494
- ):
32495
- report("single-task-goal-skill did not record provenance/license and paraphrase intent.")
32496
- return 1
32497
- # Paraphrase, not bundle: no verbatim external doc dumped inside a fenced block.
32498
- if "```" in text:
32499
- report("single-task-goal-skill bundled a fenced external block instead of paraphrasing.")
32500
- return 1
32501
-
32502
- # Positive triggers for explicit one-task automatic execution and resume.
32503
- if not (
32504
- "## When to activate" in text
32505
- and "resume" in lowered
32506
- and ("one task" in lowered or "one" in lowered)
32507
- and "explicit" in lowered
32508
- ):
32509
- report("single-task-goal-skill lacks explicit one-task/resume positive triggers.")
32510
- return 1
32511
- # Negative triggers.
32512
- negatives = ("/opsx:apply", "proposal", "ambiguous", "opencode", "deleg", "helper")
32513
- if "## When NOT to activate" not in text or any(
32514
- neg not in lowered for neg in negatives
32515
- ):
32516
- report("single-task-goal-skill lacks the required negative triggers.")
32517
- return 1
32518
- # Manual fallback and the exact copy/paste command.
32519
- if "## Manual fallback" not in text or "keel project goal" not in text:
32520
- report("single-task-goal-skill lacks a manual fallback with the exact command.")
32521
- return 1
32522
-
32523
- # Thin activation adapters exist for both native targets and no others.
32524
- agents_dir = ROOT / "plugins/keel/agents"
32525
- agent_files = sorted(p.name for p in agents_dir.glob("*.md")) if agents_dir.is_dir() else []
32526
- expected_agents = [
32527
- "keel-single-task-goal-claude.md",
32528
- "keel-single-task-goal-codex.md",
32529
- ]
32530
- if agent_files != expected_agents:
32531
- report("single-task-goal-skill adapters are not exactly the codex and claude pair.")
32532
- return 1
32533
- for name, target in (
32534
- ("keel-single-task-goal-codex.md", "codex"),
32535
- ("keel-single-task-goal-claude.md", "claude"),
32536
- ):
32537
- adapter = (agents_dir / name).read_text(encoding="utf-8")
32538
- if ("target: %s" % target) not in adapter or "read-only" not in adapter.lower():
32539
- report("single-task-goal-skill %s adapter is missing target or read-only helper policy." % target)
32540
- return 1
32541
-
32542
- report("single-task-goal-skill scenario passed.")
32543
- return 0
32544
-
32545
-
32546
- def validate_single_task_goal_real_tasks_scenario() -> int:
32547
- cases = (
32548
- ("bug-fix", "vertical-tdd", True),
32549
- ("generator", "characterization", False),
32550
- ("rendered", "rendered-behavior", False),
32551
- )
32552
- with tempfile.TemporaryDirectory(prefix="keel-real-tasks-") as raw_tmp:
32553
- root = Path(raw_tmp)
32554
- for name, strategy, redgreen in cases:
32555
- repo = root / name
32556
- repo.mkdir()
32557
- env = dict(os.environ)
32558
- env["CODEX_HOME"] = str(root / ("codex-home-" + name))
32559
- if run_keel(repo, "--install", "--target", "codex", env=env).returncode != 0:
32560
- report("single-task-goal-real-tasks %s install failed." % name)
32561
- return 1
32562
- tasks_path = repo / "openspec/changes/sample-change/tasks.md"
32563
- write_text(tasks_path, _goal_tasks_file([_goal_task_block(strategy=strategy)]))
32564
-
32565
- start = run_keel(
32566
- repo, "gate", "task-start",
32567
- "--change", "sample-change", "--task", "1.1", "--json", env=env,
32568
- )
32569
- if start.returncode != 0:
32570
- report("single-task-goal-real-tasks %s task-start failed." % name)
32571
- return 1
32572
- goal = run_keel(
32573
- repo, "project", "goal",
32574
- "--target", "codex", "--change", "sample-change", "--task", "1.1",
32575
- "--json", env=env,
32576
- )
32577
- gpayload = json.loads(goal.stdout).get("goal") or {}
32578
- if goal.returncode != 0 or gpayload.get("verificationStrategy") != strategy:
32579
- report("single-task-goal-real-tasks %s goal did not carry its strategy." % name)
32580
- return 1
32581
-
32582
- # Complete the one task through its approved strategy evidence.
32583
- write_text(
32584
- tasks_path,
32585
- _goal_tasks_file(
32586
- [_goal_task_block(strategy=strategy, filled=True, redgreen=redgreen)]
32587
- ),
32588
- )
32589
- record_contract_anchor(repo, "sample-change")
32590
- done = run_keel(
32591
- repo, "gate", "task-complete",
32592
- "--change", "sample-change", "--task", "1.1", "--json", env=env,
32593
- )
32594
- if done.returncode != 0:
32595
- report("single-task-goal-real-tasks %s task-complete failed." % name)
32596
- report((done.stderr or done.stdout).strip())
32597
- return 1
32598
-
32599
- # Current agent checks the one box; the run then stops at that boundary.
32600
- write_text(
32601
- tasks_path,
32602
- _goal_tasks_file(
32603
- [_goal_task_block(strategy=strategy, checked=True, filled=True, redgreen=redgreen)]
32604
- ),
32605
- )
32606
- stopped = run_keel(
32607
- repo, "project", "goal",
32608
- "--target", "codex", "--change", "sample-change", "--task", "1.1",
32609
- "--json", env=env,
32610
- )
32611
- if stopped.returncode == 0 or json.loads(stopped.stdout).get("status") != "blocked":
32612
- report("single-task-goal-real-tasks %s did not stop after one task." % name)
32613
- return 1
32614
- # No next fixture task exists or was auto-created.
32615
- if "1.2" in tasks_path.read_text(encoding="utf-8"):
32616
- report("single-task-goal-real-tasks %s started a next task." % name)
32617
- return 1
32618
-
32619
- report("single-task-goal-real-tasks scenario passed.")
32620
- return 0
32621
-
32622
-
32623
- def _goal_target_surface(target: str) -> int:
32624
- with tempfile.TemporaryDirectory(prefix="keel-goal-%s-" % target) as raw_tmp:
32625
- root = Path(raw_tmp)
32626
- repo = root / target
32627
- repo.mkdir()
32628
- env = dict(os.environ)
32629
- if target == "codex":
32630
- env["CODEX_HOME"] = str(root / "codex-home")
32631
- if run_keel(repo, "--install", "--target", target, env=env).returncode != 0:
32632
- report("native-goal-%s install failed." % target)
32633
- return 1
32634
- write_text(
32635
- repo / "openspec/changes/sample-change/tasks.md",
32636
- _goal_tasks_file([_goal_task_block(strategy="vertical-tdd")]),
32637
- )
32638
-
32639
- # The plugin ships the portable skill and this target's activation adapter.
32640
- adapter = ROOT / "plugins/keel/agents" / ("keel-single-task-goal-%s.md" % target)
32641
- if not (ROOT / "plugins/keel/skills" / SINGLE_TASK_GOAL_SKILL).is_dir() or not adapter.is_file():
32642
- report("native-goal-%s missing portable skill or activation adapter." % target)
32643
- return 1
32644
-
32645
- # Explicit activation, resume, drift stop, and single-task termination.
32646
- activated = run_keel(
32647
- repo, "project", "goal", "--target", target,
32648
- "--change", "sample-change", "--task", "1.1", "--json", env=env,
32649
- )
32650
- apayload = json.loads(activated.stdout)
32651
- goal = apayload.get("goal") or {}
32652
- if activated.returncode != 0 or apayload.get("status") != "ready":
32653
- report("native-goal-%s did not activate one task." % target)
32654
- return 1
32655
- if target == "claude" and goal.get("conditionLength", 0) > 4000:
32656
- report("native-goal-claude condition exceeded the 4,000-character budget.")
32657
- return 1
32658
- recorded = goal.get("fingerprint", {}).get("value")
32659
- owner = "openspec/changes/sample-change/tasks.md#1.1"
32660
- resume = run_keel(
32661
- repo, "project", "goal", "--target", target,
32662
- "--change", "sample-change", "--task", "1.1",
32663
- "--expected-fingerprint", recorded, "--expected-owner", owner, "--json", env=env,
32664
- )
32665
- if resume.returncode != 0 or json.loads(resume.stdout).get("status") != "ready":
32666
- report("native-goal-%s could not resume the authorized task." % target)
32667
- return 1
32668
- drift = run_keel(
32669
- repo, "project", "goal", "--target", target,
32670
- "--change", "sample-change", "--task", "1.1",
32671
- "--expected-fingerprint", "deadbeef", "--json", env=env,
32672
- )
32673
- if drift.returncode == 0 or json.loads(drift.stdout).get("status") != "blocked":
32674
- report("native-goal-%s did not stop on drift." % target)
32675
- return 1
32676
-
32677
- # Capabilities surface the goal at manual with a copy/paste command fallback.
32678
- caps = run_keel(repo, "capabilities", "--target", target, "--json", env=env)
32679
- cpayload = json.loads(caps.stdout)
32680
- goal_cap = cpayload.get("capabilities", {}).get("execution.goal", {})
32681
- if goal_cap.get("level") != "manual" or not goal_cap.get("command"):
32682
- report("native-goal-%s did not report an advisory goal command fallback." % target)
32683
- return 1
32684
-
32685
- # The skill carries the target-specific fallback guidance.
32686
- skill_body = ROOT / "plugins/keel/skills" / SINGLE_TASK_GOAL_SKILL / "SKILL.md"
32687
- skill_text = skill_body.read_text(encoding="utf-8") + skill_guidance_text(
32688
- skill_body
32689
- )
32690
- if target == "claude" and "disabled hooks" not in skill_text.lower():
32691
- report("native-goal-claude skill lacks the disabled-hooks fallback.")
32692
- return 1
32693
- if target == "codex" and "advisory" not in skill_text.lower():
32694
- report("native-goal-codex skill lacks the advisory activation fallback.")
32695
- return 1
32696
- return 0
32697
-
32698
-
32699
- def validate_native_goal_codex_scenario() -> int:
32700
- status = _goal_target_surface("codex")
32701
- if status == 0:
32702
- report("native-goal-codex scenario passed.")
32703
- return status
32704
-
32705
-
32706
- def validate_native_goal_claude_scenario() -> int:
32707
- status = _goal_target_surface("claude")
32708
- if status == 0:
32709
- report("native-goal-claude scenario passed.")
32710
- return status
32711
-
32712
-
32713
- def validate_native_helper_targets_scenario() -> int:
32714
- with tempfile.TemporaryDirectory(prefix="keel-helper-targets-") as raw_tmp:
32715
- root = Path(raw_tmp)
32716
- for target in ("codex", "claude"):
32717
- repo = root / target
32718
- repo.mkdir()
32719
- env = dict(os.environ)
32720
- if target == "codex":
32721
- env["CODEX_HOME"] = str(root / "codex-home")
32722
- if run_keel(repo, "--install", "--target", target, env=env).returncode != 0:
32723
- report("native-helper-targets %s install failed." % target)
32724
- return 1
32725
- caps = run_keel(repo, "capabilities", "--target", target, "--json", env=env)
32726
- helper = json.loads(caps.stdout).get("helper") or {}
32727
- # Write and delegation authority are removed where supported (enforced),
32728
- # and dimensions downgrade independently (mixed levels).
32729
- if (
32730
- helper.get("nestedDelegationPrevention", {}).get("level") != "enforced"
32731
- or helper.get("byteStability", {}).get("level") != "enforced"
32732
- or helper.get("toolRestriction", {}).get("level") != "advisory"
32733
- or helper.get("execution", {}).get("level") != "manual"
32734
- ):
32735
- report("native-helper-targets %s did not downgrade helper dimensions independently." % target)
32736
- return 1
32737
- # Only byte-stable read-only briefs are accepted.
32738
- ok = run_keel(
32739
- repo, "project", "helper", "--target", target,
32740
- "--brief", "Which file defines the gate?", "--json", env=env,
32741
- )
32742
- if ok.returncode != 0 or json.loads(ok.stdout).get("status") != "ready":
32743
- report("native-helper-targets %s rejected a bounded read-only brief." % target)
32744
- return 1
32745
- bad = run_keel(
32746
- repo, "project", "helper", "--target", target,
32747
- "--brief", "Delegate the fix to a subagent", "--json", env=env,
32748
- )
32749
- if bad.returncode == 0 or json.loads(bad.stdout).get("status") != "blocked":
32750
- report("native-helper-targets %s accepted a delegating helper." % target)
32751
- return 1
32752
-
32753
- # No agent team or OpenCode v4 artifact is introduced: the adapter set is
32754
- # exactly the codex and claude pair.
32755
- agents_dir = ROOT / "plugins/keel/agents"
32756
- names = sorted(p.name for p in agents_dir.glob("*.md"))
32757
- if names != ["keel-single-task-goal-claude.md", "keel-single-task-goal-codex.md"]:
32758
- report("native-helper-targets adapter set is not exactly the codex and claude pair.")
32759
- return 1
32760
- # No global Stop hook is registered in either native manifest.
32761
- for runtime in (".codex-plugin", ".claude-plugin"):
32762
- manifest = json.loads(
32763
- (ROOT / "plugins/keel" / runtime / "plugin.json").read_text(encoding="utf-8")
32764
- )
32765
- hooks = json.dumps(manifest.get("hooks", {})).lower()
32766
- if "stop" in hooks:
32767
- report("native-helper-targets registered a global Stop hook in %s." % runtime)
32768
- return 1
32769
-
32770
- report("native-helper-targets scenario passed.")
32771
- return 0
32772
-
32773
-
32774
- def _single_task_matrix_target(target: str, root: Path) -> int:
32775
- repo = root / target
32776
- repo.mkdir()
32777
- env = dict(os.environ)
32778
- if target == "codex":
32779
- env["CODEX_HOME"] = str(root / ("codex-home-" + target))
32780
- if run_keel(repo, "--install", "--target", target, env=env).returncode != 0:
32781
- report("native-single-task-matrix %s install failed." % target)
32782
- return 1
32783
- tasks_path = repo / "openspec/changes/sample-change/tasks.md"
32784
-
32785
- def two_tasks(checked_first: bool = False, blocker: str = "none") -> str:
32786
- return _goal_tasks_file(
32787
- [
32788
- _goal_task_block(
32789
- task_id="1.1", strategy="vertical-tdd",
32790
- checked=checked_first, filled=checked_first, redgreen=checked_first,
32791
- blocker=blocker,
32792
- ),
32793
- _goal_task_block(task_id="1.2", title="Second bounded behavior"),
32794
- ]
32795
- )
32796
-
32797
- write_text(tasks_path, two_tasks())
32798
- # A native "already complete" transcript must never act as authority.
32799
- write_text(repo / (".%s/transcripts/session.json" % target), '{"complete": true}\n')
32800
-
32801
- def goal(*args: str) -> subprocess.CompletedProcess[str]:
32802
- return run_keel(
32803
- repo, "project", "goal", "--target", target,
32804
- "--change", "sample-change", "--task", "1.1", *args, "--json", env=env,
32805
- )
32806
-
32807
- # Explicit one-task activation with the vertical strategy carried through.
32808
- activated = json.loads(goal().stdout)
32809
- if activated.get("status") != "ready" or activated["goal"]["verificationStrategy"] != "vertical-tdd":
32810
- report("native-single-task-matrix %s did not activate one vertical task." % target)
32811
- return 1
32812
- recorded = activated["goal"]["fingerprint"]["value"]
32813
- owner = "openspec/changes/sample-change/tasks.md#1.1"
32814
-
32815
- # Compaction reconstruction is identical and writes no Keel cursor/cache.
32816
- before = snapshot_files(repo)
32817
- if json.loads(goal().stdout)["goal"] != activated["goal"]:
32818
- report("native-single-task-matrix %s reconstruction diverged." % target)
32819
- return 1
32820
- if before != snapshot_files(repo):
32821
- report("native-single-task-matrix %s wrote Keel goal/cursor state." % target)
32822
- return 1
32823
-
32824
- # Exact resume; drift and ambiguous checkout hard-stop; premature success ignored.
32825
- if json.loads(goal("--expected-fingerprint", recorded, "--expected-owner", owner).stdout)["status"] != "ready":
32826
- report("native-single-task-matrix %s rejected an exact resume." % target)
32827
- return 1
32828
- if json.loads(goal("--expected-fingerprint", "deadbeef").stdout)["status"] != "blocked":
32829
- report("native-single-task-matrix %s did not stop on drift." % target)
32830
- return 1
32831
- if json.loads(goal("--expected-owner", "openspec/changes/other/tasks.md#9.9").stdout)["status"] != "blocked":
32832
- report("native-single-task-matrix %s did not stop on ambiguous checkout." % target)
32833
- return 1
32834
-
32835
- # Current-agent order: task-complete fails before evidence, passes after, and a
32836
- # blocked task never completes; failure never rolls back or escalates.
32837
- start = run_keel(repo, "gate", "task-start", "--change", "sample-change", "--task", "1.1", "--json", env=env)
32838
- if start.returncode != 0:
32839
- report("native-single-task-matrix %s task-start failed." % target)
32840
- return 1
32841
- pre = snapshot_files(repo)
32842
- if run_keel(repo, "gate", "task-complete", "--change", "sample-change", "--task", "1.1", "--json", env=env).returncode == 0:
32843
- report("native-single-task-matrix %s allowed premature completion." % target)
32844
- return 1
32845
- if pre != snapshot_files(repo):
32846
- report("native-single-task-matrix %s failing gate mutated the tree." % target)
32847
- return 1
32848
- # A blocked task never completes, even with evidence and a passing Review.
32849
- write_text(
32850
- tasks_path,
32851
- _goal_tasks_file(
32852
- [
32853
- _goal_task_block(
32854
- task_id="1.1", strategy="vertical-tdd", filled=True, redgreen=True,
32855
- blocker="native runtime lost the goal condition",
32856
- ),
32857
- _goal_task_block(task_id="1.2", title="Second bounded behavior"),
32858
- ]
32859
- ),
32860
- )
32861
- if run_keel(repo, "gate", "task-complete", "--change", "sample-change", "--task", "1.1", "--json", env=env).returncode == 0:
32862
- report("native-single-task-matrix %s let a blocked task complete." % target)
32863
- return 1
32864
-
32865
- # Helper success and helper write/delegation rejection.
32866
- ok = run_keel(repo, "project", "helper", "--target", target, "--brief", "Which file defines the gate?", "--json", env=env)
32867
- if json.loads(ok.stdout).get("status") != "ready":
32868
- report("native-single-task-matrix %s rejected a bounded helper." % target)
32869
- return 1
32870
- bad = run_keel(repo, "project", "helper", "--target", target, "--brief", "Delegate the fix to a subagent", "--json", env=env)
32871
- if json.loads(bad.stdout).get("status") != "blocked":
32872
- report("native-single-task-matrix %s accepted a delegating helper." % target)
32873
- return 1
32874
-
32875
- # Successful completion: evidence + Review, task-complete passes, current agent
32876
- # checks the box, then the goal stops and never selects the next task.
32877
- write_text(
32878
- tasks_path,
32879
- _goal_tasks_file(
32880
- [
32881
- _goal_task_block(task_id="1.1", strategy="vertical-tdd", filled=True, redgreen=True),
32882
- _goal_task_block(task_id="1.2", title="Second bounded behavior"),
32883
- ]
32884
- ),
32885
- )
32886
- record_contract_anchor(repo, "sample-change")
32887
- done = run_keel(repo, "gate", "task-complete", "--change", "sample-change", "--task", "1.1", "--json", env=env)
32888
- if done.returncode != 0:
32889
- report("native-single-task-matrix %s could not complete with evidence." % target)
32890
- report((done.stderr or done.stdout).strip())
32891
- return 1
32892
- write_text(tasks_path, two_tasks(checked_first=True))
32893
- if json.loads(goal().stdout)["status"] != "blocked":
32894
- report("native-single-task-matrix %s did not stop after completion." % target)
32895
- return 1
32896
- no_task = run_keel(repo, "project", "goal", "--target", target, "--change", "sample-change", "--json", env=env)
32897
- if json.loads(no_task.stdout)["status"] != "blocked":
32898
- report("native-single-task-matrix %s auto-advanced to the next task." % target)
32899
- return 1
32900
-
32901
- # No Keel cursor, goal id, scheduler, queue, or global Stop hook state exists.
32902
- forbidden = (".keel", "keel-cursor.json", "goal-id.json", "scheduler.json", "queue.json")
32903
- for name in forbidden:
32904
- if list(repo.rglob(name)):
32905
- report("native-single-task-matrix %s created forbidden Keel state: %s" % (target, name))
32906
- return 1
32907
- return 0
32908
-
32909
-
32910
- def validate_native_single_task_matrix_scenario() -> int:
32911
- with tempfile.TemporaryDirectory(prefix="keel-matrix-") as raw_tmp:
32912
- root = Path(raw_tmp)
32913
- for target in ("codex", "claude"):
32914
- status = _single_task_matrix_target(target, root)
32915
- if status != 0:
32916
- return status
32917
- report("native-single-task-matrix scenario passed.")
32918
- return 0
32919
-
32920
-
32921
30530
  def validate_thin_native_install_scenario() -> int:
32922
30531
  with tempfile.TemporaryDirectory(prefix="keel-thin-install-") as raw_tmp:
32923
30532
  tmp = Path(raw_tmp)
@@ -35669,7 +33278,7 @@ def validate_guard_status_stale_manifest_scenario() -> int:
35669
33278
  # operands (the gate did not fail the way the fixture requires, whichever half
35670
33279
  # was wrong), and every site prints the full problem payload alongside it, so
35671
33280
  # a reader is never left with only the sentence.
35672
- OR_GUARDED_ASSERTION_SITES = 80
33281
+ OR_GUARDED_ASSERTION_SITES = 74
35673
33282
 
35674
33283
 
35675
33284
  def or_guarded_assertion_sites(source: str) -> list[int]:
@@ -37411,10 +35020,12 @@ def validate_output_survives_the_pipe_scenario() -> int:
37411
35020
  [_goal_task_block(acceptance=huge, strategy="vertical-tdd")]
37412
35021
  )
37413
35022
 
35023
+ # A task-start result carries the whole compiled capsule, so a long
35024
+ # Acceptance makes it larger than the shrunken pipe. (It was `keel project
35025
+ # goal` until that command was removed in 5.173.0, #414.)
37414
35026
  goal_args = (
37415
- "project", "goal",
37416
- "--target", "codex",
37417
- "--change", "sample-change", "--task", "1.1", "--json",
35027
+ "gate", "task-start",
35028
+ "--change", "sample-change", "--task", "1.1", "--json", "--no-guard",
37418
35029
  )
37419
35030
 
37420
35031
  with tempfile.TemporaryDirectory(prefix="keel-pipe-") as raw:
@@ -37437,7 +35048,7 @@ def validate_output_survives_the_pipe_scenario() -> int:
37437
35048
  redirected = run_keel(repo, *goal_args)
37438
35049
  if redirected.returncode != 0:
37439
35050
  report(
37440
- f"{label}: the fixture did not produce a goal projection to "
35051
+ f"{label}: the fixture did not produce a task-start result to "
37441
35052
  f"measure against; keel exited {redirected.returncode}."
37442
35053
  )
37443
35054
  report((redirected.stderr or redirected.stdout).strip()[:400])
@@ -41103,7 +38714,6 @@ def validate_a_count_is_derived_from_what_it_counts_scenario() -> int:
41103
38714
  "authorize",
41104
38715
  "precedents",
41105
38716
  "triage",
41106
- "delegation",
41107
38717
  "full_mode_paths",
41108
38718
  ):
41109
38719
  if expected not in names:
@@ -41451,6 +39061,65 @@ def validate_guidance_is_referenced_and_carries_no_criterion_scenario() -> int:
41451
39061
  return 0
41452
39062
 
41453
39063
 
39064
+ def validate_native_projections_removed_scenario() -> int:
39065
+ """Issue #414: Keel projects no goal, helper, task view, or subagent brief.
39066
+
39067
+ The owner removed the tooling built for the stance that subagents and native
39068
+ goals had to be shaped by Keel. Each surface is checked from the outside: the
39069
+ command a model would type, the doctor line it would read, and the plugin
39070
+ files a host would load. `keel project --event startup` is the control —
39071
+ a `keel project` that refused everything would pass the rest.
39072
+ """
39073
+ label = "native-projections-removed"
39074
+ with tempfile.TemporaryDirectory(prefix="keel-414-", ignore_cleanup_errors=True) as raw:
39075
+ repo = Path(raw)
39076
+ init = run_keel(repo, "--init", "--target", "claude")
39077
+ if init.returncode != 0:
39078
+ report(f"{label}: keel --init failed: {(init.stderr or init.stdout).strip()}")
39079
+ return 1
39080
+ for args in (
39081
+ ("project", "goal"),
39082
+ ("project", "tasks"),
39083
+ ("project", "helper"),
39084
+ ("project", "--event", "subagent-start"),
39085
+ ):
39086
+ result = run_keel(repo, *args)
39087
+ said = (result.stdout + result.stderr).lower()
39088
+ if result.returncode == 0:
39089
+ report(f"{label}: keel {' '.join(args)} exited 0.")
39090
+ return 1
39091
+ if "unknown" not in said and "unsupported" not in said:
39092
+ report(f"{label}: keel {' '.join(args)} was not refused as unknown: {(result.stdout or result.stderr).strip()[:120]!r}")
39093
+ return 1
39094
+ control = run_keel(repo, "project", "--event", "startup", "--target", "claude")
39095
+ if control.returncode != 0:
39096
+ report(f"{label}: keel project --event startup no longer works: {(control.stderr or control.stdout).strip()}")
39097
+ return 1
39098
+ doctor = run_keel(repo, "--doctor", "--target", "claude")
39099
+ for prefix in ("execution.goal", "execution.task-view", "delegation.", "helper "):
39100
+ hit = [line for line in doctor.stdout.splitlines() if line.strip().startswith(prefix)]
39101
+ if hit:
39102
+ report(f"{label}: doctor still prints {hit[0].strip()!r}.")
39103
+ return 1
39104
+ for gone in (
39105
+ ROOT / PLUGIN_ROOT / "skills/keel-run-single-task-goal",
39106
+ ROOT / "src/skills/keel-run-single-task-goal",
39107
+ ROOT / PLUGIN_ROOT / "agents",
39108
+ ):
39109
+ if gone.exists():
39110
+ report(f"{label}: {gone.relative_to(ROOT)} still ships.")
39111
+ return 1
39112
+ for manifest in (ROOT / ".claude-plugin/plugin.json", ROOT / PLUGIN_ROOT / ".codex-plugin/plugin.json"):
39113
+ if "agents" in json.loads(manifest.read_text(encoding="utf-8")):
39114
+ report(f"{label}: {manifest.relative_to(ROOT)} still names agents.")
39115
+ return 1
39116
+ if label not in {name for name, _ in SCENARIOS}:
39117
+ report(f"{label}: the scenario registry does not include it.")
39118
+ return 1
39119
+ report(f"{label} scenario passed.")
39120
+ return 0
39121
+
39122
+
41454
39123
  NATIVE_CAPABILITY_SUPPRESSIONS = (
41455
39124
  "unbounded subagent",
41456
39125
  "bounded helpers return read-only",
@@ -42842,16 +40511,10 @@ def validate_external_agent_brief_scenario() -> int:
42842
40511
  payload, out = brief("dsh", "helper", repo)
42843
40512
  if not refused(payload, out, "sandbox", "worktree", what="a dsh helper over the checkout"):
42844
40513
  return 1
42845
- # Implementation with no guard: the projection's own reason.
42846
- projected = run_keel(repo, "project", "--target", "claude", "--event", "subagent-start",
42847
- "--subagent-mode", "implementation", "--change", "demo",
42848
- "--task", "1.1", "--json", env=env)
42849
- expected = " ".join(json.loads(projected.stdout).get("reasons") or [])
40514
+ # Implementation with no guard is refused, naming the guard: the host's
40515
+ # guard never sees an external process, so this is its only check.
42850
40516
  payload, out = brief("codex", "implementation", repo)
42851
- if not expected:
42852
- report(f"{label} the projection gave no reason to compare against: {projected.stdout[:400]}")
42853
- return 1
42854
- if not refused(payload, out, expected, what="an unguarded implementation"):
40517
+ if not refused(payload, out, "requires an active write guard", what="an unguarded implementation"):
42855
40518
  return 1
42856
40519
  started = run_keel(repo, "gate", "task-start", "--change", "demo", "--task", "1.1",
42857
40520
  "--record", "--json", env=env)
@@ -43222,7 +40885,6 @@ SCENARIOS: tuple = (
43222
40885
  ("sync-surface-overlay", validate_sync_surface_overlay_scenario),
43223
40886
  ("openspec-surface-overlay", validate_openspec_surface_overlay_scenario),
43224
40887
  ("update-restores-overlays", validate_update_restores_overlays_scenario),
43225
- ("model-chosen-subagents", validate_model_chosen_subagents_scenario),
43226
40888
  ("uninstall", validate_uninstall_scenario),
43227
40889
  (
43228
40890
  "uninstall-removes-the-overlay",
@@ -43295,14 +40957,8 @@ SCENARIOS: tuple = (
43295
40957
  "triage-admits-from-the-repository",
43296
40958
  validate_triage_admits_from_the_repository_scenario,
43297
40959
  ),
43298
- ("delegation-declaration", validate_delegation_declaration_scenario),
43299
- ("delegation-inheritance", validate_delegation_inheritance_scenario),
43300
40960
  ("native-capability-scope", validate_native_capability_scope_scenario),
43301
- ("delegation-projection", validate_delegation_projection_scenario),
43302
- ("delegation-sole-authority", validate_delegation_sole_authority_scenario),
43303
- ("delegation-goal-budget", validate_delegation_goal_budget_scenario),
43304
40961
  ("delegation-guard-binds", validate_delegation_guard_binds_scenario),
43305
- ("delegation-never-weakens", validate_delegation_never_weakens_scenario),
43306
40962
  ("delegation-overlay", validate_delegation_overlay_scenario),
43307
40963
  ("delegation-resident-text", validate_delegation_resident_text_scenario),
43308
40964
  (
@@ -43505,18 +41161,6 @@ SCENARIOS: tuple = (
43505
41161
  ("init-never-downgrades-openspec", validate_init_never_downgrades_openspec_scenario),
43506
41162
  ("native-plugin-marketplaces", validate_native_plugin_marketplaces_scenario),
43507
41163
  ("native-plugin-install-matrix", validate_native_plugin_install_matrix_scenario),
43508
- ("native-goal-projection", validate_native_goal_projection_scenario),
43509
- ("native-goal-gate-order", validate_native_goal_gate_order_scenario),
43510
- ("native-goal-continuity", validate_native_goal_continuity_scenario),
43511
- ("native-helper-brief", validate_native_helper_brief_scenario),
43512
- ("native-helper-read-only", validate_native_helper_read_only_scenario),
43513
- ("native-goal-capabilities", validate_native_goal_capabilities_scenario),
43514
- ("single-task-goal-skill", validate_single_task_goal_skill_scenario),
43515
- ("single-task-goal-real-tasks", validate_single_task_goal_real_tasks_scenario),
43516
- ("native-goal-codex", validate_native_goal_codex_scenario),
43517
- ("native-goal-claude", validate_native_goal_claude_scenario),
43518
- ("native-helper-targets", validate_native_helper_targets_scenario),
43519
- ("native-single-task-matrix", validate_native_single_task_matrix_scenario),
43520
41164
  ("touch-write-guard", validate_touch_write_guard_scenario),
43521
41165
  ("push-branch-guard", validate_push_branch_guard_scenario),
43522
41166
  ("push-guard-redirects", validate_push_guard_redirects_scenario),
@@ -43556,7 +41200,6 @@ SCENARIOS: tuple = (
43556
41200
  ("domain-lens-scaffold", validate_domain_lens_scaffold_scenario),
43557
41201
  ("domain-lens-doctor", validate_domain_lens_doctor_scenario),
43558
41202
  ("plan-funnel-guidance", validate_plan_funnel_guidance_scenario),
43559
- ("native-tasks-view", validate_native_tasks_view_scenario),
43560
41203
  (
43561
41204
  "declared-paths-are-read-whole",
43562
41205
  validate_declared_paths_are_read_whole_scenario,
@@ -43670,6 +41313,7 @@ SCENARIOS: tuple = (
43670
41313
  ),
43671
41314
  ("tdd-strategy-guide", validate_tdd_strategy_guide_scenario),
43672
41315
  ("native-capabilities-unrestricted", validate_native_capabilities_unrestricted_scenario),
41316
+ ("native-projections-removed", validate_native_projections_removed_scenario),
43673
41317
  (
43674
41318
  "a-tier-declares-what-is-skipped",
43675
41319
  validate_a_tier_declares_what_is_skipped_scenario,