nirs4all.pipeline.dagml.host_container module
File-backed Core .n4a V1 container for Python host payloads.
This module is a thin adapter over Core’s owner-neutral container
(nirs4all_core.open_n4a_file / nirs4all_core.write_n4a_file). It contains
no ZIP code, no container parser, no numerics and no fallback to another archive
path. Core owns the layout, integrity checks and the single verified open; the
SDK only declares its own identity (owner, feature, content types) and keeps its
serializers: members are opaque host bytes, joblib models stay trusted pickles,
and nothing is deserialized implicitly.
Core imposes no content-size cap and neither does this module. The optional
memory_budget_bytes forwards the host’s optional Core working-memory admission
budget. Core refusals are ValueError and propagate unchanged.
Members keep their SDK paths. The one SDK manifest lives at
BUNDLE_MANIFEST_MEMBER. Every member is one Core artifact whose id is its
path. Core stores physical members sorted by path, so readers must use
HostContainer.namelist() (declared order) and never physical order.
- class nirs4all.pipeline.dagml.host_container.HostMember(path: str, source: bytes | Path, kind: str, content_type: str, fingerprint: str | None = None)[source]
Bases:
objectOne host payload to store; list order of members is its semantic order.
- Variables:
path (str) – Archive path, kept exactly.
source (bytes | pathlib.Path) –
bytesheld by the caller, or a regular file streamed by Core.kind (str) – Core artifact kind (
recipe,model,provenance,attachment, …).content_type (str) – Host content type id (version 1).
fingerprint (str | None) –
sha256:<hex>of the payload, computed fromsourcewhenNone. It is checked againstbytessources and Core’s final write receipt before publication, including streamedPathsources. Opening also compares it with Core’s verified inventory (is_host_manifest()).
- nirs4all.pipeline.dagml.host_container.declares_native_package(manifest: Mapping[str, Any]) bool[source]
Whether a Core-opened manifest declares the native Methods package feature.
This is a routing declaration only: Core’s
open_native_packageselects the root and entrypoint and validates the closure (an ambiguous or invalid closure is refused there).
- nirs4all.pipeline.dagml.host_container.is_host_manifest(manifest: Mapping[str, Any]) bool[source]
Classify a Core-opened V1 manifest as a host container.
The manifest must come from a container Core opened: its inventory SHA-256 values are then the verified digests, and every host artifact’s declared
sha256.raw.v1fingerprint is compared with the inventory digest of its member. A fingerprint a writer merely declared (for example for a streamedPathsource) is rejected here when it differs, never presented as verified.- Returns:
Falsewhen the manifest neither declares the host feature nor carries a host-owned artifact or entrypoint (a canonical or foreign-owner container);Truefor a valid host shape.- Raises:
ValueError – The host feature or host-owned objects are mixed with anything else, the host shape is violated, or a fingerprint is not the inventory digest of its member. No payload byte is read.
- nirs4all.pipeline.dagml.host_container.update_host_container(base: HostContainer, target: Path, *, add: Sequence[HostMember], remove_prefix: str | None = None, memory_budget_bytes: int | None = None) Path[source]
Write
baseplusaddminusremove_prefixas a new container attarget.baseis never modified; Core copies and verifies the retained members from its open handle. A member ofaddwhose path exists inbasereplaces it in place; other new members are appended in order. Members ofbaseunderremove_prefixare dropped unlessaddreplaces them.basemay be the file attarget.- Raises:
ValueError –
baseis not a host container, the result is not a valid host shape (for example its bundle was removed), or Core refuses.
- nirs4all.pipeline.dagml.host_container.write_host_container(target: Path, members: Sequence[HostMember], *, entrypoint: bool = True, memory_budget_bytes: int | None = None) Path[source]
Write a new host container and publish it atomically at
target.- Parameters:
target – Destination; an existing regular file is replaced only on success. Its parent directory must already exist.
members – Payloads in semantic (declared) order.
entrypoint – Declare
host-predictrooted at the single bundle member. A conformal-only container passesFalseand carries no bundle member.memory_budget_bytes – Optional Core working-memory budget.
- Returns:
target.- Raises:
ValueError – Invalid members or a Core refusal. A previous
targetis untouched.