@oxy-hq/cli 0.12.0 → 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 (34) hide show
  1. package/README.md +605 -68
  2. package/dist/main.mjs +12264 -9947
  3. package/dist/main.mjs.map +1 -1
  4. package/dist/{mcp-WxYfGpMF.mjs → mcp-vlYd5Bms.mjs} +4 -183
  5. package/dist/mcp-vlYd5Bms.mjs.map +1 -0
  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 +4 -4
  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 +57 -9
  18. package/skills/oxy-custom-apps/SKILL.md +303 -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
  34. package/dist/mcp-WxYfGpMF.mjs.map +0 -1
@@ -1,16 +1,18 @@
1
1
  # Validate __NAME__'s semantic model on every pull request.
2
2
  #
3
- # `oxy compile` is the gate. It parses every workspace YAML file and writes the
4
- # result into a Postgres schema, so this job needs a throwaway database — and
5
- # it needs one more thing that is easy to miss: a row in `workspaces` for the
6
- # workspace id it compiles under. That row is created at `oxy serve --local`
7
- # boot, NOT by migrations, so a CI job that only migrates dies on a foreign-key
8
- # violation *before reading a single line of YAML*.
3
+ # `oxyc compile` is the gate. It asks the oxy deployment that serves this
4
+ # workspace to compile the branch — the commit GitHub has for it, as the
5
+ # workspace's registered subdirectory — into a STAGING revision, waits for the
6
+ # answer, and fails the job when any file recorded a failure. A staging
7
+ # revision is never promoted and nothing a customer sees reads it, so this
8
+ # changes nothing anyone is served.
9
9
  #
10
- # Every step below was run against a real Postgres 16 container before it was
11
- # written here, on the pinned CLI version. If you change a step, run it — and
12
- # run it in BOTH layouts, since `OXY_WORKSPACE` below makes this file one that
13
- # has two correct answers rather than one.
10
+ # It replaced a job that installed the Rust `oxy`, booted a throwaway Postgres,
11
+ # ran `oxy migrate`, INSERTed a `workspaces` row with psql and ran
12
+ # `oxy compile --json` over the checkout. That compiled what was on the runner,
13
+ # with whatever compiler the pin named; this compiles what the deployment will
14
+ # compile, with its compiler, and needs no database, no checkout and no
15
+ # installer script.
14
16
  #
15
17
  # What this gate catches and what it does not: see "What CI checks" in README.md.
16
18
 
@@ -25,240 +27,164 @@ on:
25
27
  # nothing. It stays useful once PRs are required too — a merge is a push, and
26
28
  # a branch protected today can be unprotected tomorrow.
27
29
  #
28
- # Deliberately no `paths:` filter. `oxy compile` reads the whole workspace,
29
- # and a filter that missed a path would skip validation silently, which is
30
- # worse than compiling on a README change.
30
+ # Deliberately no `paths:` filter. A compile reads the whole workspace, and a
31
+ # filter that missed a path would skip validation silently, which is worse
32
+ # than compiling on a README change.
31
33
  push:
32
34
  branches: [main]
33
35
 
34
- # This gate reads the tree and compiles it into a throwaway database. It never
35
- # writes to the repository, so it does not need a token that can. Stated
36
- # explicitly because the DEFAULT is whatever the repo or org is set to, which
37
- # for many repos is read/write on every scope.
36
+ # This gate never writes to the repository, so it does not need a token that
37
+ # can. Stated explicitly because the DEFAULT is whatever the repo or org is set
38
+ # to, which for many repos is read/write on every scope.
38
39
  permissions:
39
40
  contents: read
40
41
 
41
42
  env:
42
- # Pinned deliberately. `get.oxy.tech` honours OXY_VERSION, and this is the
43
- # version the sequence below was proven against — bump it only after
44
- # re-running the sequence, not on sight.
45
- OXY_VERSION: "0.5.126"
43
+ # The `@oxy-hq/cli` (`oxyc`) this job installs, exactly. `oxyc compile`
44
+ # exists from 0.13.0; an older pin has no such command.
45
+ OXYC_VERSION: "0.13.0"
46
46
 
47
47
  # WHERE THE OXY WORKSPACE IS, relative to the repo root.
