@debian777/kairos-mcp 4.7.3 → 4.8.0-beta.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.
Files changed (68) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cli/api-client.d.ts +15 -0
  3. package/dist/cli/api-client.d.ts.map +1 -1
  4. package/dist/cli/api-client.js +5 -0
  5. package/dist/cli/api-client.js.map +1 -1
  6. package/dist/cli/commands/cli-train.d.ts.map +1 -1
  7. package/dist/cli/commands/cli-train.js +11 -0
  8. package/dist/cli/commands/cli-train.js.map +1 -1
  9. package/dist/cli/commands/update.d.ts.map +1 -1
  10. package/dist/cli/commands/update.js +11 -0
  11. package/dist/cli/commands/update.js.map +1 -1
  12. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002001.md +97 -96
  13. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002002.md +1 -1
  14. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002003.md +19 -191
  15. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002004.md +3 -3
  16. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002005.md +7 -1
  17. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002006.md +2 -2
  18. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002007.md +1 -1
  19. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002008.md +2 -2
  20. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002009.md +199 -0
  21. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002010.md +202 -0
  22. package/dist/embed-docs/mem/README.md +4 -2
  23. package/dist/http/http-api-train-raw.d.ts.map +1 -1
  24. package/dist/http/http-api-train-raw.js +16 -1
  25. package/dist/http/http-api-train-raw.js.map +1 -1
  26. package/dist/resources/embedded-mcp-resources.d.ts +2 -0
  27. package/dist/resources/embedded-mcp-resources.d.ts.map +1 -1
  28. package/dist/resources/embedded-mcp-resources.js +12 -10
  29. package/dist/resources/embedded-mcp-resources.js.map +1 -1
  30. package/dist/resources/mem-injection-assertions.d.ts.map +1 -1
  31. package/dist/resources/mem-injection-assertions.js +3 -1
  32. package/dist/resources/mem-injection-assertions.js.map +1 -1
  33. package/dist/resources/mem-resources-boot.d.ts.map +1 -1
  34. package/dist/resources/mem-resources-boot.js +67 -32
  35. package/dist/resources/mem-resources-boot.js.map +1 -1
  36. package/dist/tools/forward-trace.d.ts.map +1 -1
  37. package/dist/tools/forward-trace.js +4 -2
  38. package/dist/tools/forward-trace.js.map +1 -1
  39. package/dist/tools/forward-view.d.ts.map +1 -1
  40. package/dist/tools/forward-view.js +8 -4
  41. package/dist/tools/forward-view.js.map +1 -1
  42. package/dist/tools/review-evidence-check.d.ts +12 -0
  43. package/dist/tools/review-evidence-check.d.ts.map +1 -0
  44. package/dist/tools/review-evidence-check.js +23 -0
  45. package/dist/tools/review-evidence-check.js.map +1 -0
  46. package/dist/tools/train.d.ts.map +1 -1
  47. package/dist/tools/train.js +4 -0
  48. package/dist/tools/train.js.map +1 -1
  49. package/dist/tools/train_schema.d.ts +5 -0
  50. package/dist/tools/train_schema.d.ts.map +1 -1
  51. package/dist/tools/train_schema.js +17 -1
  52. package/dist/tools/train_schema.js.map +1 -1
  53. package/dist/tools/tune-execute.d.ts.map +1 -1
  54. package/dist/tools/tune-execute.js +5 -2
  55. package/dist/tools/tune-execute.js.map +1 -1
  56. package/dist/tools/tune_schema.d.ts +5 -0
  57. package/dist/tools/tune_schema.d.ts.map +1 -1
  58. package/dist/tools/tune_schema.js +16 -1
  59. package/dist/tools/tune_schema.js.map +1 -1
  60. package/dist/ui/assets/{AccountPage-Nl6-dmbL.js → AccountPage-Dh4xpg2-.js} +1 -1
  61. package/dist/ui/assets/{index-IPXRZlMZ.css → index-DDuXMrmI.css} +1 -1
  62. package/dist/ui/assets/{index-3hsACvKc.js → index-Dv61quji.js} +2 -2
  63. package/dist/ui/index.html +2 -2
  64. package/dist/utils/version-compare.d.ts +10 -0
  65. package/dist/utils/version-compare.d.ts.map +1 -0
  66. package/dist/utils/version-compare.js +31 -0
  67. package/dist/utils/version-compare.js.map +1 -0
  68. package/package.json +1 -1
