Task: SitePack Validator
Goal
Implement a validator for an unpacked SitePack package and a validator for the encrypted envelope header.
Input
- Path to the unpacked package (directory).
- Optional: path to
*.sitepack.enc.json. - Optional: path to
sitepack.volumes.json.
Package checks
- The root MUST contain
sitepack.manifest.jsonandsitepack.catalog.json. - JSON must be valid.
- Validate
sitepack.manifest.jsonagainstschemas/manifest.schema.json. - Validate
sitepack.catalog.jsonagainstschemas/catalog.schema.json. - All
manifest.artifactsMUST be present in the catalog. - For each artifact in the catalog:
- file at
pathexists; sizematches actual byte size;- if
digestis present, it matches filesha256.
- file at
- NDJSON artifacts: each line must be a valid JSON object.
- For known media types, validate each record against the matching schema:
- entity-graph ->
schemas/entity.schema.json - asset-index ->
schemas/asset-index.schema.json - config-kv ->
schemas/config-kv.schema.json - recordset ->
schemas/recordset.schema.json
- entity-graph ->
- Asset-index validation must support both single-blob and chunked assets:
- If
pathis present, the blob file must exist and matchsizeandsha256. - If
chunksis present, each chunk file must exist and match itssizeandsha256, and the assembled asset must match the top-levelsizeandsha256.
- If
- Enforce relations encoding for entities:
relationsMUST be an object mapping keys toLink[], where Link is a string or an object withrefand optionalmeta. - Unknown
mediaTypeMUST be skipped but MUST be logged.
Envelope checks
If a path to *.sitepack.enc.json is provided:
- JSON must be valid.
- Validate against
schemas/envelope.schema.json. - Check that
payload.payloadDigestexists and matchessha256:<hex>.
Volume Set checks
If a path to sitepack.volumes.json is provided:
- JSON must be valid.
- Validate against
schemas/volume-set.schema.json. - For each volume, verify
sha256andsizeof the volume file. - If encrypted with age, use the referenced envelope header to locate and decrypt the payload, or return a clear unsupported error.
- Unpack volumes in ascending index order into a temporary directory and validate the assembled package normally.
Report
Write reports/validate.json next to the package. Minimum structure:
{
"ok": true,
"errors": [],
"warnings": [],
"summary": {
"artifactsTotal": 0,
"artifactsValidated": 0,
"unknownMediaTypes": 0,
"ndjsonLines": 0
}
}
ok=falseif there are errors.- Use machine-readable codes and human-readable messages in
errorsandwarnings.