@christang/keel 5.174.0 → 5.175.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.174.0",
3
+ "version": "5.175.0",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -1,10 +1,10 @@
1
- <!-- keel:start version=5.174.0 -->
1
+ <!-- keel:start version=5.175.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the durable authority, and memory or transcripts may only inform.
5
5
  - Obey the selected task capsule: `keel gate task-start` before implementing, `--record` its fingerprint to Evidence `Contract`, which `task-complete` requires, before checking complete. Touch bounds product writes; the change's own dir is exempt. On Claude a passing `task-start` guards it by default (`--no-guard` opts out).
6
- - Work through an approved `tasks.md` in order, each task through its own gates. A subagent is the model's choice and is treated as the main agent is. No commit, sync, or archive without explicit authorization.
6
+ - Work through an approved `tasks.md` in order, each task through its own gates. A subagent is the model's choice and is treated as the main agent is. No commit, push, sync, or archive unless the task, the owner, or `keel/config.yaml` authorizes it.
7
7
  - Route Full (the OpenSpec flow) for new features, interface or protocol changes, cross-module work, or over ~3 files / 100 lines; Lite for local fixes with no interface change. No gate checks routing; a project corrects the size bar with `full_mode_paths:` in `keel/config.yaml`, which `keel context` reports.
8
- - Native plugin projections (SessionStart context) are disposable views, never authority; without the plugin or hook, run the commands manually.
8
+ - SessionStart projections are disposable views, never authority; without the plugin, run the commands by hand.
9
9
  - Keel skills and hooks come from the `keel` native plugin (`codex plugin add` / `claude plugin install`); `keel --init` owns only the OpenSpec schema, overlays, and this bootstrap.
10
10
  <!-- keel:end -->
@@ -79,8 +79,7 @@ artifacts:
79
79
  the compiled fingerprint into that Contract line, and task-complete
80
80
  refuses a task that recorded none: without an anchor there is nothing for
81
81
  completion to compare against, so the task has no drift detection. Omitted fields inherit
82
- versioned keel-task-capsule/v1 defaults: Owner is the current Keel
83
- agent, Mode is implementation, Read is the change artifacts plus
82
+ versioned keel-task-capsule/v1 defaults: Mode is implementation, Read is the change artifacts plus
84
83
  discovered repository context, Acceptance derives from the resolved
85
84
  Covers authority, the Autonomy boundary is hard-stop, and Coupling is
86
85
  none. Exceptional boundaries are declared only when they differ from
@@ -95,7 +94,8 @@ artifacts:
95
94
  compact form.
96
95
  Verify selects the least-cost strategy that still proves the resolved
97
96
  Acceptance: vertical-tdd, regression-first, characterization,
98
- snapshot-characterization, rendered-behavior, or evidence-first.
97
+ snapshot-characterization, rendered-behavior, evidence-first, or
98
+ equivalence (which also declares `Base:` and `Fields:`).
99
99
  Red-green strategies record per-label `.red` and `.green` Evidence in
100
100
  addition to the bare `M<n>` Evidence, which is always required; all three
101
101
  must be concrete before completion. An `M<n>` may carry a comma-separated
@@ -134,25 +134,26 @@ artifacts:
134
134
 
135
135
  Use `Coupling: none` by default. When `Coupling: required`, define one
136
136
  complete candidate, its allowed provisional failures, completion gate,
137
- final assertions, retry counting, immediate task-stop conditions, and
137
+ final assertions, immediate task-stop conditions, and
138
138
  evidence. The task must agree with design.md's Coupled Iteration Contract.
139
139
 
140
- `/opsx:apply` selects unchecked tasks from this file. The current agent may
141
- read any repository file needed for the selected task; Read lists required
140
+ `/opsx:apply` works through the unchecked tasks of this file in order. Any
141
+ repository file may be read needed for the selected task; Read lists required
142
142
  starting context, not a read allowlist. The Slice Start Gate requires each
143
143
  selected current slice or contiguous slice group to name source
144
144
  expectations and compile to a capsule whose Read, Touch, Acceptance,
145
145
  verification checks, and Stop/Autonomy boundaries are sufficient to
146
146
  execute without guessing. Rough
147
147
  future slices may remain drafts, but cannot be selected for
148
- implementation or marked complete. The current agent may only modify files
149
- listed under Touch for the selected task. If implementation requires files
148
+ implementation or marked complete. Only files listed under Touch for the
149
+ selected task may be modified. If implementation requires files
150
150
  outside Touch, broader design work, or an interface/security boundary
