Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 69 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ name: CI
# same content: until 2026-10-27 it did, 28 minutes of runner time a merge, 60 merges a day. The typecheck and
# lint caches the static job restores are saved on main by warm-caches.yml.
#
# Three jobs since 2026-11-25. Until then one `checks` job ran the typecheck (1 to 17 minutes) and then the
# Three jobs since 2026-11-25, and the build leg beside them since 2026-12-02. Until then one `checks` job ran the typecheck (1 to 17 minutes) and then the
# whole suite (22 to 37) on one runner, 27 to 59 minutes a run, and every code PR paid it twice.
# static typecheck, lint, every check and the doc-reading tests. One runner, both events.
# test the suite. In the merge queue, the whole of it in shards, a runner each. On a pull request, one
# runner with the tests near the change and every test that reads files (scripts/lib/nearTests.mjs).
# build the page built by vite and the built page checked, in the merge queue alone (2026-12-02).
# checks the gate, and the one name branch protection requires.
# The queue is the only way onto main and still runs everything; a PR's own run is the quick answer first.
# Runners: the org runs 20 jobs at once. A queue build takes 4 and the queue builds 6 at once, so 24 at its
# fullest, past the cap (the owner's call, 2026-11-25, for the shorter build); a pull request's run takes 2.
# Runners: the org runs 20 jobs at once. A queue build takes 5 and the queue builds 6 at once, so 30 at its
# fullest, past the cap (the owner's calls, 2026-11-25 for the shorter build and 2026-12-02 for the build leg);
# a pull request's run takes 2.
# A leg waits for a runner when they are all out, it does not fail.
on:
pull_request:
Expand Down Expand Up @@ -309,20 +311,81 @@ jobs:
if: github.event_name != 'pull_request' && steps.changed.outputs.docs_only != 'true'
run: npx vitest run --shard=${{ matrix.part }}

build:
# The page, built and checked before the merge (punch list #480, the owner's pick of 2026-12-02). Until this
# job only deploy.yml built the client, after the merge: on 2026-12-02 a comment in index.html that named the
# page's source file passed every check here, failed the deploy's own check of the built page, and no deploy of
# main went out for two hours while twenty-nine merges waited. In the merge queue alone: every merge passes
# through it, and a pull request's own run stays the quick answer. A pull request reads this job as skipped,
# which the gate below takes on a pull request and nowhere else.
#
# `vite build` alone, not `npm run build`: that script's first half is the typecheck the static job already
# makes. src/lib/builtPage.test.ts holds the command here to the one in package.json's `build`. No Chromium:
# without a browser the help guides' share pages take the site card (helpSharePagesPlugin), and the check reads
# none of them. The values of the deploy's secrets are not needed to build, so made-up ones stand in.
name: build the page and check it
if: github.event_name == 'merge_group'
runs-on: ubuntu-latest
# On the deploy's runner the vite build takes 2 to 2.5 minutes of its Build step (read 2026-12-02), and the
# install under one. Under the 13 to 17 minutes the queue's build waits on its tests, so it adds no wait.
timeout-minutes: 20
permissions:
contents: read
steps:
# One commit, not the whole history the deploy fetches: the punch list's burndown then says it has no
# history to draw, and the page builds the same.
- name: Checkout
uses: actions/checkout@v4

# The test legs' question. A build of docs alone changes nothing the page is built from.
- name: Which files changed (a docs-only change builds nothing here)
id: changed
env:
GH_TOKEN: ${{ github.token }}
BASE: ${{ github.event.merge_group.base_sha }}
HEAD: ${{ github.event.merge_group.head_sha }}
run: |
gh api "repos/${GITHUB_REPOSITORY}/compare/${BASE}...${HEAD}?per_page=300" > "$RUNNER_TEMP/compare.json" || true
node scripts/ci-docs-only.mjs < "$RUNNER_TEMP/compare.json"

- name: Setup Node.js
if: steps.changed.outputs.docs_only != 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
if: steps.changed.outputs.docs_only != 'true'
run: npm ci

- name: Build the page (vite build, as the deploy runs it after its typecheck)
if: steps.changed.outputs.docs_only != 'true'
run: node --max-old-space-size=8192 node_modules/vite/bin/vite.js build
env:
VITE_SUPABASE_URL: https://example.supabase.co
VITE_SUPABASE_ANON_KEY: ci-dummy-anon-key

# The deploy's own check of the built page, the same script (scripts/lib/builtPage.mjs has the rules).
- name: Check the built page (what the deploy refuses, refused here first)
if: steps.changed.outputs.docs_only != 'true'
run: node scripts/check-built-page.mjs dist

