@oxy-hq/cli 0.11.0 → 0.12.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 (29) hide show
  1. package/README.md +406 -16
  2. package/dist/main.mjs +8126 -3270
  3. package/dist/main.mjs.map +1 -1
  4. package/dist/{mcp-B2KBWNOU.mjs → mcp-WxYfGpMF.mjs} +149 -13
  5. package/dist/mcp-WxYfGpMF.mjs.map +1 -0
  6. package/json-schemas/config.json +26 -45
  7. package/json-schemas/workflow.json +0 -17
  8. package/package.json +3 -2
  9. package/skills/oxy-agents/SKILL.md +15 -4
  10. package/skills/oxy-agents/references/quick-reference.md +1 -1
  11. package/skills/oxy-automations/SKILL.md +1 -1
  12. package/skills/oxy-cli/SKILL.md +49 -2
  13. package/skills/oxy-custom-apps/SKILL.md +223 -13
  14. package/skills/oxy-custom-apps/references/environment-branches.md +172 -0
  15. package/skills/oxy-custom-apps/references/phone-layout.md +88 -0
  16. package/skills/oxy-custom-apps/references/reading-data.md +4 -6
  17. package/skills/oxy-custom-apps/references/sandbox-agent-loop.md +120 -17
  18. package/skills/oxy-custom-apps/references/verifying-in-the-browser.md +19 -9
  19. package/skills/oxy-evals/SKILL.md +1 -1
  20. package/skills/oxy-experiments/SKILL.md +245 -0
  21. package/skills/oxy-semantic-modeling/SKILL.md +2 -2
  22. package/template/.github/workflows/publish.yaml +1 -1
  23. package/dist/mcp-B2KBWNOU.mjs.map +0 -1
  24. package/json-schemas/app.json +0 -1884
  25. package/skills/oxy-data-apps/SKILL.md +0 -362
  26. package/skills/oxy-data-apps/references/examples.md +0 -263
  27. package/skills/oxy-data-apps/references/quick-reference.md +0 -171
  28. package/skills/oxy-data-apps/templates/dashboard-with-controls.app.yml +0 -128
  29. package/skills/oxy-data-apps/templates/simple-dashboard.app.yml +0 -102
@@ -0,0 +1,88 @@
1
+ # Phone layout
2
+
3
+ A desktop layout squeezed into one column passes a "nothing is broken" check and
4
+ still fails a person holding a phone. The usual failures: a table you scroll
5
+ sideways to reach the column that matters, two rows of tabs cut mid-word, the
6
+ answer below a map or a wall of filters, a row tap that opens its detail in a side
7
+ panel off the screen, and explanations that only open on hover, which a touch
8
+ screen never does.
9
+
10
+ The fix is a **phone view**: a second presentation of the same screen, made from
11
+ the phone kit in `@oxy-hq/sdk/shell` (`@oxy-hq/sdk` 2.27.0 and later). It is styled by `@oxy-hq/sdk/shell.css`, which the
12
+ app already imports for the shell.
13
+
14
+ ## When to build one
15
+
16
+ Build a phone view for any screen people open on a phone: anything with a table
17
+ wider than a phone, more than about five tabs or sections, a map, side panels, or
18
+ hover tooltips. A screen that is already a single column of text and buttons only
19
+ needs the floor below (text ≥ 13px, labels ≥ 11px, actions ≥ 44px, fields ≥ 16px).
20
+
21
+ ## The pattern
22
+
23
+ Keep the desktop component exactly as it is. Render the phone view beside it, fed
24
+ by the same hooks and actions; only the presentation changes.
25
+
26
+ ```tsx
27
+ import { usePhoneLayout } from "@oxy-hq/sdk/shell";
28
+
29
+ export function Orders() {
30
+ const data = useOrders(); // the hooks the desktop already uses
31
+ const phone = usePhoneLayout(); // a phone upright, or on its side
32
+ return phone ? <OrdersPhone {...data} /> : <OrdersDesktop {...data} />;
33
+ }
34
+ ```
35
+
36
+ `usePhoneLayout()` is true below 640px wide, and on a touch screen no taller than
37
+ 500px (a phone on its side); it re-renders when that changes and is `false` on the
38
+ server. Do not branch on the user agent, and do not restyle the desktop component
39
+ with breakpoints until it "fits": the desktop and TV layout must not move.
40
+
41
+ ## What each desktop part becomes
42
+
43
+ | On desktop | On the phone |
44
+ | --- | --- |
45
+ | Tabs, a sidebar, a section switcher | `PhoneTabBar` at the bottom: up to five; past five it shows four and a More sheet |
46
+ | The page | `PhonePage` with `tabBar` (and `stickyAction`); pass the tab id as `scrollKey` |
47
+ | KPI cards | `PhoneKpiStrip`, two per row, first on the screen |
48
+ | A table | `PhoneCardList` of `PhoneCard`s: the row's name, a status pill, two or three key figures; a `summary` line on top. **Never a sideways-scrolling table.** |
49
+ | A row's action button (Post, Approve) | the card's `trailing`, or `PhoneStickyAction` for the screen's one main action |
50
+ | A detail panel, drawer or modal | `PhoneSheet` (full screen, Back). The phone's Back closes it through `onClose` and the page stays put; a sheet that opened by pushing its own entry (a route, `?item=`) passes `historyEntry={false}` |
51
+ | A list of things that need someone | `PhoneSection` of `PhoneRow`s with a `tone` dot |
52
+ | A row of filter selects | one `PhoneFilterChip` opening a `PhoneSheet` of filters |
53
+ | List / Map, Day / Week | `PhoneSegmented` |
54
+ | A hover tooltip or footnote | `PhoneHint`, an ⓘ that opens on a tap |
55
+ | A map beside or above the content | its own tab, or a sheet, filling the screen; never a fixed half above the numbers |
56
+ | Device-frame previews, wide editors, fullscreen/kiosk buttons, keyboard hints | left out of the phone view |
57
+
58
+ ## The first screen answers the job
59
+
60
+ Decide what someone opens this screen for on a phone: "is anything on fire", "what
61
+ do I need to post today", "how did yesterday go". That answer goes first, visible
62
+ without scrolling: a status row and the KPI strip, then the "needs you" rows. Maps,
63
+ history and settings come after, or behind a tab.
64
+
65
+ ## Rules of thumb
66
+
67
+ - One page scroller. `PhonePage` scrolls with the shell's main area; never put a
68
+ fixed-height box that scrolls inside it. Its dock reaches the bottom of the screen
69
+ through wrappers, but padding on a wrapper insets it: for an edge-to-edge tab bar,
70
+ render `PhonePage` without a padded `<main>` around it.
71
+ - Everything a person can tap is at least 44px; the kit's pieces already are.
72
+ - Text in a phone view is 13px or more, labels 11px or more, numbers in tabular
73
+ figures. Fields are 16px or more, or iOS zooms the page when one is focused: the
74
+ kit raises `text-sm` and smaller and fields with no size, and leaves larger ones
75
+ alone. It cannot raise `text-[11px]` or your own small `font-size`, so don't set
76
+ those on a field.
77
+ - Explanations a tap away (`PhoneHint`), never hover-only.
78
+ - Use the kit's colours (it follows your theme tokens and a `.dark` ancestor)
79
+ rather than hard-coded ones, so light and dark both work. Its corners follow
80
+ `--radius` (at `0`, square, with only status dots round) and its text `--font-sans`.
81
+
82
+ ## Checking it
83
+
84
+ Look at it, don't only test it. With the browser at 390×844 and again at 844×390,
85
+ touch emulation on, light and dark: screenshot every tab at the top and after each
86
+ screenful of scrolling, open a detail sheet, and read each screenshot as someone who
87
+ opened the app to get something done. Then load the desktop at 1440×900 and compare
88
+ it with the published version: it must be unchanged.
@@ -2,10 +2,9 @@
2
2
 
