# Preserved local operational workflows

Recurring host and local proof drivers are versioned in `linux/scripts/local-proof/` and
`linux/host-config/`. Extend the canonical script before its next use. Keep invocation JSON,
source snapshots, extracted probe inputs, output, receipts and superseded script bytes under
ignored `logs/`; those directories are evidence, never the sole home of recurring functionality.

The checked-in [inventory](../linux/scripts/local-proof/inventory.json) maps the session's old
toolkit to canonical files and records the original SHA256. Superseded versions, exact patch
recipes and historical checkpoint writers stay with their evidence. New checkpoints use the
shared driver below. The inventory does not authenticate a receipt or enumerate every file
generated by a build.

## Closed direct-wrapper preflight receipts

For an already closed direct owned-wrapper run, use `python3 linux/scripts/local-proof/complete-direct-preflight.py --directory RUN --reference PRIOR_COMPLETE_PROOF`. It reads the original invocation, strict stopped mutation seal, raw command/cache statuses, exact log slice and independent committed source snapshot. Every canonical group and discovered suite must appear once; discovery retains the unchanged canonical runner's literal library exclusions and regular-file requirement, including its non-runnable harness; the original cleanup identity, readonly source mount, empty filters and final report permissions must match. Fresh successful full-CID and ownership-label queries precede an exclusive receipt write. Failed queries retain diagnostics and refuse acceptance. This does not rerun sealing or cleanup, create a driver `run.json`, authenticate evidence, or prove images, packages or hardware. Preserve the complete helper tree beside this entry.

## Commands and ownership

