Skip to main content

Module ingest

Module ingest 

Source
Available on crate feature raster only.
Expand description

Attribute contract + typed ingest errors for real-Hypergraph topology ingest (Phase I, Task 1). This module doc is the canonical, normative home of the attribute contract; plans/phase-I-topology-ingest.md is its rationale, not its spec.

ATTR_CONTRACT_VERSION is bumped whenever a key’s meaning, default, or error disposition changes — never for adding a new optional key (D-I3).

§Node attrs (one node per agent)

Contract fieldDefault keyTypeMissing ⇒Rationale
identity(the node id itself)Stringn/aThe Hypergraph node id is the agent identity (D7 stringly-typed boundary). Never read from attrs.
wealth"wealth"finite f64IngestError::MissingNodeAttrFeeds agent_tension and psa. No honest default exists.
subsistence"subsistence"finite f64IngestError::MissingNodeAttrSame.
bloc"bloc"u8 in 0..=2DEFAULT_BLOCBloc selects a marker colour and the periphery filter. 1 is the neutral unclassified middle bloc. With ≥2 communities, at least one node must carry bloc == PERIPHERY_BLOC (2) or ingest errors.
tension"tension"finite f64 ≥ 0absent ⇒ deriveOptional override. When present, used verbatim as the terrain’s per-agent scalar (via a subsistence inversion); when absent the frozen agent_tension(a, repression) formula applies. Recorded in IngestReport::tension_source.
h3_cell"h3_cell"u64 or decimal Stringabsent ⇒ NoneOptional, carried not consumed. Stored in IngestReport::h3_cells; no instrument reads it. A decimal string is accepted because JSON numbers lose precision above 2^53 and H3 ids exceed it.

§Edge attrs (edge kind dispatches the shape)

kind default key "kind". An edge whose kind is missing or unrecognised is skipped and counted in IngestReport::skipped_edges — never a silent success, never an error.

kindExtra keysMissing ⇒Maps to
"community"name (default DEFAULT_COMMUNITY_NAME + edge id), links (array of 2-element id arrays, default [])name defaults; links defaults to emptyCommunity { name, members = edge members, links }. Any link id not among this edge’s own members ⇒ IngestError::LinkOutsideCommunity.
"extraction"head (node id, required), mass (default DEFAULT_MASS)missing head ⇒ IngestError::MissingEdgeAttrExtraction { tails = members minus head, head, mass }. head not among members ⇒ IngestError::HeadNotMember. mass defaults because no instrument reads it.
"industry"name (default = edge id), c, v, e (finite f64, all required), lane (u8 in 0..=3)c/v/e missing ⇒ IngestError::MissingEdgeAttr; lane missing ⇒ DEFAULT_LANE and IngestReport::lane_defaulted setIndustry { name, lane, c, v, e }. v == 0.0 ⇒ IngestError::DegenerateIndustry.

§Graph attrs

Contract fieldDefault keyMissing ⇒Notes
repression"repression"DEFAULT_REPRESSIONScales agent_tension and appears in psr’s denominator. Must be finite and > 0.0, else IngestError::BadGraphAttr.
zoom"zoom"DEFAULT_ZOOM (fine)instruments::build maps zoom == 1 → coarse, else fine.

seed and tick are not in the contract: they are set to 0 on the produced DeckWorld (documented sentinels, never read by any instrument); real provenance lives on IngestReport.

Structs§

AttrContract
Named spellings for every contract-governed attribute key, plus the contract version. Owned Strings so a caller may rename any key (e.g. to match babylon’s own vocabulary) without forking the crate.
IngestReport
Provenance and every default applied while ingesting one Hypergraph: what was read, what was defaulted, and how a rendered node maps back to the caller’s own string id.
IngestedEdges
The three edge collections ingest can produce from one Hypergraph, plus the edges it could not classify and whether any industry’s lane defaulted.
IngestedNodes
Result of ingest_nodes: agents in node_ids() order; the parallel original-id vector; the parallel optional H3 cells; the count of nodes whose bloc defaulted; and which formula produced subsistence.

Enums§

IngestError
Every way ingest can fail. Each variant carries the offending node/edge id and key so a caller can find the exact place their graph disagrees with the contract (Power-of-10 rule 4: no catch-all).
TensionSource
Which formula produced a DeckWorld’s per-agent tension: the frozen agent_tension derivation, or a caller-supplied tension attr (inverted into a synthetic subsistence — see crate::raster::ingest module doc, D-I1).

Constants§

ATTR_CONTRACT_VERSION
Version of the attribute contract’s key spellings, defaults, and error dispositions. Bumped only on a meaning-changing edit (D-I3).
DEFAULT_BLOC
Default bloc for a node with no bloc attr: the neutral, unclassified middle bloc — never “core” (0) or “periphery” (2).
DEFAULT_COMMUNITY_NAME
Prefix used to synthesize a community name when name is absent; the edge id is appended.
DEFAULT_LANE
Default lane for an industry edge with no lane attr. Babylon has no per-sector lane classification (see module doc); every unlabelled industry lands here and IngestReport::lane_defaulted is raised.
DEFAULT_MASS
Default mass for an extraction edge: safe because no instrument reads mass (only do_tick does, which Phase I never calls).
DEFAULT_REPRESSION
Default repression: the identity scaling, the one value that adds no information.
DEFAULT_ZOOM
Default zoom: fine (un-aggregated).
KIND_COMMUNITY
KIND_EXTRACTION
KIND_INDUSTRY
K_BLOC
K_C
K_E
K_H3_CELL
K_HEAD
K_KIND
K_LANE
K_LINKS
K_MASS
K_NAME
K_REPRESSION
K_SUBSISTENCE
K_TENSION
K_V
K_WEALTH
K_ZOOM
PERIPHERY_BLOC
The bloc read by periphery_mean_wealth (deck.rs:416-419).

Functions§

build_scenecells3d
Ingest h per c, then dispatch to the untouched instruments::build (Task 5, graceful degradation). This is a thin wrapper: it never edits, wraps, or reimplements a builder — a change here can never be the reason a builder’s byte-identity guarantee (Task 6) breaks.
ingest_edges
Ingest every edge into communities / extraction / industries, dispatched on kind; unrecognised or missing kind is skipped and reported, never an error. Order within each output vec follows Hypergraph::edge_ids relative order — load-bearing for industries (algebra::transform and build_sankey iterate it in slice order).
ingest_nodes
Ingest one node per agent, in Hypergraph::node_ids order.
to_world
Ingest a real Hypergraph into a DeckWorld the frozen render path (instruments::build → rasterize / render_pixels) can consume unchanged, per c’s attribute contract. Pure and deterministic: two calls on the same (h, c) produce equal outputs (Global Constraints — determinism).