3
3
  You don't need an `X-API-Key` to poke at the data API by hand — a bearer
4
4
  token works, and **`oxyc`** (`npm i -g @oxy-hq/cli`) is the client that sends
5
- it for you. **It replaced `oxy api`, and the Rust `oxy login`, `oxy publish`
6
- and `oxy proxy` with it**: every command that talks to a deployment's HTTP API
7
- is `oxyc`. It reads the `credentials.json` the Rust `oxy login` wrote, so an
8
- existing login still works.
5
+ it for you. **Every command that talks to a deployment's HTTP API is `oxyc`**;
6
+ the `oxy` binary has none. It reads the same `credentials.json` an older
7
+ `oxy login` wrote, so an existing login still works.
9
8
 
10
9
  The bearer is `OXY_TOKEN` (or the variable `--token-env` names), else the
11
10
  `oxyc login` cache for that deployment.
@@ -71,8 +70,7 @@ oxyc api projects/<projectId>/query --env local -f sql='select 1' --md
71
70
  401 that reads like an expired session is usually a dev call made with a
72
71
  prod token — check the `--env`. A `200` with a `null` body is the *other*
73
72
  expired-token shape; `oxyc whoami` tells them apart.
74
- - For a raw `curl`, `oxyc token` prints the resolved bearer (`oxy api
75
- --print-token` went with the rest of that command):
73
+ - For a raw `curl`, `oxyc token` prints the resolved bearer:
76
74
 
