@squadrules/mcp 5.13.7 → 5.14.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 (77) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cli/commands/export.d.ts +1 -0
  3. package/dist/cli/commands/export.d.ts.map +1 -1
  4. package/dist/cli/commands/export.js +23 -0
  5. package/dist/cli/commands/export.js.map +1 -1
  6. package/dist/embed-docs/mem/README.md +32 -14
  7. package/dist/embed-docs/mem/adapter-migration.md +59 -47
  8. package/dist/embed-docs/mem/author-adapter.md +132 -70
  9. package/dist/embed-docs/mem/bulk-insert-adapters-via-cli.md +59 -24
  10. package/dist/embed-docs/mem/challenge-type-guide.md +53 -13
  11. package/dist/embed-docs/mem/critic-loop-guide.md +38 -17
  12. package/dist/embed-docs/mem/critic-loop.md +24 -17
  13. package/dist/embed-docs/mem/protocol-linking-guide.md +10 -3
  14. package/dist/embed-docs/mem/refine-search.md +1 -1
  15. package/dist/resources/embedded-mcp-resources.js +13 -13
  16. package/dist/resources/embedded-mcp-resources.js.map +1 -1
  17. package/dist/services/memory/qdrant-point-to-memory.d.ts.map +1 -1
  18. package/dist/services/memory/qdrant-point-to-memory.js +10 -1
  19. package/dist/services/memory/qdrant-point-to-memory.js.map +1 -1
  20. package/dist/tools/activate-artifacts.d.ts +25 -0
  21. package/dist/tools/activate-artifacts.d.ts.map +1 -0
  22. package/dist/tools/activate-artifacts.js +57 -0
  23. package/dist/tools/activate-artifacts.js.map +1 -0
  24. package/dist/tools/activate.d.ts.map +1 -1
  25. package/dist/tools/activate.js +17 -64
  26. package/dist/tools/activate.js.map +1 -1
  27. package/dist/tools/activate_schema.d.ts +9 -0
  28. package/dist/tools/activate_schema.d.ts.map +1 -1
  29. package/dist/tools/activate_schema.js +2 -1
  30. package/dist/tools/activate_schema.js.map +1 -1
  31. package/dist/tools/artifact-materialize-command.d.ts +22 -0
  32. package/dist/tools/artifact-materialize-command.d.ts.map +1 -0
  33. package/dist/tools/artifact-materialize-command.js +37 -0
  34. package/dist/tools/artifact-materialize-command.js.map +1 -0
  35. package/dist/tools/forward-error-payload.d.ts +7 -0
  36. package/dist/tools/forward-error-payload.d.ts.map +1 -0
  37. package/dist/tools/forward-error-payload.js +30 -0
  38. package/dist/tools/forward-error-payload.js.map +1 -0
  39. package/dist/tools/forward-helpers.d.ts +7 -0
  40. package/dist/tools/forward-helpers.d.ts.map +1 -1
  41. package/dist/tools/forward-helpers.js +9 -2
  42. package/dist/tools/forward-helpers.js.map +1 -1
  43. package/dist/tools/forward-view.d.ts +2 -0
  44. package/dist/tools/forward-view.d.ts.map +1 -1
  45. package/dist/tools/forward-view.js +17 -3
  46. package/dist/tools/forward-view.js.map +1 -1
  47. package/dist/tools/forward_schema.d.ts +26 -1
  48. package/dist/tools/forward_schema.d.ts.map +1 -1
  49. package/dist/tools/forward_schema.js +8 -2
  50. package/dist/tools/forward_schema.js.map +1 -1
  51. package/dist/tools/next-pow-challenge-shape.d.ts.map +1 -1
  52. package/dist/tools/next-pow-challenge-shape.js +45 -2
  53. package/dist/tools/next-pow-challenge-shape.js.map +1 -1
  54. package/dist/tools/next-pow-helpers.d.ts.map +1 -1
  55. package/dist/tools/next-pow-helpers.js +13 -29
  56. package/dist/tools/next-pow-helpers.js.map +1 -1
  57. package/dist/tools/review-evidence-check.d.ts +2 -0
  58. package/dist/tools/review-evidence-check.d.ts.map +1 -1
  59. package/dist/tools/review-evidence-check.js +5 -3
  60. package/dist/tools/review-evidence-check.js.map +1 -1
  61. package/dist/tools/reward.d.ts.map +1 -1
  62. package/dist/tools/reward.js +15 -0
  63. package/dist/tools/reward.js.map +1 -1
  64. package/dist/tools/shell-failure-diagnostics.d.ts +19 -0
  65. package/dist/tools/shell-failure-diagnostics.d.ts.map +1 -0
  66. package/dist/tools/shell-failure-diagnostics.js +58 -0
  67. package/dist/tools/shell-failure-diagnostics.js.map +1 -0
  68. package/dist/tools/tool-registry.d.ts +24 -1
  69. package/dist/tools/tool-registry.d.ts.map +1 -1
  70. package/dist/ui/assets/{AccountPage-D5vGSe-z.js → AccountPage-Co_hJpj2.js} +1 -1
  71. package/dist/ui/assets/{index-eUOMUZwn.js → index-_ERynoIs.js} +2 -2
  72. package/dist/ui/index.html +1 -1
  73. package/package.json +1 -1
  74. package/dist/tools/squadrules-challenge-display.d.ts +0 -4
  75. package/dist/tools/squadrules-challenge-display.d.ts.map +0 -1
  76. package/dist/tools/squadrules-challenge-display.js +0 -81
  77. package/dist/tools/squadrules-challenge-display.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  slug: author-adapter
