Skip to content

Native loader view

The native loader view lists the native libraries and executables one cell can load. It names each library directory and executable directory the loader may search, every shared library expected by SONAME with its digest, and the libraries allowed to preload. The resolver builds it from the closure, and the closure binds its digest.

A native extension in a Python package, such as a compiled NumPy or Torch module, loads its shared libraries through this view. The Python import view and the loader view are separate documents with separate digests, and the closure binds both.

The fields

Field Holds
selected_library_roots Library directories the loader searches: a source digest, a relative path, and a root_scope
executable_roots Executable directories, in the same shape
expected_libraries Each shared library the cell may load: soname, library_digest, and the source_digest it comes from
permitted_preloads SONAMEs allowed to preload, each one also in expected_libraries
loader_cache_digest The sealed loader cache for this view
foundation_digest, capsule_digest The foundation and capsule the view was built for
native_loader_view_digest Every field above

Each expected library names a source that has a selected library or executable root. Each SONAME appears once. A root's source is the foundation rootfs, the capsule, the provider, or a component the closure selected; any other source is refused when the closure is admitted:

selected_library_roots[2] source is outside the resolved runtime closure

Where the loader looks

The loader's search set is exactly the roots in the view. The provider launches with that search set through the sealed library layout, the loader cache, the cell's mounts, or an explicitly constructed launch environment. The search set comes from the view alone; host library paths and an inherited LD_LIBRARY_PATH sit outside it.

The view refuses the fields that would widen it:

NativeLoaderViewV1 refuses ld_library_path; the loader sees only the sealed closure

host_library_roots and system_library_fallback are refused the same way.

Example

A project whose runtime.xratu declares sqlite3, on a foundation that exports libmagic1 in its baseline, gives each cell this loader view (digests shortened):

{
  "contract_version": "xck.native_loader_view.v1",
  "foundation_digest": "sha256:2011…",
  "capsule_digest": "sha256:9999…",
  "selected_library_roots": [
    {"source_digest": "sha256:bbbb…", "relative_path": "lib", "root_scope": "system_baseline"},
    {"source_digest": "sha256:e1e1…", "relative_path": "lib", "root_scope": "project_wide"}
  ],
  "executable_roots": [
    {"source_digest": "sha256:e1e1…", "relative_path": "bin", "root_scope": "project_wide"}
  ],
  "expected_libraries": [
    {"soname": "libc.so.6", "library_digest": "sha256:2222…", "source_digest": "sha256:bbbb…"},
    {"soname": "libmagic.so.1", "library_digest": "sha256:a2a2…", "source_digest": "sha256:bbbb…"},
    {"soname": "libsqlite3.so.0", "library_digest": "sha256:e3e3…", "source_digest": "sha256:e1e1…"}
  ],
  "permitted_preloads": [],
  "loader_cache_digest": "sha256:e192…",
  "native_loader_view_digest": "sha256:8ae2…"
}

libc.so.6 and libmagic.so.1 come from the foundation rootfs under system_baseline. libsqlite3.so.0 and the sqlite3 executable come from the project-wide component that runtime.xratu added, under project_wide.

Native conflicts

Two blocks that need incompatible builds of one native library get two closures, each with its own loader view, and run in separate cells. Within one closure, a native, ABI, SONAME or driver conflict refuses the closure or produces a separately selected one. The library a cell loads is decided by its view, and is the same whatever order libraries load in.

The resolver checks each candidate's native objects against the foundation's before selecting it. A candidate that fails is recorded as incompatible with one of these reasons:

Reason Condition
process_global_soname_conflict The candidate ships a SONAME the foundation also provides, with different bytes
foundation_native_closure_broken_by_override Replacing a foundation bundle would leave another foundation library without a SONAME it needs
soname_closure_incomplete A SONAME the candidate requires is available from neither the candidate nor the foundation
preload_outside_native_closure The candidate permits a preload that is outside the available SONAMEs

A block-scoped system override replaces the competing baseline bundle in that block's closure only. The foundation and every sibling closure keep the baseline bundle. See Dependency declaration.

Related: Cell environment view and Mount scopes and root scopes, which covers the root_scope labels.