Skip to content

Declare ui before auth and admin in the generated scaffolds - #219

Closed
jimhoyd wants to merge 1 commit into
mainfrom
claude/relaxed-faraday-1f6d58
Closed

jimhoyd wants to merge 1 commit into
mainfrom
claude/relaxed-faraday-1f6d58

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Auth and admin render every screen through the ui kit, but the scaffold path never wired it. urlcode init <dir> --with auth,admin emitted authExtension({service, csrfKey, projectSha256}) and an extensions: block with no ui at all; --with auth,admin,ui declared ui last. The runtime activates extensions in the order urlcode.yaml declares them (Object.entries(declarations) in src/extensions.ts), so ui has to be declared first.

Closes the first two source-evidence items in #217.

What changed

Approach: auth's scaffold refuses, the way admin's already refuses a host without auth — no core change needed, since src/init-with.ts already composes in --with order.

  • packages/auth/src/scaffold.ts — scaffold() throws when ui is absent from names, and throws again when ui comes after auth. Host entry is now authExtension({service, csrfKey, projectSha256, ui}). initAuthentication composes ui's scaffold ahead of auth's (yaml, host, files, README section), so urlcode-auth init also emits a ui-first project; hostModule takes an array of results and releases in reverse.
  • packages/admin/src/scaffold.ts — the same two refusals for ui; entry is adminExtension({service, csrfKey, projectSha256, ui, authMount: '/account'}); initAdministration splices on the new auth marker and puts ui first in the generated document.
  • Tests — the four scaffold suites plus test/workspace-scaffold.integration.ts, which now runs --with ui,auth,admin and asserts three refusals: ui,admin (no auth), auth,admin (no ui), auth,admin,ui (ui last).
  • Docs — docs/EXTENSIONS.md, docs/FRAMEWORK.md, src/cli.ts usage, both package READMEs and llms.txt files, regenerated llms-full.txt.

A generated site now yields extensions: [ui.registration, authExtension({...ui}), adminExtension({...ui})] and declares ui → auth → admin.

Judgment calls, flagged explicitly

This makes ui mandatory for the auth and admin scaffolds. urlcode init --with auth and urlcode-auth init no longer produce an auth-only site. #217 says "preserve standalone configurations", so this cuts against that line of the issue. It is a deliberate tightening of the scaffold, not a runtime requirement: authExtension and adminExtension both still accept an absent ui at activation (ui?: UiHost), so a hand-written host without ui keeps working. If standalone auth scaffolding should be kept, the refusal is the one piece to drop — the ui-first ordering and the ui host argument stand on their own.

