Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
Resolver R2: specs, semver, registry metadata with prefer-offline #
The design is design-a, with grafts from design-b, as recorded in the session scratchpad
(SYNTHESIS.md, design-a/). R1 landed the Tree (src/kernel/npm/tree.ts) and the
oracle (scripts/npm-oracle.mjs, tests/fixtures/registry/<case>/). R2 builds the pieces
the placement port (R3) calls. No placement yet: rt.install() behavior is unchanged.
Modules #
package.json: addsemver7.7.4 (the version npm 11.7.0 bundles) to dependencies. Import subpaths only (semver/functions/satisfies,semver/classes/range, ...), so esbuild bundles just those. Report the kernel bundle size before and after.src/kernel/npm/spec.ts: the npm-package-arg subset as design-a'sspec.tssketches it. It covers version, range, tag andnpm:alias (non-nesting), plus anunsupportedvariant for git, file, directory, url and workspace specs that names the spec in its error. AdddepValid(node, spec)as arborist's dep-valid has it, for registry specs. Parse once into a discriminated union and trust it inside.src/kernel/npm/registry.ts: today it holdsregistryTarballfor bundleMissing. It becomes the resolver's whole view of the network:manifest(spec) → Manifest. Fetch the abbreviated packument (Accept: application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*) and pick a version with a port of npm-pick-manifest 11 (dist-taglatestpreference, then highest satisfying, non-deprecated first, engines against the runtime's Node version). Read npm 11.7.0's bundled npm-pick-manifest under~/.volta/tools/image/npm/11.7.0/node_modules/and port it, citing the file.lockMeta(name, version): the per-version document (GET /<name>/<version>), cached without expiry, for the lockfile fields the abbreviated packument lacks (license, and whatever else the lockfile copies; check arborist's shrinkwrap.js for the list).- Prefer-offline. A stored packument is used whatever its age. The network is asked
only on a miss, or when picking from the stored copy finds no version for the spec;
that refetch uses
cache: "no-cache". Dedupe in-flight fetches per name. - Counts for the report: metadata
{ cached, fetched }. registryTarballkeeps working, through the same packument path.
src/kernel/npm/store.ts: a second cacheniw-npm-meta-v1for metadata, keyed by URL plus Accept. Keep the store a mechanical adapter; the policy lives in registry.ts.src/shared/platform.ts:NODE_VERSION, taken fromsrc/runtime/process.ts, which then imports it.
Tests #
The repo's only runner is Playwright, and its spec files run in Node and can import
src/ TypeScript directly. Use that for pure logic. Use the browser only where the
browser matters (Cache Storage, kernel worker fetches).
tests/npm-spec.spec.ts(Node side): parse cases, each with a literal expected union value, including aliases, tags,latest, prerelease ranges, scoped names and each unsupported kind.tests/pick-manifest.spec.ts(Node side): for each package in theconflict,honoandexpressrecordings (loadRecordingfrom scripts/npm-oracle.mjs), and each edge spec npm saw in the recordedpackage-lock.json,pickManifestreturns the version npm locked. That is the oracle. Add hand cases for deprecated-skipping, the engines preference and a tag that is notlatest.tests/registry.spec.ts(browser): withpage.routeserving recordings (Playwright intercepts kernel-worker fetches; that was checked), prefer-offline works:- a second
manifest()for a satisfiable spec makes zero requests even when the stored packument is old; - an unsatisfiable-from-cache spec refetches once;
- in-flight dedupe;
- counts. Exercise it through a small test-only path. Do not add test hooks to the public host API: if you need a kernel entry point, put it behind the existing message protocol and say why.
- a second
Rules #
- Bound every command with the process-group killer
/private/tmp/claude-501/-Users-nmoo-Developer-natemoo-re-node-in-wasm/ae560627-5f68-439d-bf61-330961fd4901/scratchpad/bound SECONDS cmd....perl alarmdoes NOT work here:nodeandnpmare volta shims that survive SIGALRM, and three agents stalled that way. Write long output to a file and read the tail, rather than piping intotail. - Never background a command and then wait on it.
- Playwright:
-c playwright.worktree.config.ts(port 8947, uncommitted), one spec file per command,bound 240and--global-timeout 220000. Rerun a live-registry "Failed to fetch" once with--last-failedbefore counting it. - Two or three verified commits. Imperative subjects in the repo's style. No Co-Authored-By
trailer, no AI attribution: check
git log -1 --format=%Bafter each commit and amend if one slipped in. Commit this brief with the last commit.