Skip to main content

Store

Struct Store 

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

Synthesist / lattice adapter over a project’s claims/ directory.

Writes go through Store::append; reads go through Store::query. Every append syncs the view before returning so follow-up reads see the write.

Implementations§

Source§

impl Store

Source

pub fn discover() -> Result<Self>

Open (or initialize) a Store.

Resolution order:

  1. SYNTHESIST_DIR env var (set by --data-dir in the CLI, or exported directly). Points at the directory CONTAINING claims/. An explicit override that doesn’t resolve to an existing store is a hard error — silent fallback would mask misconfiguration (e.g. a typo yielding an empty estate).
  2. Parent-directory walk from cwd. Opens the first ancestor containing claims/genesis.amc.
  3. If none, initialize a fresh store at cwd/claims/ (unless a v1 .synth/main.db is in scope, in which case we refuse and name the migrator).
Source

pub fn discover_from(start: &Path) -> Result<Self>

Like Self::discover but starts from a given path.

Walk-up order:

  1. Any ancestor with a claims/genesis.amc → open it.
  2. Otherwise, if any ancestor has a v1 .synth/main.db, bail with a prescriptive migration error. Silently creating an empty v2 estate alongside legacy data orphans the user’s work; we refuse.
  3. Otherwise, initialize a fresh v2 estate at start/claims/.
Source

pub fn open_at(claims_dir: &Path) -> Result<Self>

Open at an explicit claims/ directory. The directory must already contain a genesis.amc.

Source

pub fn init_at(claims_dir: &Path) -> Result<Self>

Initialize a fresh Store at claims_dir.

Source

pub fn discover_for(session: &Option<String>) -> Result<Self>

Discover and scope the asserter with an optional session id.

When a session id is given, subsequent appends assert as user:local:<user>:<session> — giving us attribution without cryptographic identity (see IDENTITY.md for the v0.2 roadmap).

Source

pub fn with_asserter(self, asserted_by: impl Into<String>) -> Self

Override the asserter prefix. Reserved for tests and for future callers that set asserter from a parsed Session claim (e.g. beacon sync, rather than $USER).

Source

pub fn append( &mut self, claim_type: ClaimType, props: Value, supersedes: Option<ClaimId>, ) -> Result<ClaimId>

Append a typed claim and synchronize the SQLite view.

Both the workflow layer and the substrate are type-agnostic for validation purposes since claim 0.2.0 / workflow 0.2.0: per-type schema validation is the consumer’s responsibility, applied at its API boundary (typically a CLI or library entrypoint) BEFORE calling this method. Consumers compose nomograph_claim::validation helpers with their own per-type validators; see synthesist::schema for a worked example. This method assumes the caller has already validated props for the given claim_type.

Source

pub fn query(&self, sql: &str, params: &[&dyn ToSql]) -> Result<Vec<Value>>

Run a read-only SQL query over the SQLite view.

Source

pub fn root(&self) -> &Path

The claims/ directory backing this store.

Source

pub fn sync_view(&mut self) -> Result<()>

Force a view rebuild. Most callers don’t need this; append syncs automatically.

Source

pub fn inner(&mut self) -> &mut ClaimStore

Access the underlying claim store (for session handles, compact, merge). Most callers should not need this.

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl !Sync for Store

§

impl !UnwindSafe for Store

§

impl Send for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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