48
48
  #
49
49
  # . the repo IS the workspace — every repo `oxyc new` scaffolds
50
50
  # oxy the repo CONTAINS one — the shape of every repo that was imported
51
51
  #
52
- # Substituted at render time from `__WORKSPACE__`, by the same machinery that
53
- # writes __SLUG__ and __NAME__, so `oxyc update` re-renders it and there is no
54
- # special case anywhere for a repo shaped the second way.
55
- #
56
- # It exists because this gate cannot be layout-agnostic and must not be
57
- # layout-wrong: `oxy compile` at the repo root of a repo whose workspace is
58
- # `oxy/` reads no config.yml, compiles nothing, and fails. A CI file that
59
- # installs cleanly and then fails on every run is worse than one that was
60
- # never installed.
61
- #
62
- # The TOOLING adapts to the repo, never the other way round. The platform
63
- # registered this subdirectory when the workspace was onboarded and there is
64
- # no UI or CLI to change it, so flattening a repo to match this template
65
- # would silently break its registration with no repair short of re-onboarding.
52
+ # Substituted at render time from `__WORKSPACE__`. The deployment already
53
+ # knows the subdirectory it registered and compiles that; this is only used
54
+ # to anchor a failure annotation (a workspace-relative path) on the right
55
+ # file of the repo.
66
56
  OXY_WORKSPACE: "__WORKSPACE__"
67
57
 
68
58
  jobs:
69
59
  compile:
70
- name: oxy compile
60
+ name: oxyc compile
71
61
  runs-on: ubuntu-latest
72
62
 
73
- services:
74
- postgres:
75
- image: postgres:16
76
- env:
77
- POSTGRES_PASSWORD: ci
78
- ports:
79
- - 5432:5432
80
- options: >-
81
- --health-cmd "pg_isready -U postgres"
82
- --health-interval 5s
83
- --health-timeout 5s
84
- --health-retries 10
63
+ # `id-token: write` lets this job ask GitHub for a signed statement of what
64
+ # it is — this repository, this workflow file, this environment — which
65
+ # oxyc trades for a fifteen-minute token acting as the org's service
66
+ # account. No secret is stored anywhere.
67
+ permissions:
68
+ contents: read
69
+ id-token: write
70
+
71
+ # The environment the trust policy names. Trust policies must name one
72
+ # unless the org's token policy says otherwise, because without it anyone
73
+ # who can push a branch can mint. Create the trust policy for
74
+ # `.github/workflows/validate.yaml` with environment `validate` (see
75
+ # "What CI checks" in README.md).
76
+ environment: validate
85
77
 
86
78
  env:
87
- OXY_DATABASE_URL: postgres://postgres:ci@localhost:5432/postgres
88
- # OXY_STATE_DIR is set per step, not here: the `runner` context is not
89
- # available in a job-level `env:` block, and the expression would expand
90
- # to the empty string — putting the CLI's state dir at "/oxy-state".
91
- # actionlint catches this; a job that "just ran" would not.
79
+ # The ID of the oxy workspace this repo is registered as — the one a
80
+ # branch is compiled for. Repository variable; from the workspace's
81
+ # settings page in Oxygen. Unset: the job says so and passes (the day-one
82
+ # state of a scaffold, before the repo is registered).
83
+ OXY_WORKSPACE_ID: ${{ vars.OXY_WORKSPACE_ID }}
84
+ # The ID of the org service account the OIDC exchange acts as, from
85
+ # Organization settings -> API access. Its trust policy needs a workspace
86
+ # grant on OXY_WORKSPACE_ID; `viewer` is enough — a compile check needs
87
+ # no editor standing, and the account gains nothing else from it.
88
+ OXY_SERVICE_ACCOUNT: ${{ vars.OXY_SERVICE_ACCOUNT }}
89
+ # The fallback, as in publish.yaml: a stored token wins when it is set,
90
+ # and no OIDC token is requested. Leave it unset to use trusted access.
91
+ OXY_TOKEN: ${{ secrets.OXY_TOKEN }}
92
+ # Which deployment: `production` unless the repository variable says
93
+ # otherwise. OXY_TARGET, when set, is an explicit base URL and overrides it.
94
+ OXY_ENV: ${{ vars.OXY_ENV }}
95
+ OXY_TARGET: ${{ vars.OXY_TARGET }}
96
+ # The branch the deployment compiles. On a pull request that is the head
97
+ # branch (`github.ref_name` would be `<n>/merge`, which GitHub's API does
98
+ # not serve as a branch); on a push, the pushed branch.
99
+ BRANCH: ${{ github.head_ref || github.ref_name }}
100
+ # The commit this run is about, to say so when the branch has moved on.
101
+ EXPECTED_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
92
102
 
