@cavelon/cli 0.1.5 → 0.1.6

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.
@@ -53,7 +53,9 @@ for a public widget), **propose the change; the person decides.**
53
53
  person with your reason (what fails or waits now), and wait for their answer.
54
54
  - Only after they agreed, run the confirm command it printed (the `confirm`
55
55
  field in `--json`) as it stands: it keeps the `--env` and `--tenant` of the
56
- preview, so it changes the limit the preview showed. Never raise a limit on
56
+ preview, so it changes the limit the preview showed. Over MCP, call
57
+ `limits_set` again with the same arguments and `confirm` set to the
58
+ preview's `confirm_token`. Never raise a limit on
57
59
  your own, never pick a value higher than the need you named, and never change
58
60
  one without telling them.
59
61
  - The same goes for the tenant's monthly inference budget
@@ -147,15 +149,24 @@ with `cavelon harness default`).
147
149
  2. The schema: `cavelon schema` lists the sections and the file each is kept
148
150
  in; `cavelon schema <section>` (the `package_schema` tool) lists a section's
149
151
  fields with type, required, allowed values and default, and prints the
150
- smallest entry with every required field, to copy into the file. A pulled
151
- file that is `[]` shows no shape; this does. `cavelon validate` checks the
152
- files against the same schema, and each error names the file, line and
153
- field. It also checks the references: a duplicate slug and a handoff to an
154
- agent the package lacks are errors; a skill, tool, knowledge base or
155
- solution that is neither in the package nor in the tenant's list from the
156
- last pull, a field the schema does not have (`package_field_unknown`, "did
157
- you mean temperature?") and an `llm_model` outside the tenant's model list
158
- are warnings. A finding's `suggestion` (with `--json`) is the closest name.
152
+ smallest entry with every required field, to copy into the file, and one
153
+ with an entry of each nested list. A nested entry has its own fields: reach
154
+ them by path or type name, as the section's output lists them
155
+ (`cavelon schema agents.handoffs`, `cavelon schema test_suites.test_cases.steps`,
156
+ `cavelon schema PackageAgentHandoff`); where entries take several shapes
157
+ (`test_suites.test_cases.steps.evaluation_criteria`), each shape is listed.
158
+ A pulled file that is `[]` shows no shape; this does. `cavelon validate`
159
+ checks the files against the same schema, and each error names the file,
160
+ line and field. It also checks the references: a duplicate slug, and a
161
+ handoff or a test assertion (`answered_by`, `handoff_to`) naming an agent
162
+ the package lacks, are errors; a skill, tool, knowledge base or solution
163
+ that is neither in the package nor in the tenant's list, a field the schema
164
+ does not have (`package_field_unknown`, "did you mean temperature?"), an
165
+ `llm_model` outside the tenant's model list, and a package naming another
166
+ solution than `cavelon.yaml` (`solution_slug_mismatch`) are warnings. A
167
+ finding's `suggestion` (with `--json`) is the closest name. The import
168
+ preview blocks a name the instance does not have: then `validate` does not
169
+ say "Valid", and `cavelon validate --strict` fails on every warning.
159
170
  3. Concepts and fields: `cavelon docs search <topic>` (for example "agent
160
171
  graph", "tools", "knowledge base", "triggers"), then `cavelon docs get
161
172
  <page>`.
@@ -219,12 +230,28 @@ and fill the field in to set it. A file of comments only sets nothing.
219
230
  The preview names them with the Admin path where a person sets them.
220
231
  - **Knowledge-base documents** are not in the repository: the package declares
221
232
  the knowledge bases; `cavelon kb upload` brings the documents.
222
- - **A knowledge base reaches an agent only through a search tool.** Naming it
223
- in a skill's `knowledge_base_assignments` only scopes the search; the skill
224
- (or the agent) also needs the built-in search tool in its `tool_assignments`
225
- (`cavelon docs get reference/builtin-tools` names it). Without one the agent
226
- answers from memory; `cavelon validate` warns
233
+ - **A knowledge base reaches an agent only through a tool that reads it.**
234
+ Naming it in a skill's `knowledge_base_assignments` only scopes the tools;
235
+ the skill (or the agent) also needs a built-in that reads a knowledge base in
236
+ its `tool_assignments`: `search_documents` searches it, `list_documents`
237
+ lists its documents by their metadata, and `read_document` reads one by the
238
+ id a search or list returned (`cavelon docs get reference/builtin-tools`).
239
+ A tenant tool whose `builtin_key` is one of them counts too; naming
240
+ `knowledge_base_names` on any other tool (a webhook, an MCP tool) reaches
241
+ nothing. Without such a tool the
242
+ agent answers from memory; `cavelon validate` warns
227
243
  (`knowledge_base_without_search_tool`).
244
+ - **The model comes from the tenant.** Set an agent's `llm_model` and
245
+ `llm_provider` to a row of `cavelon models list` (MODEL_ID, PROVIDER); the
246
+ models differ per instance and tenant, and the preview blocks one the tenant
247
+ does not have. On a reasoning model (the GPT-5 family, the o-series) from
248
+ OpenAI, Azure OpenAI or Anthropic the instance sends no `temperature` (the
249
+ schema still requires one: keep the default 0.4, and the preview flags any
250
+ other value); the reasoning level is what tunes such a model. Ask the
251
+ person to set it in the agent's **Model** tab in the Admin (Node
252
+ Workbench), then `cavelon pull` brings what the instance stored into
253
+ `package/agents.yaml`. `cavelon docs get concepts/choosing-models` says which
254
+ models take a temperature.
228
255
  - **Who approves goes on the Approval node, not into the memo.** When the
229
256
  brief says who approves, or that nobody approves their own request, set the
230
257
  node's `approvers` (tenant roles or access groups, directly or in `tiers`
@@ -272,9 +299,11 @@ schema has them: `cavelon validate` reports an unknown section):
272
299
 
273
300
  ## After each edit
274
301
 
275
- 1. `cavelon validate` until it reports no errors. After writing files by
276
- hand, `cavelon fmt` brings them into the form the instance's export gives
277
- them (field order, the schema's defaults filled in), so the first `pull`
302
+ 1. `cavelon validate` until it reports no errors (`--strict` before an apply
303
+ you expect to pass: it fails on the warnings the preview would block on).
304
+ After writing files by hand, `cavelon fmt` brings them into the form the
305
+ instance's export gives them (field order, the schema's defaults filled in,
306
+ test cases and steps numbered in their written order), so the first `pull`
278
307
  after `apply` shows only what changed on the instance; `cavelon fmt
279
308
  --check` changes nothing and exits 3 when a file would change.
280
309
  2. `cavelon apply --env test` to see what the instance makes of it; the
@@ -42,10 +42,16 @@ use it when you parse the result.
42
42
  - No `cavelon.yaml` here or above: for a new solution run
43
43
  `cavelon init --instance <url> --tenant <tenant> --harness <solution>`, where
44
44
  the tenant and the solution are each a name, slug or id; for an existing one
45
- add `cavelon pull` after it. To start from a package file (a blueprint, an
45
+ add `cavelon pull` after it. From your shell, `init --harness "<name>"`
46
+ creates a solution that does not exist yet as a draft; the MCP tool `init`
47
+ never creates one and names the `cavelon harness new <slug> --name "<name>"`
48
+ that does. `apply` never creates a solution: when the one an env file names
49
+ is missing it stops with `solution_not_found` and names that command. To start from a package file (a blueprint, an
46
50
  export from another instance), run
47
51
  `cavelon init --instance <url> --tenant <tenant> --from <file>` instead of
48
- splitting it by hand or importing it in the Admin. Never guess a tenant or a
52
+ splitting it by hand or importing it in the Admin; from your shell it creates
53
+ the package's only solution as a draft when the tenant lacks it (the MCP tool
54
+ names the `cavelon harness new` command instead). Never guess a tenant or a
49
55
  solution, and never ask the person for an id they would have to look up:
50
56
  `cavelon tenant list --json` and `cavelon harness list --json` list the
51
57
  names, slugs and ids to choose from, and the person names one by its name.
@@ -58,18 +64,26 @@ use it when you parse the result.
58
64
  uncommitted changes (outside git: files changed since the last pull);
59
65
  commit or apply them first. A file as the last pull or confirmed apply left
60
66
  it counts as unchanged, so a pull right after an apply goes ahead without a
61
- commit. `git diff` then shows what someone changed in the Admin.
67
+ commit. `git diff` then shows what someone changed in the Admin. A test
68
+ suite goes back to the file it came from, whatever its name. A solution's
69
+ pull leaves the tenant-wide sections (the tenant's settings, its model
70
+ list) out of the folder; `--tenant-wide` writes them, and `apply` then
71
+ sends them for the whole tenant, so only with the person's say-so.
62
72
  2. **Edit** the files in `package/` (one file per schema section) and `tests/`
63
73
  (one file per test suite). See the cavelon-authoring skill.
64
74
  3. **Validate** offline: `cavelon validate`. Fix every error; `cavelon explain
65
75
  <code>` says what a code means and how to fix it. Besides the schema it
66
- finds duplicate slugs, handoffs to an agent the package lacks, fields the
67
- schema does not have (with "did you mean"), and skills, tools, knowledge
68
- bases, solutions and models the tenant did not hold at the last pull
69
- (warnings: `cavelon pull` or `cavelon models list` refreshes that list).
70
- After writing files by hand, run `cavelon fmt`: it fills in the defaults
71
- the export writes, so the first `pull` after the apply rewrites only what
72
- changed on the instance.
76
+ finds duplicate slugs, handoffs and test assertions naming an agent the
77
+ package lacks, fields the schema does not have (with "did you mean"), and
78
+ skills, tools, knowledge bases, solutions and models the tenant does not
79
+ hold (warnings: `cavelon pull` or `cavelon models list` refreshes that
80
+ list; validate reads a list no command has read yet). The preview blocks
81
+ those names, so validate does not say "Valid" while one is left;
82
+ `cavelon validate --strict` fails on every warning. A line `Not checked:`
83
+ names a check it could not make (offline, no list). After writing files by
84
+ hand, run `cavelon fmt`: it fills in the defaults the export writes and
85
+ numbers test cases in their written order, so the first `pull` after the
86
+ apply rewrites only what changed on the instance.
73
87
  4. **Preview**: `cavelon apply --env test` (or `--harness <name or slug>`). Nothing is
74
88
  imported yet. Read the preview: what is created, updated or deleted, which
75
89
  active solutions it reaches, what the target still needs (variables and
@@ -80,25 +94,38 @@ use it when you parse the result.
80
94
  command that sets each). A blocked preview names each blocker with its
81
95
  code, package file and path, and hint; `cavelon explain <code>` says more.
82
96
  5. **Confirm** exactly that preview: `cavelon apply --confirm <preview-id>`
83
- (the line `apply` printed, with the same `--env` and `--tenant`). Exit 4 means the target changed since the preview:
84
- preview again and confirm the new id. When the error lists `blockers`, the
85
- import's own check found them as it applied: fix what each names (the hint
86
- says how for a code the kit knows), then preview again.
97
+ (the line `apply` printed, with the same `--env` and `--tenant`). Exit 4
98
+ means the preview is stale and nothing was imported: the target changed on
99
+ the instance (`import_preview_stale`), the package files changed since
100
+ (`preview_files_changed`, naming them), or the preview is more than a day
101
+ old (`preview_expired`). Preview again, show the new preview when the rules
102
+ below say so, and confirm the new id. Use `--allow-stale` only when the
103
+ person wants exactly the old preview imported. When the error lists
104
+ `blockers`, the import's own check found them as it applied: fix what each
105
+ names (the hint says how for a code the kit knows), then preview again.
106
+ Discard a preview you will not confirm (`cavelon apply --discard <id>`, or
107
+ `--discard all`), so no later agent confirms it; `cavelon status` lists the
108
+ open ones with when each expires.
87
109
  6. **Seed** knowledge when needed: `cavelon kb upload <dir> --kb <kb>`. It
88
110
  refuses before sending when a file is larger than the instance allows or of
89
111
  a type it does not accept, and a `.zip` unless the tenant has archive
90
112
  uploads on (`kb_upload_archive_enabled`) and it stays within their file
91
113
  count, unpacked size and compression ratio (exit 3, naming the limit and who
92
114
  changes it).
93
- **Updating a document**: upload the new version under the same file name
94
- with `--replace` (try it with `--dry-run` first). Without it the old version
95
- may stay active next to the new one, and both answer: `kb upload` names each
96
- file that matches an active document ("bergbahn-faq.md exists (094e95e9…)
97
- and stays active"). An instance that replaces same-named documents itself
98
- does so on every upload (`--keep-both` keeps both); where the instance's
99
- upload cannot replace, `--replace` shows the documents it would deactivate
100
- after the upload and needs `--confirm`: show the person that first. A test
101
- Sandbox gets its files with `cavelon sandbox seed <sandbox> <folder>`
115
+ **Updating a document**: upload the new version under the same file name.
116
+ `kb upload` names each file that matches an active document of the
117
+ knowledge base, and what happens to it depends on the instance (try it with
118
+ `--dry-run` first):
119
+ - An instance that replaces same-named documents does so on every upload:
120
+ "faq.md exists (0f3c…) and is replaced by the upload (--keep-both keeps
121
+ it)". `--keep-both` keeps both.
122
+ - On an older instance the old version stays active next to the new one,
123
+ and both answer: "faq.md exists (0f3c…) and stays active". Upload with
124
+ `--replace`: where the instance's upload can replace by id, the old
125
+ document is replaced once the new file is verified; where it cannot,
126
+ `--replace` shows the documents it would deactivate after the upload and
127
+ needs `--confirm`: show the person that first.
128
+ A test Sandbox gets its files with `cavelon sandbox seed <sandbox> <folder>`
102
129
  (isolated container) or `cavelon sandbox refresh <sandbox>` after the files
103
130
  were put on the VM (customer VM).
104
131
  7. **Test**: `cavelon test run --suite <suite>`, then `cavelon wait <operation>`.
@@ -120,9 +147,21 @@ says when the solution it activated is not the default.
120
147
  changes live traffic; never decide it yourself.
121
148
  - With their yes: `cavelon activate --make-default` (or `cavelon harness
122
149
  default <solution>`) shows the change, naming the current default; show it,
123
- then run the same command with `--confirm`.
150
+ then run the confirm command it printed (from your shell it carries the
151
+ change's token: `--confirm <token>`). `harness default` refuses a draft
152
+ (`solution_not_active`, exit 4): only an active solution can be the
153
+ default, so use `cavelon activate --make-default`.
124
154
  - `is_default` in `harnesses.yaml` is not applied by `apply`; the preview
125
155
  lists it under "not applied".
156
+ - To try an active solution that is not the default, talk to it by name:
157
+ `cavelon chat "<message>" --harness <solution>` (the `chat` tool over MCP)
158
+ prints its answer, the session to continue with `--session`, and the
159
+ conversation to trace. A draft answers only a person's token, as a
160
+ Playground run.
161
+ - `cavelon deactivate --harness <solution>` takes an active solution out of
162
+ live traffic: it previews, and only `--confirm` deactivates. It is the
163
+ person's decision, like the default route; the default route itself is
164
+ refused until another solution is the default.
126
165
 
127
166
  ## Show the person before confirming
128
167
 
@@ -139,11 +178,34 @@ show the preview to the person, and confirm only after they agree, when:
139
178
  The same holds for the other commands that take `--confirm`: without it they
140
179
  only show what would happen. Show it to the person before `cavelon trigger
141
180
  identity <trigger> <key> --confirm` (it gives a trigger standing authority),
142
- before `cavelon harness default … --confirm` or `cavelon activate
143
- --make-default --confirm` (it moves live traffic), and
181
+ before `cavelon harness default … --confirm`, `cavelon activate
182
+ --make-default --confirm` or `cavelon deactivate --confirm` (they move live
183
+ traffic), and
144
184
  before `cavelon sandbox seed … --confirm` or `cavelon loop cancel … --confirm` on
145
185
  anything but a test Sandbox or a run you started yourself.
146
186
 
187
+ **Over MCP, confirm with the preview's token.** `api`, `limits_set`,
188
+ `models_set_limit`, `loop_cancel`, `sandbox_seed`, `trigger_identity`,
189
+ `harness_default`, `deactivate`, `activate` with `make_default`, and
190
+ `kb_upload` where it would deactivate documents return a `confirm_token` with
191
+ their preview. Show
192
+ the preview, then call the tool again with the same arguments and `confirm`
193
+ set to that token; it makes exactly the change shown. `confirm: true` is
194
+ refused (`confirm_token_required`), and a token of another change returns the
195
+ new preview with `token_mismatch` (exit code 4): show that one instead. Tool
196
+ arguments are spelled in snake_case (`make_default`, `keep_both`, `dry_run`);
197
+ an argument a tool does not list is refused (`unknown_argument`) with the
198
+ closest one named.
199
+
200
+ **From your shell, `--confirm` takes the same token.** Run by a coding agent,
201
+ `limits set`, `models set-limit`, `loop cancel`, `sandbox seed`,
202
+ `trigger identity`, `harness default`, `activate --make-default`,
203
+ `kb upload --replace`, `variables delete` and `secrets delete` print their
204
+ preview with a confirm token and the command that confirms it
205
+ (`… --confirm <token>`). Show the preview, then run exactly that command. A
206
+ bare `--confirm` changes nothing and exits 5; a token of another change exits
207
+ 4 with the new preview.
208
+
147
209
  **`cavelon api` from your shell has the guards of the MCP `api` tool**, since
148
210
  `cavelon` sees that a coding agent runs it (`CLAUDECODE`, `CODEX_THREAD_ID`, `CODEX_SANDBOX`,
149
211
  `CURSOR_AGENT`, `GEMINI_CLI`, `COPILOT_CLI`, `COPILOT_AGENT`, `AI_AGENT` or
@@ -155,7 +217,9 @@ anything but a test Sandbox or a run you started yourself.
155
217
  exactly that request. A changed body or parameter needs a new preview (exit 4).
156
218
  - It refuses an operation the instance keeps for a person
157
219
  (`operation_for_a_person`) and a body that sets a field the instance marks as
158
- a secret value (`secret_field_for_a_person`), with or without `--confirm`.
220
+ a secret value (`secret_field_for_a_person`), with or without `--confirm`,
221
+ with exit code 5 (needs a person). `cavelon api describe <operation>` shows
222
+ both marks up front.
159
223
  Tell the person what the error's hint says; for a secret field, send the rest
160
224
  without it and let the person enter the value (`cavelon secrets set <name>`
161
225
  or the Admin). Never work around a refusal, by unsetting the variable or by
@@ -72,7 +72,14 @@ consult tool's name, not with `handoff_to`. Use the slugs from
72
72
  `package/agents.yaml`.
73
73
 
74
74
  `cavelon validate` checks the assertions against the instance's package
75
- schema where the schema describes a step's criteria. Where it does not, it
75
+ schema where the schema describes a step's criteria (`cavelon schema
76
+ test_suites.test_cases.steps.evaluation_criteria` lists each shape): a
77
+ misspelt `type` is one error with the closest type, an `answered_by` or
78
+ `handoff_to` naming an agent the package lacks is an error, and a
79
+ `tool_called` or `tool_not_called` naming a tool that is nowhere is a warning,
80
+ each with "did you mean". Cases and steps run in their written order once
81
+ `cavelon fmt` has numbered them (`sort_order`, `step_order`); left out, the
82
+ instance orders cases by name. Where the schema does not describe a step's criteria, it
76
83
  warns `test_assertion_unchecked`: an instance that does not know a type grades
77
84
  it as a judge criterion instead of checking it, so read `cavelon docs get
78
85
  concepts/regression-testing` for the types the instance knows before relying on
@@ -129,7 +136,7 @@ The case's own reason (which knowledge base, which value) is in the output of
129
136
  ## Reading what happened
130
137
 
131
138
  ```bash
132
- cavelon trace <test-run-id or operation-id> # cases, scores, judge's reasoning
139
+ cavelon trace <test-run-id or operation-id> # cases, assertions, answers, judge's reasoning
133
140
  cavelon trace <conversation-id> --kind conversation # one case's traces
134
141
  cavelon trace <conversation-id> --kind conversation --trace <trace-id> # one trace's spans
135
142
  cavelon trace <conversation-id> --kind conversation --trace <trace-id> --span <span-id>
@@ -141,24 +148,54 @@ retrieval). Output is bounded; run the command each level prints as printed: it
141
148
  carries the id its route needs. A case's traces are under its
142
149
  `conversation_id` (a trigger case's under its `run_id`, `--kind trigger`), not
143
150
  under the test run's id; a wrong id answers with a hint naming the right one.
144
- A low-scoring pass shows the judge's reasoning too.
145
-
151
+ The spans list suggests the span to open first: the one that failed, else the
152
+ last model call, else the knowledge search.
153
+
154
+ Each step lists its assertions with pass or FAIL (`Assertions (1 of 2
155
+ passed)`, then one line each with the expected and observed value of a failed
156
+ one and the reasoning), the judge's criteria with their scores, and the
157
+ answer it judged, shortened (`assertions[]` and `answer` in `--json`; the
158
+ whole answer with `--full`). Read the assertions, not only the judge's
159
+ sentence: "meets the only criterion" can stand above a failed `answered_by`.
160
+ `test run --wait` names a failed case's failed assertions and its answer too.
146
161
  Each step names the agent that answered it (AGENT, `agent` in `--json`), and a
147
- case that did not pass says `Answered by: <agent>` under its reason: the first
148
- thing to check when a routing assertion failed. A failed assertion's reason is
149
- the case's reason, and `--json` carries each assertion's result in
150
- `judge_breakdown.deterministic_criteria` (expected, observed, reasoning). A
151
- knowledge search's spans show what the agent recorded the search found
152
- (`knowledge_outcome`: `usable_evidence`, `content_gap`, `unusable_hits`,
153
- `retrieval_fault` or `deliberately_unanswerable`) on the search's tool span
154
- and its retrieval span; a search without one is one the agent did not
155
- classify. An instance that records none shows no such column.
162
+ case that did not pass says `Answered by: <agent>`: the first thing to check
163
+ when a routing assertion failed.
164
+
165
+ A knowledge search's retrieval span (`--span <span-id>`) shows the query, its
166
+ `knowledge_outcome` and the hits as a table (rank, title, score, whether it
167
+ may be cited, document id); `retrieval` in `--json`. Its tool span shows the
168
+ outcome too; a search without one is one the agent did not classify, and an
169
+ instance that records none shows no such column. The agent records one of four
170
+ values, and the trace refines `no_usable_evidence` by what the search returned,
171
+ so the trace never shows that value itself (`cavelon explain <value>` says
172
+ more, from the instance's catalog where it lists them):
173
+
174
+ | The agent records | The retrieval span shows | When |
175
+ |---|---|---|
176
+ | `usable_evidence` | `usable_evidence` | The hits support the answer |
177
+ | `no_usable_evidence` | `content_gap` | The search returned no hits at all |
178
+ | `no_usable_evidence` | `unusable_hits` | It returned hits, and none answers the question |
179
+ | `no_usable_evidence` | `retrieval_fault` | The search failed, returned a partial result, or had no knowledge base it may read |
180
+ | `retrieval_fault` | `retrieval_fault` | The agent saw the search report a fault |
181
+ | `deliberately_unanswerable` | `deliberately_unanswerable` | Policy or the request, not missing content, made the agent decline |
182
+
183
+ A question the knowledge base does not cover usually shows as `unusable_hits`,
184
+ not `content_gap`: a search almost always returns its closest passages. Read
185
+ both as a gap to fill.
156
186
 
157
187
  ## Optimizing
158
188
 
159
- Change one thing at a time, then run the same suite again and compare:
189
+ Change one thing at a time, then run the whole suite again and compare, not
190
+ only the case that failed: a prompt change that fixes one case can break
191
+ another. In one solution, a line "just answer directly" made the agent answer
192
+ an off-topic question its persona forbade.
160
193
 
161
- - **Wrong or missing facts:** check retrieval first (which chunks came back in
194
+ - **Wrong or missing facts:** check retrieval first. Under a case that did not
195
+ pass, `cavelon trace <run>` shows a `Knowledge:` line with the outcomes of
196
+ its knowledge searches (`knowledge_outcomes` per case in `--json`; `null`
197
+ where the instance or the run recorded none), so a `content_gap` shows
198
+ before you open the case's spans. Then read which chunks came back in
162
199
  the retrieval span, and its `knowledge_outcome`: `content_gap` means the
163
200
  knowledge base lacks the answer, `unusable_hits` that what came back did not
164
201
  answer it, `retrieval_fault` that the search failed). Fix the documents or
@@ -170,9 +207,25 @@ Change one thing at a time, then run the same suite again and compare:
170
207
  description and parameters, then the agent's instructions about when to use it.
171
208
  - **Right facts, poor answer:** adjust the agent's instructions; keep them short
172
209
  and specific.
210
+ - **A limit that does not hold** (the agent writes the poem it should decline):
211
+ a limit stated only in the persona's `persona_prompt` is weaker than a direct
212
+ instruction in the agent's `system_prompt`, most of all on small models. Put
213
+ the hard limit in the agent's `system_prompt` too, and keep a test case that
214
+ checks it.
173
215
  - **Too slow or too costly:** read the token counts and durations in the trace;
174
216
  a smaller model or fewer tool rounds often suffice for a step.
175
217
 
176
- Record why a change helped in the commit message. When every suite passes,
218
+ Record why a change helped in the commit message.
219
+
220
+ To try a question outside the suite, `cavelon chat "<message>" --harness
221
+ <solution>` (the `chat` tool over MCP) sends it to that solution and prints
222
+ the answer, the session to continue with `--session`, and the conversation to
223
+ trace. It reaches an active solution that is not the tenant's default route,
224
+ which the tenant's chat and widget never answer with; a draft answers only a
225
+ person's token, as a Playground run. `cavelon api chat` with `harness_id` in
226
+ the body does the same, but needs the id and a confirm. `cavelon deactivate
227
+ --harness <solution>` takes an active solution out of live traffic again; it
228
+ previews first and is the person's decision, so show the preview and confirm
229
+ only with their yes. When every suite passes,
177
230
  `cavelon activate --harness <name or slug>` goes through the readiness gate; if the
178
231
  token may not activate, a person activates in the Admin.
@@ -98,3 +98,22 @@ export function tenantMissError(ref, pool, reachesAll, from) {
98
98
  details: { tenants: listed.map((t) => ({ id: t.id, slug: t.slug, name: t.name })) },
99
99
  });
100
100
  }
101
+ export async function describeTenant(client, id) {
102
+ try {
103
+ const detail = await client.get(`/api/v1/tenants/${encodeURIComponent(id)}`, {
104
+ sendTenant: false,
105
+ headers: { "X-Tenant-Id": id },
106
+ allow: [400, 401, 403, 404, 405, 422],
107
+ });
108
+ const name = typeof detail.data?.name === "string" && detail.data.name ? detail.data.name : undefined;
109
+ const slug = typeof detail.data?.slug === "string" && detail.data.slug ? detail.data.slug : undefined;
110
+ if (detail.status === 200 && (name || slug))
111
+ return { ...(name ? { name } : {}), ...(slug ? { slug } : {}) };
112
+ const found = await readTenantless(client, { search: id });
113
+ const hit = found && !found.refused ? found.tenants?.find((t) => t.id === id) : undefined;
114
+ return hit ? { ...(hit.name ? { name: hit.name } : {}), ...(hit.slug ? { slug: hit.slug } : {}) } : {};
115
+ }
116
+ catch {
117
+ return {};
118
+ }
119
+ }
@@ -0,0 +1,172 @@
1
+ import { clip } from "./format.js";
2
+ const REASONING_CHARS = 300;
3
+ const VALUE_CHARS = 120;
4
+ const record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
5
+ const text = (value) => (typeof value === "string" && value.trim() ? value : null);
6
+ const brief = (value, max) => (typeof value === "string" ? clip(value, max) : value);
7
+ export function stepAssertions(breakdown, full = false) {
8
+ const b = record(breakdown);
9
+ if (!b)
10
+ return [];
11
+ const max = full ? Number.MAX_SAFE_INTEGER : REASONING_CHARS;
12
+ const out = [];
13
+ for (const raw of Array.isArray(b.deterministic_criteria) ? b.deterministic_criteria : []) {
14
+ const c = record(raw);
15
+ if (!c)
16
+ continue;
17
+ const type = text(c.type) ?? "assertion";
18
+ out.push({
19
+ type,
20
+ label: text(c.label) ?? type,
21
+ passed: typeof c.passed === "boolean" ? c.passed : null,
22
+ ...("expected" in c ? { expected: brief(c.expected, full ? max : VALUE_CHARS) } : {}),
23
+ ...("observed" in c ? { observed: brief(c.observed, full ? max : VALUE_CHARS) } : {}),
24
+ reasoning: text(c.reasoning) ? clip(text(c.reasoning), max) : null,
25
+ });
26
+ }
27
+ for (const raw of Array.isArray(b.criteria) ? b.criteria : []) {
28
+ const c = record(raw);
29
+ const criterion = c && text(c.criterion);
30
+ if (!c || !criterion)
31
+ continue;
32
+ out.push({
33
+ type: "judge",
34
+ label: clip(criterion, full ? max : VALUE_CHARS),
35
+ passed: null,
36
+ score: typeof c.score === "number" ? c.score : null,
37
+ reasoning: text(c.reasoning) ? clip(text(c.reasoning), max) : null,
38
+ });
39
+ }
40
+ return out;
41
+ }
42
+ export function assertionCount(assertions) {
43
+ const judged = assertions.filter((a) => a.passed !== null);
44
+ if (!judged.length)
45
+ return undefined;
46
+ return `${judged.filter((a) => a.passed).length} of ${judged.length} passed`;
47
+ }
48
+ function assertionName(a) {
49
+ if (a.type === "judge")
50
+ return `criterion "${a.label}"`;
51
+ return a.label === a.type ? a.type : `${a.label} [${a.type}]`;
52
+ }
53
+ export function assertionLine(a) {
54
+ const mark = a.passed === true ? "pass" : a.passed === false ? "FAIL" : a.score !== null && a.score !== undefined ? `score ${a.score}` : "judged";
55
+ const values = a.passed === false && ("expected" in a || "observed" in a)
56
+ ? ` (expected ${JSON.stringify(a.expected ?? null)}, observed ${JSON.stringify(a.observed ?? null)})`
57
+ : "";
58
+ return `${mark} ${assertionName(a)}${values}${a.reasoning ? `: ${a.reasoning}` : ""}`;
59
+ }
60
+ export function failedAssertions(breakdown) {
61
+ return stepAssertions(breakdown)
62
+ .filter((a) => a.passed === false)
63
+ .map(assertionName);
64
+ }
65
+ export function spanAttributes(value) {
66
+ let current = value;
67
+ for (let i = 0; i < 3 && typeof current === "string"; i++) {
68
+ const trimmed = current.trim();
69
+ if (!trimmed.startsWith("{") && !trimmed.startsWith('"'))
70
+ return undefined;
71
+ try {
72
+ current = JSON.parse(trimmed);
73
+ }
74
+ catch {
75
+ return undefined;
76
+ }
77
+ }
78
+ return record(current);
79
+ }
80
+ const num = (value) => (typeof value === "number" && Number.isFinite(value) ? value : null);
81
+ export function retrievalView(attributes) {
82
+ if (!attributes)
83
+ return undefined;
84
+ const sources = Array.isArray(attributes.sources) ? attributes.sources : [];
85
+ const query = text(attributes.query) ?? text(record(attributes.pipeline_metadata)?.query);
86
+ if (!query && !sources.length && !("knowledge_outcome" in attributes) && !("source_count" in attributes))
87
+ return undefined;
88
+ const hits = sources
89
+ .map((raw, index) => {
90
+ const s = record(raw);
91
+ if (!s)
92
+ return undefined;
93
+ return {
94
+ rank: num(s.rank) ?? index + 1,
95
+ title: text(s.title) ?? text(s.filename),
96
+ score: num(s.score),
97
+ citation_state: text(s.citation_state),
98
+ cited: typeof s.cited === "boolean" ? s.cited : null,
99
+ document_id: text(s.document_id),
100
+ knowledge_base_id: text(s.knowledge_base_id),
101
+ };
102
+ })
103
+ .filter((h) => Boolean(h));
104
+ const status = text(attributes.retrieval_status) ?? text(record(attributes.pipeline_metadata)?.retrieval_status);
105
+ return {
106
+ query,
107
+ knowledge_outcome: text(attributes.knowledge_outcome),
108
+ source_count: num(attributes.source_count) ?? (hits.length ? hits.length : null),
109
+ sources: hits,
110
+ sources_total: num(attributes.sources_total),
111
+ retrieval_status: status,
112
+ };
113
+ }
114
+ export function retrievalRows(view) {
115
+ return view.sources.map((h) => ({
116
+ rank: h.rank,
117
+ title: h.title,
118
+ score: h.score === null ? null : Math.round(h.score * 1000) / 1000,
119
+ citable: h.citation_state === null ? null : h.citation_state === "citable" ? "yes" : "no",
120
+ cited: h.cited === false ? "no" : null,
121
+ document_id: h.document_id,
122
+ }));
123
+ }
124
+ export function suggestedSpan(spans) {
125
+ const inOrder = spans.slice().sort((a, b) => (a.sequence ?? 0) - (b.sequence ?? 0));
126
+ const last = (pick) => inOrder.filter(pick).pop();
127
+ return (last((s) => Boolean(s.error_json) || s.status === "error" || s.status === "errored") ??
128
+ last((s) => s.span_type === "llm") ??
129
+ last((s) => s.span_type === "retrieval") ??
130
+ last((s) => Boolean(s.parent_span_id)) ??
131
+ inOrder[0]);
132
+ }
133
+ export const KNOWLEDGE_OUTCOME_AREA = "knowledge_outcome";
134
+ export const KNOWLEDGE_OUTCOME_PAGE = "concepts/regression-testing";
135
+ export const KNOWLEDGE_OUTCOMES = [
136
+ {
137
+ value: "usable_evidence",
138
+ message: "The agent recorded usable_evidence: what this search returned supports the answer.",
139
+ hint: "Nothing to fix. The answer's sources come from this search's hits.",
140
+ },
141
+ {
142
+ value: "content_gap",
143
+ recorded_as: "no_usable_evidence",
144
+ message: "The agent recorded no_usable_evidence and the search returned no hits at all.",
145
+ hint: "Add a document that answers the question, or check that the knowledge base the agent searches holds it.",
146
+ },
147
+ {
148
+ value: "unusable_hits",
149
+ recorded_as: "no_usable_evidence",
150
+ message: "The agent recorded no_usable_evidence although the search returned hits: none of them answers the question. A question the knowledge base does not cover usually shows here, not as content_gap, because a search almost always returns its closest passages.",
151
+ hint: "Read the hits on the retrieval span (`cavelon trace … --span <span_id>`). Add the missing content, or improve the document whose passage should have answered it.",
152
+ },
153
+ {
154
+ value: "retrieval_fault",
155
+ message: "The search failed technically: the agent recorded retrieval_fault, or it recorded no_usable_evidence for a search that reported an error, a partial or unavailable result, or no knowledge base it may read.",
156
+ hint: "Read the retrieval span's status and attributes, fix the knowledge base binding or the service, and ask again.",
157
+ },
158
+ {
159
+ value: "deliberately_unanswerable",
160
+ message: "The agent recorded deliberately_unanswerable: policy or the nature of the request, not missing content, made it decline.",
161
+ hint: "Nothing to add to the knowledge base. Change the agent's instructions if it should answer.",
162
+ },
163
+ {
164
+ value: "no_usable_evidence",
165
+ message: "What the agent records when a search's result cannot support the answer. The trace never shows it: it shows content_gap (no hits), unusable_hits (hits, none usable) or retrieval_fault (the search failed).",
166
+ hint: "Look up the value on the search's retrieval span: `cavelon explain <value>`.",
167
+ },
168
+ ];
169
+ export function knowledgeOutcome(code) {
170
+ const wanted = code.trim().toLowerCase().replaceAll(" ", "_").replaceAll("-", "_");
171
+ return KNOWLEDGE_OUTCOMES.find((o) => o.value === wanted);
172
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelon/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",