This document defines the compatibility and trust boundary for
format_version 1.
A StateCrate archive is a gzip-compressed POSIX tar archive:
statecrate/
manifest.json
manifest.sig
payload/
...
Only regular files and directories are permitted. Every payload member is listed exactly once in the manifest; the archive cannot contain unlisted payload members.
manifest.json is canonical UTF-8 JSON with sorted object keys, compact
separators, and one trailing newline. It contains:
format:"statecrate"format_version:1created_at: a timezone-aware ISO 8601 timestampentries: payload files and directoriesmissing_optional_sources: requested relative source paths that were absentmetadata: caller-owned JSON metadata
Each entry contains a relative POSIX path, kind, permission mode, expanded
size, and sha256. Directory entries have size zero and a null checksum.
Kinds are file, directory, and sqlite.
Paths cannot be absolute, contain .., overlap files with descendants, or
repeat another entry. Permission modes are limited to 0000 through 0777.
manifest.sig is canonical JSON containing the Ed25519 algorithm name, the
signer's public-key identifier, and a base64 signature over the exact
manifest.json bytes. The key identifier is sha256: followed by the SHA-256
digest of the raw Ed25519 public key.
The archive does not contain a trusted public key. A caller must provide one or more trusted keys to verification and restoration. This permits signing-key rotation without trusting data supplied by the archive itself.
The signature authenticates the manifest, and manifest hashes authenticate the payload. It does not encrypt the payload.
A conforming reader performs these checks before installation:
- Bound member count, names, manifest size, signature size, and expanded size.
- Reject links, special members, unsafe paths, and duplicate members.
- Verify the manifest signature with an explicitly trusted key.
- Validate the complete manifest schema and version.
- Require an exact match between manifest entries and payload members.
- Check every file's expanded size and SHA-256 digest while extracting.
- Run SQLite
PRAGMA quick_checkon every SQLite entry.
Resource limits are caller-configurable, with conservative defaults. A reader must not treat a higher format version as compatible unless support for that version is implemented explicitly.
Restoration recreates the payload beneath one caller-selected destination. StateCrate restores relative paths and ordinary permission bits. It does not restore ownership, special permission bits, timestamps, links, ACLs, or extended attributes.