Skip to content

Demonstrate the composed ui/auth/admin override path and document it (#217) - #226

Merged
jimhoyd merged 5 commits into
mainfrom
claude/issue-217-compose-overrides
Sep 20, 2026
Merged

jimhoyd merged 5 commits into
mainfrom
claude/issue-217-compose-overrides

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Closes #217.

What the issue claimed, re-checked against main

#217 was written from source inspection at d5a14cf. Every source-evidence bullet in it is now stale, because #220 (d9d627f) landed in between:

Issue claim Status on main
packages/ui/src/host/scaffold.ts creates ui with sources: [] and no extension templates No longer true. It wires authCatalogue, authUiTemplates and adminUiTemplates from names.
packages/auth/src/scaffold.ts emits authExtension({service, csrfKey, projectSha256}) without ui No longer true. It emits authExtension({service, csrfKey, projectSha256, ui}).
packages/admin/src/scaffold.ts emits adminExtension(...) without ui No longer true. It emits ..., ui}).
"Preserve standalone configurations — auth or admin without ui" No longer a supported configuration. #220 retired the UI primitive fallback; the kit is the only render path, and --with auth, --with auth,admin and --with auth,admin,ui all refuse at scaffold time. This PR does not re-open that; it pins the refusals and pins --with ui alone to a self-contained host.

So requirement 1 was already delivered. What was genuinely missing was requirement 3 (a demonstration, not wiring that compiles) and the documentation half.

The demonstration

test/workspace-scaffold.integration.ts gains a generated-consumer test that:

  1. runs urlcode init site --with ui,auth,admin against the built workspace packages;
  2. writes ui/templates/auth/sign-in.html, ui/templates/admin/dashboard.html and ui/copy/en.json into the generated site;
  3. bootstraps an administrator through the generated operator-service.mjs;
  4. builds a runtime from the extension array the generated host.mjs exports — nothing reaches into the packages;
  5. asserts the local template and the local copy override appear on a rendered /account/login and a rendered /admin.

It was verified to actually catch a regression: dropping adminUiTemplates from the ui scaffold makes the composition assertion fail and the render test fail at activation with the extension's own "built without the admin templates" error. It skips with a printed reason when the host SQLite is not the release auth's store requires.

packages/auth/test/lifecycle-hooks.test.ts gains one test: a throwing onSignUp replaces the success response while the account it ran after still exists, so the documented "post-action hooks cannot undo anything" rule is a tested property.

The documentation

New root document docs/COMPOSING-A-SITE.md, linked from docs/AI-AUTHORING.md's reading order, llms.txt and llms-full.txt. It:

  • separates the three things the issue asked to distinguish — declarative YAML config, project functions named from that config for lifecycle hooks, and the TypeScript a new extension needs — as a decision table and then a section each;
  • tabulates every supported --with combination and every refusal;
  • documents per-package hook input, verdict, timing and failure semantics, which get_extensions does not expose (it gives the config/policy schemas only): activation fail-fast, sandbox: true rejected rather than silently run trusted, an explicit allow: true veto contract with 403 and the hook's reason, a thrown pre-action hook degrading to a generic 500, and post-action hooks running after the operation has committed;
  • uses only schema-valid YAML; scripts/check-guidance-claims.ts passes over it (194 Markdown files, 26 closed key sets).

