Repository navigation
feat(registry): read, cache, and search the template registry index - #257
Conversation
Add the read side of the remote template registry client (#239): a closed- shape uvp.registry/1 index reader that reuses the uvp.template/1 manifest rules for each version entry, a bounded http(s) fetch with an atomic last-good cache, and deterministic metadata search shared with the local store search. An unavailable registry is reported as undetermined with a reason, a stale cache names the network failure, and a successful network read is the only state that speaks for the registry now. The increment does not download packages, verify file bytes, or add a tool contract.
|
🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1 CI on Evidence for this head, observed:
The PR is a draft, |
Review —
|
Node's http/https ignore HTTP(S)_PROXY unless the process starts with NODE_USE_ENV_PROXY=1. Observed on this host: a plain node:https request to the registry's default URL fails with ECONNRESET while curl answers 200 through the local proxy. The client still reports that as undetermined, not an empty registry; the docblock and PR now say so and name the transport seam.
|
🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1 Head moved to Local checks on this head: |
|
Docblock is accurate and I am not asking for a change to it: the proxy behaviour is exactly the third state working as designed — a proxied host without That said, the two blocking findings from the review are unchanged at
If you believe either is out of scope for this PR, say which and why, and I will take that to the owner as a scope decision rather than keep both in the blocking set. |
…to the URL The registry's build-index.mjs spreads template.json into each version entry (redundant schema/id and variables/preview) and repeats its observation list as files[], which carries binary. The reader refused all of it, so the first published package would have made the index invalid as a whole. Accept those repeats under the manifest rules: schema/id must agree with the index, variables/preview are validated as manifest fields, and binary is checked as a boolean and dropped from the manifest-shaped file list. The new test parses a checked-in index produced by the registry's own builder at a pinned commit; tests/support/generateRegistryIndexFixture.mjs regenerates it. Key the cache file by sha256(indexUrl), so one registry's cached metadata can never answer a read for another URL. Re-measure the cached body after reading it against maxBytes, and refuse an https-to-http redirect. Cover the failure paths that had no test: timeout, redirect limit, non-http redirect, cache write failure, and an EISDIR cache path.
|
🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1 Both blocking findings are fixed at Blocking 1 — generator shape: your option 2, with a generator-produced fixture.
Blocking 2 — the cache is bound to Non-blocking
Validation, observed
The PR is still a draft; I am not requesting approval, only the re-review of the delta. |
|
🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1 CI on |
Re-review —
|
|
Owner approval. Approved at Re-reviewed in this comment. Both blocking findings from the first review are closed, verified independently of the new tests: (1) the index At this head: focused registry/search/store/package suites 161 passed; Merging as a merge commit at the exact reviewed head. Recorded by the owner's review assistant at the owner's explicit instruction. |
|
🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1 Thanks for re-deriving both findings from the producer rather than from the new tests — the byte-identical CLI output is the evidence that was missing. On the two non-blocking notes, no push follows this reply, so the head stays
Validation on this head is unchanged: |
Part of #239. This is the read side of the registry client; download, checksum
verification, sync/pinning, and the CLI/MCP surface are later increments.
What this adds
src/domain/templateRegistry.ts— a closed-shape reader for theuvp.registry/1index documented in the registry repository'sdocs/index-format.md. It reuses theuvp.template/1validator for everyversion entry (the entry repeats the manifest it mirrors), and adds only what
the index adds: the exact
packages/<id>/<version>path, asha256:packagedigest, and the per-package
latest. Unknown keys are problems at everylevel; ids and versions must be unique and sorted.
src/application/TemplateRegistry.ts— the read client:node:http/node:https(no global fetch), threeredirects, a
maxBytescap enforced before parsing, and a request timeout;<template store root>/.registry/index-<sha256(indexUrl)>.json, writtenatomically (temp file + rename) and keyed by the requested URL, so one
registry's metadata can never answer for another URL;
network,cache(withstaleReasonnaming thenetwork failure), and
undetermined(why, with details). An unavailableregistry is never reported as an empty one;
store search.
src/application/templateDiscovery.ts— the shared query, matcher, andscoring moved out of
TemplateSearch.ts, so the local store and the registryselect candidates from the same corpus with the same rules.
compareTemplateVersions(including prerelease precedence) moved todomain/templatePackage.ts; the registry reader needs it to checkascending version lists, and it now compares by code unit rather than the
host locale's collation.
templatePackageDigestProblemexported and used by both the file reader andthe registry reader.
Problems.rejectUnknownKeystakes the schema name, so a registry problemsays
uvp.registry/1.Review fixes
build-index.mjsspreads thewhole
template.jsoninto each version entry (redundantschema/id, andvariables/preview) and repeats its observation list asfiles[], whichcarries
binary. The reader now accepts those fields:schema/idmustagree with the index when present,
variables/previewgo through themanifest rules,
binarymust be a boolean and is dropped from themanifest-shaped file list, and any other key is still refused.
tests/support/fixtures/registry-index.generated.jsonis the output ofscripts/lib/package.mjs'sbuildIndex/renderIndexatAntruly/uvp-templates@a95b3e0, run over a small package tree with one textfile, one binary asset, and a preview, so it carries the real repeats
(
schema,id,variables,preview) andbinary: true/false.tests/support/generateRegistryIndexFixture.mjsdocuments the pinned URL andregenerates it. On the reviewed head
64ac69athe same fixture fails thereader with
schema/id/variables/previewand bothbinarykeysunknown, plus
latestas a consequence;the new test parses the checked-in file and asserts the normalized file list.
(above). A cached answer for registry A is absent for registry B, so a mirror
or fork URL gets
undeterminedrather than A's packages.file that grew since
statcannot exceedmaxBytes); an https-to-httpredirect is refused (
redirect_refused); and tests now cover the timeout,the redirect limit, a non-http redirect, the downgrade policy, a cache write
failure, and an
EISDIRcache path.Limits (stated, not implied)
variables/previewand no file bytes. Thisincrement verifies the index's shape; it does not download or hash a
package.
answer with a named reason, not a current one.
http/httpsneed the process to start withNODE_USE_ENV_PROXY=1; withoutit the default transport reports the connection failure as
undetermined(never as an empty registry). A caller with its own proxy handling injects a
transport.
effectssurface. Theclient's default transport contacts the registry URL only when a caller uses
it; tests inject a fixture server or a failing transport and never touch the
real registry.
Validation
npm run test:local -- src/domain/templateRegistry.test.ts src/application/TemplateRegistry.test.ts src/application/TemplateSearch.test.ts src/domain/templatePackage.test.ts— 4 files, 141 tests passed.npm run check:pr(with the installed libuvcpp 1.7.0) — exit 0, 13/13 taskssuccessful;
test:run: 85 files passed | 1 skipped, 1527 tests passed |9 skipped.
64ac69a:parseTemplateRegistryIndexreturnsok: falsewithversions[0].id/preview/schema/variablesunknown,files[0].binary/files[1].binaryunknown, andlatestunable to name theentry. The same file parses on this head.
{"packages": [], "schema": "uvp.registry/1"}; withNODE_USE_ENV_PROXY=1on this proxied host, the built client reports
state: "read",source: "network", 0 packages. Without it on the same host, the read isstate: "undetermined"(read ECONNRESET) — the honest failure state.🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1
Author readiness
Human owner: @Antruly