@oxy-hq/cli 0.12.1 → 0.13.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 (33) hide show
  1. package/README.md +605 -68
  2. package/dist/main.mjs +12125 -3088
  3. package/dist/main.mjs.map +1 -1
  4. package/dist/{mcp-CJWQm-yd.mjs → mcp-vlYd5Bms.mjs} +2 -2
  5. package/dist/{mcp-CJWQm-yd.mjs.map → mcp-vlYd5Bms.mjs.map} +1 -1
  6. package/json-schemas/agent-test.json +47 -2
  7. package/json-schemas/agentic.json +77 -0
  8. package/json-schemas/config.json +2 -1
  9. package/json-schemas/topic.json +252 -0
  10. package/json-schemas/view.json +473 -0
  11. package/package.json +2 -2
  12. package/skills/oxy-agents/SKILL.md +29 -26
  13. package/skills/oxy-agents/references/quick-reference.md +4 -6
  14. package/skills/oxy-agents/templates/agentic-template.yml +2 -1
  15. package/skills/oxy-airway-pipelines/SKILL.md +27 -2
  16. package/skills/oxy-automations/SKILL.md +42 -28
  17. package/skills/oxy-cli/SKILL.md +15 -7
  18. package/skills/oxy-custom-apps/SKILL.md +293 -7
  19. package/skills/oxy-custom-apps/references/app-calls.md +98 -0
  20. package/skills/oxy-custom-apps/references/phone-layout.md +16 -2
  21. package/skills/oxy-custom-apps/references/sandbox-agent-loop.md +8 -8
  22. package/skills/oxy-evals/SKILL.md +60 -36
  23. package/skills/oxy-evals/references/diagnosis.md +7 -5
  24. package/skills/oxy-evals/references/results-json.md +23 -15
  25. package/skills/oxy-evals/references/writing-expected.md +3 -2
  26. package/skills/oxy-experiments/SKILL.md +4 -3
  27. package/skills/oxy-semantic-modeling/SKILL.md +14 -12
  28. package/template/.claude/hooks/oxyc-cloud-session.sh +40 -8
  29. package/template/.github/workflows/publish.yaml +5 -5
  30. package/template/.github/workflows/validate.yaml +125 -199
  31. package/template/README.md +50 -21
  32. package/template/_gitignore +4 -4
  33. package/template/config.yml +2 -2
package/README.md CHANGED
@@ -13,6 +13,7 @@ manages customer workspace repos.
13
13
  - **Checks** — `checks run`
14
14
  - **Sandboxes** — `env`, `fn dev`, `fn call`, `invocations`, `logs`
15
15
  - **Workspace previews** — `preview`
16
+ - **The CI compile gate** — `compile`
16
17
  - **Development** — `validate`, `mcp`, `guide`, `skills`
17
18
 
18
19
  ## Install
@@ -57,8 +58,8 @@ and `cache`.
57
58
  | `--env <name\|url>` | `production` | deployment to target |
58
59
  | `--target <url>` | — | explicit base URL; overrides `--env` |
59
60
  | `--token-env <VAR>` | `OXY_TOKEN` | env var holding the bearer: any credential. **Named, it is the only source** — an unset variable is exit `4`, never a fallback to your login |
60
- | `--api-key-env <VAR>` | `OXY_API_KEY` | env var holding the legacy API key or API token for `/external/api` |
61
- | `--service-account <id>` | `OXY_SERVICE_ACCOUNT` | in GitHub Actions: the **ID** of the service account the OIDC exchange acts as |
61
+ | `--api-key-env <VAR>` | `OXY_API_KEY` | env var holding the API token for `/external/api` |
62
+ | `--service-account <id>` | `OXY_SERVICE_ACCOUNT` | in GitHub Actions, or with `OXY_OIDC_TOKEN_FILE`: the **ID** of the service account the trusted-access exchange acts as |
62
63
  | `--org <slug>` | — | value for the `{org}` placeholder |
63
64
  | `--workspace <id>` | — | value for the `{workspace}` placeholder |
64
65
  | `--project <id>` | — | value for the `{project}` placeholder |
@@ -121,8 +122,8 @@ the server.
121
122
 
122
123
  **Surfaces.** The path selects how the credential is sent. `/api/**` sends it