# The one check branch protection requires, under the name it has always had. It runs only to fail, as
# sql-beds.yml's gate does: a skipped job takes no runner and counts as passing, so a green build never
# waits behind the backlog for a job of seconds. check-workflow-parity.mjs holds `needs` to every other job
# of this file, so a leg added later cannot be left outside the gate.
checks:
needs: [static, test]
needs: [static, test, build]
# always() is what holds a red leg out: without a status function GitHub adds success(), a failed leg then
# skips this job, and a skip passes. A cancelled or timed-out leg is not 'success' either, so it fails here.
if: always() && !(needs.static.result == 'success' && needs.test.result == 'success')
# The build leg runs in the merge queue alone, so on a pull request, and only there, its 'skipped' passes.
if: always() && !(needs.static.result == 'success' && needs.test.result == 'success' && (needs.build.result == 'success' || (github.event_name == 'pull_request' && needs.build.result == 'skipped')))
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: A leg did not pass
shell: bash
run: |
echo 'static: ${{ needs.static.result }} · test: ${{ needs.test.result }}'
echo 'static: ${{ needs.static.result }} · test: ${{ needs.test.result }} · build: ${{ needs.build.result }}'
exit 1
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Full index: [docs/README.md](./docs/README.md). The fast pointers:
6. **Test all 9 roles** — dev, master_technician, assistant, controller (assistant-like + payroll access), subcontractor, helpers (UI "Helper"), estimator, primary, superintendent.
7. **Company time zone** — `APP_CALENDAR_TZ` from `src/utils/dateUtils.ts` (Edge: `supabase/functions/_shared/appTimeZone.ts`); no new `'America/Chicago'` literals (`npm run check:timezone`); a stored instant's day is `calendarYmdInAppTzFromIso(iso)`, never its first ten characters.
8. **Realtime** — `useRealtimeChannel` from `src/hooks/useRealtimeChannel.ts` for every `postgres_changes` listener, filtered server-side via the `filter` string; don't add tables to the `supabase_realtime` publication casually.
9. **Branch + PR** — `main` is protected. Branch → PR (`gh pr create --fill`) → CI `checks` (typecheck + lint + the tests near the change, and it reads *skipped* when every leg passed) green → the merge queue (the *main merge queue* ruleset: squash, all-green, six entries built at once and five merged, a 240-minute check timeout — v2.6395) runs `checks` once more on the merged content, with the whole suite, and squash-merges; nothing on `main` gates on them again: `deploy.yml` only builds and deploys (its `npm run build` still runs `tsc -b`, and since v2.6119 its build job runs `check:calls-ahead --prod`, holding the deploy while the client calls what only an unpushed migration creates), and `warm-caches.yml` re-runs typecheck and lint on each merge only to save the `.cache` every PR and queue build restores. Run `npm run typecheck && npm run lint && npm test && npm run build` locally first, the whole suite being the queue's alone since v2.8596 (the typecheck takes a machine-wide lock, so two worktrees' typechecks run one after the other — `docs/SESSIONS.md` → One typecheck at a time; `TYPECHECK_NO_LOCK=1` skips it, as CI does) — `checks` never builds (only `deploy.yml` does), so a change to a glob, an asset import or `vite.config.ts` is proven by a local `npm run build`, never by a green PR. Never `git add -A`.
9. **Branch + PR** — `main` is protected. Branch → PR (`gh pr create --fill`) → CI `checks` (typecheck + lint + the tests near the change, and it reads *skipped* when every leg passed) green → the merge queue (the *main merge queue* ruleset: squash, all-green, six entries built at once and five merged, a 240-minute check timeout — v2.6395) runs `checks` once more on the merged content, with the whole suite, and squash-merges; nothing on `main` gates on them again: `deploy.yml` only builds and deploys (its `npm run build` still runs `tsc -b`, and since v2.6119 its build job runs `check:calls-ahead --prod`, holding the deploy while the client calls what only an unpushed migration creates), and `warm-caches.yml` re-runs typecheck and lint on each merge only to save the `.cache` every PR and queue build restores. Run `npm run typecheck && npm run lint && npm test && npm run build` locally first, the whole suite being the queue's alone since v2.8596 (the typecheck takes a machine-wide lock, so two worktrees' typechecks run one after the other — `docs/SESSIONS.md` → One typecheck at a time; `TYPECHECK_NO_LOCK=1` skips it, as CI does) — a PR's own `checks` never builds (the merge queue's build does, with `vite build` and `check:built-page`, and so does `deploy.yml`), so a change to a glob, an asset import, `vite.config.ts` or `index.html` is proven by a local `npm run build`, never by a green PR. Never `git add -A`.
10. **Theme tokens, not raw hexes** — CSS variables from `src/index.css`; CI runs `node scripts/theme-tokenize.mjs --check src`.
11. **Docs ship with the PR** — release note + `docs/recent-features/` fragment, migration and edge-function fragments, help guide, specialist doc: `CLAUDE.md` → Working conventions. Amend the line that holds a fact; never append feature detail to this file, `docs/AI_CONTEXT.md`, or `docs/README.md`.
12. **Made-up names** — the repo is public: a test, a help guide, a release note, a doc, a to-do card or a note in the code names no real customer, GC, owner or job, and no real street address, job number, phone number or email; it uses an invented one (a phone number keeps its area code and takes a 555-01xx number, which is never issued).
Expand All @@ -88,4 +88,4 @@ Break-glass repairs (understand what happened before running either):
- **Remote-only version** (a ledger row with no repo file): `supabase migration repair --status reverted VERSION --linked` — edits the history table only; runs no DOWN, drops nothing.
- **Push fails "already exists"** (DDL applied but never recorded): `supabase migration repair --status applied VERSION --linked`, then `supabase db push --linked` (`--include-all` for out-of-order timestamps).

