Skip to main content

SubstrateService

Struct SubstrateService 

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

Substrate RPC service.

Implementations§

Source§

impl SubstrateService

Source

pub fn new() -> Self

Create a new service with ADR-057 boot-default ACLs for the local mesh id "local". Prefer Self::with_mesh_id when the real mesh id is known at construction.

Source

pub fn with_mesh_id(mesh_id: impl Into<String>) -> Self

Create a service seeded with ADR-057 defaults for mesh_id.

Source

pub fn set_acl_table(&self, table: AclTable)

Replace the ACL table (tests / mesh re-bootstrap).

Source

pub fn publish_public(&self, path: &str, value: Value) -> u64

Opt a path into public readability (ADR-057 publish_public).

Seals allow: ["public"] on the exact path and publishes value under the legacy ungated publish path. Prefer the signed Self::publish_gated flow for production node writes; this helper is the ergonomic opt-out of default-private sensor posture after a successful gated publish.

Source

pub fn take_acl_denials(&self) -> Vec<AclDenialEvent>

Drain buffered ACL denial events (for ExoChain append by the daemon dispatch loop). Authenticated denials only.

Source

pub fn declare(&self, path: &str, sensitivity: Sensitivity)

Declare (or re-declare) the sensitivity level for a path.

If the path already exists, the declaration is updated in place without clearing the value. Paths not declared default to Sensitivity::Workspace on first touch.

Source

pub fn has_published_under(&self, prefix: &str) -> bool

Daemon-internal existence check: has anything been published at or under prefix? Acts as no principal and reads no values, so callers (discovery, health) need not impersonate a node to ask. It is not an egress path and must not be exposed over RPC.

Source

pub fn egress_check( &self, caller: Option<&str>, path: &str, op: &str, ) -> Result<(), EgressDenied>

Egress gate: ADR-057 path ACL then sensitivity tier.

This is intentionally the one seam the policy will gate, so callers need not change when grants land for Capture.

Source

pub fn read( &self, caller: Option<&str>, path: &str, ) -> Result<SubstrateReadSnapshot, EgressDenied>

Read the current value + metadata at a path.

Source

pub fn list( &self, caller: Option<&str>, prefix: &str, depth: u32, ) -> Result<SubstrateListSnapshot, EgressDenied>

Enumerate children of a prefix up to depth levels below it.

Contract (ADR-Explorer Phase 1 §3.1):

  • prefix — substrate path; empty string or "/" means “top-level”. Trailing slashes are trimmed.
  • depth = 0 — return only the prefix node itself, if it is a value (no children enumerated).
  • depth = 1 — one level below prefix. Default for the Explorer lazy-tree walk.
  • depth = N > 1 — up to N levels below prefix (flat list, deepest-child first in sort order).

Only paths with a published Replace value participate — pure internal nodes (no value of their own but with descendants that do) are still surfaced as entries with has_value: false when they sit on the path down to a value-bearing leaf; see child_count semantics on SubstrateListEntry.

Per-child egress: the prefix itself is egress_check’d once under op "list". Each candidate descendant path is then also egress-checked so capture-tier path names don’t leak to an anonymous caller — matching the spirit of read’s per-path gate.

Not a hot path (the Explorer expands one prefix per user click); a full DashMap scan is fine for the foreseeable substrate size.

Source

pub fn publish_gated( &self, node_id: Option<&str>, path: &str, value: Value, ) -> Result<u64, GateDenied>

Publish a Replace delta under the node-identity write gate.

Every node-private substrate write belongs to exactly one node, and may only land under that node’s namespace — substrate/<node-id>/…. This is the enforcement seam: callers provide the node_id they have already authenticated (signature verified at the RPC boundary, or trusted at in-process call sites where the daemon stamps its own id); publish_gated refuses to write anywhere else.

Mesh-canonical writes (substrate/_derived/...) are rejected by this method — the legacy gate has no crate::NodeRegistry handle and cannot consult the DerivedWriteGrant table. Use Self::publish_gated_with_grants for that tier.

Returns the new tick on success, or GateDenied when the path is outside the node’s prefix or no node id was supplied. See crate::node_registry::path_belongs_to for the exact rule.

Fans out to all external-stream subscribers registered via Self::subscribe.

Source

pub fn publish_gated_with_grants( &self, node_id: Option<&str>, path: &str, value: Value, node_registry: &NodeRegistry, ) -> Result<u64, GateDenied>

Tier-aware publish gate.

Splits writes by path tier per .planning/sensors/PIPELINE-PRIMITIVE-JOURNAL.md §R3.3:

The dual-tier check is the load-bearing bit of R3 — it lets a daemon-class node publish whisper transcripts at substrate/_derived/transcript/<source>/mic while still honouring the per-node prefix rule for everything else.

Source

pub fn publish(&self, caller: Option<&str>, path: &str, value: Value) -> u64

Publish a Replace delta at a path. Returns the new tick.

Fans out to all external-stream subscribers registered via Self::subscribe. For bring-up, the owner-check is trusted — the daemon layer should gate on its own agent role policy.

Legacy path. This is the pre-node-identity surface. New callers should use Self::publish_gated so the per-node prefix invariant holds. Phased migration lets existing in- process publishers keep working until they’re each updated.

Source

pub fn notify(&self, caller: Option<&str>, path: &str) -> u64

Emit a notify-only signal (no payload change) on a path. Returns the current tick (unchanged if no write has happened).

Source

pub fn subscribe( &self, caller: Option<&str>, path: &str, ) -> Result<(SubscriberId, Receiver<Vec<u8>>), EgressDenied>

Subscribe an external streaming sink to updates on a path.

Returns the subscriber id and a channel receiver. The caller pipes the JSON lines the sink receives into their socket.

Source

pub fn unsubscribe(&self, path: &str, id: SubscriberId)

Remove a specific subscription. Safe if the id is unknown.

Source

pub fn path_count(&self) -> usize

Number of declared paths (for metrics / tests).

Trait Implementations§

Source§

impl Clone for SubstrateService

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for SubstrateService

Source§

fn default() -> Self

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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