77
75
  ```bash
78
76
  curl -H "Authorization: Bearer $(oxyc token --env local)" \
@@ -6,6 +6,23 @@ a report its engineer can act on. What a sandbox is, and the same loop as a
6
6
  person runs it, are in
7
7
  [SKILL.md → Sandboxes](../SKILL.md#sandboxes--try-a-change-on-real-data-before-shipping-it).
8
8
 
9
+ ## The whole loop at a glance
10
+
11
+ Everything up to shipping is yours; shipping is a person's.
12
+
13
+ | Step | Do | Proves |
14
+ | --- | --- | --- |
15
+ | 1. Build locally | `oxyc publish --build-only`, `oxyc fn dev <fn>` | it builds, and a function runs, before any approval |
16
+ | 2. Get a token | `oxyc tokens create --sandbox-agent --app <org>/<app>` — your engineer approves once | you act as yourself, on those apps only |
17
+ | 3. Make a sandbox | `oxyc env create … dev-x` (planes for what you test: [environment-branches.md](environment-branches.md)) | a copy of the app nobody else uses |
18
+ | 4. Publish into it | `oxyc publish --app-env dev-x` | the build the sandbox serves |
19
+ | 5. Exercise it | `fn call`, `fn run --as-schedule`, `checks run` | the functions, on production's reads |
20
+ | 6. Check the page | `checks run --browser`, `oxyc proxy --app-env dev-x` + a browser tool | what a person sees |
21
+ | 7. Read back | `invocations list` / `held`, `logs`, `env outbox`, `env diff` | what ran, held, would have been sent, and changed |
22
+ | 8. Iterate | edit, back to 4 | |
23
+ | 9. Hand back, clean up | the report below; `env delete --wait`, then `tokens revoke --current` | |
24
+ | 10. Ship | **your engineer:** `oxyc promote <app> --from dev-x`, check staging, `oxyc promote <app>` | |
25
+
9
26
  ## An agent's own credential: the sandbox agent token
10
27
 
11
28
  **If you are an AI agent, you do not work on your engineer's login.** A login
@@ -30,8 +47,9 @@ oxyc tokens create --sandbox-agent --app <org>/<app> --env <deployment>
30
47
  in, type the code the terminal shows, and approve. The token is printed
31
48
  exactly as above. The rule does not change: never open or approve that page
32
49
  yourself, with a browser tool or any other way.
33
- - **Name who approves with `--approver <email>`** (or `OXY_APPROVER`), only
34
- with `--no-browser`: the engineer is told by push, email and Slack; they type
50
+ - **Name who approves with `--approver <email>`** (or `OXY_APPROVER`, which
51
+ counts with `--no-browser`, `oxyc login --no-wait` or in a cloud session, never
52
+ where oxyc only detected SSH or a Codespace), with the device code: the engineer is told by push, email and Slack; they type
35
53
  the code from your output on the page. Use the email your engineer gave you,
36
54
  and still show them the code `oxyc` printed, since the notice does not carry
37
55
  it. Only that person can open the request: if you were given no address, omit
@@ -78,9 +96,11 @@ token, `oxyc tokens create --agent`: see [reading-data.md](reading-data.md).
78
96
  ## What it reaches
79
97
 
80
98
  One to five named apps, and only `dev-<handle>` sandboxes it created itself —
81
- three at a time at most, counting ones still being deleted. Everything else
82
- answers `404`: production and staging, another app, someone else's sandbox,
83
- `/admin`, a secret's value. A publish to a channel (staging, production) or a
99
+ three at a time at most, counting ones still being deleted. In those it runs
100
+ the loop below and loads the app's page ([Check its page](#check-its-page)).
101
+ Everything else answers `404`: production and staging, another app, someone
102
+ else's sandbox, `/admin`, a secret's value, and the deployment's own `/api`
103
+ data routes. A publish to a channel (staging, production) or a
84
104
  promote answers `403`. `oxyc` refuses those two, and `oxyc api`, `oxyc apps`
85
105
  and `oxyc login-link`, before any request (exit `2`). **Shipping stays with a
86
106
  person.**
@@ -103,6 +123,8 @@ oxyc env secret set <org>/<app> KEY --app-env dev-x --value-env VAR --env <deplo
103
123
  # 3. Call what you changed. Success: exit 0 and "ok":true. Then run the app's checks.
104
124
  oxyc fn call <org>/<app> <function> --app-env dev-x --data '{}' --env <deployment> --token-env OXY_TOKEN --json
105
125
  oxyc checks run <org>/<app> --app-env dev-x --env <deployment> --token-env OXY_TOKEN --json
126
+ # 3b. Changed something a person sees? Check the page (see "Check its page").
127
+ oxyc checks run <org>/<app> --app-env dev-x --browser --expect-selector '<css>' --env <deployment> --token-env OXY_TOKEN --json
106
128
  # 4. Read back: what ran (a row's id is `id`), what it held instead of writing, its logs.
107
129
  oxyc invocations list <org>/<app> --app-env dev-x --env <deployment> --token-env OXY_TOKEN --json
108
130
  oxyc invocations held <org>/<app> <invocation-id> --env <deployment> --token-env OXY_TOKEN --json
@@ -145,7 +167,11 @@ Reads hit production data. A write lands in a home of the sandbox's own, or it
145
167
  is *held*: recorded in `invocations held` and not performed. A held write is
146
168
  the expected answer outside production. Report it. Unless the task asks for
147
169
  it, do not edit `nonProduction` in the manifest to make the write land:
148
- staging and every other sandbox share that map. A sandbox's schedules are off
170
+ staging and every other sandbox share that map. To make it land in this
171
+ sandbox alone, override the destination (`env update --destination`, below). A mutating `ctx.fetch` is held
172
+ the same way unless staff set the environment's `fetch` plane to `allow` for
173
+ registered provider sandboxes (`env update --fetch-host <host>`); a call sent that way shows in `invocations held`
174
+ as `(sent)`. Do not set it yourself. A sandbox's schedules are off
149
175
  unless staff turned them on, and your token cannot turn them on: to test a
150
176
  scheduled function, run it once as its schedule would — `oxyc fn run
151
177
  <org>/<app> <function> --app-env dev-x --as-schedule --env <deployment>
@@ -206,14 +232,41 @@ Branch on the exit code and the JSON fields, not on the text:
206
232
  day after its token ends, and your engineer can delete it sooner with the
207
233
  `env delete` command on their own login.
208
234
 
209
- ## You cannot open a page
235
+ ## Check its page
236
+
237
+ The token loads your own sandbox's page — its HTML, assets and `/fn` calls —
238
+ when it rides as a header with `X-Oxy-App-Env: dev-x`. It never becomes a
239
+ browser cookie, so you reach the page in one of two ways, both on the token:
240
+
241
+ ```bash
242
+ # 1. Assert it mounted: one more entry in checks[], "kind": "browser".
243
+ oxyc checks run <org>/<app> --app-env dev-x --browser --expect-selector '<css>' \
244
+ --env <deployment> --token-env OXY_TOKEN --json
245
+ # 2. Drive it yourself: a local proxy that adds the token and the header.
246
+ oxyc proxy --app <org>/<app> --app-env dev-x --port 3000 \
247
+ --env <deployment> --token-env OXY_TOKEN # in the background; leave it running
248
+ # then, with a browser tool: http://127.0.0.1:3000/customer-apps/<org>/<app>/
249
+ ```
210
250
 