151
151
  change not covered by design.md, stop and report an Out-of-scope Need.
152
- Before task completion, Evidence records the current agent's semantic
152
+ Before task completion, Evidence records the semantic
153
153
  Review with Status, Acceptance check, Scope check, and Findings. Status is
154
154
  one of pass, passed, complete, completed, ok, or done. Findings
155
- are `none` or carry a durable owner — a `Discard reason:`/`Discard
155
+ are `none` or carry a disposition — `Resolved here:` naming a check this
156
+ task declares or a path that exists, or a durable owner: a `Discard reason:`/`Discard
156
157
  rationale:` prefix, an absolute `https://…` reference, or any
157
158
  repo-relative path that exists, named after `Durable owner:` so it reads
158
159
  as the owner rather than a file the finding mentions;
@@ -186,18 +187,18 @@ apply:
186
187
 
187
188
  Apply workflow:
188
189
  1. Read the current change's proposal.md, specs, design.md when present, and tasks.md.
189
- 2. Select one unchecked task or a small contiguous group of unchecked tasks from tasks.md.
190
+ 2. Take the first unchecked task of tasks.md; later ones follow in order (step 8).
190
191
  3. Run the Task Authoring Gate: every relevant critical expectation must be covered by a selected slice, deferred to a durable owner, or explicitly discarded with rationale.
191
192
  4. Run the Slice Start Gate: every selected current slice must name source expectations and compile to a complete keel-task-capsule/v1 contract from its compact Covers, Touch, Verify, and Evidence fields plus any declared exceptional Mode, Read, Acceptance delta, Autonomy boundary, Coupling/Candidate Boundary, or Stop if clauses.
192
- 5. If a selected task lacks an execution contract, source expectations, or accepted hidden-knowledge assumptions raised by risk-triggered deep alignment or a domain lens, update OpenSpec first instead of dispatching implementation.
193
+ 5. If a selected task lacks an execution contract, source expectations, or accepted hidden-knowledge assumptions raised by risk-triggered deep alignment or a domain lens, update OpenSpec first instead of starting implementation.
193
194
  6. Rough future slices may remain non-executable drafts, but they cannot be selected for implementation or marked complete.
194
195
  7. Treat any Execution recommendation as an advisory implementation note, not as a completion gate.
195
196
  8. Work through the unchecked tasks of an approved `tasks.md` in order, each through its own `keel gate task-start` and `keel gate task-complete`; every stop trigger still halts. A subagent is the model's choice and is treated as the main agent is.
196
197
  9. Use the current checkout and selected task contract. Verification failure or context pressure preserves the checkout; continue from evidence, record a blocker, or explicitly roll back to last-green only when authorized.
197
198
  10. When `Coupling: required`, verify design.md contains a Coupled Iteration Contract and that the task defines a complete candidate, completion gate, and evidence. If not, update OpenSpec instead of execution.
198
- 11. The current agent may read any repository file needed for the selected task, but repository-wide read authority is read-only and does not expand write authority.
199
+ 11. Any repository file needed for the selected task may be read; reading does not expand write authority.
199
200
  12. Modify only files listed under Touch. If modifying any other file is required, stop and report an Out-of-scope Need with file or area, why needed, consequence if unchanged, minimal proposed change, and evidence.
200
- 13. Do not commit or push unless the selected task or human instruction explicitly allows it.
201
+ 13. Do not commit or push unless the selected task, a human instruction, or a standing authorization in `keel/config.yaml` allows it.
201
202
  14. After each iteration, compare Changed Files and command evidence with the selected task contract before checking tasks complete.
202
- 15. Run `keel-review-checklist` only at completion gates: after a complete task group, before `/opsx:sync openspec/changes/<change>/tasks.md` or `/opsx:archive openspec/changes/<change>/tasks.md`, before meaningful handoff, or when implementation reports risks, follow-ups, or out-of-scope need. The Claude target's Keel Hook completion gate checks M-command evidence for these direct command paths.
203
+ 15. Run `keel-review-checklist` only at completion gates: after a complete task group, before `/opsx:sync openspec/changes/<change>/tasks.md` or `/opsx:archive openspec/changes/<change>/tasks.md`, before meaningful handoff, or when implementation reports risks, follow-ups, or out-of-scope need. No hook gates completion; running the gates is the agent's own step.
203
204
  16. Before archive or handoff, unresolved follow-ups must be owned by current OpenSpec tasks, a new OpenSpec change, archive evidence, or an explicit discard reason.
