Expand description
#524 P1 — placement directory record ingestion + in-process index.
Polls RecordResolver::resolve_repo for a bootstrap set of node DIDs,
walks the returned CAR’s MST, and decodes ai.hyprstream.placement.*
records (node / workload / group / groupItem) into a queryable index:
label-selector evaluation, resource matching, and bidirectional-consent
group membership. Consumed by handle_query_candidates.
P1 placement directory — record ingestion + in-process index (#524).
Day-1 ingestion is polled RecordResolver reads, not a firehose/moq_event
tail (that’s explicitly out of scope — a day-2 ticket). Given a node DID, we
call crate::RecordResolver::resolve_repo, parse the returned CARv1 blob
(hyprstream_pds::car::parse_car_v1), walk the repo’s MST from the commit’s
data root, and decode every ai.hyprstream.placement.{node,workload,group, groupItem} record we find into an in-process index.
§Trust posture — verified-by-construction ingest (#932)
Membership is becoming a load-bearing input (scheduler capacity partitions
today; group ledger / spend authorization tomorrow — #924/#925), so the
index no longer trusts an ingested record graph merely because a resolver
handed it over. Ingest is verified by construction: the resolver must
provide the DID’s currently-published #atproto verification slots
(RecordResolver::resolve_verifying_keys), [PlacementIndex::ingest_did]
verifies the repo CAR’s commit signature against the bounded live set, and missing key material
fails closed. Ingest also content-binds every CAR block to its declared CID.
The commit block, each MST node, and each record block have their CID recomputed from their bytes and
checked against the CID the CAR / parent declared for them (mirroring
hyprstream_pds::mst::Proof::verify) — before any record enters the
index. The signature alone is not sufficient: Commit::verify only signs
the commit’s own bytes (which name the MST root CID), so without per-block
CID binding an attacker could replay a genuine signed commit with
substituted MST-node/record blocks and forge membership; the content-bind
check closes that. A repo whose commit signature fails verification, whose
commit.did is not the requested DID, or whose any block’s recomputed CID
≠ its declared CID is refused — it cannot reach the derived indices, so it
cannot produce membership or any other fact derived from
[PlacementIndex::is_member]. This makes verification a property of the
index itself, not a caller obligation.
Ok(None) is never permission to skip authentication. A foreign DID whose
did:web HTTPS / did:plc document cannot yet be resolved is rejected until
that resolution path is wired (tracked with #1123). This keeps the placement
trust boundary fail closed.
§Group membership — bidirectional consent
A node is effectively a member of a group only when both sides agree:
the group owner published a GroupItemRecord{group, subject} naming the
node, and the node’s own NodeRecord.groups lists that group’s at-uri
(explicit node-side consent). Neither claim alone is membership — see
[PlacementIndex::is_member].
Group membership is exposed to queryCandidates’ label-selector matching as
a synthetic label, not a schema change: for every group a node is an
effective member of, the index adds a label ("group/<group-at-uri>", "true")
to that node’s effective label set (see [PlacementIndex::effective_labels]).
Each group gets its own unique label key (rather than several ("group", X) pairs under one shared key) because crate::scheduling::LabelSelector
looks up the first entry matching a key (the k8s label model: one value per
key) — multiple same-keyed pairs would only ever let the first one be
evaluated, silently breaking multi-group membership. A caller checks
membership in group G with LabelSelector::new(format!("group/{G}"), SelectorOp::Exists, vec![]).
Structs§
- Node
Facts - One node’s durable (non-volatile) placement facts, decoded from its
ai.hyprstream.placement.noderecord. - Placement
Index - In-process placement directory index. Rebuilt by polling
RecordResolver::resolve_repofor a bootstrap set of node DIDs (day-1 ingestion — see the module docs). Read from thequeryCandidatesrequest path; written by the poller.parking_lot::RwLockmirrors the precedent already used forDiscoveryService’s other in-memory maps.