Skip to content

Class EventIndexRegistry

Namespace: DotBoxD.Plugins.Indexing
Assembly: DotBoxD.Plugins.dll

A first-class, reusable host dispatch index (issue #50). A host registers a subscription kernel together with its generated DotBoxD.Plugins.IndexedPredicates; the registry recomputes them from verified IR and compiles them into an DotBoxD.Plugins.Indexing.EventIndexMatcher (precompiled getters, no per-event reflection) and, when the host publishes an event, runs the cheap index check before entering the sandbox. Events the index rejects never reach the verified IR; survivors are dispatched to DotBoxD.Plugins.Kernel.InstalledKernel as the correctness authority — the verified ShouldHandle still runs after a matching index check because package-supplied coverage metadata is not trusted across the manifest boundary.

This is the "register a subscription and get index-based prefiltering without writing your own matcher" surface. Subscriptions whose predicates touch no indexed field are rejected by `DotBoxD.Plugins.Indexing.EventIndexRegistry.Register(DotBoxD.Abstractions.IPluginEventAdapter{},DotBoxD.Plugins.Kernel.InstalledKernel,System.Collections.Generic.IReadOnlyList{DotBoxD.Plugins.IndexedPredicate},System.Boolean)` (returns false) so the host can leave them on its broad pipeline.

public sealed class EventIndexRegistry

objectEventIndexRegistry

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

EventIndexRegistry(Action<SubscriptionDeliveryFault>?)

Section titled “ EventIndexRegistry(Action<SubscriptionDeliveryFault>?)”
public EventIndexRegistry(Action<SubscriptionDeliveryFault>? onFault = null)

onFault Action<SubscriptionDeliveryFault>?

Aggregate prefilter diagnostics across every published event and registered subscription.

public EventIndexStats Stats { get; }

EventIndexStats

Awaits every in-flight dispatch launched by DotBoxD.Plugins.Indexing.EventIndexRegistry.Publish(,System.Threading.CancellationToken) (e.g. on host shutdown).

public Task DrainAsync()

Task

Publish<TEvent>(TEvent, CancellationToken)

Section titled “ Publish<TEvent>(TEvent, CancellationToken)”

Runs every registered TEvent subscription’s cheap index check against value; survivors are dispatched to the verified IR fire-and-forget (the host’s broad pipeline keeps non-indexed subscriptions). Prefilter counters update synchronously.

public void Publish<TEvent>(TEvent value, CancellationToken cancellationToken = default)

value TEvent

cancellationToken CancellationToken

TEvent

Register<TEvent>(IPluginEventAdapter<TEvent>, InstalledKernel, IReadOnlyList<IndexedPredicate>, bool)

Section titled “ Register<TEvent>(IPluginEventAdapter<TEvent>, InstalledKernel, IReadOnlyList<IndexedPredicate>, bool)”

Registers kernel as an indexed subscription for TEvent. The matching predicates are recomputed from the kernel’s verified ShouldHandle IR; the predicates and indexCoversPredicate arguments are the package’s untrusted manifest claims and are intentionally not read here. Returns false (registering nothing) when none of the recomputed predicates map onto an DotBoxD.Plugins.Indexing.EventIndexKeyAttribute field — the caller should keep such a subscription on its broad pipeline. Returns true when the subscription is now served from the index.

public bool Register<TEvent>(IPluginEventAdapter<TEvent> adapter, InstalledKernel kernel, IReadOnlyList<IndexedPredicate> predicates, bool indexCoversPredicate)

adapter IPluginEventAdapter<TEvent>

kernel InstalledKernel

predicates IReadOnlyList<IndexedPredicate>

indexCoversPredicate bool

bool

TEvent

Removes every registration owned by kernel (e.g. when a host uninstalls it).

public void Unregister(InstalledKernel kernel)

kernel InstalledKernel