@@ -1,202 +1,30 @@
1
1
  ---
2
- version: "4.7.3"
2
+ version: "4.8.0-beta.0"
3
3
  slug: create-new-protocol-review
4
- title: Review and Publish New KAIROS Protocol
4
+ title: "DEPRECATED use phase-critic + create-new-protocol"
5
5
  ---
6
6
 
7
+ # DEPRECATED — create-new-protocol-review
7
8
 
8
- # Review and Publish New KAIROS Protocol
9
+ This adapter is **deprecated** as of v4.8.0.
9
10
 
10
- Validate a drafted KAIROS protocol through format review, stranger review, user
11
- approval, and train. Invoked by the authoring adapter (`create-new-protocol`) or
12
- directly to re-review an existing draft.
11
+ Its responsibilities are now handled by:
13
12
 
14
- ## Activation Patterns
13
+ 1. **phase-critic** (`2005`) — adversarial phase-boundary review (integrated
14
+ into the 2001 authoring flow as a mandatory gate before train).
15
+ 2. **create-new-protocol** (`2001`) — authoring adapter that now invokes
16
+ `phase-critic` directly and includes `review_evidence` in its `train` call.
15
17
 
16
- **Typically invoked by:** the authoring adapter's handoff step via
17
- `activate()` or a stored adapter URI.
18
+ ## Why deprecated
18
19
 
19
- **Can be invoked directly when user says:**
20
- - "review my protocol draft" / "validate this protocol"
21
- - "re-run format review on my draft"
22
- - "train my protocol" / "register my adapter"
20
+ The original flow split authoring (2001) and review (2003) into two chained
21
+ adapters. The phase-critic quality gate consolidates review into a single
22
+ `forward` step inside 2001, eliminating the chain hop and providing structured
23
+ evidence (`review_evidence`) on every train call.
23
24
 
24
- **Trigger pattern:** **review** / **validate** / **train** + (protocol / draft).
25
+ ## Migration
25
26
 
26
- **Must Never:**
27
- - Run shell verification without verifying that all input file paths exist first.
28
- - Skip format or stranger review.
29
- - Approve a draft merely because it sounds polished.
30
-
31
- **Must Always:**
32
- - Verify all input file paths exist before proceeding (`test -f`).
33
- - Require both reviews to pass before presenting to the user.
34
- - Freeze the draft checksum before `train`.
35
- - Review for truth, phase clarity, ambiguity, and weaker-agent executability.
36
-
37
- **Good trigger examples:**
38
- - handoff from `create-new-protocol` → run this protocol
39
- - "Review and train my protocol draft" → run this protocol
40
-
41
- **Bad trigger examples:**
42
- - "Create a new protocol" → use `create-new-protocol`
43
- - "Search for a protocol" → use `activate`
44
-
45
- ## Preflight Dependencies
46
-
47
- Before running review/publish steps, verify prerequisites up front:
48
-
49
- 1. Required MCP tools are reachable: `activate`, `forward`, `reward`, `train`.
50
- 2. Required shell utilities used in this workflow are callable.
51
- 3. Required authentication/session state is valid for MCP and SCM hosts.
52
- 4. All input file paths provided by the parent agent exist (`test -f`).
53
-
54
- If any dependency or auth check fails, stop and ask the user to choose either:
55
- proceed with AI-assisted setup or abort this run now.
56
-
57
- ```json
58
- {"contract":{"type":"comment","comment":{"min_length":80},"required":true}}
59
- ```
60
-
61
- ## Prerequisites
62
-
63
- This protocol receives all file paths as absolute paths from the invoking agent:
64
-
65
- - `$DRAFT_FILE` — the protocol draft to review (required)
66
- - `$REQUIREMENTS_FILE` — requirements document (optional)
67
- - `$FORMAT_REVIEW_FILE` — output path for format review verdict
68
- - `$STRANGER_REVIEW_FILE` — output path for stranger review verdict
69
- - `$DRAFT_CHECKSUM_FILE` — output path for the frozen checksum
70
-
71
- The parent agent is responsible for choosing collision-free paths (e.g., under
72
- `$KAIROS_LOCAL_ARTIFACT_DIR` with a session-unique segment). This protocol only
73
- verifies paths exist via `test -f` and writes to the provided output paths.
74
-
75
- If invoked directly, export the variables before proceeding.
76
-
77
- **Security:** never write credentials, tokens, or secrets into output files.
78
-
79
- ## Format Review [SUBAGENT]
80
-
81
- Delegate format verification to a subagent. The subagent writes its verdict to
82
- `$FORMAT_REVIEW_FILE`.
83
-
84
- **Input:** `$DRAFT_FILE`
85
-
86
- **Subagent task:**
87
- 1. Read the draft.
88
- 2. Verify structure:
89
- - H1 present exactly once
90
- - first H2 is `Activation Patterns`
91
- - last H2 is `Reward Signal`
92
- - every middle H2 has a challenge block
93
- - no duplicate H2 headings
94
- 3. Verify authoring quality:
95
- - explicit phase separation where relevant
96
- - no hidden assumptions
97
- - no vague filler such as "as needed" when a concrete instruction is required
98
- 4. Verify challenge type selection using `challenge-type-guide`:
99
- - no `comment` challenges for steps that create files, call tools, or check state
100
- - `shell` challenges include `timeout_seconds`
101
- - shell chains use `&&`, not `;`, except for the agent-readable shell status
102
- trailer from `challenge-type-guide`
103
- 5. Verify DRY, slug, and 350-line compliance.
104
- 6. Write verdict to `$FORMAT_REVIEW_FILE`. First line MUST be
105
- `PASS` or `FAIL`. Remaining lines list concrete fixes.
106
-
107
- **Output:** `$FORMAT_REVIEW_FILE`
108
-
109
- ```json
110
- {"contract":{"type":"shell","shell":{"cmd":"test -f \"$FORMAT_REVIEW_FILE\" && head -1 \"$FORMAT_REVIEW_FILE\" | grep -qi 'pass'","timeout_seconds":5},"required":true}}
111
- ```
112
-
113
- ## Stranger Review [SUBAGENT]
114
-
115
- Delegate executability review to a subagent with junior AI agent persona. The
116
- subagent writes its verdict to `$STRANGER_REVIEW_FILE`.
117
-
118
- **Input:** `$DRAFT_FILE`
119
-
120
- **Subagent task:**
121
- 1. Assume persona: junior AI agent, first time encountering KAIROS protocols.
122
- 2. Mocked dry-run: walk every step in order and produce structurally correct
123
- challenge responses.
124
- 3. Check:
125
- - can I execute this without guessing?
126
- - are phases clear?
127
- - do I know when to stop, ask, execute, verify, or escalate uncertainty?
128
- - are any variables or concepts undefined?
129
- 4. Write verdict to `$STRANGER_REVIEW_FILE`. First line MUST be
130
- `PASS` or `FAIL`. If FAIL, include specific failing mocks and missing context.
131
-
132
- **Output:** `$STRANGER_REVIEW_FILE`
133
-
134
- ```json
135
- {"contract":{"type":"shell","shell":{"cmd":"test -f \"$STRANGER_REVIEW_FILE\" && head -1 \"$STRANGER_REVIEW_FILE\" | grep -qi 'pass'","timeout_seconds":5},"required":true}}
136
- ```
137
-
138
- ## Checksum Freeze [SUBAGENT]
139
-
140
- Freeze the draft after both reviews pass.
141
-
142
- **Input:** `$DRAFT_FILE`
143
-
144
- **Actions:**
145
- 1. Compute md5 checksum of the draft file.
146
- 2. Write checksum to `$DRAFT_CHECKSUM_FILE`.
147
-
148
- **Output:** `$DRAFT_CHECKSUM_FILE`
149
-
150
- ```json
151
- {"contract":{"type":"shell","shell":{"cmd":"md5 -q \"$DRAFT_FILE\" > \"$DRAFT_CHECKSUM_FILE\" && test -s \"$DRAFT_CHECKSUM_FILE\"","timeout_seconds":5},"required":true}}
152
- ```
153
-
154
- ## User Review [SUBAGENT]
155
-
156
- Present the reviewed protocol to the user for final approval.
157
-
158
- **Input:** draft plus both review files
159
-
160
- **Actions:**
161
- 1. Present full protocol markdown.
162
- 2. Summarise pattern used, step count, challenge types, slug(s), and both review verdicts.
163
- 3. Ask the user to approve, request changes, or cancel.
164
-
165
- **Output:** user approval, changes, or cancellation.
166
-
167
- ```json
168
- {"contract":{"type":"user_input","user_input":{"prompt":"Review the protocol draft above. Type 'approved' to run train, describe adjustments, or 'cancel'."},"required":true}}
169
- ```
170
-
171
- ## Train adapter [SUBAGENT]
172
-
173
- Verify the draft is unchanged since checksum freeze, then call `train`.
174
-
175
- **Input:** approved `$DRAFT_FILE`
176
-
177
- **Actions:**
178
- 1. Verify draft unchanged against checksum.
179
- 2. Call `train` with `force_update: false` unless overwrite was explicitly requested.
180
- 3. If router pattern: train router first, then extensions in order.
181
- 4. Verify each `train` call returned a URI.
182
- 5. Report stored adapter URI(s) back to the user.
183
-
184
- **Output:** confirmation with stored adapter URI(s)
185
-
186
- ```json
187
- {"contract":{"type":"mcp","mcp":{"tool_name":"train"},"required":true}}
188
- ```
189
-
190
- ## Reward Signal
191
-
192
- Only reachable after all prior steps are solved.
193
-
194
- The user now has a trained KAIROS adapter that passed:
195
- 1. format review
196
- 2. stranger review
197
- 3. checksum verification
198
- 4. user approval
199
- 5. successful storage via `train`
200
-
201
- The resulting adapter is more likely to be truthful, phase-aware, and usable by
202
- weaker agents.
27
+ - If you were forwarded here by `create-new-protocol`, the parent adapter
28
+ already runs `phase-critic` and will train automatically.
29
+ - If you invoked this slug directly, use `activate` with a phrase like
30
+ "create a new protocol" to match `2001` instead.
@@ -1,5 +1,5 @@
1
1
  ---
