Skip to content

Scaffold the frontend sub-project with its dev stack, test rig, and CI job - #38

Merged
athvin merged 1 commit into
mainfrom
bm/frontend-m0-scaffold
Sep 26, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/frontend-m0-scaffold

Conversation

@athvin

@athvin athvin commented Sep 26, 2026

Copy link
Copy Markdown
Owner

M0 of the cloud UI build plan — the milestone-checkpoint delivery of docs/frontend-design.md (the design doc itself is committed here too).

What this adds

frontend/ — a standalone pnpm project (mirrors how server/ is a standalone uv project; nothing at the repo root references it at runtime):

  • Next.js App Router + TypeScript strict (noUncheckedIndexedAccess, exactOptionalPropertyTypes) + Tailwind v4 + shadcn-style primitives; ESLint flat (typescript-eslint strict-type-checked + next/core-web-vitals) with a rule banning the semantically-inverted pending_until_next_reconcile field; Prettier at the house width 100.
  • Identity groundwork: Drizzle schema for the BFF-owned erweb tables in the control-plane Postgres (users, sessions with impersonation fields, org_members, orgs_registry, org_credentials, audit) with a committed SQL migration, plus an AES-256-GCM credential vault (org+role bound as AAD) with unit tests.
  • Committed OpenAPI types: pnpm gen:api dumps erserver's schema offline (no server, no DB) → openapi.json + schema.d.ts, consumed by a server-only openapi-fetch client.
  • Login screen behind a cookie-presence middleware gate (wired to real sessions in M1).

Dev stack (frontend/dev/): compose file for control-plane Postgres (5433) + DuckLake catalog (5434) + MinIO (9000, built from the pipeline image since MinIO no longer publishes container images) — replacing the ad-hoc docker run trio in server/README; up.sh boots it plus the erserver API and dispatcher sequentially (concurrent first boot deadlocks the API's ensure_schema behind the dispatcher's leader connection — worth a look server-side); seed.py replays the lake-E2E happy path over HTTP.

Test rig — three tiers (documented in frontend/README.md):

  1. Vitest (bare, seconds).
  2. Playwright vs a mock erserver — the BFF's server-side fetches can't be intercepted at the browser, so the BFF points at tests/mock-erserver via ERSERVER_BASE_URL. Runs desktop Chromium 1440×900, iPhone 15 (WebKit), Pixel 7 projects; visual baselines are Linux-only (generated in the pinned Playwright image via make frontend-baselines, compare-off on macOS).
  3. FRONTEND_E2E=1-gated full-stack tier against the seeded dev stack (make frontend-e2e) — the release gate, off the PR path like the server lake E2E.

CI: new frontend job (no needs, off the critical path, SHA-pinned pnpm/setup-node/cache actions) running lint → format → types → vitest → build → mock-tier Playwright across all three device projects, uploading a third artifact set; the server job gains an OpenAPI snapshot drift check so an API change cannot land without the regenerated frontend types. tests/unit/test_ci_workflow.py extended (not loosened), per the 8ba1090 precedent.

Validation

  • make check green — 972 unit tests including the amended workflow contract; actionlint passes on the new job.
  • cd frontend && pnpm check && pnpm build && pnpm test:e2e green — 12/12 Playwright tests across the 3 device projects.
  • make frontend-dev && make frontend-seed verified against the real engine: corpus generated, first imports fail with error_class=precondition as designed, train + full run succeed — 800 records → 301 entities, 299 duplicate groups, 1 open review.
  • Visual baselines committed for all three projects, generated inside mcr.microsoft.com/playwright:v1.63.0-jammy.

Next milestone (M1): backend batch 1 (GET /v1/orgs, cross-org jobs view, acting-user attribution, audit read route) + BFF auth + app shell + ⌘K palette + dashboard.

🤖 Generated with Claude Code

…I job

The first milestone of the cloud UI build (docs/frontend-design.md, committed
here): a standalone pnpm project at frontend/ mirroring how server/ is a
standalone uv project. Next.js App Router + TypeScript strict + Tailwind v4,
with the identity groundwork (Drizzle schema for the BFF-owned erweb tables in
the control-plane Postgres, AES-256-GCM credential vault), committed OpenAPI
types generated from erserver's schema, and a login screen behind a
cookie-presence middleware gate.

Three test tiers, mirroring the server's bare/+Postgres/+lake prose: Vitest;
Playwright against a mock erserver (the BFF's server-side fetches can't be
intercepted at the browser) across desktop Chromium, iPhone 15 WebKit and
Pixel 7 projects with Linux-only visual baselines; and an FRONTEND_E2E-gated
full-stack tier against a seeded dev stack. frontend/dev/ boots the substrate
(control-plane Postgres 5433, catalog 5434, MinIO 9000 — replacing the ad-hoc
docker-run trio server/README documents) and seed.py replays the lake-E2E happy
path over HTTP: corpus, precondition-failing first imports, train, full run
(verified end to end: 800 records -> 301 entities, 299 duplicate groups).
The API and dispatcher start sequentially: booting both at once deadlocks the
API's ensure_schema behind the dispatcher's leader connection.

