@cavelon/cli 0.0.0 → 0.1.2

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 (61) hide show
  1. package/README.md +713 -3
  2. package/dist/LICENSE +201 -0
  3. package/dist/agents.js +107 -0
  4. package/dist/branches.js +61 -0
  5. package/dist/capacity.js +162 -0
  6. package/dist/cli.js +4 -0
  7. package/dist/command.js +62 -0
  8. package/dist/commands/api.js +313 -0
  9. package/dist/commands/async.js +207 -0
  10. package/dist/commands/docs.js +158 -0
  11. package/dist/commands/index.js +112 -0
  12. package/dist/commands/init.js +481 -0
  13. package/dist/commands/inventory.js +56 -0
  14. package/dist/commands/limits-set.js +633 -0
  15. package/dist/commands/limits.js +156 -0
  16. package/dist/commands/loops.js +798 -0
  17. package/dist/commands/models.js +197 -0
  18. package/dist/commands/sandboxes.js +674 -0
  19. package/dist/commands/session.js +480 -0
  20. package/dist/commands/solution.js +830 -0
  21. package/dist/commands/tenants.js +266 -0
  22. package/dist/commands/values.js +386 -0
  23. package/dist/commands/work.js +761 -0
  24. package/dist/context.js +60 -0
  25. package/dist/contracts.js +234 -0
  26. package/dist/credentials.js +134 -0
  27. package/dist/errors.js +64 -0
  28. package/dist/features.js +52 -0
  29. package/dist/format.js +36 -0
  30. package/dist/fsutil.js +43 -0
  31. package/dist/git.js +41 -0
  32. package/dist/http.js +304 -0
  33. package/dist/invoke.js +165 -0
  34. package/dist/io.js +49 -0
  35. package/dist/limits.js +307 -0
  36. package/dist/local-state.js +78 -0
  37. package/dist/main.js +227 -0
  38. package/dist/markers.js +113 -0
  39. package/dist/mcp.js +137 -0
  40. package/dist/openapi.js +233 -0
  41. package/dist/operations.js +107 -0
  42. package/dist/package-check.js +342 -0
  43. package/dist/package-files.js +394 -0
  44. package/dist/pair-order.js +39 -0
  45. package/dist/paths.js +77 -0
  46. package/dist/principal.js +33 -0
  47. package/dist/project.js +157 -0
  48. package/dist/prompt.js +34 -0
  49. package/dist/results.js +104 -0
  50. package/dist/session.js +190 -0
  51. package/dist/shell.js +41 -0
  52. package/dist/skills/cavelon-authoring/SKILL.md +224 -0
  53. package/dist/skills/cavelon-long-running/SKILL.md +185 -0
  54. package/dist/skills/cavelon-loop/SKILL.md +159 -0
  55. package/dist/skills/cavelon-testing/SKILL.md +97 -0
  56. package/dist/sse.js +44 -0
  57. package/dist/tar.js +172 -0
  58. package/dist/user-config.js +36 -0
  59. package/dist/version.js +17 -0
  60. package/dist/zip.js +132 -0
  61. package/package.json +40 -4