3
- version: "5.13.7"
3
+ version: "5.14.0"
4
4
  title: Author Adapter (Create / Review / Refactor)
5
5
  ---
6
6
 
@@ -30,6 +30,10 @@ Supports three operations:
30
30
  - **update** — apply specific corrections to an existing adapter and
31
31
  save the correction. Also triggered by: edit, fix, modify, change, improve, patch, refactor.
32
32
 
33
+ A fourth lifecycle operation, **delete**, is not run here: follow the Delete flow
34
+ in `docs/adapter-authoring-guide.md` (export, check the slug is not a chain
35
+ dependency, call `delete`, verify it no longer resolves).
36
+
33
37
  **Run this adapter when the user says ANY of:**
34
38
  - "create a new SQUADRULES adapter" / "register a personal adapter"
35
39
  - "train adapter into personal" / "train a workflow"
@@ -45,6 +49,8 @@ Supports three operations:
45
49
  **Must Never:**
46
50
  - Run when the user only asked to execute an existing adapter.
47
51
  - Mutate adapters during a `review` operation.
52
+ - Review your own draft: the critic pass is delegated, never performed on the
53
+ drafting thread.
48
54
  - Optimise only for pretty wording; this adapter designs agent behaviour.
49
55
  - Treat "update", "edit", or "modify an existing adapter" as **create**.
50
56
 
@@ -60,16 +66,15 @@ Supports three operations:
60
66
  Before running authoring actions, verify dependency and auth readiness:
61
67
  1. Required MCP tools are available: `activate`, `forward`, `reward`, and the
62
68
  operation-dependent tool (`train`, `export`, or `tune`).
63
- 2. Required CLI tools for planned shell steps are installed and callable.
69
+ 2. A subagent facility is available in this host for the critic pass. Without it
70
+ this adapter cannot verify its own work: stop and report the blocker rather
71
+ than reviewing the draft yourself.
64
72
  3. Required auth/session state is valid for the target MCP server.
65
73
 
66
74
  If any check fails, attempt AI-assisted remediation automatically, then re-run
67
75
  preflight. Only hard-stop when a required tool or auth genuinely cannot be
68
- established autonomously.
69
-
70
- ```json
71
- {"contract":{"type":"shell","shell":{"cmd":"echo 'preflight: ok'","interpreter":"bash","timeout_seconds":10},"required":true}}
72
- ```
76
+ established autonomously. These are checks you perform, not gates: a failure here
77
+ produces a repair action, so no contract is spent on them.
73
78
 
74
79
  ## Resolve Intent Autonomously
75
80
 
@@ -86,10 +91,6 @@ Resolve the target from context without a confirmation prompt. Record the
86
91
  inferred operation and target, then continue. Escalate to the user only when
87
92
  the request is genuinely ambiguous and no reasonable default exists.
88
93
 
89
- ```json
90
- {"contract":{"type":"subagent","subagent":{"context":"Resolve the authoring operation (create/review/update) and target adapter from user context. Record the decision."},"required":true}}
91
- ```
92
-
93
94
  ## Gather Requirements
94
95
 
95
96
  ### For `create` — collect details for a new adapter
@@ -113,27 +114,75 @@ Export target adapter(s). Check: user-need fit, mode/step clarity,
113
114
  cross-reference completeness, handoff gaps, DRY violations, contract coverage,
114
115
  truth-first behaviour, activation pattern accuracy, structure compliance
115
116
  (first H2 Activation Patterns, last H2 Reward Signal, under 350 lines),
116
- sibling consistency, chained adapter families, critic-loop integration.
117
+ sibling consistency, chained adapter families, and whether every critic hop in
118
+ the audited adapters is a `subagent` contract rather than a `forward` contract.
117
119
 
118
120
  ### For `update` — identify the specific issue
