Skip to content

feat(domain): add the uvp.template/1 manifest schema and validator - #244

Merged
Antruly merged 1 commit into
mainfrom
feat/236-template-package-p1
Oct 18, 2026
Merged

Antruly merged 1 commit into
mainfrom
feat/236-template-package-p1

Conversation

@Antruly

@Antruly Antruly commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Part of #236 — P1 of the template-package increments. Refs, not Fixes: the
local store, the directory/zip reader, search, rendering, and the tool contracts
remain open.

🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1

What this adds

Five pure domain modules, with no adapter, contract, or catalog change:

file owns
templatePackage.ts the closed vocabulary (categories, frameworks, placeholders), the limits, the SemVer 2.0.0 parser, the requirement-range spelling, the portable-path rule, and the canonical manifest digest
templatePackageManifest.ts validateTemplatePackage: closed-key parsing, field rules, and the assembled manifest
templatePackageFiles.ts the declared files list and the two-way agreement with a reader's observations
templatePackageProblems.ts the collecting problem reporter shared by the readers
templatePackage.test.ts 86 tests over the accept/refuse rows and the observation boundary

The validator reports every problem in one pass and never throws, so an
importer can write a complete report before writing anything to disk.

Decisions recorded here

The maintainer confirmed Q1–Q5 in the working session: the store root is
$UVP_TEMPLATE_HOME, else ~/.uvp/templates; a package is a directory or a
.zip; v1 has placeholders only, no conditions; search returns metadata only,
default limit 20 with a truncated flag; the six tool names and effects are
accepted. This increment fixes only the manifest vocabulary those decisions
need; it adds no tool.

Q8 limits are provisional. These are named, documented, and changeable
before P2/P4 without a schema change:

limit value
files 512
one file 1 MiB
total 8 MiB
path length 240
name 80
description 2000
tags 20
id 64

What this deliberately does not claim

  • No filesystem access. Nothing is read or written; the caller supplies
    observations from a reader that listed files/.
  • No digest recomputation. A declared digest is compared with the
    observation only when the reader supplied one; an observation without a
    digest leaves the question unexamined, not answered.
  • No symlink or binary verdict unless observed. The same applies to the
    reader's symlink and binary flags.
  • No SPDX database lookup. license.spdx is checked for syntax only.
  • No range evaluation. requires ranges are accepted only in a comparator
    spelling this revision can state; comparing them to an installed version is
    a later increment.
  • No compilation claim. Whether a generated project builds is not
    established by validating its package.

Validation

  • npm run test:local -- src/domain/templatePackage.test.ts — 86 passed.
  • npx tsc --noEmit -p tsconfig.json — exit 0.
  • npm run lint — no findings in the new files.
  • oxfmt --check — clean on all five files.
  • npm run knip — no unused exports.
  • npm run check:pr — exit 0 at c6b1908: 13/13 tasks; 1370 passed and 66
    skipped (68 files passed, 11 skipped), with every skip naming its reason.
    This run had no libuvcpp installed, so the real-toolchain lanes skipped by
    name (uvp doctor found no libuvcpp) and the Windows-only lanes skipped as
    not a Windows host; it does not claim that coverage. The CI lanes on this PR
    are separate evidence and are still running.

Author readiness

Human owner: @Antruly

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

A template package is data: a closed manifest, a source tree under `files/`,
a README, a licence, and an optional preview. This adds the pure domain
half, with no store, filesystem write, network call, or tool contract.

The schema is closed and the vocabulary is shared: categories, frameworks,
the two placeholders a v1 package may declare, and the limits are exported
constants, so a later store and search read the same set rather than
re-spelling it. Paths follow Windows rules on every host, because a package
extracted on Linux may be built on Windows. Versions are full SemVer 2.0.0
values; requirement ranges accept only a comparator set this revision can
spell, and are not evaluated here.

Digests are over the RFC 8785 canonical manifest. The declared `files` list
and the reader's observations are checked against each other in both
directions; an observation that reports no digest, symlink flag, or
binary flag is left unexamined rather than read as success. The validator
reports every problem in one pass and never throws.

Refs #236
Assisted-by: Claude Code (Antruly-dev-1)
@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Review — feat(domain): add the uvp.template/1 manifest schema and validator