@@ -1,6 +1,6 @@
1
1
  <!-- Compact v4 task source (keel-task-capsule/v1, defaults version 1).
2
2
  Record only task-specific authority. Omitted fields inherit versioned
3
- defaults: Owner is the current Keel agent, Mode is implementation, Read
3
+ defaults: Mode is implementation, Read
4
4
  is the change proposal/design/specs/tasks plus discovered repository
5
5
  context, Acceptance derives from Covers, Coupling defaults to none, and a
6
6
  subagent is the model's choice, treated as the main agent is. The next
@@ -23,7 +23,8 @@
23
23
  - Verify:
24
24
  <!-- verification discipline: Strategy is REQUIRED and is one of
25
25
  vertical-tdd, regression-first, characterization,
26
- snapshot-characterization, rendered-behavior, or evidence-first.
26
+ snapshot-characterization, rendered-behavior, evidence-first, or
27
+ equivalence (which also declares Base: and Fields:).
27
28
  Nothing is supplied by default, because the value an omission
28
29
  would select is the one with no red-green requirement.
29
30
  evidence-first additionally carries a `Reason:` entry beside
@@ -50,7 +51,7 @@
50
51
  - M1: pending
51
52
  - Review:
52
53
  <!-- Status: one of pass, passed, complete, completed, ok, done -->
53
- <!-- Findings: none, or carry a durable owner — a "Discard reason:"/"Discard rationale:" prefix, an absolute https://… reference, or any repo-relative path that exists (keel/archive/…, an openspec/changes/… artifact, or the repository's own ledger) named after "Durable owner:"; not keel/HANDOFF.md, which is a pointer override -->
54
+ <!-- Findings: none, or "Resolved here:" naming a check this task declares or a path that exists, or a durable owner — a "Discard reason:"/"Discard rationale:" prefix, an absolute https://… reference, or any repo-relative path that exists (keel/archive/…, an openspec/changes/… artifact, or the repository's own ledger) named after "Durable owner:"; not keel/HANDOFF.md, which is a pointer override -->
54
55
  - Status: pending
55
56
  - Acceptance check: pending
56
57
  - Scope check: pending
@@ -66,13 +67,13 @@
66
67
  sync, archive, or mark tasks complete
67
68
  - Read: additional required starting context beyond the base set
68
69
  - Acceptance: a task-specific observable delta the Covers authority does not express
69
- - Execution recommendation / Rationale: advisory notes for the current agent
70
+ - Execution recommendation / Rationale: advisory notes for whoever executes the task
70
71
  - Autonomy boundary: a pre-authorized fallback with its exact reversible bound and required evidence
71
72
  - Coupling: required, with the design.md Coupled Iteration Contract, one
72
73
  complete candidate, Candidate Boundary, completion-gate final assertions,
73
74
  and candidate-level Stop Rules
74
75
  - Stop if: extra hard limits beyond the standard prohibitions
75
- Requires modifying files outside Touch. always remains a stop condition. -->
76
+ `Requires modifying files outside Touch.` always remains a stop condition. -->
76
77
 
77
78
  ## 2. <!-- Task Group Name -->
78
79
 
