Repository navigation
feat(store): add the local template package store - #248
Conversation
Add P2 of #236: resolve UVP_TEMPLATE_HOME/~/.uvp/templates, read a package directory into the observations the domain validator asks for, import atomically through .tmp with a lock, list/get with corruption reporting, replace an id@version only with an explicit flag, remove through quarantine, and admit an unverified package only when allow_unverified is set (Q6). The id@version pair is immutable (Q9). No tool contract, search, export, or network call is introduced. Refs #236. Assisted-by: Claude Code (direction-lead)
Review —
|
The import renamed the staged tree into place and only then wrote the store metadata. If that write failed, the caller was told the import failed while the package stayed in the store; for an unverified package the next get re-validated strictly and refused the package the import had just admitted. Stage the metadata before moving any tree so an unwritable metadata directory fails while the store is untouched, and publish it after the rename. If publication still fails, remove the new tree (fresh import) or restore the previous tree from trash (replace); a failed restoration is named rather than reported as a clean failure. Two tests pin both paths. Refs #236, #248. Assisted-by: Claude Code (direction-lead)
Re-review — the blocking finding is fixedReviewed the fix commit The approach is the one that closes the hole rather than hiding it: metadata is staged into I reproduced the original failure and two adjacent ones independently (throwaway probe, deleted afterwards;
The two new tests ( Non-blocking, from the first review (unchanged)The eight notes recorded above still stand as recorded; the fix does not touch them. The ones that matter most for later slices are still the unbounded whole-file read in Two small observations on the new code (my judgement, non-blocking)
I am marking this ready and approving it for the owner under today's standing authorization. |
|
Owner approval. Approved at Reviewed in this comment after the fix commit. No blocking findings: metadata is staged before any tree move, published by one rename after the tree is in place, and a failed publish now rolls back — new version removed, or the previous tree restored from The non-blocking notes from the first review stand as recorded and do not hold this change. #249 and #250 are stacked on this branch and will need retargeting to Merging as a merge commit at the exact reviewed head. Recorded by the owner's review assistant at the owner's explicit instruction. |
Summary
Part of #236. P1 (the
uvp.template/1schema and validator) landed in #244/#245; this is P2, the local store.It adds
src/application/TemplateStore.ts:UVP_TEMPLATE_HOME, else~/.uvp/templates.files/, per-file SHA-256, symlink/binary observations, per-file and total limits); the validator remains the owner of the format..tmp, re-validate the copy, stage the store metadata, then rename the tree into place and publish the metadata; a lock file serializes mutations. If publication fails after the rename, the new tree is removed (fresh import) or the previous tree is restored from.trash(replace), so a failed import leaves no package and a failed replace loses no version.id@versionis immutable; an existing pair is refused unlessreplaceis explicit. A replace moves the old tree to.trashbefore the new rename and rolls back on failure; a failed trash cleanup is returned asretained.corrupt[]list with the reader's problems;getre-verifies file bytes against the manifest.license/provenanceis admitted only withallowUnverified, markedunverified: truein store metadata and never presented as verified. The source manifest is stored as authored; the relaxed validation uses a patched copy only to check the rest. The shared registry ([Feature] Remote template registry client: search, sync, download, cache, provenance #239) does not use this path.replaceis explicit; no implicit overwrite.No tool contract, CLI/MCP surface, search, export, scan, registry, or network call is added; those are P3/P4/P5. Generated workspaces and
uvp.jsonare untouched.Contract and boundary impact
Evidence and regression coverage
src/application/TemplateStore.test.ts— 16 cases covering root resolution, import/list/get, duplicate/replace, byte tampering, unverified admission, non-licence problems underallow_unverified, missing README/LICENSE, unexpected top-level files, symlinks (skipped on Windows with the host reason), lock contention, corrupt entries, removal, and the two post-rename metadata failures (fresh import and replace).7b062a3:zipimport/export, search, the secret/PII scan, and the tool contracts are not in this PR (P3/P4/P5).not_foundfor one call; that is deliberate and reported, not retried into a stale answer.npm run check:prwas not run locally; CI runs it for this PR. The commands above are what ran here; no claim is made about lanes they do not cover.Review follow-up
The blocking finding in the review at
9672605— a failed metadata write after the tree rename left a package behind, and an unverified package then failed its ownget— is fixed at7b062a3. Metadata is staged before any tree move, so an unwritable metadata directory fails with the store untouched; if the final publication fails, the fresh tree is removed or the replaced tree is restored, and a failed restoration is named. Both paths have a regression test.Author readiness
Human owner: @Antruly
Before merge
Draft. The following are left for the owner and review; none is asserted here.
type(scope): outcome.