93
103
  steps:
94
- - uses: actions/checkout@v4
95
- with:
96
- # This job runs a downloaded installer script. Without this, checkout
97
- # leaves a GITHUB_TOKEN in .git/config for that script to find. The
98
- # job-level `permissions: contents: read` already narrows what such a
99
- # token could do; not persisting it at all is the cheaper half of the
100
- # same argument, and it costs nothing here — nothing in this job
101
- # pushes.
102
- persist-credentials: false
103
-
104
- - name: Install the pinned oxy CLI
104
+ - name: Check this repo is set up for the gate
105
+ id: setup
105
106
  run: |
106
107
  set -euo pipefail
107
- # NOT `bash <(curl ...)`, the form the docs use: process substitution
108
- # hands bash an empty file when the download fails, and bash then
109
- # exits 0 — a step that reports "installed" having installed nothing.
110
- # Download to a file first so curl's own -f failure is the step's.
111
- curl -sSfL https://get.oxy.tech -o "$RUNNER_TEMP/get-oxy.sh"
112
- OXY_VERSION="$OXY_VERSION" bash "$RUNNER_TEMP/get-oxy.sh"
113
-
114
- # And check the installer left something behind: it downloads the
115
- # binary with `curl -L` (no -f) and exits 0 regardless.
116
- if [ ! -x "$HOME/.local/bin/oxy" ]; then
117
- echo "::error::the installer exited 0 but left no executable at $HOME/.local/bin/oxy." >&2
118
- exit 1
108
+ if [ -z "${OXY_WORKSPACE_ID:-}" ]; then
109
+ echo "::notice::not checked: no OXY_WORKSPACE_ID repository variable, so there is no oxy workspace to compile this branch for. Set it (and OXY_SERVICE_ACCOUNT, with a trust policy) once the repo is registered — see 'What CI checks' in README.md."
110
+ echo "ready=false" >> "$GITHUB_OUTPUT"
111
+ exit 0
119
112
  fi
120
-
121
- # The installer drops the binary in ~/.local/bin for a non-root user
122
- # and edits shell rc files, which a GitHub step never reads. Put it
123
- # on PATH explicitly instead of hoping.
124
- echo "$HOME/.local/bin" >> "$GITHUB_PATH"
125
-
126
- - name: Verify the oxy CLI
127
- run: |
128
- set -euo pipefail
129
- # Not ceremony. Two silent failures make this load-bearing:
130
- # 1. the installer runs `curl -L` WITHOUT -f, so a tag that does
131
- # not exist writes GitHub's 404 HTML page to the binary path,
132
- # chmod +x's it, and still exits 0;
133
- # 2. this CLI falls through to `--help` with exit 0 on a subcommand
134
- # it does not have, so an old binary "succeeds" at doing nothing.
135
- if ! raw="$(oxy --version 2>&1)"; then
136
- echo "::error::'oxy --version' failed — the installed binary is not runnable." >&2
137
- printf '%s\n' "$raw" >&2
138
- exit 1
113
+ if [ -z "${OXY_TOKEN:-}" ] && [ -z "${ACTIONS_ID_TOKEN_REQUEST_URL:-}" ]; then
114
+ # A pull request from a fork gets no OIDC token, by GitHub's design:
115
+ # a fork's code must not be able to act as this repo.
116
+ echo "::notice::not checked: GitHub issued this run no OIDC token (a pull request from a fork gets none) and no OXY_TOKEN secret is set. The branch is checked when it reaches this repository."
117
+ echo "ready=false" >> "$GITHUB_OUTPUT"
118
+ exit 0
139
119
  fi