It also records a gap found while writing it and confirmed by running the CLI: urlcode-ui builds its kit without the auth and admin namespaces the generated host registers, so list omits auth/* and admin/*, eject auth/sign-in is refused as unknown, copy --missing skeletons cover kit ids only, and doctor lists a project override of an extension template with no expected view model — its behind flag therefore cannot tell you an extension override has gone stale. The runtime path is unaffected, which is exactly what the new test proves.

Verified by running

npm run lint, npm run typecheck, npm run check, npm run build, npm test (531 pass, 1 pre-existing skip), npm run verify:workspaces (ui 197, auth, admin 63, workspace integration 2) — all green. Docs regenerated with npm run docs:llms.

Not established

No HTTP listener, TLS proxy, browser or deployed site was exercised; the render test runs in-process against the generated host. No published npm tarball was compared against this checkout.

Scope kept out

packages/ui/README.md's stale "auth/admin have not adopted the kit" sentence is left to #200. The UI primitive fallback is untouched — it was already removed by #220, and docs/OPEN-DECISIONS.md line 37 is now stale as a result, which belongs to that PR's follow-up rather than this one.

🤖 Generated with Claude Code

@jimhoyd
jimhoyd force-pushed the claude/issue-217-compose-overrides branch from ff09e01 to 4e681a7 Compare September 20, 2026 04:21
jimhoyd and others added 5 commits September 19, 2026 23:53
…217)

first: the wiring half is already done. #220 (d9d627f) made the ui scaffold
register authCatalogue/authUiTemplates/adminUiTemplates and pass the kit into
authExtension/adminExtension, so all three "observed source evidence" bullets
in the issue are stale. It also retired the UI primitive fallback, which means
the issue's "preserve standalone auth/admin without ui" requirement no longer
describes a supported configuration: those combinations now refuse at scaffold
time. Nothing here re-opens that decision.

What was missing was the demonstration and the documentation.

Generated-consumer regression (test/workspace-scaffold.integration.ts):
runs `init site --with ui,auth,admin` against the built packages, writes
ui/templates/auth/sign-in.html, ui/templates/admin/dashboard.html and
ui/copy/en.json into the generated site, bootstraps an administrator through
the generated operator module, creates a runtime from the extension array the
generated host.mjs exports, and asserts both the template and the copy
override appear on a rendered /account/login and a rendered /admin. Verified
to fail — not just compile — by removing adminUiTemplates from the ui
scaffold: the composition assertion fails and the render test fails at
activation. It skips, with the reason printed, when the host SQLite is not the
one auth's store requires. The same test now also pins ui-alone to
`sources: [], extensions: []` with no peer import.

A throwing onSignUp is covered in packages/auth/test/lifecycle-hooks.test.ts,
so the documented "post-action hooks cannot undo anything, keep them
non-throwing" rule is a tested property.

docs/COMPOSING-A-SITE.md is the new root document, linked from
docs/AI-AUTHORING.md's reading order, llms.txt and llms-full.txt. It separates
declarative config, project functions used for lifecycle hooks, and the
TypeScript a new extension needs; tabulates each supported --with combination
and each refusal; and gives per-package hook input, verdict, timing and
failure semantics read from the implementation (get_extensions exposes the
schemas but not these).

It also records a gap found while writing it and confirmed by running the CLI:
`urlcode-ui` builds its kit without the auth and admin namespaces, so `list`
omits auth/* and admin/*, `eject auth/sign-in` is refused, `copy --missing`
skeletons cover kit ids only, and `doctor` reports a project override of an
extension template with no `expected` view model, so its `behind` flag cannot
detect a stale extension override. The runtime path is unaffected.

Not established: no HTTP listener, TLS proxy, browser or deployed site was
exercised, and no published npm tarball was compared against this checkout.
packages/ui/README.md's claim that auth/admin have not adopted the kit is left
to #200.

Co-Authored-By: Claude Opus 5 <[email protected]>
#220 merged and retired the UI primitive fallback, but the decisions table
still described the code as retaining "tested primitive rendering without it"
and recommended keeping both pending a decision. Verified against main:
packages/auth/src/auth.ts:71 now refuses activation without ui and says
outright there is no shared-primitive fallback, so the row was wrong about the
current code and contradicted the composition path this branch documents.

Moved to the closed-questions list rather than deleted, so the resolution stays
on the record.

Co-Authored-By: Claude Opus 5 <[email protected]>
CI's `static` job runs typecheck after `npm ci` but without a workspace build,
so `@jimhoyd/urlcode-auth` and `@jimhoyd/urlcode-admin` have no type
declarations there and the two literal dynamic-import specifiers failed with
TS2307. It passed locally only because this worktree had the packages built.

The specifier is now computed, which TypeScript does not resolve. Verified the
mechanism rather than assuming it: a literal `import('@not/installed-anywhere')`
reports TS2307 under the same compiler settings and the computed form reports
nothing. Runtime resolution is unchanged and verify:workspaces still passes.

Co-Authored-By: Claude Opus 5 <[email protected]>
The new override test failed on Windows with EBUSY unlinking
site/data/auth.sqlite-wal, then hung until the job was cancelled at ten
minutes.

Cause: node:test runs after-hooks in registration order, and the project()
helper registers its own directory removal first. The auth store's closes are
registered later in the test body, so the directory was removed while SQLite
still held the WAL open. POSIX unlinks an open file without complaint, which is
why this passed everywhere except Windows.

This test now takes its own mkdtemp and registers the removal last, after the
host and runtime closes. The first test in the file keeps project(): it opens
no store, so the helper's ordering is fine there.

Not established: I could not reproduce the EBUSY locally, having no Windows
host. The ordering defect it reports is real and reproducible by inspection --
the removal genuinely ran first -- but only the Windows CI leg can confirm the
fix.

Co-Authored-By: Claude Opus 5 <[email protected]>
#229 gave `urlcode-ui` an `--extensions` option: it resolves the named
packages from `--project` and loads the namespaces they ship, so `list`,
`eject`, `preview`, `doctor` and `copy --missing` cover `auth/*` and `admin/*`
as the host that registers them does.

This page still described the gap as current, and its example commands omitted
the flag, so a reader following them would reproduce the old behaviour and
conclude the tooling was broken. The section now describes what the CLI does,
including the `extensions` field in the `doctor` report and why admin-owned
`adminUi.*` ids are deliberately absent from `copy --missing` (#227).

Co-Authored-By: Claude Opus 5 <[email protected]>
@jimhoyd
jimhoyd force-pushed the claude/issue-217-compose-overrides branch from 0d4bd2a to f2c839d Compare September 20, 2026 04:56
@jimhoyd
jimhoyd merged commit 3d74146 into main Sep 20, 2026
20 checks passed
@jimhoyd
jimhoyd deleted the claude/issue-217-compose-overrides branch September 20, 2026 05:04
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.

[Request]: Wire UI customization into composed auth/admin scaffolds and document the AI authoring path

1 participant