Skip to main content

PlacementIndex

Struct PlacementIndex 

Source
pub struct PlacementIndex { /* private fields */ }
Expand description

In-process placement directory index. Rebuilt by polling RecordResolver::resolve_repo for a bootstrap set of node DIDs (day-1 ingestion — see the module docs). Read from the queryCandidates request path; written by the poller. parking_lot::RwLock mirrors the precedent already used for DiscoveryService’s other in-memory maps.

Implementations§

Source§

impl PlacementIndex

Source

pub fn new() -> Self

Source

pub async fn ingest_did( &self, resolver: &dyn RecordResolver, did: &str, ) -> Result<()>

Poll did’s repo via resolver and (re-)ingest its placement records, replacing whatever this DID contributed on a previous poll.

Ok(()) with no visible effect when the DID has no stored repo (nothing to ingest) or its repo carries no placement records — this is not an error, just an empty directory entry.

Verified by construction (#932, #918): the resolver MUST supply a verification slots for did (RecordResolver::resolve_verifying_keys); if it cannot, the repo is rejected (fail closed) — its records never reach the derived indices. Every CAR block is always content-bound to its declared CID. A repo that fails signature verification — or whose commit.did is not did — is refused, and this returns Err (the caller — handle_report_node_liveness — logs and continues; liveness is still recorded).

The production resolver currently returns None for both the local node’s mismatched did:key authority (#1124) and foreign DIDs (no DID- document fetch is wired yet). Those repos are rejected rather than silently ingested unverified. Foreign resolution is tracked with #1123.

Source

pub fn known_node_dids(&self) -> Vec<String>

All node DIDs currently known to the index (have an ingested NodeRecord).

Source

pub fn record_uri(&self, did: &str) -> Option<String>

The at-uri of did’s NodeRecord, if known.

Source

pub fn is_member(&self, node_did: &str, group_uri: &str) -> bool

Whether node_did is an effective (bidirectional-consent) member of group_uri: the group owner must have published a GroupItemRecord naming this node, and the node’s own NodeRecord.groups must list this group. Either claim alone is not membership.

Trust statement (#932): membership facts returned here are always content-bound and signature-verified. A GroupItemRecord / NodeRecord whose repo CAR commit failed signature verification against the resolver-provided #atproto key, whose commit.did is not the requested DID, or whose any block’s recomputed CID ≠ its declared CID never entered the index, so it cannot back a true result. The per-block CID binding is what stops a replayed genuine signed commit carrying substituted blocks from forging membership. See the module trust-posture docs for the verified-by-construction, fail-closed ingest gate.

Source

pub fn effective_labels(&self, node_did: &str) -> Vec<(String, String)>

A node’s effective label set for selector matching: its declared NodeRecord.labels plus one synthetic ("group/<uri>", "true") label per group it is an effective (bidirectional-consent) member of. See the module docs for why group membership uses a per-group label key.

Source

pub fn declared_resources(&self, node_did: &str) -> Vec<(String, String)>

A node’s declared (durable) capacity — NOT the live/allocatable figure queryCandidates matches resource requests against. Exposed mainly for tests / introspection.

Trait Implementations§

Source§

impl Default for PlacementIndex

Source§

fn default() -> PlacementIndex

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> MaybeSync for T
where T: Sync,