119
121
 
120
122
  Export the target adapter, read the current markdown, identify the exact gap or
121
123
  error, and plan the minimal change.
122
124
 
123
- ```json
124
- {"contract":{"type":"subagent","subagent":{"context":"Gather requirements for the resolved operation: collect pattern/details for create, audit checklist for review, or identify the specific issue for update."},"required":true}}
125
+ ## Draft Markdown
126
+
127
+ ### Allocate the handoff paths first
128
+
129
+ The gates below read files that only exist if you created them. Resolve one hint
130
+ from the `squadrules_local_artifact_dir` field of the latest `activate` or
131
+ `forward` response (`project://<rel>` → this project root, `user://<rel>` → your
132
+ home or `$XDG_CONFIG_HOME`), export the absolute result as
133
+ `SQUADRULES_LOCAL_ARTIFACT_DIR`, then allocate collision-free paths for the
134
+ target slug:
135
+
136
+ ```bash
137
+ export SQUADRULES_LOCAL_ARTIFACT_DIR="<resolved absolute path>"
138
+ D="$SQUADRULES_LOCAL_ARTIFACT_DIR/author-adapter-$SLUG"
139
+ mkdir -p "$D"
140
+ export WORK_MANIFEST="$D/work-manifest.txt" # the critic's submission
141
+ export VERDICT_FILE="$D/verdict.txt" # the critic's verdict
142
+ export REVIEW_FINDINGS_FILE="$D/findings.md" # review operation only
125
143
  ```
126
144
 
127
- ## Draft Markdown
145
+ The server never names a path on your machine; you do.
128
146
 
129
147
  ### MCP / Local-Filesystem Boundary
130
148
 
131
149
  - A personal adapter stored in MCP **cannot** reference local files.
132
- - Only **system adapters** (bundled in the server) can chain to other system
133
- adapters via `forward`.
134
- - Personal adapters must be **self-contained**.
135
- - When a shell contract needs a reusable script, attach it as an **artifact**
136
- via `train` (with `mime`, `artifact_name`, `adapter_uri`).
150
+ - Any adapter — system or personal — may chain to another adapter with a
151
+ `forward` contract naming `squadrules://adapter/<slug>`; slugs are globally
152
+ unique, so resolution is deterministic.
153
+ - A personal adapter must still be **self-contained** in its instructions: it
154
+ cannot rely on files that only exist in one repository.
155
+ - When a `shell` check has more than one condition, parses JSON, or does not fit
156
+ one readable line, put it in a **gate script artifact** — it is stored with the
157
+ adapter and materialized at run time, not read from your local files; never
158
+ escape a program inline into `cmd`.
159
+ - Order: `train` the adapter markdown first, then `train` the script as an
160
+ artifact — an artifact attaches only to an adapter that already exists. Pin the
161
+ script's identity with a `# squadrules-artifact:` header, and pass
162
+ `force_update: true` on a re-train that matches it, so a fix updates
163
+ that artifact instead of adding a second one. Input fields and the refusal
164
+ message: the `train` tool description.
165
+ - The artifact train targets `squadrules://adapter/<slug>`, so pin the adapter's
166
+ slug with frontmatter `slug:` instead of guessing the slug `train` derived from
167
+ the title.
168
+ - Keep the contract one line: `interpreter: "bash"`, `cmd: python3
169
+ "$SQUADRULES_LOCAL_ARTIFACT_DIR/artifacts/<name>.py" --gate <name>`.
170
+ - Verify before shipping — **two** checks, both required:
171
+ 1. `activate` the adapter and confirm `linked_artifacts[].relative_path` is
172
+ exactly the path `cmd` invokes. Run each row's `materialize` command before
173
+ the contract that needs it.
174
+ 2. **Export check:** call MCP **`export`** with
175
+ `uri: "squadrules://adapter/<slug>"` and `format: skill_tree` (or
176
+ `skill_zip` for the bundle) and confirm the script is present under
177
+ `artifacts/` at the path the contract invokes. Read the returned
178
+ `diagnostics[]`: `artifact_stored_sha_mismatch` or
179
+ `artifact_relative_path_invalid` means the stored artifact is broken —
180
+ re-train it instead of shipping it.
181
+ - A `cmd` that names a script the export does not contain is a broken adapter:
182
+ it fails at run time with a missing-file error and burns the user's step.
183
+ Fix it before shipping. The only exception is a repository-owned gate that
184
+ the adapter names explicitly and that lives in the user's repository — say so
185
+ in the adapter text, and state how the agent finds it.
137
186
 
138
187
  ### Drafting rules (all operations)
139
188
 
@@ -151,81 +200,94 @@ escalation, and observable verification over narrative reassurance.
151
200
  **Slug convention:** Every adapter gets a short, unique, lowercase-hyphenated slug.