package/bin/keel.js CHANGED
@@ -99,6 +99,8 @@ Usage:
99
99
  keel shift request|check|ready|start|resume|status ... (a role's shift change; see keel shift --help)
100
100
  keel lock acquire|release|list ... (shared resource leases; see keel lock --help)
101
101
  keel worktrees [--repo <path>] [--issues <file>] [--json] (read-only worktree overview)
102
+ keel patrol [--issues <file>] [--idle <dur>] [--since-last [--notify]] [--nudge] [--json] [--repo <path>] (the coordinator's patrol; keel patrol task prints its schedule)
103
+ keel tick [--repo <path>] [--json] (one model-free step for a host scheduler; keel tick task prints the job)
102
104
  keel openspec [args...]
103
105
  keel --init [repo] [--target claude|codex|opencode] [--dry-run] [--force-template-update]
104
106
  keel --install [repo] [--target claude|codex|opencode] [--dry-run] [--force-template-update] [--with-git-hooks]
@@ -1085,7 +1087,7 @@ function updateClaudePlugin(options) {
1085
1087
  updateLine(
1086
1088
  component,
1087
1089
  versionChange(installed.version, after && after.version),
1088
- "running sessions use it at their next hook call; their skills and agents after /reload-plugins"
1090
+ "running sessions use it at their next hook call; their skills after /reload-plugins"
1089
1091
  );
1090
1092
  return true;
1091
1093
  }
@@ -1718,7 +1720,6 @@ function keelOpenSpecOverlay(action) {
1718
1720
  "- Sync completion is gated by `keel gate change-close --action sync` plus `keel-review-checklist`; there is no runtime hook for it, so running the gate is the agent's own step.",
1719
1721
  "- Before syncing, each related critical expectation must have behavior evidence, a durable follow-up owner, or an explicit discard reason.",
1720
1722
  SUBAGENT_SENTENCE,
1721
- "- Invoke OpenSpec through `keel openspec` (for example `keel openspec validate`); a bare `openspec` command may not be on PATH.",
1722
1723
  "- Syncing promotes the change's spec delta into `openspec/specs/`. A later archive of the same change must use `--skip-specs`, because archive is not idempotent over an already-promoted delta.",
1723
1724
  ];
1724
1725
  if (action === "sync") {
@@ -1740,19 +1741,17 @@ function keelOpenSpecOverlay(action) {
1740
1741
  ? [
1741
1742
  "- Work through the unchecked tasks of an approved `tasks.md` in order, each started by `keel gate task-start` and completed by `keel gate task-complete`; every stop trigger still halts.",
1742
1743
  "- Run the Task Authoring Gate: each relevant critical expectation must be covered by a slice, deferred to a durable owner, or explicitly discarded.",
1743
- "- Run the Slice Start Gate: selected current slices must name source expectations and include Read, Touch, Acceptance, Commands, and Stop/Autonomy boundaries before implementation.",
1744
+ "- Run the Slice Start Gate: selected current slices must name source expectations and compile to a capsule whose Read, Touch, Acceptance, Verify checks, and Stop/Autonomy boundaries are complete before implementation.",
1744
1745
  "- Rough future slices may remain drafts, but cannot be selected for implementation or marked complete.",
1745
- "- Obey the selected task contract: Read is required starting context, Touch is the write boundary, Commands prove Acceptance, and the Autonomy boundary controls fallback decisions.",
1746
+ "- Obey the selected task contract: Read is required starting context, Touch is the write boundary, Verify checks prove Acceptance, and the Autonomy boundary controls fallback decisions.",
1746
1747
  "- When implementation exposes a material expectation, acceptance boundary, or user-owned decision absent from durable authority, stop before implementing that choice, rerun `keel-align-expectations`, and reauthor the affected proposal/design/spec/task authority first.",
1747
1748
  "- A discovered repository fact that does not change accepted behavior or scope may be recorded and execution continues inside the existing task boundary without a product interview.",
1748
- "- Invoke OpenSpec through `keel openspec` (for example `keel openspec validate`); a bare `openspec` command may not be on PATH.",
1749
1749
  "- Consult the repository's standing authorization in `keel/config.yaml` before asking the user to confirm a repository action: a standing-authorized action proceeds without a per-occurrence confirmation, and an undeclared action still requires the confirmation it requires today.",
1750
1750
  "- A standing authorization covers the action and never substitutes for a gate, evidence, or Review; it removes the confirmation, not the record, and it is not a trigger to perform the action.",
1751
1751
  ]
1752
1752
  : [
1753
1753
  "- Archive completion is gated by `keel gate change-close --action archive` plus `keel-review-checklist`; verify task evidence, follow-up ownership, and completion gates before proceeding.",
1754
1754
  "- Before final sync/archive, each related critical expectation must have behavior evidence, a durable follow-up owner, or an explicit discard reason.",
1755
- "- Invoke OpenSpec through `keel openspec` (for example `keel openspec validate`); a bare `openspec` command may not be on PATH.",
1756
1755
  "- When `/opsx:sync` has already promoted the change's spec delta, run the archive with `--skip-specs` so the promoted delta is not re-applied; archive is not idempotent over an already-synced delta.",
1757
1756
  "- After archiving, run `keel guard clear` to drop the change's guard manifest; the read-only gate never clears it for you.",
1758
1757
  "- A repository that standing-authorizes `archive` in `keel/config.yaml` does not need the per-occurrence archive confirmation; a repository that declares nothing still needs it.",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.174.0",
3
+ "version": "5.175.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.174.0",
9
+ "version": "5.175.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "^1.4.1"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.174.0",
5
+ "version": "5.175.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.174.0",
3
+ "version": "5.175.0",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.174.0",
3
+ "version": "5.175.0",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -21,8 +21,8 @@ When the change's artifacts or the failing surface signal a domain, consult the
21
21
  There is no fixed attempt count: keep going while each attempt adds evidence, and stop when one does not. When you stop, report the original key error plus what changed during each attempt.
22
22
 
23
23
  For `Coupling: required`, an allowed provisional failure inside a candidate is
24
- not a failed attempt; what counts is the same final assertion failing at the
25
- candidate completion gate. Follow the task's immediate task-stop
24
+ expected rather than a stop; the evidence that matters is the final assertion
25
+ at the candidate completion gate. Follow the task's immediate task-stop
26
26
  rules for scope breach, missing design authority, non-reproducible evidence,
27
27
  or a baseline or acceptance change during a candidate.
28
28
 
@@ -51,8 +51,8 @@ REQUIRED_SCRIPTS = [
51
51
  "scripts/validate_plugin.py",
52
52
  ]
53
53
 
54
- PACKAGE_VERSION = "5.174.0"
55
- PROTOCOL_VERSION = "5.174.0"
54
+ PACKAGE_VERSION = "5.175.0"
55
+ PROTOCOL_VERSION = "5.175.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
@@ -755,7 +755,6 @@ def validate_openspec_schema(errors: list[str]) -> None:
755
755
  "apply:",
756
756
  "/opsx:apply",
757
757
  "keel-review-checklist",
758
- "Owner",
759
758
  "Mode",
760
759
  "Covers",
761
760
  "Read",
@@ -773,7 +772,7 @@ def validate_openspec_schema(errors: list[str]) -> None:
773
772
  "A subagent is the model's choice and is treated as the main agent is",
774
773
  "approved `tasks.md` in order",
775
774
  "Modify only files listed under Touch",
776
- "repository-wide read authority is read-only",
775
+ "reading does not expand write authority",
777
776
  "Out-of-scope Need",
778
777
  "unresolved follow-ups must be owned",
779
778
  "Task Authoring Gate",
@@ -787,7 +786,8 @@ def validate_openspec_schema(errors: list[str]) -> None:
787
786
  "real-task evidence",
788
787
  "one of pass, passed, complete, completed, ok, or done.",
789
788
  "## Expectation Coverage",
790
- "carry a durable owner",
789
+ "carry a disposition",
790
+ "`Resolved here:`",
791
791
  ):
792
792
  if required not in schema:
793
793
  errors.append(f"OpenSpec schema.yaml missing required language: {required}")
@@ -15890,7 +15890,9 @@ def validate_task_contract_core_scenario() -> int:
15890
15890
 
15891
15891
 
15892
15892
  def task_capsule_expanded_fixture() -> str:
15893
- return task_contract_fixture().replace(
15893
+ # No `Owner:`: since #413 the capsule carries an owner only when a task
15894
+ # authors one, so writing the old default is no longer the same as omitting it.
15895
+ return task_contract_fixture().replace(" - Owner: keel-agent\n", "", 1).replace(
15894
15896
  "E1: public behavior",
15895
15897
  "E1: Public behavior passes.",
15896
15898
  ).replace(
@@ -18917,9 +18919,15 @@ def validate_task_body_ends_at_heading_scenario() -> int:
18917
18919
  # one, and a vertical-tdd task compiles to the identical block and the
18918
18920
  # identical fingerprint before and after, measured both ways. So no
18919
18921
  # existing anchor drifted; this fixture is simply a different task now.
18922
+ #
18923
+ # Moved again, deliberately and for every anchor, in 5.175.0 (#413): the
18924
+ # capsule dropped three prohibitions and its default owner. The drift
18925
+ # diagnosis names that move a compiler change, measured with an anchor
18926
+ # recorded by 5.174.0, and the changelog tells each repository to
18927
+ # re-record once.
18920
18928
  pinned = {
18921
- "1.1": "11110c1cdde55df1008c6a2bd9f6bde2bffa286a34ae93addb9cf66fc1e5b90f",
18922
- "2.1": "62f7dfaec87e0614dae7e4935ce1749554f141a23518b094632eb8423e96d54c",
18929
+ "1.1": "7149e77c287d08abd33aae1835e24ff4892771efdfb5d6755b791e2d78436319",
18930
+ "2.1": "bc2d69bcf8718e5825af8f2fb5f318518f74051ea021a61d549691b449ad5929",
18923
18931
  }
18924
18932
  plain = (
18925
18933
  "# Tasks\n\n"
@@ -21625,11 +21633,8 @@ def validate_task_capsule_scenario() -> int:
21625
21633
  != [
21626
21634
  "must not change Acceptance",
21627
21635
  "must not commit",
21628
- "must not continue to another task",
21629
- "must not mark tasks complete",
21630
21636
  "must not push",
21631
21637
  "must not sync or archive",
21632
- "must not transfer Keel ownership",
21633
21638
  ]
21634
21639
  ):
21635
21640
  report("task-capsule omitted default or prohibition authority.")
@@ -39296,6 +39301,144 @@ def validate_native_capabilities_unrestricted_scenario() -> int:
39296
39301
  return 0
39297
39302
 
39298
39303
 
39304
+ # Sentences the surfaces said after the code stopped saying them (#413).
39305
+ STALE_SURFACE_SENTENCES = (
39306
+ "Owner is the current Keel agent",
39307
+ "retry counting",
39308
+ "Keel Hook completion gate",
39309
+ "unless Touch authorizes diagnostics",
39310
+ "explicitly allows it",
39311
+ "without explicit authorization",
39312
+ "Commands prove Acceptance",
39313
+ "Acceptance, Commands, and Stop/Autonomy",
39314
+ "not a failed attempt",
39315
+ "skills and agents after",
39316
+ "Invoke OpenSpec through",
39317
+ "Remote Control off, the wake task",
39318
+ )
39319
+
39320
+
39321
+ def validate_surfaces_agree_with_code_scenario() -> int:
39322
+ """Issue #413: what the model reads states what the code does.
39323
+
39324
+ #414 removed the protocol's old stance and the capsule kept it: every
39325
+ task-start still printed "must not continue to another task". The other
39326
+ sentences here contradicted the code they describe — a diagnose-only task
39327
+ the parser refuses unless its Touch is `none`, a completion hook no plugin
39328
+ declares, an authorization list ten names long beside a code list of
39329
+ thirteen. The names are read from `src/core/config.js`, so a name added
39330
+ later without its spec line fails here.
39331
+ """
39332
+ label = "surfaces-agree-with-code:"
39333
+ with tempfile.TemporaryDirectory(prefix="keel-surfaces-413-") as raw:
39334
+ repo = Path(raw)
39335
+ write_text(repo / "openspec/changes/demo/tasks.md", task_capsule_compact_fixture())
39336
+ started = run_keel(repo, "gate", "task-start", "--change", "demo", "--task", "1.1", "--no-guard", "--json")
39337
+ if started.returncode != 0:
39338
+ report(f"{label} task-start refused the compact fixture.")
39339
+ report((started.stderr or started.stdout).strip())
39340
+ return 1
39341
+ capsule = json.loads(started.stdout).get("contract", {}).get("capsule", {})
39342
+ if "owner" in capsule:
39343
+ report(f"{label} a task that authors no Owner compiled to owner {capsule['owner']!r}.")
39344
+ return 1
39345
+ kept = ["must not change Acceptance", "must not commit", "must not push", "must not sync or archive"]
39346
+ if capsule.get("prohibitions") != kept:
39347
+ report(f"{label} the capsule prohibits {capsule.get('prohibitions')!r}, not {kept!r}.")
39348
+ return 1
39349
+
39350
+ overlays = []
39351
+ for action in ("apply", "archive", "sync"):
39352
+ overlays.append(ROOT / f".claude/commands/opsx/{action}.md")
39353
+ for name in ("apply-change", "archive-change", "sync-specs"):
39354
+ overlays.append(ROOT / f".claude/skills/openspec-{name}/SKILL.md")
39355
+ overlays.append(ROOT / f".codex/skills/openspec-{name}/SKILL.md")
39356
+ schemas = [
39357
+ ROOT / "assets/openspec/schemas/keel-spec-driven",
39358
+ ROOT / "openspec/schemas/keel-spec-driven",
39359
+ ]
39360
+ required = {
39361
+ ROOT / "AGENTS.md": [
39362
+ "with `Touch: none` and no worktree writes",
39363
+ "a standing authorization in `keel/config.yaml` allows it",
39364
+ "`Verify` checks MUST verify",
39365
+ ],
39366
+ ROOT / "assets/bootstrap/AGENTS.md": [
39367
+ "No commit, push, sync, or archive unless the task, the owner, or `keel/config.yaml` authorizes it.",
39368
+ ],
39369
+ ROOT / "src/skills/keel-debug-failure/SKILL.md": ["expected rather than a stop"],
39370
+ ROOT / PLUGIN_ROOT / "skills/keel-debug-failure/SKILL.md": ["expected rather than a stop"],
39371
+ ROOT / "bin/keel.js": [],
39372
+ ROOT / "src/core/config.js": [],
39373
+ }
39374
+ for schema in schemas:
39375
+ required[schema / "schema.yaml"] = [
39376
+ "equivalence (which also declares `Base:` and `Fields:`)",
39377
+ "`Resolved here:`",
39378
+ "No hook gates completion",
39379
+ ]
39380
+ required[schema / "templates/tasks.md"] = ["equivalence", '"Resolved here:"']
39381
+ for overlay in overlays:
39382
+ required[overlay] = ["Invoke the OpenSpec CLI as `keel openspec"]
39383
+ if "apply" in overlay.as_posix():
39384
+ required[overlay].append("Verify checks prove Acceptance")
39385
+ for surface, sentences in required.items():
39386
+ if not surface.is_file():
39387
+ report(f"{label} {surface.relative_to(ROOT)} is missing, so it cannot be checked.")
39388
+ return 1
39389
+ text = surface.read_text(encoding="utf-8")
39390
+ for phrase in STALE_SURFACE_SENTENCES:
39391
+ if phrase in text:
39392
+ report(f"{label} {surface.relative_to(ROOT)} still says {phrase!r}.")
39393
+ return 1
39394
+ for sentence in sentences:
39395
+ if sentence not in text:
39396
+ report(f"{label} {surface.relative_to(ROOT)} does not say {sentence!r}.")
39397
+ return 1
39398
+ if surface in overlays and text.count("keel openspec …") != 1:
39399
+ report(f"{label} {surface.relative_to(ROOT)} tells the agent to use `keel openspec` {text.count('keel openspec …')} times, not once.")
39400
+ return 1
39401
+
39402
+ help_text = run_keel(ROOT, "--help").stdout
39403
+ for command in ("keel patrol", "keel tick"):
39404
+ if command not in help_text:
39405
+ report(f"{label} keel --help does not name {command!r}.")
39406
+ return 1
39407
+ chat_help = run_keel(ROOT, "chat", "help").stdout
39408
+ if "post-tool-use" not in chat_help:
39409
+ report(f"{label} keel chat help does not name the post-tool-use hook.")
39410
+ return 1
39411
+
39412
+ config = (ROOT / "src/core/config.js").read_text(encoding="utf-8")
39413
+ declared = re.search(r"const STANDING_AUTHORIZATION_ACTIONS = \[(.*?)\];", config, re.S)
39414
+ names = re.findall(r'^\s*"([a-z-]+)",', declared.group(1), re.M) if declared else []
39415
+ if len(names) < 13:
39416
+ report(f"{label} read {len(names)} standing-authorization names from config.js; expected at least 13.")
39417
+ return 1
39418
+ standing = (ROOT / "openspec/specs/keel-standing-authorization/spec.md").read_text(encoding="utf-8")
39419
+ vocabulary = re.search(r"(?s)### Requirement: A repository declares standing authorization in a closed vocabulary\n(.*?)\n#### ", standing)
39420
+ if not vocabulary:
39421
+ report(f"{label} keel-standing-authorization has no closed-vocabulary requirement to read.")
39422
+ return 1
39423
+ for name in names:
39424
+ if f"`{name}`" not in vocabulary.group(1):
39425
+ report(f"{label} keel-standing-authorization does not list `{name}` in its closed vocabulary.")
39426
+ return 1
39427
+ for spec, phrase in (
39428
+ ("keel-domain-lenses", "reads only the lens"),
39429
+ ("keel-domain-lenses", "no other lens is loaded"),
39430
+ ("keel-task-capsule", "current-agent ownership"),
39431
+ ):
39432
+ if phrase in (ROOT / f"openspec/specs/{spec}/spec.md").read_text(encoding="utf-8"):
39433
+ report(f"{label} {spec} still says {phrase!r}.")
39434
+ return 1
39435
+ if label.rstrip(":") not in {name for name, _ in SCENARIOS}:
39436
+ report(f"{label} the scenario registry does not include it.")
39437
+ return 1
39438
+ report(f"{label.rstrip(':')} scenario passed.")
39439
+ return 0
39440
+
39441
+
39299
39442
  def validate_tdd_strategy_guide_scenario() -> int:
39300
39443
  """Issue #389: the skill an executor loads to plan its checks says how to choose.
39301
39444
 
@@ -41414,6 +41557,7 @@ SCENARIOS: tuple = (
41414
41557
  ("tdd-strategy-guide", validate_tdd_strategy_guide_scenario),
41415
41558
  ("native-capabilities-unrestricted", validate_native_capabilities_unrestricted_scenario),
41416
41559
  ("native-projections-removed", validate_native_projections_removed_scenario),
41560
+ ("surfaces-agree-with-code", validate_surfaces_agree_with_code_scenario),
41417
41561
  (
41418
41562
  "a-tier-declares-what-is-skipped",
41419
41563
  validate_a_tier_declares_what_is_skipped_scenario,
@@ -41501,9 +41645,10 @@ def validate_openspec_invocable(errors: list[str]) -> None:
41501
41645
  cli = (ROOT / "bin/keel.js").read_text(encoding="utf-8")
41502
41646
  if 'options.action === "openspec"' not in cli:
41503
41647
  errors.append("bin/keel.js must implement the `keel openspec` passthrough.")
41504
- if cli.count("Invoke OpenSpec through") < 2:
41648
+ # Once per overlay, in the header every action shares (#413).
41649
+ if cli.count("Invoke the OpenSpec CLI as `keel openspec") < 2:
41505
41650
  errors.append(
41506
- "the apply and archive overlays must direct agents to `keel openspec` "
41651
+ "the apply, archive, and sync overlays must direct agents to `keel openspec` "
41507
41652
  "in place of a bare openspec command."
41508
41653
  )
41509
41654
 
@@ -48,7 +48,7 @@ const USAGE = [
48
48
  "keel chat bot add|remove <name> | list (the Slack bots this machine holds Keychain tokens for, as bot:<name> and app:<name>)",
49
49
  "keel chat notice (what is unread and addressed to you, for any host; always exits 0)",
50
50
  "keel chat notice --check (for schedulers: no output; exit 0 only when something addressed to you is unread, else 1)",
51
- "keel chat hook session-start|user-prompt-submit|file-changed|session-end (Claude Code hook; JSON on stdin)",
51
+ "keel chat hook session-start|user-prompt-submit|post-tool-use|file-changed|session-end (Claude Code hook; JSON on stdin)",
52
52
  "keel chat wake add [--host codex] [--thread <id>] [--max-per-hour <n>] [--compact-at <tokens>] (this machine starts a Codex turn when something addressed to this worktree's role arrives)",
53
53
  "keel chat wake remove (stop waking this worktree's role on this machine)",
54
54
  "keel chat wake status [--json]",
@@ -36,8 +36,9 @@ const STANDING_AUTHORIZATION_ACTIONS = [
36
36
  // (#319). It reaches that one session, so it takes no scope.
37
37
  "shift-restore",
38
38
  // A session's own four outgoing steps on the desktop app, after `keel shift
39
- // ready --wake` stored its note: Remote Control off, the wake task, the
40
- // rename, and the clear (#319). Never the decision to change shift.
39
+ // ready --wake` stored its note: the wake task, starting it, the rename,
40
+ // and the clear (#319; Remote Control stays on since #324). Never the
41
+ // decision to change shift.
41
42
  "self-shift",
42
43
  ];
43
44
 
@@ -1481,7 +1481,7 @@ function compileTaskContract(repo, change, task, options = {}) {
1481
1481
  id: task.id,
1482
1482
  title: normalizeText(task.title),
1483
1483
  },
1484
- owner: normalizeText(field(task, "Owner")) || "keel-agent",
1484
+ ...(normalizeText(field(task, "Owner")) ? { owner: normalizeText(field(task, "Owner")) } : {}),
1485
1485
  mode,
1486
1486
  authority,
1487
1487
  read,
@@ -1543,11 +1543,8 @@ function compileTaskContract(repo, change, task, options = {}) {
1543
1543
  // Whether the action it performed was the authorized one is a Review
1544
1544
  // judgment; what the capsule fixes is the write posture.
1545
1545
  ...(mode === "repo-action" ? [] : ["must not commit"]),
1546
- "must not continue to another task",
1547
- "must not mark tasks complete",
1548
1546
  "must not push",
1549
1547
  "must not sync or archive",
1550
- "must not transfer Keel ownership",
1551
1548
  ...(NO_WRITE_MODES.has(mode) ? ["must not write product files"] : []),
1552
1549
  ],
1553
1550
  };