`query.rs` is the read side, over a `&Mind<S>` with no store file, no daemon and no index. A `PipelineDocumentView` is four fields: the id, because a `PipelineDocument` does not carry its key and a client must never derive one; the document; the facts of its admission; and its status. The facts come from the commit receipts and from their `writes` alone, so a document a later batch cited as a strong read keeps the receipt that wrote it, and `admitted_at` is that receipt's `committed_at` -- the `now` admission was passed -- never the store's `stored_at`. A pipeline document the image holds and no receipt wrote is an integrity fault and refuses; the store has one writer and the receipt is its proof. Status is derived per call through `docs::Docs`, the same owner the admission rules ask, so a withdrawn resolution reopens its subject for a reader exactly when it reopens it for a rule. `closing_resolution` is `in_force_unless`'s own body asked for the resolution rather than the bool, so there is no second derivation to drift. Four reads: `view` by id, `query` over the filters (root, repo, cut, kinds, in force, faculty, an admission window), `open_items` for one campaign's unanswered questions, standing findings, follow-ups, unreported specs and unjudged reports, and `history` for every resolution a subject ever had or every assignment of a repo to this mind, withdrawn ones included with their reasons. A query is ordered by `(admitted_at, id)`, capped at 200, and carries `matched`, the count before the cap, so a truncation is never a short page that reads like the whole answer. `semantic` is accepted by the type and refused typed until Cut 11 owns the index; no substring filter lives here to become a second answer to "the text of a document". `cargo test -p huginn-mind --lib`: 56 passed, 0 failed, 0 warnings (46 + the ten tests). `cargo check --workspace` clean. No dependency, no target, no kind, no schema, no epoch; `Cargo.toml` and `Cargo.lock` untouched. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
42 lines
1.9 KiB
Rust
42 lines
1.9 KiB
Rust
//! `huginn-mind`: one instance's mind as typed CultCache state.
|
|
//!
|
|
//! The crate owns three decisions and nothing else. `Mind::open_with` owns
|
|
//! "may this store be this instance's mind": the opener refuses a foreign
|
|
//! type, a foreign epoch, a missing identity or a foreign identity before it
|
|
//! attaches anything. `receipt::commit` owns "did a batch enter, whole, with a
|
|
//! receipt": one compare-and-swap over the store, a receipt naming the exact
|
|
//! bytes read and written, and a typed conflict when the swap loses.
|
|
//! `Mind::admit_prepared` owns "may this batch enter": every cross-field and
|
|
//! cross-document rule, every derived write, and the replay check, in one
|
|
//! ordered path that `admit`, the daemon's sink and the hand-off all share.
|
|
//!
|
|
//! The read side derives status, joins the receipts and answers typed queries
|
|
//! through the same `docs` the rules use; nothing is stored for it.
|
|
//!
|
|
//! Document shape, bounds, formats and keys are `epiphany-pipeline`'s; the
|
|
//! organ registers, prepares, decodes and validates through the leaf's four
|
|
//! doors and never re-derives a key. The store is CultLib's owned redb
|
|
//! CultCache, whose lifetime-long exclusive lock is the single-writer
|
|
//! invariant's mechanism. No function here reads a clock or the environment:
|
|
//! `now` is passed in.
|
|
|
|
pub mod admission;
|
|
mod docs;
|
|
pub mod mind;
|
|
pub mod query;
|
|
pub mod receipt;
|
|
pub mod refusal;
|
|
pub mod store;
|
|
|
|
#[cfg(test)]
|
|
pub(crate) mod fixtures;
|
|
|
|
pub use admission::{BATCH_MAX, PipelineAdmissionBatch, PipelineAdmissionOutcome};
|
|
pub use mind::{HuginnMindEpoch, Mind};
|
|
pub use query::{
|
|
AdmissionFacts, HistoryScope, PipelineDocumentView, PipelineOpenItems, PipelineQuery, PipelineQueryPage,
|
|
PipelineStatus, QUERY_LIMIT_MAX, SemanticQuery,
|
|
};
|
|
pub use receipt::{DocumentVersion, Faculty, HuginnCommitReceipt, PipelineProvenance, RECEIPT_SCHEMA_VERSION};
|
|
pub use refusal::MindRefusal;
|
|
pub use store::MindStore;
|