last_updated: 2026-11-25
last_updated: 2026-12-02
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Guidance for Claude Code (and humans) working in this repo. Hard rules only, one

## Deploy model (four separate tracks)

CI (`ci.yml`) typechecks, lints, links every edge function and holds each function's upload under 4.5 MB, and `dev-mcp`'s under 10 MB since it deploys bundled (`npm run check:edge-bundles` — Deno refuses a missing named export at boot, the typecheck never reads the functions, and the deploy refuses 5 MB of source with HTTP 413, type-only imports counted) and tests every PR and the merge queue's build of it (the queue's build runs the whole suite, in shards on runners of their own, and a PR's own run the tests near its change and every test that reads files, since the queue is the only way onto `main` — `scripts/lib/nearTests.mjs`, fail-safe, a change to a dependency, `vite.config.ts` or a tsconfig brings the suite back; a change that touches only docs, to-dos, a root `.md`, `.claude/` or a release note runs the five tests that read those files instead of the suite — `scripts/lib/docsOnlyChange.mjs`, fail-safe, one code file brings the suite back), and the merge deploys the **client** to GitHub Pages (`deploy.yml`, which repeats no checks job: the queue is the only way onto `main`); only the deploy runs `vite build`, so run `npm run build` before merging a change to a glob, an asset import or `vite.config.ts`. The other three are manual — the first two against the linked prod project `yewfzhbofbbyvkvtaatw` ("plumbing-stage-manager"):
CI (`ci.yml`) typechecks, lints, links every edge function and holds each function's upload under 4.5 MB, and `dev-mcp`'s under 10 MB since it deploys bundled (`npm run check:edge-bundles` — Deno refuses a missing named export at boot, the typecheck never reads the functions, and the deploy refuses 5 MB of source with HTTP 413, type-only imports counted) and tests every PR and the merge queue's build of it (the queue's build runs the whole suite, in shards on runners of their own, and a PR's own run the tests near its change and every test that reads files, since the queue is the only way onto `main` — `scripts/lib/nearTests.mjs`, fail-safe, a change to a dependency, `vite.config.ts` or a tsconfig brings the suite back; a change that touches only docs, to-dos, a root `.md`, `.claude/` or a release note runs the five tests that read those files instead of the suite — `scripts/lib/docsOnlyChange.mjs`, fail-safe, one code file brings the suite back), and the merge deploys the **client** to GitHub Pages (`deploy.yml`, which repeats no checks job: the queue is the only way onto `main`); the queue's build runs `vite build` and the deploy's check of the built page (`npm run check:built-page`) and a PR's own run does neither, so run `npm run build` before arming a change to a glob, an asset import, `vite.config.ts` or `index.html`, or the queue turns it back. The other three are manual — the first two against the linked prod project `yewfzhbofbbyvkvtaatw` ("plumbing-stage-manager"):