211
- The token signs no browser in, and the sandbox's host answers only a signed-in
212
- staff session. So you verify the functions (`fn call`, `checks run`,
213
- `invocations held`, `logs`) and your engineer verifies what a person sees. Do
214
- not log in to get a session, and do not drive the app's production URL
215
- instead: it does not serve your build. What your engineer does with the link
216
- is in [verifying-in-the-browser.md](verifying-in-the-browser.md).
251
+ - **The browser check** passes when the page names `dev-x` and the build `env
252
+ show` reports, sends its ready beacon, throws nothing, and shows the
253
+ `--expect-selector` element. It needs Playwright resolvable from the
254
+ working directory. Over MCP it is `oxy_checks_run` with `browser: true`
255
+ (and `expectSelector`).
256
+ - **The proxy** serves the deployment at `http://127.0.0.1:<port>`, adding the
257
+ token and `X-Oxy-App-Env` to requests under the app's path only. Open that
258
+ path with a browser tool (`browser_navigate`, `browser_click`,
259
+ `browser_take_screenshot`, `browser_evaluate` to measure) and click through
260
+ what you changed. In a sandbox it forwards writes: they land in the
261
+ sandbox's homes or are held, as a `fn call`'s are. Stop it when you are done.
262
+ - **What it cannot show:** the page's own calls to the deployment's `/api`
263
+ (an SDK `useQuery` or semantic query) answer `404` to your token, so a card
264
+ fed that way renders empty or errors. `/fn` calls work. Report which cards
265
+ you could not see with data; do not reach for another credential.
266
+
267
+ Do not log in to get a session, and do not drive the app's production URL
268
+ instead: it does not serve your build. How to drive and measure a page is in
269
+ [verifying-in-the-browser.md](verifying-in-the-browser.md).
217
270
 
218
271
  ## What to hand back
219
272
 
@@ -226,7 +279,10 @@ Whether the task worked or not:
226
279
  - each function you called, with its input and whether it was `ok`; each
227
280
  check's name and `passed`, or that the app declares no checks;
228
281
  - every held write (`op`, `plane`, `table`, `note`);
229
- - what you did not verify: under this token, everything on the page;
282
+ - the page: the browser check's result, and what you clicked through the
283
+ proxy, with screenshots;
284
+ - what you did not verify: cards fed by the deployment's `/api` (they answer
285
+ `404` to your token), and anything you did not open;
230
286
  - the cleanup: the sandbox deleted or still up, and the token revoked.
231
287
 
232
288
  Copy what you need out of `invocations` and `logs` into the report before you
@@ -266,10 +322,11 @@ cases:
266
322
 
267
323
  If your runtime speaks MCP, `oxyc mcp --env <deployment>` serves the same loop
268
324
  as tools — `oxy_env_create` / `oxy_env_list` / `oxy_env_show` /
269
- `oxy_env_delete`, `oxy_publish_sandbox`, `oxy_fn_call`, `oxy_checks_run`,
325
+ `oxy_env_delete`, `oxy_env_update`, `oxy_env_reset`, `oxy_env_outbox`,
326
+ `oxy_publish_sandbox`, `oxy_fn_call`, `oxy_fn_run`, `oxy_checks_run`,
270
327
  `oxy_invocations_list` / `oxy_invocations_held`, `oxy_logs`. It reads its
271
328
  credential from `OXY_TOKEN` and nowhere else (a person on their own login
272
- adds `--login`). With a sandbox agent token the list is those ten,
329
+ adds `--login`). With a sandbox agent token the list is those fourteen,
273
330
  `oxy_whoami`, `oxy_env_secret_list` / `_set` / `_delete` and
274
331
  `oxy_token_revoke` (`confirm: true`) — and no `oxy_request`. Prefer them to
275
332
  shelling out: each calls its verb's own request-building code, so the result
@@ -279,9 +336,51 @@ with the class at the end of its text (`[exit 5 NOT_FOUND]`, plus `server
279
336
  code: <code>` when the server sent one) — branch on that the way you would
280
337
  on the exit code. `oxy_fn_call` and `oxy_checks_run` set `isError` when the
281
338
  function or a check failed, with the full document still in the result.
339
+ `oxy_checks_run` takes `browser: true` and `expectSelector` for the page
340
+ check. The proxy has no tool: run `oxyc proxy` in the background.
282
341
  `oxy_env_delete` needs `confirm: true`. `oxy_publish_sandbox` takes only a
283
342
  `dev-<handle>` and cannot reach staging or production.
284
343
 