152
201
 
153
202
  **Structure:** H1 title, first H2 Activation Patterns, second H2 Preflight
154
- Dependencies, middle H2s one per step with JSON contract block, last H2 Reward
203
+ Dependencies, middle H2s one per stage with JSON contract block, last H2 Reward
155
204
  Signal. Frontmatter: `slug` (required), `version` (optional), `chain_root`
156
205
  (required for mid-chain adapters).
157
206
 
158
- **Challenge types:** Load `challenge-type-guide` for decision rules and JSON
159
- formats (`forward` with `squadrules://adapter/challenge-type-guide`).
207
+ **Scripts are obtained, not assumed:** when a step's `cmd` invokes a script, the
208
+ adapter must state in its own text how the agent obtains that file before
209
+ running the command — materialize the `activate` artifact row, or `export` the
210
+ adapter. A step that says only "run `python3 …/artifacts/x.py`" leaves the agent
211
+ guessing where the file is; a missing-file gate failure is the most common
212
+ result of that omission.
213
+
214
+ **Contracts:** One per adapter is the default; a second is justified only at a
215
+ boundary that is hard to roll back. Load `challenge-type-guide` for decision
216
+ rules and JSON formats (`forward` with
217
+ `squadrules://adapter/challenge-type-guide`).
160
218
 
161
219
  **Critic-loop and mutation gates:** Load `critic-loop-guide` for placement,