1. **DB migrations** — `supabase db push` (rule above). When a migration changes behavior the old client would misread, deploy the client first; when the client calls a function, table or view only the migration creates, push right after the merge, before the Pages deploy finishes, and arm that PR only when the person who pushes is at hand — `npm run check:calls-ahead` labels such a PR *push right after the merge* and holds the deploy until the push, because PostgREST answers the missing name with a refusal, not a lost signal.
2. **Edge functions** — `supabase functions deploy <name>` (or MCP `deploy_edge_function`); `dev-mcp` alone deploys bundled from `main` by the `dev-mcp-deploy.yml` job, which `bash scripts/deploy-functions.sh dev-mcp` dispatches and waits for, because Supabase holds a bundle to 20 MB and raw files to 5 MB. Editing `supabase/functions/*` does nothing until deployed; `npm run check:edge-drift` says what is behind. `create-user` keeps `verify_jwt = false` in `config.toml` on every redeploy.
Expand Down
2 changes: 1 addition & 1 deletion docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Never raise `max_rows` instead — it moves the cliff and hides it again.

**Cause**: Rollup runs the `copy-404` plugin's `closeBundle` even after a failed bundle; before v2.5588 the plugin's `copyFileSync` threw on the missing `index.html` and replaced the build's own error. The real error on 2026-10-16 was every lesson `.md` parsed as JavaScript by a lazy `import.meta.glob` with no `?raw` (fixed in v2.5589).

**Fix**: since v2.5588 the plugin returns when there is no `index.html` to copy, so the log shows the error that stopped the build; read that line. Run `npm run build` locally before merging a change to a glob, an asset import or `vite.config.ts` — only the deploy runs it.
**Fix**: since v2.5588 the plugin returns when there is no `index.html` to copy, so the log shows the error that stopped the build; read that line. Run `npm run build` locally before arming a change to a glob, an asset import, `vite.config.ts` or `index.html` — a PR's own run never builds, and the merge queue's build leg turns a broken build back.

## Investigating errors under load (CLI + logs)

Expand Down
31 changes: 31 additions & 0 deletions docs/recent-features/v2.9253.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# v2.9253 — A change that breaks the build is turned back before it merges (2026-12-02)

Punch list #480, step 3. A workflow and its test, and three sentences in the entry docs. No screen changes. Nothing owed on prod.

## What was wrong

Only `deploy.yml` built the client, and it runs after the merge. `ci.yml` held no `vite build`. So a change that built a page the deploy refuses passed every check, merged, and failed each deploy of `main` after it. On 2026-12-02 that held twenty-nine merges off the live site for almost two hours.

## What changed

- `ci.yml` has a fourth job, **build the page and check it**. It runs in the merge queue alone (`if: github.event_name == 'merge_group'`), which is the owner's pick of the card's call 1 (2026-12-02): every merge passes through the queue, and a pull request's own run stays the quick answer.
- The job runs `vite build` alone, the half of `npm run build` after the typecheck, since the static job already typechecks. Then it runs `node scripts/check-built-page.mjs dist`, the deploy's own check from step 2.
- It installs no Chromium. Without a browser the help guides' share pages take the site card, and the check reads none of them. It uses made-up values where the deploy uses its secrets.
- A build of docs alone skips the install, the build and the check, by the same question the test legs ask.
- The `checks` gate needs the new job. A pull request reads the job as skipped, and the gate takes a skipped build on a pull request and nowhere else. `check-workflow-parity.mjs` already holds the gate to every job of the file.
- `CLAUDE.md`, `AGENTS.md` and `docs/TROUBLESHOOTING.md` each had a sentence that said only the deploy builds. Each is amended, and each now names `index.html` beside a glob, an asset import and `vite.config.ts`.

## What it costs

Step 1 of the card measured it. The `vite build` is 2 to 2.5 minutes on a runner, with the install about 4 to 5. A queue build with code in it waits 13 to 17 minutes on its tests, so the job adds nothing to the wait. It takes a fifth runner for those minutes: six builds at once are then 30 jobs against the org's 20, and a leg waits for a runner when they are all out.

## How it is held

`src/lib/builtPage.test.ts` has four more tests: the job is there and in the merge queue alone, its command is the vite half of `package.json`'s `build`, the check runs after it, and the gate's one mention of a skipped leg is the build's on a pull request.

Proven on a runner before this PR was armed, on a throwaway pull request that was closed and never merged: this branch with the job's `if` widened to a pull request. The job was read green on the branch as it is, and red with `main.tsx` put in a comment in `index.html`. The fragment's PR names that pull request and its runs.

## Not done here

- A failed deploy on `main` still tells nobody (step 4), and nothing on the live site names its commit (step 5).
- The deploy still builds and checks on its own after the merge. The check there is now a second look, not the first.
Loading
Loading