| Repeated operation | Canonical entry points |
|---|---|
| Append reviewed operational notes while preserving the exact prior bytes | `linux/scripts/append-operational-memory.py` with its two `operational_memory` companions |
| Freeze and run every preflight group | `linux/scripts/run-isolated-preflight.py`; `local-proof/replay-full-preflight.py` reuses an explicitly supplied bounded unit profile |
| Compare exact finished Linux package binary members | `linux/scripts/verify_package_binary.py` for directories/TAR/DEB; `06-packaging/verify-native-appimage-binary.sh` for matching native AppImages; keep original producer/assembly provenance separate |
| Observe existing builds | `linux/scripts/watch-build-units.py`; `local-proof/observe-full-preflight.py` also checks the owned container and optional resource counters |
| Preserve current producer states in handoffs | `local-proof/checkpoint-proof-runs.py` |
| Extract and seal full preflight output | `local-proof/extract-preflight-mutator.py`, `seal-complete-preflight.py`, `complete-preflight-receipt.py`, `complete-direct-preflight.py`; these retain the canonical `seal-mutation-unit.py` boundary |
| Validate, commit and seal an exact source patch | `local-proof/seal-source-proof.py`, `launch-source-commit.py`, `seal-source-commit.py`; `docs-commit-profile.py` handles Markdown-only changes |
| Apply reviewed exact edits or archive whole changelog dates | `local-proof/apply-anchored-edits.py`, `archive-changelog-date.py` |
| Preserve independent committed consumer trees | `preserve-consumer-sources.py --checkouts DIR --plan PLAN --directory NEW_DIR` |
| Preserve exact staged consumer files and gitlinks over an explicit base | `preserve-consumer-sources.py --working-source ROOT --destination NEW_CHECKOUT --directory NEW_PROOF --revision FULL_SHA` |
| Inspect frozen Git roots and failed source checks | `local-proof/inspect-preserved-roots.py`, `audit-failed-source-check.py` |
| Prepare or admit an ordinary compiler and launch its SDK or qualified GPU child | `local-proof/prepare-next-compiler-plan.py`, `compiler_plan_profile.py`, `check-compiler-disk-admission.py`, `launch-normal-compiler-plan.py`, `launch-normal-sdk.py`, `launch-normal-gpu.py`, `normal_stage_launch.py`, `gpu_source_profile.py`, `nvidia_handoff_profile.py` |
| Retain a failed compiler's explicitly unverified prefix and bounded linker controls | `local-proof/compiler-prefix-diagnostic.py`, `launch-cross-clang-link-probe.py`, `probe-cross-clang-link.py`, `probe-cross-clang-link.sh`, `cross-clang-link-minimal.c` |
| Check baked compiler/SDK selection and native OCI ancestry | `local-proof/compiler-image-qualification.py`, `probe-cross-clang-image.py`, `native-oci-handoff.py` |
| Export a completed native GPU stage and launch required Media | `local-proof/gpu-oci-handoff.py`, `gpu_handoff_profile.py`, `nvidia_handoff_profile.py`, `launch-normal-media.py` |
| Prepare all six WebGPU Media command profiles before parent admission | `local-proof/webgpu_media_lanes.py`, `normal_stage_launch.py`; see [Media command profiles](linux-accelerator-images.md#six-webgpu-media-command-profiles) |
| Upload, accept and promote the Windows ARM64 bundle image by digest | `local-proof/windows-arm64-acceptance.py`; see [Accept an ARM64 image](windows-cross-builds.md#accept-an-arm64-image-before-moving-its-tag) |
| Launch default amd64 Media from the exact qualified SDK | `local-proof/launch-default-amd64-media.py`, `default_media_launch.py` and the existing SDK/OCI and stage-launch companions; see [default Media admission](#default-amd64-media-admission) |
| Replay Media profile controls plus the existing source protocol | `local-proof/run-media-lane-controls.sh PROOF_DIRECTORY SELECTED_MUTATIONS`; delegates to `03-media/build/migraphx/source-check.sh` inside the family image |
| Repeat explicit loader, wrapper, SDK-materializer and refusal controls | `local-proof/replay-native-llvm-loader-profile.py`, `seal-native-llvm-loader-replay.py`, `replay-native-clang-wrappers.py`, `replay-sdk-llvm-materialization.py`, `replay-cross-clang-refusal.py` |
| Seed and reverify a stopped producer's local cache in a fresh namespace | `local-proof/seed-buildkit-cache.py`, `buildcache_transfer.py` |
| Retain actual compiler cache evidence | `local-proof/extract-buildkit-vertex.py`, `inspect-buildkit-cache-log.py`, `capture-compiler-cache-log.py`, `capture-live-sccache-log.py`, `replay-sccache-log-capture.py`, `seal-sccache-log-capture.py` |
| Compare the GPU follow-up's compiler and selected script bytes | `local-proof/verify-amd-parent-identity.py` |
| Continue exact native Media through ordinary Android | `local-proof/media-oci-handoff.py`, `media_handoff_profile.py`, `launch-normal-android.py` |
| Continue same-target default Media through native Android | The same entries with `--variant default`, then `local-proof/android-oci-handoff.py` with `default_handoff_profile.py` |
| Continue verified native Android through ordinary local runtime | `local-proof/launch-normal-runtime.py`, `runtime_launch_profile.py`, `normal_stage_launch.py`; `owned-nerdctl.py`, `owned_nerdctl_args.py` and existing ownership/cleanup companions |
| Observe one live ordinary runtime and reclaim eligible regular layers | `linux/scripts/launch-runtime-storage-guard.py`, `runtime_storage_guard.py` |
| Bound full local FINAL consumers and seal owned cleanup | `linux/scripts/launch-local-final.py` |
| Prepare repeatable require-removal recipe data | `docs/scripts/generate_require_mutations.py`; merge through `docs/scripts/merge_mutation_recipes.py` |
| Snapshot rootless runtime identities and verify canonical cleanup | `linux/host-config/nerdctl-full-state.py`, `autonomous-safe-prune.py`, `verify-safe-prune.py` |
| Install or upgrade rootless nerdctl-full | `linux/host-config/install-nerdctl-full.sh` |
| Preview or remove explicitly reviewed unused QA environments | `linux/host-config/cleanup-qa-venvs.py`, `qa_venv_cleanup.py`, `qa_venv_usage.py`; reuse `relocate-quality-venv.py` validation |

`local-proof/` in this table means `linux/scripts/local-proof/`. Every launcher has explicit
inputs and `--help`. `capture-compiler-cache-log.py` is an image-side worker: its sole positional
argument is an existing output directory. Copy the required sibling scripts and C/C++ fixtures
together; the inventory lists the closure. The two `test-*.py` and two `mutate-*.py` drivers
preserve independent refusal fixtures and actual parse-valid guard mutations.

## Run artifacts and operational scripts

Preserve recurring operational scripts in the repo. The canonical implementation must be
Git-tracked; an ignored `logs/` copy is evidence only. Promote a recurring helper before its next
use, retain its required companions and parameterize run-specific inputs. This page's toolkit owns
the reusable proof, checkpoint and authorized cleanup drivers. Reuse and extend the canonical
helper; do not regenerate regular preflight, monitoring or probe drivers in scratch space.

Generated run artifacts belong under `logs/`, which Git ignores:

- `logs/build-logs/` for Linux stage logs and resource metrics;
- `logs/windows-build-logs/` for Windows BuildKit runs;
- `logs/test-results/` for Python test reports;
- `logs/code-quality/` for ty and annotation reports, mutation results and complexity metrics.

Live `chain-status*.json` stays at the repo root.

## Unused QA environments

The owner's standing authorization permits automatic removal of unused, reproducible QA virtualenvs and temporary test build directories. The helper below implements only ignored `quality/.venv` directories. Existing invocation-owned container cleanup handles its own temporary build outputs; this is no general directory deletion tool or recurring service.

Run `python3 linux/host-config/cleanup-qa-venvs.py --review REVIEW.json --root ABSOLUTE_ALLOWED_ROOT --protect ABSOLUTE_CURRENT_QA_ENV --protect ABSOLUTE_TOOL_CACHE --directory ABSOLUTE_NEW_PROOF_DIRECTORY`. The default is a dry run. The review must contain a nonempty `candidates` array of objects with literal absolute `environment` paths. Repeat `--protect` for required environments and caches; explicit protection is mandatory. Add `--authorization AUTHORIZATION.json --apply` to remove the selected environments. The record must declare scope `standing-automatic-cleanup-of-unused-reproducible-QA-outputs`, category `ignored-quality-venv` and the same `allowed_root`. This supplied record documents consent; the helper does not authenticate it.

Copy `qa_venv_cleanup.py` and `relocate-quality-venv.py` beside the entry, plus `linux/scripts/qa_venv_usage.py`, `linux/scripts/host_commands.py` and `linux/scripts/source_ci/common.py` in their original layout. Python optimization is refused because the shared validator uses assertions. Sources need `AGENTS.md`, `quality/uv.lock` and `quality/pyproject.toml`; Git must confirm the environment is ignored and unversioned. Embedded checkouts, shared regular-file inodes, special files, path aliases, overlapping protections and existing evidence refuse before deletion.

Fresh observations require terminal known build units with zero main/control PIDs, idle containers and BuildKit records, no selected-tree mounts and no owning-source references in current user process arguments, maps, working directories, executable paths or open descriptors. These are conservative current observations, not locks or a guarantee against concurrent writers. Unknown or failed observations refuse. Stop owned QA jobs before applying; never relax a refusal to reclaim space.

The worker records exact paths, full tree hashes, input hashes and owning Git/lock state, rechecks them immediately before each deletion, and retains an empty original mountpoint. Each completed removal gets a receipt; a later failure preserves partial evidence and cannot produce a passed receipt. Versioned sources, compiler/download caches, required images, packages, original archives, logs and the current shared QA environment remain protected. Before/after free bytes can include unrelated filesystem activity. Tests and mutations exercise disposable fixtures and fake host observations; they do not prove host idleness, build or runtime acceptance.

## Operational memory appends

Run `python3 linux/scripts/append-operational-memory.py --memory FILE --expected-bytes N --expected-sha256 SHA256 --append-file NOTES --directory NEW_PROOF_DIR` on the Linux host. Inputs must be single-link regular files; notes must be nonempty UTF-8. The destination proof directory must be new and its parent trusted and present. Copy both `operational_memory` modules, `host_commands.py` and `source_ci/common.py` beside the entry in their original layout.

The helper requires a successful user-systemd JSON query, validates each matching controller's identity and both PIDs, and scans readable process arguments for storage-guard and safe-prune names, including underscore spellings and ancestor processes. Missing, unreadable or unknown observations refuse the append. Terminal failed, inactive or exited services with both PIDs zero are allowed; process checks still apply. This is an observation of names and arguments, not authentication or a promise that another writer will remain idle.

Under a nonblocking file lock, it verifies the exact expected prefix, preserves exclusive byte-for-byte prefix and append snapshots, then rechecks prefix and inode before writing with `O_APPEND`. It verifies the entire resulting file, rechecks both saved snapshots and writes a passed receipt only after successful synchronization. Snapshot bytes are checked before writing too; a failed post-write check preserves the already extended memory and cannot produce a passed receipt. Short writes are completed; no failure path truncates memory or overwrites old evidence. Existing directories refuse. If a write or final receipt fails after an append, inspect the retained bytes before continuing: repeating the old expected prefix must fail. Other writers can ignore locks, rename or truncate files, and the file/proof updates are not one crash-atomic transaction. Fixtures and mutations prove these boundaries with synthetic services and files, not live-host controller absence or protection from hostile writers.

## Working consumer sources

The optional working-source command requires every tracked regular-file edit to be staged. It copies the selected committed base into an independent Git store, applies a binary patch from the source index, and verifies the complete index and actual file bytes, permissions and literal links. The original owner HEAD and selected base are recorded separately; neither is substituted for the staged overlay.

Committed, recursive and working copies retain every locally configured origin URL,
in its original order and with literal value boundaries. This keeps workflow repository
selection from seeing a local directory name such as `editor`. Copying uses local objects;
no remote is contacted. A source without a configured origin keeps the clone's local
reference. Existing copies are not silently rewritten on reuse; inspect their metadata
or prepare a fresh copy. Origin metadata does not authenticate the source or establish
workflow acceptance.

When permanent materialized copies consume the source reserve, keep a durable archive
and restore temporary independent checkouts with `restore-consumer-archive.py`.
Its schema-1 `archive.json` records the base, HTTPS GitHub origin, whether the original
is shallow, and SHA256 values for `base.bundle`, `working.patch`, `working-index.bin`
and `versioned-files.json`. Shallow originals also carry `original-shallow.bin`.
Create the bundle from the selected base, the binary patch and index from the staged
source, and file metadata through `preserve-consumer-sources.py:working_files`.
These native Git operations and the existing preservation APIs do not create a consumer commit.

Pass the expected manifest digest from the reviewed source plan:

```bash
python3 linux/scripts/restore-consumer-archive.py \
  --archive /durable/source-archive --expected-manifest-sha256 "$ARCHIVE_SHA256" \
  --destination /temporary/independent-checkout --receipt /evidence/source-restore.json
```

The helper checks every fixed archive input before allocation, restores only the exact
original shallow metadata before checkout, applies the staged patch and compares the
complete index and actual files, modes and literal links. Missing Git objects fail;
metadata paths and kinds must match the index before any file mode is restored.
Archive inputs are checked again before the receipt is written.
do not synthesize shallow boundaries to suppress that failure. A bundle verifier's
complete-history message alone does not prove the original has complete history.
Copy the helper with its preservation, host-command and `source_ci/common.py` companions.
The receipt covers the parent only; preserve and bind recursive dependencies separately.
Temporary materializations may disappear after reboot, so retain the complete durable
archive and restore it before reusing paths. Filesystem availability does not prove a
tmpfs user quota has room. The expected digest selects bytes; it does not authenticate
their producer, run a build or establish hardware acceptance.

A gitlink can have three different revisions: the selected base records A, the current index records B, and the actual child checkout contains C. The copy must retain B. Reading the working-tree diff would substitute C; ignoring submodules in the patch would omit B. The index-only patch avoids both errors. The unstaged regular-file guard may ignore submodule working-tree differences because actual child HEADs, indices and file trees require separate explicit bindings.

This mode does not initialize or recursively preserve child sources, authenticate a pin, or prove a build or inference. Preserve every used child independently and verify its binding before running a consumer. Existing committed-tree acceptance still requires exact recursive gitlink matches and clean sources. Temporary real Git controls exercise the staged/index/checkout distinction, refusal paths and source races; mutation controls cannot establish source authenticity or hardware acceptance.

Current ordinary compiler/SDK qualification requires X86, AArch64, RISCV and
AMDGPU backend metadata; actual [offline HIP device compilation](linux-accelerator-images.md#early-hip-device-compiler-check)
is a separate required source-stack gate. Preserved older three-CPU-backend
receipts retain their historical scope and do not establish HIP capability.
These compiler/SDK proof profiles retain their reviewed Linux amd64, three-CPU-plus-AMDGPU-backend, six-wrapper,
pin, base-ancestry and accepted-checkpoint contracts. They are not general arbitrary-image
launchers. A new platform or source-proof kind needs a reviewed profile and matching tests.
The targeted source scope `operational-tools` permits only the same exact patch, cleanup and normal-hook proof as the existing named source profiles. It grants no compiler or image acceptance.

Normal source-commit units retain `/usr/local/sbin`, `/usr/sbin` and `/sbin` in
addition to the user and ordinary binary directories. Debian dependency fixtures
invoke `ldconfig`; omitting its system directory makes the unmutated baseline
fail on the host despite passing in the image. Hooks, mutation selection and
failure statuses remain unchanged; supply the complete path rather than skip a
probe or weaken a test. The raw-readelf regression uses a real ELF
and fixed linker-cache/package-owner stubs; it does not grade the host multilib
inventory or replace the separate real ELF/ABI dependency suite.
Offline source checks need the unchanged locked dependencies in the actual tool image's uv URL cache, using its own cache format and mount paths. A directory of verified wheels or a successful install with another host uv version does not establish that cache. Prime it with the same normal tool image and original locks, preserve the bounded owned-container cleanup, and require a fresh offline control before the proof. Keep test-container networking disabled.
The retained `probe-soname-load.py` worker takes the soname, expected prefix and maps output as positional arguments; its original bytes remain bound by the supplied qualification.
The independent cross-Clang image probe requires `--sysroot=/` for all six wrappers, matching Debian's absolute target linker scripts. Its separately constructed positive fixture uses that root; four negative controls reject the old `/usr/<triplet>` root for both foreign C/C++ drivers. Mutations restore each obsolete foreign root and must fail the fixture. A corrected host probe can check an already built immutable image; record its actual input hashes in a fresh invocation and retain the failed old probe. This does not replace the baked smoke or grant SDK, complete C++ ABI or GPU acceptance.
Default paths derive from `Path.home()`; original qualifications, loader probes, parallel-source
producers, compiler unit identities and cleanup authorization files are explicit inputs.

The owner's standing local container cleanup also permits the documented selective
removal of obsolete published local images after an idle-engine and immutable
registry/config check. Reuse the full-state and bounded unit watcher tools with
run-specific selected-tag data; preserve every unselected image and compiler/source
cachemount, check before/after identities and recheck the actual ordinary reserve.
The [host cleanup page](linux-host-setup.md#b7-reclaiming-disk-without-losing-the-compile-caches)
owns this workflow; cleanup does not create source, image or hardware acceptance.

## Proof-workflow fixture companions

The proof-workflow harness carries `tests/proof_workflow_ft_tests.py`,
`tests/proof_workflow_capture_tests.py` and `tests/proof_workflow_cleanup_tests.py`
beside `proof_workflow_tests.py`. The
runner supplies the selected script root and owns each engine fixture lifetime;
all free-threaded bootstrap and owned-container refusal cases remain in the
same discovered suite. These fixtures do not qualify a real build or GPU.

## Complete preflight transcripts

The isolated worker redirects both streams of its unchanged `make preflight` command
into `/evidence/isolated-preflight-command.log`. The evidence bind preserves those
bytes before container removal. The host retains the engine's attach stream separately
as `engine-attach.log` and copies the regular mounted transcript byte for byte to
`preflight.log`. A missing transcript or symlink fails the run even when the engine
returns zero; original command and cleanup statuses remain separate. This prevents
an incomplete attach stream from becoming the only retained test output. The observed
transport cause is not established. Fixtures cover clipped attachment, binary bytes,
missing/linked transcripts, both redirected streams and raw failed command status;
they do not prove a real container run. Complete acceptance still requires the existing
all-group, exact-registry, source, terminal and cleanup checks. Keep earlier incomplete
logs and failed sealing attempts unchanged; do not add a success footer to them.

The final receipt reader accepts the original `--property=ExecStopPost=...`,
`--property ExecStopPost=...`, `-p ExecStopPost=...` and joined `-pExecStopPost=...`
forms. Exactly one cleanup property is required across all forms. Preserve the
executed argv without rewriting it. The same owner ID, raw cleanup result, strict
mutation proof and independent engine absence checks still apply. Mixed or repeated
properties, a missing cleanup, wrong owner or failed cleanup refuse. Synthetic CLI
fixtures cover those cases and quoted paths with spaces; they do not authenticate
receipts, execute systemd or establish image acceptance.

## Media profile source controls

The isolated `run-isolated-preflight.py` runner accepts
`--fast-ubuntu-mirror-url http://de.archive.ubuntu.com/ubuntu/` when an operator
has checked the endpoint. It records the exact URL and uses the existing shared
Ubuntu source rewriter before package bootstrap. The default sends an empty
bootstrap value and keeps the image's original APT sources. URL validation refuses
non-HTTP(S), credentials, malformed ports, whitespace, queries and fragments.
The rewrite retains suites, components and `Signed-By`; APT still verifies its
normal metadata. Changing mirrors does not qualify packages or a source run.

For a closed disposable `quality/.venv`, use
`linux/host-config/relocate-quality-venv.py --environment PATH --target TMPFS_PATH
--directory FRESH_PROOF`. The environment must be unversioned and ignored by its
owning Git repository; the target must be a fresh `ant-quality-venv-*` directory
on a different existing tmpfs. Hardlinks shared with a cache and special files
are refused. Canonical GNU tar hashes compare contents, names, links and archive
metadata before and after the move. The original directory becomes an empty
container mountpoint; bind the retained environment there in matching tool
images. This assumes the environment is closed and has no concurrent writer.
Keep its lock and persistent download cache. Volatile environments need recreation
after reboot and supply no source, build or runtime acceptance.

Run `local-proof/run-media-lane-controls.sh PROOF_DIRECTORY SELECTED_MUTATIONS`
inside the selected family tool image. The proof directory must exist, the
selected manifest must be a file, and neither the captured source patch nor the
copied manifest may already exist. Input refusals precede tool bootstrap.
The driver retains explicit Media profile tests and delegates the shared suites,
mutation execution and structural preflight subset to the existing source-check
protocol. Its required tools must already be available offline.

Raw child and final Git failures remain fatal. The staged patch, index and clean
worktree must survive the run before the final success sentinel. Isolated command
fixtures exercise early refusal, preserved existing evidence, raw failure and
source drift; they do not execute actual source suites or establish image/GPU
acceptance. The separate strict sealer checks actual mutation IDs and group logs.

## Default amd64 Media admission

`launch-default-amd64-media.py` selects the default amd64 command from the six-lane
builder after the existing SDK qualifier rehashes its native OCI blobs, actual
engine manifest/config, compiler ancestor layers and original complete source
proof. The compiler plan and SDK must retain the exact same source path and
revision; changed SDK invocation or source-proof bytes refuse. Optimized Python
refuses before the shared assertion-based parent checks can be disabled.

```bash
python3 linux/scripts/local-proof/launch-default-amd64-media.py \
  --compiler-plan PLAN --sdk-invocation SDK_INVOCATION --parent-proof SDK_OCI_PROOF \
  --output FRESH_OUTPUT --unit webgpu-normal-media-default-amd64-YYYYMMDD-N.service \
  --image-repo ant-local/webgpu-default
```

Shared admission requires an idle host, fresh local image/unit/output names and
at least 300 GiB of available durable storage, retaining a stricter caller reserve.
The bounded ordinary stage records SDK/source/parent hashes and uses the qualified
native SDK context plus its immutable repository/digest. Both accelerator toggles
are explicitly false; `ORT_WEB_REQUIRED=1` and both Wasm modes remain required.
The shared launcher owns the bounded unit and cache transport. Keep successful
producer units for subsequent checked handoffs and require owned cleanup and
independent absence queries when closing any container proof.

For arm64 or riscv64, run the same module directly with the selected SDK target.
The SDK must pass the matching [component qualification](#sdk-component-qualification).

```bash
python3 linux/scripts/local-proof/default_media_launch.py --arch arm64 \
  --compiler-plan PLAN --sdk-invocation SDK_INVOCATION --parent-proof SDK_OCI_PROOF \
  --output FRESH_OUTPUT --unit webgpu-normal-media-default-arm64-YYYYMMDD-N.service \
  --image-repo ant-local/webgpu-default
```

Use `riscv64` in the target and unit name for that lane. The engine image for
both is Linux amd64, while the SDK tools and Media artifacts target the
selected architecture. Synthetic command and refusal tests cover this wiring.
Actual SDK builds, factory replay, NVIDIA handoffs, licence closure and FINAL
acceptance remain open.

## Native GPU-to-Media handoff

Use `gpu-oci-handoff.py launch|seal --compiler-plan PLAN --gpu-invocation GPU_INVOCATION
--context FRESH_PARENT/gpu-context-NAME --unit webgpu-normal-gpu-export-amd64-DATE-N.service`.
The default invocation selects the ordinary ROCm amd64 profile. It requires the original
qualified SDK and compiler ancestry, complete exact source proof, unchanged invocation hashes
and the GPU producer's actual successful terminal state. Launch binds the current engine's
manifest/config and independently resolves the bare immutable local manifest ID to the same
config and manifest. The host export uses that verified ID through the shared bounded
transport. A local Docker-loaded image can lack a repository@digest name even when
inspection reports that RepoDigest; its inspected config ID is a different identity.
Media's FROM still uses repository@digest with the verified native OCI context.
The unchanged byte reserve applies before starting; existing units, contexts and receipts refuse.

The 2026-11-14 loader repair has a complete 6,246-mutation/42-group source proof
at exact production `8c4e13b0`; qualified host tools are separate at `158daf7f`.
The next `launch-normal-gpu.py` must explicitly select that production source and
its new `rocm-sqlite-loader-20261114/full-preflight-1/complete-preflight-proof.json`,
retaining the original `amdgpu-codegen-20261114` compiler plan, SDK invocation and
stopped native SDK proof. A tool or documentation descendant is not the image
producer and does not inherit the production source receipt. The real GPU rebuild,
native export, both actual Wasm modes and final consumers remain required.

Sealing rehashes the complete native OCI layout, verifies all SDK descriptors/diffIDs and
immutable shared parent layer identities, and requires both actual export pipeline statuses.
Only after a successful stop and independent terminal-state observation is a stopped receipt
written. Preserve partial output on failure. Local cross builds do not emit the pushed
image's ancestry annotation; this profile checks real native ancestry instead of inventing
Config labels or modifying an image manifest. Supplied receipts do not authenticate provenance.

Then use `launch-normal-media.py --compiler-plan PLAN --gpu-invocation GPU_INVOCATION
--parent-proof GPU_OCI_STOPPED_PROOF --output FRESH_OUTPUT --unit
webgpu-normal-media-amd64-DATE-N.service --image-repo ant-local/webgpu-NAME`.
It revalidates that exact subject and starts the unchanged ordinary `build-cross-stage.sh`
with native GPU context and digest pin, `ORT_WEB_REQUIRED=1` and
`ORT_WASM_WEBGPU_FLAVORS=true`. The strict Media RUN replays both factories after
JS staging, including when the shared cache supplied the compiled products.
Keep the actual build and probe receipts for both flavors. Shared host admission retains idle-engine,
collision, ambient-flag and fresh temporary-root checks. Media launch admission requires
at least 300 GiB available and retains any stricter plan.

### A Media source newer than its GPU parent

`launch-normal-media.py --media-source CLEAN_CHECKOUT --media-source-proof COMPLETE_PROOF`
builds ROCm Media from a later commit while keeping the verified GPU parent. The
`media_source_profile.py` review refuses unless the GPU source revision is an ancestor, the new
commit has its own complete preflight proof, and every compiler, SDK and GPU input is
byte-identical between the two revisions. Those inputs are the four upstream Dockerfiles,
both `.dockerignore` files, every path those Dockerfiles mount or copy (an `${ARG}` path is
compared up to its first variable) and the SDK and AMD selected-script closures. The Media
export recomputes the review and requires the recorded one; Android and later stages inherit
the Media source unchanged. The review proves that the upstream inputs are unchanged. It does
not prove cache hits or a successful build. NVIDIA has no such profile.

### A runtime source newer than its Android parent

`launch-normal-runtime.py --runtime-source CLEAN_CHECKOUT --runtime-source-proof COMPLETE_PROOF`
keeps a verified ROCm Android parent while the runtime lane runs a later commit. For any Android
source other than the historical `8c4e13b0`, `runtime_source_profile.py` requires ancestry, the new
commit's own complete preflight, byte-identical inputs for every stage from base through Android
(the four upstream Dockerfiles plus `Dockerfile.media` and `Dockerfile.android`, their mounted and
copied paths and the SDK and AMD script closures) and no image stage naming a host-only file. The
only permitted differences inside those inputs are two runtime-lane files. Image stages mount `01-core`
whole, but only host orchestrators load `01-core/runtime-build-fns.sh`, through `artifact-common.sh`;
`03-media/runtime/assemble-torch-app.sh` lies under a Media mount prefix, but only `Dockerfile.torch`
copies and runs it. The review
proves unchanged parent inputs, not cache hits or a successful runtime build.

Carry the existing `normal_stage_launch.py`, `gpu_source_profile.py`, `media_source_profile.py`,
native OCI/seed and proof helpers beside these entries. `test-gpu-handoff.sh` uses real synthetic OCI bytes and
hardlinks with explicit engine/unit doubles; the standard native seed and stage suites
retain their earlier compiler/SDK scopes. They do not establish actual image completion,
full binary licences, native loader ABI, GPU parity or digest-specific FINAL acceptance.

## NVIDIA GPU and Media handoffs

Use the same compiler plan, exact proven source and qualified SDK receipt for
the selected cross target. This example uses arm64/SBSA on the Linux amd64
build host. For NVIDIA amd64 use `amd64` in the target argument and unit names.

```bash
python3 linux/scripts/local-proof/launch-normal-gpu.py --variant nvidia --arch arm64 \
  --compiler-plan PLAN --sdk-invocation SDK_INVOCATION --parent-proof SDK_OCI_STOPPED_PROOF \
  --output FRESH_GPU --unit webgpu-normal-gpu-nvidia-arm64-YYYYMMDD-N.service --image-repo ant-local/webgpu-NAME
python3 linux/scripts/local-proof/gpu-oci-handoff.py launch --variant nvidia \
  --compiler-plan PLAN --gpu-invocation GPU_INVOCATION --context EXPORTS/gpu-context-NAME \
  --unit webgpu-normal-gpu-export-nvidia-arm64-YYYYMMDD-N.service
```

After each export succeeds, repeat its command with `seal`. Pass the stopped
GPU receipt to Media. The launchers select the normal private NVIDIA stage
tags. The arm64 lane selects SBSA and keeps DeepStream disabled. Both lanes
enable CUDA and TensorRT, and leave image and cachemount pruning disabled.

```bash
python3 linux/scripts/local-proof/launch-normal-media.py --variant nvidia \
  --compiler-plan PLAN --gpu-invocation GPU_INVOCATION --parent-proof GPU_OCI_STOPPED_PROOF \
  --output FRESH_MEDIA --unit webgpu-normal-media-nvidia-arm64-YYYYMMDD-N.service --image-repo ant-local/webgpu-NAME
python3 linux/scripts/local-proof/media-oci-handoff.py launch --variant nvidia \
  --compiler-plan PLAN --media-invocation MEDIA_INVOCATION --context EXPORTS/media-context-NAME \
  --unit webgpu-normal-media-export-nvidia-arm64-YYYYMMDD-N.service
```

Media build and export admission require at least 300 GiB free. The strict
Media build uses both WebGPU Wasm modes and replays the delivered factories.
The stopped exports bind rehashed image bytes, the baked cross target and
CUDA/TensorRT environment, every parent descriptor and diffID, and both raw
export statuses. Carry `nvidia_handoff_profile.py`, the shared stage and
export profiles, the SDK qualifier and Media command companions together.
`test-nvidia-handoff.sh` uses synthetic layouts and engine/unit doubles.
Actual build, factory, binary licence, runtime, FINAL and hardware receipts
still require their corresponding runs.

Continue from the stopped Media receipt with `launch-normal-android.py
--variant nvidia --compiler-plan PLAN --media-invocation MEDIA_INVOCATION
--parent-proof MEDIA_OCI_STOPPED_PROOF --output FRESH_ANDROID --unit
webgpu-normal-android-nvidia-arm64-YYYYMMDD-N.service --image-repo ant-local/webgpu-NAME`.
It revalidates the GPU and Media ancestry and requires the same 300 GiB build
floor. Use `android-oci-handoff.py launch|seal --variant nvidia --compiler-plan PLAN
--android-invocation ANDROID_INVOCATION --context EXPORTS/android-context-NAME-arm64
--unit webgpu-normal-android-export-nvidia-arm64-YYYYMMDD-N.service`.
The context suffix matches the target. The stopped receipt proves native
Media ancestry and the inherited accelerator environment under the same
architecture and source bindings.

## Native Media-to-Android handoff

The explicit ROCm amd64 host profile continues a successful ordinary Media build
through Android before runtime. `media-oci-handoff.py launch|seal` takes
`--compiler-plan PLAN --media-invocation MEDIA_INVOCATION --context
FRESH_PARENT/media-context-NAME --unit
webgpu-normal-media-export-amd64-DATE-N.service`. It uses the shared bounded
native exporter with a distinct Media subject, requiring the loaded successful
Media producer, its exact source and GPU receipt chain, immutable local image
resolution, fresh output and the unchanged disk floor. Sealing checks every blob,
GPU layer descriptor/diffID, shared parent identity and both raw export statuses
before retaining a stopped receipt.

Then run `launch-normal-android.py --compiler-plan PLAN --media-invocation
MEDIA_INVOCATION --parent-proof MEDIA_OCI_STOPPED_PROOF --output FRESH_OUTPUT
--unit webgpu-normal-android-amd64-DATE-N.service --image-repo ant-local/webgpu-NAME`.
Its source and parent metadata use the same shared builder as Media; ordinary
stage validation binds the exact command, variant, native context and parent
repository/digest. Android consumes the completed Media layout through the
existing stage driver. Keep the original compiler/SDK/GPU/Media producer units
loaded for downstream identity checks, and keep each invocation's original host
tool paths and bytes.

Carry `media_handoff_profile.py`, the GPU export entry, `gpu_handoff_profile.py`,
`normal_stage_launch.py` and their existing native OCI/proof companions together.
The new suite uses synthetic native layouts and command/unit doubles; the GPU,
SDK and seed suites retain their previous boundaries. Native ancestry alone
grants no factory, binary licence, inference, shipped-byte or FINAL acceptance.
Actual native/GIL/FT and both Wasm products still need their own checks. Other
Linux architectures and variants require their actual lane proofs. Runtime must
consume this run's verified Android output; a resumed no-push chain cannot supply
that prefix from a mutable or published tag.

## Default Media and Android handoffs

After the selected default Media producer succeeds, export and seal its OCI
context with the existing entry and the explicit default variant. This example
uses arm64. Substitute amd64 or riscv64 in the unit name for those lanes.

```bash
python3 linux/scripts/local-proof/media-oci-handoff.py launch --variant default \
  --compiler-plan PLAN --media-invocation MEDIA_INVOCATION \
  --context FRESH_PARENT/media-context-NAME --unit webgpu-normal-media-export-default-arm64-YYYYMMDD-N.service
```

Rerun with `seal` after a successful export. Pass the resulting stopped receipt
to `launch-normal-android.py --variant default --compiler-plan PLAN
--media-invocation MEDIA_INVOCATION --parent-proof MEDIA_OCI_STOPPED_PROOF
--output FRESH_OUTPUT --unit webgpu-normal-android-default-arm64-YYYYMMDD-N.service
--image-repo ant-local/webgpu-NAME`. After Android succeeds, run
`android-oci-handoff.py launch|seal --variant default --compiler-plan PLAN
--android-invocation ANDROID_INVOCATION --context FRESH_PARENT/android-context-NAME
--unit webgpu-normal-android-export-default-arm64-YYYYMMDD-N.service`.

The default host profiles revalidate the exact source, original SDK receipt,
both required Media Wasm flags, immutable engine manifest/config and the
target-specific OCI scope. Both images are Linux amd64 build-host images. Their
baked target, cross build mode and accelerator flags must agree with the
invocation. Exports rehash all blobs, compare each ancestor layer descriptor
and diffID, verify linked parent bytes and retain both raw transport statuses.
Carry `default_handoff_profile.py`, `default_media_launch.py`, the SDK qualifier
and Media command companions alongside the shared export and stage profiles.
The existing idle, fresh-output and at least 180-GiB disk checks still apply,
with 300 GiB required to launch default Media.

`test-default-handoff.sh` checks all three targets using synthetic OCI layouts
and declared SDK and systemd doubles. Actual default build, factory, runtime,
licence, GPU and FINAL receipts remain separate.

## Native Android export

After the same ordinary ROCm amd64 Android producer actually succeeds, use
`android-oci-handoff.py launch|seal --compiler-plan PLAN --android-invocation
ANDROID_INVOCATION --context FRESH_PARENT/android-context-NAME --unit
webgpu-normal-android-export-amd64-DATE-N.service`. It requires the exact source
and complete preflight already bound to Media, the original successful loaded
producer units, both required Media Wasm flags, the stopped native Media receipt
and its full GPU/SDK/compiler ancestry. The immutable local manifest must resolve
to the same config as the Android tag; an ordinary invocation alone is insufficient.

The bounded shared exporter retains the Android subject, all Media layer
descriptors and diffIDs, independent child metadata, complete blob hashes and both
raw transport statuses. Sealing requires the exact original worker files and
verified parent-layer identities before stopping the export unit. Preserve all
existing receipts and their original tool-path/hash bindings. Fresh ordinary
180-GiB admission remains mandatory before export, with no floor override.

Copies of the GPU, Media and Android profiles carry `stage_handoff_profile.py`,
`normal_stage_launch.py` and the native OCI helpers. Android additionally carries
`android_handoff_profile.py` and its Media/GPU companions; the worker inventory
binds that recursive closure. Their shared source, receipt and ancestry checks
retain each caller's own stage labels and Media's required Wasm checks.

`test-android-handoff.sh` uses synthetic real OCI bytes and explicit engine/unit
and parent doubles, including known but wrong stage receipts and unrelated valid
parent bytes. Its mutations detect lost bindings and preserve raw failures. This
does not build Android, authenticate supplied receipts, prove binary licences or
run inference. Runtime must consume this actual verified Android output; the
ordinary final wrapper and fresh digest-specific six-consumer acceptance remain
separate required steps.


## Ordinary local runtime

The [default runtime workflow](#default-runtime-and-local-final) covers amd64,
arm64 and riscv64.

The explicit ROCm amd64 host profile uses `launch-normal-runtime.py
--compiler-plan PLAN --android-invocation ANDROID_INVOCATION --parent-proof
STOPPED_ANDROID_PROOF --output FRESH_OUTPUT --unit
webgpu-normal-runtime-amd64-DATE-N.service --image-prefix
ant-local/webgpu-NAME:runtime-rocm-DATE-N --app-ref EXACT_40_HEX_COMMIT`.
Keep the verified native Android context's `-amd64` suffix: the ordinary runtime
appends it to `ARTIFACT_CONTEXT_ROOT`. Its producer source and complete preflight
normally remain the exact ones already qualified through compiler, SDK, GPU and Media;
committing host tools does not qualify a new image source.

The explicit pair `--runtime-source REPAIRED_SOURCE --runtime-source-proof
COMPLETE_SOURCE_PROOF` selects only the reviewed wheel-context and unused-smoke-export
repair pinned in `runtime_source_profile.py`. Both arguments are required together. Its complete
proof must match that exact clean source commit, every current registry mutation,
all default groups, actual script suites and cleanup. A targeted source receipt
or the original Android proof cannot satisfy it. Copy that new module beside the
runtime profile and existing native/normal-stage companions.

The source sets the group count. `normal_stage_launch.preflight_slugs` reads `KNOWN_SLUGS` from the
proved checkout's `preflight.sh`. A complete proof must record one distinct group per slug. A new slug
needs a new complete proof, so a 42-group receipt cannot qualify a 43-slug source.
`launch-normal-compiler-plan.py` keeps its 42: it is bound to fixed older checkouts.

The current reviewed source is `2aa1a7780861db8012cb769e04d3de474dddca37`:
it keeps the stable wheel contexts and disables push, store and unpack only for the
unused required-smoke image. Its own 6,512-entry full preflight is required; the
older `ec3be1855d2adee3622e36ac99cc76afcbfc5795` receipt is insufficient. The
intermediate `74f6be54` full run failed context validation on its COPY fixtures;
the current source uses one valid fixture and an absent-target negative control.
Its unchanged smoke-export code still needs its own exact-source complete proof. Original
Android source `8c4e13b0` and its native ancestry remain separate, unchanged inputs.
This selection does not establish a successful runtime or FINAL consumer acceptance.

Selection happens before runtime tags, alias preparation or unit creation. The
actual driver uses the repaired checkout; its source revision and full-proof hash
are recorded separately from `parent_source_revision`, original Android invocation,
manifest/config and native parent receipt. The original Android ancestry is still
revalidated. The default image wheel mode, exact app commit, shared disk minimum,
all runtime gates and invocation-owned cleanup retain their existing policies.
Source proof does not authenticate supplied receipts or prove that a finished
runtime, GPU inference, complete licences or FINAL consumers passed.

Before launch the shared transport refuses active builds, running containers,
ambient build flags, existing unit/output/temporary roots and any existing
base/package/wrapper name. The ordinary ROCm runtime requires the larger of
300 GiB and its parent plan's byte requirement; the shared 180-GiB floor remains
a lower bound. The same checked byte requirement is recorded in the invocation.
Refusal precedes output allocation, local alias preparation and unit creation.
Runtime7 passed base/package/serial smoke after a 204,024,397,824-byte admission,
then exhausted disk unpacking Chrome in FINAL. The larger starting margin addresses
that observed failure; it is not a reservation or proof of peak-disk sufficiency.
Fixtures exercise both sides of the exact byte boundary and retain larger parent
requirements. The preparation step creates or verifies a local `docker.io/ant-local/...@sha256:...` alias of the
actual Android manifest and independently checks its config. Docker-mode nerdctl
inspection of a repository-at-digest name is not reliable on this host: verify the
canonical name through image inventory and inspect the bare immutable manifest.
Tag creation itself uses the verified actual source tag: this nerdctl accepts a
bare manifest for inspection but refuses it as the source of `image tag`. Keep all
post-tag manifest/config/platform checks; a successful tag command alone is insufficient.
This local alias makes no registry or publication claim.

The actual command is the original `build-runtime-manifest.sh` with one amd64
architecture, the exact app commit, `--skip-manifest`, default image wheel source
and the verified native Android layout. Input preflight, image smoke, wrapper
content and ancestry enforcement remain enabled. No `--log-dir` is passed to this
driver; its `LOG_DIR` and unit log are explicit. All three names, selected worker
hashes, source/native receipts, app commit and actual command remain in invocation
evidence. The source tools themselves must be clean and committed before use.

Copy `owned-nerdctl.py`, `owned_nerdctl_args.py`, `owned_containers.py`,
`host_commands.py` and `cleanup-owned-containers.py` together. The exec wrapper
adds one fresh invocation label to reviewed run/create forms, rejects label files
and ownership overrides, and forwards builds, pulls, streams and raw statuses.
The same UUID, owner label and real engine reach the unit's ExecStopPost before
it starts. Keep the cleanup CLI's required CID-file argument at a fresh reserved
path; runtime discovers every actual child by its unique invocation label,
including when that CID path was never written. Successful RemainAfterExit producers also require explicit canonical
cleanup plus an independent successful engine query proving every owned container
absent before acceptance; a terminal producer alone is insufficient.

The command/native fixtures and mutations cover admission, argument boundaries,
local alias identity, cleanup installation and raw failure propagation. They do
not build runtime, authenticate supplied receipts, prove complete binary licences
or establish FINAL consumer or GPU inference acceptance. Other Linux lanes and
finished consumer/provider-profile requirements remain separate required work.

An explicit `--serial-smoke` on the host launcher adds only `RUNTIME_SMOKE_OVERLAP=0`: the same mandatory package smoke runs before the wrapper, with its raw failure still fatal. The default retains ordinary overlap. This is a host scheduling choice, not a new production source, a smoke bypass or a changed consumer contract; record it alongside the original source/full-preflight, Android, app, worker and cleanup bindings.

Actual Runtime5 completed base (244 s, status 0) and package import (938 s, status 0). Its concurrent smoke and wrapper both failed after 310 s with ENOSPC while materializing separate native contexts. The guardian's third live cleanup had already reclaimed 63,756,185,600 bytes and allowed package import to finish; it did not establish sufficient space for both later contexts. Retain the complete raw failures and six cleanup receipts. Before a fresh attempt, qualify the scheduling choice and remeasure headroom; passing the ordinary admission floor alone does not establish a full runtime.

## Default runtime and local FINAL

After the [default Android handoff](#default-media-and-android-handoffs) is
sealed, pass its original invocation and stopped OCI receipt to
`launch-normal-runtime.py`. Use the target as the suffix of the Android
context name and in the runtime unit below.

```bash
python3 linux/scripts/local-proof/launch-normal-runtime.py --variant default \
  --compiler-plan PLAN --android-invocation ANDROID_INVOCATION \
  --parent-proof STOPPED_ANDROID_PROOF --output FRESH_OUTPUT \
  --unit webgpu-normal-runtime-default-arm64-YYYYMMDD-N.service \
  --image-prefix ant-local/webgpu-NAME:runtime-default-YYYYMMDD-N \
  --app-ref EXACT_40_HEX_COMMIT --serial-smoke
```

The reader rehashes the Android export, matches the Media descriptors and
diffIDs, and checks the baked target in the original Linux amd64 image. The
runtime exports that exact Android wheelhouse on the build-host platform.
Base, package, smoke and wrapper consume the selected target. The default lane
uses CPU Torch with both accelerator flags off. Start requires at least 300 GiB
available and retains any stricter plan requirement. Use a clean committed host
toolkit and keep the existing local alias, gate and ownership checks.

After the runtime build and invocation-owned cleanup pass, run the ordinary
[six-consumer local FINAL](#local-final-consumer-acceptance) with the runtime
invocation and exact wrapper manifest. It checks the Android target, original
receipt hashes, same complete source proof, and the runtime's worker hashes and
command. The focused tests use synthetic OCI data and command doubles.

## NVIDIA runtime and local FINAL

Pass the same-target stopped NVIDIA Android export from the
[GPU and Media handoffs](#nvidia-gpu-and-media-handoffs) to the ordinary runtime
launcher. The same committed source produces every stage. This example selects
arm64/SBSA. Use amd64 in the unit and Android context suffix for the amd64 lane.

```bash
python3 linux/scripts/local-proof/launch-normal-runtime.py --variant nvidia \
  --compiler-plan PLAN --android-invocation ANDROID_INVOCATION \
  --parent-proof STOPPED_ANDROID_PROOF --output FRESH_OUTPUT \
  --unit webgpu-normal-runtime-nvidia-arm64-YYYYMMDD-N.service \
  --image-prefix ant-local/webgpu-NAME:runtime-nvidia-YYYYMMDD-N \
  --app-ref EXACT_40_HEX_COMMIT --serial-smoke
```

The launcher rehashes the Android export and its Media ancestry before
admission. Both lanes use `onnxruntime-gpu` and `pytorch-cu130` with TensorRT
enabled. Only arm64 selects SBSA, and DeepStream is enabled on amd64. The
wheelhouse export uses the amd64 build-host platform. The base, package, smoke
and wrapper use the target platform. Launch requires at least 300 GiB available
and honors any stricter plan. The input, smoke, wrapper and ancestry gates run
with invocation-owned cleanup. Image and cachemount pruning stay disabled.

The [local FINAL runner](#local-final-consumer-acceptance) checks the same
Android index, stopped export and original Media receipt. It checks the
variant, target flags and digest pin in the runtime's systemd environment,
then uses the actual wrapper manifest and the complete canonical consumer plan.
Copy the matching NVIDIA, Media, native OCI and runtime companions with the
launcher. Fixture tests cover both targets and the refusal paths. A fresh
runtime and the actual consumers still have to run for receipt-based acceptance.

## Local FINAL consumer acceptance

The producer-bound checks accept both canonical wheelhouse delivery modes and bind an explicit lane name to the same declared variant. A separate owned-wrapper checkout is permitted only with identical selected companion bytes and a clean tree; the host revision and complete worker mapping still identify the original launcher checkout. No producer receipt is rewritten to fit the acceptance tool.

Missing Android stage metadata is derived only from its complete checked ordinary Android command and original full-source proof. Preserve the unchanged receipt and its original hash, and retain the distinct actual native-parent proof. The synthetic controls cover all six lane schemas; they do not prove new consumer execution or hardware support.

The explicit [unpublished FINAL mode](image-acceptance.md#check-an-unpublished-local-final-wrapper)
uses the existing full consumer runner and a producer-bound local receipt. It shares
`runtime_worker_files` and the platform/engine-aware `prepare_local_alias` helper;
copy the complete runtime/native/source profile companions. Actual runtime success,
canonical producer cleanup and its independent absence query are prerequisites.
For a genuinely unloaded successful runtime, `runtime_terminal_evidence.py`
requires the original sealed storage guardian and fresh trusted same-boot journal
lifecycle, preserving the actual historical exit timestamp with an explicit
observation-source label. It verifies the original clean host before importing
the guardian API; supplied JSON or a default zero exit status cannot replace
these checks. Preserve the guardian authorization snapshot and all referenced
cleanup proofs. An existing live, failed or merely stopped loaded unit cannot
fall back to history. Include this companion in copied acceptance and guardian
worker closures.
The receipt remains local and cannot promote a registry tag. Fixture and mutation
coverage establish refusals only, not real consumers or hardware acceptance.

Use the committed `linux/scripts/launch-local-final.py` for an initial bounded host run:

```bash
python3 linux/scripts/launch-local-final.py launch \
  --runtime-invocation /absolute/runtime/invocation.json \
  --image docker.io/ant-local/webgpu-NAME@sha256:WRAPPER_MANIFEST \
  --directory /absolute/fresh/local-final \
  --unit webgpu-local-final-amd64-20261115-1.service
```

The launcher verifies the successful runtime before allocating output, materializes the entire canonical plan with only its supported platform changed, and binds its clean tooling revision and worker hashes. It reserves a fresh UUID and ownership label, routes every consumer and ownership-helper creation through `owned-nerdctl.py`, and installs canonical invocation cleanup in `ExecStopPost` before starting the worker. The six-hour oneshot has a five-minute stop bound, literal arguments, control-group teardown and an on-disk temporary directory outside Git. Source refs, commands, per-consumer timeouts and the local receipt schema remain unchanged.

After the unit actually terminates, run `python3 linux/scripts/launch-local-final.py seal --directory /absolute/fresh/local-final`. It verifies the exact complete receipt and producer again, stops only its own unit, checks cleanup status/UUID and a fresh independent label query, and writes `proof-stopped.json` with input hashes. Failed outer status stays failed even if an inner receipt exists; a failed seal returns nonzero and grants no acceptance. Retain the invocation, alias receipt, consumer logs, cleanup/query diagnostics and stopped proof. This is local consumer evidence, not registry promotion, complete binary licences or GPU inference. Existing direct-runner replay remains available through `image-acceptance.py`.

## Live configure snapshots

Use `snapshot-live-configure.py` beside its `capture-live-sccache-log.py`, `cache_capture_profile.py`, `native_oci_layout.py`, `native_oci_seed.py` and `proof_commands.py` companions. This replaces repeated copying/hash commands before the selected RUN removes its private build directory. The default `--phase migraphx` retains the original GPU profile; `--phase app-wheelhouse` requires a normal live Media unit, its exact outer `build-app-wheelhouse.sh;` command and a root under `tmp/app-wheelhouse/iree-build-target`. Inner children, sibling build trees and other unit families refuse. The current process must match the normal build marker and remain the same start identity throughout copying; its supplied producer unit must be live. The output parent is a plain directory and the new output cannot overlap the source.

```bash
python3 linux/scripts/local-proof/snapshot-live-configure.py \
  --invocation /absolute/path/to/gpu-run/invocation.json --pid 12345 \
  --relative-root tmp/migraphx-source-stack/backend/build \
  --output /absolute/path/to/fresh-configure-snapshot
```

It copies only CMakeCache.txt, build.ninja, CMakeFiles/rules.ninja and CMakeFiles/CMakeConfigureLog.yaml, together at most 64 MiB. The legacy profile additionally limits each file to 32 MiB; the explicit IREE profile permits one file up to that unchanged total bound because its actual generated Ninja file exceeds 32 MiB. Every source/copy hash must match, source directories/files cannot be symlinks, and existing outputs remain preserved. A failed copy leaves diagnostic partial files without a passed observation. The invocation and process marker do not authenticate producer ownership; a stable snapshot proves neither a completed phase, final cache-error attribution, binary linkage/licence closure nor image acceptance. `test-live-configure-snapshot.sh` uses real file copies and explicit unit/process doubles.

## Live cache log retention

`replay-sccache-log-capture.py` reuses the bounded read-only unit transport with the current canonical `capture-live-sccache-log.py` and its `cache_capture_profile.py` companion. Both reader inputs are hashed in the invocation. The existing GCC, LLVM, Rust and Python phases retain their compiler unit names; `--phase migraphx` matches the actual normal `bash /opt/scripts/03-media/build/migraphx/build-image.sh` process and uses `webgpu-gpu<run>-migraphx-error-capture-<date>-<attempt>.service`.

Media additionally supports `--phase ort-cpu`, `ort-gpu`, `ort-web`, `opencv` and `app-wheelhouse` with
`webgpu-media<run>-<phase>-error-capture-<date>-<attempt>.service`. The first two
match the actual outer `build-onnxruntime.sh --step cpu;` and `--step gpu;` RUNs;
`ort-web` matches the actual `web-wasm-cache.sh;` build wrapper, excluding the
separate verify-only call. `app-wheelhouse` matches the actual outer `build-app-wheelhouse.sh;` RUN, covering its IREE, Torch and final drain lifetime without claiming per-project counters. The terminating semicolon preserves the outer RUN's
lifetime through its final drain; an inner child command alone refuses. Independent
fixtures match the normal Dockerfile declarations and reject wrong phases/owners
before allocating output. `opencv` covers the `opencv` and `opencv-gst` RUNs. It requires
the outer `build-opencv.sh` invocation followed by the final `sccache-s3-level.sh drain`.
The inner OpenCV command and dependency setup are refused. Media seals require both
exact worker and profile hashes.
These profiles collect diagnostics only: the GPU step may skip NVIDIA compilation,
and Wasm cache reuse or an empty log does not prove either flavor actually built.

Supply the actual live PID, producer unit, original reviewed transport template and a fresh output. The reader opens only the existing regular `/proc/<pid>/root/tmp/sccache.log`, tracks process start identity and refuses replacement of that live log inode. It retains all bytes before closing the descriptor, including after the RUN filesystem disappears. Each replay writes its unit log beside the new invocation. `seal-sccache-log-capture.py` verifies worker/companion hashes, raw terminal status, file size/SHA and stopped/PID0 state. A reader timeout is explicitly partial, and neither an empty file nor a completed reader classifies compiler-cache errors or accepts an image. `test-live-cache-capture.sh` uses synthetic process files and command doubles; it does not prove a genuine build or source provenance.

`audit-failed-source-check.py` also retains a completed mutation run containing `SURVIVED` failures before preflight starts. Its failed receipt requires exact passed/survived IDs, the matching failure summary, actual failed/PID0 unit, cleanup and independent absence. Quality-only failures retain their strict complete mutation proof. Interrupted or other incomplete mutation failures need separate inspection; a failure audit never accepts source.
An early direct-suite assertion failure can be retained without creating a mutation log. The
audit requires the original failed assertion report and no later preflight report, retains
the raw failed unit status, and explicitly records that mutation execution did not start.

## Local BuildKit cache transfer

Use `seed-buildkit-cache.py` for recurring local cache seeding rather than regenerating `cp` commands. Keep its `buildcache_transfer.py`, `native_oci_layout.py`, `native_oci_seed.py`, `proof_commands.py` and type companion together. Supply a producer receipt with its actual successful loaded terminal and stopped state; the current user unit must also be inactive with PID zero. The caller is responsible for selecting the correct producer and ensuring exclusive access to both cache trees. These checks do not authenticate that relationship or prevent a separate uncooperative writer.

```bash
python3 linux/scripts/local-proof/seed-buildkit-cache.py \
  --source /absolute/path/to/stopped-export \
  --destination /absolute/path/to/fresh-cache-root/actual-stage-slug \
  --producer-proof /absolute/path/to/producer/proof-stopped.json \
  --receipt /absolute/path/to/fresh-cache-transfer.json
python3 linux/scripts/local-proof/seed-buildkit-cache.py \
  --verify-only --receipt /absolute/path/to/fresh-cache-transfer.json \
  --dry-run-log /absolute/path/to/normal-driver-dry-run.log \
  --image-tag ant-local/example:cross-compiler-amd64
```

Only the modern OCI image-manifest BuildKit cache format is supported. Every referenced manifest, cache config and layer is size/hash checked; repeated descriptors are counted once. Only immutable content-addressed blobs are hard-linked. Index and layout bytes get separate files so the next export cannot overwrite the old mutable metadata. Cache roots must be plain disjoint directories on one filesystem, with a fresh destination and receipt outside both trees. Existing outputs are preserved. A failure leaves partial diagnostic files without a passed receipt. Reverification checks source and destination bytes, shared blob inodes, independent metadata, producer identity and exact accounting.

Select the destination from the ordinary driver's own stage-cache path; do not invent another slug algorithm. Before the next build, explicitly set its `BUILDKIT_CACHE_DIR` to the destination's parent and retain a normal `--dry-run` showing `--cache-from type=local,src=<destination>`. Verify that log with the paired `--dry-run-log` and `--image-tag` options above: require exactly one normal build, the intended image, caching enabled and exactly the transferred local import. This checks supplied log bytes, not the provenance or execution of that command. A fresh output directory or unchanged GNU source closure does not carry over an older namespace. The transfer helper does not rewrite plans or relax source, full-preflight, base ancestry, disk-reserve or publication gates. Never seed or modify a live export, and never restart a producer merely to chase hits. Actual solve logs and compiler counters remain the cache evidence. `test-buildcache-transfer.sh` uses real synthetic files and an explicit systemd double; it proves no actual solve, source authenticity or image acceptance.

## Native AMDGPU compiler planning

`prepare-next-compiler-plan.py --profile native-amdgpu` prepares the ordinary
compiler command while the production checkout stays frozen. Carry its
`compiler_plan_profile.py` and `native_oci_layout.py` companions. The default
`clang-wrapper-repair` profile retains its original three changed LLVM paths.

The explicit native profile additionally requires the OCI transport change in
`01-core/context-management.sh`: its current bytes must match ancestor commit
`8271db71f46ab74393ff45c14864d0eaca6707a5`, and the original reference must retain
the known prior SHA256. Neither an extra changed source nor a missing required
delta is accepted. All five storage-control files remain checked. The generated
audit records that its reviewed transport control changed and preserves both
hashes; the broader input comparison keeps this file in `changed_bound_files`.
It cannot become an unchanged GNU mount or disappear through a rewritten input
reference. Source and prior Dockerfiles must still match.

The planner retains the existing source-proof/normal-hook binding, manager-flag
refusal, immutable base fields, 180-GiB floor and no-push contract. Preparation
does not start a build or prove a cache hit. The launcher still requires fresh
complete source preflight, real disk admission and all base-blob checks.
`test-compiler-plan-profile.sh` uses actual fixture files and explicit Git and
manager doubles; those controls do not authenticate history or accept an image.

## GNU_UNIQUE compiler planning

`prepare-next-compiler-plan.py --profile llvm-gnu-unique` reviews only source
`a4741df72654abd91008f75ced01f57e7b4a1461`, whose compiler bytes remain identical
to repair `60ce0c91`. Carry `compiler_unique_profile.py`, `compiler_plan_profile.py`,
`proof_profiles.py` and `native_oci_layout.py` with the entrypoints. Both planning
and launch call the shared targeted-patch validator unconditionally.

The reference remains compiler6 source `652e5440`. Read its original
`build_inputs_comparison`: combine unchanged fingerprints with the current side
of its earlier deltas and verify every file against that frozen checkout.
The six existing changed inputs are the runtime build functions, native Clang
builder, LLVM validator, cross builder, LLVM module and SDK materializer. The
new seventh input is `llvm-gnu-unique.sh`, explicitly absent from compiler6.
No other delta is accepted. The materializer matches the reviewed compiler
repair; the complete Dockerfile differs only by its readonly LLVM companion
mount. The GNU RUN and every one of its bound inputs remain unchanged.

The current operational fixture repair retains its targeted receipt and every
matching normal-hook mutation under the existing cap of sixteen; its two
matching targets do not become a claim of sixteen checks. Earlier planner
profiles retain their original proof kind and sixteen-hook requirement.
A real compiler launch still needs this exact source's complete registry/all42
proof, the normal reserve, original base blobs, idle engine and fresh output.
Input equality is not a cache hit. Actual build logs, compiler counters, shipped
LLVM byte checks and downstream image/hardware acceptance remain separate.
The shared test fixture supports both old profiles and the new profile using
real files and explicit Git/proof doubles; it authenticates no receipt.

## Ordinary SDK and GPU stage launch

`launch-normal-sdk.py` and `launch-normal-gpu.py` share `normal_stage_launch.py` for fresh local alias/unit/output selection, idle-host checks, ambient manager-flag refusal, the unchanged 180 GiB minimum and bounded named-unit transport. Preserve that companion when copying either launcher. SDK argument defaults and its qualified compiler contract remain intact.

The GPU profile covers ROCm amd64 and defaults to the exact same clean source and complete preflight as the supplied SDK invocation. It rehashes every native SDK and compiler blob, checks all 26 compiler descriptors/diffIDs, revalidates the SDK qualification and actual engine identity, and calls the ordinary `build-cross-stage.sh --stage gpu --arch amd64` with `CROSS_VARIANT=rocm`. The normal AMD Dockerfile retains the full source-built MIGraphX stack. A local stage invocation does not prove a rebuilt backend, compiler-cache hit, inference or final-runtime acceptance; those require actual completion and separate receipts.

```bash
python3 linux/scripts/local-proof/launch-normal-gpu.py \
  --compiler-plan /absolute/path/to/compiler-plan.json \
  --sdk-invocation /absolute/path/to/sdk/invocation.json \
  --parent-proof /absolute/path/to/sdk-context.proof-stopped.json \
  --output /absolute/path/to/new-gpu-run \
  --unit webgpu-normal-gpu-amd64-20261114-1.service \
  --image-repo ant-local/webgpu-reviewed-gpu
```

An optional paired `--gpu-source NEW_CHECKOUT --gpu-source-proof COMPLETE_PROOF` selects only the reviewed HIP output-format repair through `gpu_source_profile.py`. The profile fixes the original SDK revision and intervening tool ancestor, checks both change sets and the exact HIP bytes, compares SDK/GPU Dockerfiles and version pins independently, and requires the new checkout's complete registry/all-42-group proof. Additional production inputs refuse. The original SDK source, qualification, OCI ancestry, actual engine identity and mandatory disk/idle admission remain required. Both source revisions, the review and the actual selected source proof are recorded. `test-gpu-source-profile.sh` grades real fixture files with explicit Git and proof doubles, not history authenticity, actual HIP compilation or GPU acceptance.

The additional `backend-install-manifest` source profile admits exactly four reviewed production files by SHA256: the install stager, shared ROCm loader paths and GPU/package Dockerfiles, plus the host proof-kind table that names this targeted source scope. It retains exact HIP bytes, unchanged SDK Dockerfile/pins and complete new-source verification; any missing, additional or altered production input refuses. Original SDK qualification, native ancestry and disk/idle admission remain required. These supplied receipts do not authenticate provenance or prove image acceptance.

The additional `backend-runtime-load` profile binds six exact file hashes: the earlier GPU/package Dockerfiles, updated stager, shared ROCm paths, normal AMD entry and host proof-kind table. Its earlier HIP and backend-install profiles retain their original pins. Shared profile selection requires the complete exact meaningful path set before file validation, then every selected hash, original SDK/pins, exact HIP repair and complete new-source proof. Fixtures preserve the earlier policy checksum and check current runtime-profile bytes, added/missing paths and failed proofs. This profile grants no rebuilt-image, complete ABI, licence or GPU acceptance.

The source and parent proof hashes remain in `invocation.json`; real SDK receipts are inputs, never generated from a stage plan. `test-normal-stage-launch.sh` uses synthetic OCI bytes and explicit command/qualification doubles, covers source/parent/host/transport refusals and cannot establish source provenance or hardware acceptance.

## Observe and checkpoint

```bash
python3 linux/scripts/local-proof/observe-full-preflight.py \
  --directory logs/test-results/preflight-001 \
  --output logs/test-results/preflight-001-observation-001.json --processes

python3 linux/scripts/local-proof/checkpoint-proof-runs.py \
  --preflight logs/test-results/preflight-001 \
  --preflight logs/test-results/preflight-002 \
  --state logs/test-results/work/state.json \
  --markdown logs/test-results/work/CURRENT.md \
  --output logs/test-results/work/units-001.json
```

Both runs use adjacent `<directory>-invocation.json` records. Checkpointing preserves unrelated
state fields and old handoff text, records every supplied unit, and replaces only its own marked
Markdown block on later calls. A running unit's `Result=success` is an observation, never a pass.
No observer stops or restarts a producer. The shared watcher recognizes a retained oneshot only after its recorded exit, zero main PID and `active/exited` state; a live success field still cannot finish observation. Sealing requires its loaded successful terminal state,
exact mutation IDs, all source groups, raw statuses, cleanup and an independent absence query.

The optional `replay-full-preflight.py --jobs 8 --memory 20g` profile additionally requires
`--resource-admission`, `--existing-preflight` and `--compiler-unit`. It rechecks the existing
four-worker/12-GiB producer's identity, memory peak, current limits and live host reserve before
creating the new run. It never changes that producer. Other resource profiles require review.

## Failed compiler linker diagnostics

`compiler-prefix-diagnostic.py prepare|launch|seal` takes an explicit failed-plan JSON,
directory, fresh unit and local image name containing `unverified`. Preparation requires a
loaded failed producer with zero PID, a nonzero exit and an absent normal candidate. It extracts
the unchanged Dockerfile prefix before the required smoke and labels that diagnostic image.
Launch retains the normal 180-GiB admission, original source identity, bounded unit and compiler
cache arguments. It can execute heavy stages again; a prefix extraction does not prove reuse.
Neither extraction nor a successful diagnostic build qualifies a compiler, SDK or final image.

After sealing that component, `launch-cross-clang-link-probe.py launch|seal` binds its exact
image to `--prefix-proof`, a fresh unit/directory and `--mode baseline|gcc-sysroot`. It copies the
worker, shell entry, minimal C fixture and existing native-wrapper C/C++ fixtures together.
The worker uses the image's baked bounded command transport and normal LLVM loader publication.
It preserves real verbose linker stderr, dynamic/static results, GNU-reported sysroots and
static native/QEMU executions for all three architectures and both drivers. The optional mode
changes only the foreign diagnostic commands' sysroot to GNU's reported root. The native
GNU driver is the unprefixed source binary and may legitimately report an empty sysroot; its
native wrapper remains unchanged in both modes. Raw GNU facts are written before validation. It is evidence for a
source repair, never a replacement for repairing and rebuilding the normal wrappers.

Sealing requires the exact six tuples, unchanged native Clang bytes, all three CPU backends plus AMDGPU, no
preload and real successful required links/executions. Expected baseline foreign failures must
have positive raw statuses and actual stderr; a timeout or signal cannot supply them. Owned
containers are bounded, removed by the shared cleanup helper and independently queried absent.
Keep both failed and successful controls. The tests and mutations exercise refusal behavior
with doubles; only retained actual runs can prove what the image did.

The ordinary common compiler smoke now preserves linker stderr and its raw failure status in
the aggregate diagnostic. It refuses invalid temporary allocation and records failed cleanup.
Its C input through both drivers still does not prove the full C++ ABI or final runtime.
Object and link suites share the harness's invalid-allocation emitter; its failed, empty and
missing-directory outcomes remain distinct.

## Explicit compiler image qualification

A current canonical compiler run can supply `image_qualification_profile: "compiler-cross-cpu"`
in its separate qualification input, preserving the original producer invocation unchanged.
Plans carrying `source_proofs` require that explicit profile; unknown profile values fail.
The historical `launcher_contract: 2` path still selects the same complete CPU checks.
Both default and login modes require all six cross wrappers, four foreign static executions,
native C/C++ programs, the four LLVM backends and the actual loader/default selection checks.
The OCI parent validator uses that same required scope. Synthetic profile and transport
fixtures do not prove an image, GPU inference, receipt provenance or finished consumers.
The subject and OCI modules belong to strict ty and focused annotation coverage. The type
driver supplies their real sibling roots; its fixture imports across those roots and plants
type and annotation errors in both modules without reducing the existing scan.

## SDK component qualification

Pass the actual normal SDK's `invocation.json` through `--sdk-invocation` to both
`compiler-image-qualification.py launch|seal` and `native-oci-handoff.py launch|seal`.
Keep `--plan` pointed at the unchanged compiler plan. The amd64, arm64 and
riscv64 profiles require the same complete source and its sealed 26-layer
compiler parent. The producer unit, stage command and image alias must select
the same SDK target.

The qualifier uses a fresh `webgpu-sdk-image-qualification-<id>.service` and output directory.
Retain the original `--plain-load-probe` and `--original-qualification` inputs. The SDK's
materialized `/opt/llvm-target` must own all 157 native tools and source LLVM loader selection;
its `llvm-target-amd64` alias, exact two native wrapper scripts, driver byte comparisons and
actual native C/C++ object/link/execution smokes must pass in default and login shells.
For arm64 and riscv64, the Linux amd64 SDK image must retain the real
`/opt/llvm-target-amd64` host tools and source loader. The target alias must
resolve to `/opt/llvm-target`, and both target driver ELF headers must match the
selected architecture. Both target wrappers must compile, link and execute
the static C and C++ smokes under QEMU in each shell mode. These profiles
cover the selected compiler checks. Full C++ ABI, Vulkan API and GPU inference
remain separate. The compiler image retains its three targets and four
foreign QEMU executions per mode.

SDK OCI exports use `webgpu-normal-sdk-export-<arch>-<id>.service` and a fresh `sdk-context-*`
directory beside the compiler plan. Sealing hashes every native blob, binds the actual SDK
manifest/config and matches every compiler parent descriptor and diffID; the compiler path
retains its original 12-layer base check. The unchanged 180-GiB admission applies before an
export or subsequent heavy build. Receipts record the supplied invocation, parent and source
proof hashes; they do not authenticate those inputs. SDK component success never supplies a
final runtime or consumer receipt.

Copy `proof_subject.py` and `proof_commands.py` beside both CLIs; the OCI handoff also requires
`native_oci_layout.py` and `native_oci_seed.py`. Their CPU worker uses
`probe-cross-clang-image.py`, `qualify-compiler-with-cross.sh`, the original native qualifier,
loader probe and C/C++ inputs together. SDK fixture runs also carry `sdk_profile_fixture.py`;
all recurring logic stays versioned and per-run arguments/results stay under `logs/`.

## Verified parent layer reuse

SDK exports use the current versioned toolkit's `01-core/context-management.sh` and pass the
sealed compiler parent proof as the fourth `export_image_to_oci_layout` argument. The default
three-argument path retains its existing reset policy. The optional seeded path refuses any
existing destination, then checks the parent receipt, index, manifest, config and every blob's
size/SHA256 before linking unique layer files into the fresh child context. Unsupported
hardlinks fail; no silent full-copy fallback changes the space requirement. Parent and child
contexts must not overlap or resolve through symlink directories, and proof/metadata/layer
inputs remain regular files. Child index, layout and config are written independently.

`tar --skip-old-files` preserves those immutable layer links. The transport retains producer
and extractor raw statuses, including under conditional callers and ordinary errexit, and
returns the rightmost pipeline failure. Seeded exports write `<context>.transport.json` and
`<context>.parent-links.json`. The sealer requires both statuses to be zero, the exact worker
hash manifest, every recorded unique digest/path, source/child device/inode and post-link
size/mode/owner/mtime identity, and independent child index/layout files. New schema-2 link
receipts exclude ctime because creating another sibling or descendant link advances that
timestamp on the same unchanged inode. Every parent blob is still rehashed before replay;
equal-byte replacement inodes and changed stable metadata still fail. Schema-1 receipts retain
their original ctime requirement, including refusal after a later link advances it. Historical
receipts are never rewritten or silently upgraded. These checks prove current bytes and file
identities, not the absence of every past write. Source hashes and logical paths stay unchanged.

The byte protocol accepts sealed native default Media and Android parents for
amd64, arm64 and riscv64. Each status names its target, stage and parent type,
for example `passed-native-default-arm64-Media-OCI-and-SDK-ancestry-only`.
Each profile retains the same manifest/config/index, every blob hash, layer
count and stopped-export checks. The default and ROCm launchers require their
own variant and source receipts.

Only layers are shared. Parent receipt and source paths remain explicit, and every final child
blob and ancestor descriptor/diffID is still verified. These local checks do not authenticate a
supplied parent receipt or establish complete ABI/GPU acceptance. The original 180-GiB admission
still applies; shared-byte arithmetic is not a disk guard. Re-measure actual space and preserve
the usual cachemount, image, source and receipt protections during any authorized cleanup.

`test-native-oci-seed.sh` uses synthetic OCI data, real tar extraction and declared engine/unit
doubles to test preservation, symlink/path/receipt refusals, equal-byte inode changes, both raw
failures and the actual SDK launcher/sealer logic. Mutation recipes break these guards. Copy its
`native_oci_seed_tests.py` and `native_oci_transport_fixture.py` companions together. The shared
layout module retains the existing compiler API and 12-layer base checks.

## Copied package staging

`local-proof/cleanup-package-staging.py` previews or retires only the copied `oxidant`,
`oxidant.AppDir` and `deb` trees of a closed private AMD package producer. Run it in an
owned bounded container: mount that producer's literal `package-work` directory at
`/staging`, its three retained archives read-only at `/archives`, and a separate proof
output. The CLI accepts `--plan PLAN --output NEW_PROOF`; only `--apply-preview PREVIEW`
performs removal after matching the complete preview snapshot.

The supplied plan binds the producer unit, full CID, owner label and nonce, original
invocation and terminal-proof hashes, host path and mounted device/inode. Fresh observations
must show PID 0, exact CID/label absence and no registered or nested mount conflicts.
All three nonempty archive hashes must match. Unknown entries, source/cache names,
shared file inodes, special files or changed staging refuse before removal. Descriptor-based
removal selects only the three copied trees; the private home cache and package archives
are checked again afterward. Preserve source checkouts, compiler targets and all receipts.

These checks require an authorized caller to gather truthful host observations and prevent
new writers. They do not authenticate supplied facts, inspect archive contents, establish
future quiescence or replace build/consumer acceptance. Fixture and require-removal mutation
controls cover these boundaries; only a real retirement measures actual reclaimed space.

## Authorized cleanup

```bash
python3 linux/host-config/autonomous-safe-prune.py launch \
  --directory logs/host-maintenance/prune-001 \
  --unit webgpu-safe-prune-001.service \
  --authorization /absolute/path/to/owner-operational-rules.md
```

The supplied file must contain the standing owner authorization for autonomous canonical
`prune-safe.sh` cleanup. The worker retains that check, snapshots image identities and all
cachemount IDs, and skips reclaim when the unchanged 180-GiB reserve already passes. It uses
`PRUNE_KEEP_GB=120`, disables duplicate-cachemount cleanup, and retains at least 100 GB during
builds. A smaller explicit `--keep-gb` requires `--idle-store` and an idle store before and after.
Changed identities, failed queries or failed cleanup cannot produce a successful receipt.
Call the same driver with `seal` after its loaded successful terminal state; retain the original
directory, unit and authorization arguments. This creates no timer or recurring service.

These checks record supplied facts; they do not authenticate an authorization file, prove GPU
inference or replace final runtime/consumer acceptance. See [host setup](linux-host-setup.md#b7-reclaiming-disk-without-losing-the-compile-caches)
and [quality tooling](code-quality-tooling.md#preserved-local-proof-workflows).

#Independent consumer source preservation uses the helper in the table above. It waits
for the consumer log, which opens after source preparation, and copies committed Git
trees and recursive pins without hardlinks, alternates or promised objects. Reuse
rechecks HEAD, index, working-tree cleanliness and object integrity. It preserves no
build outputs and authenticates no source; retain the acceptance receipt and its
original source/lock evidence separately. Missing or not-yet-ready consumers remain
pending. A partially failed copy remains diagnostic evidence and is never a passed
preservation receipt. Ordinary successful acceptance retains its original checkouts.

## Bounded runtime storage observation

Start `linux/scripts/launch-runtime-storage-guard.py launch --runtime-invocation /absolute/runtime-output/invocation.json --directory /absolute/runtime-output-storage-guard --unit webgpu-safe-prune-runtime-amd64-20261115-1.service --authorization /absolute/path/to/owner-operational-rules.md` immediately after the ordinary runtime has an actual live PID. Run it from the runtime's host tools checkout. Place the directory beside the runtime output with the `-storage-guard` suffix: local FINAL reads an unloaded runtime's guardian only there and at that revision. The launcher refuses anything else. Pass an unchanging copy of the authorization file; FINAL rehashes it. The guardian requires a clean committed owning checkout, its complete worker hashes, the supplied standing authorization, the successful launch record and the same live unit, command, PID and `/proc` start ticks. It starts no producer or container.

The six-hour oneshot uses a separate control group, 256-MiB memory limit, 25% CPU quota, literal arguments and a fresh on-disk temporary directory outside Git. Between one-second waits it checks the producer and free bytes. Below the unchanged 193,273,528,320-byte reserve, it considers only unused, unshared regular layers above a 100-GB retained layer budget. Every record type reporting zero in-use records does not make the outer live build idle. A new eligible pressure state triggers the existing `autonomous-safe-prune.py worker` synchronously inside the same control group, with its full before/after preservation checks and duplicate-cachemount cleanup disabled. It rechecks source and process identity immediately before dispatch. Unchanged ineffective candidates do not loop; a worker that skips because space recovered can be retried if pressure returns. No image removal or recurring timer is installed.

When the watched producer ends, preserve its actual outcome: a failed producer gives the guardian status 1. Systemd can retain `failed` after a successful stop of an already failed unit; accept that stopped state only with PID 0 and the previously verified failed outcome. Successful guardians still require `inactive`. The original Runtime5 controller's old seal failure is retained, not rewritten as a successful receipt. Call the same CLI with `seal --directory /absolute/observation` after the guardian actually terminates; sealing checks raw unit results and cleanup-proof hashes, stops only the guardian and writes `proof-stopped.json`. Errors, a missing producer or a changed binding fail visibly. Retain observation rows, child cleanup receipts and unit logs. The result is storage observation only; it cannot establish timely reclamation, sufficient future space, a successful image, FINAL consumers, complete licences or GPU inference. Synthetic lifecycle controls and parse-valid gate mutations cover refusal, transport and receipt behavior; a real later build must demonstrate actual reclamation timing.

## Validation

`bash linux/scripts/tests/test-local-proof-tools.sh` checks the inventory, portable paths,
independent cross-wrapper and SDK-parent refusal fixtures, cleanup authorization, budgets and
identity preservation. It uses disposable host doubles and cannot reclaim real storage or prove
an image. Mutation recipes remove the corresponding guards and must fail assertions. Existing
`test-proof-workflows.sh` remains responsible for the isolated runner and observer transport.

## Consumer command seals

`linux/scripts/seal-command-unit.py` replaces repeated manual terminal-command sealing for
consumer jobs whose invocation and cache capture are already preserved. Run it only after
the actual unit is terminal successful:

```bash
python3 linux/scripts/seal-command-unit.py --directory /absolute/job-output \
  --unit webgpu-consumer-example.service --success-marker 'Actual command passed'
```

The directory needs `invocation.json`, `unit.log`, `compiler-cache/exit-status.txt` and
`compiler-cache/cache-stats.json`. The invocation records the unit, run ID and owner label.
The log must contain every supplied marker as a complete line, both raw statuses must be
zero, and the existing shared terminal verdict must pass. The tool records input hashes
and the uninterpreted cache counters, stops the unit, and requires matching owned cleanup
with exit status zero before writing `command-proof-stopped.json`.

Existing seals and `cleanup.json` refuse before stopping: an exclusive cleanup cannot be
replayed, including on a retained terminal Runtime producer. Keep `seal-mutation-unit.py`,
`runtime_terminal_evidence.py`, `host_commands.py` and `source_ci/common.py` with this entry.
The supplied marker is not authenticated; a seal proves command lifecycle and cleanup,
not artifact contents, cache success, physical GPU inference, clean-host behavior or image
promotion. Preserve independent engine-absence and acceptance checks separately. Mocked
regressions and their mutation recipes live under `linux/scripts/tests/`.


## Reviewed OCI archive deduplication

`linux/host-config/deduplicate-oci-archives.py` previews an explicitly reviewed
list of immutable `blobs/sha256` files. It hashes actual bytes, requires ordinary
owned files in literal OCI layouts, and groups only equal device, ownership, mode,
size and modification time. Nested Git checkouts are refused. Already linked files are counted once. Outside links,
receipt-bound file identities and receipt-bound immediate parent directories are
excluded, including the keeper, so their ctime and link count remain untouched.

Pass every operational JSON receipt root explicitly. Identity fields, positional
identity records and escaped JSON keys are inspected; identity-bearing parse or
read failures abort. Identity detection consumes complete quoted tokens once and examines JSON keys; unrelated malformed source manifests remain byte-fingerprinted without being treated as identity receipts. Proofs in other formats or outside those roots are not covered.
JSON aliases pin their target contents and link value; dangling aliases remain tracked, and non-file targets fail. Receipt metadata must remain stable across reads. The operation's fresh proof directory is excluded from its own receipt scan.

```bash
python3 linux/host-config/deduplicate-oci-archives.py preview \
  --review "$candidates" --expected-sha256 "$candidate_sha" \
  --root "$allowed_root" --receipt-root "$allowed_root" \
  --receipt-root "$worktrees" --directory "$proof" \
  --authorization "$authorization" --engine "$engine"
python3 linux/host-config/deduplicate-oci-archives.py apply \
  --review "$proof/preview.json" --expected-sha256 "$preview_sha" \
  --directory "$proof" --engine "$engine"
```

The authorization JSON selects `allowed_actions: ["oci-archive-dedup"]`, a nonempty
`owner_instruction` and the exact `candidates_sha256`. It records supplied authority;
it cannot authenticate the person supplying it. Preview and apply retain fresh
engine/unit observations. Apply refuses changed inputs, authorization, receipts or
file identities and never repeats an existing journal. Each replacement is atomic;
the entire operation is not a transaction. A failure retains its journal and cannot
produce a success receipt. Final verification checks all replaced paths, content,
stable metadata and protected receipt bytes. Observations do not lock other writers.

Copy `oci_archive_dedup.py`, `host_commands.py`, `source_ci/common.py`,
`local-proof/native_oci_layout.py` and `local-proof/native_oci_seed.py` with the CLI
in the shared layout; the native OCI type companion remains in that closure.
The fixture suite uses temporary layouts and stubbed transports; it does not run
Docker/BuildKit, authenticate receipt roots, or prove image/GPU acceptance.

## Retiring closed temporary quality environments

A retained `ant-quality-venv-*` directory is a disposable installation of the locked
quality tools. Match each literal owned temporary directory to its original
`relocate-quality-venv.py` closure receipt and `tree_digest`, and exclude live
process or container references. Shared compiler, Cargo and uv caches, consumer
sources and finished packages are outside this workflow.

Preserve the reviewed environments in a durable archive and compare every member
before clearing them. Keep the exact root lists, source hashes, archive hash,
native command arguments and raw statuses in the operation receipt. Native tools
implement the recurring operations; those lists are reviewed inputs.

```bash
tar --create --format=gnu --numeric-owner --sort=name \
  --use-compress-program='zstd -T4 -6 --long=29' --file "$archive" \
  -C "$temporary_root" --null --verbatim-files-from --files-from "$relative_roots"
tar --compare --numeric-owner --use-compress-program='zstd -d --long=29' \
  --file "$archive" -C "$temporary_root"
xargs --null --no-run-if-empty --max-args=1 --max-procs=1 \
  --arg-file "$absolute_roots" uv venv --clear --offline --no-project \
  --no-python-downloads --no-managed-python --python /usr/bin/python3 \
  --prompt antfrastructure-quality --
```

Recheck closure hashes and original receipt hashes immediately before the native
clear operation. It leaves empty virtual environments that can be recreated from
the owning locks; preserve the archive for exact restoration. The observations do
not lock other writers, authenticate receipts or establish runtime acceptance.

## Cleanup and relocation invariants

Rules for local proofs that clean up, relocate or retire trees. Each item is one rule.

- Isolated preflight mirror opt-ins use the shared Ubuntu rewrite before apt. Retain signed source metadata, the recorded URL and default-off behavior.
- Relocate only closed, Git-ignored quality venvs to a different existing tmpfs. Shared inodes, nonregular payloads or changed canonical archive bytes cannot produce a receipt.
- Recurring source proofs use the versioned launcher and current recipe definitions by ID. Retain reviewed resource limits, matching tool locks, fresh units, raw statuses and canonical cleanup.
- Share unconditional and source-order wiring checks through `Assert-TestAstCommand -Unconditional` and `Assert-TestAstOrder`.
- Isolated preflight installs the source-pinned managed FT interpreter, retains it across env-i and refuses wrong versions, enabled GILs or missing headers before running gates.
- Reviewed OCI archive deduplication uses its versioned preview/apply helper, preserves equal bytes and stable metadata, and excludes receipt-bound or externally linked inodes. Copy its host-command and native-OCI companions together.
- Retire closed temporary quality installations only after closure hashes and a durable archive comparison match. Retain source trees, packages and shared compiler/Cargo/uv caches.

## Local launch and handoff invariants

Rules for the local stage launches, their handoffs and the operational toolkit. Each item is one rule.

- - Local GPU-to-Media handoffs rehash native OCI bytes and SDK layer/diffID ancestry. Require the actual terminal GPU producer, exact source proof and bounded export before ordinary Media with both required Wasm modes. Resolve the immutable local manifest ID independently against the tagged config before export. Media retains its repository@digest and native-context binding.
- - Ordinary local Media launches require at least 300 GiB available across the default, ROCm and NVIDIA lanes. A stricter plan still applies.
- - A ROCm Media source newer than its GPU parent requires `media_source_profile.py`: ancestry, its own complete source proof and byte-identical compiler, SDK and GPU inputs, rechecked at the Media export ([alternate Media source](#a-media-source-newer-than-its-gpu-parent)).
- - Local Media-to-Android handoffs retain the same exact source/command checks and native GPU ancestry. Keep distinct Media receipts, complete worker companions, raw export statuses and the unchanged disk floor. Android precedes runtime. Native exports are not FINAL acceptance. Native Android exports keep their own subject and all Media ancestors. GPU/Media/Android copies carry `stage_handoff_profile.py` and the recursive parent companions.
- - Ordinary local runtime launches retain the verified native Android layout, exact app commit, all three fresh canonical image names and default image wheel transport. Create the immutable local alias from the verified source tag and independently inspect its bare manifest/config. Preserve the post-tag identity checks. Carry `owned-nerdctl.py`, `owned_nerdctl_args.py`, `owned_containers.py`, `host_commands.py` and the cleanup entry together. Install the same fresh ownership token, required cleanup CID-file argument and ExecStopPost before launch, then require cleanup and an independent absence query before acceptance. Runtime command success is not FINAL consumer acceptance.
- - The alternate ROCm runtime selector requires the exact reviewed wheel-context/smoke-export source with context-valid exporter controls and its own complete current preflight before any tags or units. An older source receipt cannot qualify the repair. Preserve the original Android/native parent, shared admission minimum, app commit and invocation cleanup bindings. Ordinary ROCm runtime launches additionally require at least 300 GiB before allocating outputs, aliases or units.
- - A bounded local FINAL run keeps the complete canonical consumer plan, committed tooling and successful runtime binding. Install fresh UUID-labelled container cleanup before any consumer work and require actual terminal unit status, receipt validation, canonical cleanup and an independent empty label query before the stopped proof. Failed outer status cannot become acceptance through an inner receipt. An unloaded successful runtime requires the sealed canonical guardian plus freshly queried trusted same-boot lifecycle records. Preserve actual exit time and explicit observation provenance, and never infer success from not-found defaults. Copied acceptance/guardian workers carry `runtime_terminal_evidence.py`.
- - A runtime storage guardian binds one already live ordinary runtime by invocation hash, unit, PID and start ticks. Commit its source and worker closure before launch. Reuse the canonical regular-layer worker synchronously in its bounded control group, retaining at least 100 GB while the outer producer is live even if BuildKit reports zero in-use records. Never restart, stop or accept the producer from storage observation. Retain failed producer status in the stopped receipt. A stopped failed unit may retain systemd's failed state with PID 0. A successful guardian still requires an inactive stopped state.
- - The explicit ordinary-runtime `--serial-smoke` host option sets only `RUNTIME_SMOKE_OVERLAP=0`. Keep the same required smoke, raw failure, production source proof, app, native parent and cleanup bindings. Ordinary overlap remains the default.
- - Automatic local image cleanup selects explicit obsolete published tags, verifies their immutable registry manifests/configs and waits for an idle engine. Preserve current build parents, E30/receipts, all cachemounts and every unselected image identity. Keep before/after evidence and recheck the ordinary reserve ([host cleanup](linux-host-setup.md#b7-reclaiming-disk-without-losing-the-compile-caches)).
- - Native ORT, OpenCV and app-wheelhouse Media cache readers require the outer RUN and the Media unit family. For OpenCV, require the final drain after the build command. Retain mandatory worker/profile hashes and explicit partial-timeout scope. IREE configure snapshots require the selected target build tree and the same live process identity.
- Diagnostic compiler prefixes remain explicitly unverified and cannot qualify an SDK parent. Retain the failed producer and mandatory source smoke.
- Keep run-specific inputs, extracted code and reports under `logs/`.
- Add missing recurring functionality to Git before its next use.
- Local BuildKit cache transfers use `local-proof/seed-buildkit-cache.py` with its stopped-producer proof. Preserve separate mutable metadata and verify the actual next command's cache import before launch.
- A transport receipt does not prove cache hits.
- Current compiler plans with `source_proofs` require `image_qualification_profile=compiler-cross-cpu`. Retain both shell modes, all six wrappers and the OCI parent refusals.
- Its subject and OCI modules stay in strict ty and ANN001/ANN201 scopes. Retain their sibling module search roots.
- Direct-suite failures retain raw failed status and assertion logs. A missing mutator log cannot become passing mutation evidence.
- The permanent isolated preflight, unit watcher and native plugin probe are documented in [quality tooling](code-quality-tooling.md#preserved-local-proof-workflows).
- Isolated preflight keeps the mounted worker transcript separately from engine attach output. A missing or linked transcript cannot pass, and complete source acceptance still requires every normal group and mutation.
- Complete-preflight cleanup readers accept joined and separated systemd property arguments, require exactly one ExecStopPost, and retain the original argv and all cleanup/owner checks.
- Isolated preflight requires the engine init to reap orphaned test children. Group-disappearance checks stay strict.
- Cached-image replays use its explicit image and read-only native-tools-cache options. Retain report writability and record the altered environment scope.
- Long isolated-preflight units pass one fresh run-id to both the driver and independent cleanup hook before launch.
- Container cleanup tools also carry `owned_containers.py`. Long container units require its `cleanup-owned-containers.py` ExecStopPost hook with the same fresh label/token and CID file.
- Source CI dispatch, retrieval and audits use `source-ci.py` with its `source_ci/` and `host_commands.py` companions.
- Mutation seals require a loaded, terminal successful unit before stopping. Cached default success is insufficient.
- Direct-wrapper complete receipts use the original closed evidence and unchanged canonical suite discovery. Never synthesize driver run.json, re-seal or repeat exclusive cleanup.
- Native worker source tests require Dart, C/C++, Rust and sccache. Use `ensure-native-worker-test-tools.sh` and preserve mandatory VM coverage.
- Flutter `--keep-cache` is a test-runner opt-in. Fresh image installs retain their default bare-SDK policy.
- Check the [fallback-font lock](../linux/webserver/README.md#fallback-fonts-from-the-site) against the exact pinned Flutter SDK when its engine changes.
- Parity CLI copies carry `lib/cli-value-options.sh` and logging companions. Retain usage alias binding and complete remaining arguments.
- `+CALLBACK` CLI dispatch uses an output count and an unconditional invocation. Do not swallow the caller's active errexit policy.
- Container transport fixtures accept the shared runner security and value flags before parsing the image and command. Preserve the production AppArmor setting.
- QAIRT endpoint exchange uses `qairt-key-handoff.py`. Private keys and decrypted endpoints stay outside every Git checkout, and issue comments carry only public SPKI keys, fingerprints or ciphertext.
- Private SDK delivery uses `qairt-private-transfer.py` beside the key helper. Retain exact source/remote hashes, conditional no-replace, bounded execution and redacted receipts.
- Receiver cache/hash gates stay mandatory.
- An alternate runtime source requires its own complete source proof and explicit reviewed selection. Preserve the original Android source, invocation and native ancestry separately. A host-tools commit or the parent's source proof cannot qualify changed runtime code. A later runtime source on a newer Android parent may differ only in host-only runtime files ([runtime source](#a-runtime-source-newer-than-its-android-parent)).
- Literal shell expressions in unit argv require `--expand-environment=no`. Host-shell quoting does not disable systemd expansion.
- Container engines may keep their payload outside the starter unit. Use the versioned owned-container ExecStopPost hook and verify cleanup separately before handoff. Command success without stopped/PID0 or absence is insufficient. Retained failed containers stay stopped.
- User units retain system utility directories in PATH, including `/usr/sbin` and `/sbin`, for probes such as `ldconfig`.