162
- FAIL gate, and solution check rules (`forward` with
220
+ the FAIL gate, and the work-submission rules (`forward` with
163
221
  `squadrules://adapter/critic-loop-guide`).
164
222
 
165
223
  For `create`: draft the full adapter markdown.
166
224
  For `review`: write a structured gap report to `$REVIEW_FINDINGS_FILE`.
167
225
  For `update`: apply the identified change and show a diff-style summary.
168
226
 
169
- ```json
170
- {"contract":{"type":"subagent","subagent":{"context":"Draft the adapter markdown (create), findings report (review), or corrected markdown (update) following all shared drafting rules."},"required":true}}
171
- ```
172
-
173
227
  ## Critic-Loop Review (create and update only)
174
228
 
175
- For `create` and `update`: run critic-loop against the drafted markdown. This is
176
- an autonomous quality loop — the agent owns content, the critic owns quality, and
177
- no human approval is requested at any point.
229
+ For `create` and `update`: have the draft reviewed. This is an autonomous quality
230
+ loop — the agent owns content, the critic owns quality, and no human approval is
231
+ requested at any point. The critic must not be you: you wrote the draft, so your
232
+ own re-reading cannot detect what you did not intend to write.
178
233
 
179
- 1. Invoke critic-loop via `forward` with `squadrules://adapter/critic-loop`.
180
- Submit the drafted markdown as a `file_set` work submission — write
181
- `kind: file_set`, `root: <directory of the draft>`, then the drafted file
182
- under `items:` into the handoff pointed to by `$WORK_MANIFEST` — with the
183
- slug as `calling_protocol_slug` and "structural compliance and agent
184
- behaviour" as `verification_target`.
185
- 2. Run the FAIL gate shell contract on the verdict file:
234
+ Write the submission handoff to `$WORK_MANIFEST` as flat keys — `kind: file_set`,
235
+ `root: <directory of the draft>`, then `items:` with the drafted file's path on
236
+ one line — and delegate the review to a subagent. Delegate it now; do not audit
237
+ the draft on this thread first.
186
238
 
187
239
  ```json
188
- {"contract":{"type":"shell","shell":{"cmd":"head -1 \"$VERDICT_FILE\" | grep -qi '^PASS$'","interpreter":"bash","timeout_seconds":5},"required":true}}
240
+ {"contract":{"type":"subagent","subagent":{"context":"Run the critic on the drafted adapter markdown and return its actual report. Call the forward tool with uri squadrules://adapter/critic-loop and submit: work from $WORK_MANIFEST (kind file_set, the drafted file), the original requirement list, calling_protocol_slug author-adapter, verification_target 'structural compliance and agent behaviour', context.verdict_file $VERDICT_FILE, context.iteration and context.max_iterations (8). Follow critic-loop to its end, let it write $VERDICT_FILE, and report back its findings plus the verdict file's first two lines. Do not review the draft yourself and do not re-delegate the review.","mcp":[{"tool_name":"forward","arguments":{"uri":"squadrules://adapter/critic-loop"}}]},"required":true}}
189
241
  ```
190
242
 
191
- 3. If FAIL: address every finding, then re-invoke critic-loop and re-run the FAIL
192
- gate. **Loop automatically until the verdict is PASS** — do not proceed and do
193
- not ask the user whether to continue.
194
- 4. If PASS: capture the verdict file path for the `review_evidence` field
195
- in the `train` call below.
196
-
197
- For `review`: skip this step (read-only operation).
198
-
199
- ## FinaliseOperation
200
-
201
- No human approval step. The critic-loop PASS verdict is the sole quality gate.
202
-
203
- For `create`: call `train` with the drafted markdown and `review_evidence`
204
- from the critic-loop step. Use `force_update: false` unless overwrite was
205
- explicitly requested.
206
-
207
- For `review`: do not call `train`. Save the findings report only if requested.
208
-
209
- For `update`: use `tune` with the existing adapter URI, corrected content, and
210
- `review_evidence`. Use `train` with `force_update: true` only for a required
211
- structural replacement (changing identity/H1 mapping or layer count). Update the
212
- corresponding repository source when the adapter is repo-managed; make repository
213
- edits in the task's isolated worktree.
214
-
215
- Report the outcome: adapter URI(s) for create/update, or findings summary for
216
- review.
243
+ ## Save After a PASS Verdict
244
+
245
+ Read the verdict the critic left behind and act on it, then save.
246
+
247
+ 1. Run the gate below. `FAIL` → address **every** finding in the report, then
248
+ start a fresh critic pass the same way (a subagent delegating
249
+ `squadrules://adapter/critic-loop` with the corrected draft, the same
250
+ requirements, and `iteration` incremented) and re-run this gate. Loop
251
+ automatically; do not ask the user whether to continue.
252
+ 2. The loop is bounded by `max_iterations`. When `iteration` exceeds it, the
253
+ critic returns `failure_class: iteration_ceiling`: **stop looping**, report the
254
+ unresolved findings, and do not save an unreviewed draft as if it passed.
255
+ 3. On `PASS`, capture the verdict file path and save:
256
+ - `create` — call `train` with the drafted markdown and `review_evidence`
257
+ (verdict file path, exit code, stdout). Use `force_update: false` unless an
258
+ overwrite was explicitly requested.
259
+ - `update` — call `tune` with the existing adapter URI, corrected content, and
260
+ `review_evidence`. Use `train` with `force_update: true` only for a required
261
+ structural replacement (changing identity/H1 mapping or layer count). Update
262
+ the corresponding repository source when the adapter is repo-managed, and
263
+ make repository edits in the task's isolated worktree.
264
+ - `review` — do not call `train`; the operation is read-only and this gate is
265
+ satisfied by the findings report at `$REVIEW_FINDINGS_FILE`.
266
+ 4. Read the stored adapter back (`export` it, or the CLI on a local transport)
267
+ and compare it against what you intended to save; report the URI and any
268
+ difference. This is the run's completion criterion, not a gate: a remote
269
+ store cannot be observed from a shell command, so no contract asserts it.
217
270
 
218
271
  ```json
219
- {"contract":{"type":"comment","comment":{"min_length":80},"required":true}}
272
+ {"contract":{"type":"shell","shell":{"cmd":"head -1 \"$VERDICT_FILE\" | grep -qi '^PASS$'","interpreter":"bash","timeout_seconds":5},"required":true}}
220
273
  ```
221
274
 
222
275
  ## Reward Signal
223
276
 
224
277
  Adapter complete when:
225
- - `create` — adapter(s) stored via `train` (with review_evidence) and URI(s) reported
226
- - `review` — findings report delivered
227
- - `update` — corrected adapter saved via `tune` (or required structural replacement),
228
- read back and verified; repo-managed source updated in the task worktree
278
+ - `create` — a delegated critic returned `PASS`, the adapter is stored via `train`
279
+ with that `review_evidence`, its URI is reported, and the stored copy was read
280
+ back
281
+ - `review` — findings report delivered from `$REVIEW_FINDINGS_FILE`
282
+ - `update` — a delegated critic returned `PASS` on the changed parts, the corrected
283
+ adapter is saved via `tune` (or a required structural replacement), read back and
284
+ reported; repo-managed source updated in the task worktree
285
+
286
+ What this proves: a separate context ran `critic-loop` over the draft and left a
287
+ verdict file that reads `PASS`, and the store accepted that evidence. What it does
288
+ not prove: that the report came from that context, or that the verdict is bound to
289
+ the reviewed content — server-issued review receipts would be needed for that.
290
+ Report the outcome as it stands; a passing gate is not a guarantee of correctness.
229
291
 
230
292
  A successful result means the resulting SQUADRULES adapter is more truthful,
231
293
  step-aware, agent-readable, and aligned with human–AI harmony.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  slug: bulk-insert-adapters-via-cli
3
- version: "5.13.7"
3
+ version: "5.14.0"
4
4
  title: Bulk Insert Adapters via SQUADRULES CLI
5
5
  ---
6
6
 
@@ -59,12 +59,11 @@ Verify before execution:
59
59
  2. Authentication is valid (`squadrules token` returns a token without error).
60
60
  3. Target directory path exists and contains at least one `.md` file.
61
61
  4. If a space is specified, confirm it exists via `squadrules spaces`.
62
+ 5. A subagent facility is available for the review hop below. Without it the
63
+ store will refuse the upload; report the blocker, do not skip the review.
62
64
 
63
- If any check fails, stop and report the issue with remediation guidance.
64
-
65
- ```json
66
- {"contract":{"type":"shell","shell":{"cmd":"squadrules --version && squadrules token > /dev/null 2>&1 && echo 'auth: ok'","interpreter":"bash","timeout_seconds":15},"required":true}}
67
- ```
65
+ If any check fails, stop and report the issue with remediation guidance. These
66
+ checks are performed, not gated — the gate sits at the write.
68
67
 
69
68
  ## Resolve Scope and Validate
70
69
 
@@ -85,31 +84,54 @@ Validate each `.md` file against SQUADRULES adapter requirements:
85
84
  Skip invalid files, train the valid subset, and document every skipped file with
86
85
  its validation error and a suggested fix. Do not stop to ask the user.
87
86
 
87
+ ## Review the Set Before Uploading
88
+
89
+ `train` refuses a markdown adapter without critic-loop `PASS` evidence, so an
90
+ unreviewed batch uploads nothing. Allocate the handoff paths under
91
+ `$SQUADRULES_LOCAL_ARTIFACT_DIR` — resolve a hint from the
92
+ `squadrules_local_artifact_dir` field of the latest `activate`/`forward` response
93
+ and export it; the server never names a path on your machine. You need
94
+ `$WORK_MANIFEST`, `$VERDICT_FILE`, and `$BULK_LOG_FILE`. List the valid files in
95
+ `$WORK_MANIFEST` as flat keys (`kind: file_set`, `root: <source directory>`, then
96
+ `items:` with one file path per line) and delegate the review:
97
+
88
98
  ```json
89
- {"contract":{"type":"shell","shell":{"cmd":"test -d \"$SOURCE_DIR\" && find \"$SOURCE_DIR\" -name '*.md' | head -1 | grep -q .","interpreter":"bash","timeout_seconds":10},"required":true}}
99
+ {"contract":{"type":"subagent","subagent":{"context":"Run the critic over the adapter files listed in $WORK_MANIFEST and return its actual report. Call the forward tool with uri squadrules://adapter/critic-loop, submitting the file list as work kind file_set with the source directory as root, the requirement list above as requirements, and context.verdict_file $VERDICT_FILE with context.iteration and context.max_iterations (8). Do not review the files yourself.","mcp":[{"tool_name":"forward","arguments":{"uri":"squadrules://adapter/critic-loop"}}]},"required":true}}
90
100
  ```
91
101
 
92
- ## Execute Bulk Train
102
+ ## Prove the Write Boundary
93
103
 
94
- Run the batch train operation using the SQUADRULES CLI:
104
+ A directory batch overwrites adapters in a shared space: hard to roll back, so
105
+ one gate sits in front of it and one behind it. Run the gate below **before** any
106
+ `train` command. If it exits non-zero, nothing has been uploaded — fix the named
107
+ condition (install the CLI, re-authenticate, correct `$SOURCE_DIR`, or obtain a
108
+ `PASS` verdict), then run it again.
95
109
 
96
- ```
97
- squadrules train <directory> --recursive --model <model> --space <space> [--force]
110
+ ```json
111
+ {"contract":{"type":"shell","shell":{"cmd":"squadrules --version && squadrules token > /dev/null && test -d \"$SOURCE_DIR\" && find \"$SOURCE_DIR\" -name '*.md' | head -1 | grep -q . && head -1 \"$VERDICT_FILE\" | grep -qi '^PASS$'","interpreter":"bash","timeout_seconds":30},"required":true}}
98
112
  ```
99
113
 
100
- If the directory contains files that should NOT be trained (README, reference
101
- docs), either train file-by-file for the valid subset, or move non-adapter files
102
- out before running `--recursive`.
114
+ ## Run the Batch and Report
103
115
 
104
- Capture stdout and stderr. The CLI reports per-file status.
116
+ Run the batch and keep its report. The CLI reads review evidence from the
117
+ `SQUADRULES_REVIEW_EVIDENCE` environment variable as one JSON object
118
+ (`verdict_file`, `exit_code`, `stdout`) and reuses it for every file in a
119
+ directory batch. Therefore:
105
120
 
106
- ```json
107
- {"contract":{"type":"shell","shell":{"cmd":"squadrules train \"$SOURCE_DIR\" --recursive --model \"$MODEL_ID\" --space \"$TARGET_SPACE\"","interpreter":"bash","timeout_seconds":120},"required":true}}
108
- ```
121
+ - If the critic reviewed the set as one submission, export that verdict once and
122
+ train the directory, capturing its report:
109
123
 
110
- ## Report Results
124
+ ```
125
+ squadrules train <directory> --recursive --model <model> --space <space> [--force] 2>&1 | tee "$BULK_LOG_FILE"
126
+ ```
111
127
 
112
- Summarise the batch outcome:
128
+ - If the critic reviewed files individually, train file-by-file and re-export
129
+ `SQUADRULES_REVIEW_EVIDENCE` for each file, so no adapter is stored under
130
+ another adapter's verdict; append every run to `$BULK_LOG_FILE`. Move
131
+ non-adapter files (README, reference docs) out of the directory before using
132
+ `--recursive` — the batch skips `README.md` by name and nothing else.
133
+
134
+ Summarise the outcome for the user:
113
135
 
114
136
  | Metric | Value |
115
137
  |--------|-------|
@@ -118,20 +140,33 @@ Summarise the batch outcome:
118
140
  | Failed | N |
119
141
  | Skipped (invalid) | N |
120
142
 
121
- For each failure, report: file path, error message, suggested fix.
122
- If all succeeded, confirm adapter URIs are accessible via `squadrules spaces`.
143
+ For each failure, report: file path, error message, suggested fix. If all
144
+ succeeded, confirm the adapter URIs are accessible via `squadrules spaces`.
145
+ A `REVIEW_EVIDENCE_REQUIRED` failure means the review did not cover that file:
146
+ review it, then retry; never store an unreviewed adapter to clear the error.
147
+
148
+ The batch prints one summary line (`<n> ok, <m> failed (of <total>)`) and one
149
+ `ERR <path>: <error>` line per failure. The gate below reads that captured report
150
+ instead of trusting a recollection of it, so the write is verified by what the
151
+ CLI actually stored:
123
152
 
124
153
  ```json
125
- {"contract":{"type":"comment","comment":{"min_length":80},"required":true}}
154
+ {"contract":{"type":"shell","shell":{"cmd":"test -s \"$BULK_LOG_FILE\" && grep -qE '[1-9][0-9]* ok, 0 failed' \"$BULK_LOG_FILE\" && ! grep -q 'ERR ' \"$BULK_LOG_FILE\"","interpreter":"bash","timeout_seconds":10},"required":true}}
126
155
  ```
127
156
 
128
157
  ## Reward Signal
129
158
 
130
159
  Workflow complete when:
160
+ - A delegated critic returned `PASS` over the files being uploaded.
131
161
  - All valid adapter files in the target directory have been trained to the
132
- specified space.
162
+ specified space, and the captured batch report shows `0 failed`.
133
163
  - Per-file results have been reported.
134
164
  - Any failures have been documented with remediation guidance.
135
165
 
166
+ What this proves: the store accepted the uploads and the CLI reported no failures
167
+ in the captured output. What it does not prove: that the review covered each file
168
+ individually when one verdict served a directory batch, or that the verdict came
169
+ from the delegated context rather than this one.
170
+
136
171
  A successful bulk insert means the user's local adapter library is now
137
172
  registered in SQUADRULES and available for activation by AI agents.
@@ -1,5 +1,5 @@
1
1
  ---
2
- version: "5.13.7"
2
+ version: "5.14.0"
3
3
  slug: challenge-type-guide
4
4
  title: Challenge Type Selection Guide
5
5
  ---
@@ -135,7 +135,7 @@ Every solution follows the same envelope:
135
135
 
136
136
  **forward solution**
137
137
  ```json
138
- {"type":"forward","outcome":"success","evidence":{"target":"squadrules://adapter/critic-loop","success":true}}
138
+ {"type":"forward","outcome":"success","evidence":{"target":"squadrules://adapter/implement-terraform","success":true}}
139
139
  ```
140
140
 
141
141
  **subagent solution**
@@ -168,6 +168,12 @@ Every solution follows the same envelope:
168
168
  data formats, or complex string processing, use `python3`. Use `node` only when
169
169
  the check requires the Node.js runtime.
170
170
 
171
+ `cmd` is always program text: `python3` / `node` receive it as `-c` / `-e` source,
172
+ so these rows describe short inline programs. Once a check needs more than one
173
+ readable line, stop choosing an interpreter and ship the script as an artifact,
174
+ invoked through a `bash` wrapper — see
175
+ [Artifacts for Shell Contracts](#artifacts-for-shell-contracts).
176
+
171
177
  ## Security and Working Directory Rules
172
178
 
173
179
  Use `$SQUADRULES_LOCAL_ARTIFACT_DIR` as the base directory for local handoff
@@ -230,7 +236,8 @@ external worktrees, or open the worktree as a separate project window.
230
236
  **Write-then-grep** — subagent writes a verdict file, main agent checks line 1.
231
237
 
232
238
  **Phase-batch with critic** — batch related items, verify hard artifacts with
233
- shell, then call `critic-loop` for adversarial review.
239
+ shell, then delegate `critic-loop` for adversarial review from a `subagent`
240
+ contract. The review must not run on the thread that produced the work.
234
241
 
235
242
  **Chain-link via forward + slug** — layer N's contract requires `forward` with a
236
243
  specific adapter slug. Use when the adapter exceeds 350 lines or needs
@@ -241,16 +248,48 @@ Example ```json
241
248
 
242
249
  ## Artifacts for Shell Contracts
243
250
 
244
- When a shell contract needs a reusable script, **attach it as an artifact**
245
- rather than inlining it in the contract JSON:
246
-
247
- 1. Write the script file.
248
- 2. `train` with `mime: "text/x-python"`, `artifact_name: "isolation-guard.py"`,
249
- `adapter_uri: "squadrules://adapter/my-adapter"`, and the script content.
250
- 3. In the shell contract, reference it via `export` with
251
- `squadrules://artifact/{uuid}` at execution time.
252
-
253
- This keeps adapter markdown clean and makes scripts independently versionable.
251
+ A gate that needs more than one short command belongs in a **script shipped with
252
+ the adapter**, not in the contract's `cmd`. An artifact keeps the contract
253
+ readable, makes the script independently versionable, and lets one dispatcher
254
+ serve many gates.
255
+
256
+ **Author it in this order** — an artifact attaches to an adapter that already
257
+ exists:
258
+
259
+ 1. Draft the markdown. The contract stays one line and invokes the script by its
260
+ artifact path. `interpreter` names the wrapper that runs that line, because
261
+ `cmd` is program text for every interpreter:
262
+ Example ```json
263
+ {"contract":{"type":"shell","shell":{"cmd":"python3 \"$SQUADRULES_LOCAL_ARTIFACT_DIR/artifacts/my-gates.py\" --gate preflight","interpreter":"bash","timeout_seconds":60},"required":true}}
264
+ ```
265
+ 2. `train` the markdown.
266
+ 3. `train` the script with the `mime` matching its extension (`text/x-python`,
267
+ `text/x-shellscript`, `text/javascript`), `artifact_name`, and that adapter's
268
+ `adapter_uri`. Add `relative_path` only when the default
269
+ `artifacts/<artifact_name>` is not the path you want; the identity header and
270
+ slug rules are in the `train` description.
271
+ 4. Verify before you run it — **two** checks:
272
+ - `activate` the adapter and check that `linked_artifacts[].relative_path`
273
+ equals the path the contract invokes.
274
+ - **Export check:** `export` the adapter (`format: skill_tree`, or
275
+ `skill_zip` for the bundle) and confirm the script is in the bundle at
276
+ that path, with no `artifact_stored_sha_mismatch` or
277
+ `artifact_relative_path_invalid` in `diagnostics[]`.
278
+
279
+ A mismatch surfaces only when the gate runs — by then it is the user's
280
+ failed step, not your typo.
281
+
282
+ **At execution time:** run the `materialize` command carried by that
283
+ `linked_artifacts[]` row — it writes the payload under
284
+ `$SQUADRULES_LOCAL_ARTIFACT_DIR`, verifies the digest, and marks the file
285
+ executable. `forward` responses do not repeat the list, so materialize during the
286
+ run's first step. When the choice carries no artifact row, the agent obtains the
287
+ script with **`export`** (`format: skill_tree` or `format: skill_zip`) and takes
288
+ it from `artifacts/`. State which route applies in the adapter text — a step that
289
+ does not say how to get the file leaves the agent guessing.
290
+
291
+ **One script, many gates:** `--gate <name>` on a single dispatcher replaces one
292
+ inlined program per step. Change the gate once, not seven times.
254
293
 
255
294
  Example ```json
256
295
  {"contract":{"type":"comment","comment":{"min_length":30},"required":true}}
@@ -268,3 +307,4 @@ The agent can now:
268
307
  5. use forward contracts for chain links
269
308
  6. use subagent contracts for delegated work
270
309
  7. apply stronger verification patterns instead of weak comment checks
310
+ 8. ship a multi-step gate as an adapter artifact and keep its contract one line