140
-
141
- have="$(printf '%s\n' "$raw" | sed -n 's/^oxy-app version: \([0-9][0-9.]*\).*/\1/p' | head -1)"
142
- if [ -z "$have" ]; then
143
- echo "::error::could not read a version out of 'oxy --version' — the install probably wrote a 404 page." >&2
144
- printf '%s\n' "$raw" >&2
120
+ if [ -z "${OXY_TOKEN:-}" ] && [ -z "${OXY_SERVICE_ACCOUNT:-}" ]; then
121
+ echo "::error::OXY_WORKSPACE_ID is set but OXY_SERVICE_ACCOUNT is not: trusted access needs the ID of the service account to act as. Set the repository variable, or an OXY_TOKEN secret as the fallback." >&2
145
122
  exit 1
146
123
  fi
124
+ echo "ready=true" >> "$GITHUB_OUTPUT"
147
125
 
148
- oldest="$(printf '%s\n%s\n' "$OXY_VERSION" "$have" | sort -t. -k1,1n -k2,2n -k3,3n | head -1)"
149
- if [ "$oldest" != "$OXY_VERSION" ]; then
150
- echo "::error::oxy $have is older than the pinned $OXY_VERSION." >&2
151
- exit 1
152
- fi
153
-
154
- echo "oxy $have (pin $OXY_VERSION)"
155
-
156
- - name: Migrate the throwaway database
157
- env:
158
- OXY_STATE_DIR: ${{ runner.temp }}/oxy-state
159
- run: oxy migrate
126
+ - name: Install the pinned oxyc CLI
127
+ if: steps.setup.outputs.ready == 'true'
128
+ run: |
129
+ set -euo pipefail
130
+ npm install --prefix "$RUNNER_TEMP/oxyc" --no-audit --no-fund "@oxy-hq/cli@$OXYC_VERSION"
131
+ echo "$RUNNER_TEMP/oxyc/node_modules/.bin" >> "$GITHUB_PATH"
160
132
 
161
- - name: Seed the workspace row oxy compile needs
133
+ - name: Verify the oxyc CLI
134
+ if: steps.setup.outputs.ready == 'true'
162
135
  run: |
163
136
  set -euo pipefail
164
- # `oxy compile --workspace-id` defaults to the nil UUID, and inserting
165
- # a revision for it needs the matching `workspaces` row to exist.
166
- # Migrations do not create it. Seeding it here is one INSERT against a
167
- # database that is destroyed with the job; the alternative — booting
168
- # `oxy serve --local` just to trigger its boot-time seed — costs ~25s,
169
- # binds two ports, and has no "seed and exit" mode.
170
- if ! command -v psql >/dev/null 2>&1; then
171
- echo "::error::psql is not on this runner. GitHub's ubuntu-latest image ships it; a self-hosted runner may not. Install postgresql-client, or run this INSERT with: docker exec ${{ job.services.postgres.id }} psql -U postgres" >&2
137
+ # A version other than the pin means PATH found a different oxyc first.
138
+ have="$(oxyc --version)"
139
+ if [ "$have" != "$OXYC_VERSION" ]; then
140
+ echo "::error::oxyc $have is on PATH, not the pinned $OXYC_VERSION." >&2
172
141
  exit 1
173
142
  fi
174
- psql "$OXY_DATABASE_URL" -v ON_ERROR_STOP=1 -q -c \
175
- "INSERT INTO workspaces (id, name) VALUES ('00000000-0000-0000-0000-000000000000', 'ci-validate') ON CONFLICT (id) DO NOTHING;"
143
+ echo "oxyc $have (pin $OXYC_VERSION)"
176
144
 
177
- - name: Compile the workspace
178
- env:
179
- OXY_STATE_DIR: ${{ runner.temp }}/oxy-state
145
+ - name: Compile the branch
146
+ if: steps.setup.outputs.ready == 'true'
180
147
  run: |
181
148
  set -euo pipefail
