Shared script libraries (linux/scripts/lib/)

Contents

Shared script libraries (linux/scripts/lib/)#

shared/python/verify_ort_loader_trace.py owns ORT/plugin loader parsing for Linux bundle and AppImage evidence. Its public verify_loader_traces API retains caller layout rules and optional live symlink resolution. Profile mode requires the sibling verify_ort_profile.py and binds the selected trace to the provider-checked process; see loader evidence for arguments, the copied closure and the limits of path/process evidence. The shared profile suites carry shared/python/tests/ort_profile_fixture.py with their tests.

Sourceable, project-agnostic cores. Nothing about a specific project is hard-coded in any of them. The contract is always the same:

  1. A thin wrapper script sets that library’s *_DEFAULT_* / *_* variables — its project defaults.

  2. It optionally declares hook functions.

  3. It sources the library and calls the library’s *_main.

None of them set -e/-u/-o pipefail: sourcing must not change the caller’s shell options, and wrappers are expected to run under set -euo pipefail themselves. Neither do the 01-core/ modules loaded through source_module (logging.sh, common.sh, build-helpers.sh, platform.sh, verify.sh, downloads.sh, …), with two exceptions documented at file scope: 01-core/python_uv.sh (a consumer inherits strict mode from it) and the test suites, which run set -u without -e because the harness decides the exit code. Anything the wrapper does not provide is discovered from the environment — logging from 01-core/logging.sh (or minimal fallbacks), job computation from 01-core/parallelism.sh, tool presence and the Vulkan environment from the caller’s own has_tool/require_tools/source_vulkan_env when it declares them.

Three have their own pages, because their topic is bigger than the library: code-quality.sh, slang-compile.sh, and the agentic-loop.sh + agentic-engines.sh pair, one executable loop in two files (agentic-loop-build-matrix.md).

The Slang twins accept additional pinned source roots and import an owner’s WGSL manifest without a copied definition; their caller parameters and ownership rules are in slang-shader-compilation.md.

Shared compiler and media probe policies#

Smoke ELF inspection calls the canonical platform.sh parser. A preloaded parser keeps precedence; otherwise the existing platform loader runs in a subshell so its functions and flags do not change the smoke caller. Toolchain copies carry that platform owner. Compiler validation shares its separate raw Machine: query and case-insensitive comparison, retaining host versus swapped/target failure policy.

GStreamer and OpenCV collect optional target-Python paths in caller-selected order through cross-python.sh. Missing probes preserve existing fields; failed probes retain partial stdout. Cargo compiler bindings share environment publication in cross-env.sh; callers keep compiler validation, wrapper choice, host variables and Rust-name policy.

Host Cargo compiler setup shares the nonempty-compiler check, wrapper capture and parent-shell publication in compiler-resolution.sh. Each caller retains its resolver order and publishes from its original local slots. Selected callbacks run unconditionally so strict wrapper failures and partial publication keep their original behavior; internal argument-free calls stay argument-free.

Optional runtime libstdc++ pinning shares availability and advisory invocation in media’s existing core/common.sh. FFmpeg and GStreamer bind both lookup and pin commands where the original commands were parsed, forwarding the original caller arguments to preserve prefix aliases. Compiler setup and architecture gates remain caller policy. A selected caller refuses an older media owner that lacks this transport; both producers inherit its fresh local Dockerfile copy.

Test fixtures share probe execution, rescued-stage assertions and Renovate apply and permission lifetimes. They retain independent child cleanup so mutating a production stop function cannot strand the test’s own processes. Retention fixtures share budget assignment followed by the real prune call, keeping that budget visible afterward and retaining raw failures. Archive setup and every literal archive expectation remain independent.

Privilege, APT and target Cargo policy#

sudo-policy.sh owns privilege selection and availability enforcement. Caller-bound publishers retain the original SUDO and optional SUDO_WRAP assignments, including readonly failures and attributes. Common keeps SDK delegation ahead of import; bootstrap loads the policy only when its common lookup misses. Its internal leaf lookup remembers the bootstrap owner at import time, independently of later directory changes and the project directory passed to the common lookup. Copied modules carry the policy: base and compiler recipes use narrow readonly binds, SDK copies it, and existing whole-core provisions carry it without extra inputs. The policy is an L0 leaf.

cross-apt.sh owns update selection. apt_update_smart alone supplies its historical -y default; GStreamer passes its original arguments unchanged. Lookup and update commands retain their caller bindings and parent-shell effects. Helper lookup prefers the current repository owner, then the installed layout, while leaving the SDK updater itself unchanged. The internal --ant-source-apt-update-only mode exports selection before the loaded flag and full-module provider definitions. GStreamer validates the exact first-line # ANT_APT_UPDATE_SOURCE_API=1 marker before sourcing that mode, so older owners cannot ignore the argument and replace an SDK updater. Owned selection exports are refreshed, with unset, source and missing-export failures kept visible. Existing fresh cross-APT provisions carry this API without another companion.

Target Cargo setup shares the optional resolver guard and selected CC/CXX value transport in compiler-resolution.sh. Rice keeps one capture and GStreamer two separate captures; callbacks remain inside them so late aliases bind at the same point. Caller-local compiler slots, Rust-name derivation and parent-shell publication keep their original lifetimes and order. Offline tests use fake providers; they do not compile Rust or install packages.

Shared ONNX staging and report fixtures#

ONNX Runtime and GenAI append their shared cross-toolchain definitions from the existing ONNX build library. Python, Rust and test switches remain caller policy, as do the order and spelling of compiler arguments.

01-core/elf-strip.sh also owns filename-based shared-library traversal and batched advisory actions. Callers supply depth, filename patterns and action arguments; this operation does not replace the content-based ELF probes in strip_elf_tree. Copied build helpers still carry this existing companion.

Copied-gate fixtures share allow-row creation and gate invocation. Version and mutation suites reuse the common workspace lifecycle while retaining their distinct cleanup and input trees. Fixtures continue to execute the actual subject gates.

Shared cache, dependency and packaging operations#

01-core/compiler-cache-utils.sh supplies launcher selection and start/health probes without initializing defaults or starting a server when sourced. Copy it beside common.sh, compiler-cache.sh and standalone cache probes. Base-image steps use narrow companion mounts. Copied-module refusal fixtures first load the complete closure successfully, then remove only the targeted companion. Another missing dependency cannot stand in for the protected failure. Callers retain hook versus direct startup, stream routing, S3 defaults and failure policy.

install-deps-preamble.sh reports staged target Python development readiness; GStreamer, LiteRT and OpenCV retain their native/cross decisions and version lookup policy, including an explicitly empty OpenCV version. Media core owns optional Vulkan toolchain import. GStreamer pre-setup shares pkg-config rendering while retaining fatal Vulkan and advisory Csound write failures and SDK precedence.

app_packaging_write_deb_control renders control metadata for native and Python packagers. Its optional ninth argument distinguishes an omitted Homepage field from an explicitly empty one. Caller defaults, multiline descriptions, builder arguments and failure status remain caller policy.

Linux test fixtures share compilerless CMake projects, source-module invocations, preflight extraction and disposable workspaces. The workspace loads the test harness; function extraction uses its existing t_source_functions. Harness receipt writers preserve ordered shell-quoted fields, and worker invocations pass the harness path explicitly. t_capture_command captures merged output and raw failure status for assertions; it does not turn a failed command into a successful test. These fixtures exercise stubbed operations and do not prove live cache servers or package builds.

The packaging inventory companion also owns media_rocm_library_paths [IMAGE_ROOT]. It emits image-relative directories with source MIGraphX first, one entry per existing directory, and excludes ASAN. Its shared publish_rocm_ld_path uses that complete list only after a successful scan and sort. The normal GPU entry and runtime copy entry call that same publisher. Copied consumers already carry media-payloads.sh; no private publication or path-ordering copy is needed. These filesystem controls do not establish actual loader selection or GPU ABI.

Selected script closures#

script_closure.py owns deterministic selected-file staging; its CLI is stage-script-closure.py PROFILE. The plans under script-closures map source files to image paths and include other plans explicitly. SDK and AMD consume one common core selection, while their remaining files stay profile-specific. The stager reads every selected source before allocating a fresh output, preserves its bytes and records hashes, rejects unsafe or ambiguous inputs, and normalizes file modes and timestamps. The receipt describes staged sources only.

The cross-stage driver reads one literal Dockerfile profile label with stage-script-closure.py --profile-for DOCKERFILE. It stages fresh selected bytes under the run’s log directory. --context prints only the full receipt SHA256 and stages the bundle at PATH/SHA256/files/. The driver validates that key and passes both --build-context hub-scripts=PATH and --build-arg HUB_SCRIPTS_KEY=SHA256. SDK COPY and AMD read-only mounts select that exact namespace and leaf; a missing key cannot fall back to the flat root. The legacy flat staging API remains available for its existing callers. Dry runs validate the profile without creating a staging directory. Query, allocation and staging failures retain their raw status and prevent dispatch. Legacy Dockerfiles without this contract keep their existing argument list.

The absolute script-copy gate follows the declared external context only through its actual COPY or read-only bind transport, including a declared FROM alias. It also models canonical internal producers when all selected inputs and transitive plans are mounted. Its read-only --provided-scripts Dockerfile.sdk report gives a JSON image-path/source map. The shared structural fixture runs that report in a fresh process, retaining copied-root isolation. Cold SDK import suites use the actual declared map and prove required-child failures; they do not establish SDK execution, binary ABI or BuildKit hits.

script_context_cache.py and probe-script-context-cache.py reuse that stager and the shared evidence helpers for the actual BuildKit transport probe. Both production transports, exact step markers, exported bytes and unchanged original inputs are required. The selected-source control changes bytes without changing their length; each child status is recorded before semantic assertions. Keep its fake-engine fixture visibly separate from real cache receipts.

Shared synthetic test fixtures#

linux/scripts/tests/synthetic-elf-fixture.sh provides t_write_synthetic_elf for parseable ELF64 test files. Callers choose --strsz when their probe needs DT_STRSZ, and --symbol STYLE:SHNDX when testing an ORT export through GNU or SysV symbol tables. The same writer serves the hub’s ORT census and OmniAccelerANT’s bundle closure test; each suite keeps its own assertions.

linux/scripts/tests/gst-inspect-fixture.sh provides t_write_gst_inspect_stub with an optional --with-name. Both GStreamer tests exercise element membership and the bundled-plugin path through this stub; OmniAccelerANT requests the extra Name field its gate parses. These fixtures produce controlled test inputs, not a live ELF loader or GStreamer installation.

Ordered probes and compatibility fallbacks#

Media core shares ordered regular-file checks for TensorFlow SDK completeness and staged HarfBuzz development files. Each caller keeps its branch selection, completion-stamp policy and diagnostics. Missing selected helper APIs fail before an absent function can be mistaken for an ordinary cache miss.

The platform owner visits existing directories in caller order. Cross environment publication keeps duplicate entries; LLVM keeps its colon-based deduplication. The visitor uses the caller’s dir loop binding so readonly-variable failures and shell state remain unchanged. Check the visitor and callback before invocation, then invoke it unconditionally and retain the caller’s final status policy.

01-core/cross-active-fallback.sh registers the core and native compatibility profiles. Source it at the original registration point so optional providers and aliases retain their binding time. Existing functions and commands keep precedence; the native profile keeps its false fallback. Narrow copies of common.sh and install-deps-preamble.sh carry the companion. Failed imports clear the caller’s loaded flag and permit retry after restoration.

QNN staging and CPU artifact verification share the shallow regular-library query in qnn-sdk.sh, with caller-specific filename patterns. The verifier imports it only for a detected QNN provider and requires successful sourcing and its export. The CPU verification RUN binds that exact companion without widening core mounts.

parallel-loop.sh owns advisory child signaling followed by reaping. Runtime timers and chain disk watchers keep their PID guards, variable reset and command status. Both cleanup commands remain advisory; their stderr stays suppressed. Selected timers and watchers require the cleanup API before spawning; an older loaded owner or incomplete definition cannot leave a child behind and report success. Timer fixtures share function-source assembly and carry the process definition, while real heartbeat lifetime and process-tree assertions remain independent.

The chain and single-stage CLI handlers share log-directory consumption through orchestrator_consume_log_dir. Pass their complete argument list: Bash nameref subscripts may read later positional parameters or the argument count. The consumer keeps assignment order and introduces no local alias that could shadow a target. Cross-target handling retains its separate existing policy.

Bound commands and artifact queries#

guard-helpers.sh owns first_match_using, which appends -print -quit, hides finder stderr and retains partial stdout on failure. The original first_match entry keeps its argument and local-binding behavior. LiteRT FlatBuffers and ORT TensorRT discovery bind their find command inside the existing capture, so later aliases retain their original effect without leaving callback functions in the parent shell. Existing headers still bypass the selected discovery requirement. Both producer RUNs already bind the fresh core owner.

Media smoke queries share producer stderr suppression and the grep -q . verdict. Caller callbacks retain find and grep bindings at their original declaration points. Python-library and JS-loader predicates stay separate, as do native import fallbacks and optional web diagnostics. Unlike first-match lookup, the query keeps its raw pipeline status, including producer failures after partial output.

The npm vendor script shares quiet Python invocation for metadata and archive digests. Each command binds inside its existing capture and leaves no parent callback behind. Metadata remains advisory; digest failures retain their original strict-shell behavior. Download retries, integrity comparisons, tar fallback and cleanup remain caller policy. Offline receipts use fake HTTP and tar commands; they do not establish registry trust or archive validity.

Probe publication, reporting and callback context#

Compiler resolution shares ordered primary and alternate GCC probes in a private helper. It publishes through the caller’s existing resolved local so provider hooks retain that binding. Keep probe order, nonempty-test order and direct printf failure behavior; filesystem and PATH fallbacks remain outside the collector.

The chain shares its nonempty, non-self, live sibling-PID predicate. Both callers keep their original pidfile reads, output, refusal and write policies. The helper retains raw kill -0 status and does not signal a process.

Libcamera’s optional component report shares availability, quiet presence probing and found/missing reporting after the original path initialization. Bound pkg-config and GStreamer callbacks keep their original aliases, version fallback and messages. Its standalone file still needs no extra companion.

Callback dispatch must retain the bindings visible to supplied Bash wrappers. Wheel transport and packaging failure dispatch use private names; media queries and component reports use positional arguments. Generic helper locals such as tool, producer or source must not replace caller configuration. Literal global and caller-local controls complement the frozen behavior receipts. Bound literal commands also retain the original positional context when an alias expands "$@"; command arguments and enclosing caller arguments are separate contracts. Meson providers keep each original binding phase: libcamera binds its native provider after the cross provider has run, while GStreamer binds both with its function declaration. GStreamer’s cross-flag setup and wheel stripping keep those internal callers’ existing argument-free contracts; their adapters restore an empty enclosing context before executing the tool arguments. Finder callbacks retain their enclosing argument context separately from the shared first-match helper’s generated finder arguments. Target Python path probes share quiet best-effort capture in the existing cross-Python owner. Each caller binds its literal provider inside the original capture; the readiness API rejects older or incomplete owners. OpenCV retains its output argument context. GStreamer’s internal resolver keeps its existing argument-free call from the preparation function, whose extra arguments remain ignored.

Help rendering and termination share show_usage_and_exit in the existing logging owner. Each CLI binds usage at its original parser declaration and forwards the remaining parser arguments to preserve alias positional expansion. Keep the selected call unconditional so strict callback failures retain their status. The following raw-status exit refuses a missing helper even when the parser runs conditionally; otherwise help could repeat the argument loop or reach later work. Copied fixtures first prove complete help output, then exercise an older logging owner.

Shell safety conventions#

Five bash bug classes, all found live. Each of these killed or falsified a real build before it was fixed. The full stories: changelog-archive-2026-08-13.md. tests/test-ifs-safety.sh lint-gates class 3. When writing or reviewing bash here:

  1. No trap … RETURN inside functions. The trap survives the function and fires again on the caller’s return, where the locals are gone (set -u abort after a green run). Capture rc with || rc=$? and clean up explicitly.

  2. Guard every pipeline whose empty result is legitimate. grep/find/ls/du/pgrep/ dpkg -S/readelf in $(...) under set -euo pipefail needs || true when the code below handles the empty case. find | head -1 also dies of SIGPIPE (rc 141) on multiple matches. A large captured result must not flow through printf | grep -q under pipefail. An early match can close the pipe and turn a valid marker into UNKNOWN.

  3. Split comma lists with IFS=',' read -r -a arr <<< "$list", never ${list//,/ } or $(... tr ',' ' '). Under a script’s IFS=$'\n\t' those do not split, and the loop runs once with the whole list as one bogus item. Sourced 01-core functions run under the caller’s IFS. The two list helpers (arch_list_to_words, smoke_arch_words) emit newline-separated words, so for x in $(...) splits under any IFS. Keep that if you touch them (test-smoke-arch-parity.sh pins it).

  4. Source vendor scripts (SDK setup-env, venv activate) with nounset suspended. case $- in *u*) …; set +u;; esac … set -u after. LunarG’s setup-env.sh reads $1 unguarded.

  5. Never end a function with a bare [ cond ] && action. The false case becomes the function’s return value 1, and under set -e the healthy path kills the caller. End with || true, ; return 0, or an if. Shell test predicates with an intentional false status use explicit return 0 and return 1 branches so the gate can distinguish intent.

Host tool traps when you measure a run. These falsify your audit, not the build. Each produced a wrong verdict once, and none announces itself:

  • grep on this host is ugrep. A pattern beginning -- parses as an option and silently matches nothing, so a fault-injection arm that never fires looks like a clean run. Always grep -e "$pat". Symptom entry: failure-modes.md.

  • comm needs LC_ALL=C sort on both inputs. Any other collation reports a wrong set difference that still looks like an answer. It turned “0 shared” into “36 shared” in one day’s audits, and had made a preflight assertion pass vacuously.

  • Never count warnings by grepping a BuildKit log. BuildKit echoes each RUN’s command text, so a warning string written inside a Dockerfile command counts as if it had fired. Match real output lines only.

The tree, as AGENTS.md drew it#

Moved out of AGENTS.md on 2026-09-15 (owner decision D10), and edited since only to keep it current. overview.md § Repo map keeps one line per top-level directory; the per-file detail, the deletion history and the consumer-surface notes are here.