344
+ ## Planes, the outbox, reset and `--from`
345
+
346
+ A sandbox's planes say how isolated it is (every plane, mode and refusal is in [environment-branches.md](environment-branches.md)). Every
347
+ command below takes `--env <deployment> --token-env OXY_TOKEN` like the rest.
348
+
349
+ - **Read what a `capture` sandbox would have sent:** `oxyc env outbox <app> dev-x
350
+ [--limit N] [--json]` (over MCP `oxy_env_outbox`), newest first, 50 by default,
351
+ 200 at most. Each message has `kind` (`email` or `notify`), `to`, `subject` or
352
+ `title`, `body`, `invocation_id`, `function`, `captured_at`. Your token sees
353
+ only what was captured since *this* sandbox began, so a name you re-create
354
+ starts empty. Assert on it after `fn call`.
355
+ - **Write to a database of its own:** `env update <app> dev-x --destination
356
+ <db>=<mapped>` writes `<mapped>` instead of production's `<db>` in this sandbox
357
+ only, over the manifest's `nonProduction.destinations` (`--clear-destination
358
+ <db>` removes it; both repeat, and `env create` takes `--destination`). The
359
+ mapped name may not be the production database or itself overridden: `400
360
+ invalid_planes`. Prefer this to editing the manifest, which every non-production
361
+ environment shares. Over MCP, pass `planes: {"warehouse": {"mode": "mapped",
362
+ "destinations": {"<db>": "<mapped>"}}}`.
363
+ - **Start clean:** `env reset <app> dev-x --plane storage,secrets,messages` empties
364
+ those planes; each answers `done`. `--plane oltp [--at <ts>]` re-cuts a sandbox's
365
+ own OLTP branch (`oltp=branch|empty`) from production: it answers `queued` with a
366
+ `run_id`, not `done`, so poll `env show` for `oltp_branch.status == "ready"` before
367
+ the next call. A sandbox on the default `oltp=schema` has nothing to reset
368
+ (`409 plane_not_resettable`): publish again to re-seed it. A second reset while
369
+ a teardown or migration holds the sandbox is `409 environment_busy`: retry. On `staging` only `messages`
370
+ resets (`409 plane_not_resettable` for the others: the team shares them).
371
+ - **Start on a build:** `env create dev-x --from <env>` points the new sandbox at
372
+ the parent's build and queues that build's migrations, so you can `fn call`
373
+ without publishing. A parent with no build gives a sandbox with none. Your token
374
+ may fork only from a sandbox it created, or from staging if it was minted with
375
+ the staging option: `--from production` (and `--from staging` without that
376
+ option) answers `400 invalid_parent`, as does a name that does not exist. A person can
377
+ fork any environment they may open.
378
+
379
+ Over MCP these are `oxy_env_outbox`, `oxy_env_update`, `oxy_env_reset` and
380
+ `oxy_env_create` (`from`, `at`, `preset`, `planes`). An outbox only fills when
381
+ the sandbox's `messages` plane is `capture`: check `oxyc env show` (`set:`)
382
+ before you read an empty one as "nothing was sent".
383
+
285
384
  ## A sandbox isolates the app, not the workspace
286
385
 
287
386
  The semantic model, automations and Airway pipelines a sandbox reads are
@@ -304,4 +403,8 @@ when what it waited for ended `failed` or `cancelled`, `7` past its deadline.
304
403
  Over MCP the same verbs are `oxy_preview_create` / `_list` / `_show` /
305
404
  `_delete` (`confirm: true`) / `_checks` / `_run` / `_runs_list` / `_run_show`.
306
405
  To make a sandbox read the branch's semantic model, publish to it with
307
- `--semantic-branch <branch>`.
406
+ `--semantic-branch <branch>`, or pin the environment itself with
407
+ `oxyc env update <app> dev-<handle> --plane semantic=branch:<branch>` (it
408
+ recompiles on a push; `503 semantic_branch_not_ready` until the first compile
409
+ lands — retry). To run an automation your bundle starts as a dry run, set
410
+ `--plane workspace-actions=preview`. `release:staging` is not available.
@@ -5,14 +5,23 @@ a card rendering a red error banner, a grid with ragged rows, a button wired to
5
5
  nothing, or a component misreading its function's response shape. **The build is
6
6
  not the check — driving the published app is.**
7
7
 
8
- ## An agent on a sandbox agent token cannot do this on a cloud target
8
+ ## An agent on a sandbox agent token: through `oxyc proxy`
9
9
 
10
- And says so. The token signs no browser in. Your sandbox's page is on its own
11
- host (the `url` from `env create`), behind a staff session, and `oxyc proxy`
12
- cannot target a sandbox. Verify the functions in the sandbox, hand your
13
- engineer the link, and list what on the page you could not check
14
- ([What to hand back](sandbox-agent-loop.md#what-to-hand-back)). The rest of
15
- this file is what they do with that link.
10
+ The token signs no browser in, so a browser tool cannot open the sandbox's
11
+ own host (the `url` from `env create`). Put the proxy in between instead. It
12
+ holds the token, adds `X-Oxy-App-Env`, and serves your sandbox's page on
13
+ localhost:
14
+
15
+ ```bash
16
+ oxyc proxy --app <org>/<app> --app-env dev-x --port 3000 --env <deployment> --token-env OXY_TOKEN # background
17
+ ```
18
+
19
+ Then drive `http://127.0.0.1:3000/customer-apps/<org>/<app>/` as below. For a
20
+ plain "did it mount" assertion, `oxyc checks run … --browser` needs no proxy.
21
+ Cards fed by the deployment's `/api` answer `404` to the token, so they render
22
+ without data; say which ones in your report
23
+ ([Check its page](sandbox-agent-loop.md#check-its-page)). A person on their own
24
+ login opens the sandbox's `url` directly.
16
25
 
17
26
  ## Drive the page
18
27
 
@@ -21,7 +30,7 @@ fits. After `oxyc publish`, for anything touching `src/**` or a function a
21
30
  card calls:
22
31
 
23
32
  ```
24
- browser_navigate → the published /customer-apps/<org>/<slug>/ URL
33
+ browser_navigate → the published /customer-apps/<org>/<slug>/ URL (the proxy's, for an agent)
25
34
  browser_find → locate a control by its text, get its ref
26
35
  browser_click → drive it
27
36
  browser_evaluate → MEASURE (grid widths, computed styles, element counts)
@@ -52,7 +61,8 @@ for (const el of grid.children) {
52
61
  ## Two prerequisites that bite
53
62
 
54
63
  - **The app is behind auth.** The browser must hold a session for the target
55
- Oxy deployment — sign in there first.
64
+ Oxy deployment — sign in there first — or go through `oxyc proxy`, which
65
+ carries the credential for it.
56
66
  - **`pnpm dev` against cloud data returns `origin not allowed`** — the data API
57
67
  rejects a localhost origin for a published app. Drive the published URL, or
58
68
  run the `oxyc proxy` sidecar
@@ -315,7 +315,7 @@ all of them. Preserve the file's existing style. Explain the root cause alongsid
315
315
  ### 5. Validate
316
316
 
317
317
  There's no build step. `oxy test` reloads the agent file, its context and its semantic files
318
- from disk on every run, and `oxy build` (embeddings and integration sync) plays no part. Check
318
+ from disk on every run, and `oxy build` (which does nothing any more) plays no part. Check
319
319
  the files you edited, then re-run:
320
320
 
321
321
  ```bash
@@ -0,0 +1,245 @@
1
+ ---
2
+ name: oxy-experiments
3
+ description: >-
4
+ Use when running an Oxy experiment from a terminal or agent — drafting a
5
+ design, choosing its grain (hour, day, week, month), pricing candidate
6
+ designs, registering, watching a live run and its interim reading, aborting,
7
+ or reading the report — with `oxyc experiments`. Covers the lifecycle order,
8
+ the hash handshake that guards every write, why a pricing refusal or a sealed
9
+ result is the answer rather than an error, why an interim is a hint and not a
10
+ result, and what lives in git versus the experiment record.
11
+ ---
12
+
13
+ # Oxy experiments with `oxyc`
14
+
15
+ An experiment is a **record on the deployment**, not a file in the workspace:
16
+ one draft design edited in place, priced, registered (which freezes it and
17
+ makes it the run), then watched until it is reported or aborted. What the
18
+ design *points at* stays in git and is compiled like any other workspace file:
19
+ the lever automations (`lever.on.via`, `lever.off.via`), the measures and views
20
+ (`outcome.target`, `design.time_dimension`, guardrail criteria). A design that
21
+ names an automation or measure the workspace does not have is refused at
22
+ pricing or registration — fix the workspace, not the record. So is a lever
23
+ whose automation never reads the units it is sent — `{{ unit }}` for
24
+ `lever.per: unit`, `{{ units }}` for `per: wave`, or `{{ members }}` under
25
+ `assign_by` — since every flip would then switch the whole fleet. Make the
26
+ automation act on the units it is given.
27
+
28
+ There is no file to import: create the draft from a YAML or JSON body
29
+ (`create --file`), or start from an existing design's config (`design <name>`).
30
+ `owner` is a workspace member's email (any `@` makes it one, matched whatever
31
+ its capitals) or else a team name; it receives guardrail alerts, abort notices
32
+ and estimate failures. An owner that matches nobody sends them to the
33
+ organisation's owners and admins.
34
+
35
+ Every verb needs `--workspace <id>` (`oxyc api {org}/workspaces` lists them)
36
+ and the deployment (`--env dev|staging|local`, or `--target <url>`). Staff
37
+ reach a tenant workspace only inside `oxyc assume start --org <slug> --reason …`;
38
+ a 403 that says `assume_role_required` means start one, not that the role is
39
+ missing.
40
+
41
+ ## The loop
42
+
43
+ ```bash
44
+ oxyc experiments list # what exists, and each status
45
+ oxyc experiments design customer_promo > promo.yml # a starting point: the config as YAML
46
+ # edit promo.yml: `experiment:` is the new name; leave design.waves/seed and
47
+ # outcome.mde_at_proposal empty — pricing writes those. Set design.grain if not daily
48
+ oxyc experiments create --file promo.yml
49
+ oxyc experiments price promo \
50
+ --candidate '{shape: waves, wave_sizes: [20, 20], first_switch_on: 2026-11-02, spacing_days: 14}' \
51
+ --candidate '{shape: switchback, first_period_on: 2026-11-02, period_days: 7, pairs: 6}' \
52
+ --wait
53
+ oxyc experiments use promo <proposal-id> # pricing's keys onto the draft
54
+ oxyc experiments register promo --yes # irreversible: freezes the design
55
+ oxyc experiments status promo # flips, guardrails, compliance, estimate
56
+ oxyc experiments interim promo # the reading so far — a peek, not the result
57
+ oxyc experiments result promo # sealed until the run is reported
58
+ ```
59
+
60
+ Statuses, in order: `draft` → `registrable` (a priced proposal was adopted) →
61
+ `registered` → `live` → `closing` → `reported`, or `aborted` from
62
+ `registered`/`live`. `registration_refused` carries the reason in the `note`
63
+ column.
64
+
65
+ ## Grain: what one reading is
66
+
67
+ `design.grain` is `day` (the default, and omitted from the config), `hour`,
68
+ `week` or `month`. One reading is a unit's outcome over one period of it, and
69
+ **every count in the design is in periods**: `pre_days`, `post_days`,
70
+ `washout_days`, `anticipation_days`, a candidate's `spacing_days` and
71
+ `period_days` keep their `_days` names but mean hours, weeks or months at those
72
+ grains. The answer is stated per unit-period (per store-week), and a period
73
+ that has not finished is never read.
74
+
75
+ - Every date must start a period: a **Monday** at week grain, **the 1st** at
76
+ month grain, any date at day grain (the switch happens as that day begins in
77
+ `design.timezone`), and a **whole local hour** at hour grain, written
78
+ `2026-10-26T14:00` (a bare date means midnight; 14:30 is refused). Pricing
79
+ refuses a first date that is not a period start and names the next one.
80
+ - **Hour** needs the outcome's time dimension to be a datetime; on a date
81
+ column it is refused. At hour grain a switchback can alternate within a day,
82
+ and the read-back (`when_on`/`when_off`) measures must also have a time of
83
+ day, or no switch inside a day could be confirmed — pricing warns and names
84
+ the measure. Prefer a period that holds the same hours in both halves of a
85
+ pair (12 or 24); hourly outcomes swing hard across the day.
86
+ - **Week** is Monday to Sunday. A warehouse whose weeks start on Sunday
87
+ (BigQuery and MySQL by default) is refused at week grain: use day or month.
88
+ - Pick week or month when the measure does not add up over days (weekly
89
+ active customers), when most days are empty, or when dates must line up with
90
+ how the business runs. On a measure that adds up and has data every day the
91
+ grain changes the unit of the answer, not the answer.
92
+ - What watches a live run stays in **days** at every grain: `grace_days`,
93
+ guardrails, and the arrival-lag warnings.
94
+
95
+ ## Pricing: read a refusal as the result
96
+
97
+ `price` takes one to six candidates and prices each against the draft. Each
98
+ comes back `done` (an MDE), `refused` (why this design cannot answer the
99
+ question) or `failed` (a fault). **A refusal is the platform's most valuable
100
+ output** — "all 80 units are placed in waves, none is left as a control", or
101
+ "a sign-flip test over 4 pairs cannot reach α = 0.05" — so change the candidate
102
+ the way the reason says and price again. Do not retry the same candidate.
103
+
104
+ - Rank candidates on **`mde/unit-day`** only (per unit-period at other
105
+ grains). A grouped design's own `mde` is per *group*-day, so raw `mde`
106
+ numbers are not comparable across candidates.
107
+ - `alpha` on a candidate overrides `outcome.alpha` for it. Above 0.05 the
108
+ report can only ever say *directional*, never *significant*.
109
+ - A proposal marked `stale` priced an earlier draft; `use` refuses it. Price again.
110
+ - `--wait` polls until every candidate settles (default 600 s, `--timeout`);
111
+ without it, read them later with `oxyc experiments proposals <name>`.
112
+
113
+ ## Writes are guarded by the draft's hash
114
+
115
+ `edit` sends the hash of the draft it read (or `--base-hash` for the one *you*
116
+ read earlier); `register` and `retrospective` send the hash of the draft they
117
+ read just before posting. If someone edited the draft in between, the server
118
+ answers 409 "the design was changed since you read it" — re-read with
119
+ `design`, merge, and try again. Never loop on the 409.
120
+
121
+ An experiment has **one draft**, edited in place until it is registered;
122
+ registering locks it, and a **registered design never changes**. To change
123
+ one, `duplicate <name> <new-name>` (the UI's *Duplicate as new draft*) and
124
+ edit and price the copy.
125
+
126
+ ## Register vs retrospective
127
+
128
+ - `register` pre-registers: it freezes the design at the server's clock and the
129
+ driver flips levers on the scheduled dates. Do it before the first switch date.
130
+ - `retrospective` is for a design whose dates are **all past**: it analyses
131
+ existing data as the experiment's one run and moves no lever. `status` says
132
+ `retrospective_ready` when it is allowed, or `not yet` with the reason.
133
+
134
+ A retrospective needs no `lever` and no `mde_at_proposal`. A rollout that was not
135
+ randomised is declared with `design.assignment: observed`: its waves are the units
136
+ that changed and the dates they changed, and it needs no `seed` and no pricing.
137
+ Its report reads **Observational**; never price-and-overwrite the waves to fake a
138
+ draw (a hand-edited split is reported as written by hand). A retrospective whose
139
+ estimate refused (a unit with no rows, coverage) leaves the design editable: fix
140
+ it, then `retrospective` again.
141
+
142
+ To read what happened after a past change ended (a promotion's pull-forward),
143
+ give an observed design's wave `switch_off` (the first day it was off) and set
144
+ `design.carryover_days`; carryover on an observed design is refused without it.
145
+ `switch_off` must not fall inside the post window (end `post_days` at it), and the
146
+ retrospective is refused until the carryover window's last day is over.
147
+ Use the real end date: a promotion stopped early but exported with its planned
148
+ end reads the wrong days.
149
+
150
+ A retrospective leaves out a unit with too little data, or listed with none,
151
+ and names it under the report's dropped units; it does not refuse the run. A
152
+ unit missing a few days keeps the rest and costs no other unit anything; one
153
+ under the coverage floor of a single wave's window is left out of that wave only.
154
+ `outcome.denominator` makes the outcome a per-unit share (`Σ target / Σ
155
+ denominator`): retrospective only, and pricing refuses it. `outcome.scale:
156
+ proportional` reads each value as `ln(1 + y)` and reports a % lift per unit
157
+ (`report.proportional`, the headline as a share, 0.12 = +12%): use it when units
158
+ differ in size by orders of magnitude. Retrospective only; refused with a
159
+ denominator, a driver or a switchback, and on a negative value. A denominator is
160
+ also refused with `design.one_date_test: permutation`, `design.strata`,
161
+ `design.carryover_days` or more than one switch date: the ratio is read on one
162
+ switch date with Welch's test. A proportional outcome's carryover is a share too.
163
+
164
+ An `anomaly` guardrail's `significance` picks the detector's band: `0.9545`
165
+ (±2σ; anything below `0.9973` reads as this), `0.9973` (±3σ) or `0.9999994`
166
+ (±5σ). It trips only on **two consecutive** flagged treated days at one unit.
167
+ `direction: increase | decrease | both` picks the side; absent, a guardrail on
168
+ `outcome.target` watches the side against `outcome.direction` and any other
169
+ measure both.
170
+
171
+ A change made in a few **chosen** units (a promotion on three products, a
172
+ campaign in one market) is better read against a synthetic control: on an
173
+ observed design set `design.comparison: synthetic_control`, and list in
174
+ `design.exclude` any unchanged unit the change may still have reached (sibling
175
+ products, neighbouring stores). Each treated unit gets its own weighted mix of
176
+ unchanged units that tracked it before the switch. It needs one switch date and
177
+ at least 10 donors, and is refused with a switchback, strata, a denominator,
178
+ carryover or hour grain. `report.synthetic` lists each unit's fit (`pre_fit`: 0
179
+ tracks perfectly, 1 is no better than a flat line), its donor weights and its
180
+ series; the report is labelled **Not randomised — synthetic control** and
181
+ offers no projection.
182
+
183
+ A one-date design is tested with Welch by default. For a handful of treated
184
+ units beside many untreated ones, set `design.one_date_test: permutation`: the
185
+ treated units are read against every untreated one, which Welch cannot do with
186
+ two or three of them. It needs enough units for a relabelling to reach alpha (3
187
+ vs 3 cannot), takes seconds, and is refused with several switch dates (always
188
+ permutation), a switchback, or a synthetic control.
189
+
190
+ With two or more waves, `report.waves` lists each wave's own effect and
191
+ interval. They are not adjusted for the number of waves: quote the pooled
192
+ headline as the answer, and a clear single wave as a lead, never a finding.
193
+
194
+ Both take the experiment's only run, both are irreversible, and both refuse
195
+ without `--yes` when stdin is not a terminal (exit 8). Confirm with the person
196
+ before passing `--yes` — say which design (`design <name>` prints its hash).
197
+
198
+ ## Watching, aborting, reporting
199
+
200
+ - `status` shows flip counts (`sent` overlaps `confirmed`/`unconfirmed`/`failed`),
201
+ failed flips by unit (a failed flip is resent after a backoff of 1h, doubling to
202
+ 8h: an `on` up to 3 attempts, an `off` until one lands), guardrail standing, compliance (not measured until a
203
+ treated flip is decided) and the estimate job. `NOT ADVANCING` means the
204
+ driver has not moved the run: that is a platform problem to report, not
205
+ something to fix from the CLI.
206
+ - `abort <name> --reason "<what the owner is told>"` with `--levers off`
207
+ (default, the UI's *Turn levers off*: switch treated units back off) or
208
+ `--levers keep` (*Keep levers as they are*). Ask the person which; it is
209
+ their call. It records a request; the next tick actuates it. An aborted run
210
+ cannot resume, its report is labelled ABORTED, and at hour grain only whole
211
+ days before the abort are measured.
212
+ - `result` before `reported` prints **sealed** and exits 0. There is
213
+ deliberately no final effect number on a live run — do not try to compute
214
+ one from `status` or from the warehouse. A finished run whose report is not
215
+ written yet prints *being prepared*.
216
+ - `interim <name>` is the registered analysis over the periods finished so
217
+ far, on a `live` or `closing` run only (a retrospective run has none). It is
218
+ read once a day while live; `--refresh` asks for a fresh one (members who can
219
+ price; one at a time per run) and `--wait` polls until it lands. It shows
220
+ *read through* the last period it read, *last attempt* when the newest try
221
+ failed (the previous reading stays), and nothing until a whole period of the
222
+ first after window has finished. A run not in progress prints its state and
223
+ exits 0.
224
+ - **An interim is a hint, not a result.** Its interval and p-value are the
225
+ registered fixed-horizon ones, correct only when read once at the end; read
226
+ daily, noise crosses the bar far more often. Say *so far* and *not final*
227
+ whenever you quote one, never call it significant, and never advise stopping
228
+ a run or rolling a change out because it looks good. Use it to catch
229
+ something plainly broken (an effect far outside plausible, in the wrong
230
+ direction) and to see data is flowing. It has no total, projection or
231
+ write-back, and it never moves a lever or changes the run.
232
+ - A report: state its `verdict` (not a bare "significant"), and repeat every
233
+ line under `assumptions` — a switchback's carryover and pull-forward
234
+ assumptions are part of the result.
235
+ - `write-back <name>` opens a branch writing the measured coefficient into the
236
+ World Model file. It needs the deployment that holds the workspace's working
237
+ copy (503 elsewhere); review the branch like any other change.
238
+
239
+ ## Branch on exit codes
240
+
241
+ `--json` on every verb returns the server's body. Exit codes are the `oxyc`
242
+ contract: 2 usage, 4 auth (or no assume session), 5 not found, 6 refused
243
+ request (409 stale hash or wrong state, 422 the design's own reason), 7
244
+ server/network, 8 an irreversible step not confirmed. The message is the
245
+ server's own sentence — quote it to the person rather than paraphrasing.
@@ -323,8 +323,8 @@ pre_aggregations:
323
323
  - Neither checks **cross-file** wiring — an entity join that matches nothing,
324
324
  a topic naming a view that does not exist, a measure that a twin lacks. Run
325
325
  a real query through the topic before calling it done.
326
- - **`oxy build` does not validate the semantic model** — it rebuilds search
327
- embeddings and syncs integrations. `oxy sync` writes table and column
326
+ - **`oxy build` does not validate the semantic model** — it does nothing any
327
+ more. `oxy sync` writes table and column
328
328
  metadata to `.databases/`, which is the place to read real column names
329
329
  from.
330
330
  - `inherits_from:` and `{{ globals.* }}` were removed from views; a file using