CI grows a frontend job (no needs, off the critical path, like server) running
lint/format/types/vitest and the mock-tier Playwright suite, uploading a third
artifact set; the server job gains an OpenAPI-snapshot drift check so an API
change cannot land without the regenerated frontend types. The workflow
contract in tests/unit/test_ci_workflow.py is extended, not loosened, per the
precedent of 8ba1090.

Validation: make check green (972 unit tests incl. the amended contract);
frontend pnpm check + build + Playwright (12/12 across 3 device projects)
green; make frontend-dev && make frontend-seed verified against the real
engine; visual baselines generated in the pinned Playwright Linux image.

Co-Authored-By: Claude Fable 5 <[email protected]>
@athvin
athvin merged commit b314095 into main Sep 26, 2026
36 checks passed
athvin added a commit that referenced this pull request Oct 20, 2026
…187)

* ci(frontend): make the gate blocking, and add the supply-chain half

The frontend has had a real CI workflow since #97, but it never gated
anything: branch protection on main requires four contexts and all four
are rust.yml's. `lint + types + unit` and `playwright functional tier`
ran and were then ignored at merge time. On top of that the `paths:`
filter meant #184, #185 and #186 did not run the frontend tier at all.

Making those jobs required needs the filter gone first: a workflow a
path filter skips never reports, so a required check would sit pending
forever on every backend-only PR. rust.yml already solved this for its
`.claude/**` skip — a `detect` job and an `if:` on each real job, since
a job skipped by `if:` reports "skipped", which branch protection
accepts. This mirrors that, filtering on `^frontend/` instead.

Then the half that was missing entirely. The Rust side runs cargo-deny
(advisories + licenses + bans) on every PR; the frontend ran nothing —
no `pnpm audit`, no license check, no SAST — and Dependabot covered only
`github-actions`, so npm dependencies were never bumped. The repo's own
notes flagged it (skills/security/references/secrets-iac.md: "Dependabot
does not cover cargo or npm").

Switching the gate on showed what that cost: 4 HIGH advisories, six of
them against `next` itself, including a HIGH SSRF in image optimization
fixed four patch releases earlier. So this also bumps next 16.3.6 →
16.3.8 (and the two eslint packages in lockstep), sharp → 0.35.5 and
source-map-js → 1.2.2, taking the tree from 4 high / 5 moderate / 1 low
to 1 high / 1 moderate. 16.3.8 rather than 16.4.2 deliberately: it is
the minimum that clears the advisories and stays inside the pinned
minor, which keeps the committed visual baselines in play.

The one remaining HIGH is allowlisted with its reasoning, following
deny.toml's convention of a prose justification per entry: [email protected]
is the newest published version and the advisory records no patched
release, it is reached only through @next/eslint-plugin-next at lint
time, and the only glob patterns it ever sees are our own eslint config.

New gates, each verified to fail as well as pass:

- `pnpm audit:check` — HIGH/CRITICAL fail, moderate and below reported.
  Reports stale allowlist entries so exceptions cannot accumulate.
- `pnpm licenses:check` — an allowlist, not a denylist, so an unseen
  license fails and gets looked at. deny.toml's 12 ids verbatim plus the
  npm tree's additions, each carrying why it is permissive enough.
- `pnpm authz:check` — every tenant route calls requireOrgAccess and
  every admin route requireSuperAdmin (54 handlers, all compliant).
  This was written as a semgrep rule first; semgrep rejected the pattern
  as invalid TypeScript while still reporting the rule as run with zero
  findings, so two deliberately unauthorized handlers passed. It is now
  code with tests that plant violations and require them to be caught.
- semgrep keeps the three sink rules confirmed to fire: HTML injection,
  dynamic eval, and NEXT_PUBLIC_* leakage.
- the `pnpm gen:api` drift gate frontend/README.md has claimed since #38
  but which never existed — the only related step was rust.yml's
  er-openapi-check, suffixed `|| true`.

Also restores the five `make frontend-*` targets dropped by 9a55504,
whose message says the frontend targets were retained. Their scripts
were never deleted, and frontend/dev/run.sh:97 has been calling
`make frontend-seed` since. `frontend-seed` itself is NOT restored: its
implementation went in 7cc444f with no replacement, which is why the
full-stack e2e tier is dormant.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(web): pin the GCM auth-tag length in the credential vault

The first run of the new semgrep gate found this
(javascript.node-crypto.security.gcm-no-tag-length), and it is a real if
modest hardening.

GCM accepts 4-16 byte authentication tags. `open()` slices the last
TAG_BYTES off the stored ciphertext, so a row whose ciphertext is
SHORTER than 16 bytes slices to a short tag — and without an explicit
authTagLength, Node accepts it. A short tag is correspondingly cheaper
to forge. The vault's whole premise is surviving someone who can write
the row (that is what the org+role AAD binding is for), so this is
exactly the threat model to care about.

Pinning authTagLength on both ends makes Node reject any tag that is not
16 bytes. The new test truncates a sealed ciphertext to 0/1/8/15 bytes
and requires each to throw.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: bmoore813 <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants