application tier

application-analytics

Forge analytics module — first-party web analytics (events, visitor identity, rollups). Wraps observability-analytics.

Forge analytics module — first-party web analytics (events, visitor identity, rollups). Wraps observability-analytics.

Tierapplication
Roleunclassified (baselined)
Pathcrates/application/analytics
Edition2024
Targetsapplication_analytics, disclosure_schema_live
Public items118 across 18 modules
Tests108

What it is for

application-analytics — first-party web analytics. Wraps observability-analytics.

B-009 Gate-0.5 finding: observability-analytics (crates/observability/analytics) ships no migrations/ directory. PgAnalyticsStore (storage/postgres.rs) is a query/write layer only — its own doc comment states the consumer must already have analytics_events, analytics_conversions, and analytics_daily_rollups — and those tables are in fact owned and created by application-engine's central platform migration set (crates/application/engine/migrations/ 020_analytics.sql, 062_analytics.sql, plus several later ALTERs), not by this library crate. There is no schema here for migrations() to vendor; staying empty is correct. permission_codes() was already declared before this pass.

Capabilities

crate root

application-analytics — first-party web analytics. Wraps observability-analytics.

Item
pub const DISCLOSURE_MIGRATIONS: & (& str, & str)

AnalyticsModule

application-analytics — first-party web analytics. Wraps observability-analytics.

Item
pub struct AnalyticsModule
AnalyticsModule :: fn new() -> Self
AnalyticsModule :: fn name(& self) -> & 'static str
AnalyticsModule :: fn version(& self) -> & 'static str
AnalyticsModule :: fn migrations(& self) -> Vec <MigrationSet>
AnalyticsModule :: async fn migrate_pending(& self, pool : & PgPool) -> std::result::Result <u32, MigrationError>
AnalyticsModule :: fn permission_codes(& self) -> Vec <String>

api::analytics_admin (other)

Analytics query admin REST router — Sprint 28 (Track 4).

Item
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, AnalyticsState : FromRef <S>,

api::disclosure_ingest (other)

POST /lab/beacon — the disclosure-lab ingest route (Sprint 3.8, T6).

Item
pub const BEACON_PATH: & str

DisclosureLab

POST /lab/beacon — the disclosure-lab ingest route (Sprint 3.8, T6).

Item
pub struct DisclosureLab
DisclosureLab :: fn new(ingest_key : IngestKey, settings : & ProbeSettings, probe_config_hash : impl Into <String>, retention : LabRetention, sink : Arc <dyn DisclosureSink>,) -> Self

DisclosureLabState

POST /lab/beacon — the disclosure-lab ingest route (Sprint 3.8, T6).

Item
pub struct DisclosureLabState
DisclosureLabState :: fn new(lab : DisclosureLab) -> Self
async fn ingest_beacon(State(state) : State <DisclosureLabState>, ConnectInfo(peer) : ConnectInfo <SocketAddr>, req : Request,) -> Response
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, DisclosureLabState : FromRef <S>,

api::probe_run_ingest (other)

POST /lab/probe-run — the probe battery's beacon (sprint 4.55 task 4).

Item
pub const PROBE_RUN_PATH: & str
pub const PAGE_TOKEN_HEADER: & str

PageTokens

POST /lab/probe-run — the probe battery's beacon (sprint 4.55 task 4).

Item
pub trait PageTokens

ProbeRunIngest

POST /lab/probe-run — the probe battery's beacon (sprint 4.55 task 4).

Item
pub struct ProbeRunIngest

ProbeRunIngestState

POST /lab/probe-run — the probe battery's beacon (sprint 4.55 task 4).

Item
pub struct ProbeRunIngestState
ProbeRunIngestState :: fn new(ingest : ProbeRunIngest) -> Self
async fn ingest_probe_run(State(state) : State <ProbeRunIngestState>, ConnectInfo(peer) : ConnectInfo <SocketAddr>, req : Request,) -> Response
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, ProbeRunIngestState : FromRef <S>,

middleware::visitor_id (other)

First-party visitor-identity cookie — Sprint 22 (T266, US-117).

Item
pub const COOKIE_NAME: & str
async fn visitor_id_layer(secure : bool, req : Request <Body>, next : Next) -> Response
fn cookie_value <'a>(header : & 'a str, name : & str) -> Option <& 'a str>

services (other)

Analytics service — first-party event collection + query facade.

Item
fn store(state : & AnalyticsState) -> Option <Arc <observability_analytics::PgAnalyticsStore>>
fn enabled(state : & AnalyticsState) -> bool

AnalyticsConfig

Analytics service — first-party event collection + query facade.

Item
pub struct AnalyticsConfig
AnalyticsConfig :: fn default_excludes() -> Vec <String>
AnalyticsConfig :: fn default() -> Self

IdentityLane

Analytics service — first-party event collection + query facade.

Item
pub enum IdentityLane

EventCollector

Event collector — the unbounded channel + supervised flush worker.

Item
pub struct EventCollector
EventCollector :: fn start(pool : PgPool, cfg : AnalyticsConfig) -> Self
EventCollector :: fn start_with_store(store : Arc <dyn AnalyticsStore>, cfg : AnalyticsConfig) -> Self
EventCollector :: fn submit(& self, event : AnalyticsEvent) -> bool
EventCollector :: async fn shutdown(& self)

services::disclosure_lab::auth (other)

Ingest credential handling for the disclosure lab (Sprint 3.8, T6).

Item
pub const INGEST_KEY_HEADER: & str
pub const MIN_INGEST_KEY_LEN: usize
pub const CREDENTIAL_QUERY_PARAMS: & & str
fn constant_time_eq(a : & u8, b : & u8) -> bool
fn query_carries_credential(query : Option <& str>) -> bool

IngestKey

Ingest credential handling for the disclosure lab (Sprint 3.8, T6).

Item
pub struct IngestKey
IngestKey :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result
IngestKey :: fn new(raw : & str) -> Result <Self, IngestKeyError>
IngestKey :: fn matches(& self, presented : & u8) -> bool

IngestKeyError

Ingest credential handling for the disclosure lab (Sprint 3.8, T6).

Item
pub enum IngestKeyError

services::disclosure_lab::limits (other)

Input limits for the beacon ingest route (Sprint 3.8, T6).

Item
pub const MAX_BODY_BYTES: usize
pub const MAX_JSON_DEPTH: usize
pub const MAX_BATCH_ITEMS: usize
pub const MAX_DETAIL_LEN: usize
pub const REQUIRED_CONTENT_TYPE: & str
fn json_depth(value : & serde_json::Value) -> usize

LimitViolation

Input limits for the beacon ingest route (Sprint 3.8, T6).

Item
pub enum LimitViolation
fn check_content_type(value : Option <& str>) -> Result <(), LimitViolation>
fn check_content_encoding(value : Option <& str>) -> Result <(), LimitViolation>
fn check_declared_length(value : Option <& str>) -> Result <(), LimitViolation>
fn check_body_len(len : usize) -> Result <(), LimitViolation>
fn check_depth(value : & serde_json::Value) -> Result <(), LimitViolation>
fn check_item_count(found : usize) -> Result <(), LimitViolation>

services::disclosure_lab::payload (other)

Beacon payload shape, probe gating, and the retention ingest gate

Item
fn safe_probe_key(raw : & str) -> String
fn gate(beacon : & Beacon, probes : & EnabledProbes,) -> Result <BTreeMap <String, BeaconItem>, GateViolation>
pub const NO_READING_DETAIL: & str
fn probe_group_for(key : & str) -> & 'static str
fn plan(retention : LabRetention, beacon : & Beacon, accepted : & BTreeMap <String, BeaconItem>, probes : & EnabledProbes, probe_config_hash : & str, raw_payload : serde_json::Value,) -> IngestOutcome

Beacon

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub struct Beacon

BeaconItem

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub struct BeaconItem

ClientProbeStatus

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub enum ClientProbeStatus