@@ -0,0 +1,224 @@
1
+ ---
2
+ name: cavelon-authoring
3
+ description: Writing and changing a Cavelon solution package in a repository - the package/ files split by schema section, the package schema, environments in env/, declaring the variables and secrets a solution needs, and fixing validation codes with cavelon explain. Use when editing files under package/, tests/ or env/ of a folder with cavelon.yaml, when cavelon validate or apply reports an error code, when the user asks to add or change agents, tools, skills, knowledge bases or triggers of a Cavelon solution, or when a limit of the tenant needs changing (cavelon limits set) or they set up a self-hosted model endpoint or its concurrency limit (max_concurrent_requests).
4
+ license: Apache-2.0
5
+ ---
6
+
7
+ # Authoring a Cavelon package
8
+
9
+ The package is the solution's configuration. The instance publishes its
10
+ format as a JSON Schema; `cavelon` splits it along that schema's top-level
11
+ sections, so the files follow whatever the instance version defines. Do not
12
+ assume a section or field exists: check the schema or the docs first.
13
+
14
+ ## Before you plan: the instance's limits
15
+
16
+ Read `cavelon limits` (or the `limits` MCP tool) before you design or change a
17
+ solution. It lists, for this tenant, every limit the instance enforces that a
18
+ solution can run into: knowledge-base upload size and file types, structured
19
+ knowledge-base sizes, agent turns and tool calls, pipeline stages and
20
+ `harness_call` depth, webhook, API Request, MCP and model timeouts and sizes,
21
+ rate limits, the licence's cap on solutions, and branch concurrency; and the
22
+ tenant's quotas (agents, tools, knowledge bases, storage, monthly tokens, the
23
+ monthly Processing Step cap) with their use.
24
+
25
+ - Design within them: a webhook timeout above `webhook_max_timeout_seconds`
26
+ or a document above `kb_upload_max_file_size_mb` fails on the instance.
27
+ - Each limit says where its value comes from (`source`: tenant, platform or
28
+ licence), who can change it (`changeable_by`: a tenant admin or the
29
+ operator) and the `setting`. A tenant admin's limit can be changed with
30
+ `cavelon limits set <key> <value>` (see below), or in the Admin; an operator
31
+ changes environment settings or the licence. The run caps
32
+ also name their `origin`: a platform setting the operator changes in the
33
+ Admin, the environment, or the default. Ask the person rather than working
34
+ around a limit, and never edit a limit into the package.
35
+ - A fan-out or Map loop runs at most `orchestration_max_branch_concurrency`
36
+ branches at once: a `max_concurrency` above it is capped, and `cavelon
37
+ validate` warns (`branch_width_capped`). When `limits` says branches do not
38
+ run concurrently, every fan-out and Map loop runs one branch after another
39
+ (same result, slower); `validate` warns (`branches_run_in_sequence`) and
40
+ `limits` names the switch that is off and who turns it on. Plan the time a
41
+ long document takes with that, and tell the person.
42
+ - A limit the instance does not list does not bind there. `cavelon docs get
43
+ <page>` with a limit's `docs` path explains it.
44
+
45
+ ## Changing a limit
46
+
47
+ When a solution needs more than a limit allows, or less (a lower rate limit
48
+ for a public widget), **propose the change; the person decides.**
49
+
50
+ - Run `cavelon limits set <key> <value>` without `--confirm` (MCP: `limits_set`
51
+ without `confirm`). It changes nothing and shows the old and the new value,
52
+ the operation it would send and the permissions it needs. Show that to the
53
+ person with your reason (what fails or waits now), and wait for their answer.
54
+ - Only after they agreed, run the confirm command it printed (the `confirm`
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
57
+ your own, never pick a value higher than the need you named, and never change
58
+ one without telling them.
59
+ - The same goes for the tenant's monthly inference budget
60
+ (`monthly_inference_token_budget`) and the monthly Processing Step cap
61
+ (`monthly_processing_step_cap`, a Tenant Owner's; `none` removes it): both
62
+ decide what the tenant pays. When new work is refused at the cap,
63
+ `cavelon explain processing_step_cap` says when it resets and who raises it.
64
+ - An operator's or the licence's limit (`changeable_by: operator`: the run
65
+ caps, the slot waits, timeouts, `licence_max_harnesses`) goes to the
66
+ operator. Where it publishes a `change` (the run caps), `limits set` sends it
67
+ only with a personal access token in Platform mode of the role it names, and
68
+ otherwise refuses naming the role and the Admin page; `--tenant <tenant>`
69
+ then sets one tenant's own run cap. Without a `change` it cannot be changed
70
+ at runtime. Tell the person who changes it and where, and design within it
71
+ meanwhile; never ask for an operator's token.
72
+ - A rate limit only goes down to what the operator allows; above the ceiling
73
+ (`maximum_setting`), it is the operator's too. That holds for the per-visitor
74
+ limits (`rate_limit_chat_visitor_rpm`, `rate_limit_widget_visitor_rpm`) as
75
+ well. A refusal `limit_above_platform_ceiling` names the ceiling and the
76
+ operator's setting; `cavelon explain limit_above_platform_ceiling` lists them.
77
+ - Archive uploads are one switch, `kb_upload_archive_enabled` (`true` or
78
+ `false`). The archive caps apply only while it is on (`binds_when` in
79
+ `limits`), and can be set before. The formats are the platform's.
80
+ - A refusal for permissions (exit 7) means this credential may not change it:
81
+ ask a person who holds one of the permissions it names. The kit refuses
82
+ before sending when the instance publishes the credential's permissions. An
83
+ instance that does not publish how to change a limit is changed in the Admin.
84
+
85
+ ## Self-hosted model endpoints
86
+
87
+ A model served from the customer's own endpoint (vLLM, TGI, an on-prem
88
+ gateway: a Model Registry row with a `base_url`) answers only so many requests
89
+ at once. Declare that number as the row's `max_concurrent_requests`, so chat,
90
+ triggers and ingestion wait in line for a free slot instead of overloading the
91
+ endpoint.
92
+
93
+ - Only on a row with a `base_url`; empty means no limit. `cavelon validate`
94
+ refuses the field on a row without one.
95
+ - The count is shared by every row that points to the same endpoint (the same
96
+ `base_url`), across tenants: give each such row the same number.
97
+ - Ask the person for the number the endpoint serves (for vLLM, its concurrent
98
+ sequences); do not guess high.
99
+ - Plan it with the instance's own tutorial before you propose a number:
100
+ `cavelon docs get tutorials/plan-model-capacity` goes from what the server
101
+ serves to the endpoint limit, the run caps and a load test, at this
102
+ instance's version.
103
+ - A call that finds no free slot within `model_endpoint_slot_wait_seconds`
104
+ (`cavelon limits`) fails with `model_endpoint_busy`; `cavelon explain
105
+ model_endpoint_busy` says what to raise.
106
+ - On rows that already exist, `cavelon models list` shows each row's endpoint
107
+ and `max_concurrent_requests` (never a key). `cavelon models set-limit
108
+ <model_id> <n|none>` shows the old and the new value and changes nothing;
109
+ with `--confirm` it changes the row. It refuses a row without a `base_url`.
110
+ Where this instance's package format does not carry the field, `validate`
111
+ warns that the import ignores it; set it this way instead.
112
+
113
+ **Propose a limit; the person decides.** Say which value you would set and
114
+ why (what the endpoint serves, which rows share it, what waits or fails now),
115
+ then wait for the person's answer. Run `models set-limit --confirm` only after
116
+ they agreed, and never raise or lower a limit without telling them. A limit
117
+ `cavelon limits` names as the operator's (the run caps, the slot waits, the
118
+ licence) is not yours or the tenant's to change: tell the person who changes
119
+ it and where, as the output says.
120
+
121
+ ## The files
122
+
123
+ | Path | Holds |
124
+ |---|---|
125
+ | `cavelon.yaml` | instance, tenant, solution (`harness`), package format version, layout. Never a token. |
126
+ | `package/<section>.yaml` | one top-level section of the package each (`manifest`, `agents`, `tools`, …) |
127
+ | `tests/<suite>.yaml` | one test suite each, when the layout maps test suites there |
128
+ | `env/<name>.yaml` | where `apply --env <name>` goes: `tenant`, `harness`, `mode`, `runtime_bindings` |
129
+ | `seeds/` | your seed scripts and data manifests |
130
+ | `.cavelon/` | local state (inventory, previews); never committed, never edit |
131
+
132
+ A file of a section the instance does not know is kept as it is; the preview
133
+ lists it under "ignored". `package/manifest.yaml` names the package format
134
+ version; leave it as `pull` wrote it.
135
+
136
+ ## Finding out what a section takes
137
+
138
+ 1. Start from what exists: `cavelon pull`, then read the section files. Copy
139
+ the shape of a similar entry rather than inventing fields. A blueprint or
140
+ another instance's export comes in through `cavelon init --from <file>`
141
+ (JSON or YAML): it writes the same files as `pull`, refuses to change files
142
+ that hold something else unless `--force`, and names the sections this
143
+ instance ignores.
144
+ 2. The schema: `cavelon validate` checks the files against the instance's
145
+ package schema, and each error names the file, line and field.
146
+ 3. Concepts and fields: `cavelon docs search <topic>` (for example "agent
147
+ graph", "tools", "knowledge base", "triggers"), then `cavelon docs get
148
+ <page>`.
149
+ 4. A code from `validate`, `apply` or a failed request: `cavelon explain
150
+ <code>`. It gives the meaning, the fix and a docs link.
151
+
152
+ ## Rules that keep a package portable
153
+
154
+ - **Slugs are identities.** An entry is matched by its slug on import; renaming
155
+ a slug creates a new entry and, with `--mode replace`, deletes the old one.
156
+ - **Secrets and variables are references only:** write `{{secret:<name>}}` or
157
+ `{{var:<name>}}` where a value is needed, and declare the name (below). Never
158
+ write a secret value into any file, an argument or a message.
159
+ - **Environment specifics go into `env/`, not `package/`.** Runtime
160
+ requirements (Sandboxes, other solutions) are bound per environment in
161
+ `runtime_bindings`, keyed by the requirement's key, to the target tenant's
162
+ resource id. The preview lists unbound ones under "needs bindings".
163
+ - **OAuth grants and trigger execution identities** are never in the package.
164
+ The preview names them with the Admin path where a person sets them.
165
+ - **Knowledge-base documents** are not in the repository: the package declares
166
+ the knowledge bases; `cavelon kb upload` brings the documents.
167
+ - **A knowledge base reaches an agent only through a search tool.** Naming it
168
+ in a skill's `knowledge_base_assignments` only scopes the search; the skill
169
+ (or the agent) also needs the built-in search tool in its `tool_assignments`
170
+ (`cavelon docs get reference/builtin-tools` names it). Without one the agent
171
+ answers from memory; `cavelon validate` warns
172
+ (`knowledge_base_without_search_tool`).
173
+ - **Who approves goes on the Approval node, not into the memo.** When the
174
+ brief says who approves, or that nobody approves their own request, set the
175
+ node's `approvers` (tenant roles or access groups, directly or in `tiers`
176
+ chosen by a number at `by`, such as the amount) and `forbid_self_approval:
177
+ true`, where the package schema publishes them; the instance then refuses
178
+ anyone else. Read the approval node in the schema and the human-in-the-loop
179
+ docs for the shape. A test only shows the approval is reached; a person
180
+ decides once per branch.
181
+
182
+ ## Variables and secrets the solution needs
183
+
184
+ A package carries names, never values. Declare every variable and secret the
185
+ solution needs in two sections of the package (check that the instance's
186
+ schema has them: `cavelon validate` reports an unknown section):
187
+
188
+ ```yaml
189
+ # package/required_variables.yaml
190
+ - name: crm_base_url
191
+ description: Base URL of the CRM API, e.g. https://crm.example.com
192
+ ```
193
+
194
+ ```yaml
195
+ # package/required_secrets.yaml
196
+ - name: crm_api_token
197
+ description: API token of the CRM integration user
198
+ ```
199
+
200
+ - A name is what the placeholder uses: letters, digits, `_`, `.` and `-`. The
201
+ description tells the person setting it what to enter.
202
+ - `pull` and `apply` keep both files; the instance sorts the entries by name.
203
+ - `cavelon apply` lists each declared or referenced name the target has no
204
+ value for, under "needs variables" and "needs secrets", with the command
205
+ that sets it (`--json`: `set_commands`).
206
+ - **Variables** are plain text that anyone who may view the tenant's settings
207
+ reads. You may set one with `cavelon variables set <name> <value>` (the
208
+ `variables_set` tool) when the value is not a credential and you know it;
209
+ ask the person otherwise. `cavelon variables list` shows them.
210
+ - **Secrets are set by a person, never by you.** Tell the person the exact
211
+ command `apply` printed, `cavelon secrets set <name>` (with the `--env` and
212
+ `--tenant` it printed), to run in their own terminal; it asks for the value
213
+ without echoing it. Never ask for the value, never put it into a file,
214
+ an argument or a message, and never put a credential into a variable.
215
+ `cavelon secrets list` (the `secrets_list` tool) shows which are set,
216
+ never a value. A tenant API key cannot set a secret at all.
217
+
218
+ ## After each edit
219
+
220
+ 1. `cavelon validate` until it reports no errors.
221
+ 2. `cavelon apply --env test` to see what the instance makes of it; the
222
+ preview re-checks everything on the server, including rules that only the
223
+ instance can check (graph rules, references between sections).
224
+ 3. Follow the cavelon-loop skill for confirming and testing.
@@ -0,0 +1,185 @@
1
+ ---
2
+ name: cavelon-long-running
3
+ description: Long-running work on Cavelon - Masterloop loops that a trigger starts, Sandboxes in their two modes (isolated container, customer VM), seeding a workspace, following and pausing a loop, taking results out, binding a trigger's execution identity, testing loops, and runs that wait for run capacity. Use when a solution has a Masterloop node, a trigger that runs on its own, or a Sandbox, when the user wants to run, watch, stop or test a loop, or when a run stays queued or fails with run_capacity_busy or model_endpoint_busy.
4
+ license: Apache-2.0
5
+ ---
6
+
7
+ # Long-running work: loops and Sandboxes
8
+
9
+ A **Masterloop** node runs one solution again and again in bounded iterations
10
+ until its check passes, its budget or deadline runs out, or a person stops it.
11
+ Each iteration returns `continue`, `wait`, `done` or `blocked`. A loop starts
12
+ only through its **trigger**, and stopping the trigger run stops the loop.
13
+
14
+ A **Sandbox** is a workspace a loop (or an ordinary agent) reads and writes. One
15
+ writer at a time: while a run holds a Sandbox, nothing else changes it.
16
+
17
+ Read the instance's own docs for the details: `cavelon docs search masterloop`,
18
+ `cavelon docs search sandbox`. `cavelon sandbox list` shows the tenant's
19
+ Sandboxes, their mode and what each mode offers.
20
+
21
+ ## The two modes
22
+
23
+ | | `isolated_container` | `customer_vm` |
24
+ |---|---|---|
25
+ | Where | the reference runner's containers | a directory on the customer's own VM |
26
+ | Put files in | `cavelon sandbox seed <sandbox> <folder>` | copy them onto the VM, then `cavelon sandbox refresh <sandbox>` |
27
+ | Take results out | `cavelon artifacts export <sandbox>` (a tar) | `cavelon sandbox cat <sandbox> <path>` |
28
+ | Evidence a loop finished | the runner's trusted receipt (`sandbox receipt`) | the files themselves; completion is only agent-reported |
29
+
30
+ `cavelon` refuses what a Sandbox's mode does not offer and names the mode (exit 3).
31
+ Do not work around it; use the other column.
32
+
33
+ ## Prepare
34
+
35
+ 1. **Author** the loop in `package/` like any other solution (cavelon-authoring
36
+ skill). `cavelon validate`, then `cavelon apply --env test`: the preview shows
37
+ the loop's budget, Sandboxes that an active solution writes to, and triggers
38
+ whose execution identity is missing.
39
+ 2. **Bind the test Sandbox** in `env/test.yaml` (`runtime_bindings`), never the
40
+ live one: a loop test needs a Sandbox of its own, because only one writer at a
41
+ time may use it.
42
+ 3. **Check the Sandbox:** `cavelon sandbox validate <sandbox>` (exit 3 lists the
43
+ failing checks). A person enrols VMs, grants Sandbox Access and sets its
44
+ policy in the Admin; you cannot, so ask.
45
+ 4. **A parent and its iteration solution** go in a fixed order: apply the
46
+ iteration, apply the parent, run the parent's loop suite, activate the
47
+ iteration, activate the parent (cavelon-loop skill, "A Masterloop parent and
48
+ its iteration solution"). `activate` never forces.
49
+ 5. **Seed it.** Isolated container: `cavelon sandbox seed <sandbox> <folder>`
50
+ shows what it would send; add `--confirm` to send it. The archive **replaces
51
+ the workspace**, so confirm only for a test Sandbox or after the person
52
+ agreed. Customer VM: the files go onto the VM, then `cavelon sandbox refresh
53
+ <sandbox>`.
54
+
55
+ ## Run and follow
56
+
57
+ ```bash
58
+ cavelon loop start <trigger> --input @request.json # prints the run id and an operation id
59
+ cavelon loop watch <run> --timeout 5m # each iteration's verdict, then the loop's outcome
60
+ cavelon loop iterations <run> # state, budget, iterations (a page at a time)
61
+ cavelon wait <operation-id> --timeout 90s # exit 0 done, 1 failed, 5 needs a person, 6 still running
62
+ ```
63
+
64
+ A loop started from `cavelon` runs **as the person whose token it is**, checked
65
+ again on every iteration. If `loop start` exits 8 (a timeout, a cut
66
+ connection), the run may have started: retry only with the
67
+ `--idempotency-key <key>` its error names, never without it, or a second run
68
+ starts and spends the budget again. `cavelon trace <operation-id>` reads the
69
+ run's traces. Keep each `watch` or `wait` under your shell's time
70
+ limit and run it again to resume (exit 6 means still running). Over MCP, use the
71
+ `loop_iterations` and `operation_status` tools; they never block.
72
+
73
+ - **Pause** at the next safe point: `cavelon loop pause <run>`. Resume with
74
+ `cavelon loop resume <run>`. A paused loop makes `wait` and `loop watch` exit
75
+ 5 at once: tell the person why it paused and what the watch says to run, do
76
+ not wait forever. A pause that is a verdict on the task (`task_blocked`,
77
+ `invalid_continuation`, …) resumes only with `--reason <the pause reason>`,
78
+ exactly as the loop names it, once the person reviewed the cause; `--reason`
79
+ is never free text. A pause that cannot be resumed is cancelled
80
+ (`cavelon loop cancel <run> --confirm`) and started again after the fix; the
81
+ watch prints both commands.
82
+ - An iteration reads **accepted** (with its outcome: continue, wait, done,
83
+ blocked), **rejected**, or **failed** when its child failed. A run that ended
84
+ without a loop names the stage that recorded an error.
85
+ `cavelon trace <child_run_id>` reads one iteration's run.
86
+ - **Stop** a run and its loops: `cavelon loop cancel <run>` shows what stops;
87
+ `--confirm` stops it. Stop runs you started, not someone else's.
88
+ - A run that waits at an **Approval** node, or a loop paused by a guardrail,
89
+ needs a person: `wait` prints the reason and the Admin link. An approval is
90
+ decided by a person, or by an API key an owner granted the explicit scope
91
+ `approvals.decide`. `cavelon` has no command for it, and you never approve
92
+ or reject anything, not through `cavelon api` either: tell the person.
93
+
94
+ ## Waiting for capacity
95
+
96
+ The instance runs only so many agent runs at once, per tenant and in total. A
97
+ trigger or channel run that meets a full cap is not refused: it stays `queued`
98
+ (`pending`) and the instance retries it every few seconds until a slot frees.
99
+ The run says so itself (`waiting_for_capacity`), so `wait`, `watch`,
100
+ `loop watch`, `trace` and `status` say **waiting for run capacity** from the
101
+ first poll and name the cap and where it is set. On an instance that does not
102
+ say, they infer it once the run has been queued for longer than a normal start
103
+ (30 s), and `--json` marks the wait `inferred`. It is not stuck: keep waiting
104
+ within your timeout, and run the same command again on exit 6. Do not cancel
105
+ and restart it; a new run queues behind the same cap.
106
+
107
+ What waits for what, and where each limit is set, is the instance's own page:
108
+ `cavelon docs get concepts/capacity-and-concurrency` (model endpoint slots, run
109
+ caps, branches inside a run, ingestion and rate limits).
110
+
111
+ Two reasons end work for capacity; each has its code in `cavelon explain`:
112
+
113
+ - `run_capacity_busy`: every run slot of the tenant or the instance was in use,
114
+ on a path that does not wait (a synchronous call, a test run). Retry later,
115
+ or ask the instance operator to raise `max_concurrent_agent_runs_per_tenant`
116
+ (for this tenant alone, or for all as a platform setting).
117
+ - `model_endpoint_busy`: a self-hosted model endpoint was at its
118
+ `max_concurrent_requests` and no slot freed within
119
+ `model_endpoint_slot_wait_seconds`. Retry later, or, if the endpoint can serve
120
+ more, propose raising the Model Registry row's `max_concurrent_requests`
121
+ (`cavelon models list` shows it). The person decides; only then run
122
+ `cavelon models set-limit <model_id> <n> --confirm`.
123
+
124
+ `cavelon limits` shows the caps, their source and origin, the slot waits, and
125
+ branch concurrency (how many items of a Map loop run at once, and whether they
126
+ run concurrently at all). Raising them is someone else's decision: tell the
127
+ person what the output names. An operator changes a run cap with
128
+ `cavelon limits set … --confirm` and a Platform-mode personal access token of
129
+ their own; never ask for one.
130
+
131
+ ## Look inside
132
+
133
+ ```bash
134
+ cavelon sandbox files <sandbox> [folder] # what is in the workspace
135
+ cavelon sandbox cat <sandbox> <path> # a file, 32 KiB at a time (--offset reads on)
136
+ cavelon sandbox activity <sandbox> # commands, transfers, validations
137
+ cavelon sandbox logs <sandbox> <activity-id> # one activity's output
138
+ cavelon sandbox receipt <sandbox> <activity> # isolated container only
139
+ cavelon trace <run> # the run's traces, as for any trigger run
140
+ ```
141
+
142
+ Sandbox reads go through a solution the Sandbox allows: `--harness`, or the
143
+ folder's solution, or the Sandbox's only allowed one. Exit 7 means Sandbox
144
+ Access does not list it; a person changes that in the Admin.
145
+
146
+ Take results out of an isolated container with `cavelon artifacts export
147
+ <sandbox> --path output --wait --out results.tar` (it never overwrites a file),
148
+ or start it without `--wait` and download later with `--job <id>`.
149
+
150
+ ## Unattended runs: the execution identity
151
+
152
+ A scheduled or webhook run has no caller, so it acts as an **API key** bound to
153
+ its trigger. `apply` never binds one; it lists unbound triggers in the preview.
154
+
155
+ ```bash
156
+ cavelon trigger identity <trigger> # who it runs as, what the key must reach
157
+ cavelon trigger identity <trigger> <key-name> # shows the change
158
+ cavelon trigger identity <trigger> <key-name> --confirm
159
+ ```
160
+
161
+ Binding gives the trigger standing authority over its Sandboxes: show the person
162
+ first and confirm only after they agree. Name the key by its name or id, never
163
+ its value. A personal access token is never an execution identity. Creating keys
164
+ and adding a key to a Sandbox's Access stay in the Admin; the output says when
165
+ that is still missing.
166
+
167
+ ## Test a loop
168
+
169
+ Loop tests are ordinary test suites whose cases start a trigger and check what
170
+ the loop left behind: the outcome, what it spent, and files in the Sandbox (on an
171
+ isolated container also the receipt). Run them like any suite (cavelon-testing
172
+ skill):
173
+
174
+ ```bash
175
+ cavelon test run --suite <loop-suite> --wait --timeout 10m
176
+ ```
177
+
178
+ On a customer VM the test's own file checks are the evidence.
179
+
180
+ ## Exit codes
181
+
182
+ 0 ok · 1 failed or cancelled · 2 usage · 3 refused: invalid, or not offered by
183
+ the Sandbox's mode · 4 conflict (the loop or binding changed; read it again) ·
184
+ 5 needs a person · 6 still running (run the same command again) · 7 not
185
+ authorised · 8 server or network error.
@@ -0,0 +1,159 @@
1
+ ---
2
+ name: cavelon-loop
3
+ description: The development loop for a Cavelon solution kept in a repository - init or pull, edit, validate, apply (preview, then confirm), seed, wait, test, trace, fix. Use when the user wants to build, change, deploy or promote a Cavelon solution (harness, agents, tools, knowledge bases), when the folder has a cavelon.yaml, or when they mention the cavelon CLI.
4
+ license: Apache-2.0
5
+ ---
6
+
7
+ # The Cavelon development loop
8
+
9
+ A Cavelon solution lives in two places: the **instance** runs it, and the
10
+ **repository** holds its blueprint (`cavelon.yaml`, `package/`, `tests/`,
11
+ `env/`). The `cavelon` CLI moves it between them. Every command takes `--json`;
12
+ use it when you parse the result.
13
+
14
+ ## Before anything
15
+
16
+ - `cavelon status` says which instance, tenant and solution this folder is
17
+ bound to, the last pull and the open previews. `cavelon whoami` says who the
18
+ token acts as and when it expires.
19
+ - **Never handle a token.** If a command exits 7 (not authorised) or says no
20
+ token, ask the person to run `cavelon login --instance <url>` themselves (in a
21
+ terminal, or with a `!` prefix where your client offers one). Never ask them
22
+ to paste a token to you, and never put one in a file or an argument.
23
+ - **Secrets are set by a person.** When a preview or `cavelon secrets list`
24
+ names a secret that is not set, tell the person the exact command to run in
25
+ their terminal, `cavelon secrets set <name>` (as `apply` prints it, with its
26
+ `--env` and `--tenant`). Never ask for the value, never pipe or pass one yourself; there is
27
+ no MCP tool for it. Plain-text variables you may set with `cavelon variables
28
+ set <name> <value>` when the value is not a credential.
29
+ - **Read the limits before you plan a solution:** `cavelon limits` (the
30
+ `limits` tool over MCP). It lists what this instance allows the tenant
31
+ (upload size and file types, agent turns, tool calls, timeouts, rate limits,
32
+ the licence's solution cap, how many branches of a fan-out run at once and
33
+ whether they run concurrently) and the tenant's quotas with their use, the
34
+ monthly Processing Step cap among them. Plan within them: split a document
35
+ that is too large, keep a webhook under its timeout. Each limit names who can
36
+ change it (a tenant admin, a Tenant Owner, or the operator) and the setting;
37
+ when the plan needs more, propose `cavelon limits set` (without `--confirm`)
38
+ or tell the person who to ask instead of working around it. `cavelon status`
39
+ says when a quota is close to full.
40
+ - No `cavelon.yaml` here or above: for a new solution run
41
+ `cavelon init --instance <url> --tenant <tenant> --harness <slug>`; for an
42
+ existing one add `cavelon pull --harness <slug>` after it. To start from a
43
+ package file (a blueprint, an export from another instance), run
44
+ `cavelon init --instance <url> --tenant <tenant> --from <file>` instead of
45
+ splitting it by hand or importing it in the Admin. Ask the person for the
46
+ instance and tenant if you do not know them; do not guess.
47
+
48
+ ## The loop
49
+
50
+ 1. **Pull** what is live: `cavelon pull`. It refuses when `package/` has
51
+ uncommitted changes (outside git: files changed since the last pull);
52
+ commit or apply them first. `git diff` then shows what someone changed
53
+ in the Admin.
54
+ 2. **Edit** the files in `package/` (one file per schema section) and `tests/`
55
+ (one file per test suite). See the cavelon-authoring skill.
56
+ 3. **Validate** offline: `cavelon validate`. Fix every error; `cavelon explain
57
+ <code>` says what a code means and how to fix it.
58
+ 4. **Preview**: `cavelon apply --env test` (or `--harness <slug>`). Nothing is
59
+ imported yet. Read the preview: what is created, updated or deleted, which
60
+ active solutions it reaches, what the target still needs (variables and
61
+ secrets with the command that sets each, OAuth grants, runtime bindings,
62
+ trigger identities), loop budgets, and what the instance ignores.
63
+ 5. **Confirm** exactly that preview: `cavelon apply --confirm <preview-id>`
64
+ (the line `apply` printed, with the same `--env` and `--tenant`). Exit 4 means the target changed since the preview:
65
+ preview again and confirm the new id. When the error lists `blockers`, the
66
+ import's own check found them as it applied: fix what each names (the hint
67
+ says how for a code the kit knows), then preview again.
68
+ 6. **Seed** knowledge when needed: `cavelon kb upload <dir> --kb <kb>`. It
69
+ refuses before sending when a file is larger than the instance allows or of
70
+ a type it does not accept, and a `.zip` unless the tenant has archive
71
+ uploads on (`kb_upload_archive_enabled`) and it stays within their file
72
+ count, unpacked size and compression ratio (exit 3, naming the limit and who
73
+ changes it). A test
74
+ Sandbox gets its files with `cavelon sandbox seed <sandbox> <folder>`
75
+ (isolated container) or `cavelon sandbox refresh <sandbox>` after the files
76
+ were put on the VM (customer VM).
77
+ 7. **Test**: `cavelon test run --suite <suite>`, then `cavelon wait <operation>`.
78
+ See the cavelon-testing skill. A solution with a Masterloop node is run with
79
+ `cavelon loop start <trigger>` and followed with `cavelon loop watch <run>`;
80
+ see the cavelon-long-running skill.
81
+ 8. **Fix** what the results and traces show, and go back to step 2. Commit
82
+ when a step works.
83
+
84
+ ## Show the person before confirming
85
+
86
+ Confirm on your own only for a draft solution in a test environment. Stop and
87
+ show the preview to the person, and confirm only after they agree, when:
88
+
89
+ - the preview lists an active solution under "reaches active", or the target
90
+ solution is active;
91
+ - the environment is `prod` (`--env prod`), or the preview deletes anything
92
+ (`--mode replace`);
93
+ - the preview lists target needs (secrets, grants, identities): only a person
94
+ can provide them, with `cavelon secrets set <name>` or in the Admin.
95
+
96
+ The same holds for the other commands that take `--confirm`: without it they
97
+ only show what would happen. Show it to the person before `cavelon trigger
98
+ identity <trigger> <key> --confirm` (it gives a trigger standing authority), and
99
+ before `cavelon sandbox seed … --confirm` or `cavelon loop cancel … --confirm` on
100
+ anything but a test Sandbox or a run you started yourself.
101
+
102
+ `activate` goes through the readiness gate only, and only with a token that
103
+ may activate. It never forces: activating without the evidence stays a person's
104
+ decision in the Admin, so do not ask for it as a shortcut.
105
+
106
+ ## A Masterloop parent and its iteration solution
107
+
108
+ A parent whose Masterloop node runs another solution (its iteration solution)
109
+ and that iteration solution are two solutions, applied and activated one at a
110
+ time. The iteration has no test of its own: the parent's loop suite is its
111
+ evidence. Keep this order; it needs no override:
112
+
113
+ 1. **Apply the iteration solution** (`cavelon apply`, then `--confirm`). It
114
+ stays a draft.
115
+ 2. **Apply the parent**, with the iteration solution's id under
116
+ `runtime_bindings` in its `env/<name>.yaml`. A draft parent binds a draft
117
+ iteration; an active or paused parent refuses one
118
+ (`runtime_draft_iteration_needs_draft_parent`), so apply the pair into a
119
+ draft parent.
120
+ 3. **Run the parent's loop suite** (`cavelon test run --suite <loop-suite>
121
+ --wait`), with a trigger case whose loop runs through the iteration solution.
122
+ 4. **Activate the iteration solution**: `cavelon activate --harness <iteration>`.
123
+ 5. **Activate the parent**: `cavelon activate --harness <parent>`.
124
+
125
+ When `apply` or `activate` meets a step out of order, its `hint` says which
126
+ step and repeats the order (`cavelon explain <code>` too). Do not work around it.
127
+
128
+ ## Long-running work
129
+
130
+ `kb upload`, `test run`, `loop start`, `sandbox seed` and `artifacts export`
131
+ return operation ids at once. `cavelon wait <ids> --timeout 90s` returns the
132
+ state when the time is up (exit 6 means still running; the same `wait` again
133
+ resumes). Keep each wait under your shell's command time limit, and run longer
134
+ waits in the background if your client can. Over MCP, the `operation_status`
135
+ tool reads an operation without blocking. Exit 5 means a person must act (an
136
+ approval, a paused loop): tell them, with the link `wait` prints.
137
+
138
+ **Never approve anything.** An approval is decided by a person, or by an API
139
+ key an owner granted the explicit scope `approvals.decide`; never by you, and
140
+ not through `cavelon api` either, even when the token could reach the route.
141
+
142
+ Loops, Sandboxes and execution identities have their own skill:
143
+ cavelon-long-running.
144
+
145
+ ## Exit codes
146
+
147
+ 0 ok · 1 other error · 2 usage · 3 validation failed · 4 conflict or stale
148
+ preview · 5 needs a person · 6 timed out (still running) · 7 not authorised ·
149
+ 8 server or network error.
150
+
151
+ ## Where to read more
152
+
153
+ - `cavelon docs search <query>` and `cavelon docs get <page>`: the instance's
154
+ own docs, for its version.
155
+ - `.cavelon/inventory.md`: the tenant's solutions, knowledge bases, tools, test
156
+ suites and sandboxes from the last pull; `cavelon sandbox list` for their
157
+ current state and mode.
158
+ - `cavelon api list --search <word>` and `cavelon api <operation>`: any API
159
+ operation the workflow commands do not cover.
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: cavelon-testing
3
+ description: Testing and optimizing a Cavelon solution - writing test suites in tests/, running them with cavelon test run, waiting for results, reading traces with cavelon trace, and improving prompts, tools and retrieval from what the traces show. Use when the user wants to test, evaluate, debug or improve the answers of a Cavelon solution, when a test run fails, or before activating a solution.
4
+ license: Apache-2.0
5
+ ---
6
+
7
+ # Testing and optimizing a Cavelon solution
8
+
9
+ A solution is ready when its test suites pass on the instance, not when the
10
+ package validates. Test against a draft solution or a test tenant
11
+ (`--env test`), never by trying things on an active solution.
12
+
13
+ ## Test suites
14
+
15
+ Suites live in `tests/`, one YAML file per suite, and `apply` imports them with
16
+ the package. Each suite has cases, and each case one or more steps (a user
17
+ message and what a good answer must contain or do). Copy the shape of an
18
+ existing suite from `cavelon pull`, or read `cavelon docs search regression
19
+ testing`.
20
+
21
+ Write cases for:
22
+
23
+ - the questions the solution exists for, with the facts a good answer needs;
24
+ - edge cases: out of scope, ambiguous, a follow-up in the same conversation;
25
+ - the tools it must call, and the ones it must not;
26
+ - what it must refuse or hand over;
27
+ - in a pipeline with an approval: the cases that must reach it, and the ones
28
+ that must not.
29
+
30
+ ## Testing an approval
31
+
32
+ A test run never waits for a person and never approves anything. A run that
33
+ reaches an Approval node ends there: its trace records that the approval was
34
+ reached (`test_approval_reached`), with the approval's title and instructions,
35
+ and the judge grades the step against those. So write the criteria about what
36
+ the person would see: that the approval was reached, who approves, the facts
37
+ and the recommendation in the instructions. The branches after the decision
38
+ (approved, rejected, expired) are never reached by a test; a person checks them
39
+ on a draft solution by deciding a real approval, and you never decide one.
40
+ Who may decide (`approvers`, `forbid_self_approval`) is enforced when a person
41
+ decides, not in a test: with tiers by amount, write one case per tier that
42
+ reaches the approval, and leave the refusals to the instance.
43
+ `examples/expense-approval` in the dev-kit repository has such a suite.
44
+
45
+ ## Running
46
+
47
+ ```bash
48
+ cavelon apply --env test # preview, then --confirm <preview-id>
49
+ cavelon test run --suite <suite> # returns operation ids at once
50
+ cavelon wait <operation-id> --timeout 90s
51
+ ```
52
+
53
+ `wait` exits 6 when the run is still going; run the same `wait` again (keep
54
+ each call under your shell's time limit). `test run --wait --timeout 5m` does
55
+ both in one call where your client allows long commands; when its wait ends
56
+ first, its last line is the command that resumes, with the same timeout. Exit 1 after a run
57
+ means a case failed, even though the run itself finished; the output names the
58
+ cases that did not pass and why, and `cavelon trace <run>` shows each one. Exit
59
+ 1 also means the run measured nothing comparable (steps not run, technical
60
+ errors, no pass rate): it is no evidence the solution works, so do not go on to
61
+ `activate`; find the cause and run again. Exit 5 means answers wait for a
62
+ person's verdict or a value a case needs: tell the person.
63
+
64
+ ## Reading what happened
65
+
66
+ ```bash
67
+ cavelon trace <test-run-id or operation-id> # cases, scores, judge's reasoning
68
+ cavelon trace <conversation-id> --kind conversation # one case's traces
69
+ cavelon trace <conversation-id> --kind conversation --trace <trace-id> # one trace's spans
70
+ cavelon trace <conversation-id> --kind conversation --trace <trace-id> --span <span-id>
71
+ ```
72
+
73
+ Go down only as far as you need: the summary first, then the failing case's
74
+ trace, then the one span that went wrong (the model call, the tool call or the
75
+ retrieval). Output is bounded; run the command each level prints as printed: it
76
+ carries the id its route needs. A case's traces are under its
77
+ `conversation_id` (a trigger case's under its `run_id`, `--kind trigger`), not
78
+ under the test run's id; a wrong id answers with a hint naming the right one.
79
+ A low-scoring pass shows the judge's reasoning too.
80
+
81
+ ## Optimizing
82
+
83
+ Change one thing at a time, then run the same suite again and compare:
84
+
85
+ - **Wrong or missing facts:** check retrieval first (which chunks came back in
86
+ the retrieval span). Fix the documents or the knowledge base's settings
87
+ before the prompt.
88
+ - **Wrong tool, or a tool called with bad arguments:** sharpen the tool's
89
+ description and parameters, then the agent's instructions about when to use it.
90
+ - **Right facts, poor answer:** adjust the agent's instructions; keep them short
91
+ and specific.
92
+ - **Too slow or too costly:** read the token counts and durations in the trace;
93
+ a smaller model or fewer tool rounds often suffice for a step.
94
+
95
+ Record why a change helped in the commit message. When every suite passes,
96
+ `cavelon activate --harness <slug>` goes through the readiness gate; if the
97
+ token may not activate, a person activates in the Admin.