Where shared dependencies live¶
Isolation is the default. Each block declares what it imports, and each block's closure is resolved on its own, so two blocks in one workflow can run incompatible versions of the same library.
It is also what makes a large shared library expensive. Twelve blocks that each
declare torch and find nothing to reuse each reach the last line of the
resolution order:
reusable-block declared requirement
-> compatible foundation component: reuse it
-> otherwise compatible admitted project-prepared component: reuse it
within block-declared authority
-> otherwise exact external solve and automatic immutable block-local
component build
Twelve external solves, twelve component builds, and twelve closures that agree on nothing except what the index happened to offer each time. Immutable bytes are still cached by digest across closures, so the disk cost collapses when the solves agree, and nothing makes them agree.
Large and shared is the case isolation handles worst, and there are two homes for it.
The foundation, for what is large and shared¶
A library many projects use belongs in the foundation, the base image every cell runs on: built into the image once, inventoried, SBOM'd, provenance-bound, signed, and admitted by digest. Every cell on that foundation has it already, and a block's requirement resolves to it on the first line of the order above, with no solve and no build.
The cost is that changing it is a foundation build: a new rootfs digest, fresh inventory, SBOM and provenance, a new signature, a control-plane policy entry for the new digest, and re-resolution of every project's foundation reference. That is the right weight for a substrate many projects share, and the wrong weight for one project that needs one more package.
runtime.xratu, for changing the shared set without a rebuild¶
runtime.xratu amends what a project's cells get, leaving foundation_digest
untouched.
apt adds system libraries and executables to every closure in the project. The
project's system requirements are injected into each block's closure resolution
whether or not the block names them, so no block declares libmagic1.
requirements prepares Python components. The solve happens once at project
scope and pins one version, and every block whose constraint that version
satisfies reuses it by reaching the second line of the order instead of the
third.
The two lists behave differently¶
apt reaches a block without the block asking. requirements never does: a
prepared component is a candidate, and a block that did not declare a compatible
requirement receives UndeclaredDependency.
A native library is ABI-level. libmagic1 exposes symbols and carries no
program semantics a block could be coupled to, so thirty blocks holding one
version of it constrains none of them, and it can be injected into every closure
without asking each block first.
A Python distribution version is program semantics. torch==2.4 and
torch==2.6 behave differently, so a block that read its version from a shared
project file would change behaviour when another team edited that file.
Take the twelfth embedding block: it needs torch>=2.6 for a new operator.
Eleven blocks keep declaring torch>=2.4,<3 and select the prepared component
at 2.4.1. The twelfth declares torch>=2.6, finds the prepared component does
not satisfy it, and resolves its own 2.6.0 into its own closure. Each block runs
the version it asked for and no other block's behaviour moves. See
Version coexistence.
Had the version been inherited from runtime.xratu, that one block's need would
have forced a project-wide bump, and eleven blocks would have silently changed
the library they run against.
What project scope costs¶
The apt injection is unconditional, so every closure in the project carries
every project-wide system requirement, including blocks that never use it. A
block-scoped @xratu(apt=[...]) reaches only the blocks that declare it. A
block that declares a package the project also declared keeps its own
block-scoped binding rather than being reclassified.
Choosing¶
A library many projects on this substrate need belongs in the foundation's exported baseline, and putting it there is a foundation build.
A library or package this project's blocks share belongs in runtime.xratu,
which changes no foundation: apt for system libraries, requirements for
Python components several blocks should converge on.
Anything one block needs belongs in that block's @xratu, which keeps it out of
every other closure.
Related: Three declaration scopes covers the reach of each scope, and Changing shared dependencies covers which one to edit for a given change.