Repository navigation
feat(studio): bootstrap the Mecatl Studio web UI as apps/ - #1754
Conversation
Review findingsReviewed the bootstrap commit against its immediate plan/ADR parent, without assuming later stack layers repair it.
|
e07acaa to
40f1e60
Compare
Review findings addressedAll eleven confirmed against the code and fixed in this layer. Where a fix needed evidence, I checked it first rather than reading the finding at face value. P1
P2
The interface change for the audit hooks also touched the Also in this round
|
40f1e60 to
e53f1b2
Compare
e53f1b2 to
e5f6bd9
Compare
e5f6bd9 to
8a50500
Compare
Implementation layer of docs/acceptance/studio-bootstrap.md (ADR 0351): a self-contained pnpm workspace at apps/ — contracts (Zod → OpenAPI → generated Hey API client, drift-gated), server (Hono BFF over the PUBLISHED @stacklok-oss/mecatl-sdk: spawn/mock/external runtime modes, RFC 9728 discovery with MECATL_RESOURCE_URL, PKCE login with sealed HttpOnly cookies, 401 gating, single-flight refresh, CSP and security headers, same-origin + double-submit CSRF, per-client rate limiting, trusted-proxy hops, audit records, SPA serving), and web (React shell, auth gate, connection banner, empty workspace). Ships apps/Dockerfile (multi-stage, Chainguard node by digest, STUDIO_IMAGE=1), a Studio-owned mecated.Dockerfile plus compose, the studio:* Taskfile namespace, a `studio` CI job with a no-push image build, the `publish-studio` release job cloned from the Slack bot's, ac-trace resolver support for apps/ proofs, and the in-repo docs (apps/README.md, docs/architecture.md, AGENTS.md). 26 server + 3 web Vitest proofs cover the plan's Scenario 2–4 ACs; smoke-tested against a spawned `mecated --mock` and the built image. Tracking: #1736 Signed-off-by: Samuele Verzi <[email protected]> Answers eleven review findings against this layer. Security and correctness: local .env files are excluded from every Docker build context, so the documented Compose flow no longer sends provider keys to BuildKit through the mecated image's root context; the authorization request carries the discovered audience, as the Go client does, so issuers that bind tokens to an audience mint the right one; the login transaction carries its own expiry and is refused past it, so a copied sealed cookie cannot be replayed after ten minutes; clearing a session now clears the CSRF cookie too; and a login is audited complete only after Mecatl verifies the credential and the session is sealed, with a failure record on the rejection path. Contract: the login route exposes `return_to`, the name the acceptance plan states, instead of camel case; MECATL_BASE_URL is validated as an authority and rejects credentials, a query, a fragment, or a path before listening; and gRPC errors map from their stable string code rather than from `status`, which over gRPC carries a Connect code and not an HTTP status. Image: the contracts workspace package moves to devDependencies, since the bundle inlines it, so the pruned runtime no longer ships its TypeScript sources; the Node major difference between the Node 24 workspace and the Node 26 runtime is documented where the digest is pinned, and `engines` widened to `>=24` to match; and a manual release labels the revision it actually checked out rather than the branch commit that started the run. The image and the README now state plainly that Studio is early access and may change between releases without a deprecation period. CI relevance: the go and macOS classifiers now treat apps/ as irrelevant, alongside docs and the site. apps/ holds no Go package, no go.mod, and nothing a Go build or test reads (the one repo-wide Go walker collects go.mod files only), so a Studio-only change no longer runs the Go and macOS matrices and inherits unrelated flaky Go tests; the studio category owns its checks. Classifier tests cover the skip and the mixed cases, and the macOS closure guard still passes.
8a50500 to
b8737cd
Compare
Summary
What lands
apps/pnpm workspace (pnpm 12.4.2, Node 24):contracts(Zod → OpenAPI → generated client, drift-gated),server(Hono BFF),web(Vite + React shell). Depends on@stacklok-oss/mecatl-sdk0.3.0 from npm; nothing referencessdk/typescript.MECATL_RESOURCE_URLor derived fromMECATL_BASE_URL, fail-closed on anything but404); PKCE login with AES-GCM-sealed HttpOnly cookies; server-side401gating; single-flight refresh;secureHeaders+ CSP; same-origin + double-submit CSRF on mutations; per-client rate limiting withSTUDIO_TRUSTED_PROXY_HOPS; structured audit records; SPA serving with cache rules;STUDIO_IMAGE=1refusals and theSTUDIO_ALLOW_UNAUTHENTICATED=1opt-in.mode: oidc), connection banner, CSRF request interceptor.apps/Dockerfile(Chainguard node pinned by digest),apps/docker/mecated.Dockerfile,apps/docker-compose.yml,task studio:*.studiorelevance category and job (install, lint, typecheck, test, generated-check, no-push image build);publish-studiorelease job cloned from the Slack bot's; ac-trace vitest resolver acceptsapps/proofs.apps/README.md,docs/architecture.mdStudio section, AGENTS.mdapps/bullet.Amended after review
Eleven review findings are fixed in this layer; the resolution comment below lists each with its evidence and proof. In short: local
.envfiles are excluded from every Docker build context; the authorization request sends the discoveredaudience, as the Go client does; the login transaction carries and enforces its own expiry; clearing a session clears the CSRF cookie; a login is audited complete only after verification and sealing; the login route uses the contract'sreturn_to;MECATL_BASE_URLis validated as an authority; gRPC errors map from their string code; the contracts package no longer ships into the runtime image; a manual release labels the revision it built; and the Node 24 workspace versus Node 26 runtime difference is documented where the digest is pinned.Studio is stated as early access in the README and on the image (
org.stacklok.mecatl.studio.stability=early-access). The stack is rebased onto currentmain, and the Studio ADR is renumbered to 0351 becausemainmerged its own ADR 0350.Verification
task studio:check— Biome, typecheck ×3, 26 server + 3 web Vitest, generated-drifttask lint:actions,task docs,task ac-trace(28/28 proofs resolve)mecated --mockdocker build -f apps/Dockerfile apps+ container startA
secure-code-reviewerpass overapps/serveris owed per the plan's Definition of done.Further amendments
Implements the amended bootstrap contract (see the plan layer below):
hostAllowlistmiddleware answers421 host_not_allowedfor aHostother than the public URL's host (loopback only without one)./api/healthstays reachable for probes.Originwhenever one is present.127.0.0.1outside the image unlessSTUDIO_HOSTsays otherwise, and the Vite dev proxy targets127.0.0.1./oauth/callback. Alogin_state_mismatchcallback keeps the existing session.defaultHookturns request-validation failures into problem details. gRPC errors fall back to the Connect code's HTTP class.apps/.node-version, andapps/.dockerignoredrops nested.envfiles.New proofs: the Host allowlist, loopback bind, negative
return_to, the validation hook, and the Connect-class fallback. Re-verified:task studio:checkpasses (34 server + 3 web Vitest)./api/openapi.jsonroute is removed, because generation usesgetOpenAPIDocumentand the contract makes/api/healththe only route outside/api/v1.accountkey (a hash of the subject) is added to the session response.lib/account-storage.tsclears user-scoped storage on sign-out and on an account change.gatestep skipspublish-studiofor tags that predate Studio, and for a dispatch whose checked-out revision differs fromgithub.sha.landed(header and index), per the plan lifecycle; the transition is authoritative only when this PR merges, andtask ac-trace-strictnow gates the plan.Re-verified on the rebased stack:
task studio:checkpasses (37 server + 6 web Vitest), andtask ac-trace-strictpasses with every Studio plan gated aslanded(141 ACs, 0 failures).Development stage
Contract linkage
gh stack) delivery for the whole Studio series: nothing merges until every layer is reviewed, so the plan's approval-by-merge event is deferred to the end (recorded in each plan's Delivery line), and each implementation layer records the exact plan commit it built against.docs/acceptance/studio-bootstrap.mde344835ed203c0400565fe8364109aff7c7ac2b5(the plan layer below; not yet merged — stacking exception above)Interface conformance
shand Node's bundlednpm(no pnpm, no OS package manager, no sources, no dev deps).Issue relationship
Relates to #1746 (parent #1736; stack #1766). Non-closing: the step completes when both of its layers merge.
Type of change
Test plan
Baseline checks
task lint)task test)go run ./cmd/mecademo)task docs)Studio gates (this workspace is not covered by
task lint/task test, which are Go-only):task studio:check(Biome, typecheck, Vitest, generated-drift),task ac-trace,task lint:actions— all pass; see Verification above.User-facing change
A new browser client image
ghcr.io/stacklok/mecatl/studio(bootstrap: login, runtime status, shell).Special notes for reviewers
Part of a fourteen-layer stack; review bottom-up. Nothing merges until the whole series is reviewed.