182
-
183
- # --workspace-path MUST be absolute. See the floor check below.
184
- #
185
- # $OXY_WORKSPACE is repo-RELATIVE, so it is joined to $GITHUB_WORKSPACE
186
- # and then CANONICALISED rather than concatenated: `cd` + `pwd -P`
187
- # collapses the trailing `/.` that a root workspace would otherwise
188
- # leave in the path, and it fails HERE, naming the directory, instead
189
- # of handing oxy a path that is not there. One expression, correct for
190
- # a repo that is the workspace and for one that contains it.
191
- ws=""
192
- if ! ws="$(cd "$GITHUB_WORKSPACE/$OXY_WORKSPACE" 2>/dev/null && pwd -P)"; then
193
- echo "::error::no directory at \$GITHUB_WORKSPACE/$OXY_WORKSPACE. OXY_WORKSPACE says where this repo's Oxy workspace is, relative to the repo root: '.' when the repo IS the workspace, a subdirectory name when it contains one." >&2
194
- exit 1
149
+ # An unset secret arrives as an EMPTY variable; oxyc treats the two
150
+ # alike, and unsetting it says which path this run takes.
151
+ if [ -z "${OXY_TOKEN:-}" ]; then
152
+ unset OXY_TOKEN
153
+ echo "authenticating with this job's GitHub OIDC token as service account $OXY_SERVICE_ACCOUNT"
154
+ else
155
+ unset OXY_SERVICE_ACCOUNT
156
+ echo "authenticating with the OXY_TOKEN secret (the fallback path)"
195
157
  fi
196
- echo "workspace: $ws (OXY_WORKSPACE=$OXY_WORKSPACE)"
158
+ where=(--env "${OXY_ENV:-production}")
159
+ if [ -n "${OXY_TARGET:-}" ]; then where=(--target "$OXY_TARGET"); fi
197
160
 
198
161
  status=0
199
- oxy compile --workspace-path "$ws" --skip-migrations --json \
200
- >"$RUNNER_TEMP/compile.stdout" 2>"$RUNNER_TEMP/compile.stderr" || status=$?
201
-
202
- cat "$RUNNER_TEMP/compile.stderr" >&2
203
-
204
- # `--json` does NOT put only JSON on stdout: a human-readable
205
- # "Compiling workspace id=... path=..." line comes first, so piping
206
- # stdout straight into jq fails ("Invalid numeric literal", exit 4).
207
- # Extract from the line that opens the JSON object instead.
208
- sed -n '/^{/,$p' "$RUNNER_TEMP/compile.stdout" > "$RUNNER_TEMP/compile.json"
162
+ oxyc compile "$BRANCH" --workspace "$OXY_WORKSPACE_ID" "${where[@]}" --wait --json \
163
+ >"$RUNNER_TEMP/compile.json" || status=$?
209
164
 
165
+ # `--json` prints the report whenever the compile ran to an answer,
166
+ # failed or not. Empty means oxyc stopped before that — not signed
167
+ # in, not allowed, no such branch — and said why on stderr above.
210
168
  if [ ! -s "$RUNNER_TEMP/compile.json" ]; then
211
- echo "::error::oxy compile printed no JSON — it failed before compiling anything (database unreachable, or no workspaces row for --workspace-id)." >&2
212
- exit 1
169
+ echo "::error::oxyc compile stopped before the compile answered (exit $status) — the lines above say why." >&2
170
+ exit "$status"
213
171
  fi
214
172
 
