polyc-query 2026.9.0

Read layer over the event log: a DataFusion engine for SQL over replayed partitions, and a per-conversation Parquet projection for participation-scoped search.
//! Read-only read layer over the event log, with two mechanisms behind one
//! sealed funnel: a `DataFusion` engine for SQL over replayed partitions, and
//! a per-conversation Parquet projection for participation-scoped search.
//!
//! Implements the accepted designs tracked by #1178 (epic), #1179, #1202,
//! and the access-control design this crate's `authority` module
//! implements, plus the participation-scoped search index's own design.
//!
//! The crate was SQL-only when it was named, so the description says what it
//! now is rather than describing a crate this no longer matches.
//!
//! # The sealed funnel
//!
//! [`authority::QueryAuthority`] is the crate's ONE public entry point —
//! one scope path, sealed. Every other
//! module that can build an unscoped engine or read unredacted data
//! (`engine`, `session`, `provider`, `views`, `decode`, `statement_gate`,
//! `search_index`) is `pub(crate)`: nothing outside this crate can reach
//! a `engine::QueryEngine` except through [`authority::QueryAuthority::scope_for`],
//! which only ever accepts an already-verified [`authority::Principal`] —
//! itself mintable only by [`authority::QueryAuthority`]'s own verification
//! methods, never by a public constructor. [`authority`]'s own module doc
//! states the full sealed/public split and how it is pinned.
//!
//! [`output::QueryResultJson`] (the wire JSON envelope) and [`audit::ReadAuditRecord`]
//! (the durable per-query audit record shape) round out the public surface,
//! alongside [`QueryLimits`] (re-exported here since it is a plain resource-
//! ceilings config struct [`authority::QueryAuthority::new_state_backed`] takes by value —
//! no reason for a caller assembling one to reach into the `pub(crate)`
//! `engine` module for it) — see each module's own doc.
//!
//! [`SearchIndex`] is the one exception the seal deliberately makes, and it
//! widens nothing: `search_index` itself stays `pub(crate)`, and this handle
//! exposes only what a Container must do to keep the projection maintained —
//! open it, register its observer, supervise its worker. It reads nothing back
//! out. The read side arrives as a scope-checked port behind
//! [`authority::QueryAuthority`], the same funnel every other read goes
//! through.

pub mod audit;
pub mod authority;
pub(crate) mod cache;
pub(crate) mod core_evidence;
pub(crate) mod core_execution;
pub(crate) mod core_production;
pub(crate) mod core_redaction;
pub(crate) mod core_resolution;
pub mod core_service;
pub(crate) mod credential;
pub mod dashboard;
pub(crate) mod decode;
pub(crate) mod engine;
pub mod feed;
pub mod journal;
pub(crate) mod metrics;
pub mod output;
pub(crate) mod provider;
pub mod routine_catalog;
pub(crate) mod search_index;
pub(crate) mod session;
pub(crate) mod statement_gate;
pub(crate) mod views;

pub use cache::CacheConfig;
pub use engine::QueryLimits;
pub use search_index::marks::CommitMarks;
pub use search_index::{SearchIndex, SearchIndexError, TermKeyOrigin};

/// Force-register this crate's own Prometheus metric families with the
/// process default registry.
///
/// (`metrics`, QRY-3 hardening review item D) so `/metrics` answers a
/// query-sizing scrape from the first call — not only after the first query
/// happens to touch a series. Call once at process startup, alongside any
/// other crate's own `init_metrics` (`crates/control-plane/src/grpc/mod.rs`'s
/// `serve` is where the control plane calls every such crate's
/// `init_metrics` today).
pub fn init_metrics() {
    metrics::force();
}