111 lines
7.1 KiB
Markdown
111 lines
7.1 KiB
Markdown
# Private indexed artifact adapter v0
|
|
|
|
This is an implementation protocol under development, not a frozen artifact API.
|
|
The caller authenticates the exact OSTree commit against its configured remote and
|
|
creates a protected checkout. The service then verifies it natively:
|
|
`artifact::inspect` runs `check::verify`, which reads and hashes the checkout itself,
|
|
and converts the result with `artifact::read_checked`. No JSON index is accepted from
|
|
another process. `artifact.py` remains the equivalent checker for the Python overlay
|
|
build adapters that still run inside the build sandbox; it is not on the service path.
|
|
Neither checker authenticates commits nor executes layer code, and Rust validates the
|
|
Layer v1 manifest before using the result.
|
|
|
|
## Metadata
|
|
|
|
All metadata is UTF-8 JSON with unique object keys. Floating-point values,
|
|
nonfinite numbers and boolean substitutes for integers are rejected.
|
|
|
|
- `metadata/manifest.json`: Layer v1 manifest.
|
|
- `metadata/lock.json`: `version: 0`, `manifest_sha256`, `packages_sha256`,
|
|
`files_sha256` (hashes of exact metadata bytes), `snapshot_id`, `architecture`,
|
|
`requirements` (declared runtime package names), and `authored_sources` (source
|
|
names from manifest file entries mapped to SHA-256 of the source bytes).
|
|
- `metadata/packages.json`: `version: 0` and `packages` array. Each record has
|
|
`name`, `version`, `architecture`, `identity`, `archive_sha256`, `dependencies`
|
|
(resolved package names), and `alpm: metadata/alpm/<identity>`.
|
|
- `metadata/files.json`: `version: 0` and `objects` array. Each row has `source`,
|
|
`path`, `package` (contribution identity or null), and `object`.
|
|
|
|
Objects contain `kind`, integer `mode`, `uid`, `gid`, and `xattrs` (names to
|
|
lowercase hexadecimal bytes). Files additionally have `sha256`; symlinks have
|
|
literal `target` and mode 0777. Directories have neither. Sources use
|
|
`payload/packages/<identity>/root/<target>` or `payload/files/root/<target>`.
|
|
Targets are canonical `/usr/...` paths excluding `/usr/local`. Namespace parent
|
|
directories can be implicit; contributed objects must be indexed.
|
|
|
|
Every layer-authored object must correspond one-to-one to `spec.files`, including
|
|
type, mode and symlink target. The private Arch path profile maps `/bin` and
|
|
`/sbin` to `/usr/bin`, `/lib` and `/lib64` to `/usr/lib`, and `/etc` defaults to
|
|
`/usr/etc` before checking declarations. Normalization collisions fail. File bytes
|
|
must match `authored_sources`. Currently only root/root authored ownership is
|
|
supported; other identities fail pending locked resolution evidence. Authored
|
|
xattrs are rejected until an explicit declaration/evidence adapter exists.
|
|
|
|
## Package contribution identity
|
|
|
|
Original `desc`, `files`, and `mtree` bytes live in `metadata/alpm/<identity>/`.
|
|
The contribution identity hashes UTF-8 JSON serialized with sorted keys, compact
|
|
separators and unescaped Unicode. Its fields are `name`, `version`, `architecture`,
|
|
`archive_sha256`, sorted `dependencies`, `alpm` (each of those three filenames
|
|
mapped to its byte SHA-256), and `objects` (records containing `path` and `object`,
|
|
sorted by target path). Source paths are omitted to avoid self-reference.
|
|
This private canonicalization is not a substitute for the public JCS contract.
|
|
|
|
The checker verifies original ALPM name/version/architecture and every indexed
|
|
object. Dependency resolution, original-to-effective ALPM transformations,
|
|
kernel/ABI checks, whole-package replacements and finalization still require
|
|
integration before the artifact can produce an installed deployment.
|
|
|
|
Fixtures exist twice: `tests/artifact.py` validates the Python checker used by the
|
|
build sandbox and must run as root (payload ownership is verified against uid/gid 0),
|
|
while the Rust `check::tests` suite runs in the normal release pipeline and covers
|
|
the same acceptance and rejection cases through `artifact::inspect`.
|
|
Compilation and Python syntax checks alone are not runtime acceptance.
|
|
|
|
## Effective database adapter
|
|
|
|
Private layer locks may additionally carry `requirement_bindings`, an array of
|
|
`{requirement, package}` from isolated libalpm resolution. Each declared runtime
|
|
name plus its exact constraint must occur once; the selected provider must exist
|
|
in the package index, and the resolved provider set must equal `requirements`.
|
|
This preserves virtual-package choices without rewriting the manifest. Structural
|
|
validation does not prove libalpm version/provider conformance: the isolated
|
|
resolver and subsequent effective database checks remain mandatory.
|
|
|
|
The optional private `inherited` package field binds retained legacy base records:
|
|
`adapter: legacy-managed-base-v0`, `hashes` of desc/files/mtree, a `lifecycle` map
|
|
from canonical paths to original runtime spellings, and `absent` immutable paths.
|
|
These sets are disjoint from effective and explicitly removed paths. All original
|
|
paths must still be accounted for. The adapter verifies record hashes, retains
|
|
the inherited file-list and backup entries, and expands flat ALPM mtree defaults
|
|
when retaining their original mtree entries. It neither creates lifecycle objects
|
|
nor reads their state from the live host. Inherited absent paths must remain absent
|
|
before finalization; the explicit post-finalization transition is described below.
|
|
The ledger records inherited evidence separately from composition deletions.
|
|
After successful offline finalization the service sends a separate request with
|
|
`finalizer_sha256`. Previously absent immutable paths that now exist are emitted
|
|
as effective objects with fresh mtree/backup metadata and `generated` provenance
|
|
bound to that finalizer. Before that phase their presence is an error. Lifecycle
|
|
paths never use this transition. The original request and original records remain
|
|
unchanged.
|
|
This preservation adapter does not implement lifecycle actions for new overlay
|
|
packages, and requires real pacman conformance checks in the normal pipeline.
|
|
|
|
`package_db.py ROOT OUTPUT REQUEST` creates a fresh output, never mutating a live
|
|
database. Its version-0 request has a `packages` array; records contain `name`,
|
|
`identity`, effective layer `owner`, protected original `record` directory,
|
|
integer install `reason` (0 explicit, 1 dependency), canonical image `paths`,
|
|
explicit `removed_paths`, and `path_owners` (each retained path to `{layer,package}`).
|
|
The two path sets must account for every original ALPM file-list entry after
|
|
Arch path normalization. Missing lifecycle adapters fail rather than silently
|
|
discarding persistent/package paths. Removed objects must actually be absent.
|
|
|
|
Output `local/` holds effective desc/files/mtree; `originals/<identity>/` retains
|
|
the original three records, and `transformations.json` binds original/effective
|
|
hashes, adapter identity, removed paths, effective object hashes/metadata and
|
|
content ownership independently of package ownership. Vendor defaults map back
|
|
to runtime `etc/`; backup MD5 values use effective default bytes. Mtree uses
|
|
numeric ownership, epoch mtimes and escaped literal paths/links. Its gzip stream
|
|
has timestamp zero. The service rebuilds this output after offline finalization.
|
|
This adapter still needs real libalpm/pacman acceptance and lifecycle-path adapters
|
|
for the existing full Core/Purpose images before it can stage a general composition.
|