EnabledProbes

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub struct EnabledProbes
EnabledProbes :: fn from_settings(settings : & ProbeSettings) -> Self
EnabledProbes :: fn state(& self, key : & str) -> ProbeKeyState
EnabledProbes :: fn keys(& self) -> impl Iterator <Item = & str>
EnabledProbes :: fn len(& self) -> usize
EnabledProbes :: fn is_empty(& self) -> bool

GateViolation

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub enum GateViolation

IngestOutcome

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub enum IngestOutcome

PersistPlan

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub struct PersistPlan

ProbeKeyState

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub enum ProbeKeyState

ProbeResultRow

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub struct ProbeResultRow

RawWindow

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub enum RawWindow

StoredProbeStatus

Beacon payload shape, probe gating, and the retention ingest gate

Item
pub enum StoredProbeStatus
StoredProbeStatus :: fn as_str(self) -> & 'static str
StoredProbeStatus :: fn from(v : ClientProbeStatus) -> Self

services::disclosure_lab::probe_run (other)

The probe-run beacon: one driver's run of the probe page, validated into a

Item
pub const HEADERS_NEVER_STORED: & & str
fn validate(beacon : & ProbeRunBeacon, max_events : usize) -> Result <(), ProbeRunViolation>
fn storable_headers <'a>(headers : impl Iterator <Item =(& 'a str, & 'a str)>,) -> BTreeMap <String, String>

CanaryWire

The probe-run beacon: one driver's run of the probe page, validated into a

Item
pub struct CanaryWire

EventWire

The probe-run beacon: one driver's run of the probe page, validated into a

Item
pub struct EventWire

ProbeRunBeacon

The probe-run beacon: one driver's run of the probe page, validated into a

Item
pub struct ProbeRunBeacon

ProbeRunPlan

The probe-run beacon: one driver's run of the probe page, validated into a

Item
pub struct ProbeRunPlan

ProbeRunViolation

The probe-run beacon: one driver's run of the probe page, validated into a

Item
pub enum ProbeRunViolation

PgProbeRunSink

Where a validated probe run goes: the three probe tables, one transaction

Item
pub struct PgProbeRunSink
PgProbeRunSink :: fn new(pool : PgPool) -> Self
PgProbeRunSink :: async fn persist_run(& self, plan : & ProbeRunPlan) -> Result <Uuid, SinkError>

ProbeRunSink

Where a validated probe run goes: the three probe tables, one transaction

Item
pub trait ProbeRunSink

services::disclosure_lab::rate_limit (other)

Pre-parse rate limiting for the beacon ingest route (Sprint 3.8, T6).

Item
pub const DEFAULT_MAX_PER_WINDOW: u32
pub const DEFAULT_WINDOW_SECS: i64
pub const DEFAULT_MAX_TRACKED_PEERS: usize

IngestRateLimiter

Pre-parse rate limiting for the beacon ingest route (Sprint 3.8, T6).

Item
pub struct IngestRateLimiter
IngestRateLimiter :: fn new(max_per_window : u32, window_secs : i64, max_tracked_peers : usize) -> Self
IngestRateLimiter :: fn for_lab() -> Self
IngestRateLimiter :: fn check(& self, peer : IpAddr) -> RateDecision
IngestRateLimiter :: fn check_at(& self, peer : IpAddr, now : DateTime <Utc>) -> RateDecision
IngestRateLimiter :: fn tracked_peers(& self) -> usize
IngestRateLimiter :: fn default() -> Self

RateDecision

Pre-parse rate limiting for the beacon ingest route (Sprint 3.8, T6).

Item
pub enum RateDecision
RateDecision :: fn is_allowed(self) -> bool

RateDenial

Pre-parse rate limiting for the beacon ingest route (Sprint 3.8, T6).

Item
pub enum RateDenial

services::disclosure_lab::sink (other)

Persistence seam for validated disclosure-lab beacons (Sprint 3.8, T6).

Item
pub const ABSOLUTE_GRACE_MINUTES: i32

DisclosureSink

Persistence seam for validated disclosure-lab beacons (Sprint 3.8, T6).

Item
pub trait DisclosureSink

PgDisclosureSink

Persistence seam for validated disclosure-lab beacons (Sprint 3.8, T6).

Item
pub struct PgDisclosureSink
PgDisclosureSink :: fn new(pool : PgPool) -> Self
PgDisclosureSink :: async fn persist(& self, plan : & PersistPlan) -> Result <Uuid, SinkError>

SinkError

Persistence seam for validated disclosure-lab beacons (Sprint 3.8, T6).

Item
pub enum SinkError
fn window_minutes(window : RawWindow) -> Result <i32, SinkError>

services::middleware (other)

Axum middleware that captures every HTTP request as an

Item
async fn analytics_middleware(State(analytics) : State <AnalyticsState>, ConnectInfo(peer) : ConnectInfo <SocketAddr>, req : axum::extract::Request, next : Next,) -> Response

AnalyticsState

Analytics state bit (Sprint 65: extracted from rust-cms-engine).

Item
pub struct AnalyticsState

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

application_analytics

flowchart TD
  n_application_analytics["application_analytics"]
  n_application_analytics --> n_api["api"]
  n_api --> n_api__analytics_admin["analytics_admin"]
  n_api --> n_api__disclosure_ingest["disclosure_ingest"]
  n_api --> n_api__probe_run_ingest["probe_run_ingest"]
  n_application_analytics --> n_middleware["middleware"]
  n_middleware --> n_middleware__visitor_id["visitor_id"]
  n_application_analytics --> n_services["services"]
  n_services --> n_services__collector["collector"]
  n_services --> n_services__disclosure_lab["disclosure_lab"]
  n_services__disclosure_lab --> n_services__disclosure_lab__auth["auth"]
  n_services__disclosure_lab --> n_services__disclosure_lab__limits["limits"]
  n_services__disclosure_lab --> n_services__disclosure_lab__payload["payload"]
  n_services__disclosure_lab --> n_services__disclosure_lab__probe_run["probe_run"]
  n_services__disclosure_lab --> n_services__disclosure_lab__probe_run_sink["probe_run_sink"]
  n_services__disclosure_lab --> n_services__disclosure_lab__rate_limit["rate_limit"]
  n_services__disclosure_lab --> n_services__disclosure_lab__sink["sink"]
  n_services --> n_services__middleware["middleware"]
  n_application_analytics --> n_state["state"]

Public surface

`crate root`

ItemWhat it is
pub const DISCLOSURE_MIGRATIONS: & (& str, & str)The disclosure lab's migrations, in apply order, embedded at compile time.
pub struct AnalyticsModule
AnalyticsModule :: fn new() -> Self
AnalyticsModule :: fn name(& self) -> & 'static str
AnalyticsModule :: fn version(& self) -> & 'static str
AnalyticsModule :: fn migrations(& self) -> Vec <MigrationSet>The analytics tables themselves stay engine-owned (B-009, above)
AnalyticsModule :: async fn migrate_pending(& self, pool : & PgPool) -> std::result::Result <u32, MigrationError>
AnalyticsModule :: fn permission_codes(& self) -> Vec <String>

`api::analytics_admin`

ItemWhat it is
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, AnalyticsState : FromRef <S>,

`api::disclosure_ingest`

ItemWhat it is
pub const BEACON_PATH: & strPath the beacon is POSTed to, relative to wherever the router is mounted.
pub struct DisclosureLabEverything the ingest route needs, assembled once at boot.
DisclosureLab :: fn new(ingest_key : IngestKey, settings : & ProbeSettings, probe_config_hash : impl Into <String>, retention : LabRetention, sink : Arc <dyn DisclosureSink>,) -> SelfAssemble the route's state from the active configuration.
pub struct DisclosureLabStateClonable handle a consumer composes into its own application state.
DisclosureLabState :: fn new(lab : DisclosureLab) -> SelfWrap an assembled DisclosureLab.
async fn ingest_beacon(State(state) : State <DisclosureLabState>, ConnectInfo(peer) : ConnectInfo <SocketAddr>, req : Request,) -> ResponsePOST /lab/beacon
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, DisclosureLabState : FromRef <S>,Router carrying BEACON_PATH

`api::probe_run_ingest`

ItemWhat it is
pub const PROBE_RUN_PATH: & strPath the probe-run beacon is POSTed to.
pub const PAGE_TOKEN_HEADER: & strHeader carrying a page token minted by the host when it served the page.
pub trait PageTokensA second credential: single-use page tokens
pub struct ProbeRunIngestEverything the route needs, assembled once at boot.
pub struct ProbeRunIngestStateClonable handle a host composes into its state.
ProbeRunIngestState :: fn new(ingest : ProbeRunIngest) -> Self
async fn ingest_probe_run(State(state) : State <ProbeRunIngestState>, ConnectInfo(peer) : ConnectInfo <SocketAddr>, req : Request,) -> ResponseThe handler
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, ProbeRunIngestState : FromRef <S>,Router carrying PROBE_RUN_PATH

`middleware::visitor_id`

ItemWhat it is
pub const COOKIE_NAME: & strThe cookie name — short, first-party, analytics-only.
async fn visitor_id_layer(secure : bool, req : Request <Body>, next : Next) -> ResponseSet hp_vid on public-page responses that lack a valid one
fn cookie_value <'a>(header : & 'a str, name : & str) -> Option <& 'a str>Extract a named cookie's value from a Cookie header string.

`services`

ItemWhat it is
pub enum IdentityLaneIdentity-resolution lane (Gate 1.5 R1 D-28.3)
pub struct AnalyticsConfigConsumer-supplied analytics configuration
AnalyticsConfig :: fn default_excludes() -> Vec <String>The default exclude list — these paths are dropped at the middleware before reaching the channel
AnalyticsConfig :: fn default() -> Self
fn store(state : & AnalyticsState) -> Option <Arc <observability_analytics::PgAnalyticsStore>>Look up the consumer's PgAnalyticsStore when analytics is enabled
fn enabled(state : & AnalyticsState) -> boolWhether analytics is enabled for this consumer instance.

`services::collector`

ItemWhat it is
pub struct EventCollectorOwns the analytics ingest channel + the supervised worker that drains it
EventCollector :: fn start(pool : PgPool, cfg : AnalyticsConfig) -> SelfSpawn the collector
EventCollector :: fn start_with_store(store : Arc <dyn AnalyticsStore>, cfg : AnalyticsConfig) -> SelfSpawn the collector with a caller-provided store
EventCollector :: fn submit(& self, event : AnalyticsEvent) -> boolPush an event onto the channel
EventCollector :: async fn shutdown(& self)Signal the worker to drain remaining events and exit

`services::disclosure_lab::auth`

ItemWhat it is
pub const INGEST_KEY_HEADER: & strHeader the ingest credential is presented in
pub const MIN_INGEST_KEY_LEN: usizeShortest credential the lab will accept
pub const CREDENTIAL_QUERY_PARAMS: & & strQuery-parameter names that would carry a credential
pub enum IngestKeyErrorWhy a configured ingest key was refused
pub struct IngestKeyA validated ingest credential
IngestKey :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::ResultRedacted
IngestKey :: fn new(raw : & str) -> Result <Self, IngestKeyError>Validate and wrap a configured key
IngestKey :: fn matches(& self, presented : & u8) -> boolWhether a presented credential matches, in constant time.
fn constant_time_eq(a : & u8, b : & u8) -> boolCompare two byte strings without an early exit on the first differing byte
fn query_carries_credential(query : Option <& str>) -> boolWhether a URL query string carries something shaped like a credential

`services::disclosure_lab::limits`

ItemWhat it is
pub const MAX_BODY_BYTES: usizeLargest beacon body accepted, in bytes.
pub const MAX_JSON_DEPTH: usizeDeepest JSON nesting accepted, counting a scalar as depth 1.
pub const MAX_BATCH_ITEMS: usizeMost probe readings accepted in one beacon batch.
pub const MAX_DETAIL_LEN: usizeLongest detail string accepted on a probe reading
pub const REQUIRED_CONTENT_TYPE: & strThe only media type the ingest route accepts.
pub enum LimitViolationAn input limit that was exceeded, or a required header that was wrong
fn check_content_type(value : Option <& str>) -> Result <(), LimitViolation>Require Content-Type: application/json, ignoring parameters
fn check_content_encoding(value : Option <& str>) -> Result <(), LimitViolation>Refuse any content coding other than absent or identity
fn check_declared_length(value : Option <& str>) -> Result <(), LimitViolation>Reject on the declared length, before any body is read
fn check_body_len(len : usize) -> Result <(), LimitViolation>Reject on the actual number of bytes received
fn json_depth(value : & serde_json::Value) -> usizeNesting depth of a decoded document: a scalar or empty container is 1, and a non-empty container is one more than its deepest child
fn check_depth(value : & serde_json::Value) -> Result <(), LimitViolation>Reject a document nested deeper than MAX_JSON_DEPTH
fn check_item_count(found : usize) -> Result <(), LimitViolation>Reject a batch larger than MAX_BATCH_ITEMS

`services::disclosure_lab::payload`

ItemWhat it is
pub enum ClientProbeStatusStatus a client is permitted to report for a probe
pub enum StoredProbeStatusStatus as stored, mirroring the migration's dl_probe_status_ck alphabet.
StoredProbeStatus :: fn as_str(self) -> & 'static strThe literal the database column takes.
StoredProbeStatus :: fn from(v : ClientProbeStatus) -> Self
pub struct BeaconItemOne probe reading as sent by the probe page.
pub struct BeaconOne beacon POST
pub enum ProbeKeyStateWhether a probe key is known to the active config, and if so whether it is on.
pub struct EnabledProbesThe active config, projected to the only question the ingest route asks of it: is this key on? Built by serialising ProbeSettings rather than by a hand-written match
EnabledProbes :: fn from_settings(settings : & ProbeSettings) -> SelfProject the active ProbeSettings
EnabledProbes :: fn state(& self, key : & str) -> ProbeKeyStateClassify one probe key.
EnabledProbes :: fn keys(& self) -> impl Iterator <Item = & str>Every probe key in the active config, enabled or not
EnabledProbes :: fn len(& self) -> usizeHow many probes the config knows about.
EnabledProbes :: fn is_empty(& self) -> boolWhether the config knows about no probes at all — the fail-closed state, in which every beacon is refused.
pub enum GateViolationA beacon that the server refuses
fn safe_probe_key(raw : & str) -> StringRender a probe key safe to put in a response body or a log line
fn gate(beacon : & Beacon, probes : & EnabledProbes,) -> Result <BTreeMap <String, BeaconItem>, GateViolation>Server-side re-check of a decoded beacon against the active config
pub struct ProbeResultRowOne row destined for disclosure_lab_probe_results.
pub const NO_READING_DETAIL: & strDetail recorded when an enabled probe sent no reading at all
pub enum RawWindowHow long the raw payload is kept, as the plan expresses it.
pub struct PersistPlanEverything the sink needs, with nothing left to decide.
pub enum IngestOutcomeWhat the ingest route should do with a validated beacon.
fn probe_group_for(key : & str) -> & 'static strGroup letter for a probe key, per §10's battery.
fn plan(retention : LabRetention, beacon : & Beacon, accepted : & BTreeMap <String, BeaconItem>, probes : & EnabledProbes, probe_config_hash : & str, raw_payload : serde_json::Value,) -> IngestOutcomeDecide what to persist for a gated beacon

`services::disclosure_lab::probe_run`

ItemWhat it is
pub struct EventWireOne DOM event as the page recorded it
pub struct CanaryWire
pub struct ProbeRunBeaconThe beacon body.
pub enum ProbeRunViolationWhy a beacon is refused before any row is written.
pub const HEADERS_NEVER_STORED: & & strRequest headers the sink may store
pub struct ProbeRunPlanEverything the sink needs, with nothing left to decide.
fn validate(beacon : & ProbeRunBeacon, max_events : usize) -> Result <(), ProbeRunViolation>Validate a decoded beacon against the lab's caps
fn storable_headers <'a>(headers : impl Iterator <Item =(& 'a str, & 'a str)>,) -> BTreeMap <String, String>Keep only the headers the sink may store.

`services::disclosure_lab::probe_run_sink`

ItemWhat it is
pub trait ProbeRunSinkA destination for a probe run.
pub struct PgProbeRunSinkThe Postgres sink over the lab's own database.
PgProbeRunSink :: fn new(pool : PgPool) -> Self
PgProbeRunSink :: async fn persist_run(& self, plan : & ProbeRunPlan) -> Result <Uuid, SinkError>

`services::disclosure_lab::rate_limit`

ItemWhat it is
pub const DEFAULT_MAX_PER_WINDOW: u32Requests per window, per peer, in the lab's default posture.
pub const DEFAULT_WINDOW_SECS: i64Window length in seconds, in the lab's default posture.
pub const DEFAULT_MAX_TRACKED_PEERS: usizeMost distinct peers tracked at once, in the lab's default posture.
pub enum RateDenialWhy a request was refused by the limiter.
pub enum RateDecisionThe limiter's answer for one request.
RateDecision :: fn is_allowed(self) -> boolWhether the request may proceed.
pub struct IngestRateLimiterFixed-window per-peer limiter
IngestRateLimiter :: fn new(max_per_window : u32, window_secs : i64, max_tracked_peers : usize) -> SelfBuild a limiter
IngestRateLimiter :: fn for_lab() -> SelfThe lab's default posture: DEFAULT_MAX_PER_WINDOW per DEFAULT_WINDOW_SECS, tracking DEFAULT_MAX_TRACKED_PEERS peers.
IngestRateLimiter :: fn check(& self, peer : IpAddr) -> RateDecisionDecide, using the wall clock.
IngestRateLimiter :: fn check_at(& self, peer : IpAddr, now : DateTime <Utc>) -> RateDecisionDecide, at an explicit instant
IngestRateLimiter :: fn tracked_peers(& self) -> usizeHow many peers are currently tracked
IngestRateLimiter :: fn default() -> Self

`services::disclosure_lab::sink`

ItemWhat it is
pub const ABSOLUTE_GRACE_MINUTES: i32Grace between raw_expires_at and the deadline nothing extends
pub enum SinkErrorWhy a validated plan could not be stored
pub trait DisclosureSinkWhere a validated beacon goes.
fn window_minutes(window : RawWindow) -> Result <i32, SinkError>Project a plan's retention window onto the schema's raw_window_minutes column
pub struct PgDisclosureSinkPostgres implementation over migration 122.
PgDisclosureSink :: fn new(pool : PgPool) -> SelfWrap a pool.
PgDisclosureSink :: async fn persist(& self, plan : & PersistPlan) -> Result <Uuid, SinkError>

`services::middleware`

ItemWhat it is
async fn analytics_middleware(State(analytics) : State <AnalyticsState>, ConnectInfo(peer) : ConnectInfo <SocketAddr>, req : axum::extract::Request, next : Next,) -> ResponseSelf-scoped analytics capture middleware

`state`

ItemWhat it is
pub struct AnalyticsStateThe analytics-specific slice of consumer state

Re-exports. Exported here, defined elsewhere.

