Skip to content

Record exact runtime and extension pins for generated applications (#212) - #221

Merged
jimhoyd merged 3 commits into
mainfrom
claude/pin-generated-dependencies-212
Sep 20, 2026
Merged

jimhoyd merged 3 commits into
mainfrom
claude/pin-generated-dependencies-212

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Closes #212.

What changed

New src/project-dependencies.ts. Resolves the running runtime, every extension named in --with, and every package those extensions declare in peerDependencies (so @jimhoyd/urlcode-ui is pinned for an auth,admin site although nobody named it). It validates the whole set against every declared peer range and renders a private package.json with exact pins. Only package manifests are read, by name, through a plain node_modules walk — no extension implementation is imported and nothing in a resolved package is loaded or executed.

urlcode init --with now writes that manifest by default, after refusing an incompatible set or a missing required peer before the destination directory exists. The site README gains a ## Dependencies section, and the install step is the first numbered next step.

urlcode init is unchanged: route-only initialization still writes no manifest. --manifest opts a route-only project into pinning the runtime; --no-manifest opts a --with site out.

--pin <package>=<specifier> records an operator-chosen specifier (local tarball, checkout, mirror). A package npm installed from a local path or tarball is also detected from npm's own install record (node_modules/.package-lock.json) and pinned by that absolute path with no flag, with the README stating that such a pin only reproduces where the path exists.

urlcode-auth init (packages/auth/src/scaffold.ts) previously wrote {name, private, type} with no dependencies; it now pins itself exactly and each declared peer at the version installed beside it, returns those pins, and names any peer it could not resolve. Changeset included.

Docs: docs/EXTENSIONS.md (new "Recorded versions"), docs/VERSION-ALIGNMENT.md (new "Generated applications"), docs/STARTERS.md, regenerated llms-full.txt.

Range satisfaction is implemented locally (comparators, ^/~ over a complete x.y.z, ||, and npm's prerelease rule so 0.5.0-alpha.1 does not slip past <0.5.0) because semver is a devDependency here and core takes no new runtime dependency. Unsupported range syntax refuses rather than guessing.

Verified

  • npm run lint, npm run typecheck, npm run check, npm test — 530 tests, 0 failures (1 pre-existing skip).
  • npm run test:workspace-integration against the real built auth/admin/ui packages: the generated manifest pins core, auth, admin and ui at the workspace versions, and no node_modules/package-lock.json appears in the generated site.
  • packages/auth typecheck and its scaffold/scaffold-contract suites.
  • New test/project-dependencies.test.ts covers prerelease range rules, the set validation refusals, --pin, hidden-lockfile local specifiers, and every init flag combination.

Deliberately not done

  • No lockfile is generated by urlcode. The issue asks for a lockfile "generated through an explicit install step"; here that step is the operator's own npm install in the generated directory, printed by the command and the README. Core does not spawn a package manager — that would download and run code from a urlcode init, which this runtime's trust model keeps out of generation. If an opt-in --install flag that shells out to npm is wanted, that is a separate, reviewable change.
  • No upgrade command, and none is implied: docs/VERSION-ALIGNMENT.md and the generated README both say plainly that it does not exist and that changing a pin means editing the manifest and re-installing.
  • Not established: no generated manifest was actually installed end to end (that needs a registry or published tarballs), so "these pins install cleanly" is checked against declared metadata, not against a real resolution. The auth package's full test suite was not run — only its scaffold suites and typecheck.

🤖 Generated with Claude Code

Comment thread src/project-dependencies.ts Fixed
Comment thread test/project-dependencies.test.ts Fixed
@jimhoyd
jimhoyd force-pushed the claude/pin-generated-dependencies-212 branch 2 times, most recently from b2f1865 to fa27ff8 Compare September 20, 2026 03:59
jimhoyd and others added 3 commits September 19, 2026 23:09
`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]>
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]>
#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
jimhoyd force-pushed the claude/pin-generated-dependencies-212 branch from fa27ff8 to b148e52 Compare September 20, 2026 04:11
@jimhoyd
jimhoyd merged commit 4352e87 into main Sep 20, 2026
20 checks passed
@jimhoyd
jimhoyd deleted the claude/pin-generated-dependencies-212 branch September 20, 2026 04:18
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]: Provide consistent exact dependency pins for generated consumer projects

2 participants