215
- # An empty .failures array is a legitimate result and jq exits 0 for
216
- # it, so no `|| true` is needed — and `|| true` here would be wrong,
217
- # since it would also swallow a real jq failure.
218
- jq -r '.failures[] | "::error file=\(.path)::[\(.kind)] \(.message)"' "$RUNNER_TEMP/compile.json"
219
- jq -r '"compile: status=\(.status) seen=\(.file_count_seen) compiled=\(.file_count_compiled) failed=\(.file_count_failed)"' "$RUNNER_TEMP/compile.json"
220
-
221
- # Floor check, and it earns its place: `oxy compile --workspace-path .`
222
- # finds config.yml and nothing else — every recursive kind is globbed
223
- # as "<root>/**/*.view.yml", which matches nothing when <root> is "."
224
- # — and it exits 0 while doing it. A green gate that validated no
225
- # views is worse than no gate, so assert the walker saw at least the
226
- # semantic files that are on disk.
227
- seen="$(jq -r '.file_count_seen' "$RUNNER_TEMP/compile.json")"
228
- floor=0
229
- # Under $ws, not the checkout directory. In a repo whose workspace is
230
- # `oxy/` the root has no config.yml, so a root-relative floor would
231
- # sit one lower than the truth — quietly agreeing with a walk that saw
232
- # nothing, which is the exact silence this check exists to break.
233
- if [ -f "$ws/config.yml" ]; then
234
- floor=$((floor + 1))
235
- fi
236
- # Count the WHOLE workspace tree, not just semantics/: the walker
237
- # globs `**/*.view.yml` from the workspace root, so a view under
238
- # models/ counts too, and a floor that only looked at semantics/ would
239
- # sit at 1 and agree with a walk that saw nothing — the same silent
240
- # agreement it exists to catch. Rooted at $ws for the same reason the
241
- # config.yml check is: what the walker will descend into is the
242
- # workspace, and a repo that contains one may hold .view.yml files
243
- # outside it (a vendored fixture, an example) that the walker will
244
- # never see and that would make this floor unreachably high.
245
- # The prunes mirror the walker's own skip list; pruning a directory
246
- # the walker would have descended can only UNDER-count, and a floor
247
- # that is too low never fails a healthy repo.
248
- # find prints nothing and exits 0 when there is no match, which is
249
- # this repo's day-one state — a legitimate result, not an error to
250
- # swallow. (On that empty tree floor=1=seen, so the check has nothing
251
- # to detect and correctly says nothing.)
252
- n="$(find "$ws" \( -name .git -o -name node_modules -o -name target \
253
- -o -name dist -o -name build -o -name .oxy_state \
254
- -o -name .semantics -o -name .preagg -o -name .worktrees \
255
- -o -name .cubestore -o -name .airlayer_cache \) -prune \
256
- -o -type f \( -name '*.view.yml' -o -name '*.topic.yml' \) \
257
- ! -name '*.test.*' -print | wc -l | tr -d ' ')"
258
- floor=$((floor + n))
259
- if [ "$seen" -lt "$floor" ]; then
260
- echo "::error::oxy compile saw $seen file(s) but at least $floor are on disk under $ws — the walker did not descend into the workspace. Check that --workspace-path is absolute, and that OXY_WORKSPACE ('$OXY_WORKSPACE') names the directory holding config.yml." >&2
261
- exit 1
173
+ # The paths are workspace-relative; anchor each on the repo's file.
174
+ # An empty `failures` array is the green case and jq exits 0 for it.
175
+ prefix=""
176
+ if [ "$OXY_WORKSPACE" != "." ]; then prefix="$OXY_WORKSPACE/"; fi
177
+ jq -r --arg prefix "$prefix" \
178
+ '.failures[] | "::error file=\($prefix)\(.path)::[\(.kind)] \(.message)"' \
179
+ "$RUNNER_TEMP/compile.json"
180
+ jq -r '"compile: status=\(.status) sha=\(.git_sha) seen=\(.file_count_seen // "?") compiled=\(.file_count_compiled // "?") failed=\(.file_count_failed // "?")"' \
181
+ "$RUNNER_TEMP/compile.json"
182
+
183
+ # The deployment compiles the branch as GitHub has it NOW, which can
184
+ # be a later commit than the one this run was started for.
185
+ sha="$(jq -r '.git_sha' "$RUNNER_TEMP/compile.json")"
186
+ if [ "$sha" != "$EXPECTED_SHA" ]; then
187
+ echo "::warning::compiled $BRANCH at $sha, not $EXPECTED_SHA: the branch moved on after this run started. The newer run checks the newer commit."
262
188
  fi
263
189
 
264
190
  exit "$status"
@@ -43,21 +43,47 @@ before the team sees it.
43
43
 
44
44
  ## What CI checks
45
45
 