Not addressed here (still open under #217)

  • packages/ui/src/host/scaffold.ts still passes sources: [], so auth's and admin's English catalogues are not registered with the kit.
  • No generated-consumer regression demonstrating a local template or copy override reaching an auth and an admin screen.
  • The AI-authoring composition/override docs, and packages/ui/README.md still claiming auth/admin have not adopted the kit.

Verification

npm run verify at the repo root, exit 0: lint, typecheck, check (schema/reference/llms-full/cookbook-index/plugin generation all regenerated and clean), build, core 523 tests, then verify:workspaces — ui 57, auth 209, admin 69 — and test:workspace-integration (1). No assertion was weakened or deleted.

CI passing is not an independent security review.

🤖 Generated with Claude Code

Auth and admin render every screen through the ui kit, but the scaffold
path never wired it: `urlcode init --with auth,admin` emitted
`authExtension({service, csrfKey, projectSha256})` and an extensions block
with no `ui` at all, and `--with auth,admin,ui` declared ui last. The
runtime activates extensions in the order `urlcode.yaml` declares them, so
ui has to come first.

Auth's scaffold now refuses a request whose `names` omit `ui` or place it
after `auth`, the way admin's already refuses a host without `auth`; admin
refuses the same way. Both host entries take the `ui` object the ui setup
defines, and `initAuthentication`/`initAdministration` compose ui's
fragments ahead of their own so the single-package initializers produce the
same ui-first layout.

Closes the first two source-evidence items in #217. Not addressed here:
`packages/ui/src/host/scaffold.ts` still passes `sources: []`, so auth's and
admin's catalogues are not registered with the kit, and there is no
generated-consumer regression showing a local template or copy override
reaching an auth or admin screen.

Note: this makes ui mandatory for the auth and admin scaffolds, so
`urlcode init --with auth` and `urlcode-auth init` no longer produce an
auth-only site. That is a deliberate tightening, not a runtime requirement:
`authExtension` still accepts an absent `ui` at activation.

Verified with `npm run verify` at the repo root (exit 0): core 523, ui 57,
auth 209, admin 69 tests, plus test:workspace-integration.

Co-Authored-By: Claude Opus 5 <[email protected]>
@jimhoyd

jimhoyd commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #220, which retires the UI primitive fallback outright and includes this scaffold fix as a consequence of it.

The two arrived at the same approach independently — auth's scaffold refuses the way admin's already refused a host without auth, no change to core's contract, since ScaffoldRequest.names already carries the composed set in --with order. #220 additionally changes packages/ui/src/host/scaffold.ts, which this PR does not touch: without it the generated host still gets createUiExtension({..., sources: []}) with no peer templates, so admin refuses at activation for missing adminUiTemplates even once ui is declared first.

Not carried over, and worth picking up separately — these are real improvements #220 does not contain:

  • docs/EXTENSIONS.md and docs/FRAMEWORK.md — the --with ui,auth,admin ordering in the worked examples and layout walkthrough.
  • src/cli.ts — the usage banner line ([--with ui,auth,admin] … name ui first).
  • packages/auth/README.md, packages/admin/README.md, and both llms.txt files — ordering guidance for agents.
  • llms-full.txt — regenerated to match.

Nothing here is lost by closing; it is recorded above so a follow-up can take it.

@jimhoyd jimhoyd closed this Sep 20, 2026
jimhoyd added a commit that referenced this pull request Sep 20, 2026
Ports the documentation and CLI changes from #219, which is closed as superseded
by this branch. Auth and admin render only through the kit and the runtime
activates extensions in declaration order, so every documented invocation now
names ui first.

Two files #219 did not reach were stale the same way: DEVELOPMENT-PIPELINE.md
and CI-FOLLOWUP-2026-09-19.md both wrote `--with auth,admin,ui`, which is the
one order the scaffolds now refuse.

The admin README keeps this branch's wording rather than #219's: that PR
documented the host entry as `adminExtension({..., ui, authMount: '/account'})`,
while the code here emits `authMount` first.

Co-Authored-By: Claude Opus 5 <[email protected]>
jimhoyd added a commit that referenced this pull request Sep 20, 2026
…#220)

* Retire the UI primitive fallback; settle the provider execution model

Auth and admin each had two render paths: through the urlcode-ui kit when the
host supplied and activated the `ui` extension, and through shared primitives
otherwise. Every screen was tested twice. The kit path is now the only path.

`@jimhoyd/urlcode-ui` was already a required peer of both packages, so nothing
new needs installing; what changes is that the extension must be supplied and
active. Both refuse at activation, naming what is missing, rather than failing
per request. Activation order follows `urlcode.yaml` declaration order, not the
host array, so `ui` must be declared first -- the errors and docs say so.

Scaffolding follows: ui's scaffold reads the composed `names` and registers each
peer's copy and templates with the kit, auth's and admin's refuse when `ui` is
absent or ordered after them, and the standalone `init` paths compose the kit
themselves. Without this, every generated project would have thrown at boot.

Two defects surfaced on the way: admin wrapped its kit layout with a different
presentation context than it rendered with (`lang="en"` around translated copy),
and `initAuthentication` never created parent directories for nested scaffold
files.

Separately, the provider execution model is decided: projects using `function`
or `middleware` deploy as one trusted Node process. Per-route Lambda compilation
is declined, and the AWS/Vercel refusal is now a settled position rather than a
gap awaiting an adapter. Its spike is archived as the analysis behind that
decision, and the roadmap's stale middleware-package references are corrected --
that package was withdrawn, not migrated.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Name ui first in the scaffold docs and CLI usage

Ports the documentation and CLI changes from #219, which is closed as superseded
by this branch. Auth and admin render only through the kit and the runtime
activates extensions in declaration order, so every documented invocation now
names ui first.

Two files #219 did not reach were stale the same way: DEVELOPMENT-PIPELINE.md
and CI-FOLLOWUP-2026-09-19.md both wrote `--with auth,admin,ui`, which is the
one order the scaffolds now refuse.

The admin README keeps this branch's wording rather than #219's: that PR
documented the host entry as `adminExtension({..., ui, authMount: '/account'})`,
while the code here emits `authMount` first.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
jimhoyd added a commit that referenced this pull request Sep 20, 2026
#219 landed while this branch was open: `init --with` now names ui explicitly
and composes the kit into the auth scaffold, and `--with auth,admin` refuses
rather than emitting a project that throws at activation.

Resolved in favour of both changes. The auth scaffold keeps main's ui
composition and gains this branch's pin resolution ahead of mkdir;
`@jimhoyd/urlcode-ui` is a declared peer of auth, so the kit the scaffold now
emits is pinned by the same pass that pins auth itself.

The integration test's role expectation was written when nobody named ui and it
arrived only as a peer. The invocation now names it, so its role is genuinely
`extension`; the expectation and its comment are corrected rather than the
assertion weakened. No real composition reaches the peer role any more, so the
comment points at test/project-dependencies.test.ts, which covers it against
synthetic packages -- the first wording claimed `--with auth,admin` covered it,
which is wrong now that the case refuses.

Co-Authored-By: Claude Opus 5 <[email protected]>
jimhoyd added a commit that referenced this pull request Sep 20, 2026
#219 landed while this branch was open: `init --with` now names ui explicitly
and composes the kit into the auth scaffold, and `--with auth,admin` refuses
rather than emitting a project that throws at activation.

Resolved in favour of both changes. The auth scaffold keeps main's ui
composition and gains this branch's pin resolution ahead of mkdir;
`@jimhoyd/urlcode-ui` is a declared peer of auth, so the kit the scaffold now
emits is pinned by the same pass that pins auth itself.

The integration test's role expectation was written when nobody named ui and it
arrived only as a peer. The invocation now names it, so its role is genuinely
`extension`; the expectation and its comment are corrected rather than the
assertion weakened. No real composition reaches the peer role any more, so the
comment points at test/project-dependencies.test.ts, which covers it against
synthetic packages -- the first wording claimed `--with auth,admin` covered it,
which is wrong now that the case refuses.

Co-Authored-By: Claude Opus 5 <[email protected]>
jimhoyd added a commit that referenced this pull request Sep 20, 2026
) (#221)

* Record exact runtime and extension pins for generated applications

`urlcode init --with` resolved whatever extension packages happened to be
installed and wrote nothing about which versions those were, so a generated
site's reproducibility depended entirely on a manifest it did not have (#212).
The auth initializer wrote a package.json with no dependencies at all.

`init --with` now resolves core, every named extension and every package those
extensions declare in peerDependencies, validates the whole set against every
declared peer range, and writes a private package.json pinning each one at the
version actually resolved. An incompatible set or a missing required peer
refuses before the destination directory exists. `urlcode-auth init` pins this
package and its peers the same way.

Route-only `urlcode init` is unchanged and still writes no manifest; `--manifest`
opts a route-only project into pinning the runtime, and `--no-manifest` opts a
--with site out. `--pin <package>=<specifier>` records a local tarball or
checkout, and a package npm installed from a local path is detected from npm's
own install record and pinned by that path without a flag.

No package manager is ever run: producing package-lock.json remains an explicit
`npm install` the operator runs after reviewing the manifest, which the command
output, the generated README and the docs all say. There is no upgrade command,
and the docs say that plainly.

Range satisfaction is a small local implementation (comparators, ^ and ~ over a
complete x.y.z, || alternatives, npm's prerelease rule) because semver is a
devDependency here and core takes no new runtime dependency; unsupported range
syntax refuses rather than guessing. No extension implementation is imported:
only package manifests are read, by name.

Verified: npm run lint, npm run typecheck, npm run check and npm test (530
tests) pass, as do npm run test:workspace-integration against the real built
auth/admin/ui packages and the auth package's scaffold suites and typecheck.
Not verified: no actual `npm install` of a generated manifest was run (that
needs a registry or a published tarball), and the auth package's full test
suite was not run.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Fix the two CodeQL findings in the new dependency code

CodeQL is a required check and it caught two real defects this branch
introduced.

js/polynomial-redos, src/project-dependencies.ts: `manifestName` trimmed with
/^[._-]+|[-._]+$/, whose anchored trailing quantifier is retried from every
start position -- quadratic on a directory name of many dashes, and the input
is a path the caller supplies. Trimmed with indices instead. Verified
behaviour-identical on ten cases spanning the previous regex's branches, and
60k dashes now trims in about a millisecond.

js/incomplete-sanitization, test/project-dependencies.test.ts: the expected
message was built into a RegExp escaping only dots. A version can carry
prerelease and build punctuation, so it now escapes every metacharacter.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Rebase onto the ui-first scaffolds

#219 landed while this branch was open: `init --with` now names ui explicitly
and composes the kit into the auth scaffold, and `--with auth,admin` refuses
rather than emitting a project that throws at activation.

Resolved in favour of both changes. The auth scaffold keeps main's ui
composition and gains this branch's pin resolution ahead of mkdir;
`@jimhoyd/urlcode-ui` is a declared peer of auth, so the kit the scaffold now
emits is pinned by the same pass that pins auth itself.

The integration test's role expectation was written when nobody named ui and it
arrived only as a peer. The invocation now names it, so its role is genuinely
`extension`; the expectation and its comment are corrected rather than the
assertion weakened. No real composition reaches the peer role any more, so the
comment points at test/project-dependencies.test.ts, which covers it against
synthetic packages -- the first wording claimed `--with auth,admin` covered it,
which is wrong now that the case refuses.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
@jimhoyd
jimhoyd deleted the claude/relaxed-faraday-1f6d58 branch September 22, 2026 14:26
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.

1 participant