123
124
  as a bearer — whichever one [resolves](#authentication). `/external/api/**`
124
- sends `X-API-Key` from `$OXY_API_KEY`, which holds a legacy API key (`oxy_…`) or
125
- an API token (`oxy_pat_…`, `oxy_sat_…`, `oxy_ci_…`). With none set, an
125
+ sends `X-API-Key` from `$OXY_API_KEY`, which holds an API token (`oxy_pat_…`,
126
+ `oxy_sat_…`, `oxy_ci_…`). With none set, an
126
127
  `OXY_TOKEN` holding either of those stands in for it, so one `OXY_TOKEN` covers
127
128
  both surfaces. A session token never does.
128
129
 
@@ -180,9 +181,10 @@ oxyc logout # revoke the cached token, then forget it
180
181
  oxyc tokens list [--json] # your personal access tokens
181
182
  oxyc tokens revoke <id>
182
183
  oxyc tokens revoke --current # end the token in OXY_TOKEN
183
- oxyc tokens create # opens Account → Personal access tokens
184
+ oxyc tokens create # opens Settings → Organization → API tokens
184
185
  oxyc tokens create --sandbox-agent --app <org>/<app> [--app …] [--hours 8] [--name …] [--browser | --no-browser [--approver <email>]]
185
186
  oxyc tokens create --agent [--standing] [--hours 8] [--name …] [--browser | --no-browser [--approver <email>]]
187
+ oxyc tokens create --org-service-account <org>/<account> [--role member|admin] [--token-name …] [--expires-in-days 90] [--set-app-secret <org>/<app> --key <KEY> [--app-env production|staging]] [--browser | --no-browser [--approver <email>]]
186
188
  ```
187
189
 
188
190
  **An agent runs on its own token, never on the person's `oxyc login`.** Which
@@ -204,10 +206,12 @@ variable exits `4` instead of quietly running on the person's cached login.
204
206
  1. **`OXY_TOKEN`** (or the variable `--token-env` names). It holds any
205
207
  credential, and all are sent as a bearer: an API token — a personal access
206
208
  token (`oxy_pat_…`), a service account token (`oxy_sat_…`), a CI token
207
- (`oxy_ci_…`) or a sandbox agent token (`oxy_sbx_…`) — a legacy API key
208
- (`oxy_…`), a publish token, or a session token. A blank value counts as
209
+ (`oxy_ci_…`) or a sandbox agent token (`oxy_sbx_…`) — a publish token, or a
210
+ session token. A blank value counts as
209
211
  unset. An agent token is a personal access token by its prefix: only its
210
- own description tells it from a login (`oxyc whoami`).
212
+ own description tells it from a login (`oxyc whoami`). The value
213
+ `from-proxy` means the token is not on this machine at all: see
214
+ [A token the proxy adds](#a-token-the-proxy-adds).
211
215
  2. **The login cache** — what `oxyc login` stored for this deployment.
212
216
  3. **GitHub OIDC**, in a GitHub Actions job granted `id-token: write`: the job's
213
217
  OIDC token is exchanged, once per process, for a fifteen-minute token acting
@@ -223,15 +227,15 @@ machine. A person who wants `oxyc mcp` on their own login starts it with
223
227
  `--login`. `OXY_API_KEY` is unaffected: a command that can use one on its own
224
228
  (`checks run`, the sandbox verbs) still does.
225
229
 
226
- `OXY_API_KEY` holds a legacy API key or an API token, and is honoured where it
227
- always was — the `/external/api` surface, and `checks run`.
230
+ `OXY_API_KEY` holds an API token, and is honoured where it always was — the
231
+ `/external/api` surface, and `checks run`. The name is historical: it held a
232
+ legacy API key until those were removed.
228
233
 
229
- **Legacy API keys and API tokens are separate things.** A legacy API key is the
230
- older `oxy_…` key: it reaches everything its owner can and can't be limited to
231
- workspaces. It keeps working wherever it works today, but it is not a token —
232
- `oxyc tokens` never lists or revokes one, and `oxyc whoami` calls it a
233
- `Legacy API key`. They are extended and revoked in the web app, under
234
- Settings → Workspace → Legacy API keys. Use an API token for anything new.
234
+ **Legacy API keys were removed.** The older `oxy_…` key reached everything its
235
+ owner could and couldn't be limited to workspaces. A request carrying one is now
236
+ answered `401` naming its replacement, so if an integration of yours stopped
237
+ working, mint a token and set it where the key was — the header is the same.
238
+ `oxyc whoami` still calls one a `Legacy API key`, and adds that it was removed.
235
239
 
236
240
  **`login`** runs a browser loopback flow. Against a current deployment it
237
241
  receives a one-time code and exchanges it (PKCE) for a **personal access
@@ -250,8 +254,8 @@ it from this machine whatever the server said. It never touches `OXY_TOKEN`.
250
254
  rather than reading as fine from the cache. For a token it also prints what the
251
255
  token is and what it can reach — `all access`, or one line per grant with the
252
256
  role it is capped at, and any organization whose policy blocks it. For a legacy
253
- API key it prints `Legacy API key`, and that it reaches everything its owner
254
- can. For an agent token it says `agent token`, who approved it, whether it
257
+ API key it prints `Legacy API key`, and that legacy keys were removed. For an
258
+ agent token it says `agent token`, who approved it, whether it
255
259
  carries their staff or partner access, and when it expires. When a token in
256
260
  `OXY_TOKEN` is refused (exit `4`), the advice is never to log in — a login
257
261
  cannot replace what is in the variable. An agent stops and reports.
@@ -264,8 +268,10 @@ since the output is the token. It still expires in fifteen minutes.
264
268
  **`tokens`** manages personal access tokens, and the server allows that from a
265
269
  **browser session only**: a token that could list, mint or revoke tokens could
266
270
  outlive its own revocation. Since `login` now stores a token, `tokens list` and
267
- `tokens revoke` usually answer with a pointer to the web app (Account →
268
- Personal access tokens, `<deployment>/?settings=account.tokens`); they work
271
+ `tokens revoke` usually answer with a pointer to the web app (Settings →
272
+ Organization → API tokens → Personal access tokens,
273
+ `<deployment>/?settings=account.tokens`, an old link the web app still sends
274
+ there); they work
269
275
  from a login that stored a session token. `tokens create` always opens that
270
276
  page — a new token's secret is shown once, and a terminal is the wrong place.
271
277
 
@@ -339,8 +345,9 @@ is collected, refused or lapses (ten minutes). `--browser` skips it.
339
345
  anything else is a usage error, exit `2`) names who must approve, so nobody
340
346
  has to hand them a URL: the platform tells that person itself, by push,
341
347
  email and Slack DM where their organization connected it, and in their
342
- Oxygen inbox. They type the code from your output on the approval page. The
343
- notice never holds the code and links to `/cli-auth/device` without it, and
348
+ Oxygen inbox. The notice never holds the code, so hand them the link from
349
+ your output, which carries it (one click), or they type the code on the
350
+ approval page. The notice links to `/cli-auth/device` without it, and
344
351
  the request is then theirs alone: anyone else who finds the page is told
345
352
  there is no such request. `oxyc` prints `Approval request sent to <email>`
346
353
  beside the code and the URL; it prints that whether or not the deployment
@@ -412,6 +419,45 @@ must carry no standing that was not asked for. A deployment that predates agent
412
419
  tokens would otherwise hand back an ordinary ninety-day login. On any mismatch
413
420
  the command prints nothing, revokes what was minted, and exits `8`.
414
421
 
422
+ **`tokens create --org-service-account <org>/<account>`** mints a token
423
+ (`oxy_sat_…`) of an **organization's service account**: a credential that
424
+ belongs to the organization rather than a person, such as the one a custom
425
+ app's function holds to call that organization's admin routes. The account is
426
+ reused when the organization has one of that name, and created otherwise —
427
+ as a `member` unless `--role admin`. An existing account at another role is
428
+ refused, never changed. The token carries one grant over the whole organization
429
+ at the account's role, and lives `--expires-in-days` (default 90; the
430
+ organization's token policy may cap it).
431
+
432
+ ```bash
433
+ oxyc tokens create --org-service-account acme/store-ops-tablets --role admin \
434
+ --set-app-secret acme/store-ops --key TABLETS_API_KEY --env dev
435
+ ```
436
+
437
+ Creating an account or minting its token is browser-session-only on the server:
438
+ a token asking gets `403 session_required`, so a leaked one can never mint its
439
+ successor. So this is the same browser approval as `--agent`, and it is
440
+ approved by an **owner or admin of that organization** (or staff in an assume
441
+ session for it), on a page that first asks the server what approving would
442
+ create — the organization, the account (new or existing) and its role, the
443
+ token's name, lifetime and reach — and shows that.
444
+
445
+ Where the token goes:
446
+
447
+ - without `--set-app-secret`, stdout is the token and nothing else, printed once;
448
+ - with `--set-app-secret <org>/<app> --key <KEY>`, it is written straight into
449
+ that app's secret (`--app-env production`, the default, or `staging`) with
450
+ `POST /api/customer-apps/{id}/secrets`, on this machine's own `oxyc login`
451
+ (an owner or app admin), and **never printed**. The app is resolved before
452
+ the browser opens, and must be in the account's organization.
453
+
454
+ Never written to the credentials file. What comes back is checked first — a
455
+ whole `oxy_sat_`, described by the server as that account's token with one
456
+ org-wide grant at the asked role, expiring no later than asked — and on a
457
+ mismatch, or a secret that could not be stored, the token is revoked with
458
+ itself and nothing is printed. Not `--service-account`: that global flag names
459
+ the account a GitHub Actions run acts as.
460
+
415
461
  Credentials live in the OS config directory under **`oxy`** — the same file the
416
462
  Rust `oxy login` wrote before it was removed, so an existing login still works:
417
463
 
@@ -452,8 +498,8 @@ Stdout is the URL and nothing else; what the link is goes to stderr.
452
498
  and cannot manage tokens.
453
499
  - **It needs a personal access token** (`oxy_pat_…`) — what `oxyc login`
454
500
  stores. Any other credential is exit `4` with the next step: a session token
455
- from an older login, a service account, CI or publish token, a legacy API
456
- key. A sandbox agent token is exit `2`, before any request. A deployment that
501
+ from an older login, a service account, CI or publish token, or a removed
502
+ legacy API key. A sandbox agent token is exit `2`, before any request. A deployment that
457
503
  predates sign-in links is exit `5`.
458
504
  - **`--next <path>`** is where the browser lands: a path on the deployment
459
505
  starting with a single `/`. A URL, `//host` or a backslash is exit `2`, and
@@ -462,6 +508,40 @@ Stdout is the URL and nothing else; what the link is goes to stderr.
462
508
  **`--open`** also opens the link in your default browser — which uses it, so
463
509
  the printed URL will not work a second time.
464
510
 
511
+ ### A token the proxy adds
512
+
513
+ `OXY_TOKEN=from-proxy` says an egress proxy adds the credential to each
514
+ request on its way out, and `oxyc` sends none. Use it in a Claude Code cloud
515
+ environment whose Oxy token is a **network secret**: the token stays in
516
+ Anthropic's proxy, never in the VM, so neither the agent nor a log can read it.
517
+
518
+ 1. In the cloud environment's settings, add a network secret: **Allowed
519
+ websites** `app.oxygen-hq.com` (and `*.oxy.tech` for dev and staging),
520
+ header `Authorization`, prefix `Bearer`, value a personal access token or a
521
+ service account token.
522
+ 2. In its environment variables, set `OXY_TOKEN=from-proxy`. It is not a
523
+ secret.
524
+ 3. `oxyc whoami --env <env>` prints who the secret is, and a `via` line naming
525
+ the network secret.
526
+
527
+ What changes under the sentinel:
528
+
529
+ - **No `Authorization` and no `X-API-Key` is sent** by any command, and the
530
+ login cache and GitHub OIDC are not tried. A host the secret does not list
531
+ gets a request with no credential.
532
+ - **The token's kind is unknown here.** `oxyc` reads a kind off a token's
533
+ prefix to choose a path before it asks (a sandbox agent token's limits, a
534
+ service account's machine surface). Under `from-proxy` none of those apply,
535
+ and the deployment decides. `whoami` asks the server, so it still reports
536
+ the token; the sandbox loop needs its `oxy_sbx_` token in the variable.
537
+ - **A refusal names the secret, not `oxyc login`.** A 401 says to check the
538
+ secret's hosts, header and prefix, and that the token may have expired.
539
+ - **`tokens revoke --current` refuses.** It would end the secret's token for
540
+ every session in the environment; revoke it in the web app, then delete the
541
+ secret.
542
+ - A token minted into `~/.config/oxy/agent-token.env` (the cloud hook's file)
543
+ sets `OXY_TOKEN` before every command, so it replaces the sentinel.
544
+
465
545
  ### CI without a stored secret
466
546
 
467
547
  In a GitHub Actions job granted `id-token: write`, with no `OXY_TOKEN` set,
@@ -489,7 +569,7 @@ sign-in at all; use `OXY_TOKEN` there.
489
569
  What makes the deployment honour the job is a
490
570
  **trust policy** on that service account, naming the repository, the workflow
491
571
  file and the job's `environment:` — registered by `oxyc init-ci`, or in the web
492
- app under Organization settings → API access → Service accounts → *the
572
+ app under Settings → Organization → API tokens → Service accounts → *the
493
573
  account* → Trusted access.
494
574
 
495
575
  **The account is always named, never guessed.** Anyone can register a trust
@@ -506,8 +586,8 @@ same account name under it and register a policy on your repository's public
506
586
  ids. A workflow that said `acme/deployer` would then be naming *their*
507
587
  account. An ID never changes hands, so it is the only thing the deployment
508
588
  takes: anything else answers `400 service_account_required`, and `oxyc` does
509
- not fall back from that. The ID is shown in the web app (Organization settings
510
- → API access → Service accounts → *the account*), and `oxyc init-ci` writes it
589
+ not fall back from that. The ID is shown in the web app (Settings → Organization
590
+ → API tokens → Service accounts → *the account*), and `oxyc init-ci` writes it
511
591
  for you. `oxyc` passes the value through untouched; the answer still says
512
592
  `<org>/<name>`, so the log reads as it did.
513
593
 
@@ -548,6 +628,42 @@ in `publish` and `checks run`, which fall back to the app's registered
548
628
  publisher, as they also do on `no_matching_policy` and when no account is
549
629
  named.
550
630
 
631
+ ### A service on another platform without a stored secret
632
+
633
+ A service whose platform signs identity tokens for it — ferret on ECS, through
634
+ AWS IAM outbound identity federation — signs in the same way, with its own
635
+ token instead of GitHub's. Write a token requested for the audience
636
+ `oxy:<the deployment's host>` to a file, set `OXY_OIDC_TOKEN_FILE` to that file
637
+ and `OXY_SERVICE_ACCOUNT` to the account's ID; `oxyc` reads the file, posts it to
638
+ `/api/auth/oidc/exchange`, and uses the fifteen-minute `oxy_ci_…` token that
639
+ comes back. When both are set, the file wins over GitHub's variables.
640
+
641
+ ```sh
642
+ # On AWS: the workload's IAM role needs sts:GetWebIdentityToken. A regional
643
+ # STS endpoint, and RS256 (the signature Oxygen verifies).
644
+ aws sts get-web-identity-token \
645
+ --region "$AWS_REGION" --endpoint-url "https://sts.$AWS_REGION.amazonaws.com" \
646
+ --audience oxy:app.oxygen-hq.com --signing-algorithm RS256 --duration-seconds 300 \
647
+ --query WebIdentityToken --output text > /tmp/oxy-token
648
+
649
+ OXY_SERVICE_ACCOUNT=3f2504e0-4f89-41d3-9a0c-0305e82c3301 \
650
+ OXY_OIDC_TOKEN_FILE=/tmp/oxy-token \
651
+ oxyc api /api/orgs --target https://app.oxygen-hq.com
652
+ ```
653
+
654
+ An org admin registers the issuer, then a trust policy on the account saying
655
+ which of its tokens may act as it (Settings → Organization → API tokens →
656
+ Service accounts → Trusted access). For AWS that is the account's issuer URL and
657
+ the IAM role's ARN; the policy's menu shows these commands filled in. Any other
658
+ OIDC issuer works through **Custom OIDC**: its keys, and the claims a token must
659
+ have. The file is read again on each exchange, so whatever writes it picks the
660
+ token; an issuer registered as single use (the AWS preset is) refuses the same
661
+ token twice. A token must be asked for with a life of at most an hour.
662
+ Refusals name what to fix: `unknown_issuer` (the issuer is not registered in
663
+ the account's org), `replayed`, `token_lifetime_too_long`, `wrong_audience` (it
664
+ says which audience to ask for), `no_matching_policy` (no policy's conditions,
665
+ for AWS the role, match the token), `ambiguous_policy` (more than one does).
666
+
551
667
  ## Acting as an organization
552
668
 
553
669
  ```bash
@@ -575,10 +691,65 @@ oxyc oltp status [--org <slug|uuid|url>] [--json]
575
691
  oxyc oltp provision --org <slug|uuid|url> --writer app:<slug> [--writer pipeline:<source> …] [--yes] [--json]
576
692
  oxyc oltp provision --org <slug|uuid|url> --branch staging [--yes] [--json]
577
693
  oxyc oltp reset --org <slug|uuid|url> --branch staging [--yes] [--json]
694
+ oxyc oltp dsn --org <slug|uuid|url> [--role analyst|app:<slug>|pipeline:<source>] [--json]
695
+ oxyc oltp connect --org <slug|uuid|url> [--role analyst|app:<slug>|pipeline:<source>]
696
+ oxyc oltp expose --org <slug|uuid|url> --writer app:<slug>|pipeline:<source> [--revoke] [--json]
697
+ oxyc oltp deprovision --org <slug|uuid|url> [--writer app:<slug>|pipeline:<source>] --yes [--json]
698
+ oxyc oltp audit --org <slug|uuid|url> [--json]
699
+ oxyc oltp rotate --org <slug|uuid|url> --role app:<slug>|pipeline:<source> --yes [--json]
700
+ oxyc oltp apply --org <slug|uuid|url> [--workspace <id>] --yes [--json]
578
701
  ```
579
702
 
580
703
  `status` lists every org, with a database or without; with `--org` it shows
581
- that org's store and writers. No credential is ever printed.
704
+ that org's store and writers, and its Postgres major (`pg 17 (provisioning now
705
+ uses 18)` when a managed tenant differs from the default; `--json` carries
706
+ `pg_version`, `default_pg_version` and `pg_version_drift`). `status`, `provision` and `reset` never print a
707
+ credential.
708
+
709
+ `dsn` prints a connection string, bare on stdout so a script can capture it
710
+ (`--json` gives `{role, dsn, writable}`). `connect` runs the local `psql` with
711
+ it, passing the password in `PGPASSWORD` rather than on the command line, and
712
+ exits `1` if `psql` fails (`7` if `psql` is not installed). Both default to the
713
+ read-only `analyst`; a writer role is a live write credential to one schema.
714
+ Each disclosure is audited on the server. There is no `--role owner`: the
715
+ migration owner's credential is not handed out.
716
+
717
+ `expose` lets the read-only analyst read a writer's schema (`app_*` is hidden
718
+ by default, `raw_*` visible); `--revoke` withdraws it.
719
+
720
+ `deprovision --writer` drops one writer's schema, role and data and leaves the
721
+ rest of the database; without `--writer` it destroys the org's whole database
722
+ at the provider. Both are irreversible, so both print what they would destroy
723
+ and exit `8` unless `--yes` is given; there is no prompt. An org with no
724
+ database is a no-op that exits `0`.
725
+
726
+ `audit` reads every role in the org's database from `pg_roles` — whether it
727
+ is still confined (no `superuser`, `createdb`, `createrole`, `bypassrls`,
728
+ `replication`, and no membership) and what it can reach outside its own schema
729
+ — and exits `9` when it finds any violation, `--json` included (the report is
730
+ the server's, its verdict in `clean`). It opens a session as the owner, so it
731
+ wakes a suspended compute; a database that would not open one exits `7`.
732
+
733
+ `rotate` re-mints one writer's password, reseals it and re-asserts its
734
+ confinement. The old password stops working at once and the new one is never
735
+ shown (`--json` gives `{writer, role, schema}`), so it exits `8` without
736
+ `--yes`. Only writers rotate; the analyst and the owner are re-minted by
737
+ `provision`. Both are audited on the server, and both replaced the Rust `oxy
738
+ oltp audit | rotate`, whose blanket exit `1` is now `9` / `8` / the table's.
739
+
740
+ `apply` runs the workspace's compiled `schemas/*.sql` that the org's database
741
+ has not run, as its owner, then re-grants every writer over its schema (so it
742
+ also repairs `permission denied for table`). It reads the workspace's newest
743
+ successful compile on the server, never a checkout; `--workspace` names it when
744
+ the org has more than one (otherwise exit `6`). DDL is not undone, so it exits
745
+ `8` without `--yes` and sends nothing. A migration that fails exits `9`,
746
+ `--json` included (the server's body: `applied`, `already_applied`, `failed`,
747
+ `ok`; `applied` names the files this call committed before the failure, which
748
+ stay applied). Another apply holding the org's lock exits `7`, and so does an
749
+ apply the server cut off after 50 seconds (`timed_out: true`, with `applied`
750
+ naming what landed): a re-run resumes at the first file the database has not
751
+ run. It is audited on the server (a row before the DDL and
752
+ one after), and replaced the Rust `oxy oltp apply`.
582
753
 
583
754
  `provision` prints what it will create and asks first, because it calls a paid
584
755
  provider; without a terminal it refuses unless `--yes`. It is idempotent — an
@@ -600,14 +771,15 @@ without a terminal).
600
771
  ## Airhouse tenants
601
772
 
602
773
  Staff can see a workspace's Airhouse tenant — the warehouse behind
603
- `ctx.airhouse` and `type: airhouse_managed` — and repair it, without the admin
604
- console. The server provisions a workspace's tenant itself; `provision` is the
774
+ `ctx.airhouse` and `type: airhouse_managed` — repair it, and rotate its
775
+ service account, without the admin console or a database URL. The server provisions a workspace's tenant itself; `provision` is the
605
776
  repair and backfill tool, for a workspace that predates that or whose tenant or
606
777
  service account did not come up.
607
778
 
608
779
  ```bash
609
780
  oxyc airhouse status [--workspace <id>] [--json]
610
781
  oxyc airhouse provision --workspace <id> [--yes] [--json]
782
+ oxyc airhouse rotate-sa --workspace <id> --yes [--json]
611
783
  ```
612
784
 
613
785
  `status` lists every workspace, with a tenant or without; with `--workspace` it
@@ -624,10 +796,226 @@ workspace's UUID. A 404 can be a workspace outside your staff grant's scope, a
624
796
  503 is a deployment with no Airhouse configured, and an active `assume` session
625
797
  closes `/admin`.
626
798
 
799
+ `rotate-sa` is the response to a suspected bearer leak: it revokes the
800
+ workspace's service account at Airhouse and mints a fresh one under the same
801
+ name. The old account stops working at once (credentials already minted under
802
+ it last until they expire, 24h at most), so it always needs `--yes`, terminal
803
+ or not, and exits `8` without it after printing what it would revoke. `--json`
804
+ prints `{ workspace_id, old_sa_id, new_sa_id, rotated_at }`; the new bearer is
805
+ never shown. 404 is no workspace, no tenant, or one outside your grant; 409 is
806
+ a tenant with no service account (provision first); a 502 may have revoked the
807
+ old account without binding a new one, so run it again (the revoke is
808
+ idempotent). It replaced the Rust `oxy admin airhouse rotate-sa`.
809
+
810
+ ## Evals
811
+
812
+ Run a workspace's `.test.yml` evals (LLM-judged, over its `.agentic.yml`
813
+ agents) on a deployment: the counterpart of `oxy test`, which runs them on a
814
+ local checkout.
815
+
816
+ ```bash
817
+ oxyc evals run [<file>.test.yml] --workspace <id> [--case <c>] [--tag <t>] [--regrade <results.json>] [--min-accuracy N] [--threshold-mode average|all] [--wait [s]] [--detach] [--json] [--output-json [file]]
818
+ oxyc evals wait <run_id> --workspace <id> [--min-accuracy N] [--threshold-mode average|all] [--wait [s]] [--json] [--output-json [file]]
819
+ ```
820
+
821
+ `run` queues the eval for the deployment's worker fleet
822
+ (`POST /api/{workspace_id}/evals/runs`) and polls it to the end. The deployment
823
+ runs the test files and agents the workspace has **compiled**, so push a new or
824
+ edited test file first (a file it has not compiled answers exit `5`). With no
825
+ file it runs every compiled test file. `--json` prints the results document and
826
+ `--output-json` writes it — byte for byte what `oxy test --output-json` wrote,
827
+ to the same default path (`<file>.results.json`, or `test-results.json`).
828
+ `--min-accuracy` exits `9` when the average (or, with `--threshold-mode all`,
829
+ any test file's) accuracy is below it; a failed, cancelled or timed-out run
830
+ exits `1`; `--wait <s>` gives up after `s` seconds with exit `7` while the run
831
+ goes on. `--detach` prints the run id; `wait <run_id>` reports it later.
832
+
833
+ ## Airway pipelines
834
+
835
+ Run, backfill and inspect a workspace's airway ELT pipelines on a deployment,
836
+ and recover a pipeline whose single-flight lease is stuck. These replaced the
837
+ Rust `oxy airway` (deleted 2026-11-21), which ran pipelines from a local file
838
+ with the database URL.
839
+
840
+ ```bash
841
+ oxyc airway run <pipeline_ref> --workspace <id> [--resources a,b] [--variables <json|@file|->] [--detach] [--json]
842
+ oxyc airway backfill <pipeline_ref> --workspace <id> --from <rfc3339> --to <rfc3339> [--granularity month|week|day] [--resources a,b] [--wait <s>] [--json]
843
+ oxyc airway backfill --resume <range_id> --workspace <id> [--wait <s>] [--json]
844
+ oxyc airway coverage <pipeline_ref> --workspace <id> [--json]
845
+ oxyc airway coverage --range <range_id> --workspace <id> [--json]
846
+ oxyc airway leases --workspace <id> [--json]
847
+ oxyc airway release-lease <pipeline_name> --workspace <id> [--yes | --force] [--json]
848
+ ```
849
+
850
+ `run` starts the pipeline the deployment has **compiled** for the workspace's
851
+ served revision — queued for the worker fleet, never a `.airway.yml` on your
852
+ machine — then streams its events until a terminal one, and exits with the run
853
+ row's outcome: `0` done (a partial failure included), `1` failed, cancelled or
854
+ timed out. `--json` prints one `{seq, event_type, payload}` object per event
855
+ (the server adds `attempt` to each payload). Nothing from your shell's
856
+ environment is sent: a pipeline's `{{ VAR }}` templates render from
857
+ `--variables` only, which is stored with the run — credentials go through
858
+ `*_var` keys and the workspace's secrets. A backfill takes no variables.
859
+ Ctrl-C stops watching, not the run. To
860
+ try an unmerged edit, push a branch and use `oxyc preview run <branch>
861
+ airway_sample <ref>`. A pipeline already running answers `409` (exit `6`); a
862
+ ref the served revision does not have yet answers `503` (exit `7`).
863
+
864
+ `backfill` records a range of `[from, to)` split into chunks and queues its
865
+ drive, then returns; `--wait` polls the range until it settles and exits `1`
866
+ if chunks were left not done. Each call is a new range; `--resume <range_id>`
867
+ re-drives a range's not-done chunks (an unfinished range for the same window
868
+ is named before a new one is started). `coverage <ref>` lists the pipeline's
869
+ ranges; `--range` shows one range's missing periods.
870
+
871
+ `leases` lists what holds each pipeline, flagging lapsed rows (which block
872
+ nothing). `release-lease` takes the pipeline's NAME as `leases` prints it,
873
+ shows the holder and asks first; with no terminal it refuses (exit `8`) unless
874
+ `--yes` (release the holder it just listed, and only that run) or `--force`
875
+ (release whatever holds it). If the holder changed before the delete, nothing
876
+ is released and it exits `6` naming who holds it now. Both need a workspace
877
+ admin; staff act inside a tenant through `oxyc assume`.
878
+
879
+ ## Agentic agents
880
+
881
+ Ask a workspace's agentic agent a question on a deployment, follow and steer
882
+ its run, and read the workspace's runs. These replaced the Rust `oxy agentic`
883
+ (a one-release stub since 2026-11-24 that prints the `oxyc` command and exits
884
+ `2`), which ran a `.agentic.yml` from a local checkout with the database URL
885
+ and the LLM keys in your shell.
886
+
887
+ ```bash
888
+ oxyc agentic run <agent> -q <question> --workspace <id> [--thinking-mode auto|extended_thinking] [--json]
889
+ oxyc agentic events <run_id> --workspace <id> [--after-seq <n>] [--json]
890
+ oxyc agentic answer <run_id> --answer <text> --workspace <id>
891
+ oxyc agentic cancel <run_id> --workspace <id>
892
+ oxyc agentic list --workspace <id> [--limit <n>] [--json]
893
+ oxyc agentic inspect <run_id> --workspace <id> [--json]
894
+ oxyc agentic status --workspace <id> [--active] [--watch <s>] [--json]
895
+ ```
896
+
897
+ `run` starts the agent the deployment has **compiled** for the workspace's
898
+ served revision (`POST …/analytics/runs`, the chat's route), with the
899
+ workspace's own secrets and LLM keys — never a file on your machine, so push a
900
+ change before running it. `<agent>` is the agent's path inside the workspace
901
+ (`agents/sales.agentic.yml`, or `agents/sales`). Each run is a chat: it opens a
902
+ thread in your history, as the web app does. It streams the run's events
903
+ (`GET …/runs/{id}/events`) until `done` (exit `0`), `error` or `cancelled`
904
+ (exit `1`; the Rust command exited `0`), or a question: a run that stops to ask
905
+ something is suspended, and `run` exits `0` once the stream has been quiet for
906
+ a moment after it, naming `oxyc agentic answer`. `--json` prints the Rust
907
+ command's lines, one compact `{"seq","event_type","payload"}` object per event,
908
+ with three additions from the route: `attempt` in each payload, a
909
+ `recovery_resumed` event when the run was re-driven after a restart, and a
910
+ terminal event built from the run row when the run ended without one. A start
911
+ the agent cannot make answers `400` (exit `6`); a workspace not compiled yet
912
+ `503` (exit `7`).
913
+
914
+ `events` replays a run (from `--after-seq`), and follows it when it is still
915
+ going; it exits `0` whatever the run did. `answer` delivers the text and the run
916
+ resumes on the deployment (the Rust command only marked the row running); a run
917
+ not waiting for one is exit `6`. `cancel` asks the run's driver to stop.
918
+
919
+ `list`, `inspect` and `status` read the Orchestrator Dashboard
920
+ (`…/analytics/coordinator/{runs, active-runs, runs/{id}/tree}`), an Oxygen
921
+ Nexus surface: org owners and admins, Oxy staff, and members Oxy granted the
922
+ workspace; anyone else is `403 factory_access_required` (exit `4`). Their
923
+ `--json` keeps the Rust keys the routes carry: `list` is
924
+ `[{run_id, status, source_type, question, created_at}]`; `inspect` drops
925
+ `metadata`, `event_count` and `extension` and adds `agent_id`, `task_status`,
926
+ `attempt`, `trigger` and `llm_usage`; `status` drops `event_count` and adds
927
+ `task_status`. Timestamps are RFC 3339. `status` reads one run tree per listed
928
+ run, so it expands at most 20 runs, four at a time, and `--watch` refreshes no
929
+ faster than every 2 s.
930
+
931
+ ## Running SQL and automations
932
+
933
+ Run a `.sql` file or an automation on a deployment. It replaced the Rust
934
+ `oxy run` (2026-11-24), which now prints this command and exits `2` for one
935
+ release.
936
+
937
+ ```bash
938
+ oxyc run <file.sql> [--database <name>] [-v KEY=VALUE ...] [--json] --workspace <id>
939
+ oxyc run <file.automation.yml> [-v KEY=VALUE ...] [--json] [--detach] [--timeout <s>] --workspace <id>
940
+ ```
941
+
942
+ A SQL file's text is read here and sent to `POST /api/{workspace_id}/sql/query`;
943
+ it runs against the **deployed** database of that name, with the workspace's
944
+ secrets and your identity. `--database` is checked against
945
+ `GET …/databases` (unknown: exit `5`) and may be left out only when the
946
+ workspace has one database. `-v` renders the file's `{{ name }}` placeholders,
947
+ and only when given; any other Jinja, or a placeholder with no value, exits `2`
948
+ and sends nothing. The output is a table; `--json` prints the route's rows
949
+ (arrays of strings, header row first). The route stops at 10,000 rows, and
950
+ `oxyc` warns when a result reaches that.
951
+
952
+ An automation runs the definition the deployment has **compiled** for its
953
+ served revision, on the worker fleet, not the file here: push it first, or try
954
+ a branch with `oxyc preview run <branch> procedure <ref>`. The file's path from
955
+ the checkout root (the nearest directory above it holding `config.yml`) is its
956
+ ref. `oxyc` reads the deployed definition first (`404` exits `5`), starts the
957
+ run with `-v` as its `variables`, and polls it until it ends; `done` prints
958
+ `✓ <file>` and each task's result in task order, `--json` the final snapshot,
959
+ `--detach` just the run id. Exit `1` a run that failed, was cancelled or timed
960
+ out, or `--timeout` (default 3600s) ran out with the run still going (re-running
961
+ would start a second run; a failed status read is retried meanwhile), `4` not
962
+ signed in or not a member, `6` a failed query, `7` retryable, before anything
963
+ started. `--dry-run`, `--retry` and `--retry-from`
964
+ did not come across.
965
+
966
+ ## Database schema sync
967
+
968
+ Write a workspace's `.databases/` schema files (each dataset's DDL and one
969
+ `<table>.schema.yml` per table) into your checkout. The server introspects the
970
+ warehouses the **deployed** `config.yml` names, with the workspace's secrets,
971
+ and renders the files; `oxyc` writes them. It replaced the Rust `oxy sync`
972
+ (2026-11-21), which now prints this command and exits `2` for one release.
973
+
974
+ ```bash
975
+ oxyc sync [database] --workspace <id> [-d <dataset>]... [--tables <schema.table>]... [-o] [--dry-run] [--dir <checkout>] [--json]
976
+ ```
977
+
978
+ Run it from the checkout's root (or pass `--dir`). Each request renders one
979
+ database (`POST /api/{workspace_id}/databases/sync` → `[{ path, content }]`);
980
+ with no database named, `oxyc` lists them and asks for each, so one failure
981
+ does not stop the rest, and a type sync cannot introspect (`airhouse_managed`,
982
+ `airhouse`, `mysql`) is skipped with a warning. An existing file is skipped
983
+ unless `-o`/`--overwrite`, which also prunes a stale file from each `models/`
984
+ directory it writes (never the database directory); with `--tables`,
985
+ `--overwrite` replaces only those tables' models, prunes nothing and keeps an
986
+ existing dataset `.sql`. `--dry-run` prints the
987
+ plan and writes nothing; `--json` prints `{dry_run, databases, files}`. Every
988
+ path is checked before anything is written: one outside `.databases/` in the
989
+ checkout, symlinks included, exits `8` and writes nothing. Exit `4` not signed
990
+ in or not a workspace admin, `5` no such database, `6` it cannot connect as
991
+ configured (or, named, cannot be synced), `7` the warehouse failed or the
992
+ sync outlasted the server's limit (narrow it with `-d`).
993
+
994
+ ## Looker integrations
995
+
996
+ Check a Looker integration's credentials on a deployment. This replaced the
997
+ Rust `oxy looker test` (a one-release stub since 2026-11-21), which read
998
+ `config.yml` from a checkout and the credentials from your shell.
999
+
1000
+ ```bash
1001
+ oxyc looker test <name> --workspace <id> [--json]
1002
+ ```
1003
+
1004
+ The server checks what it serves: the integration from the workspace's
1005
+ compiled `config.yml`, the client ID and secret from the workspace's secrets.
1006
+ It signs in to Looker and lists the LookML models, and prints the first five.
1007
+ One integration per call. A check that ran answers `200` with its verdict, and
1008
+ a failed one exits `9`, naming the stage: `resolve` (a secret is missing),
1009
+ `client`, `auth` (Looker refused the credentials), `connect` or `timeout`
1010
+ (`base_url` did not answer). `--json` prints
1011
+ `{ ok, stage, error, integration, base_url, models: [{ name, explores }], elapsed_ms }`,
1012
+ on a failure too. `5` is no Looker integration by that name; `4` is a caller
1013
+ who is not a workspace admin (staff act inside a tenant through `oxyc assume`).
1014
+
627
1015
  ## Feature flags
628
1016
 
629
- Staff-only control of the flags Oxy declares in code
630
- (`crates/app/src/server/feature_flags/registry.rs`): the kill switch and the
1017
+ Staff-only control of the flags Oxy declares in its server code (the
1018
+ registry `GET /api/admin/feature-flags` lists): the kill switch and the
631
1019
  targeting rules — per-org / per-user overrides plus a weighted fallthrough for
632
1020
  A/B splits. Flags are not created at runtime. **Every write hits the
633
1021
  deployment `--env` names (production by default) and takes effect for real
@@ -687,7 +1075,6 @@ oxyc experiments status <name> # flips, guardrails, complian
687
1075
  oxyc experiments abort <name> --reason <text> [--levers off|keep] [--yes]
688
1076
  oxyc experiments interim <name> [--refresh [--wait]] # the reading so far, badged not final
689
1077
  oxyc experiments result <name> # sealed until reported
690
- oxyc experiments write-back <name> # branch writing the coefficient back
691
1078
  ```
692
1079
 
693
1080
  A candidate is one design to price, tagged by `shape`:
@@ -709,8 +1096,8 @@ prints that it is sealed and exits 0: there is deliberately no effect number
709
1096
  before `reported`. `interim` is the registered analysis over the periods
710
1097
  finished so far on a live or closing run, labelled not final (its interval is
711
1098
  the fixed-horizon one, so reading it early overstates confidence); `--refresh`
712
- asks for a fresh one and a run not in progress exits 0 with its state. `write-back` needs the deployment that holds the
713
- workspace's working copy. Staff reach a tenant workspace only inside an
1099
+ asks for a fresh one and a run not in progress exits 0 with its state. A proposed coefficient
1100
+ (`write_back` in the result) is applied by editing the workspace's repository and pushing. Staff reach a tenant workspace only inside an
714
1101
  `oxyc assume` session.
715
1102
 
716
1103
  ## Home layout
@@ -867,7 +1254,7 @@ oxyc bootstrap verify poke-house --env dev --json \
867
1254
  oxyc publish [--env <e>] [--dir <path>] [--promote] [--build-only | --prebuilt] [--json] [--allow-function-lint] [--app-env <dev-handle>]
868
1255
  oxyc promote <app> [--from staging|dev-<handle>] [--build <id>] [--remove-schedule <fn>]… [--dry-run] [--yes] [--json]
869
1256
  oxyc rollback <app> --app-env staging|production [--to <build>] [--remove-schedule <fn>]… [--dry-run] [--yes] [--json]
870
- oxyc init-ci [--app <org>/<app>] [--environment <name>] [--promote] [--force] [--no-register] [--setup-action]
1257
+ oxyc init-ci [--app <org>/<app>] [--environment <name>] [--promote] [--force] [--no-register] [--setup-action] [--browser | --no-browser [--approver <email>] [--no-wait]]
871
1258
  oxyc proxy [--app <org>/<app> --app-env staging|dev-<handle>] [--port <n>] [--allow-writes] [--allow-events] [--yes]
872
1259
  ```
873
1260
 
@@ -878,7 +1265,12 @@ the target's public `build-config`, and uploads the bundle — to the **draft**
878
1265
  channel (staging). `--env` defaults to **production**; name it. Ship it with
879
1266
  `oxyc promote`, below. `--promote` still publishes and promotes in one request,
880
1267
  through the same server-side path, and the server answers it with a
881
- deprecation warning: it shows nobody the plan.
1268
+ deprecation warning: it shows nobody the plan. It meets the blockers `oxyc
1269
+ promote` meets — confirm each production schedule it retires with
1270
+ `--remove-schedule <function>` — and a blocker refuses the whole publish
1271
+ (exit `6`, each blocker named with what to do): nothing lands, staging
1272
+ included. With the app's second-person rule on, `--promote` is always refused:
1273
+ publish to staging and have someone else promote.
882
1274
 
883
1275
  - **The manifest** is read strictly: `oxy-app.json` is validated against the
884
1276
  JSON Schema `@oxy-hq/sdk` generates from its `OxyAppManifest` type (the same
@@ -960,7 +1352,9 @@ person, and writes the ID into the workflow with the name beside it as a
960
1352
  comment (`OXY_SERVICE_ACCOUNT: 3f25…3301 # acme/deployer`). When it cannot
961
1353
  look the ID up — nobody logged in, no such account yet — it writes a
962
1354
  `<service-account-id>` placeholder and says so; it never writes the name as
963
- the value. `--promote` makes the publish go live. **No `checks run` step is
1355
+ the value. A `--force` re-run that cannot look it up (a member may not list
1356
+ the org's accounts) keeps the ID the existing workflow already names for that
1357
+ same account instead. `--promote` makes the publish go live. **No `checks run` step is
964
1358
  written**, even when the manifest declares a check: the job's service-account
965
1359
  token is answered `403` on the check routes, which sit behind platform gates a
966
1360
  service account never passes, so the step could not succeed. The workflow
@@ -973,21 +1367,41 @@ says so when it writes one.
973
1367
 
974
1368
  *The registration* is a trust policy on that service account — this repository,
975
1369
  the workflow file, the environment — granted publishing this one app and
976
- nothing else. `init-ci` creates the `deployer` account if none was named and it
977
- does not exist, then the policy, and is idempotent: a second run finds both. A
978
- named account is never created, and must be one of the app's own org — an
979
- account's grants never reach another org, so `init-ci` refuses one. A service
980
- account's name is lowercase words joined by single hyphens, starting with a
981
- letter, 2–40 characters.
982
-
983
- It can only register **when the caller can**: an org admin, logged in with a
984
- browser-session credential — the server refuses those two creations to a token,
985
- which is what a fresh `oxyc login` stores. When it cannot (not an admin, a token
986
- login, offline, a deployment without trusted access, `--no-register`), the
987
- workflow is still written and the command prints the exact steps instead: where
988
- in the web app, the `oxyc api` calls with every id it managed to learn filled
989
- in, and the older `…/publishers` registration for a deployment without trust
990
- policies. Registration never fails the command.
1370
+ nothing else. When the account (the `deployer` account if none was named) or
1371
+ the policy is missing, **an owner or admin of the org approves both once**, in
1372
+ the browser or by device code (`--no-browser`, `--approver <email>`): the same
1373
+ `/cli-auth` approval `tokens create` uses, for a `trust_policy`. The page shows
1374
+ the org, the account (new or existing), the repository as GitHub names it, the
1375
+ workflow, the environment and the one app it may publish, and the deployment
1376
+ writes them **at the approval**, under the approver's session. **Nothing is
1377
+ minted**: the CLI collects only what was written, and the account's ID goes
1378
+ into the workflow. The person running `init-ci` need not be an admin: when it
1379
+ may not list the org's apps or accounts it names the app by slug, and the
1380
+ approver's deployment resolves it.
1381
+
1382
+ **With no one waiting at the terminal** — an agent in a Claude Code remote
1383
+ session, a remote box — `--no-wait` (the default under `CLAUDE_CODE_REMOTE`)
1384
+ asks, prints the link, writes the workflow with a placeholder and exits; add
1385
+ `--approver <email>` and the admin is told by push, email and Slack. A later
1386
+ `oxyc init-ci --force` collects the answer (with `--no-wait`, it checks once and
1387
+ says if it is still waiting) and writes the account's ID. Because the approval
1388
+ itself writes the rows, an answer nobody collects is not lost: a run that may
1389
+ read the org's accounts finds them and asks nobody.
1390
+
1391
+ It is idempotent: a run that finds both in place asks nobody, and the deployment
1392
+ reuses what is already there. A named account is never created, and must be
1393
+ one of the app's own org — an account's grants never reach another org, so
1394
+ `init-ci` refuses one. A service account's name is lowercase words joined by
1395
+ single hyphens, starting with a letter, 2–40 characters.
1396
+
1397
+ Creating either row is still browser-session-only on the server: `init-ci`
1398
+ never calls those routes with its token. When no approval can happen (declined,
1399
+ a CI runner with nobody to approve, offline, a deployment that predates it,
1400
+ `--no-register`), the workflow is still written and the command prints the
1401
+ exact steps instead: re-running where a browser can open, where in the web app,
1402
+ the `oxyc api` calls with every id it managed to learn filled in, and the older
1403
+ `…/publishers` registration for a deployment without trust policies.
1404
+ Registration never fails the command.
991
1405
 
992
1406
  **`--app-env <dev-handle>`** moves one sandbox's build pointer instead of the
993
1407
  draft/live channel — see [Sandboxes](#sandboxes). It needs a staff credential
@@ -1007,8 +1421,10 @@ sending the plan's build and `expect_current` back — `409 target_moved` if the
1007
1421
  target moved in between. `--dry-run` stops at the plan. A plan with blockers is
1008
1422
  refused before any act (exit `6`): `staging_never_served` (production only
1009
1423
  serves a build staging has served), `validation_not_passed`,
1010
- `required_secrets_unset`, and `schedule_removal_unconfirmed` — name each retired
1011
- schedule with `--remove-schedule <function>`. `--build` names an older build the
1424
+ `required_secrets_unset`, `schedule_removal_unconfirmed` — name each retired
1425
+ schedule with `--remove-schedule <function>` — and `same_person_promote` (the
1426
+ app requires a second person to promote, and you published the build; a
1427
+ rollback to a build production served before is exempt). `--build` names an older build the
1012
1428
  source served (publish id or UUID). Promoting the build already served is
1013
1429
  `409 already_serving`.
1014
1430
 
@@ -1023,6 +1439,43 @@ Both need a staff credential: a publish token, a service account's and a sandbox
1023
1439
  agent token are refused before any request (exit `2`). `--json` prints the
1024
1440
  server's plan verbatim.
1025
1441
 
1442
+ ## App events
1443
+
1444
+ ```bash
1445
+ oxyc events ls [org] [--json]
1446
+ oxyc events show <event-id> [--chain] [--json]
1447
+ oxyc events find <type> --key <key> [--app-env <env>] [--json]
1448
+ oxyc events tail <org>/<app> [--app-env <env>] [--json]
1449
+ oxyc events dead <org>/<app> [--app-env <env>] [--json]
1450
+ oxyc events redeliver [<event-id>] [--to <app>/<fn> --status dead|expired|held [--since <t>]] [--dry-run] [--json]
1451
+ oxyc events replay <type> --since <t> [--until <t>] --to <app>/<fn> [--app-env <env>] [--dry-run] [--json]
1452
+ oxyc events resync <org>/<app> <function> [--app-env <env>] [--backfill] [--dry-run] [--json]
1453
+ oxyc events discard --until <t> [--type <type>] [--to <app>/<fn>] [--yes] [--json]
1454
+ oxyc events purge <type> [--key <key>] [--before <t>] [--yes] [--json]
1455
+ ```
1456
+
1457
+ Staff commands over an org's app events (the org's `app_events` flag).
1458
+
1459
+ **`ls`** lists every event type with its publisher and each listener's health,
1460
+ stuck ones first. A second block, **Table subscriptions**, lists each function
1461
+ that runs on a table (`on: { "table": "<database>:<schema>.<table>" }`): the
1462
+ table, listener, environment, state (`active`, `BEHIND HORIZON`, `BROKEN` or
1463
+ `PAUSED`), the cursor (the last snapshot delivered), the table's newest snapshot,
1464
+ the lag in snapshots, and, for a state that needs a person, why. `--json` prints
1465
+ the server's reply, with the same rows as `tables`; an older server has none.
1466
+
1467
+ **`resync`** is the way out of every table state. It moves each table the
1468
+ function watches in `--app-env` (default production) to the newest snapshot, so
1469
+ what changed meanwhile is **skipped, not replayed**; it clears `behind_horizon`
1470
+ (the cursor's next snapshot was expired), `broken` (a column of the table was
1471
+ removed, renamed or retyped) and `paused` (the circuit breaker stopped a
1472
+ subscription that ran above a sustained rate). `--backfill` then runs the
1473
+ function once with an event whose `data.backfill` is `true` and which carries no
1474
+ rows, so it can re-derive what it keeps from the whole table. `--dry-run` prints
1475
+ where each cursor would move and changes nothing. It also forgets the columns
1476
+ the watch held as its contract, so a column removed on purpose stops being a
1477
+ break. Audited.
1478
+
1026
1479
  ## Apps
1027
1480
 
1028
1481
  Read-only except `domains add | verify | remove`: every other request these make
@@ -1217,7 +1670,7 @@ trust policy first, the app's registered publisher second — and drives
1217
1670
  `/api/customer-apps/**`, the same three routes a person's credential uses. A
1218
1671
  service account's token (`oxy_sat_…`, `oxy_ci_…`) or a publish token set in
1219
1672
  `OXY_TOKEN` is used without minting. What differs is the app lookup: a
1220
- personal token, a legacy API key or a session can list apps to resolve
1673
+ personal token or a session can list apps to resolve
1221
1674
  `<org>/<app>`; a machine credential may not, so it names the app by UUID or
1222
1675
  through its own grants. `OXY_API_KEY` is read **before** OIDC here: a job that set one has said
1223
1676
  which credential it means.
@@ -1264,7 +1717,8 @@ it) but does need `<org-slug>/<app-slug>`, since it is registered by slug.
1264
1717
  **Exit codes:** `0` every check passed; `9` (`CHECK_FAILED`) at least one check
1265
1718
  failed or timed out; `1` the app declares no checks; `5` the app was not
1266
1719
  found; `4` no credential resolved, or the API rejected it (401/403 — an
1267
- expired legacy API key or API token reads this way, not as a missing one); `2` a bad
1720
+ expired API token, or a removed legacy API key, reads this way, not as a
1721
+ missing one); `2` a bad
1268
1722
  `--timeout`, or a slug where the credential needs a UUID; `7` (`UNAVAILABLE`)
1269
1723
  the deployment answered the OIDC exchange without an `app_id`, meaning it
1270
1724
  predates trusted checks.
@@ -1290,6 +1744,8 @@ oxyc fn run <app> <function> [--app-env <name>] [--as-schedule] [--data …] [--
1290
1744
  oxyc checks run <app> --app-env <name> # see "Checks" above
1291
1745
 
1292
1746
  oxyc invocations list <app> [--app-env] [--build] [--function] [--limit]
1747
+ # an invocation another app's call started (mode `call`)
1748
+ # prints `parent <id>`; --json carries `parent_invocation_id`
1293
1749
  oxyc invocations held <app> <invocation-id>
1294
1750
  oxyc logs <app> [--app-env] [--invocation] [--request] [--hours] [--limit]
1295
1751
  oxyc logs <app> [--app-env <name>] --follow [--timeout <seconds>] [--json]
@@ -1532,10 +1988,39 @@ is: the server's own `code` rides along on the thrown error, and the exit
1532
1988
  class follows the usual HTTP-status mapping (`400`/`409` → `6`, `404` → `5`).
1533
1989
  Full contract: `internal-docs/workspace-previews.md`.
1534
1990
 
1991
+ ## The CI compile gate
1992
+
1993
+ ```bash
1994
+ oxyc compile <branch> --workspace <id> [--wait] [--timeout <s>] [--json]
1995
+ ```
1996
+
1997
+ Asks the deployment to compile `<branch>` of the workspace — the commit GitHub
1998
+ has for it, as the workspace's registered subdirectory — into a **staging**
1999
+ revision, which is never promoted, and with `--wait` polls until it is `ready`
2000
+ or `failed`. It is the customer repo's `validate.yaml` gate, and replaced the
2001
+ `oxy compile --skip-migrations --json` that job ran against a throwaway
2002
+ Postgres; `oxy compile` itself stays, for a local database.
2003
+
2004
+ `--json` prints `{status, workspace_id, branch, git_sha, revision_id,
2005
+ file_count_seen, file_count_compiled, file_count_failed, failures, error}`;
2006
+ `failures` is always an array of `{path, kind, message}`, the shape
2007
+ `oxy compile --json` printed (pinned in `compile.test.ts`). Exit `0` compiled
2008
+ (or, without `--wait`, queued), `9` compiled and recorded file failures, `1`
2009
+ failed with no file failure (the compile did not run to the end; re-run), `4`
2010
+ not signed in or not allowed, `5` no such workspace or a branch GitHub does not
2011
+ have, `7` `--wait` ran out.
2012
+
2013
+ Who may: a person with Factory access and editor standing in the workspace, or
2014
+ — in GitHub Actions, through trusted access (`OXY_SERVICE_ACCOUNT`,
2015
+ `id-token: write`) — the org's service account whose trust policy grants it a
2016
+ workspace grant (`viewer` is enough; it adds this and nothing else). The
2017
+ template's README ("What CI checks") has the setup.
2018
+
1535
2019
  ## Development commands
1536
2020
 
1537
2021
  ```bash
1538
2022
  oxyc validate [-f <file>] [--json]
2023
+ oxyc migrate-automations [path] [--dry-run]
1539
2024
  oxyc mcp
1540
2025
  oxyc guide
1541
2026
  oxyc skills install | list
@@ -1544,17 +2029,48 @@ oxyc exit-codes
1544
2029
  ```
1545
2030
 
1546
2031
  **`validate`** checks workspace YAML against `json-schemas/*.json`, which are
1547
- generated from the Rust config types. No network, no token.
2032
+ generated from the Rust config types, and then as the runtime checks each file
2033
+ once it has loaded. No network, no token. It replaced `oxy validate`, which is
2034
+ a stub for one release that prints this command and exits `2`.
1548
2035
 
1549
2036
  | File | Schema |
1550
2037
  | --- | --- |
1551
- | `config.yml` / `config.yaml` | `config.json` |
1552
- | `*.automation.yml`, `*.procedure.yml` (`*.workflow.yml` is not a recognised kind; `oxy migrate-automations` renames it) | `workflow.json` |
2038
+ | `config.yml` / `config.yaml` at a workspace root | `config.json` |
2039
+ | `*.automation.yml`, `*.procedure.yml` (`*.workflow.yml` is not a recognised kind; `oxyc migrate-automations` renames it) | `workflow.json` |
1553
2040
  | `*.agentic.yml` | `agentic.json` |
1554
2041
  | `*.agent.test.yml` | `agent-test.json` |
1555
-
1556
- Structural checks only. `oxy validate` additionally resolves `databases:` and
1557
- `llm.ref` against the loaded workspace, and wins where the two disagree.
2042
+ | `*.view.yml`, `*.topic.yml`, anywhere the compiler finds them (`.yml` only) | `view.json`, `topic.json` |
2043
+
2044
+ Past the schema:
2045
+
2046
+ - **References**, against the `config.yml` of the workspace each file is in (the
2047
+ outermost one the walk finds above it; with `--file`, the nearest one above
2048
+ the directory you run in, as `oxy` read it).
2049
+ An automation's `execute_sql` `database:` and `omni_query` / `looker_query`
2050
+ `integration:` must name an entry of that kind, including inside a
2051
+ `loop_sequential`. An agentic agent's `databases:` and `llm.ref` must name a
2052
+ database and a model; the Rust command never checked those.
2053
+ - **Rules** the runtime applies to an automation: a non-empty `tasks:` and task
2054
+ `name:`, an `export:` format the task kind supports, `http_request`
2055
+ `timeout_secs` from 1 to 120, `dry_run_limit` at least 1, and a
2056
+ `consistency_prompt` that parses as a template (a structural check of the
2057
+ template, not minijinja's full grammar).
2058
+ - **Views and topics**: no `inherits_from:` or `{{ globals.* }}` (removed), and
2059
+ every `{{variables...}}` well formed.
2060
+
2061
+ A `config.yml` nested inside a workspace (an Airform project's, say) is not
2062
+ checked as a workspace config. Workspace files with no `config.yml` above them
2063
+ are one `missing` finding. Each finding in `--json` has a `kind`: `parse` (the
2064
+ file does not load), `ref`, `rule` or `missing`. Where a generated schema is
2065
+ stricter or looser than the runtime's deserializer (an alias, `serde(other)`, a
2066
+ `deny_unknown_fields` `schemars` cannot see), `src/validate/serde-leniency.ts`
2067
+ patches it, and `fixtures/validate-parity/` pins every verdict against the one
2068
+ `oxy validate` gave.
2069
+
2070
+ **Exit codes:** `0` clean; `9` (`CHECK_FAILED`) at least one finding — `oxy
2071
+ validate` exited `1`, so a script testing `$? -eq 1` changes; `1` nothing could
2072
+ be read; `2` a kind `--file` cannot check; `5` a `--file` path that does not
2073
+ exist.
1558
2074
 
1559
2075
  Every **`oxy-app.json`** it finds is checked for data placement — the shape of
1560
2076
  the data picks the store: facts and history in Airhouse (`ctx.airhouse`),
@@ -1638,6 +2154,25 @@ A **sandbox agent token** must pass `--app <org>/<app> --app-env dev-<handle>`
1638
2154
  oxyc proxy --app acme/store --app-env dev-a1 # then open the printed URL
1639
2155
  ```
1640
2156
 
2157
+ **`migrate-automations`** renames every `*.procedure.yml` / `*.workflow.yml`
2158
+ under `path` (default `.`) to `*.automation.yml`, then rewrites references to
2159
+ the old extensions — `src:`, `workflow_ref:`, glob includes — in every `.yml` /
2160
+ `.yaml` / `.sql` file. Local only: no network, no token. `--dry-run` prints the
2161
+ rename plan and writes nothing. It replaces the Rust `oxy migrate-automations`,
2162
+ which for one release only prints this command and exits `2`.
2163
+
2164
+ - **It never overwrites.** A file whose `.automation.yml` target already exists,
2165
+ or two files that map to one name (`x.procedure.yml` beside `x.workflow.yml`),
2166
+ is a collision: listed on stderr, skipped, and left for you. Collisions alone
2167
+ still exit `0`.
2168
+ - **The rewrite is a plain substring replace**, so a reference to a collided
2169
+ file is rewritten too, and points at a name that exists only once you resolve
2170
+ the collision. References are rewritten only on a run that renamed something.
2171
+ - It skips `.git`, `.worktrees`, `.oxy_state`, `target`, `node_modules`, `dist`,
2172
+ `build`, `.venv` and every other dot-directory, and leaves a file that is not
2173
+ UTF-8 alone. Only the `.yml` spellings are renamed.
2174
+ - A path that does not exist exits `5`; a path that is a file exits `2`.
2175
+
1641
2176
  **`mcp`** serves the API over stdio as four generic tools — `oxy_routes`,
1642
2177
  `oxy_schema`, `oxy_request`, `oxy_whoami` — rather than one per endpoint, so
1643
2178
  those schemas cost ~2 KB per turn and reach endpoints added after this
@@ -1697,7 +2232,8 @@ written in `skills/` here; see `internal-docs/platform-skills.md`.
1697
2232
  6 the request was malformed (4xx other than 401/403/404)
1698
2233
  7 unavailable — 5xx, a timeout, or the network failed. Retryable.
1699
2234
  8 refused — the operation would have destroyed or overwritten something
1700
- 9 a check ran and failed or timed out (`oxyc checks run`)
2235
+ 9 a check ran and failed or timed out (`oxyc checks run`, `oxyc looker test`,
2236
+ `oxyc validate`)
1701
2237
  ```
1702
2238
 
1703
2239
  `4` almost always means the wrong `--env`. A person logs in again. An agent on
@@ -1709,9 +2245,10 @@ its own token (`tokens create --agent` or `--sandbox-agent`) does not: there,
1709
2245
 
1710
2246
  | Variable | Default | Meaning |
1711
2247
  | --- | --- | --- |
1712
- | `OXY_TOKEN` | — | any credential, sent as a bearer; overrides the login cache and GitHub OIDC |
1713
- | `OXY_API_KEY` | — | a legacy API key or an API token, for the `/external/api` surface and for `checks run` |
1714
- | `OXY_SERVICE_ACCOUNT` | — | the **ID** of the service account a GitHub OIDC exchange acts as (`--service-account`); never `<org>/<name>` |
2248
+ | `OXY_TOKEN` | — | any credential, sent as a bearer; overrides the login cache and GitHub OIDC. `from-proxy`: an egress proxy adds it, so none is sent ([A token the proxy adds](#a-token-the-proxy-adds)) |
2249
+ | `OXY_API_KEY` | — | an API token, for the `/external/api` surface and for `checks run` (the name is historical: it held a legacy API key until those were removed) |
2250
+ | `OXY_SERVICE_ACCOUNT` | — | the **ID** of the service account a trusted-access exchange acts as (`--service-account`); never `<org>/<name>` |
2251
+ | `OXY_OIDC_TOKEN_FILE` | — | a file holding a token from an OIDC issuer the org registered, traded at the exchange instead of GitHub's ([A service on another platform without a stored secret](#a-service-on-another-platform-without-a-stored-secret)) |
1715
2252
  | `OXY_AGENT` | detected | the name of the agent driving `oxyc`, sent in the user agent — see below |
1716
2253
  | `OXY_CREDENTIALS_PATH` | OS config dir | the shared `credentials.json` |
1717
2254
  | `OXYC_ORG` | `oxy-hq` | GitHub org the customer repos live in |
@@ -1736,7 +2273,7 @@ its own token (`tokens create --agent` or `--sandbox-agent`) does not: there,
1736
2273
 
1737
2274
  **In a Claude Code cloud session,** the repo's SessionStart hook installs
1738
2275
  `oxyc` and keeps an agent token across shell calls. The environment must allow
1739
- the Oxy hosts. Setup: the `oxy-custom-apps` skill, "Headless and cloud
2276
+ the Oxy hosts, or hold a network secret for them with `OXY_TOKEN=from-proxy`. Setup: the `oxy-custom-apps` skill, "Headless and cloud
1740
2277
  sessions".
1741
2278
 
1742
2279
  **An agent should set `OXY_AGENT`.** Every request `oxyc` makes to a deployment