Reviewed at head c6b1908 against base be99c25 (the merge of #243). No blocking findings; six non-blocking notes below. This is the schema and validator only, and it stays inside its stated boundary: five pure domain modules, no reader, no store, no tool.

What I verified independently

  • The validator reads the whole document in one pass and does not throw. I probed it beyond the test file: a non-object manifest, unknown keys at every level, a traversal path, an invalid digest, an observation-only mismatch, and a manifest with no observations all return a result. canonicalize omits undefined object properties, so a JS caller's {spdx:"MIT", name: undefined} digests the same as {spdx:"MIT"} rather than throwing.
  • The closed schema is actually closed. Unknown keys are reported at the top level and inside license, provenance, requires, variables, and files; the variables vocabulary is exactly name/port and their types are pinned (slug/port).
  • Path rules are host-independent. Absolute paths, drive letters, ~, backslashes, control characters, Windows-reserved characters and device names, empty/./.. segments, and trailing dots/spaces are all refused; case-insensitive duplicate declarations are caught.
  • The two-way file agreement and its boundary. A declared-but-unobserved file, an observed-but-undeclared file, a size mismatch, a digest mismatch, a symlink, and a binary outside assets/ are each reported; an observation with only path/bytes is accepted without inventing a digest, symlink, or binary verdict.
  • The digest is canonical. Reordered keys digest identically; a changed field changes the digest; canonicalJson is RFC 8785 (identity.ts:66).
  • Gates at this head. npm run compile, npm run typecheck, npm run lint (no findings in the new files), npm run knip (clean), oxfmt --check (clean on all five), and npx vitest run src/domain/templatePackage.test.ts — 86 passed. CI: 15 pass, real-toolchain and Windows MSVC skipped for a domain-only change.

Non-blocking (my judgement)

  1. The schema is not documented outside these files. [Feature] Standard template package format and a local template store with AI-facing CRUD/search #236's first acceptance criterion is "A documented package schema", and grep uvp.template docs returns nothing — the format currently exists only as code comments and the PR body's limits table. This increment adds no way to consume a package, so nothing is broken today; but before P2 exposes package creation, a docs/ page with the field reference, the limits, and an example template.json would make the criterion true. It belongs with the schema while the rules are fresh.
  2. license.spdx says "identifier or expression" but refuses expressions. The type comment and the failure message both allow an expression, while SPDX_PATTERN (templatePackageManifest.ts:48) has no space, parenthesis, or AND/OR/WITH token. I probed it: MIT OR Apache-2.0 is refused, MIT+ is accepted. Either narrow the comment and message to "a single SPDX identifier", or accept the expression grammar. Existence is still unchecked, as stated.
  3. "The two lists against each other in both directions" holds only when observations are supplied. With no files observations, a manifest whose declared files do not exist returns ok: true with a digest. That is the honest answer to "validate the manifest", but the success type does not record what was examined, so a caller can read ok as "the package is valid". The header of templatePackageFiles.ts states the stronger claim unconditionally. A checked/observed marker on the result — or a narrower sentence — would keep the evidence boundary visible at the type level.
  4. Case rules are inconsistent between the two checks. Duplicate declarations and duplicate observations are detected case-insensitively, but an observation is matched to a declaration by exact case, so SRC/A.CC against a declared src/a.cc is reported as "'SRC/A.CC' is not listed in the manifest". If exact-case agreement is the intent (reasonable for a portable package), say so in the message; otherwise compare case-insensitively in both places.
  5. files[] paths are relative to files/, but a path starting with files/ is accepted. A manifest declaring files/src/a.cc passes and denotes <pkg>/files/files/src/a.cc. Not unsafe, but it misleads a reader that joins the paths naively; refusing a leading files/ segment would close the ambiguity.
  6. Some limits are hardcoded rather than named. The PR body says the limits are named and documented, but tag length 32 (readTags), author/revision 120, licence name 80, and SPDX 64 are literals inside the readers rather than TemplatePackageLimits fields. Minor, and changing them has no schema impact either way.

Two smaller observations, not worth a change on their own: 2026-02-31T00:00:00Z is accepted (Date.parse rolls it to 3 March) if strict calendar validity is intended; and free-text fields (name, description, author) accept control characters while paths refuse them.

I'll re-review if the head moves. The remaining notes are each a sentence or a validation predicate; none touches the assembled manifest or the digest.

@Antruly
Antruly marked this pull request as ready for review October 18, 2026 10:47
@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Owner approval. Approved at c6b190807467504b9f14d6f4a1bb82624b398ba2.

Reviewed in this comment. No blocking findings: the five modules stay inside the stated P1 boundary (no reader, store, or tool), and I verified the closed-key parsing, the path and limit rules, the two-way file agreement when observations are supplied, and the canonical digest — including probes beyond the test file. The six non-blocking notes recorded there (schema docs before P2, SPDX expressions vs the stated contract, the observation boundary in the success type, case rules, the files/ prefix, and hardcoded limits) do not hold the change.

At this head: npm run compile and npm run typecheck clean, npm run lint with no findings in the new files, npm run knip clean, oxfmt --check clean, and the focused suite 86 passed. All 15 applicable checks pass; the real-toolchain and Windows MSVC lanes are skipped for a domain-only change. Readiness is declared (Owned by @Antruly; author readiness declared.).

Merging as a merge commit at the exact reviewed head.

Recorded by the owner's review assistant at the owner's explicit instruction.

@Antruly
Antruly merged commit dd454a7 into main Oct 18, 2026
21 of 22 checks passed
@Antruly

Antruly commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Merged at c6b1908; thank you. The six non-blocking notes and the two smaller observations from the review are carried in draft PR #245 (fix/236-template-package-review-notes, head 1508f7c), since those commits were pushed after the merge. No change to the merged commit.

🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1

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