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 field | Default key | Type | Missing ⇒ | Rationale |
|---|---|---|---|---|
identity | (the node id itself) | String | n/a | The Hypergraph node id is the agent identity (D7 stringly-typed boundary). Never read from attrs. |
wealth | "wealth" | finite f64 | IngestError::MissingNodeAttr | Feeds agent_tension and psa. No honest default exists. |
subsistence | "subsistence" | finite f64 | IngestError::MissingNodeAttr | Same. |
bloc | "bloc" | u8 in 0..=2 | DEFAULT_BLOC | Bloc 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 ≥ 0 | absent ⇒ derive | Optional 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 String | absent ⇒ None | Optional, 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.
kind | Extra keys | Missing ⇒ | Maps to |
|---|---|---|---|
"community" | name (default DEFAULT_COMMUNITY_NAME + edge id), links (array of 2-element id arrays, default []) | name defaults; links defaults to empty | Community { 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::MissingEdgeAttr | Extraction { 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 set | Industry { name, lane, c, v, e }. v == 0.0 ⇒ IngestError::DegenerateIndustry. |
§Graph attrs
| Contract field | Default key | Missing ⇒ | Notes |
|---|---|---|---|
repression | "repression" | DEFAULT_REPRESSION | Scales 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§
- Attr
Contract - 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. - Ingest
Report - 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. - Ingested
Edges - The three edge collections ingest can produce from one
Hypergraph, plus the edges it could not classify and whether any industry’slanedefaulted. - Ingested
Nodes - Result of
ingest_nodes: agents innode_ids()order; the parallel original-id vector; the parallel optional H3 cells; the count of nodes whoseblocdefaulted; and which formula producedsubsistence.
Enums§
- Ingest
Error - 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).
- Tension
Source - Which formula produced a
DeckWorld’s per-agent tension: the frozenagent_tensionderivation, or a caller-suppliedtensionattr (inverted into a syntheticsubsistence— seecrate::raster::ingestmodule 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
blocattr: the neutral, unclassified middle bloc — never “core” (0) or “periphery” (2). - DEFAULT_
COMMUNITY_ NAME - Prefix used to synthesize a community name when
nameis absent; the edge id is appended. - DEFAULT_
LANE - Default lane for an industry edge with no
laneattr. Babylon has no per-sector lane classification (see module doc); every unlabelled industry lands here andIngestReport::lane_defaultedis raised. - DEFAULT_
MASS - Default
massfor an extraction edge: safe because no instrument readsmass(onlydo_tickdoes, 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_
scene cells3d - Ingest
hperc, then dispatch to the untouchedinstruments::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 onkind; unrecognised or missingkindis skipped and reported, never an error. Order within each output vec followsHypergraph::edge_idsrelative order — load-bearing forindustries(algebra::transformandbuild_sankeyiterate it in slice order). - ingest_
nodes - Ingest one node per agent, in
Hypergraph::node_idsorder. - to_
world - Ingest a real
Hypergraphinto aDeckWorldthe frozen render path (instruments::build→rasterize/render_pixels) can consume unchanged, perc’s attribute contract. Pure and deterministic: two calls on the same(h, c)produce equal outputs (Global Constraints — determinism).