46
- Every pull request runs `.github/workflows/validate.yaml`: a Postgres 16
47
- service container, then `oxy compile` over this whole tree. It needs no
48
- warehouse credentials — compiling is a pure YAML-to-rows transform — so the
49
- gate works before a single database is connected.
46
+ Every pull request (and every push to `main`) runs
47
+ `.github/workflows/validate.yaml`, which runs `oxyc compile <branch> --wait`:
48
+ the oxy deployment that serves this workspace compiles the branch — the commit
49
+ GitHub has for it, as the workspace's registered subdirectory, with the
50
+ deployment's own compiler — into a **staging** revision, and the job fails if
51
+ any file recorded a failure. A staging revision is never promoted and nothing
52
+ anyone is served reads it. It needs no warehouse credentials — compiling is a
53
+ pure YAML-to-rows transform — so the gate works before a single database is
54
+ connected. The branch must be on GitHub, which a pull request's is.
55
+
56
+ **Setting it up** (once, by an org admin, after the repo is registered as a
57
+ workspace):
58
+
59
+ 1. Repository variable `OXY_WORKSPACE_ID`: the workspace's ID, from its
60
+ settings page in Oxygen. Until it is set the job passes with a notice saying
61
+ nothing was checked — a scaffold's day-one state.
62
+ 2. A service account (Organization settings → Service accounts), and on it a
63
+ **trust policy** (*Trusted access*) naming this repository, the workflow
64
+ file `.github/workflows/validate.yaml` and the environment `validate`, with
65
+ a **workspace grant on the workspace at `viewer`**. That is enough: checking
66
+ a branch compiles is the one thing it adds to a viewer, and the account can
67
+ edit nothing. Then repository variable `OXY_SERVICE_ACCOUNT`: the account's
68
+ ID (never `<org>/<name>`).
69
+ 3. Optional: repository variable `OXY_ENV` (default `production`), or
70
+ `OXY_TARGET` for an explicit base URL. A stored `OXY_TOKEN` secret is the
71
+ fallback, and wins when set, as in `publish.yaml`.
72
+
73
+ A pull request from a fork gets no OIDC token from GitHub, so its run passes
74
+ with a notice; the branch is checked once it is in this repository.
50
75
 
51
76
  It catches:
52
77
 
53
- - **YAML that does not parse**, anywhere in the tree, `config.yml` included.
54
- The failing path is emitted as a GitHub error annotation, so the failure
55
- lands on the diff rather than only in the log. It anchors to the **top of
56
- the file**, not to the offending line: `oxy compile --json` reports a path, a
57
- kind and a message per failure, and no line or column for the workflow to
78
+ - **YAML that does not parse**, anywhere in the workspace, `config.yml`
79
+ included. The failing path is emitted as a GitHub error annotation, so the
80
+ failure lands on the diff rather than only in the log. It anchors to the
81
+ **top of the file**, not to the offending line: the compile reports a path,
82
+ a kind and a message per failure, and no line or column for the workflow to
58
83
  pass on.
59
84
  - **Two files of one kind declaring the same `name:`** — two views both called
60
85
  `orders`, say, which is what a copy-pasted file usually produces.
86
+ - **A `config.yml` the platform could not read**, which is never promoted.
61
87
 
62
88
  It does **not** catch, and each of these compiles green today:
63
89
 
@@ -73,11 +99,13 @@ It does **not** catch, and each of these compiles green today:
73
99
  So a green check means "this parses, and the identifiers are unique". It does
74
100
  not mean the model is correct, and it is not a substitute for reading the diff.
75
101
 
76
- The `oxy` CLI version is **pinned** in that workflow, and the job fails if the
77
- installed binary is older. Both halves matter: the installer does not fail on a
78
- version tag that does not exist, and this CLI answers a subcommand it does not
79
- have with its own help text and exit 0 — so an unpinned, unguarded job can go
80
- green while doing less than you think.
102
+ Exit codes, if you script around it: `0` compiled, `9` compiled and recorded
103
+ file failures, `1` the compile itself did not run to the end (re-run), `4` not
104
+ signed in or not allowed (check the trust policy and its grant), `5` no such
105
+ workspace, or a branch GitHub does not have, `7` it did not finish in time.
106
+
107
+ The `oxyc` version is **pinned** in that workflow (`OXYC_VERSION`), and the job
108
+ fails if a different one is on `PATH`.
81
109
 
82
110
  ## Developing an app locally
83
111
 
@@ -279,7 +307,7 @@ What makes oxy honour the statement is a **trust policy** on the service
279
307
  account, and it has to exist before the first publish. An org admin registers
280
308
  one **per environment**, once:
281
309
 