linux/scripts/
├── 01-core/             shared utilities (`ls linux/scripts/01-core/*.sh | wc -l` counts them; among them versions.env, logging, platform, cross-env, cross-gcc, cross-meson, cross-apt, compiler-resolution, tag-naming, stage-defs, digest-pinning, ancestry, build-helpers, cli-parsers, …)
├── 02-toolchain/        GCC, LLVM, Rust, Python, CMake, Vulkan builds
├── 03-media/            media library build scripts
│   ├── core/common.sh   single DRY bootstrap — sourced by every media script
│   ├── build/           per-library build scripts
│   │   ├── onnxruntime/   ONNX Runtime + GenAI (build/ steps, runtime/ pkgconfig, android/)
│   │   ├── litert/        LiteRT + TFLite C API (Critical Fix #2: abseil span.h copy in build-litert.sh)
│   │   ├── opencv/        OpenCV 5.x
│   │   ├── ffmpeg/        FFmpeg (build-ffmpeg.sh has fixed host compiler wrapper)
│   │   ├── gstreamer/     GStreamer monorepo (common/ has patch-gstreamer-sources.sh — Critical Fix #5)
│   │   ├── libcamera/     libcamera
│   │   ├── pyav/          PyAV wheel (`import av`), built in a stage layered on the FFmpeg it links against (Dockerfile.media `FROM ffmpeg AS pyav`); versions.env pinned PYAV_VERSION while nothing built it until 2026-08
│   │   ├── armnn/         Arm NN + Arm Compute Library — arm64 ONLY; other arches get empty /opt/armnn + /opt/acl
│   │   ├── hailo/         HailoRT + hailortcli + the hailonet element, built in the wrapper image (Dockerfile.torch); riscv64 skips
│   │   └── iree/          android/ ONLY (dispatched via android-dispatch.sh); the Linux-lane IREE is built by 05-frameworks/torch/build-app-wheelhouse.sh
│   └── runtime/         artifact collection, runtime config, wheel repair, verification, media-env.sh (canonical ENV)
├── 04-runtime/          entrypoint + env scripts (gstreamer-env.sh, etc.)
├── 05-frameworks/       TVM, Torch, Flutter
└── 06-packaging/        assembly + smoke tests (smoke-media.sh, smoke-common.sh)

Top-level orchestrators: build-cross-chain.sh, build-cross-compiler.sh, build-cross-stage.sh, build-runtime-manifest.sh, build-runtime-artifacts.sh. Verification: verify-cross-chain.sh, verify-critical-fixes.sh, verify-artifact-copy-parity.sh.

Beyond linux/scripts/:

linux/scripts/lib/       consumer-facing bash libraries: agentic-loop.sh +
                         agentic-engines.sh (one loop in two files),
                         app-packaging.sh (tar/deb/AppImage/Flatpak),
                         app-runner.sh (generic app launcher: arg parse, exe
                         discovery, LD_LIBRARY_PATH, per-profile hooks),
                         cmake-build.sh, code-quality.sh, coverage.sh,
                         compiler-llvm-tools.sh (a build tree's own LLVM
                         tools, first on PATH), dartdoc-build.sh (+
                         dartdoc-guides.py), linker-select.sh (opt-in
                         KATAGLYPHIS_LINKER=lld|mold), log-bootstrap.sh (the
                         logging block the others source), slang-compile.sh,
                         wasm-opt.sh, ctest-run.sh (ctest runner),
                         docs-build.sh (Sphinx build helper),
                         rust-toolchain.sh — the last three had NO doc entry
                         anywhere until the 2026-08-08 orphan sweep. A
                         consumer surface, reached through the consumer's
                         third_party/ANTfrastructure checkout: no image
                         ships lib/, and in-repo only preflight.sh and
                         05-frameworks/flutter/flutter_checks.sh source it
                         (code-quality.sh)
linux/scripts/02-toolchain/rust/   cargo_* helpers (test/bench/debug/
                         fmt+clippy/security/coverage/release/doc; test,
                         bench and debug run through _cargo_wrapper.sh) —
                         consumer surface COPY'd into the
                         toolchain/sdk/package images; nothing in-repo calls
                         them (the redundant zero-ref Build-Linux.sh duplicate
                         was deleted 2026-08-08)
linux/scripts/02-toolchain/python/ci_*.sh   Python CI helpers (tests, static
                         analysis, packaging, docs) — same consumer-surface
                         status as rust/
linux/scripts/01-core/setup-host-deps.sh    hand-run developer-onboarding
                         helper (host toolchains, compiler caches, analysis
                         and coverage tools); intentionally not wired into CI
                         or builds
linux/scripts/06-packaging/package_archive.sh   tar/deb/AppImage/Flatpak
                         assembly — consumer surface. Called from
                         OxidANT's reusable-linux.yml, which its Linux
                         lanes (linux-x64.yml, linux-arm64.yml) call;
                         rust_ubuntu26_04.yml until the 2026-09-24 rename.
                         Deleted by the 2026-08-08 orphan sweep as
                         "zero-reference" and restored 2026-08-11: the sweep
                         searched only THIS repo, so a consumer's CI lane was
                         broken silently. Grep the consumer repos before
                         deleting anything under lib/, rust/, python/ or
                         06-packaging/.
windows/scripts/         Windows lane, GROUPED since #108 (2026-08-20):
                         build/ (chain components: Build-*FromSource.ps1,
                         Build-*All.ps1 wrappers, Test-Container.ps1,
                         Import-Versions.ps1), host/ (Install-*/Set-*/
                         Repair-*/Reset-* + elevated maintenance),
                         diagnostics/ (Test-*/Get-*/Invoke-*/Measure-* probes
                         + the Invoke-DiagnosticProbe.ps1 runner). A settled
                         one-shot is DELETED, not archived: git history is the
                         record, and the diagnostics/archive/ facility that
                         used to hold them never worked as advertised —
                         `**/archive/` in .dockerignore strips it from every
                         build context, so the -ProbeScript archive/<name>.ps1
                         it promised could not solve. Container mounts
                         stay FLAT (C:\bkmnt, C:\temp\scripts) — the
                         $scriptAssetRoot resolver bridges both layouts and
                         is gated by ScriptAssetRoot.Parity.Tests.
                         Ungrouped residents BY DECISION (#131):
                         Invoke-Lint.ps1, entrypoint.cmd, cargo-retry.cmd
                         (consumer-CI suspect — never delete unverified),
                         certificates/ (MSIX cert generation + WebDAV
                         download_webdav_files.py — see its README.md),
                         python/ + rust/ (consumer CI-lane drivers).
                         Also ungrouped: patches/ (the static source-build
                         patches, catalogued in its README.md).
                         modules/*.psm1 (reusable PS modules: SourceBuild,
                         Build.Common, ContainerBuild.Reuse, AgenticLoop,
                         CMake, Config, Formatting, Msix.{Common,Signing},
                         WebDav, Uv, Scripts.Shared, Toolchain, CodeQL,
                         ContainerImage, CrossBundle, Flutter, Installer,
                         HostMaintenance, SmokeTest, GstPlugins, …),
                         tests/ (harness + suites), shims/
windows/upstream/        prepared upstream submissions (not build inputs), one
                         directory per submission = format-patch + PR.md. See
                         its README.md for the index, and
                         docs/upstream-windows-patches.md for the graded
                         register of EVERY local third-party change.
                         hcsshim-teardown-timeout/ is the one already FILED
                         (microsoft/hcsshim#2855) and also carries ISSUE.md,
                         the deployed 45min local patch and the rebuild
                         recipe; the other 14 are prepared and UNSENT - do
                         not post without the owner saying so.
shared/agentic-loop/     cross-platform data: prompts/*.md — the single source
                         for the default planner/refactor-planner/executor task
                         prompts read by BOTH WindowsAgenticLoop.Common.psm1
                         and linux/scripts/lib/agentic-loop.sh;
                         system-prompts/*.md, the role prompts both halves
                         compose (agentic-engines.sh on Linux); templates/,
                         the consumer config and runner wrappers
.github/actions/         12 composite actions consumers call @develop, incl.
                         cleanup-disk-space (Windows runners),
                         run-in-linux-container, run-in-windows-container;
                         full list in .github/actions/README.md

out/: generated build artifacts (OCI layouts, rootfs exports). Excluded from Docker context via .dockerignore.

Module loading order, as AGENTS.md carried it#

The rules stay in AGENTS.md; this is the reference behind them.

artifact-common.sh sources 01-core modules in dependency order:

  1. common.sh 2. tag-naming.sh 3. stage-defs.sh 4. digest-pinning.sh 5. chain-verify.sh 6. ancestry.sh 7. build-helpers.sh 8. cross-stage-build.sh 9. context-management.sh 10. version-forwarding.sh 11. cli-parsers.sh 12. runtime-push.sh 13. runtime-build-fns.sh 14. compiler-resolution.sh 15. parallel-loop.sh 16. path-helpers.sh. abseil-headers.sh is deliberately NOT in this loop (backlog A3, 2026-08-12): it has no host-side caller, and its in-image consumers load it via source_module.

runtime-flow-common.sh is sourced by lib-orchestrator.sh inside runtime_flow_preamble(); build-runtime-artifacts.sh and build-runtime-manifest.sh reach it by sourcing lib-orchestrator.sh.

Both runtime mains call runtime_prepare_flow unconditionally so Bash retains the existing errexit behavior. It exports DRY_RUN, binds TARGET_ARCHES by name, resolves wheel delivery, then validates Hailo and host payloads. Wheel failures keep their status; validation failures exit 2 and payload validation stdout stays quiet. Image prefixes and provenance placement remain caller policy.

lib-runtime-wheels.sh (RUNTIME_WHEELS_SOURCE) is sourced by lib-orchestrator.sh at top level, right after artifact-common.sh. It sits beside 01-core, not in it, because 01-core is in the compiler image’s closure and this file is host-only. append_wrapper_build_args calls into it only while RUNTIME_WHEELS_EXPORT_ROOT is set, which only its own runtime_wheels_setup does (both deliveries).

03-media/build/hailo/hailo-build-lib.sh is sourced there too, right after it, for one function: hailo_validate_knobs, which the chain and both runtime orchestrators call before they build anything. The same file is the Hailo build’s own library inside the wrapper image, so it sets no shell options and runs nothing at load, and a change to it re-keys only the wrapper’s Hailo RUN (two switches).

Which loader a NEW script should use (the dual-loader rule): scripts that also execute INSIDE containers (bind-mounted or COPY’d — base-image, 02-toolchain, 03-media, 06-packaging) load via modules.sh / source_module, which resolves both the repo layout and the /opt/scripts container layout. Host-only orchestration (build-cross-*.sh, runtime flows) sources artifact-common.sh directly. Do not mix: a container-capable script hard-sourcing repo paths breaks at /opt/scripts. (Known wart: modules.sh hardcodes a ../02-toolchain search path — a 01-core file encoding stage-2 layout; fold a fix into any future modules.sh touch. The layer order itself is frozen by tests/test-layer-order.sh.)

What holds the standalone contract#

Two suites, and they split the work. tests/test-lib-smoke.sh is the cheap half over every lib/*.sh: the module parses (bash -n), it sources cleanly under set -euo pipefail — a strict-mode consumer must not be killed by an unbound variable or a failing top-level command — and sourcing it defines at least one function, counted as a delta inside one shell so functions exported into the test environment cannot fake the number. A module that exports nothing is a gutted or early-returning copy, not a library. It also parses cmake_build_parse_args in isolation. No network, no cmake run.

tests/test-lib-modules.sh is the strict half described under The logging bootstrap: double-source safety, and that info/warn/err arrive from the real 01-core/logging.sh rather than a private fallback copy. It skips the agentic-*.sh pair, one executable loop split over two files rather than a source-library.

t_capture_stubbed in the shell test harness owns isolated library calls with per-case environment overrides, a fresh command log and captured output/status. The Flatpak and bind-mount ownership suites retain their own stub defaults and expected results. Both suites pass the same assertions before and after the extraction; status-swallowing and dropped-environment mutations must fail.

t_write_exec_stub <path> writes an executable that exits 0. The Vulkan target-decomposition suite uses it for every host tool it fakes; dropping its chmod turns six of that suite’s cases red.

The logging bootstrap#

The commit/push hooks’ hook-host-red.sh imports this bootstrap like the other shared shell libraries. Its unchanged host-red selection policy cannot bypass a failed unmutated library control. Copies carry the bootstrap companion; the existing standalone-library suite checks real logger exports and repeat imports.

The bootstrap also owns fallback registration for standalone Abseil, Torch wheelhouse and payload-copy scripts. A scoped _LOG_BOOTSTRAP_REGISTRAR_ONLY=1 source imports only the registrar; it loads no real logger and leaves the bootstrap guard and caller arguments unchanged. Standalone scripts retain command lookup, plain prefixes and their selected logger names. Library fallbacks retain function-only lookup, ANSI prefixes, stderr warnings and fatal errors. Existing callbacks keep their own status and output policy.

Toolchain and Media carry lib/log-bootstrap.sh for the core Abseil module, including a partial Media rebuild against an older SDK parent. Adjacent Media core copies share the same pre-RUN source set and permissions. The isolated package payload COPY carries the same file beside its entry point and inventory. Keep these companions when copying either closure; missing companions fail instead of restoring private fallback definitions.

log-bootstrap.sh is the one owner of the block every other library needs before it can say anything: resolve ../01-core/logging.sh if the caller has not already defined info, and otherwise define the minimal info/warn/err that let the library run standalone. Each library sources it on the line after its own re-source guard; only cmake-build.sh and wasm-opt.sh keep a _*_CORE_DIR of their own, because they reach into 01-core for parallelism.sh, load-versions-env.sh and downloads.sh as well.

One file, not a pasted idiom: nine hand-kept copies drifted twice into defects (no re-source guard, no err), and at more than MAX_OWNERS (6) owners verify_code_dupes treats the block as idiom and cannot catch that.

Sourcing a sibling to get logging is not the bootstrap paradox it looks like. The block it replaced already sourced a file — ../01-core/logging.sh, one directory further away — and every consumer vendors the whole ANTfrastructure checkout (third_party/ANTfrastructure/linux/scripts/lib/<lib>.sh), so a missing file next to the library it serves is a broken checkout, not a supported state. tests/test-lib-modules.sh holds that line: every lib/*.sh must source cleanly standalone, define info/warn/err, survive a double source, and end up with the real logging module rather than the fallbacks.

Shared CLI value parsing#

app-runner.sh, cmake-build.sh and ctest-run.sh source cli-value-options.sh beside them. Keep that companion when copying these libraries. One cursor loop assigns value flags from each caller’s map; caller callbacks retain positional handling, repeatable configure arguments, optional skip-configure values and -- behavior. A value flag without another argument exits with its diagnostic instead of repeating an unsuccessful shift 2. An explicitly empty argument remains valid where the caller already accepts it.

test-cli-value-options.sh exercises all three real parsers with bounded workers; it launches no application, CMake build or CTest process. Mutation cases remove the missing-value guard and retain the delimiter, and both must fail.

cmake-build.sh — configure + build a CMake project in a container#

Variable

Meaning

Default

CMAKE_BUILD_DEFAULT_PRESET

CMake preset name

—

CMAKE_BUILD_DEFAULT_BUILD_DIR

build directory

build

CMAKE_BUILD_DEFAULT_CLEAN_BUILD_DIR

true to rm -rf the build dir first

false

CMAKE_BUILD_DEFAULT_SKIP_CONFIGURE

true to build without configuring

false

CMAKE_BUILD_DEFAULT_VULKAN_SETUP_SCRIPT

setup-env.sh sourced when it exists

—

CMAKE_BUILD_DEFAULT_MB_PER_JOB

peak RAM per compile job

4000

CMAKE_BUILD_DEFAULT_ALLOW_PREBUILD_FAILURE

true makes a failing pre-build hook non-fatal

false

CMAKE_BUILD_DEFAULT_CONFIGURE_ARGS

bash ARRAY of extra configure-step arguments

empty

CMAKE_BUILD_SAFE_DIRECTORY

path registered as a git safe.directory; empty disables

/workspace

CMAKE_BUILD_PREBUILD_LABEL

label logged around the pre-build hook

—

CMAKE_BUILD_USAGE_INTRO

one-line description shown in --help

—

An empty positional preset remains in CMAKE_BUILD_POSITIONAL and uses the normal caller default. The value-option table is consulted only for a nonempty argument; Bash associative arrays reject an empty key.

Vulkan selection — _cmake_build_resolve_vulkan. Three sources can name a Vulkan SDK, and they are resolved in one place: an explicit --vulkan-version / --vulkan-setup-script / --vulkan-sdk flag overwrites whatever the image exported, and CMAKE_BUILD_DEFAULT_VULKAN_SETUP_SCRIPT is consulted last — only when nothing else set VULKAN_SETUP_SCRIPT and the file it names exists. That -f test is the load-bearing half: cmake_build_prepare_env sources VULKAN_SETUP_SCRIPT unconditionally once it is set, so adopting a default that is not on disk turns a missing SDK into a sourcing error much later. tests/test-lib-smoke.sh pins all four cases.

Extra configure arguments — --configure-arg. Repeatable, and the only way to put a -D on the configure command line. Each occurrence appends one argument, in order, to CMAKE_BUILD_CONFIGURE_ARGS; the list is reset per cmake_build_parse_args call and seeded from CMAKE_BUILD_DEFAULT_CONFIGURE_ARGS (an array, not an environment string — splitting one would break the first -D whose value contains a space, and --configure-arg '-DCMAKE_CXX_FLAGS=-O2 -g' must stay one argument). They reach the configure step only, never cmake --build. An empty value is fatal rather than dropped: cmake "" fails with a message about the source directory, nowhere near the caller. Without this, a wrapper that needed one -D had to run --skip-configure true and issue its own cmake -B … --preset …, i.e. call three library entry points where cmake_build_main would do.

Hook — cmake_build_prebuild_hook. Called only when the wrapper declares it. Runs after configure, immediately before cmake --build; use it for code or asset generation the build or the runtime depends on (shader precompilation, codegen). A non-zero return is fatal by default — see cmake_build_run() for why.

app-packaging.sh — the two flatpak entry points#

The shared native-app DEB builder uses gzip control and data archives for older Debian package managers, and makes payload entries root-owned.

Linux TAR selects its source through app_packaging_detect_bundle_dir, honoring APP_PACKAGING_BUNDLE_DIR and its default Flutter path. It refuses a missing selected tree or failed resolution instead of falling back to raw build output. The generic TAR writer retains its legacy out/ and project-root copies; Android APK TAR still selects its own build output. Real TAR fixture tests cover selected bytes, notices and paths with spaces, but do not establish native execution or complete licence coverage.

Every packager in the file obeys three rules. Staging trees are container-native, never inside the mounted workspace: a bind-mounted host drive refuses chmod/fchmod for the container uid, so dpkg-deb, appimagetool and flatpak-builder fail there, and only finished artifacts are copied into out/. flatpak-builder’s exit code is reported but never the verdict; ostree --repo=<repo> refs decides whether the app is committed. And nothing prints Created: without app_packaging_assert_artifact. Bundle DEBs use dpkg-deb --root-owner-group so payload ownership is root even when the staging tree is owned by the unprivileged build user; an unsupported dpkg fails the build. Two entry points were added on 2026-09-15 for a consumer that packages a CMake install tree rather than a Flutter bundle; the finish-args block and the CON2 probe landed on 2026-09-17:

  • app_packaging_ensure_flatpak_runtime [arch] [runtime] [sdk] [version] — flathub plus the runtime/SDK pair, for a run that is not inside the family CI image. Deliberately not app_packaging_setup_dependencies_for_container: that one assumes the image already ships flatpak, installs missing packages through a privilege helper and installs under dbus-run-session. This one installs nothing with apt and asks first, so a warm dev box is a no-op. User installation first, system as the fallback, for the remote and for both refs — an unprivileged user cannot write the system installation, and pulling a second copy of a ref the machine already has system-wide costs 1-2 GB. app_packaging_setup_dependencies_for_container now probes both scopes before installing too (CON2, 2026-09-17): the CI image installs the pair system-wide as root while the container runs as uid 1001, so its unconditional --user install was pulling that second copy on every flatpak-packaging run.

  • app_packaging_flatpak_finish_args_block — the manifest’s finish-args list: the four generated entries (network, the two display sockets, DRI) plus whatever KATAGLYPHIS_FLATPAK_FINISH_ARGS adds, space-separated. Appended, never replaced (CON6, 2026-09-17). V4L2 capture needs --device=all (there is no per-device video grant in flatpak) and a user-chosen model path needs a --filesystem=; the knob exists because the omission is invisible to every gate — the bundle ships, the window opens, and only the camera stays silent.

  • app_packaging_package_cmake_install_flatpak <build_dir> <out_dir> <app_id> <project_name> <version_suffix> [runtime] [sdk] [version] [branch] [arch] — cmake --install into a container-native staging prefix, rename the PROJECT-named .desktop/.png/.appdata.xml to the APP ID, write the manifest, build, and copy only the finished bundle into <out_dir>. <out_dir> is routinely the build directory on a mounted workspace, which is exactly why nothing but the bundle is written there.

app_packaging_require_flatpak_tools, which both packagers call first, requires three binaries: flatpak, flatpak-builder and — since 2026-09-15 — ostree. The verdict above is ostree refs, but Debian’s and Ubuntu’s flatpak package depends on libostree and not on the ostree CLI, so a box with the two obvious tools installed passed the check and then reported is not in <repo> over an export that had succeeded. Each missing tool is reported with what the packaging step wanted it for, and all of them at once: one apt-get installs the set.

tests/test-app-packaging-flatpak.sh pins all of them against stubbed flatpak/flatpak-builder/ostree/cmake, including the two cases the exit code cannot see: a non-zero flatpak-builder whose app is committed still ships, and a zero exit with an empty repo fails.

app-packaging-artifacts.sh — one finished artifact per format#

A package check sources this file to find the artifacts it verifies. It needs only log-bootstrap.sh beside it, not the rest of app-packaging.sh.

  • app_packaging_single_artifact DIR SUFFIX prints the one DIR/*SUFFIX. None or two fail, and the message names the count. A match that is a directory or a link fails too.

  • app_packaging_linux_artifacts DIR DEB_VAR TARBALL_VAR APPIMAGE_VAR sets the three named variables to the one .deb, .tar.gz and .AppImage. It reports every miscounted format before it fails, and then sets none of them.

It expands the caller’s glob and changes no shell option, so hidden files count only under dotglob. It proves that one artifact was selected, not that the package is valid. tests/test-app-packaging-artifacts.sh covers none, one and two of each format.

06-packaging/package_archive.sh — one binary, four formats#

One release binary, a tar always, and by --package-types a deb, an AppImage and a flatpak. The types are comma- or space-separated, in any case. Until 2026-10-06 it wrote the tar and stopped: its create_deb() was deleted on 2026-08-08 as unreachable, and --flatpak-manifest, --desktop-file and --appdata-file were checked for existence and then never read.

It requires the project’s nonempty LICENSE (or --license-file) and stages it with the binary in the tar and bundle. app_packaging_stage_project_license is available to other callers that build their own bundles; copies of app-packaging.sh must carry app-packaging-license.sh beside it. Copies of that helper and pe-icon-tools.sh also carry log-bootstrap.sh beside them. The helper does not inventory third-party licenses. After the tar it stages that bundle in ${KATAGLYPHIS_PACKAGING_WORKDIR:-/tmp/packaging-work}/bundle. It hands that tree to the three bundle packagers above, the ones a Flutter lane calls, through seven knobs. Unset, each keeps the Flutter default, so a Flutter lane packs what it did before:

Knob

Flutter default

package_archive.sh sets

APP_PACKAGING_BUNDLE_DIR

build/linux/<arch>/release/bundle

the staged tree

APP_PACKAGING_VERSION

pubspec.yaml’s version:

--version, minus a tag’s leading v

APP_PACKAGING_DESKTOP_FILE

a generated entry

--desktop-file

APP_PACKAGING_ICON_FILE

web/icons/Icon-512.png, then the fallbacks

--icon-file

APP_PACKAGING_OUT_DIR

out

--archive-dir

APP_PACKAGING_DEB_DEPENDS

libc6, libstdc++6, libgtk-3-0

libc6, libgcc-s1, unless the caller set it

APP_PACKAGING_APP_ID

<APP_PACKAGING_APP_ID_PREFIX>.<package>

--app-id, when given

Three details each format depends on:

  • The desktop entry is the project’s own. app_packaging_adapt_desktop_file keeps every line but Exec and Icon, and sets those two right after [Desktop Entry] for the format: the package name for the deb and the flatpak, AppRun for the AppImage.

  • The icon goes where its real size says. app_packaging_icon_size reads WxH from the PNG header, so a 128×128 logo lands in hicolor/128x128/apps. Staging refuses a missing or structurally invalid PNG; this checks its header, end marker and dimensions, not full decoding or visual identity.

  • The flatpak copies lib/ and data/ only when they exist. A Flutter bundle has both, a single binary has neither.

--flatpak-manifest and --appdata-file now stop the run with an error that says why, instead of being accepted and ignored. The flatpak manifest is generated from the staged bundle. An unknown package type stops the run before anything is built, and the three bundle formats need --arch.

tests/test-package-archive.sh pins the wiring against stubbed packagers. It also packs one real deb through the real library and checks its contents, Depends and desktop entry. Measured 2026-10-06 in :latest, OxidANT’s release kataglyphis_cli (1.9 MB; it links libc, libm and libgcc_s) gave:

  • a tar of 885 KB;

  • a deb of 732 KB, whose binary runs;

  • an AppImage of 1.7 MB, which runs with APPIMAGE_EXTRACT_AND_RUN=1;

  • a flatpak of 684 KB, which flatpak install --system --bundle installs and flatpak run --command=oxidant runs, with its desktop entry and 128×128 icon exported.

dev-doctor.sh — what is stale in a dev checkout#

bash third_party/ANTfrastructure/linux/scripts/dev-doctor.sh "$PWD"

Read-only: it fetches nothing and writes nothing. One line per item, STALE for a finding, ok for a pass and note for what this host cannot answer or what no gate depends on. Exit 1 on any finding, 2 for a root that is no git checkout. A month-old image, a uv older than the lock format and a tree about 100 commits behind each cost an hour of wrong debugging on 2026-11-12, and nothing said so.

Check

STALE when

origin’s develop

its tip, read with git ls-remote on the public https URL, is not in the clone, or HEAD lacks commits of it

submodules

one is not checked out, not at its recorded commit, or in conflict

core.hooksPath

unset, or relative (the git hooks)

the CI image

no local copy, or one older than DOCTOR_IMAGE_MAX_DAYS (7) days

uv

the one on PATH differs from UV_VERSION in versions.env

shellcheck, actionlint, gitleaks and ruff on PATH against tool-pins.env are notes: the gates fetch their pinned copies, and only a run by hand takes the PATH one. DOCTOR_ENGINE names the container engine (default nerdctl, else docker). tests/test-dev-doctor.sh covers each line on fixture clones.

ctest-run.sh — run a CMake project’s test suite in a container#

The twin of cmake-build.sh for the test phase, and deliberately a separate library rather than another entry point inside it: CI configures and builds once, then runs ctest several times over different build trees (plain, ASan, TSan…). Sourcing the build driver for that would drag in its cargo/ccache/sccache writability fallbacks and its pre-build hook machinery, none of which a ctest run uses.

Variable

Meaning

Default

CTEST_RUN_DEFAULT_BUILD_DIR

build tree to cd into; empty means “stay here”

build

CTEST_RUN_DEFAULT_BUILD_TYPE

value for ctest -C

Debug

CTEST_RUN_DEFAULT_EXCLUDE

default ctest -E regex

none

CTEST_RUN_DEFAULT_TIMEOUT

per-test ctest --timeout in seconds (--timeout, env CTEST_TIMEOUT); 0 sets none, and a --timeout after -- replaces it. A test’s own TIMEOUT property wins over both

1500, CTest’s own DART_TESTING_TIMEOUT: a hung test ends named, not at the lane’s limit

CTEST_RUN_DEFAULT_ARGS

ctest flags when the caller does not override them

maximally loud on purpose — a container test run is only debuggable through its log

CTEST_RUN_SAFE_DIRECTORY

git safe.directory; empty disables

/workspace

CTEST_RUN_USAGE_INTRO

one-line description shown in --help

—

--fail-on-skipped REGEX (env CTEST_FAIL_ON_SKIPPED): a skip is not a pass. After ctest, each test whose name matches REGEX (an extended regular expression, matched anywhere, as -R does) and whose JUnit record says skipped is printed with ctest’s reason (SKIP_REGULAR_EXPRESSION_MATCHED, SKIP_RETURN_CODE=77) and fails the run: status 1, or ctest’s own when that already failed. A GoogleTest GTEST_SKIP under gtest_discover_tests is such a skip. ctest’s Disabled tests (Not Run (Disabled)) never count; its other Not Run tests do, and ctest fails those anyway. The report is the caller’s last --output-junit, removed before the run so an old one cannot stand in, or a temporary one the library appends and deletes; no readable report fails the run. It needs python3, and an invalid pattern stops before ctest starts.

--fail-on-log-pattern REGEX (env CTEST_FAIL_ON_LOG_PATTERN): a passing test can still log what must never happen (CON291). After ctest, every line of a test’s output that matches REGEX names that test with its count and first line, and fails the run as --fail-on-skipped does. It reads this run’s Testing/Temporary/LastTest*.log (newer than a marker taken before ctest starts; -T test names each run’s log anew), not the JUnit report, whose output ctest cuts to 1 KiB for a passed test; and only the section between Output: and <end of output>, as a test’s Command: line holds its own echo text. AccelerANTgine’s pattern, [A-Za-z0-9-]+-CRITICAL \*\*, catches GLib’s and GStreamer’s criticals; BeschleunigerBallett’s SYNC-HAZARD scan fits the same option.

A GPU test suite needs the loader and the layers on the same terms the build had, which is why the Vulkan environment is resolved here too.

Without a GPU device node, ctest gets lavapipe only (CON284). After the Vulkan environment, vulkan_env_default_cpu_driver (01-core/vulkan-env.sh) exports VK_LOADER_DRIVERS_SELECT='*lvp*' when no /dev/dri/renderD*, /dev/nvidia<N> or WSL’s /dev/dxg exists and a lvp_icd*.json sits in /usr/share, /usr/local/share or /etc vulkan/icd.d. Mesa’s other ICDs then neither print their per-instance warnings (PowerVR’s Failed to enumerate drm devices) nor leak under ASan (failure-modes.md). A caller that sets VK_LOADER_DRIVERS_SELECT, VK_DRIVER_FILES or VK_ICD_FILENAMES keeps its own choice, and a host with a GPU node keeps the loader’s. cargo_test.sh applies the same default.

compiler-llvm-tools.sh — the LLVM tools of the compiler that built a tree#

Anything that reads clang’s output has to come from the same LLVM. That covers llvm-profdata and llvm-cov on a raw profile, and clang-tidy on module PCMs. The images put a source-built clang behind clang/clang++, while the bare tools on PATH can be an older distro LLVM, so the pairing fails with “no profile can be merged” or “uses a newer format that cannot be read”. The image after CON11 links clang’s own copies into /usr/local/bin (BACKLOG CON15); keep the helper for older images and for a tree another compiler configured.

  • compiler_llvm_tool <build-dir> <tool> prints the tool beside the compiler that configured the tree (CMAKE_CXX_COMPILER in its CMakeCache.txt, else clang++). It asks that compiler’s -print-prog-name, and fails when the answer is the bare name, which is clang’s way of saying it has none.

  • use_compiler_llvm_tools <build-dir> <tool>... puts that directory first on PATH, but only when it holds every named tool. A half set would mix two LLVMs in one report, so it warns and leaves PATH alone instead. Call it in a subshell when the directory holds a tool the caller must not swap, such as clang-format.

It came up from AccelerANTgine’s ci-common.sh once BeschleunigerBallett’s coverage lane hit the same “no profile can be merged” (2026-09-24). linux/scripts/tests/test-compiler-llvm-tools.sh pins it with two fake LLVM installs.

linker-select.sh — an opt-in linker#

KATAGLYPHIS_LINKER=default|lld|mold picks the linker for one build. Unset, or default, changes nothing: clang keeps GNU ld 2.46 and x64 Rust keeps rustc’s own rust-lld. linker_select_env applies it, and cmake_build_prepare_env and the cargo_test/cargo_bench/cargo_debug wrappers call it. A Flutter lane calls it itself, after it has set CC.

  • C/C++: it appends -fuse-ld=<x> to LDFLAGS. CMake folds that into every CMAKE_*_LINKER_FLAGS, but only at the first configure, so a reused build tree keeps its old linker. For mold under clang it also passes -Wl,-plugin,<clang prefix>/lib/LLVMgold.so. Without it mold stops on LTO bitcode archive members (“the -plugin option was not provided”). GCC’s collect2 passes its own plugin.

  • Rust: for the host triple only, it sets CARGO_TARGET_<HOST>_LINKER=$CC and appends -C link-arg=-fuse-ld=<x> to CARGO_TARGET_<HOST>_RUSTFLAGS. wasm32 and the Android targets keep their own linkers. Changing the value recompiles every crate, and sccache misses with it.

  • Loud, never a fallback. An unknown value returns 2. Three things return 1: a set RUSTFLAGS or CARGO_ENCODED_RUSTFLAGS (cargo would take either over the per-target flags without a word), a driver that cannot link a one-line probe with -fuse-ld=<x>, and a mold that cannot be had. USE_LLD in compiler-cache.sh falls back silently; this switch exists to measure, and a fallback would make the measurement lie.

  • mold comes from PATH, else the pinned release. No image ships it yet. linker_select_ensure_mold downloads the MOLD_LINUX_* pin in tool-pins.env (SHA256 per arch: x86_64, aarch64, riscv64) into a version-keyed cache (LINKER_SELECT_CACHE_DIR, default $TMPDIR). An unpinned architecture fails.

Which one to pick. Measured 2026-10-05 in :latest on 32 cores, across OxidANT, AccelerANTgine and the OmniAccelerANT Flutter app, and BeschleunigerBallett on 2026-10-06:

Build

GNU ld

lld 23

mold 3.0.0

AccelerANTgine Debug (ASan, UBSan), relink all 5 binaries

1.70 s

0.35 s

0.56 s

AccelerANTgine release, libAccelerANTgine.so (ThinLTO)

0.97 s

0.85 s

0.82 s

flutter build linux --release, full / touch one TU

49.3 / 3.9 s

47.6 / 3.8 s

49.5 / 4.3 s

Rust dev link, liboxidant.so (rust-lld default: 0.22 s)

0.87 s

0.14 s

0.33 s

BeschleunigerBallett linux-debug-clang (ASan, UBSan, coverage), relink commitTestSuite (110 MB)

1.55 s

0.20 s

0.32 s

Linking is about 2% of these builds, so lld is the useful value. It is already in the image, and it is the one real gain on Debug relinks. mold 3.0.0 links correctly, with the same exported symbols and passing tests, but is never faster than lld here. mold 2.x (Ubuntu’s 2.40.4, the last C++ release 2.42.1) does not link AccelerANTgine. It stops on its non-PIC spdlog (R_X86_64_PC32 … recompile with -fPIC). With spdlog made PIC it exports 619 extra symbols, and two Debug suites abort on an ASan odr-violation. That is why the pin is 3.x and why no apt package is used.

linux/scripts/tests/test-linker-select.sh pins it with stub drivers and a stubbed download.

rust-toolchain.sh — the wasm32 std and a locked wasm-bindgen#

Both helpers return 1 with a warning instead of exiting: whether wasm is required is the caller’s call.

  • ensure_wasm32_target adds wasm32-unknown-unknown through rustup, or, on a distro Rust without rustup, checks that the target’s std is installed.

  • ensure_wasm_bindgen <Cargo.lock> makes PATH’s wasm-bindgen the version the lock pins: wasm-bindgen-cli refuses a module built by any other wasm-bindgen. It reads the version with wasm_bindgen_lock_version (exact crate name, CRLF lockfiles too), installs nothing when PATH already runs it, else runs cargo install --locked wasm-bindgen-cli --version <v> and returns cargo’s status when that fails. After an install it asks PATH again: cargo writes to ${CARGO_HOME:-~/.cargo}/bin, which the family image’s PATH leaves out, so a caller there puts that directory first. A missing lock, or one without wasm-bindgen, returns 1 before cargo runs.

BeschleunigerBallett’s docs-build-web.sh and OxidANT’s webgpu-demo-browser.sh each carried a copy (2026-11-16). linux/scripts/tests/test-lib-wasm-tools.sh pins both with stubbed rustup, rustc, cargo and wasm-bindgen.

riscv64-cross.sh — cross-build for riscv64, test under QEMU#

riscv64_cross_env turns the amd64 image into a riscv64 cross environment over a sysroot built from the image’s riscv64 child (RISCV64_SYSROOT, default /opt/riscv64-sysroot). It writes triple-named clang wrappers, exports the cc-rs, Cargo and pkg-config variables for riscv64gc-unknown-linux-gnu, names the CMake toolchain in RISCV64_CMAKE_TOOLCHAIN_FILE, sets the QEMU CPU model, and fails when a riscv64 binary does not execute. Why each piece is there, and what it was measured against: riscv64-cross-test-lanes.md. linux/scripts/tests/test-riscv64-cross.sh pins it.

docs-build.sh — build a Sphinx documentation tree#

Every project in this family builds its docs the same way: get a virtualenv with the docs requirements, pull whatever the C++/Doxygen side generated into _static, optionally run a diagram generator, then make html and make linkcheck with warnings promoted to errors.

Not 02-toolchain/python/ci_build_docs.sh, which is the docs step for pure-Python repositories (uv_sync_project over a pyproject, pytest/coverage report staging, no linkcheck). This one is for projects whose docs sit next to a C++/Rust build.

Variable

Meaning

Default

DOCS_BUILD_PROJECT_ROOT

project root

cwd

DOCS_BUILD_DOCS_DIR

directory holding the Sphinx Makefile

<root>/docs

DOCS_BUILD_SOURCE_DIR

Sphinx source dir

<docs>/source

DOCS_BUILD_STATIC_DIR

static asset dir

<source>/_static

DOCS_BUILD_VENV_DIR

virtualenv to activate

<root>/.venv

DOCS_BUILD_UV_VENV_CREATE_SCRIPT

script that creates the venv

—

DOCS_BUILD_UV_INSTALL_REQUIREMENTS_SCRIPT

script that installs its requirements

—

DOCS_BUILD_SVG_SOURCE_DIR

directory whose *.svg are copied into the static dir before the build; empty skips

—

DOCS_BUILD_GENERATOR_SCRIPT

Python script run with the source dir as cwd before Sphinx; empty skips

—

DOCS_BUILD_PYTHON

interpreter for that script

python

DOCS_BUILD_SPHINXOPTS

SPHINXOPTS for every target

-W --keep-going — warnings are errors, but the build reports all of them

DOCS_BUILD_TARGETS

array of make targets

html linkcheck

Both UV_* scripts run with the project root as cwd — the same contract as code-quality.sh’s pair, and both defer to 01-core/python_uv.sh. Unlike that pair, which falls back to the hub’s own bootstrap since 2026-09-15, both are required here: an unset one is fatal.

docs_build_main stops at the first failed step and returns its status, whether or not the caller runs under set -e.

A missing SVG is fatal on purpose. An empty diagram set means the generating build did not run, and shipping docs with holes in them is worse than failing here.

dartdoc-build.sh — theme and enrich a dart doc site#

The Dart/Flutter counterpart of docs-build.sh. dart doc has no theme and no navigation hook, so the library works the only two seams it leaves: the generated doc/api/static-assets/styles.css, and the emitted HTML.

The theme sheet is generated, never hand-written. DARTDOC_BUILD_THEME_CSS points at style/dartdoc.css, which DocumANTation’s style/generate_style.py renders from style/brand.json — the same single source of truth the LaTeX, Pandoc and Sphinx consumers read. That file exists because the hand-written predecessor had drifted onto a Tailwind slate/sky palette (#0284c7 links, #22c55e hover) while the brand’s link colour was #0e7490, so one site in the family rendered a different brand from every other. Its two marker lines are load-bearing: dartdoc_build_apply_theme truncates a previous append at the first line, so rebuilding cannot stack copies of the sheet.

dartdoc-guides.py next to it renders the configured Markdown into dartdoc’s own index.html shell, so a guide page carries the same header, sidebars and theme as an API page. It rewrites every relative link, resolved from the guide’s own source path; a link with a scheme (https:, mailto:), a site-absolute one and a same-page anchor stay as they are:

  • to a guide: that guide’s page, anchor kept (getting-started.md#known-issues becomes guide-getting-started.html#known-issues). Heading anchors are GitHub’s, so an anchor written for GitHub lands on the site too;

  • to any other file or folder of the repository, Markdown or not (.github/workflows/web.yml, rust_builder/cargokit/README): its page on GitHub, <repository>/blob/develop/<path> for a file and /tree/ for a folder, and a path inside a submodule goes to that submodule’s repository (from .gitmodules). The repository is DARTDOC_BUILD_REPO_URL, else the checkout’s origin. A submodule the build did not check out is linked unchecked;

  • to nothing in the repository: a page of the built site stays as it is; anything else fails the render, and so does a link out of the repository or one with no GitHub URL to use, since each would be a 404.

rustdoc sites take the same guides (2026-10-21). docs-site.sh’s rustdoc builder runs the stage and render steps over cargo doc’s site with DARTDOC_BUILD_API_DIR=target/doc, DARTDOC_BUILD_FLAVOR=rustdoc and DARTDOC_BUILD_SHELL=<crate>/index.html, the root package’s page (cargo_build_doc.sh’s rule). A guide is that page with its main content and its sidebar’s #rustdoc-toc replaced, written beside it so its ../static.files/ paths hold; every page with a <div class="sidebar-elems"> gets a Guides block at its top, and source pages, which have none, are skipped. A shell missing #main-content or #rustdoc-toc fails the render, as dartdoc’s landmarks do.

dartdoc emits TWO page shapes, and a third kind of file. Some pages carry a static left sidebar with a bare <ol>; the rest carry <div id="dartdoc-sidebar-left-content"></div>, filled at runtime from a *-sidebar.html fragment — measured on one consumer, 1030 of 1459 pages were the second kind. Those fragments are not documents at all: no <html, no </body>. So the renderer skips a page it cannot hang navigation on and skips a fragment it cannot attach a footer to, rather than aborting the run on the first one, and the END of the run is where vacuity is caught instead: a run that navigated no page, or that configured a footer and footered no page, fails. It prints both numbers (navigated X/N and footered Y/N) so “it worked” is a measurement.

Variable

Meaning

Default

DARTDOC_BUILD_PROJECT_ROOT

project root

cwd

DARTDOC_BUILD_DOC_ROOT

directory dart doc writes into

<root>/doc

DARTDOC_BUILD_API_DIR

the site the guide steps work on

<doc root>/api

DARTDOC_BUILD_FLAVOR

the site’s generator, dartdoc or rustdoc

dartdoc

DARTDOC_BUILD_SHELL

the page a guide is cut from and written beside, relative to the site

index.html

DARTDOC_BUILD_CLEAN_CMD

array run before generation; unset skips

—

DARTDOC_BUILD_DOC_CMD

explicit array that generates the site; bypasses tool resolution

the pinned dartdoc tool below

DARTDOC_BUILD_TOOL_CACHE

isolated generator cache root, keyed by the tool pin

<root>/.dart_tool/dartdoc-tool

DARTDOC_BUILD_THEME_CSS

generated brand sheet appended to dartdoc’s stylesheet

— (required)

DARTDOC_BUILD_IMAGES_DIR

directory copied to doc/api/images; empty skips

—

DARTDOC_BUILD_GUIDES

array of <source markdown>|<slug>|<nav title>

—

DARTDOC_BUILD_FOOTER_LINKS

array of <label>|<url> for the page footer

—

DARTDOC_BUILD_FOOTER_TITLE

bold name in front of those links

—

DARTDOC_BUILD_TITLE_SUFFIX

appended to each guide page’s <title>

—

DARTDOC_BUILD_REPO_URL

GitHub URL a link to a repository file that is no guide points into

the checkout’s origin

DARTDOC_BUILD_VENV_DIR

the renderer’s venv, on a workstation without the image only

${TMPDIR:-/tmp}/kataglyphis-dartdoc-venv

DARTDOC_BUILD_REQUIREMENTS

the file that pins markdown-it-py==X.Y.Z

lib/dartdoc-guides.requirements.txt

DARTDOC_BUILD_PYTHON

interpreter for the renderer

python3, when it imports the pinned parser

A configured input that is missing is fatal. An absent DARTDOC_BUILD_IMAGES_DIR, guide source or theme sheet fails the build instead of being skipped: a docs site quietly missing its theme and half its pages is worse than a build that stops and says so. The same rule governs the CI ownership fix — the container writes doc/ as root over a bind mount, and a chown that fails leaves a tree the host user cannot rebuild.

The API generator#

The default resolves the exact DARTDOC_VERSION from 01-core/tool-pins.env through official pub.dev in <root>/.dart_tool/dartdoc-tool/<version>. A matching cached tool is reused; a failed activation or generator fails the build. DARTDOC_BUILD_TOOL_CACHE moves that cache, and an explicit DARTDOC_BUILD_DOC_CMD bypasses resolution. The SDK, app dependencies and the caller’s global tool cache are untouched. This follows the host-tool bootstrap convention; the Dart executable still comes from the image.

The image’s bundled dartdoc 9.0.6 crashes while stripping dependency @docImport comments (RangeError (end), offset 80 in a 79-character comment). Upstream 9.0.8 fixes the offset drift. On 2026-10-22, the exact published image reproduced that crash on ANThology; the pinned tool completed its full themed site and the link gate found zero issues across 1179 documents. tests/test-dartdoc-tool.sh checks pin, cache, caller override and error propagation with recording executables; it does not substitute for that real documentation build.

The renderer’s Python#

dartdoc_build_prepare_python_env downloads nothing in CI or in the image (2026-10-19, BACKLOG CON101). It uses, in this order:

  1. DARTDOC_BUILD_PYTHON, when the caller sets it;

  2. python3, when it imports markdown_it at exactly the version dartdoc-guides.requirements.txt pins. In the image that is /opt/venv/bin/python3 (see The parser in the image);

  3. otherwise, with CI=true or inside the image (/opt/venv exists), it fails: python3 (...) lacks markdown-it-py 4.2.0; CI and the image never download it;

  4. on a workstation without the image, a uv venv at DARTDOC_BUILD_VENV_DIR with the parser and dependencies locked by quality/dartdoc/uv.lock. An explicit DARTDOC_BUILD_REQUIREMENTS still installs the caller’s requirements file. OmniAccelerANT’s getting-started.md § Build API docs runs generate-docs.sh on a host, which is the one caller of this path.

The default requirements file is a generated compatibility export for existing consumers; renovate-local.sh --apply refreshes it with the uv lock in one transaction. A copied dartdoc-build.sh must carry quality/dartdoc/ and the shared python_uv.sh companions. Suite: tests/test-dartdoc-python.sh checks the image policy, workstation selection, override and install failure; it does not download from a package index.

The parser in the image#

The image holds the parser at the renderer’s pin, not at whatever version myst-parser pulls in with OrchestrANT’s docs extra:

  1. Dockerfile.torch copies dartdoc-guides.requirements.txt to /opt/scripts/packaging/ before the torch venv RUN.

  2. setup-torch-venv.sh install_dartdoc_guide_parser installs that file into /opt/venv with uv pip install --require-hashes. It runs after the app’s extras are installed, which would replace an earlier install, and before the venv is byte-compiled. A pure cross artifact has no venv and skips it. uv pip install only warns when the pin breaks a package that requires markdown-it-py, such as myst-parser, which the hub’s Sphinx build loads from /opt/venv. So dartdoc_guide_parser_requirers_met then fails the RUN when uv pip check names markdown-it-py or mdurl, or cannot run at all.

  3. The runtime smoke’s DARTDOC-PARSER row (check-python-runtime.sh) reads the pin with _dartdoc_build_parser_pin from the hub’s own file. It fails unless /opt/venv/bin/python3 prints exactly that markdown_it version.

A bump of the requirements file therefore re-keys the torch venv layer, and the next image’s smoke checks the new pin. tests/test-dartdoc-python.sh checks the install command, its place in setup-torch-venv.sh main and the COPY. It feeds the requirer check recorded and real uv pip check reports, and the smoke a recorded probe. The image itself is checked by the smoke only.

The rustdoc theme sheet#

02-toolchain/rust/cargo_build_doc.sh styles cargo doc output with the same generated brand sheet the Sphinx and dartdoc builds use: DocumANTation’s style/generate_style.py renders it from style/brand.json and ships it inside the sphinx_kataglyphis package.

It did not always find it. Both probes that stood in that script named a hub path that resolves to nothing — the hub’s own docs/_static/css/custom.css was dropped in fc26b1d1 (2026-07-15) as a stale fork of that very sheet, and the fallback pointed one level short, at linux/docs/_static/, which has never existed in this repository. The block therefore produced an empty EXT_CSS on every run and rustdoc got no theme at all, silently.

The path is now resolved from SCRIPT_DIR rather than the working directory, so it answers the same inside a consumer’s third_party/ANTfrastructure checkout — which is the case the cwd-relative probe existed for in the first place.

Every crate of a workspace#

A Cargo.toml with a [workspace] table gets cargo doc --no-deps --workspace (2026-10-19). Without it cargo documents the root package alone: OxidANT’s site showed oxidant and none of its ten member crates. Measured in :latest against OxidANT 8af8f67: 11 crates in target/doc/, every one in rustdoc’s crate list, 39 s. A caller that names the packages (-p, --package, --workspace, --all) keeps its choice, and a single-package manifest builds as before. Suite: tests/test-cargo-build-doc.sh.

Consumer entry points that are not libraries#

The things below are executables a consumer runs, not cores it sources. They share one rule, and it is the rule the lint-secrets.sh and lint-workflows.sh repairs were both about: the consumer repo root is an explicit argument, never inferred from BASH_SOURCE. A consumer checks this repo out at third_party/ANTfrastructure/, so a self-derived root resolves to ANTfrastructure and the tool operates on the wrong tree — reporting green, having looked at nothing.

06-packaging/collect-release-assets.sh#

collect-release-assets.sh [options] <artifacts dir> <out dir>: a release run’s uploads as one flat directory of release files, by --skip, --include, --rename, --zip, --expect and the rest, or one option per line through --options FILE. The reusable release-publish.yml runs it; options and names: branch-and-release-strategy.md § Collecting the release files.

lib/fetch-data-lock.py#

python3 -I fetch-data-lock.py --lock FILE [--dest DIR] [--extract] [--only NAME]...: the files or scenes a data lock pins, checked by SHA-256, through a cache; CMake reaches it through kataglyphis_fetch_data. The contract: data-repositories.md § The hub’s fetcher.

lib/mirror-app-models.py#

python3 -I mirror-app-models.py --out DIR --model LOCK FILE [--model LOCK FILE]... [--root DIR] [--cache DIR]: each model with its license texts from a data lock, through fetch-data-lock.py, under DIR/models/<sha256>/, with a web manifest. The manifest and the refusals: docs-sites.md § Mirroring an app’s models.

lib/stage-ort-web.py#

python3 -I stage-ort-web.py --out DIR [--source DIR] [--jsep] [--no-js-bundles | --js-dir DIR] [--site-packages DIR]: the image’s ORT Web builds under DIR/ort/<version>-<build hash>/, checked against the image’s receipt, with ORT’s license texts and a manifest. Builds, files and refusals: docs-sites.md § Staging ORT Web for an app.

lib/tiny-genai-model.py#

python3 -I tiny-genai-model.py --out DIR [--check] [--hidden-states]: a GenAI model of a few hundred KB whose greedy output is known, so a binding test needs no model file. fixture.json beside it is the oracle the tests read; --check decodes it through the installed onnxruntime_genai and exits 2 where there is none. The model, and what the stdlib suite cannot prove: language-ai.md § The test model.

lib/test-harness.sh#

A consumer’s bash suite sources $(antfrastructure_path linux/scripts/lib/test-harness.sh) and gets the hub’s own harness: t_case, t_assert_eq, t_assert_contains, t_assert_ok, t_assert_fails, t_assert_rc, t_assert_grep, t_assert_no_grep, t_rc, t_out, t_skip_unless, t_needs and t_summary (cross-build-verification.md § The linux/scripts/tests suites). The suite runs under set -u, not -e: the harness counts every failed assertion and t_summary sets the exit code, 0 only when at least one assertion ran and none failed. It prints the same N assertion(s) passed line the consumers’ own passed counters did. Like every lib/ module it loads 01-core/logging.sh through log-bootstrap.sh, so info, warn and err are there too.

A consumer’s own helper

The harness

expect <rc> <name> <args…>

t_case <name>, then t_assert_rc <rc> <command…>; a miss prints the command’s output

check <name> <file> <ERE> [absent]

t_case <name>, then t_assert_grep or t_assert_no_grep <file> <ERE>; a miss prints the file

check <name> <command…> with a fails count

t_case <name>, then t_assert_ok <command…>

passed and the closing printf

t_summary

Gate aggregation (01-core/gates.sh)#

run_gate / gate_skip / assert_gates, the shell half of the fleet’s “run every gate, then fail once” idiom (the PowerShell half is Invoke-BuildGate / Add-BuildGateSkip / Assert-BuildGates in WindowsBuild.Common.psm1).

On GitHub a failed gate also writes ::error title=<batch>: <gate>::<gate> failed (exit N) and, where $GITHUB_STEP_SUMMARY is writable, a summary row, so the run’s annotations name it (CON293). A host step has GITHUB_ACTIONS=true; run-in-linux-container passes GATES_GITHUB_ANNOTATIONS=1 into its container instead, as GITHUB_ACTIONS would also change the tools’ own behaviour there. A lane split into named parts (owner decision D7, no reusable Linux C++ lane) runs one step per part under if: ${{ !cancelled() }} plus that part’s own build outcome, and guards each upload with hashFiles, as BeschleunigerBallett’s reusable-linux.yml does: every check runs, and the red step names the failure.

source "${CORE_DIR}/gates.sh"
gate_reset "static analysis"
run_gate "ruff check" ruff check --no-fix src
run_gate "ty"         ty check
if has_tool clang-tidy; then
  run_gate  "clang-tidy" clang-tidy src
else
  gate_skip "clang-tidy" "not installed in this image"
fi
assert_gates            # 0 when all passed; 1 naming every failure or skip

Every gate RUNS even after an earlier one fails, so one push names every finding instead of one per round trip. run_gate returns 0 for a failing gate — that is deliberate and it is only safe because assert_gates re-raises: a run_gate batch with no closing assert_gates is suppression, not aggregation. It is compatible with set -e (the command runs inside a || list). assert_gates also fails when no gate ran, because an aggregator whose list came out empty reporting success is the failure this mechanism exists to prevent.

The third bucket: a gate that could not RUN#

A gate can also be neither a pass nor a failure: its tool is not installed. Both ways of forcing that into the other two buckets are lies — counted as a pass it is the suppression this file exists to prevent, counted as a failure it is a red nobody can act on — so gate_skip <name> [why] records it as its own thing. The reason is part of the record on purpose: “skipped” without one reads exactly like a gate somebody quietly deleted.

Bucket

Recorded by

Counts as “a gate ran”?

Verdict

pass

run_gate, command exits 0

yes

green

failure

run_gate, command exits non-zero

yes

red, and named

skip

gate_skip

no

red, unless --tolerate-skips

A skip is RED BY DEFAULT, and that default is the inverse of the first cut. The earlier spelling was assert_gates --fail-on-skip: tolerance was what you got for free and strictness was the thing you had to remember, which is exactly the “allowed to fail” shape the fleet rule forbids. A driver that forgot the flag reported green over a tool that never ran, and nothing in the tree recorded which drivers those were. Inverted, tolerance is an explicit --tolerate-skips at a call site, so one grep -rn -- --tolerate-skips enumerates every place in the fleet where a missing tool is currently allowed to pass and the audit is finite. assert_gates returns 2 for any other argument, so a stale --fail-on-skip is a caller bug rather than a silently re-armed default.

A skip does not count towards _GATE_RAN, so a batch of nothing but skips is red even with --tolerate-skips: nothing was graded, so there is no result to tolerate. That is the no-gate-ran rule above, and it outranks the flag — as does a real failure sharing the batch.

run_gate runs its command in a SUBSHELL#

( "$@" ), not a bare "$@". Upstream check helpers report failure with err() (01-core/logging.sh), which ends in exit 1. Called directly that exit unwinds the driver, not just the gate: the findings already recorded are lost, the gates after it never run, and the batch never reaches assert_gates — “stop at the first failure” arriving through the back door, in the one file whose whole job is to prevent it. || does not catch exit; only a subshell does. The cost is that a gate can no longer export state back to the driver, which no caller wanted. linux/scripts/tests/test-lint-gates.sh grades this by running one driver against the shipped file and against a copy with the subshell removed: the copy has to die mid-batch, or the shipped file passing proves nothing.

Windows parity, and the one place the halves differ#

The third bucket is mirrored exactly — Add-BuildGateSkip -Context -Name [-Reason] and Assert-BuildGates [-TolerateSkips], where a [switch] is false unless passed, so the inverted default is the same fact on both halves.

The subshell is not mirrored, and that was measured rather than assumed: exit inside a gate scriptblock terminates the whole PowerShell driver through both & $Script and $Script.Invoke(), and the only containment left is a child runspace, which breaks the closures a gate scriptblock is written with. The hazard also does not arise there for the reason it does in bash. Invoke-BuildGate’s contract is that a gate fails by throwing, or by a non-zero exit propagated through Invoke-BuildExternal, and its try/catch already contains both; PowerShell has no equivalent of the fleet-wide err() helper that makes exit the normal way to report a failure. windows/scripts/tests/BuildGates.ThirdBucket.Tests.ps1 pins both halves of that paragraph, the child-pwsh measurement included, so the day PowerShell contains an exit this section goes red instead of quietly aging into a false claim.

Tool presence (01-core/tool-checks.sh)#

has_tool <cmd> and require_tools <cmd>..., the latter naming every missing tool rather than the first. Each is defined only when the caller has not already defined it, so a project common.sh still wins — that conditional shape is what the inline fallbacks in lib/code-quality.sh and lib/coverage.sh were, and those two now source this instead of carrying a copy each.

Python interpreter probe (01-core/python-probe.sh)#

python_venv_executable selects an executable bin/python, then Scripts/python.exe, preserving the raw venv path. UV and WebDAV retain their own named errors and checks. Copies of either module require the pure probe beside it. UV and Python CI also share the /workspace/pyproject.toml override; caller defaults, cwd changes and PATH setup remain caller policy.

preflight_python_require <caller> returns 0 with PREFLIGHT_PYTHON exported when that value (or, unset, python3) runs -c pass, and 1 naming the caller and the knob otherwise. Plain python3 is not trusted because on Windows Git Bash it is the Microsoft Store stub, which prints an install hint and exits non-zero. preflight.sh probes a candidate list and exports the winner; a gate run standalone inherits nothing, so lint-workflows.sh and run-lint-gates.sh call this before their Python steps instead of each carrying the check inline, which is where the second copy sat until 2026-09-14. lint-python.sh and this repo’s own pre-commit/pre-push hooks joined them on 2026-09-15. Expand the value unquoted, as preflight.sh does: it may be a command line such as uv run --no-project python, the very hint the failure message gives.

ci_image_python_require <caller> <docs-hint> [python-path] is the stricter consumer entry point for scripts that must run inside the family Linux image. It requires the image’s PYTHON_MAJOR_MINOR marker and a working /opt/venv/bin/python3 (the optional path is for isolated tests). Success exports PREFLIGHT_PYTHON; failure returns 2 with the caller’s documentation hint and leaves an existing interpreter override untouched. ModelANT and AssetANT source this file through their hub resolver instead of each keeping the image check locally.

run-in-ci-image.sh — run a command in the CI image#

bash third_party/ANTfrastructure/linux/scripts/run-in-ci-image.sh . -- bash scripts/linux/build.sh

<repo-root> [--engine docker|nerdctl] [--image REF] [--platform ...] [--workdir ...] [--mount-hub-scripts] [--name N] [--user U[:G]] [--keep] [--volume NAME:/PATH]... [--env NAME=VALUE]... [--privileged] [--memory SIZE] [--cpus N] -- <command...>.

It replaces the hand-typed docker run that had drifted across consumer READMEs. The image comes from ci-image-ref.sh. The checkout is mounted at /workspace, and every directory is a git safe.directory. The engine is nerdctl when present, else docker; under nerdctl the run adds --security-opt apparmor=unconfined. --image REF replays an explicit image; record proof with a digest.

MSYS_NO_PATHCONV=1 MSYS2_ARG_CONV_EXCL='*' are exported by the script rather than documented for the reader: from Git Bash, MSYS rewrites anything that looks like a POSIX path into a Windows one, destroys every -v/-w argument, and fails with “expected an absolute path”. A note nobody reads is how that keeps being rediscovered.

On a Windows host the Linux images run in Rancher’s WSL distro. From Git Bash or another WSL distro, without --engine, the helper asks wsl.exe -d rancher-desktop -e nerdctl version. When that answers, every engine call goes through it. The checkout is then mounted as /mnt/<drive>/.... Stevedore’s docker.exe and nerdctl on the Windows PATH drive the Windows engine and hold no Linux images. Another distro’s /mnt/c/... binds an empty directory (why). The helper uses -e, not --: through the distro’s shell, a $( ) in the command would expand there.

A checkout off the Windows drives is refused by name. RUN_IN_CI_IMAGE_WSL_DISTRO names another distro, and --engine skips the detection. With any engine, an empty /workspace stops the command with exit 2. Pull the image from that distro too (wsl -d rancher-desktop -- nerdctl pull …). Its logins live there; a Windows credsStore: wincred fails outside an interactive logon.

Every directory is a git safe.directory in the container ('*', in its throwaway global config). A Windows-drive checkout is root-owned to uid 1001, and so are its submodules. Trusting only /workspace made every gate that reads a submodule call it “not a git checkout”. A linked git worktree is refused by name before any engine call. Its .git names the gitdir by a host path the container cannot open, so run from a clone. tests/test-run-in-ci-image-wsl.sh covers the detection over fakes.

A cache that outlives the run. --volume NAME:/PATH (repeatable) mounts a named volume, which the engine creates on first use, and --env NAME=VALUE (repeatable) points a tool at it:

bash third_party/ANTfrastructure/linux/scripts/run-in-ci-image.sh . \
  --volume myrepo-cargo-target:/ct --env CARGO_TARGET_DIR=/ct \
  --volume myrepo-cargo-registry:/usr/local/cargo/registry -- cargo test --locked

A new named volume belongs to root. When the run has another user (--user, or the image’s own user when no --user is given), the helper first starts one short container as root that hands each volume’s directory to that user; only the directory, not what an earlier run under another user left in it. Without --user it reads the image’s user from the local copy and pulls the image first when there is none. A value that is not NAME:/absolute/path, or carries a comma or a mount option, is refused before any engine call, and so is an --env without =. --privileged is passed on as it is; the consumers’ CI lanes run privileged, so a local run that should match them asks for it.

Under a rootless engine on Linux the helper runs as root without being asked: when the engine’s info reports rootless and no --user was given, it passes --user 0:0 and TAR_OPTIONS=--no-same-owner (linux-build-basics.md § A lane under a rootless engine … has the two failures behind that). An explicit --user is kept, and so is a TAR_OPTIONS the caller passes with --env. Docker on a CI runner and Rancher Desktop on Windows are not rootless in this sense and keep the image’s user.

--memory SIZE (12g) and --cpus N (6, 2.5) cap the container. Without them, RUN_IN_CI_IMAGE_MEMORY and RUN_IN_CI_IMAGE_CPUS from the environment do. The swap limit equals the memory limit, so a container at its cap is killed instead of swapping the VM full (rancher-desktop-linux-containers.md § Sizing the VM). A malformed value is refused before any engine call. The stderr line names the caps. The runner exits with the engine’s status, so a run killed at its cap exits 137.

How old the image is. Every run prints one line on stderr before the command starts: run-in-ci-image.sh: image <ref>, local copy created <date>, or no local copy; the engine pulls it. A month-old local :latest without GTK 4 once looked like broken code. The line is on stderr, so the command’s stdout stays the command’s. A local copy older than RUN_IN_CI_IMAGE_MAX_AGE_DAYS (default 7) is pulled again for the run’s platform before the run, since a three-week-old copy once graded a branch with another toolchain than CI’s. 0 keeps any local copy; a failed pull warns and runs the old copy, so an offline host still builds. test-run-in-ci-image-age.sh holds both over a fake engine.

Not covered: bind mounts beyond the checkout and the hub scripts, devices (--device), GPU flags and a network other than the default. Tests: proof_workflow_tests.py with an engine that records its arguments, and one real run of each path on the rootless arm64 dev host; recipes host.run-image-*. test-run-in-ci-image-limits.sh holds the caps over a fake engine. Where an engine reports the memory and swap limits and holds a local copy of the CI image, it also writes 256 MB under --memory 64m for real. That run must exit 137, and the same write under 1g must pass. When either is missing, as inside the CI image (no engine) or on a fresh CI runner (no local copy), the case prints SKIP.

CI workflow steps keep using the run-in-linux-container composite action; this is for everything that is not a workflow step.

ci-image-ref.sh — the family CI image reference#

Prints ${IMAGE_REGISTRY_PREFIX}:${CI_IMAGE_LINUX_TAG} (or …_WINDOWS_TAG with --windows, …_WINDOWS_ARM64_TAG with --windows-arm64 for the arm64 cross bundle) on stdout and nothing else, so it is safe in a command substitution.

docker run --rm -v "$PWD:/workspace" -w /workspace \
  "$(third_party/ANTfrastructure/linux/scripts/ci-image-ref.sh)" <cmd>

Workflow steps do not need it: the four container composite actions carry the same value as their image: input default. It is for the callers that cannot omit an input because they are not calling an action — a raw docker run, a local repro, a lane driver. It is the one entry point here that takes no consumer root, because the only file it reads is this repo’s versions.env whatever tree is being built; a root parameter would imply a per-consumer answer and there is none. Its PowerShell twin is Get-CiImageReference (WindowsContainerImage.Common.psm1). tests/test-ci-image-ref.sh holds the script to the same strings as verify_ci_image_refs.py, which grades the four action defaults (and the Windows pair’s image-arm64); ContainerImage.CiRef.Tests.ps1 holds the twin to versions.env.

The empty-scope rule#

_lint_gates_scope builds a gate’s file list from git ls-files under the graded root, minus the excluded top-level directories. Its third argument decides what an empty result means, and the two callers genuinely differ:

Mode

Meaning

Who uses it

refuse-empty (default)

a BROKEN SCOPE. lint-shell.sh with zero file arguments falls back to ANTfrastructure’s OWN tree and passes, so green over nothing is a lie.

the shell gate

allow-empty

a FACT about the repo.

the python gate

The python gate can allow it because it passes explicit absolute paths: with no paths there is no argument list to fall back from, so there is nothing to run and nothing to mis-grade. That distinction is not cosmetic — ANThology is a pure Dart package and OxidANT a Rust crate, neither has a single .py, and refusing an empty Python scope made both lanes exit 1 on every push for a reason nothing in either tree could change. A permanently red lane is a tolerated failure by construction.

run-lint-gates.sh — the gates over a consumer tree, plus the opt-in ratchets#

bash third_party/ANTfrastructure/linux/scripts/run-lint-gates.sh "$PWD"
bash third_party/ANTfrastructure/linux/scripts/run-lint-gates.sh "$PWD" --exclude vendor
bash third_party/ANTfrastructure/linux/scripts/run-lint-gates.sh "$PWD" --ratchets --code-dupes-report

shellcheck, actionlint (+ the CI image-ref check), gitleaks, ruff (error tier), the shared-config drift check, the consumer pin-forwarding check, the README length, the README badges, the consumer lanes, the doc prose, the pattern limits and mutation staleness, in one command, every gate running even after one fails. Three consumers had grown their own copy — two of them as run: blocks inside a workflow, so the gate blocking their deploy could not be reproduced locally at all.

What the copies carried and this keeps: the git ls-files scope (a **/*.sh glob does not recurse without globstar, so it graded the directories somebody remembered), the empty-list guards (lint-shell.sh with zero file arguments falls back to ANTfrastructure’s own tree and exits 0), and the gitleaks self-test — a clean-tree positive control plus a planted-PAT canary matched by path, which is what tells “the gate ran and found nothing” from “the gate never started” and proves the scan root was honoured.

--exclude <dir> (default third_party) drops a vendored top-level directory from every scope while KEEPING the tracked plain files directly inside it: those are the consumer’s own, and dropping the whole prefix excluded them silently.

The secret scan reads the files a commit could take. That is git ls-files -co --exclude-standard: the tracked files, and untracked files no ignore rule covers. Their working-tree bytes go to a temporary tree, without the vendored subtrees. The scan runs over that tree’s top-level entries. It uses the staged checks’ driver. An ignored file is never read, such as a local quality/.venv. So a dev host and a fresh CI checkout agree. Deleted files, symbolic links, gitlinks and nested repositories are not scanned. A tree with no file to scan fails the gate. The copy goes under TMPDIR, since mktemp -d makes it. Where /tmp is RAM, large tracked assets fill memory. Point TMPDIR at a disk there.

The pin preconditions the copies carried (“does the pinned lint-secrets.sh understand a scan root yet?”) are gone by construction: this script ships in the same commit as the gates it calls.

Shell line endings runs verify-shell-eol.sh <consumer-root>, the hub’s own crlf-guard: no tracked shell script (by lint-shell.sh --list-files, so a hook without a suffix counts) with w/crlf, w/mixed or w/-text. The staged checks run it with --staged, which reads the i/ column of the staged scripts: the bytes the commit carries.

README length runs verify_readme_length.py --root <consumer-root>. Its 100-line limit binds at once. Words and width only report until the consumer seeds <consumer-root>/readme-length.census.

README badges runs verify_readme_badges.py --root <consumer-root>. It is off until the consumer adds <consumer-root>/readme-badges.allow.

Consumer lanes runs verify_consumer_lanes.py --root <consumer-root>. It is on without any file: a quality lane the tree needs and no workflow calls on push and pull request fails, with the caller to add.

Doc prose runs verify_doc_prose.py --root <consumer-root>. It only reports until the consumer seeds <consumer-root>/doc-prose.census; from then on a page’s prose may only get better.

Pattern limits runs verify_pattern_limits.py --root <consumer-root>: a quality-report.toml row kind = "pattern" with max = 0 fails on its first match and prints file and line. Without such a row it passes with one line.

Mutation staleness runs verify_mutations.py --stale-check --root <consumer-root> over every tracked scripts/linux/tests/*mutations*.json, directly in that directory, and runs no recipe’s test. A recipe whose find text is gone fails the gate with the recipe’s id and its manifest; a manifest that still applies prints one line; a tree without one passes with nothing to grade. The reusable lint lane calls this script, so CI’s lint lane has the check too. Not covered: an untracked manifest, one in a subdirectory or elsewhere, and whether a mutant is caught, which the mutation lane proves. A consumer wrapper that still runs its own --stale-check loop before this script deletes that loop: both give the same verdict.

One warning line on stderr, never a verdict, when core.hooksPath is unset in the graded checkout and CI is not set: it names the config line of the git hooks.

--agents-drift (opt-in) adds verify_agents_drift.py over the consumer: only a repo with the six-section AGENTS.md and a quality-report.toml passes it, so only the four AI consumers turn it on.

--ratchets (opt-in, 2026-09-14) adds the eight measurement gates that take --root — verify_code_size, verify_code_complexity, verify_dead_functions, verify_comment_size, verify_stdout_returns, verify_masked_assignments, verify_trailing_conditional and verify_shellcheck_warnings — over the consumer tree, exactly as the scan-root contract describes: the freeze files are read from <consumer-root>/<gate>.allow (function-size.allow, file-size.allow, code-complexity.allow, dead-functions.allow, comment-size.allow, masked-assignments.allow, trailing-conditional.allow, shellcheck-warnings.allow; verify_stdout_returns has none). It is opt-in because a tree with no freeze files is red on its first run — that first report is what seeds them. Seed, commit, then keep the flag on in the wrapper and the workflow.

--code-dupes-report writes an advisory duplication measurement to ignored logs/code-quality/code-dupes.txt; the reusable workflow enables and uploads it by default. --code-dupes is a separate fatal gate once copied blocks are removed. Neither switch changes the eight --ratchets gates or authorizes a new freeze budget. --allow-empty-shell is an explicit option for repositories with no tracked shell files; the default still refuses an empty shell scope. The workflow’s workflow-conventions input (default empty) sets WORKFLOW_CONVENTIONS_GATE for the run, so a consumer measured clean of a convention such as sha-pin arms it without changing any other caller’s verdict (the conventions).

The step also runs docs/scripts/verify_doc_links.py --root (2026-09-15), which is the ninth gate and the odd one out: it has no freeze file, so there is nothing to seed and it is safe the very first time the flag goes on. It grades every tracked Markdown page in the consumer — which is what puts a consumer’s own README.md into the cross-reference graph at all — and it runs even when the tree carries no shell, because a Dart or Python repo still has pages. verify_doc_dupes.py --against-hub --root (2026-10-19) runs beside it: a consumer page that restates a hub page fails, once the consumer seeds doc-dupes-hub.allow (how it decides).

A consumer with no tracked shell at all — a pure Dart or Python repo — may still pass the flag: the step asks gate_scope.assert_non_empty once with on_empty="allow", prints ratchets: no tracked *.sh outside third_party under <root> - nothing to grade. and returns green. That decision belongs to the aggregator, not to the gates: rule 2 of the scan-root contract says an empty scan is a decision and never a default, and who pointed the gate at this tree is the only thing that knows which answer is right. Pointed at a tree by hand, a gate still refuses. A root that is not a usable checkout fails the step outright, with gate_scope’s own message.

The Python gates run under PREFLIGHT_PYTHON when it is set (the same contract preflight.sh and lint-workflows.sh document) and probe the interpreter first: on a Windows host plain python3 is the Microsoft Store stub, and the probe names the fix instead of letting a gate die inside its Python step.

The staged checks (--staged)#

bash scripts/linux/run-lint-gates.sh --staged
bash third_party/ANTfrastructure/linux/scripts/run-lint-gates.sh "$PWD" --ratchets --staged --index .git/index

--staged replaces the gates above by the two that can grade the index alone, for the commit hook:

  • Large files, only with --ratchets: verify_large_files.py --root, the same check and the same large-files.allow as the ratchet step. It reads blob sizes from the index, so it grades a staged file before its commit. It reads the whole index, and it refuses a tracked file that is missing from the working tree.

  • The secret scan: the staged blobs of added, copied, modified, renamed and type-changed paths are written to a temporary tree with git checkout-index and scanned by the same driver, self-test and config as the tree scan. A secret that is staged fails although the working tree no longer holds it; an unstaged one does not. A vendored subtree, a symbolic link and a gitlink are not scanned. A commit that stages no file to scan passes without a scan.

--index <file> names the index to read. The commit hook passes the one git hands it: git commit -a and git commit <path> build the commit’s index in a lock file, and the plain index does not show their files yet. A file that does not exist is refused, and so is --index without --staged. The other flags are accepted and select nothing.

Left to the full gates: every whole-tree gate, mutation staleness included. Not available in either mode: a line-ending check, for which the hub has only its own preflight slug.

05-frameworks/flutter/setup-sqlite3-wasm.sh#

Fetches the pinned sqlite3.wasm into <consumer-root>/web/, SHA256-verified through download_verified_file. Two consumers had copied the same unverified curl and had already drifted to different versions; the version and its digest now live in 01-core/versions.env (SQLITE3_WASM_VERSION / SQLITE3_WASM_SHA256). There is deliberately no version argument — the pin is the point.

WindowsFlutterPin.Common.psm1#

The Windows twin of flutter_resolve_pin. windows/scripts/host/Install-PinnedFlutter.ps1 -Destination <dir> clones the FLUTTER_VERSION tag, refuses a checkout that is not FLUTTER_COMMIT (tool-pins.env), adds bin/ to GITHUB_PATH and prints the version. A caller’s FLUTTER_VERSION wins with a warning and no commit check. A git checkout serves x64 and arm64 alike, which the x64-only Windows zip does not, so the commit is its pin. The check covers the framework commit only; the first flutter run still fetches its engine from upstream.

05-frameworks/flutter/lane-prologue.sh#

flutter_lane_prepare_env [flutter_dir] is the Flutter twin of cmake-build.sh’s cmake_build_prepare_env, and exists for the same reason: two consumers had each grown their own prologue, they had drifted, and the differences were all work the IMAGE already does.

It asserts ${FLUTTER_DIR:-/opt/flutter}/bin/flutter, puts its bin/ on PATH once, registers a git safe.directory for the repo root only, defaults PUB_CACHE to <repo>/.pub-cache, and prints flutter --version — the tag is unpinned, so the version is a measurement rather than a constant.

Because that cache lands inside the repository, a consumer that also runs a tree-walking gate must keep it out of the walk: every dependency ships its own example/ sources, and a gate that grades them fails on code the repository neither owns nor can format. OmniAccelerANT measured 28 such CMake files — fl_chart’s example/linux/CMakeLists.txt among them — after one pub get. code_quality_find_cmake_files therefore excludes */.pub-cache/* by default (CODE_QUALITY_CMAKE_DEFAULT_EXCLUDES, added to whatever CODE_QUALITY_CMAKE_EXCLUDE_PATHS a consumer sets, never replacing it): the hub created the directory, so the hub excludes it. The C/C++ walks skip it too, with the other dependency and output trees git never lists (CODE_QUALITY_UNTRACKED_EXCLUDES; Windows’ walk the same set, 2026-10-19). Any OTHER tree-walking gate a consumer runs — a licence sweep, a secret scan over sources — has to exclude it in that gate’s own list.

Three things it does not do, and must not gain: a safe.directory for the SDK (setup-package-image.sh registers /opt/flutter at --system level, so a --global copy is a no-op that reads like a requirement), sourcing ~/.bashrc to find flutter (Dockerfile.package’s ENV PATH already carries it, and a stock non-interactive .bashrc returns early with a meaningless status while hiding a broken rc file), and installing an SDK — a lane that installs one is testing a different toolchain from the one it ships.

flutter_build_web [--wasm] [--no-tree-shake-icons] [args...] is the optional second half: flutter build web --release with the two flags every consumer passes named rather than re-spelled, everything else forwarded untouched.

01-core/webdav-download.sh#

webdav_download_tree <remote> <local> [extension|all] pulls a WebDAV tree into a directory. Credentials come from WEBDAV_HOSTNAME / WEBDAV_USERNAME / WEBDAV_PASSWORD and are never arguments — a password on a command line is in every ps listing and in every CI log line that echoes the command.

It installs the client at WEBDAVCLIENT_REF from 01-core/versions.env, which is the point of the pin: the PowerShell twin (WindowsWebDav.Common.psm1) installs the same ref, so “which WebDavClient did this run use” has one answer instead of “whatever the default branch was that day”. The --python in the install is load-bearing — the image bakes a root-owned /opt/venv and exports UV_PYTHON at it, so a plain uv pip install inside an activated .venv still targets /opt/venv and dies with “Permission denied (os error 13)” as the uid-1001 build user.

The script it runs is 01-core/download-webdav-files.py. Filtered and complete walks both call the client’s download_all_files_iterative(..., extension=...). The client owns decoded path validation, local-root containment, response lifetime and atomic replacement. A listing, HTTP or streaming failure reaches the CLI as exit status 1, including a failure after earlier successful files. The .pfx certificate fetch uses the same implementation with a filter. A one-line shim remains at windows/scripts/certificates/download_webdav_files.py, because the PowerShell module resolves that path relative to itself.

01-core/http-readiness.sh#

wait_for_http <url> <who> [attempts] [sleep] polls until an endpoint answers. Three consumers had written this loop and every difference between them was an accident — attempt count, sleep length, and the one that matters: whether failure kills the caller. It returns non-zero rather than exiting, because the nginx caller has to dump docker logs before it dies and a helper that calls exit takes that away. Probes that fail while the server is still starting are the expected case and stay silent; only the verdict is printed, and it names who — a bare URL never told anyone which server failed to come up. Defaults are 50 attempts at 0.2s, the ten seconds the consumers converged on.

01-core/bind-mount-ownership.sh#

fix_bind_mount_ownership <target> <reference> hands a tree a container wrote back to whoever owns the bind mount. <reference> is a path the host user owns — normally the workspace root — and its uid:gid is what <target> is handed back to; nothing takes a uid as an argument, because a number typed at a call site is the thing that goes stale.

The three decisions around the chown are the whole reason this is shared:

  • Only the paths that actually differ, never a blanket chown -R. On a tree that is mostly already correct, recursing over it asks the kernel for a chown it refuses for a non-owner and turns a no-op into an error. -h so a symlink is retargeted rather than its destination, which may be outside the tree.

  • A failure as a non-root uid is explained and tolerated. Giving a file to a different uid needs CAP_CHOWN; as an unprivileged container user that is arithmetic, not a defect, and it was measured red on a Windows host with nothing an operator could do about it.

  • The same failure as root is fatal. There it means a read-only or broken mount, and the tree really is left in the state this step exists to prevent.

A missing <target> is not an error: a docs step that produced nothing has nothing to hand back. lib/dartdoc-build.sh’s dartdoc_build_fix_ownership is the older blanket chown -R form over one fixed tree and predates this; tests/test-bind-mount-ownership.sh pins all three decisions.

The asset mirror#

01-core/downloads.sh owns it, so every caller of download_verified_file (and of download_verified_cached and download_verified_install, which go through it) inherits it without a new companion file. download_mirror_fetch asks <ASSET_MIRROR_URL>/<sha256>/<name> first, download_verify_sha256 checks the bytes, and a miss or a mismatch falls back to the upstream URL. The config comes from KATAGLYPHIS_ASSET_MIRROR_FILE, else the RUN’s /run/secrets/asset_mirror, else ~/.config/kataglyphis/asset-mirror.env; without one, nothing changes. The mirror speaks plain HTTP over WireGuard on purpose, since the pinned digest, not TLS, vouches for the bytes. download_mirror_curl signs a request when the file holds a key and passes the key on stdin; fill-asset-mirror.sh reuses it and download_mirror_object_name, so the reader and the writer cannot disagree on a name. Knobs and log lines: linux-cross-builds.md § The asset mirror; tests/test-asset-mirror.sh pins the fallbacks.

ELF stripping in media and toolchain builds#

01-core/elf-strip.sh owns strip_elf_files and strip_elf_tree. Media build helpers source this companion; copy it beside build-helpers.sh. A minimal 02-toolchain/bootstrap.sh also needs the companion in its directory, the adjacent 01-core directory or /opt/scripts/core. It reports a missing companion rather than defining a private strip implementation. GCC and LLVM’s narrow Dockerfile closures both mount the leaf explicitly.

Tree stripping still selects ELF files, uses the requested tool and parallelism, and treats strip errors as quiet best-effort work. GCC retains its narrower executable/shared-object selection and invokes both host and target strip tools. The shared invocation uses NUL separators, preserving filenames containing spaces; an empty selection invokes no tool. test-elf-strip.sh uses stubbed file and strip tools, not real ELF mutation or a compiler build.

Renovate driver helpers#

renovate-cli.sh owns the local/fleet argument loop and their explicit option policies. renovate-git.sh owns root validation and callback-based submodule enumeration. Both are passive libraries, require the driver’s existing err function and must accompany either driver. Discovery callbacks own branch classification and recursive identity resolution. See dependency-updates.md for the dry-run contract and regression coverage.

GStreamer monorepo setup uses the cross guard validated by media_common_init. It refuses a missing guard before configuring flags, rather than defining its own fallback. The Meson fixture suite checks both guard verdicts and incomplete closure refusal. The fallback for core-only consumers remains owned by 01-core/common.sh.

Shared CMake and CTest project environment#

lib/project-env.sh owns Git safe-directory setup and project Vulkan initialization. It loads log-bootstrap.sh directly, so standalone sourcing supplies the same real logging module as the launchers. The whole-library census includes this companion; new libraries must pass it before any library mutation has a valid baseline. Both launchers source it, so copies must carry it and 01-core/vulkan-env.sh. An empty safe-directory setting opts out; Git configuration failures stay advisory. The caller’s source_vulkan_env hook takes precedence over an explicit setup script, including its exit status. Explicit scripts use the Vulkan leaf’s active-link restoration. That leaf also owns the common Vulkan CLI help lines.

test-project-env.sh checks hooks, setup-script effects in the caller, directory spacing and each launcher’s delegation with stubbed Git. Existing Vulkan fixtures check the active link. Neither suite initializes a real SDK or changes user Git configuration. CMake retains its separate Cargo, ccache and linker policies.

Core-only cross detection lives in core_cross_build_is_active in common.sh; its source-time selector preserves a loaded canonical guard or compatibility hook. The fallback suite tests this approximation directly, including native architecture aliases, while GStreamer tests the mandatory canonical guard at its own boundary.

Compiler identity and pinned source staging#

platform.sh owns clang_embedded_deb_version, used by package setup and compiler validation. Embedded Debian metadata identifies the selected binary even when a loaded distro libclang-cpp changes its --version output. The existing epoch and suffix parsing and CLI fallback remain unchanged. The validator wrapper keeps an empty result nonfatal under errexit; setup retains its existing failure policy. test-clang-embedded-version.sh checks these boundaries with executable fixtures, not a real Clang installation.

downloads.sh owns clone_pinned_repository: try a filtered clone, fall back to an unfiltered clone, check out the requested commit and compare HEAD exactly. Each failure propagates in a conditional caller. HailoRT initializes submodules after cloning; TAPPAS copies its selected include tree and uses its own sentinel. The pinned-repository suite exercises those policies with a stub and a real local Git repository; it accesses no remote repository.

hailo-build-lib.sh owns hailo_unpack_source_archive. Callers retain their readiness checks, URLs, hashes and cache paths. The helper verifies before extraction, creates the destination, applies the requested strip count and keeps the archive for cache reuse. The archive suite uses real local tarballs and hashes, including corrupted archives and a failed download over a valid stale archive. download_verified_file stops on fetch failure even when its caller disables errexit; checksum success alone cannot turn a failed fetch green.

Android CMake target arguments#

android-build-preamble.sh owns android_cmake_target_args, which replaces the caller’s array with the selected NDK toolchain path, ABI and resolved API level. IREE, LiteRT and OpenCV expand that array into their target configuration; host configuration, project options, configure retries and failure policy remain with the caller. The argument suite checks three ABIs and an NDK path containing spaces; it does not invoke an NDK or build any of the projects.

Python CI test fixtures#

The test harness owns t_python_ci_fixture <root> <scripts> [relative-script ...]. It exports WS, TREE, CALLS, OUT and BIN for fixture subprocesses, creates isolated directories and copies python_uv.sh, logging and each requested script, then writes workspace detection that points to FIXTURE_WS. Missing inputs fail in conditional callers too. The four Python CI suites append their own preparation and uv stubs; their wheel, packaging and interpreter assertions remain unchanged. Harness fixtures verify source bytes, paths with spaces and workspace binding without invoking uv.

Windows test fixture helpers#

TestHarness.psm1 owns temporary directory allocation and exception assertions. New-TestDir -Prefix preserves each suite’s diagnostic prefix and creates a unique directory. A suite-scoped fixture keeps its existing AfterAll cleanup; Invoke-InTestDir owns cleanup for one test body, including failures. Assert-Throws -MessagePattern checks both the exception and the expected diagnostic instead of copying a Boolean and catch block.

Assert-FileUnchanged -Path -Action compares exact SHA256 file bytes around an operation. It uses literal paths, retains callback context and propagates exceptions from the operation. It neither restores modified files nor proves that their contents are correct; local controls cover callback execution, changed bytes and bracketed paths.

The harness fixtures exercise directory creation, prefixes, cleanup and exception matching, with mutation proofs for allocation.

OpenCV and its GStreamer plugin delegate checkout-directory creation to Invoke-GitClone and Git itself. They no longer pre-create the checkout parent; a local-repository regression covers cloning into missing parent directories.

Common build CLI dispatch#

01-core/cli-parsers.sh owns _parse_common_build_flags for the runtime and cross orchestrator parsers. It dispatches global options and mirror updates before architecture aliases and help. Existing nameref destinations, parser signatures and project-specific options stay unchanged. Return codes still mean unknown (0), one argument (1), a flag plus value (2), or help (255); the outer dispatcher retains its missing-value checks. The parser suite exercises both public entry points, including URL whitespace and swallowed option values.

Cross GCC builder invocation#

02-toolchain/gcc.sh owns _gcc_invoke_cross_builder for ordinary cross GCC and Canadian native GCC. It preserves option order, the root sysroot, target include path, C/C++ languages, non-bootstrap mode, compiler cache and registration policy. Only the Canadian call supplies --host; its compiler environment and configure cache answers remain with that caller. Prefix, scratch directory and requested or detected job count are forwarded to the existing builder.

Both callers raise builder failures explicitly. An ordinary cross build can no longer appear successful under a conditional caller merely because an earlier installation left executable tools behind. The Canadian link-probe skip remains opt-in and happens before the builder. Local fake tools exercise argument order, environment, job counts and fatal/skip paths; they do not compile GCC or inspect real compiler ELF files.

Shared Windows source edit cycles#

WindowsSourceBuild.Patches owns optional/must-exist file loading, callback marker skips and write/no-change verdicts. Regex and callback transformations keep their own semantics. Their optional -Quiet mode leaves logging and aggregate change counts with the caller while preserving missing-input errors, transform failures and regex postconditions. Existing calls keep their default warning behavior.

GStreamer, IREE, LiteRT-LM, C++ keyword conversion and Ninja cleanup use this common cycle. The GStreamer OpenCV 5 transformation is a pure text function so fixtures can check header insertion and Windows CRT substitutions without running a source build. Get-TestCommandArguments -AsAst exposes typed argument nodes so fixtures can exercise the actual caller callbacks without executing the build entry scripts. The test harness’s Invoke-SourceFileDiagnosticCase exercises changed/unchanged transforms in normal and quiet modes, including output types, file bytes, failure propagation and no-op timestamps.

Torch’s Dockerfile test parser indexes stage objects as it reads them, retaining global instructions, unnamed stages and references to the final instruction lists. Its fixture and mutation proof cover indexing without invoking a container build.

Cold module visibility fixtures#

Test-ColdModuleCommands in the Windows test harness runs module imports and command visibility checks in a fresh PowerShell session. It returns the child exit code and captured diagnostics, quotes literal paths and command names, and accepts -Force only when a caller needs a forced entry-level import. Re-export and build-call closure suites share this probe. Their declarations come from the harness AST readers and command binder, so malformed scripts fail before export or function discovery. Get-TestFunctionNames reads only parsed function declarations, including nested definitions, without executing the source. The fixture tests cover exported and missing commands, failed imports, apostrophes in paths and isolation from parent-session functions; they do not execute build entry points.

ONNX web installation and artifact verdicts#

50-build-js.sh shares install_onnx_web_lock across js, js/common and js/web. Each call runs in its original directory, retries npm ci once after five seconds and fails after a second error. There is no npm install fallback. require_onnx_web_js accepts either JavaScript extension and checks both js/web/dist and the final WASM output directory. The copy still treats an absent extension as optional, and a missing destination artifact is fatal.

test-onnx-web-build.sh runs the actual step with local npm, sleep and cleanup stubs plus the production logger. It covers both extensions, retry success and failure in all three directories, failed builds, missing bundles and failed copies. It does not build real bundles, contact npm or validate the contents of upstream lockfiles. The fixture can take an earlier step file as its first argument for behavior comparison.

Shared bundle packaging lifetime#

The public deb, AppImage and Flatpak bundle entry points keep their arguments. app-packaging-entrypoint.sh owns executable selection and is a required companion of copied app-packaging.sh; a missing module or export fails during import. The selector sources log-bootstrap.sh itself, including when imported directly. Set APP_PACKAGING_BINARY_NAME for a bundle containing executable helpers, such as OxidANT with its HIP worker. It selects the application for the installed DEB wrapper, AppRun and Flatpak command. A nonempty value must be an ASCII portable basename (letters, digits, _, ., +, -), excluding . and .., and name a regular executable file inside the bundle. Missing, nonexecutable or linked selections fail without choosing a different program. Unset or empty values keep the existing automatic discovery policy. The entrypoint suite executes the real rendered AppRun and inspects the DEB wrapper using stub builders; it proves no compression, installation or GPU execution. They share a dispatcher that owns local bundle facts, the common icon name and the final nonempty-artifact verdict. Format callbacks retain their layout, commands, output names and diagnostics. A callback failure propagates before the final verdict, even when a previous artifact exists. The callback is invoked unconditionally: putting it in an || list would disable Bash errexit inside its staging operations. A local regression verifies that an early copy failure still stops an unconditional AppImage invocation.

The format architecture wrappers share supported-architecture validation and retain their original alias conversions and format-specific refusal messages. Bundle copying preserves hidden files, symlinks and executable payloads through one shared staging operation. Desktop-entry and optional-icon staging has one owner; template adaptation and format-specific Exec, Icon and destination values remain with the caller. test-app-packaging-bundle-facts.sh exercises these contracts with local fixtures. The existing archive suite also builds and inspects a real deb; the Flatpak suite uses tool stubs. These checks do not validate real AppImage or Flatpak creation on a target machine.

TVM compiler-name resolution#

_tvm_gcc_commands in 05-frameworks/tvm.sh selects versioned GCC and G++ names independently, falling back to the corresponding generic command. Validation still requires both toolchain compilers and checks explicit CC and CXX overrides. Selection still resolves override paths and hands C then C++ to the ABI wrapper with the original LLVM and build-directory arguments. The local selection fixtures also run against the previous implementation; they execute neither compilers nor TVM builds.

Shared log-prefix formatting#

01-core/logging.sh formats severity labels and their color policy in one place. _log_prefix_plain and _log_prefix_color keep their existing names and output. INFO is blue, WARN yellow, ERROR red; unknown levels retain LOG with the existing bold-only colored form. NO_COLOR still wins over forced color, normal messages use stdout, warnings use stderr and errors exit 1. The prefix/stream fixtures and ERR-trap suite run without a terminal; actual terminal rendering is outside their coverage.

Shared cross-Python path lookup#

The cross-Python library shares library-directory suffix lookup, scoped Python/triplet/root context and pkg-config filename composition. The staged prefix precedes system locations, root arguments retain their order, a failed version probe stops later lookups and embed metadata keeps its own suffix. Path-context assignments stay in caller-owned locals. The local path fixtures also run against the previous implementation and cover candidate ordering, forwarding, missing metadata and resolver failures. They do not execute a target interpreter or establish target ABI compatibility.

Windows test fixture companions#

WindowsArchGate.Fixture.psm1 shares architecture-suite binary constructors, runtime-tree setup and child-gate verdicts. Valid PE samples use the existing harness constructor; malformed headers and COFF/archive members retain their boundary bytes. Child exit-code and diagnostic checks remain mandatory, with a mutation that rejects a fabricated successful exit code.

WindowsUv.ChainFixtures.psm1 shares command/log observers and replacement assertions. Recording occurs before caller-owned rejection; each invocation keeps independent state. OpenCV and ORT keep their own environment and error handling, exact command expectations and positive/negative pattern checks. The fixture’s dropped-recorder mutation must fail its command-count verdict. Both companions live beside their suites and must accompany copied suites; they are test helpers, not new image dependencies.

Wheel requirement fixtures use New-TestWheel rather than private ZIP writers. A Requires-Dist-looking body line proves parsing stops at the header boundary; a local mutant that reads the body is rejected. These fixtures do not run uv, target binaries or target interpreters. Existing platform-dependent skips and failures remain visible in the focused suite results.

Shared foreign-target guard#

The libstdc++ linker repair and runtime pinning entry points share a pure nonempty-target-versus-build-architecture predicate. They retain raw target spelling, the existing amd64 fallback after a failed build-architecture probe and their distinct triplet policies. Default target resolution remains at the original unconditional call sites, preserving errexit on resolution failures. The guard fixtures stub all link operations and do not modify system libraries. The path and guard suites share module selection, scratch setup and cleanup in tests/cross-toolchain-fixture.sh, which must accompany those test scripts.

The artifact suite shares copy/recursion and invalid-pkgconfig fixtures while retaining each negative condition. Its forced-recursion mutant must fail the omitted-switch case. These are local test fixtures, not new build dependencies.

Wheelhouse and media compiler preparation#

Torch wheelhouse builds share source preparation and wheel collection while retaining component clone flags, host-install order and C-extension repair before retagging. Sysconfig, repair, retagging and copy failures propagate through the conditional orchestration; failed preparation cannot report success. Local fake builders cover these paths without downloading or building dependencies.

GStreamer build paths share missing cross-compiler initialization through the existing media core companion. The stage build retains its additional libstdc++ repair, legacy SDK fallback and runtime pinning in their original order. Fixtures stub compiler and linker operations; they do not change system libraries.

Windows formatting and source-build fixtures#

Formatting shares tracked-file filtering and clang-format lookup. C/C++ keeps its sorted, deduplicated Git results and filesystem fallback. Dart remains tracked-only with its own exclusions and preserves Git order and duplicates. Both formatting modes prefer PATH, then the two common LLVM installation locations. Missing-tool rewrite errors identify clang-format instead of an uninitialized local variable; check mode retains its advisory and mandatory policies.

WindowsSourceBuild.RetryFixtures.psm1 owns retry fixture environment, temporary logs and cleanup. Ninja and Git retain distinct retry policies and identical fake tool programs. WindowsMedia.WiringFixture.psm1 shares FFmpeg listing and OpenCV AST wiring assertions. These companions stay beside copied suites; they add no image dependency. Local mutation proofs reject dropped attempts, nested-function matches and nonfatal finding guards. Windows-specific execution failures remain visible on Linux hosts.

The CUDA cache diagnostic delegates context-directory creation to the existing Resolve-DirectoryPath helper. Its random temporary prefix and cleanup stay at the call site. Local path fixtures cover creation and reuse with payloads; they do not start BuildKit, access a remote cache or compile CUDA.

Python application requirement hashing groups each requirement with its following hash lines. Only matching hashed groups gain the built wheel hash; other lines, repeated groups and continuation bytes retain their order. A local lost-final-group mutation guards against silently omitting the final requirement.

Repository refresh and Linux parser fixtures#

downloads.sh owns the best-effort shallow fetch used by the generic repository helper and TVM: try the requested ref, then tags, tolerating failure of both. Checkout policy stays with each caller. The generic helper still tolerates a failed checkout and reports stale or missing HEAD; TVM still requires checkout success before refreshing submodules. TVM receives this helper through its existing common.sh/downloads.sh companions. Local fake-Git fixtures verify fetch order and checkout policy against both implementations without a network.

The orchestrator and runtime CLI parsers share named-option assignment through caller-specific destination maps. Aliases, raw empty and option-shaped values, consumed-argument counts and common flag precedence retain their policies. Their public interfaces and nameref targets remain unchanged. Parser fixtures exercise every mapped option, help, positional inputs and dispatcher errors.

Compiler validation shares target-native GCC/LLVM ELF fallback checks and the compiler target-failure verdict. Mandatory failures still exit immediately; advisory failures retain their aggregation and diagnostics. Local fixtures compare baseline and refactor outputs without executing target compilers.

Parallel-loop fixtures share child-shell setup while retaining the strict caller-return scenario and separate fail-fast and keep-going expectations. They still invoke the actual loop library; mutations that omit it or invert its fixture predicate must fail. These tests launch only local stub workers.

Shared object smoke lifecycle and ONNX probing#

Android NDK and generic compiler object probes share temporary-directory allocation, compilation, verification dispatch and cleanup in smoke-common.sh. Each caller retains its original C program, artifact name, ELF policy and messages. NDK rejects an empty architecture mapping; the generic probe retains its readelf/file-presence guards. Failed or invalid temporary allocation never invokes the compiler, and failed cleanup cannot report success. The existing smoke companion must accompany both entry points; no new runtime companion is introduced. Fake-compiler fixtures exercise successful and failed compilation, wrong or unreadable ELF metadata, verifier failures and cleanup errors without running SDK compilers or target binaries.

The media smoke shares native-import versus cross-library probing for ONNX modules. ONNX Runtime remains required and checks the CPU execution provider; GenAI remains optional. Cross probes never import target modules. Native library fallbacks keep their deferred-runtime diagnostic and original search roots.

Argument-consistency checks share declaration traversal and fatal reporting. Callbacks retain the distinct forwarding, default-drift and defaultless policies, per-file deduplication, Android exemptions and aggregate counts. Expanded fixtures run against both the original and refactored checker; mutations guard callbacks, counting and fatal exits. These are source checks, not container-build proofs.

Disk-guard and Renovate-audit fixtures share cache setup, audit command capture and rollback verdicts. Independent sizes, modification times, JSON errors and failure inputs remain explicit. The fixtures perform no real cache pruning, registry access or build-daemon operations.

Host architecture resolution and shared quality probes#

platform.sh shares host probing after the caller selects its preferred raw architecture. Target resolution retains explicit argument then TARGETARCH; build resolution retains BUILDARCH then the final BUILDPLATFORM component. Only an empty selection probes dpkg, then uname. Partial output from failed dpkg, empty successful uname output and the failed-uname unknown fallback retain their behavior. The target Python version helper delegates its shared pin and host-probe fallback to the existing host-version owner after its target override. LLVM builder discovery uses one ordered candidate loop and still prefers the sibling builder over the installed container path, including non-executable regular files. Local fixtures check probe order, status and baseline behavior. No new companion is introduced for these helpers.

C++ quality and tidy file discovery share extension predicates and filesystem traversal while retaining distinct configuration defaults, multi-root inputs, exclusions and caller-array ownership. Compiler-cache tests share their fixture bootstrap while retaining launcher selection and server-address assertions.

Runtime consumer and shipped-content probes share their shell transport and scalar container configuration lookup. Tests compare generated shell wrappers and payload environment bytes, including empty-Python guards and caller-owned sentinel verdicts. Consumer metadata checks keep required entrypoint failures separate from advisory working-directory differences. Config verdicts also share volume handling; only the volume check treats NONE as absent, while a literal NONE working directory remains an advertised value.

Critical-fix source checks share compound predicates and record parsing while retaining independent patterns, diagnostics and fatal/advisory policies. Existing mutation IDs are retargeted to their shared owners when the protected behavior moves, so extraction cannot silently retire a regression proof.

Toolchain companion and web-smoke probes#

Toolchain common, build-helper and ELF-strip loading share candidate construction and source lifecycle. Common loading keeps its mounted-core preference; the build-helper and ELF-strip paths keep repository-core preference after an adjacent companion. The shared source call stays unconditional so ordinary errexit remains effective. Existing conditional callers retain their prior source-status policy, and missing ELF fallback remains fatal. Local fixtures exercise precedence, missing companions and source failure without building.

Flutter integration smokes share HTTP-200 verdicts and download-size probing. Callers retain their exact success and failure messages. JavaScript and bootstrap sizes remain strictly greater than their distinct thresholds; a failed download retains curl’s exit code even when it emits a plausible size. Existing HTTP probes keep their guarded curl behavior. Fixture sites cover size boundaries, missing assets, CSP, local engine and fallback fonts without HTTP access.

01-core/module-bootstrap.sh owns framework initialization and required-symbol loading. Base and setup-dependencies keep their distinct module candidate lists; media validation and Torch setup retain their ordered platform candidates and fail if the required symbol is still absent. Source calls remain unconditional so selected-module and framework initialization failures retain the caller’s normal errexit behavior, including existing conditional-call semantics.

The companion is a separate read-only bind mount in all six base RUNs and both setup-dependencies toolchain RUNs. SDK’s explicit core COPY and Torch’s explicit core COPY carry it into later stages. No whole-core mount replaces these narrow inputs. Fixtures validate candidate order, selected-source failures, missing symbols and each required Dockerfile closure without apt operations or builds.

Native ONNX builds and cross-verification targets#

Native CPU and AMD ONNX Runtime builds share invocation failure handling and wheel collection through their existing build/lib/common.sh companion. CPU keeps its retry count and delay; AMD keeps its direct invocation. Cross-build verbose diagnostics remain advisory, while the failed original build remains fatal. Native-only missing-wheel fallback, labels, output directories, header and provenance order and final free-threaded work retain their policies. Fresh child-shell fixtures exercise collection failures under ordinary errexit without invoking a real compiler or fetching packages.

platform.sh shares cross-verification target selection and normalization. An available resolver wins even when it returns an empty list. Without that resolver, the tool-version and LLVM wrappers keep their distinct legacy fallbacks. Resolver errors retain ordinary errexit; normalization failure keeps the existing quiet versus logged skip policies. The tool-version wrapper still restores its architecture variables, while LLVM retains its dispatcher contract. Fixtures compare both original wrappers and the shared implementation with a nondefault IFS, aliases, missing/empty targets and failed resolver/callback paths.

LiteRT web vendoring shares repeated asset handling without changing pinned inputs or payload layout. Lint consumer fixtures share repository creation and vendored file construction; tests prove those files exist before checking that a gate excludes them. They use cached lint tools and perform no network work.

GCC release assets share bounded wget invocation while retaining per-asset retry counts, timeouts, additional flags, argument order and failure status. GCC and Clang share compiler-cache help rendering and unknown-option rejection through their already-required toolchain bootstrap. Each builder retains its help spacing, cache options and remaining parser behavior. Offline argv and byte comparisons exercise the original and refactored builders without downloading or compiling.

Cache policy, packaging inventory and media dispatch#

01-core/compiler-cache-utils.sh owns disabled-flag recognition and launcher statistics without installing environment defaults or starting cache servers. Cache modules require this companion; GCC resolves it through the existing bootstrap. GCC and LLVM retain separate read-only mounts in the toolchain stage, and the media stage explicitly copies it beside the CMake cache helper. Existing whole-core copies already carry it. Launcher arguments, selected statistics, output streams and best-effort failure handling retain each caller’s policy.

06-packaging/media-payloads.sh owns the ordered optional payload inventory. The copier processes all fourteen entries; the validator observes only the five marked for advisory checks. Paths remain relative to the caller’s source prefix, and GPU payload order and missing-payload behavior remain unchanged. Package’s artifact-source validator mounts the companion beside its script. The temporary copier copies and removes both files; the final validator carries the companion under /opt/scripts/packaging. Each closure is checked without building images.

The GStreamer Android recipe wrapper uses android_apply_patch after its existing recipe guards. Mounted core scripts retain precedence; repository lookup uses the caller’s source directory. Fixtures cover paths containing spaces, both layouts, skipped recipes and failed patch status without applying real patches. Arm NN and OpenCV share optional install stripping through media common. Older SDKs without the strip callback still skip it quietly; callback failures remain advisory. Tests use stubs and never strip installed libraries.

Lifecycle fixtures use production truthiness behavior instead of copied boolean tables. They track and reap their own children on exit. Offline fixtures and mutation checks cover these dispatch contracts; they do not prove compiler, container build, registry or real filesystem installation behavior.

Provenance verdicts and verification fixtures#

ORT and GenAI verification share hashing and indexed chain-byte comparison in 03-media/ort-provenance.sh, which GenAI already sources. Each scan keeps its own archive rules, exemptions, counters and diagnostic suffixes. Multiple valid chain files with the same name remain acceptable; missing or unreadable files retain their previous findings. Offline fixtures exercise byte identity and failure cases without downloading models or building ONNX Runtime.

The two verifiers also share FetchContent directory-name expressions for onnxruntime-src, onnxruntime-subbuild and onnxruntime-build. Each caller retains its own ortlib patterns, traversal scope, link handling and pruning.

TVM wheel fixtures share fake-builder invocation while retaining successful, failed and missing-pipefail paths, captured stderr and log assertions. Ancestry fixtures share requested-stamp execution while distinguishing missing labels, unreadable images and requests without a run id. No registry is contacted.

The Ubuntu mirror verifier shares error emission and aggregate accounting. Every Dockerfile, bootstrap order, scheme and suite probe still runs, and any failed probe keeps the verifier red. These source checks do not test remote mirror availability or perform package installation.

Artifact collection and paired probes#

The WASM build worker shares artifact collection across its build passes. Required build failures remain fatal; optional passes and artifact copies retain their existing best-effort policies. IREE Android shares its runtime configuration profile while keeping host and target toolchain and driver options in their original argument positions. Offline fixtures use stubbed tools; they do not compile SDKs or validate produced WebAssembly binaries. Their shared linux/scripts/tests/script-stage-fixture.sh owns source selection and workspace cleanup.

Ubuntu mirror callers share source-file enumeration through their existing ubuntu-mirror.sh companion. The original file ordering and shell option state remain observable. Fixtures exercise source layouts without running apt or contacting a mirror.

Media artifact checks share the nonempty-file verdict while retaining their distinct file and symlink admission rules and failure accounting. Image parity checks share paired probe execution. Version comparison still uses first-line output and its existing status policy; import checks preserve full output and per-image failures. Empty version output cannot pass vacuously. Stubbed probes characterize these contracts without starting containers.

Renovate collateral fixtures share the original-byte and clean-index checks for staged deletions and modifications. Logging fixtures share severity, status and unbound-variable verdicts; child scripts still exercise distinct trap lifetimes. Module shadowing fixtures share production module loading while preserving each assertion. Ownership fixtures share failed-chown setup while retaining distinct root and non-root verdicts. Their mutation proofs cover dispatch and failure detection; they do not perform dependency updates or real compiler builds.

Version-bump fixtures reuse their existing offline Python importer and forward fixture arguments into fresh interpreters. Tag fixtures retain their exact fake upstream candidates. GenAI binding fixtures share healthy defaults while passing per-case overrides last; deliberately unpinned cases keep explicit unset behavior. Provenance and lint fixtures retain their separate checks while sharing setup.

t_emit_optional_functions in the Linux harness serializes present functions in argument order and skips absent names. Worker fixtures use it only for optional helpers; required definitions remain mandatory. Focused tests check missing names, usable emitted bodies and exit status. This test API performs no source parsing or container execution.

CLI arguments, core probes and workflow fixtures#

lib/cli-value-options.sh owns append_cli_nonempty_args. Code-quality and coverage callers retain argument order, duplicate values and whitespace inside arguments. Empty values remain omitted; gcovr excludes keep their per-value prefix. Copied libraries carry this companion alongside their existing logging and tool-check dependencies. The CMake-format fixture explicitly copies it; repository and submodule consumers already resolve the complete library tree.

01-core/lint-root.sh shares scope initialization and root publication without adding an environment export. Linter-specific options and pinned-tool handling remain in each driver. ShellCheck fatal reports share diagnostic replay while retaining distinct flags and headings and the original exit status.

The shell, Python and Dockerfile drivers source 01-core/lint-scope-init.sh in their own shell. It loads the root parser, publishes the selected tree and replaces positional arguments with the unconsumed arguments. Keep this initializer beside lint-root.sh when copying a driver. A function call would isolate set -- from the driver. Empty arguments, line breaks, repeated root options and rejected roots have frozen original receipts; linter execution has separate driver tests. The ShellCheck root-contract test copies a small hub separately from its consumer fixture so ignoring --root reaches the same assertions without scanning the entire repository. The live-tree warning check remains separate.

01-core/common.sh owns wheel_archive_run for quiet wheel unpack and pack commands, including multiword Python launchers and their raw status. LiteRT renaming and runtime stripping retain their own payload edits, verdicts and temporary cleanup. Repacking still regenerates RECORD through the wheel tool.

02-toolchain/packaging-deps.sh shares command execution and status capture between packaging steps and sudo retries. Separate failure handlers retain best-effort warnings, root refusal and the original sudo arguments and status. Offline fixtures cover the current user’s branch; they do not change privilege or run package installation.

Wheel platform resolution shares canonical-helper precedence while preserving LiteRT’s required target lookup and Torch’s best-effort fallback. GStreamer shares foreign-target selection through its existing media owner. Keep each original lookup separate. Remove scratch state before the selected action so a failed lookup retains its status.

Compiler validation shares GCC version capture and source-fixture transport. Source writers and probes remain unconditional, with caller-specific source bytes, compiler arguments, link checks and diagnostics. Dynamic temporary-directory and sanitizer state keep their original scope; cleanup retains its failure behavior.

ORT provenance shares component-name exclusions and filename candidate predicates. Tree scans include .tar.lzma2 archives; build-record scans stay at depth one and omit that extra suffix. The concatenated GenAI spelling remains an archive-only exclusion. Partial traversal findings and advisory failure diagnostics remain. Stream fixtures share workspace and optional receipt initialization while keeping each suite’s expected outputs independent.

Rootless binfmt setup shares requested-architecture CSV parsing in its existing script. Extraction, registration and verification retain separate unknown-target and status policies. Array scope, IFS behavior and the literal namespace command remain unchanged; offline tests never enter a real namespace.

The existing platform owner shares best-effort Debian triplet queries. Optional mapper failures keep their stdout and suppress stderr and failure status, while compiler and GStreamer callers retain their defaults and directory choices. An unavailable canonical query helper fails before caller fallbacks can hide it.

01-core/verified-script-install.sh owns curl, optional checksum verification, shell execution and final cleanup for UV and Rust installers. Callers retain temporary-file allocation, pin lookup and mismatch callbacks, including their different diagnostics and cleanup order. Copy this functions-only companion beside python_uv.sh; Rust’s Toolchain RUN binds the same fresh file. Cold import tests reject absent, incomplete and failing companions and verify UV retry after restoration. Lifecycle tests use fake download and shell commands. uv_ensure_installed runs the UV_VERSION release’s installer, not the moving astral.sh/uv/install.sh, and fails when no pin resolves or another version results.

The standalone nerdctl installer owns binfmt_handler_enabled, shared with the runtime manifest verifier. Its --source-binfmt-probe entry returns before shell options, global initialization or setup actions. The verifier first requires the exact # ANT_BINFMT_PROBE_SOURCE_API=1 marker, then checks source status and the exported function. Older installers ignore unknown arguments, so checking the function only after sourcing would be unsafe. Copied manifest checkouts carry the fresh owner at linux/host-config/install-nerdctl-full.sh. Caller-specific tool lookup timing, overrides, warnings and fatal aggregation remain separate.

Optional Meson cross/native flag providers share ordered dispatch in the existing core owner. GStreamer retains its cross-file edit callback between those providers; libcamera has no extra callback. Keep selected calls unconditional so strict-shell failures remain active. Each caller keeps its array, diagnostics and final status.

Clang’s CLI job input and both job-selection branches share the same numeric predicate. Empty values retain short-circuit match state, zero and leading zeros remain accepted, and unguarded override access still reports unset values.

Fleet dependency insertion, transitive closure and mutual-cycle detection share literal token membership. Keep both word boundaries and quoted identities; wildcards in an identity remain data. The layer-order test’s independent source oracle stays separate. Tiny graph fixtures retain original byte receipts and explicit cycle, closure and convergence assertions without running Git or Renovate.

Core helpers share nondefault-host suffix formatting and caller-directory resolution while preserving explicit path bytes. Disk validation keeps positive settings distinct from nonnegative free-space readings: zero-disabled settings do not probe or start a watcher. Stage publication retains built-map, pin and parallel-marker ordering. These helpers stay in existing mounted/copied owners; no new runtime companion or broader mount is required.

Lane fixtures share YAML loading and query execution while preserving lane fields, relative paths for Windows Python and the Linux multiword interpreter contract. Mutation fixtures keep their ignore and skip scenarios independent. Workflow fixtures share document and job construction while preserving malformed YAML and line-sensitive findings. Flatpak failure fixtures forward every per-case tool and payload override. Offline characterization and mutation proofs validate these contracts without starting container engines, builds, pruning or disk watchers.

Fetch and runtime validation lifecycles#

ONNX fetch uses a private clone-if-missing helper in 20-fetch.sh. Both checkouts keep shallow branch cloning with three attempts and ten-second retry spacing. ORT retains retried submodule commands; GenAI retains one-shot commands and its existing-directory message. Every cwd change and requirements/emsdk step remains caller-owned. Frozen offline receipts compare command boundaries, output and failures; they do not execute Git, downloads or SDK setup.

validate-media-runtime.sh shares complete-line unresolved-library collection and counted summary rendering. Binary scans still accept dangling symlinks while plugin scans select regular *.so paths and live links. Empty records are skipped; duplicates, whitespace and partial output before resolver failure are retained. The resolver’s failure remains advisory. Repair advice, source-built denial counters and final fatal gates stay in their original callers.

runtime-consumer-contract.sh owns the ordered required-fact guard used by appimagetool, JDK and Android verdicts. It uses the original first-match fact reader and preserves exact values. Callers retain their diagnostic priority and failure status; Android retains its environment reads but skips platform-tools and PATH fact checks after an explicit payload-off marker. The helper already travels with the smoke script; no new production companion or image closure is required.

Runtime and SDK help share row descriptions and padding in runtime-build-fns.sh. Callers retain row order, description columns, wrapping and profile-specific wording. Complete output receipts cover both runtime entrypoints and SDK help. The environment contract renders runtime help before checking its names against runtime consumers; documentation functions and SDK-only references cannot make a dead runtime override appear live.

Torch venv setup shares best-effort missing-marker writes inside setup-torch-venv.sh; cache-aware apt-list cleanup lives in package-image-wiring.sh and is also called by package setup. Copied Torch setup requires that companion before its first execution, including the early selective image COPY. Marker reasons, neutral-cwd imports, OpenCV fallback, package choices and warning/fatal policies remain local. Offline receipts cover failed marker operations and mount probes without running apt or installing packages.

The Python payload emitted by smoke-common.sh uses one exception recorder for native Tensor and generation failures. Existing operation labels, exception names, str formatting and final defect counts remain unchanged; the recorder does not invoke custom exception formatting methods.

Containment, image arguments and runtime enumeration#

01-core/path-helpers.sh owns the lexical root predicate used by ORT provenance and GStreamer’s ORT checks. GStreamer retains roots verbatim; provenance trims exactly one trailing slash before ignoring an empty root. Neither policy resolves symlinks or dot components. Copied callers require the existing helper in their relative 01-core layout. Five media recipes mount those same canonical bytes at the matching installed path; cache IDs and the stage graph stay unchanged.

image-ref-args.sh binds the optional container CLI and image reference for build-helpers.sh and digest-pinning.sh. One argument uses NERDCTL_BIN or nerdctl; multiple arguments retain the explicit first two values and ignore extras. The callers retain their own inspect/registry work, errors and shell failure contexts. No new argument validation changes their existing zero-argument behavior. Both compiler recipes and isolated copied bundles carry the mandatory pure companion.

FFmpeg’s SDK bundler and apt manifest share their existing bin-then-lib runtime file enumeration. It keeps depth limits, regular-file selection and suppressed find diagnostics. The bundler retains advisory process-substitution failures; the manifest retains its pipeline status. Independent byte receipts cover both producers failing under direct/conditional and strict/relaxed shell contexts.

The runtime help pages also share the three common build-stage descriptions and options/footer/environment rendering. Caller heredocs retain their own text and literal values; the independent full-help receipts verify the original byte order.

Cross-chain and cross-compiler help use the common repository-description row with their original columns. Their --cross-targets callbacks share raw assignment and argument consumption through orchestrator_set_cross_targets; compiler targets remain distinct from the chain’s per-stage architecture list. Independent fixtures exercise empty values, commas, spaces, literal shell text and newlines inside caller-local variables. Complete help receipts also cover both cross entrypoints.

Runtime selectors, compiler tools and wheel manifests#

orchestrator_consume_runtime_push_arg owns the shared runtime push selectors. Each entrypoint keeps its accepted flag set and unique options. The helper keeps assignment order and argument consumption; untouched fields remain unset or keep the caller’s existing value. Gates-only handling stays in the manifest caller.

compiler_tool_enabled probes availability before checking its explicit tool policy and retains suppressed lookup output and original lookup status. FFmpeg and ORT retain the historical off spellings 0, false, FALSE, no, NO, off, OFF; their False input still enables the optional tool. Other cache readers retain their established default handling, including False as disabled.

wheelhouse-manifest.sh owns sorted, null-safe regular-file discovery and binary hash-separator normalization. The host library retains strict failure behavior; Torch diagnostics retain their best-effort behavior and separate count/log policy. Both imports require the canonical companion; Torch’s early image COPY carries it. An independent three-file golden checks complete manifest bytes and hashes, beside original/current failure receipts and the existing host/image agreement check.

Native GCC system paths and test dependencies#

01-core/native-gcc-system-paths.sh owns the system include and library exports used by Torch setup and the native GCC shell profile. Torch retains directory discovery. The generated profile imports the same helper when sourced, so flags set after image construction still precede the appended paths. Repeated sourcing, empty values and the existing _idaf side effect retain their original behavior. Android and Torch copy the helper before use; the package image’s full core copy also includes it. Independent environment receipts cover both callers.

The FFmpeg TensorFlow fixture reads the canonical is_truthy function instead of maintaining its own implementation. Its expected flags and default-off assertions remain independent. Chain lifecycle fixtures share process cleanup and archive construction, while retaining explicit assertions for leaf termination, retained and removed run IDs, symlinks and foreign files. Cleanup tracks fixture processes without relying on the production subtree terminator under test.

Cross-chain verification help#

Cross-chain and verification-wrapper help share architecture rows through runtime_usage_chain_arches and the repository row through runtime_usage_row. The chain profile preserves the original arch-list wording and column widths. The verification wrapper loads the function-only renderer inside usage; normal forwarding does not depend on it or initialize build helpers. Its independent receipts cover full help bytes, a missing renderer, empty and multiline forwarded arguments, describe mode and the child process’s nonzero exit status.

Optional linkers, installer services and cache removal#

FFmpeg and ORT use the optional-tool predicate’s explicit literal-false policy for LLD: only false disables it. Values such as 0, FALSE, no and off retain their historical enabled behavior. Lookup still precedes the policy check; lookup failure keeps its original status and suppresses diagnostics. Caller compiler arguments and logs remain separate. Their offline suites share fixture setup while retaining independent policy expectations and complete byte receipts.

The nerdctl installer shares its user-stack stop and rootful service actions inside the installer file. Callers retain service guards, stop/start order, logging, unit-list splitting and best-effort behavior. Offline fixtures exercise actual service sections with stubbed commands; they never execute installation or real service operations.

_disk_guard_remove_slug owns guarded, quiet removal and remaining-path evidence. The in-stage trimmer stops at an undeletable slug; the chain protects it and keeps looking. Both retain advisory removal-command failure and their original logs and counters. Unit tests cover actual filesystem outcomes and independent caller assertions, including empty-root refusal and strict-shell command failure.

Host Python path policies#

platform.sh owns host_python_path with explicit and derived profiles. Both retain the ordered executable pins from MEDIA_HOST_PYTHON, UV_PYTHON, VIRTUAL_ENV and PYTHON_MAJOR_MINOR, followed by PATH lookup. The canonical cross-Python caller retains optional PYTHON_VERSION derivation; GStreamer’s fallback does not gain it and still prefers an existing host_python_bin override. Inputs remain raw and are read when called. Each profile retains its original trailing-newline and output-failure behavior. Both imports require the existing platform companion rather than loading the broader cross environment or providing a private fallback. Independent receipts cover pin order, failed lookups, version policy, overrides, source guards and copied-companion failures.

Artifact refusal, media dispatch and standalone downloads#

tag-naming.sh owns the unsupported artifact-mode diagnostic in one private helper. Platform and image-reference callers retain their own native/cross branches and lazy access to their environment. Extracted test fixtures carry the rejection helper so invalid-mode assertions still exercise its exact status and stderr rather than an undefined-function error.

smoke_native_dispatch shares cross-target presence checking and calls the native callback unconditionally when execution is appropriate. It introduces no local variables that could shadow caller globals. FFmpeg’s shared test-pattern encoder and null decoder retain exact arguments and streams; callers retain codec policy, rate and preset choices, the H264 interstitial success message and cleanup order. Independent complete-section receipts cover tool calls, shell failure contexts, global state and temporary files without running real media tools.

source_toolchain_downloads uses only the historical repository-core and installed core candidates, in that order, and leaves a supplied download_file untouched. The shared selector’s core-paths-only mode excludes an adjacent downloads file. Both standalone callers carry bootstrap.sh beside their entrypoint; SDK and package copies refresh it and Android’s flattened layout includes it. Torch’s /usr/local/bin/vulkan.sh also carries vulkan-install.sh. The bootstrap contains function definitions and shell options; the downloads module’s actual top-level state remains global when selected. Source calls keep their original strict and conditional failure behavior, and no private download fallback is restored.

Bound CLI callbacks#

parse_cli_value_options MAP REMAINING +CALLBACK ARGS... invokes the selected callback unconditionally so the caller’s active Bash errexit policy survives. The callback receives the consumed-count variable name first, shifts that parameter, then handles the complete remaining argv and assigns its count through a nameref. It returns normally for handled flags; help and errors keep their original exit policy. Existing callback names without + retain their status-as-count interface. The host parity verifier uses the bound form; its frozen help receipts cover strict/conditional calls and usage aliases, with separate empty/spaced values.

Loaded module and isolated worker assets#

shared/rust/loaded_module.rs owns address-to-loaded-file lookup. Its exact shared asset accompanies the isolated Rust binding/tests, C source/header and HIP worker source/header. Declare consumer destinations in .antfrastructure-shared.manifest; retain the complete companion set. The consumer contract explains path and runtime evidence limits.

The C supervisor uses one monotonic-clock helper before starting a worker and for elapsed time. Clock failure preserves the original nonzero errno and otherwise returns EIO, so it cannot report success with an unset timestamp. A failure during supervision still kills and reaps its worker before returning the error. isolated-helper-compile.sh compiles both the shared C object and clock fixture with -O3 -Wall -Wextra -Werror through the measured compiler cache. It imports the canonical 01-core/common.sh, requires both cache launcher APIs, initializes the address in the compiling shell and resolves the guarded launcher before capturing each command. The ASAN C++ fixtures share this boundary with their original flags. Required import, resolver and real compiler failures retain their raw status; the required environment call also propagates its status explicitly before resolution or compilation. Clock fixture compilation still fails before linking. The launcher-policy suite canonicalizes scan roots before excluding tests and checks guarded and bare calls through a tests/.. fixture, plus missing-root refusal.

test-isolated-helper-cache.sh injects the hosted cache-internal temporary-file failure into both real C/C++ compiles. The canonical launcher retries the cache and then compiles directly; real compiler errors are not retried. Controls also check required imports/exports, parent-shell address publication and captured raw statuses. These fake cache controls do not establish real daemon health, hit performance or inference; the existing Rust/Dart and clock suites remain required.

test-isolated-helper-clock.sh injects initial and elapsed clock failures with zero or nonzero errno into real supervised child runs. It checks error values, unchanged failed output, no worker on initial failure, actual reaping after an elapsed failure and ordinary timeout cleanup. These controls do not prove HIP, package placement, consumer integration or kernel-blocked process cleanup.

Cargo native helper transport#

06-packaging/stage-cargo-native-helper.py stages one exact OUT_DIR helper using successful Cargo JSON and the selected native artifact. Copies include ort_census_probe.py; the wheel-license stager imports the same ELF identity function. The staging contract states its target, no-replace and evidence limits.

The existing Rust release driver optionally captures its workspace and final CLI calls into separate Cargo JSON streams. Both paths are cleared before shared wrapper setup; ordinary releases retain their original full workspace, explicit CLI and raw failure behavior.

Hook host diagnostics#

linux/scripts/lib/hook-host-red.sh imports its sibling log-bootstrap.sh before defining the hook diagnostic helper. Standalone sourcing therefore publishes the canonical info, warn and err functions, just as it does for other libraries. Callers copying this helper must retain the shared bootstrap and its logging owner.

The existing test-lib-modules.sh checks standalone loading, real logging and the bootstrap import. Removing that import must fail those positive checks; the dedicated removal mutation proves the regression. A failing unmutated suite invalidates a mutation result rather than proving that a mutant was caught. These source controls do not establish a successful hosted workflow, image or consumer build.

Companion files a copied helper needs#

A helper copied into an image or a consumer needs the files it sources or imports beside it. Each row names a copied helper and its companions; a missing companion must fail, never fall back.

Rule

Copied restore-consumer-archive.py carries preserve-consumer-sources.py, host_commands.py and source_ci/common.py; restore exact original shallow metadata before checkout, never synthesize new boundaries to hide missing objects. Archive restoration proves neither source authenticity nor recursive dependencies.

Copied runtime environments, shell CLI libraries and Windows launcher/uv modules carry their shared companions; do not restore private fallbacks.

Copied lint drivers carry lint-scope-init.sh and lint-root.sh; source initialization in the driver shell so remaining positional arguments survive.

Copied compiler/SDK qualifiers and OCI handoffs carry proof_subject.py and proof_commands.py; SDK profiles bind the actual invocation, complete source and compiler parent, both native shell modes and all compiler ancestor layers. Never retarget a compiler plan to represent an SDK.

Copied live configure snapshots carry their cache reader/profile, native OCI layout/seed and command companions; require a live matching process, stable before/after source and copied bytes, bounded regular files, fresh output and no source/output overlap.

Copied cache log readers/replayers/sealers carry cache_capture_profile.py; retain actual PID/start identity, existing regular-file and live inode checks, input hashes, bounded named units and explicit partial-timeout verdicts.

Copied normal SDK/GPU launchers carry normal_stage_launch.py; GPU admission requires the exact qualified SDK, rehashed native blobs and compiler ancestry, complete source proof, fresh local alias, idle host and unchanged disk floor.

Copied native OCI handoffs also carry native_oci_layout.py and native_oci_seed.py; parent-seeded context exports require these helpers beside the core layout, a fresh destination, immutable verified layer links, independent child metadata and both raw transport statuses. Hash and ancestry checks remain mandatory after sharing. New link receipts use schema 2 with device/inode, size, mode, owner and mtime checks; later links may advance ctime. Schema 1 retains its strict ctime policy. Default Media and Android handoffs carry default_handoff_profile.py and the SDK/Media launch companions; require each target’s own receipt scope, exact parent and baked cross environment.

Copied python_uv.sh bundles include verified-script-install.sh; Rust carries the same narrow installer companion.

Copied common and minimal bootstrap modules carry sudo-policy.sh; retain SDK delegation before importing the policy from its module owner.

Copied core and dependency preambles carry cross-active-fallback.sh; source it at the original registration point to retain alias binding.

Copied stage-script-closure.py carries script_closure.py and all selected/transitive profiles; bundle-aware copy-coverage probes require that same parser. The read-only declared-script reporter does not prove built images or ABI.

Copied WASM proof modules carry the build-proof/runtime modules and webgpu-factory-probe companions; copied suites carry wasm_proof_fixture.py and its independent node fixture.

Copied runtime smoke drivers carry check-ort-runtime.sh; the FT store runs the same Python gate in its installed FT environment.

Copied 35-build-migraphx-plugin-ep.sh and 37-build-tensorrt-plugin-ep.sh carry plugin-ep-exports.sh and plugin-ep-seeds.txt beside them; the media verify stage reads the export probe from the mounted ORT build directory, so keep that directory mount on the GPU RUN.

Copied MIGraphX build scripts carry both ownership patches and the core apply-patch.sh entry; a failed patch stops before the next patch or seeds.

Copied WindowsBuild.Common.psm1 and Build-TorchApp.ps1 carry WindowsSdistCompiler.Common.psm1 with its WindowsTargetArch and WindowsScripts.Shared siblings; its gate grades only what uv reports as built.

Copied Python ORT registration helpers stay exact shared assets; cache successful registrations per owning binding and preserve explicit-root precedence, retryable failures and fresh device selection. Python plugin sessions attach devices through SessionOptions without a legacy constructor provider override. Native callers share one registry per live owning API/environment, preserve its lifetime and return raw C-API failures instead of aborting wrappers.

Copied antfrastructure.sh carries renovate-git-mode.sh beside it; the hub driver imports the same canonical selector before handling a Windows-authored WSL checkout.

Copied code-quality and coverage libraries carry cli-value-options.sh; preserve empty-argument filtering, prefixing and caller argv order.

Copied app-packaging.sh carries app-packaging-license.sh and app-packaging-entrypoint.sh; both it and pe-icon-tools.sh carry log-bootstrap.sh in the shared lib layout. Package the original project license and validate declared texts in built artifacts. The standalone entrypoint selector also imports the canonical logging bootstrap.

Copied host tensor-pair drivers carry the CLI/environment helpers, both shared Python probes and the parity reader; preserve raw child status, isolated Python, both devices and every-run profile checks.

Copied stage-cargo-licenses.py carries cargo_license_tree.py; live tree selection preserves the build’s target and feature flags and records both tree and metadata scopes.

Copied WindowsPythonApp.Common.psm1 carries WindowsIcon.Common.psm1 and WindowsMsix.Common.psm1; unforced imports and re-exports keep their icon and license APIs visible.

Copied copy-media-payloads.sh carries llvm-loader-path.sh; native compiler and package publication share its source-first conf and raw write/cache failures.

Copy compiler-cache-utils.sh beside common.sh, cache modules and standalone cache probes and media-payloads.sh beside packaging copy/validation scripts; preserve narrow mounts.

Copy elf-strip.sh and image-ref-args.sh beside build-helpers.sh; digest-pinning.sh also requires image-ref-args.sh.

Copied GCC/Vulkan modules carry fresh path-helpers.sh; copied Rust version utilities carry load-versions-env.sh beside the existing core companions.

Copied ORT provenance and GStreamer ORT checks carry path-helpers.sh in their relative 01-core layout.

Copies of python_uv.sh and webdav-download.sh carry python-probe.sh; missing companions fail rather than restoring interpreter-selection copies.

Copied isolated-worker Rust bindings carry their canonical C source/header; retain descriptor closure, parent-death guards, validated worker status and normal worker exec/teardown. Initial supervisor startup uses ordinary fork for libc state repair.

Copied loaded-module Rust lookup stays an exact shared asset; retain byte paths, foreign-symbol ownership and the wrong-module refusal after relative loading and cwd changes.

Copied Torch setup carries package-image-wiring.sh, wheelhouse-manifest.sh and native-gcc-system-paths.sh before its first execution.

Copied build-app-wheelhouse.sh carries torch-source-pins.sh beside it.

Copied lib-runtime-wheels.sh carries 01-core/wheelhouse-manifest.sh.

A copied smoke-runtime-image.sh carries check-arch-isa.sh and check-intel-gpu-userspace.sh; a copied build-opencv.sh carries opencv-cpu-baseline.sh.

Copied isolated-helper-compile.sh carries lib/log-bootstrap.sh; SDK failure fixtures own their temporary download archives through the harness.

Copied package staging retirement requires the closed producer, fresh absence/mount observations, exact preview and retained archive hashes; remove only its three declared copied trees and preserve home caches, compiler targets, sources and receipts.

- Compiler-plan copies carry compiler_plan_profile.py, compiler_unique_profile.py, proof_profiles.py and native_oci_layout.py; retain original profiles and record reviewed deltas without rewriting the old reference. The explicit GNU_UNIQUE profile binds its exact source, compiler6 inputs and normal matched-hook count; copied profile suites carry their shared fixture module.

Copied ci_packaging.sh carries ci-compiler-cache.sh; cache-enabled copies need the full core layout.

Copied host proof tools carry host_commands.py; the watcher also carries preflight-status.py, and isolated preflight carries both scripts under isolated-preflight/.

Copied append-operational-memory.py carries both operational_memory modules, host_commands.py and source_ci/common.py; preserve controller refusals, exact prefix checks and exclusive backups.

Copied run-in-ci-image.sh carries the shared lib/cli-value-options.sh and logging companions; the mutation recipe contract lives in mutation_parse.py beside its runner.

Proof-workflow test copies carry proof_workflow_ft_tests.py and proof_workflow_cleanup_tests.py; preserve their selected script roots and the owning EngineFixture lifecycle.

Copied verify_mutations.py carries mutation_workspace.py beside its parse, push and shard companions, including consumer-hook fixtures; preserve normalized target paths and source-copy defaults. Hook fixtures isolate inherited per-command Git configuration.

Copied QNN configure suites carry fixtures/qnn-build-driver.sh; keep the worker in Bash scope.

Copied MIGraphX SDK/HIP checks carry native-check-common.sh, retaining caller-visible argument and compiler setup.

Shell helper invariants#

Rules for the shared shell helpers and the callers that use them. Each item is one rule.

  • Compiler smoke callbacks stay unconditional. Preserve GStreamer’s separate target lookups, temporary cleanup and raw failure statuses.

  • The hooks’ host-red helper imports the canonical logging bootstrap. Copied helpers retain it and the existing positive library-import controls.

  • Optional Cargo release JSON paths are paired, distinct regular outputs cleared before wrapper setup. Retain the whole workspace then explicit CLI, their original alias parse points, raw failures and one unfiltered invocation per stream.

  • Validate the host binfmt owner’s source API marker before sourcing its probe mode. An older installer ignores unknown arguments and could install.

  • Invoke selected Meson providers and callbacks unconditionally. Retain availability guards, order, partial flags and raw failures.

  • Callback dispatch preserves caller-visible bindings and positional context. Generic helper locals must not hide configuration used by supplied shell wrappers.

  • Host compiler wrappers retain parent-shell publication and original local slots. Optional media pinning retains caller-bound lookup and invocation.

  • Validate cross-apt’s first-line source API marker before its helper-only import. Older full imports must not overwrite provided SDK updaters.

  • Shared CLI consumers retain complete argument lists when nameref assignments can read positional parameters.

  • Bound command callbacks retain their original parse phase and source scope. Preserve caller-specific raw failure and advisory policies.

  • Ordered directory visitors retain the caller’s dir binding, append policy and unconditional selected calls.

  • Require child cleanup APIs before starting timers or watchers. Advisory cleanup signals then reaps and retains caller PID guards, reset and command status.

  • CMake consumers use Get-CmakeBuildArgs for target, configuration and parallel flags. Keep its argument order and caller-specific build verdict.

  • Fixture byte-preservation checks share Assert-FileUnchanged. Retain caller bindings and propagate operation exceptions.

  • Fixture cleanup uses Remove-TestDir with literal paths. Bracketed diagnostic prefixes must leave no temporary roots.

  • Inline source patchers share the patch API. -Quiet transfers diagnostics to the caller without relaxing required inputs or postconditions.

  • CMake/CTest library copies include project-env.sh, log-bootstrap.sh and the Vulkan leaf. SDK hooks keep precedence over explicit setup scripts.

  • Shared mirror enumeration preserves source-file order and original shell-option behavior. Artifact and image probes retain caller failure policies.

  • Minimal toolchain bootstraps carry elf-strip.sh and load-versions-env.sh. Keep the narrow GCC/LLVM mounts.

  • New required toolchain imports validate their expected export and preserve selected-file failures. Legacy file-only imports retain their caller policy.

  • Standalone Android, GCC and Vulkan entries carry bootstrap-import.sh and bootstrap.sh beside them. Vulkan also carries vulkan-install.sh, and supplied download helpers retain precedence.

  • Consumer checks running inside the family Linux image use ci_image_python_require from python-probe.sh. Retain its image marker, pinned interpreter probe and caller-specific diagnostic.

  • Runtime consumer probes retain lazy required-fact checks and distinguish missing facts from failed facts.

  • Rust plugin consumers carry the exact shared policy, preserve GetEpDevices failures and retain the owning environment during V2 calls without blocking its normal teardown.

  • Native child waits under Dart must preserve external-reaper failures. An ECHILD or a successful failure-control probe never proves worker teardown or bridge acceptance.

  • Cargo native helper staging uses the exact successful Cargo JSON artifact and build-script OUT_DIR. Copy stage-cargo-native-helper.py with ort_census_probe.py and retain target checks and no-replace publication.

  • Native transport controls execute while the bounded Dart child is live. Preserve the canonical HIP worker/fake-runtime companions, normal sanitizer teardown, its real report and the expected leak-control exit.

  • Native GCC profiles carry native-gcc-system-paths.sh. Preserve flag expansion when the profile is sourced.

  • verify-cross-chain.sh help carries runtime-build-fns.sh. Ordinary forwarding must not load build helpers.

  • Repository refresh shares best-effort fetches. Callers retain checkout failure policy. Linux parser destination maps preserve raw values and consumed-argument counts.

  • Object smokes share compile/cleanup lifecycle while retaining caller ELF policies. Allocation or cleanup failure cannot pass.

  • Host probing preserves target/build precedence and failed/empty probe behavior. Shared runtime transports retain Python guards and caller sentinel verdicts. TVM codegen skips only a missing import. Unexpected initialization errors fail the smoke.

  • Flutter browser smokes record Playwright failures and let unexpected Python errors propagate, so an implementation bug cannot report a green run.

  • Logging prefixes share severity formatting. Preserve ANSI bytes, streams and NO_COLOR precedence.

  • Standalone fallback registration keeps caller lookup policy. Copied Abseil and payload entry points carry the logging bootstrap in its documented layout.

  • Smoke ELF inspection carries its platform owner and preserves caller parser overrides without leaking platform initialization.

  • ONNX web steps share lockfile retries and JS artifact verdicts. Keep install failures fatal and check both source and copied artifacts.

  • Agentic build, test and quality phases share execution. Preserve fatal build/test results and advisory quality results.

  • Runtime and cross orchestrators share common CLI dispatch. Preserve consumed-argument counts and help code 255.

  • Critical source-pattern checks share verdict handling. Failed probes increment the aggregate and must reach the failing summary.

  • Verified downloads must propagate fetch failures even under conditional calls. A matching stale archive does not excuse a failed fetch.

  • Temporary process environments restore absent, empty and existing values after setup or callback failure. Sanitizer overrides belong to the test child.

  • Cross-bundle DLL closure uses the architecture graph. Retain first-directory precedence, machine checks, indexed API sets and system descendants.

  • ORT directory indexing preserves caller recursion, filename and unreadable-file policies. Flutter sync preserves CMake-state exclusions and robocopy verdicts.

  • Guard empty arguments before associative-array lookups. An empty positional CMake preset retains the caller-default behavior and its positional-array entry.

  • Shell fixture environment values remain individually quoted arguments, including PATH and SDK directories with spaces. Do not word-split a string of assignments.

  • Keep QNN’s frozen query receipts independent of directory enumeration while retaining raw tool status, argument boundaries and all 120 original cases.

  • A knob’s ${X:=...} default goes at the top level above its first reader. knob-order follows call order and has no allow file.

  • Parallel result collection must explicitly propagate a failed harvest, including when workers succeeded. Publish worker pins only after a successful, nonempty read. Conditional callers disable errexit throughout the helper’s body.

  • Shared Git-hook diagnostics import log-bootstrap.sh. Standalone library checks must publish the real logging API before any mutation can count.

Key shared utilities#

The helper to use for each recurring job in the build scripts, instead of a local copy.

Job

Helper

Architecture resolution

platform.sh → canonical_target_arch(), canonical_resolve_arch(). The single source of truth; never ad-hoc dpkg/uname -m.

Architecture list resolution

artifact-common.sh → resolve_arch_list(). Normalizes TARGET_ARCHES from the canonical name + aliases with fallback; use it instead of 4-level fallback chains.

Dry-run guard

build-helpers.sh → is_dry_run(), _bool_truthy(), instead of [ "${DRY_RUN:-0}" -eq 1 ].

Module loading

modules.sh → source_modules_framework(), the bootstrap for sourcing 01-core.

Media bootstrap

03-media/core/common.sh → media_common_init <script_dir>: the one entry that sources the 01-core module framework; every media build script sources it instead of copying a preamble block. (The old media_build_preamble_init alias is gone: zero callers, no definition.)

Media file selection

03-media/core/common.sh → _media_first_existing_file <caller-slot> <argc> <argv...> <candidates...>; callers keep their own source command so dynamic bindings stay visible.

CC validation

validate-compilers.sh → _validate_cc_target() (dumpmachine/ELF/cc1/link smoke).

Cross-chain tags

tag-naming.sh → cross_base_tag(), cross_compiler_tag(), cross_sdk_tag(), cross_media_tag(), cross_android_tag(), cross_stage_repo() (nvidia’s private stage package), the runtime tag functions. Never construct tags by hand.

Stage graph

stage-defs.sh → CROSS_STAGE_ORDER (base→compiler→sdk→media→android→runtime), RUNTIME_STAGE_ORDER (base→package→wrapper). Pin init: cross_stage_init_pins(). Validation: cross_stage_validate_graph(). Cross→runtime handoff: cross_stage_ensure_parent_available().

Chain verification

chain-verify.sh → verify_cross_chain_staleness(), describe_cross_chain(). Informational: it prints digests and gates nothing.

Stage ancestry (gating)

ancestry.sh → ancestry_output_annotations(), ancestry_recorded_parent(), ancestry_assert_chain(). Every pushed cross stage records the parent ref it was built FROM as the OCI manifest annotation org.kataglyphis.parent-digest; a run with --from-stage after base walks that chain and HARD-FAILS when a parent was re-pushed after the child that would be inherited. Read path: manifest-annotation.py (annotations live in the base64 Raw field of manifest inspect --verbose). Absent annotation = warn (predates the mechanism); present + mismatch = fail. Escape hatch: --no-verify-ancestry / CROSS_VERIFY_ANCESTRY=0.

Cross-stage build

cross-stage-build.sh → cross_stage_run(), cross_stage_build_and_push(), cross_stage_build_local(), cross_stage_resolve_parent_pin(), cross_stage_assemble_runtime_helper_args().

Runtime flow init

runtime-flow-common.sh → init_runtime_flow_defaults() (loaded by lib-orchestrator.sh in runtime_flow_preamble(), not sourced directly).

Retry logic

logging.sh → retry <max> <sleep> <desc> <cmd...>.

Mirror args

build-helpers.sh → append_mirror_build_args_from_env().

Version forwarding

version-forwarding.sh → append_version_build_args() (auto-discovers from versions.env).

CMake cache/linker

cmake-cache-linker.sh → append_cmake_cache_linker_args <array_ref>, sourced by 03-media/core/common.sh automatically.

Install deps preamble

cross-apt.sh → install_deps_preamble [packages...].

Media ENV reference

03-media/runtime/media-env.sh is the canonical definition of PATH/PKG_CONFIG_PATH/LD_LIBRARY_PATH/GST_PLUGIN_PATH/GI_TYPELIB_PATH; the Dockerfile.media and Dockerfile.package ENV blocks must stay in sync with it.

Media artifact verification

03-media/runtime/verify-media-artifacts.sh checks that each media build stage produced output, called from Dockerfile.media RUN steps after every library build. Stages: onnxruntime-cpu, onnxruntime-genai, onnxruntime-gpu, onnxruntime-ep-amdgpu, onnxruntime-ep-qnn, onnxruntime-ep-tensorrt, onnxruntime-pkgconfig, litert, litert-headers, opencv, opencv-core, ffmpeg, gstreamer, libcamera, armnn, app-wheels, media-inputs, sizes.

Runtime stage elements

the Dockerfile.torch final stage is canonical for the COPY of runtime scripts, WORKDIR, VOLUME, ENTRYPOINT, CMD, HEALTHCHECK, the kataglyphis user, OCI labels.

Builder functions

run_nerdctl_build() is the canonical nerdctl build wrapper (BUILDKIT_HOST support); use it instead of an ad hoc nerdctl build.