2
- version: "4.7.3"
2
+ version: "4.8.0-beta.0"
3
3
  slug: challenge-type-guide
4
4
  title: Challenge Type Selection Guide
5
5
  ---
@@ -15,7 +15,7 @@ drafting and review.
15
15
  ## Activation Patterns
16
16
 
17
17
  **Typically invoked by:** `create-new-protocol` and
18
- `create-new-protocol-review`.
18
+ `phase-critic`.
19
19
 
20
20
  **Can be invoked directly when agent needs:**
21
21
  - "challenge type reference" / "which challenge type to use"
@@ -39,7 +39,7 @@ drafting and review.
39
39
 
40
40
  **Bad trigger examples:**
41
41
  - "Create a new protocol" → use `create-new-protocol`
42
- - "Review my protocol draft" → use `create-new-protocol-review`
42
+ - "Review my protocol draft" → use `phase-critic`
43
43
 
44
44
  ## Core Rules
45
45
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- version: "4.7.3"
2
+ version: "4.8.0-beta.0"
3
3
  slug: phase-critic
4
4
  title: Phase Critic
5
5
  ---
@@ -189,6 +189,12 @@ Turn the audit into a final PASS / FAIL result.
189
189
  line 2 is `High`, `Medium`, or `Low`, and the remaining lines summarise key