282
- 1. In the web app: **Organization settings → API access → Service accounts**.
310
+ 1. In the web app: **Settings → Organization → API tokens → Service accounts**.
283
311
  Create a service account — `deployer` is the conventional name — with the
284
312
  role *member*.
285
313
  2. Open it and, under **Trusted access**, add a policy for each of `dev` and
@@ -300,7 +328,7 @@ presented, which is usually enough to see which field is off.
300
328
 
301
329
  **Name the account the workflow acts as, by its ID**, in an
302
330
  `OXY_SERVICE_ACCOUNT` **variable** on the environment. The ID is on the
303
- account's page (Organization settings → API access → Service accounts → the
331
+ account's page (Settings → Organization → API tokens → Service accounts → the
304
332
  account). It is required for a trust policy to be used at all: the deployment
305
333
  matches a run against the policies of the one account its workflow names, and
306
334
  never picks one on a run's behalf — anyone can register a policy that names a
@@ -326,7 +354,7 @@ Use it where the deployment has no trusted access yet, or where a repository
326
354
  cannot be given a trust policy. Each of the two **GitHub environments** — `dev`
327
355
  and `production` — holds its own **`OXY_TOKEN`** (Settings → Environments →
328
356
  *environment* → Environment secrets). Prefer a **service account token**
329
- (Organization settings → API access → Service accounts → *account* → Tokens),
357
+ (Settings → Organization → API tokens → Service accounts → *account* → Tokens),
330
358
  granted only what publishing needs; a personal access token or an older
331
359
  workspace API key also works, and carries its owner's access with it — a
332
360
  leaked one is that person, not "this app only".
@@ -459,10 +487,11 @@ someone points each at the branch:
459
487
 
460
488
  Promoting the production semantic model is a deliberate, human step: open the
461
489
  production workspace in Oxygen and pull the latest commit. **CI does not do
462
- it**, and holds no credential that could — the trust policy behind each
463
- environment grants publishing apps and nothing else, so the token the job is
464
- handed cannot compile or promote a workspace at all. (Keep it that way on the
465
- fallback path: an `OXY_TOKEN` should be a token that can only publish.) So a merge
490
+ it**, and holds no credential that could — the publish trust policies grant
491
+ publishing apps and nothing else, and the validate policy's `viewer` grant lets
492
+ it compile a branch into a staging revision, which is never promoted. Neither
493
+ token can promote a workspace. (Keep it that way on the fallback path: an
494
+ `OXY_TOKEN` should be a token that can only publish.) So a merge
466
495
  to `main` never changes what production answers until someone decides it
467
496
  should.
468
497
 
@@ -6,10 +6,10 @@
6
6
  # ignore. Without this file the first commit of a customer workspace carries
7
7
  # node_modules/ and every app's build output.
8
8
  #
9
- # Both CI workflows already prune these same directory names when they walk
10
- # the tree (.github/scripts/discover-apps.sh, and the compile floor check in
11
- # validate.yaml), so this list and those prunes are two views of one rule:
12
- # these directories are generated, and nothing here reads them as source.
9
+ # The publish workflow already prunes these same directory names when it walks
10
+ # the tree (.github/scripts/discover-apps.sh), and the compiler skips them too,
11
+ # so this list and those prunes are two views of one rule: these directories
12
+ # are generated, and nothing here reads them as source.
13
13
 
14
14
  # Dependencies. Restored by `pnpm install` from pnpm-lock.yaml, which IS
15
15
  # committed.
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Minimal and valid on purpose: this compiles clean on day one, before a single
6
6
  # view, topic, pipeline or automation exists. `models:` must be present even
7
- # when empty — `oxy compile` fails with "missing field `models`" without the
7
+ # when empty — the compile fails with "missing field `models`" without the
8
8
  # key. `databases:` may be omitted entirely (the compiler synthesizes an empty
9
9
  # list), and is spelled out here only so there is an obvious place to add one.
10
10
  #
@@ -39,7 +39,7 @@ databases: []
39
39
 
40
40
  # defaults:
41
41
  # database: <replace-me-database-name> # must name an entry above; note
42
- # # that `oxy compile` does NOT
42
+ # # that the compile does NOT
43
43
  # # check this reference, so a typo
44
44
  # # here surfaces at query time
45
45