build(packaging): retain qualified payloads through verified owner archives

This commit is contained in:
DCCONSTRUCTIONS
2026-11-21 20:58:24 +03:00
parent bd8af772d9
commit c45bd6b882
14 changed files with 1241 additions and 33 deletions
+72 -1
View File
@@ -17,6 +17,7 @@ run at publication; service journal rotation runs in the owning writer.
| Imported Gaussian worlds, recordings, evidence, missions, plans, accepted maps, session map versions | Durable application data. No TTL. Deletion belongs to the owning product workflow or an explicitly reviewed archive/removal operation. |
| Simulation qualifications, computation experiments/results, engineering materials | Preserve unique evidence and the exact input/configuration/result relationship. An old experiment is not a cache. Archive only with a verified destination and complete dependency inventory. |
| Qualified releases and rollback artifacts | Explicit pins; retain independently of the intermediate count. Retiring a release requires removing its pin by name and recording the reason. |
| Unpacked qualified `.deb` duplicates | Node/X4 owner builders automatically retire only their exact packaged payloads after atomic installer publication and full SHA-256 verification. The installer, qualification evidence and recovery pointer remain. Persistent consumer holds or an unavailable reader check defer cleanup. See qualified payload closeout below. |
| Intermediate Linux build inputs | Keep two most recently **published, completed, unpinned** inputs per line, plus every transitive base of retained inputs. Lines are `node/node-only`, `node/node-core`, `x4/native`, `x4/package`, `x4/owner`. Enforced by `scripts/packaging/build_retention.py`. |
| Active/disconnected builds, transfers and qualifications | Persistent active hold, with owner token. No automatic expiry. Explicit terminal outcome releases the hold. Eight unfinished inputs per archive family block the next publication. Node profiles share this conservative unfinished limit. |
| Old or unknown inputs | Protected as `legacy-unreviewed`; importing into the registry requires a named protective pin. Neither mtime nor lack of a reference proves that a legacy file is disposable. |
@@ -102,7 +103,7 @@ build log. All unknown inputs remain protected even without registry enrollment.
## Integrity, interruption and audit
Only exact build-input filenames directly under `apps/node-agent/build` and
For `build_retention.py`, only exact build-input filenames directly under `apps/node-agent/build` and
`plugins/insta360-x4/build` are eligible. Installers, `.deb` releases, qualified
subdirectories, rollback copies and runtime data are outside the allowlist.
Symlinks and traversal paths are refused. Publications and maintenance share an
@@ -132,6 +133,76 @@ presence and verified identity.
space: hardlinks/APFS clones can share blocks. Receipts report filesystem free
space before/after; concurrent system activity can affect that delta.
## Qualified payload closeout (2026-11-16)
The owner installer builders previously kept both their `.pyz` installer and
all loose `.deb` files. Input-bundle retention cannot remove these: qualified
directories deliberately sit outside its allowlist. The separate
`scripts/packaging/qualified_payloads.py` now owns this narrow output lifecycle.
It is called by the Node and X4 `build_owner_release.py` entry points; the X4
standalone Ubuntu builder carries the same helper inside its verified bundle.
It does not change the Linux input-bundle policy, installed software, runtime
data, project sources, Worker storage or retained installers.
Publication and closeout share OS locks. The builder writes a private temporary
installer, flushes it and atomically publishes without replacement. A recorded
interrupted publication can remove only its own temporary inode on the next
invocation. An existing installer is reused only if every member matches.
Before any loose payload is removed, the helper verifies the complete installer
SHA-256, each archived member, the qualification report and all loose candidates.
It durably records member names, sizes and hashes in `PAYLOAD_LOCATION.json`.
Only the exact `.deb` members admitted by that builder are eligible. Unknown
files, directories, legacy pointers without managed membership, symlinks and
changed evidence never become cleanup candidates. Hardlinks are handled without
removing another owner's path. Logical bytes are not a physical-space guarantee.
The pointer journals each unlink and the final result. If the process stops
between unlinks, retry validates the retained archive and finishes the remaining
paths. There is no age-based sweep or background timer. Normal successful
publication closes out automatically; deferred/interrupted work is retried by
the same builder, explicit `retry`, or release of a consumer hold. The builder's
JSON includes `payload_cleanup` (`complete` or `deferred` with a reason).
`QualifiedPayloads.read(name)` reads a still-present package or its verified
installer member, without recreating a persistent copy. Both owner builders use
this path, including repeated/concurrent packaging after closeout. The Node
Linux source generator also embeds the retained X4 package directly from verified
archive bytes; `repack_runtime.py` reads its retained Node predecessor the same
way. Neither recreates a loose base package. Older
one-off repack scripts that directly open a `.deb` path must use this API or
register a hold **before** installer publication. They are not silently made
archive-aware. The historical v1 recovery pointers created by the reviewed
one-time cleanup remain readable and are not automatically enrolled for deletion.
A dependent consumer spanning multiple commands uses a persistent named hold.
Under the canonical repository, set `qualified_dir` to its exact qualification
directory and `archive_dir` to `apps/node-agent/build` or
`plugins/insta360-x4/build` (canonical absolute paths):
```sh
.venv/bin/python scripts/packaging/qualified_payloads.py hold \
--repository "$PWD" --archive-root "$archive_dir" --qualified "$qualified_dir" \
--owner "dependent transfer/qualification"
# Retain the returned token; after that consumer is confirmed terminal:
.venv/bin/python scripts/packaging/qualified_payloads.py release \
--repository "$PWD" --archive-root "$archive_dir" --qualified "$qualified_dir" \
--token "$payload_token"
```
Holds survive restarts and never expire. Releasing the final hold runs closeout.
An open reader detected by `lsof`, a missing `lsof` executable, a timeout or an
ambiguous reader-check result defers removal while preserving the installer and
loose payloads. After resolving the condition, use `retry` with the same three
path arguments. Do not force-delete the files or another consumer's hold.
`tests/test_qualified_payloads.py` exercises real Node/X4 builders using tiny
payloads, concurrent/repeated publication, the standalone isolated X4 entry,
reader deferral, persistent holds, modified evidence, publication failure,
interrupted deletion, pointer-write failure, hardlinks and unsafe paths. No
production rebuild or Core service restart is needed for this operator-script
change; it takes effect on subsequent owner packaging.
## Acceptance
`tests/test_build_retention.py` covers separate lines, transitive bases, release