190
190
  findings.
191
191
 
192
+ **Verdict contract (calling adapter must obey):**
193
+ - Line 1 is `PASS` → calling adapter may continue to the next phase.
194
+ - Line 1 is `FAIL` → calling adapter **MUST NOT** proceed to reward, **MUST NOT**
195
+ ask the user for approval, and **MUST NOT** continue to the next phase.
196
+ The calling adapter must address findings and re-invoke phase-critic.
197
+
192
198
  **Output:** final verdict file
193
199
 
194
200
  ```json
@@ -1,5 +1,5 @@
1
1
  ---
2
- version: "4.7.3"
2
+ version: "4.8.0-beta.0"
3
3
  slug: protocol-linking-guide
4
4
  title: Protocol Linking Guide
5
5
  ---
@@ -15,7 +15,7 @@ validation for deterministic cross-protocol linking.
15
15
  ## Activation Patterns
16
16
 
17
17
  **Typically invoked by:** `create-new-protocol` and
18
- `create-new-protocol-review`.
18
+ `phase-critic`.
19
19
 
20
20
  **Can be invoked directly when agent needs:**
21
21
  - "layers vs chains" / "when to split into multiple adapters"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  slug: bulk-insert-adapters-via-cli
3
- version: "4.7.3"
3
+ version: "4.8.0-beta.0"
4
4
  title: Bulk Insert Adapters via KAIROS CLI
5
5
  ---
6
6
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- version: "4.7.3"
2
+ version: "4.8.0-beta.0"
3
3
  slug: skill-format-guide
4
4
  title: Skill Format and Local Authoring Guide
5
5
  ---
@@ -16,7 +16,7 @@ protocol-authoring agents during drafting and review when the output format is
16
16
  ## Activation Patterns
17
17
 
18
18
  **Typically invoked by:** `create-new-protocol` and
19
- `create-new-protocol-review`.
19
+ `phase-critic`.
20
20
 
21
21
  **Can be invoked directly when agent needs:**
22
22
  - "SKILL.md format reference" / "how to write a skill"
@@ -0,0 +1,199 @@
1
+ ---
2
+ version: "4.8.0-beta.0"
3
+ slug: phase-critic-guide
4
+ title: Phase Critic Integration and Mutation Gate Guide
5
+ ---
6
+
7
+ # Phase Critic Integration and Mutation Gate Guide
8
+
9
+ Decision rules for integrating `phase-critic` into adapter protocols and
10
+ determining when solution checks (hard verification gates) are required versus
11
+ when phase-critic review is sufficient.
12
+
13
+ ## Activation Patterns
14
+
15
+ **Typically invoked by:** `create-new-protocol` during adapter drafting, and
16
+ any adapter that includes review or validation phases.
17
+
18
+ **Can be invoked directly when agent needs:**
19
+ - "when to add phase critic" / "should I use solution check"
20
+ - "mutation gate rules" / "which actions need hard gates"
21
+ - "phase critic vs solution check" / "irreversible action rules"
22
+ - "add review step to protocol" / "where does critic go"
23
+
24
+ **Trigger pattern:** **phase critic** / **mutation gate** / **solution check** +
25
+ (integration | when | rules | guide | which | where).
26
+
27
+ **Must Never:**
28
+ - Be used as an execution protocol.
29
+ - Override the adapter author's judgment on review depth.
30
+ - Recommend solution checks for reversible or local-only actions.
31
+
32
+ **Must Always:**
33
+ - Distinguish between quality review (phase-critic) and mutation blocking
34
+ (solution checks).
35
+ - Recommend phase-critic at every major phase boundary.
36
+ - Restrict solution checks to irreversible remote-system mutations.
37
+
38
+ **Good trigger examples:**
39
+ - drafting a new adapter and deciding where to add review → load this
40
+ - reviewing whether an adapter has the right solution checks → load this
41
+ - "does my MR step need a solution check?" → load this
42
+
43
+ **Bad trigger examples:**
44
+ - "run the phase critic" → use `activate` to match `phase-critic`
45
+ - "create a new protocol" → use `create-new-protocol`
46
+ - "which challenge type for this step?" → use `challenge-type-guide`
47
+
48
+ ## Core Decision Rule
49
+
50
+ **Phase-critic** is an adversarial review step at phase boundaries. It verifies
51
+ claims, gathers evidence, and searches for contradictions. Use it for quality
52
+ and truthfulness review.
53
+
54
+ **Solution checks** are per-layer contract verification mechanisms (shell
55
+ commands, MCP tool calls, user input). Use them ONLY to block actions that
56
+ cause **irreversible changes on remote systems**.
57
+
58
+ ### What counts as an irreversible remote mutation
59
+
60
+ | Action | Needs solution check? | Why |
61
+ |--------|----------------------|-----|
62
+ | Create/update merge request | Yes | Remote system state change |
63
+ | Create/update Jira issue | Yes | Remote system state change |
64
+ | Send email | Yes | Cannot unsend |
65
+ | Send Teams message | Yes | Cannot unsend |
66
+ | Create calendar invite | Yes | Sends notifications |
67
+ | Deploy to production | Yes | Irreversible infrastructure change |
68
+ | Delete remote resource | Yes | Irreversible |
69
+ | Push to git remote | Yes | Remote state change |
70
+ | Write/edit local file | No | Use phase-critic instead |
71
+ | Run local tests | No | Read-only / local |
72
+ | Analyze code | No | Read-only |
73
+ | Generate report | No | Local artifact |
74
+ | Read data from API | No | Read-only |
75
+ | Compute / transform data | No | Local operation |
76
+
77
+ ```json
78
+ {"contract":{"type":"comment","comment":{"min_length":30},"required":true}}
79
+ ```
80
+
81
+ ## How to Chain Phase-Critic into an Adapter
82
+
83
+ Use `forward` + slug to invoke `phase-critic` at phase boundaries. The standard
84
+ pattern is a `mcp` contract that requires calling `forward` with the
85
+ `phase-critic` slug:
86
+
87
+ ### After a planning phase
88
+
89
+ ```json
90
+ {"contract":{"type":"mcp","mcp":{"tool_name":"forward","arguments":{"uri":"kairos://adapter/phase-critic"}},"required":true}}
91
+ ```
92
+
93
+ ### After an implementation phase
94
+
95
+ Use the same contract. The phase-critic adapter receives the calling protocol's
96
+ context and independently verifies the work.
97
+
98
+ ### Verdict handoff pattern
99
+
100
+ Phase-critic writes a verdict file. The calling adapter reads it:
101
+
102
+ 1. Phase-critic writes `$VERDICT_FILE` with `PASS`/`FAIL` on line 1.
103
+ 2. Calling adapter's next layer reads the verdict file.
104
+ 3. If `FAIL` → **hard stop**: do NOT proceed to reward, do NOT ask the user
105
+ for approval, do NOT continue to the next phase. Address findings first.
106
+ 4. If `PASS` → the adapter continues to the next phase.
107
+
108
+ **FAIL is a hard stop, not an escalation trigger.** A FAIL verdict means the
109
+ work is not ready. Asking the user "should I proceed?" after FAIL bypasses the
110
+ review. The correct action is to fix the findings and re-invoke phase-critic.
111
+
112
+ ### FAIL gate contract (required after every phase-critic invocation)
113
+
114
+ Every adapter that chains phase-critic **must** include a shell contract that
115
+ fails when the verdict is not PASS. This is the mechanical guard that prevents
116
+ weaker agents from proceeding after FAIL:
117
+
118
+ ```json
119
+ {"contract":{"type":"shell","shell":{"cmd":"head -1 \"$VERDICT_FILE\" | grep -qi '^PASS$'","timeout_seconds":5},"required":true}}
120
+ ```
121
+
122
+ If the critic wrote FAIL, this shell command exits non-zero. The server rejects
123
+ the solution and the agent cannot advance to the next layer. Protocol wording
124
+ alone does not stop determined agents; this contract does.
125
+
126
+ ## Train/Tune Evidence Requirement
127
+
128
+ `train` and `tune` enforce phase-critic PASS at the tool level:
129
+
130
+ - **Adapter (markdown) `train`** requires `review_evidence`: verdict_file path,
131
+ exit_code (must be 0), and stdout (line 1 must be PASS). Without it, the
132
+ server rejects the store with `REVIEW_EVIDENCE_REQUIRED`.
133
+ - **`tune` with content** requires the same `review_evidence`. Space-only moves
134
+ skip this check.
135
+ - **Artifact trains** (non-markdown mime) skip the evidence check.
136
+
137
+ This is the tool-level enforcement of the FAIL gate. Even if an agent bypasses
138
+ the adapter flow and calls `train` directly, the server rejects the store
139
+ without PASS evidence. The agent must run phase-critic, capture the verdict
140
+ file, and pass it as `review_evidence`.
141
+
142
+ ## Mutation Gate Pattern
143
+
144
+ When an adapter step performs an irreversible remote mutation, add a solution
145
+ check that requires explicit confirmation BEFORE the action:
146
+
147
+ ### Pre-mutation confirmation
148
+
149
+ ```json
150
+ {"contract":{"type":"user_input","user_input":{"prompt":"Confirm: you are about to create a merge request on repo X targeting branch Y. This action cannot be undone."},"required":true}}
151
+ ```
152
+
153
+ ### Post-mutation verification
154
+
155
+ ```json
156
+ {"contract":{"type":"mcp","mcp":{"tool_name":"getMergeRequest","arguments":{"repo":"X"}},"required":true}}
157
+ ```
158
+
159
+ ## Phase-Critic Placement Rules
160
+
161
+ 1. **Add phase-critic at every major phase boundary** — after planning, after
162
+ implementation, after validation.
163
+ 2. **Do NOT add phase-critic between every layer** — it is a phase-level review,
164
+ not a step-level check.
165
+ 3. **Add solution checks ONLY on layers that perform remote mutations** — see
166
+ the table above.
167
+ 4. **Never replace a solution check with phase-critic** for remote mutations —
168
+ phase-critic reviews truth, it does not block execution.
169
+ 5. **Never add a solution check for local operations** — phase-critic provides
170
+ sufficient review.
171
+
172
+ ## Adapter Authoring Checklist
173
+
174
+ When drafting a new adapter, apply this checklist:
175
+
176
+ 1. Identify all phase boundaries in the adapter flow.
177
+ 2. Add a `phase-critic` chain link at each boundary.
178
+ 3. Identify all steps that perform irreversible remote mutations.
179
+ 4. Add solution checks (user_input + post-action verification) for each.
180
+ 5. Verify that no solution checks exist for purely local operations.
181
+ 6. Verify that the phase-critic verdict handoff pattern is present.
182
+ 7. Verify that a FAIL gate shell contract follows every phase-critic invocation.
183
+ 8. Verify that `train`/`tune` calls include `review_evidence` from the critic.
184
+ 9. Ensure the adapter's Reward Signal describes what the critic protects.
185
+
186
+ ```json
187
+ {"contract":{"type":"comment","comment":{"min_length":80},"required":true}}
188
+ ```
189
+
190
+ ## Reward Signal
191
+
192
+ Only reachable after all prior steps are solved.
193
+
194
+ The agent can now:
195
+ 1. Decide when to use phase-critic versus solution checks
196
+ 2. Identify irreversible remote mutations that need hard gates
197
+ 3. Chain phase-critic into adapters at the correct phase boundaries
198
+ 4. Apply the mutation gate pattern for remote-system actions
199
+ 5. Avoid unnecessary solution checks for local or read-only operations