ExportDefined in
AnalyticsStatestate::AnalyticsState
EventCollectorcollector::EventCollector
analytics_middlewaremiddleware::analytics_middleware
disclosure_labservices::disclosure_lab
{AnalyticsConfig,EventCollector,analytics_middleware}services::{AnalyticsConfig,EventCollector,analytics_middleware}
{BEACON_PATHasDISCLOSURE_BEACON_PATH,DisclosureLab,DisclosureLabState,routerasdisclosure_ingest_router,}api::disclosure_ingest::{BEACON_PATHasDISCLOSURE_BEACON_PATH,DisclosureLab,DisclosureLabState,routerasdisclosure_ingest_router,}
{Beacon,BeaconItem,ClientProbeStatus,EnabledProbes,GateViolation,IngestOutcome,PersistPlan,ProbeKeyState,ProbeResultRow,RawWindow,StoredProbeStatus,gate,plan,}payload::{Beacon,BeaconItem,ClientProbeStatus,EnabledProbes,GateViolation,IngestOutcome,PersistPlan,ProbeKeyState,ProbeResultRow,RawWindow,StoredProbeStatus,gate,plan,}
{DisclosureSink,PgDisclosureSink,SinkError}sink::{DisclosureSink,PgDisclosureSink,SinkError}
{INGEST_KEY_HEADER,IngestKey,IngestKeyError,constant_time_eq,query_carries_credential,}auth::{INGEST_KEY_HEADER,IngestKey,IngestKeyError,constant_time_eq,query_carries_credential,}
{IngestRateLimiter,RateDecision,RateDenial}rate_limit::{IngestRateLimiter,RateDecision,RateDenial}
{LimitViolation,MAX_BATCH_ITEMS,MAX_BODY_BYTES,MAX_DETAIL_LEN,MAX_JSON_DEPTH}limits::{LimitViolation,MAX_BATCH_ITEMS,MAX_BODY_BYTES,MAX_DETAIL_LEN,MAX_JSON_DEPTH}
{PAGE_TOKEN_HEADER,PROBE_RUN_PATH,PageTokens,ProbeRunIngest,ProbeRunIngestState,routerasprobe_run_ingest_router,}api::probe_run_ingest::{PAGE_TOKEN_HEADER,PROBE_RUN_PATH,PageTokens,ProbeRunIngest,ProbeRunIngestState,routerasprobe_run_ingest_router,}

Boundary

Reaches into observability, platform.

Shares tier application with 120 other crates: application-agreements, application-ai, application-approvals, application-assessments, application-audit-log, application-auth, application-billing, application-browser-automation, … (120 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)application
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/application/analytics
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_application["application"] --> n_observability["observability"]
  n_application["application"] --> n_platform["platform"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`application-core`applicationnoalways
`application-rbac`applicationnoalways
`observability-analytics`observabilitynoalways
`platform-dto`platformnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
axum^0.7multipartnoalways
chrono^0.4serdenoalways
futures-util^0.3noalways
serde^1derivenoalways
serde_json^1noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
thiserror^2noalways
tokio^1fullnoalways
tower-sessions^0.13noalways
tracing^0.1noalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tower^0.5noalways

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_platform_disclosure_lab["platform-disclosure-lab"] -->|uses| SELF
  SELF["application-analytics"]
  SELF -->|runtime| n_application_core["application-core"]
  SELF -->|runtime| n_application_rbac["application-rbac"]
  SELF -->|runtime| n_observability_analytics["observability-analytics"]
  SELF -->|runtime| n_platform_dto["platform-dto"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libapplication_analytics`src/lib.rs`
testdisclosure_schema_live`tests/disclosure_schema_live.rs`

Error model

Error typeNamed by
IngestKeyErrordeclared, no public signature returns it
SinkErrorwindow_minutes

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessyes
network I/Oyes
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
CARGO_PKG_VERSIONsrc/lib.rs

1 workspace crate depends on this one: platform-disclosure-lab.

Verification

KindCount
Unit tests104
Integration tests4
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root201
api::analytics_admin101
api::disclosure_ingest501
api::probe_run_ingest706
middleware::visitor_id300
services401
services::collector100
services::disclosure_lab::auth701
services::disclosure_lab::limits1300
services::disclosure_lab::payload1601
services::disclosure_lab::probe_run800
services::disclosure_lab::probe_run_sink202
services::disclosure_lab::rate_limit601
services::disclosure_lab::sink500
services::middleware100
state100

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc103118
Public modules with a //! block1818
pie showData
    title Public items with rustdoc
    "Documented" : 103
    "No rustdoc detected" : 15

Metrics

MetricValue
Rust source files19
Source lines5404
Code lines3886
Public API items118
Public modules18
Tests108
Examples0
Cargo features0
Direct runtime dependencies16
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "constant" : 19
    "enum" : 13
    "function" : 26
    "method" : 36
    "struct" : 21
    "trait" : 3
pie showData
    title Rust source composition
    "Code" : 3886
    "Blank or comment" : 1518

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All application · Manual