pub struct PostgresStorage { /* private fields */ }Expand description
PostgreSQL-backed storage with connection pooling and optional multi-tenancy.
Implementations§
Source§impl PostgresStorage
impl PostgresStorage
Sourcepub async fn connect(database_url: &str) -> Result<Self, StorageError>
pub async fn connect(database_url: &str) -> Result<Self, StorageError>
Connect to Postgres with the default tenant.
Sourcepub async fn connect_tenant(
database_url: &str,
tenant_id: &str,
) -> Result<Self, StorageError>
pub async fn connect_tenant( database_url: &str, tenant_id: &str, ) -> Result<Self, StorageError>
Connect to Postgres with a specific tenant ID for data isolation.
Applies the default pool size cap (DEFAULT_POOL_SIZE).
Sourcepub async fn connect_tenant_with_pool_size(
database_url: &str,
tenant_id: &str,
max_size: usize,
) -> Result<Self, StorageError>
pub async fn connect_tenant_with_pool_size( database_url: &str, tenant_id: &str, max_size: usize, ) -> Result<Self, StorageError>
Connect to Postgres with a specific tenant ID and an explicit pool
size cap (v2-M1). max_size is clamped to at least 1.
Sourcepub fn connect_tenant_blocking(
database_url: &str,
tenant_id: &str,
max_size: usize,
) -> Result<Self, StorageError>
pub fn connect_tenant_blocking( database_url: &str, tenant_id: &str, max_size: usize, ) -> Result<Self, StorageError>
Connect from synchronous code. Needs no async runtime, and also works when called from inside one.
Sourcepub fn for_tenant(&self, tenant_id: &str) -> Result<Self, StorageError>
pub fn for_tenant(&self, tenant_id: &str) -> Result<Self, StorageError>
A storage for another tenant on this storage’s connection pool, for a host that serves many tenants from one process. Every tenant opened this way shares the one pool, so the pool’s size caps the connections the process holds however many tenants it opens, and they share its TLS setup. Tenants stay apart as they do across processes: every row carries its tenant, and every query filters on it.
Cheap enough for a tenant’s first request: the schema was brought up to
date when this storage connected, so opening a tenant only stores its
default namespace if it has none. The new storage has its own sweep
lock and this storage’s GC grace period. Works from any thread, like the
rest of the storage API.
Sourcepub fn with_gc_grace(self, grace: Duration) -> Self
pub fn with_gc_grace(self, grace: Duration) -> Self
Set how recently written an unreachable object must be for a GC sweep
to spare it (default DEFAULT_GC_GRACE).
Writers don’t wait for a sweep here; the grace period protects them instead. A write stores its new objects before it commits them, and an object stored again refreshes its write time (at most a minute old after any write), so a sweep never takes an object a write in flight is about to commit. A sweep spares everything written since it started, whatever the grace. A grace under a minute narrows the protection for writes already in flight when a sweep starts; tests use zero to see garbage go at once.
Sourcepub fn pool_max_size(&self) -> usize
pub fn pool_max_size(&self) -> usize
Return the configured pool’s maximum size. Useful for tests.
Sourcepub fn tenant_pool(&self) -> TenantPool
pub fn tenant_pool(&self) -> TenantPool
The storage’s connection pool, for its tenant: configured as for the
storage itself (TLS, pool size), with every query recorded as a
database span, and every connection it hands out has the tenant set
(TENANT_SETTING). For a host that keeps tables of its own in the
same database: scope their rows by the tenant all the same, add the
tenant policy to each (add_tenant_policy) so row-level security
covers them, and use the pool inside PostgresStorage::run, so a
connection it opens is driven by the storage’s runtime like the
storage’s own, not by a caller’s runtime that may be gone when the
connection is reused. Take the pool before handing the storage to a
Repository. Create the tables in a transaction holding an advisory
lock (pg_advisory_xact_lock): CREATE TABLE IF NOT EXISTS from two
processes at once can still fail on Postgres’s catalog index. The
client crates are re-exported as
agentstategraph_storage::{oxtel_sql, tokio_postgres}.
Sourcepub fn pool(&self) -> Pool
👎Deprecated since 1.5.0: use tenant_pool(): a connection from pool() carries whichever tenant used it last, so row-level security can’t back up its queries
pub fn pool(&self) -> Pool
use tenant_pool(): a connection from pool() carries whichever tenant used it last, so row-level security can’t back up its queries
The storage’s connection pool, raw: its connections don’t set a tenant, so one carries whichever tenant used it last, and row-level security can’t back up a query on it.
Sourcepub fn row_security(&self) -> Result<RowSecurity, StorageError>
pub fn row_security(&self) -> Result<RowSecurity, StorageError>
Where row-level security stands in the storage’s schema, table by table, and whether this connection’s role skips it.
Sourcepub fn set_row_security(&self, on: bool) -> Result<RowSecurity, StorageError>
pub fn set_row_security(&self, on: bool) -> Result<RowSecurity, StorageError>
Switch row-level security on or off for every table in the storage’s
schema that has the tenant policy, AgentStateGraph’s and a host’s
alike, and return where it then stands. On means enabled and forced,
so it binds the tables’ owner too: a statement sees and writes only
the rows of its connection’s tenant (TENANT_SETTING), a backstop
behind every query’s own tenant filter.
It’s off until switched on, per database. Every connection the storage
checks out already has its tenant set, so the processes using the
database needn’t restart. It doesn’t cover a superuser or a role with
BYPASSRLS (see RowSecurity::role_bypasses), so connect as a role
with neither; nor a connection from the deprecated
pool.
Run it as the role that owns the tables. It locks each table briefly,
under the schema setup lock, and gives up if it waits 10 seconds for
one. With it on, pg_dump run as the tables’ owner fails rather than
dump only some rows: dump as a superuser or a role with BYPASSRLS.
Sourcepub fn run<F, T>(f: F) -> T
pub fn run<F, T>(f: F) -> T
Run f to completion on the storage’s runtime (one per process), from
whatever kind of thread the caller is on: a plain thread, or a thread of
either kind of tokio runtime. Every synchronous storage method goes
through this; a host uses it with pool for its own
tables. (Before Plan D t-002 this assumed a multi-threaded tokio
runtime: plain threads panicked, as did single-threaded runtimes.)
Trait Implementations§
Source§impl CommitStore for PostgresStorage
impl CommitStore for PostgresStorage
Source§fn list_commits(
&self,
from: &ObjectId,
limit: usize,
) -> Result<Vec<Commit>, StorageError>
fn list_commits( &self, from: &ObjectId, limit: usize, ) -> Result<Vec<Commit>, StorageError>
The first-parent line in one recursive query, instead of one round trip per commit.
Source§fn list_commits_dag(
&self,
from: &ObjectId,
limit: usize,
) -> Result<CommitWalk, StorageError>
fn list_commits_dag( &self, from: &ObjectId, limit: usize, ) -> Result<CommitWalk, StorageError>
Every parent edge in one recursive query. UNION keeps each commit
once however many paths reach it, so merge-heavy histories stay
linear, and the walk stops once it has one commit more than limit
(which is how truncation is detected). Commits come out breadth
first; order within one generation is unspecified. Each parent is
looked up through LATERAL ... LIMIT 1, which keeps the step an index
lookup: given a plain join, the planner may hash the tenant’s whole
commit table instead.
Source§fn history_extract_batch(
&self,
batch_size: usize,
) -> Result<usize, StorageError>
fn history_extract_batch( &self, batch_size: usize, ) -> Result<usize, StorageError>
Fold the next commits into the history tables, as the SQLite backend
does, but ordered by the id of the transaction that wrote each commit
rather than by insertion order. With several writers, a commit can
become visible after a later-inserted one has already been folded, and
an insertion-order cursor would step past it for good. Only commits
whose transaction is older than every transaction still running are
read, so no commit can appear behind the cursor later. When commits
are waiting on an older transaction, this waits up to HISTORY_WAIT
for it to finish; a writing transaction that runs longer than that,
anywhere on the server, delays history until it ends.
Source§fn history_cursor(&self) -> Result<i64, StorageError>
fn history_cursor(&self) -> Result<i64, StorageError>
How many commits have been folded. (SQLite reports its last folded rowid; either way it only grows, and 0 means nothing is extracted.)
Source§fn history_gc_sweep(
&self,
roots: &[ObjectId],
batch: usize,
) -> Result<GcSweep, StorageError>
fn history_gc_sweep( &self, roots: &[ObjectId], batch: usize, ) -> Result<GcSweep, StorageError>
Mark everything reachable from roots, the current ref tips and the
pinned roots, then delete this tenant’s other objects in batches, each
its own transaction. Writers keep going meanwhile: whatever was written
since the sweep started, or within the grace period before it, is
spared, and each delete re-checks the write time, so an object stored
again mid-sweep stays. deleted_target can therefore exceed
objects_deleted.
Source§fn history_gc_lock_writers(&self) -> Result<(), StorageError>
fn history_gc_lock_writers(&self) -> Result<(), StorageError>
Take this tenant’s sweep lock, so two sweeps can’t run at once. Unlike
SQLite’s, it doesn’t hold writers off: the grace period keeps their
work safe (see PostgresStorage::with_gc_grace).
Source§fn history_gc_unlock_writers(&self, _commit: bool) -> Result<(), StorageError>
fn history_gc_unlock_writers(&self, _commit: bool) -> Result<(), StorageError>
Release the sweep lock. A sweep’s deletes are already committed batch
by batch, so commit changes nothing here.
Source§fn commit_state_roots_recent_first(&self) -> Result<Vec<ObjectId>, StorageError>
fn commit_state_roots_recent_first(&self) -> Result<Vec<ObjectId>, StorageError>
Newest first, by the order the commits’ transactions got ids (commits from before that was recorded come last, newest first by timestamp).
Source§fn store_totals(&self) -> Result<Option<StoreTotals>, StorageError>
fn store_totals(&self) -> Result<Option<StoreTotals>, StorageError>
This tenant’s object and commit counts, and the bytes its rows take in each table (before indexes and free space; the tables are shared with other tenants). Reads every row, so it is slow on a large store. This tenant’s objects and commits. The tables are shared by tenants, so there is no size of the tenant’s own to report.
Source§fn put_commit_traced(
&self,
commit: &Commit,
trace: Option<&CommitTrace>,
) -> Result<(), StorageError>
fn put_commit_traced( &self, commit: &Commit, trace: Option<&CommitTrace>, ) -> Result<(), StorageError>
commit and, when given, the trace it was made in. A backend
that can does both in one write, which matters on every commit; the
default stores one after the other.Source§fn set_commit_trace(
&self,
commit_id: &ObjectId,
trace: &CommitTrace,
) -> Result<(), StorageError>
fn set_commit_trace( &self, commit_id: &ObjectId, trace: &CommitTrace, ) -> Result<(), StorageError>
commit_id was made in. The first record for a
commit stands. Backends that don’t keep trace links ignore it.Source§fn get_commit_trace(
&self,
commit_id: &ObjectId,
) -> Result<Option<CommitTrace>, StorageError>
fn get_commit_trace( &self, commit_id: &ObjectId, ) -> Result<Option<CommitTrace>, StorageError>
commit_id was made in, if one was recorded.Source§fn all_commit_ids(&self) -> Result<Vec<ObjectId>, StorageError>
fn all_commit_ids(&self) -> Result<Vec<ObjectId>, StorageError>
Source§fn get_commit(&self, id: &ObjectId) -> Result<Option<Commit>, StorageError>
fn get_commit(&self, id: &ObjectId) -> Result<Option<Commit>, StorageError>
Source§fn put_commit(&self, commit: &Commit) -> Result<(), StorageError>
fn put_commit(&self, commit: &Commit) -> Result<(), StorageError>
Source§fn has_commit(&self, id: &ObjectId) -> Result<bool, StorageError>
fn has_commit(&self, id: &ObjectId) -> Result<bool, StorageError>
Source§fn history_undistilled_commit_count(&self) -> Result<i64, StorageError>
fn history_undistilled_commit_count(&self) -> Result<i64, StorageError>
0 means the
extractor is caught up, so every commit’s signal is distilled and the GC
can safely make historical state unmaterializable. Backends without
history report 0 (they have no distillation gate).Source§fn history_is_commit_distilled(
&self,
id: &ObjectId,
) -> Result<bool, StorageError>
fn history_is_commit_distilled( &self, id: &ObjectId, ) -> Result<bool, StorageError>
id’s commit has been folded into the history tables — i.e. its
position is at or before the extractor cursor. This is the “already
captured” predicate Plan B’s GC checks before pruning a commit’s raw
snapshot: a distilled commit’s signal survives in the metric tables.
Backends without history report false (nothing distilled → prune
nothing on this basis).Source§fn history_rollup(&self) -> Result<Vec<HistoryRollupRow>, StorageError>
fn history_rollup(&self) -> Result<Vec<HistoryRollupRow>, StorageError>
Source§fn history_milestones(
&self,
limit: usize,
) -> Result<Vec<HistoryMilestoneRow>, StorageError>
fn history_milestones( &self, limit: usize, ) -> Result<Vec<HistoryMilestoneRow>, StorageError>
limit.Source§fn history_retained_state_roots(&self) -> Result<Vec<ObjectId>, StorageError>
fn history_retained_state_roots(&self) -> Result<Vec<ObjectId>, StorageError>
Source§fn history_gc_reachability(
&self,
roots: &[ObjectId],
batch: usize,
) -> Result<GcReachability, StorageError>
fn history_gc_reachability( &self, roots: &[ObjectId], batch: usize, ) -> Result<GcReachability, StorageError>
roots (state roots) and report live
vs. total object counts — the GC reclaimable estimate (Plan B t-001). Read moreSource§fn gc_pin_root(&self, key: &str, root: &ObjectId) -> Result<(), StorageError>
fn gc_pin_root(&self, key: &str, root: &ObjectId) -> Result<(), StorageError>
root under key as reachable-but-uncommitted (an open
speculation’s base or working tree), so a GC sweep — in this process or
any other sharing the store — keeps every object it references.
Replaces any earlier root for key and refreshes its age.Source§fn gc_unpin_root(&self, key: &str) -> Result<(), StorageError>
fn gc_unpin_root(&self, key: &str) -> Result<(), StorageError>
gc_pin_root. A no-op
when absent.Source§fn gc_pinned_roots(
&self,
max_age: Duration,
) -> Result<Vec<ObjectId>, StorageError>
fn gc_pinned_roots( &self, max_age: Duration, ) -> Result<Vec<ObjectId>, StorageError>
max_age. Older pins belong to a
process that died with a speculation open, and stop protecting their
objects once they expire.Source§fn history_store_shape(&self) -> Result<StoreShape, StorageError>
fn history_store_shape(&self) -> Result<StoreShape, StorageError>
StoreShape.Source§fn history_unpin_legacy_milestones(&self) -> Result<usize, StorageError>
fn history_unpin_legacy_milestones(&self) -> Result<usize, StorageError>
Source§fn history_vacuum(&self) -> Result<VacuumStats, StorageError>
fn history_vacuum(&self) -> Result<VacuumStats, StorageError>
VACUUM — the sweep frees pages to the freelist, but the file only
shrinks after this. Reports bytes before/after. Backends without a file
report zeros.Source§impl EpochStore for PostgresStorage
impl EpochStore for PostgresStorage
Source§fn create_epoch(&self, epoch: &Epoch) -> Result<(), StorageError>
fn create_epoch(&self, epoch: &Epoch) -> Result<(), StorageError>
StorageError::Backend — the
repo layer is expected to guard uniqueness.Source§fn seal_epoch(
&self,
id: &str,
summary: &str,
sealed_at: DateTime<Utc>,
sealed_commits: &[ObjectId],
seal_hash: &ObjectId,
) -> Result<(), StorageError>
fn seal_epoch( &self, id: &str, summary: &str, sealed_at: DateTime<Utc>, sealed_commits: &[ObjectId], seal_hash: &ObjectId, ) -> Result<(), StorageError>
Sealed, stamp sealed_at,
record the seal summary, and persist the set of commits that
must remain reachable for seal-violation enforcement (V8).
Subsequent set_commit_epoch calls referencing this id must
fail with EpochAlreadySealed.
seal_hash is the tamper-evident digest over the sealed set; it is
persisted, not recomputed on read, so a later walk cannot quietly
produce a different answer than the one that was sealed.Source§fn assign_epoch_namespace(
&self,
id: &str,
namespace: &str,
) -> Result<bool, StorageError>
fn assign_epoch_namespace( &self, id: &str, namespace: &str, ) -> Result<bool, StorageError>
Source§fn list_epochs(&self) -> Result<Vec<Epoch>, StorageError>
fn list_epochs(&self) -> Result<Vec<Epoch>, StorageError>
Source§fn get_epoch(&self, id: &str) -> Result<Option<Epoch>, StorageError>
fn get_epoch(&self, id: &str) -> Result<Option<Epoch>, StorageError>
Source§fn archive_epoch(&self, id: &str) -> Result<(), StorageError>
fn archive_epoch(&self, id: &str) -> Result<(), StorageError>
Source§fn set_commit_epoch(
&self,
commit_id: &ObjectId,
epoch_id: &str,
) -> Result<(), StorageError>
fn set_commit_epoch( &self, commit_id: &ObjectId, epoch_id: &str, ) -> Result<(), StorageError>
Source§impl ObjectStore for PostgresStorage
impl ObjectStore for PostgresStorage
Source§fn batch_put_objects(
&self,
objs: &[Object],
) -> Result<Vec<ObjectId>, StorageError>
fn batch_put_objects( &self, objs: &[Object], ) -> Result<Vec<ObjectId>, StorageError>
One multi-row INSERT per chunk, all in one transaction: callers such as merge write a batch as a unit, and the trait’s default made one independent round trip per object.
Source§fn batch_get_objects(
&self,
ids: &[ObjectId],
) -> Result<Vec<Option<Object>>, StorageError>
fn batch_get_objects( &self, ids: &[ObjectId], ) -> Result<Vec<Option<Object>>, StorageError>
One query for the whole batch, results in the order asked.
Source§fn leaf_index_search(
&self,
namespace: &str,
ref_name: &str,
query_lower: &str,
limit: usize,
) -> Result<Option<Vec<(String, String)>>, StorageError>
fn leaf_index_search( &self, namespace: &str, ref_name: &str, query_lower: &str, limit: usize, ) -> Result<Option<Vec<(String, String)>>, StorageError>
Case-insensitive substring match. The trigram index serves it when
pg_trgm is installed; %, _ and \ in the query match themselves.
Source§fn get_object(&self, id: &ObjectId) -> Result<Option<Object>, StorageError>
fn get_object(&self, id: &ObjectId) -> Result<Option<Object>, StorageError>
Source§fn put_object(&self, obj: &Object) -> Result<ObjectId, StorageError>
fn put_object(&self, obj: &Object) -> Result<ObjectId, StorageError>
Source§fn leaf_index_is_built(
&self,
namespace: &str,
ref_name: &str,
) -> Result<bool, StorageError>
fn leaf_index_is_built( &self, namespace: &str, ref_name: &str, ) -> Result<bool, StorageError>
(namespace, ref) leaf set has been built.Source§fn leaf_index_build(
&self,
namespace: &str,
ref_name: &str,
entries: &[(String, String)],
) -> Result<(), StorageError>
fn leaf_index_build( &self, namespace: &str, ref_name: &str, entries: &[(String, String)], ) -> Result<(), StorageError>
(namespace, ref) with
entries and mark the set built. Called once, from the read path, the
first time a ref is searched after the feature is enabled.Source§fn leaf_index_apply(
&self,
namespace: &str,
ref_name: &str,
removed_paths: &[String],
added: &[(String, String)],
) -> Result<(), StorageError>
fn leaf_index_apply( &self, namespace: &str, ref_name: &str, removed_paths: &[String], added: &[(String, String)], ) -> Result<(), StorageError>
(namespace, ref), delete the rows
at removed_paths and insert added (path, value) rows. A no-op if
the set has not been built (the backfill will pick up the new state).
Called from the write path as a ref advances.Source§fn leaf_index_tracks_roots(&self) -> bool
fn leaf_index_tracks_roots(&self) -> bool
leaf_index_root,
leaf_index_build_at and
leaf_index_advance.Source§fn leaf_index_root(
&self,
namespace: &str,
ref_name: &str,
) -> Result<Option<ObjectId>, StorageError>
fn leaf_index_root( &self, namespace: &str, ref_name: &str, ) -> Result<Option<ObjectId>, StorageError>
(namespace, ref) set reflects. None when it
isn’t built, was built or changed without a root, or the backend
doesn’t record roots.Source§fn leaf_index_build_at(
&self,
namespace: &str,
ref_name: &str,
root: &ObjectId,
entries: &[(String, String)],
) -> Result<(), StorageError>
fn leaf_index_build_at( &self, namespace: &str, ref_name: &str, root: &ObjectId, entries: &[(String, String)], ) -> Result<(), StorageError>
Source§fn leaf_index_advance(
&self,
namespace: &str,
ref_name: &str,
from: &ObjectId,
to: &ObjectId,
removed_paths: &[String],
added: &[(String, String)],
) -> Result<bool, StorageError>
fn leaf_index_advance( &self, namespace: &str, ref_name: &str, from: &ObjectId, to: &ObjectId, removed_paths: &[String], added: &[(String, String)], ) -> Result<bool, StorageError>
from to the tree at to, by the leaf
diff between them, only if it is at from. Returns whether it moved.
A backend that doesn’t record roots applies the diff unconditionally,
as leaf_index_apply, and returns true.Source§fn has_object(&self, id: &ObjectId) -> Result<bool, StorageError>
fn has_object(&self, id: &ObjectId) -> Result<bool, StorageError>
Source§impl RefStore for PostgresStorage
impl RefStore for PostgresStorage
Source§fn create_namespace(&self, namespace: &Namespace) -> Result<(), StorageError>
fn create_namespace(&self, namespace: &Namespace) -> Result<(), StorageError>
NamespaceAlreadyExists if it already
exists — callers that want idempotent creation should check first or
ignore that variant.Source§fn list_namespaces(&self) -> Result<Vec<Namespace>, StorageError>
fn list_namespaces(&self) -> Result<Vec<Namespace>, StorageError>
Source§fn get_ref(
&self,
namespace: &Namespace,
name: &str,
) -> Result<Option<ObjectId>, StorageError>
fn get_ref( &self, namespace: &Namespace, name: &str, ) -> Result<Option<ObjectId>, StorageError>
NamespaceNotFound if the namespace doesn’t exist.Source§fn set_ref(
&self,
namespace: &Namespace,
name: &str,
target: ObjectId,
) -> Result<(), StorageError>
fn set_ref( &self, namespace: &Namespace, name: &str, target: ObjectId, ) -> Result<(), StorageError>
NamespaceNotFound if
the namespace hasn’t been created yet.Source§fn cas_ref(
&self,
namespace: &Namespace,
name: &str,
expected: ObjectId,
new: ObjectId,
) -> Result<bool, StorageError>
fn cas_ref( &self, namespace: &Namespace, name: &str, expected: ObjectId, new: ObjectId, ) -> Result<bool, StorageError>
expected.
Returns true if the swap succeeded, false if the current value
didn’t match expected. Returns NamespaceNotFound if the namespace
doesn’t exist.Source§fn create_ref(
&self,
namespace: &Namespace,
name: &str,
target: ObjectId,
) -> Result<bool, StorageError>
fn create_ref( &self, namespace: &Namespace, name: &str, target: ObjectId, ) -> Result<bool, StorageError>
true if
it was created, false if one already existed (left untouched).
Returns NamespaceNotFound if the namespace doesn’t exist. Read moreSource§fn cas_delete_ref(
&self,
namespace: &Namespace,
name: &str,
expected: ObjectId,
) -> Result<bool, StorageError>
fn cas_delete_ref( &self, namespace: &Namespace, name: &str, expected: ObjectId, ) -> Result<bool, StorageError>
expected. Returns true if
it was deleted, false if it was absent or pointed elsewhere.
Returns NamespaceNotFound if the namespace doesn’t exist. Read moreSource§fn list_refs(
&self,
namespace: &Namespace,
prefix: &str,
) -> Result<Vec<(String, ObjectId)>, StorageError>
fn list_refs( &self, namespace: &Namespace, prefix: &str, ) -> Result<Vec<(String, ObjectId)>, StorageError>
namespace whose name starts with prefix.
Returns NamespaceNotFound if the namespace doesn’t exist.Source§fn delete_ref(
&self,
namespace: &Namespace,
name: &str,
) -> Result<bool, StorageError>
fn delete_ref( &self, namespace: &Namespace, name: &str, ) -> Result<bool, StorageError>
true if the ref existed. Returns
NamespaceNotFound if the namespace doesn’t exist.Source§fn delete_namespace(&self, namespace: &Namespace) -> Result<bool, StorageError>
fn delete_namespace(&self, namespace: &Namespace) -> Result<bool, StorageError>
true if the namespace
existed and was deleted, false if it was not found. The “default”
namespace cannot be deleted and returns InvalidOperation.Source§impl ReminderStore for PostgresStorage
impl ReminderStore for PostgresStorage
Source§fn update_if_unchanged(
&self,
expected: &Reminder,
new: &Reminder,
) -> Result<bool, ReminderError>
fn update_if_unchanged( &self, expected: &Reminder, new: &Reminder, ) -> Result<bool, ReminderError>
Compare and write in one transaction with the row locked, so no other writer can change the reminder in between. The trait’s default compared and wrote separately: six racing updates from one snapshot all “won”.
Source§fn save(&self, reminder: &Reminder) -> Result<(), ReminderError>
fn save(&self, reminder: &Reminder) -> Result<(), ReminderError>
id field is already populated by
CreateReminder::into_reminder().Source§fn update(&self, reminder: &Reminder) -> Result<(), ReminderError>
fn update(&self, reminder: &Reminder) -> Result<(), ReminderError>
Source§fn delete(&self, id: &str) -> Result<bool, ReminderError>
fn delete(&self, id: &str) -> Result<bool, ReminderError>
update with status: Cancelled).Source§fn list(&self, filter: &ReminderFilter) -> Result<Vec<Reminder>, ReminderError>
fn list(&self, filter: &ReminderFilter) -> Result<Vec<Reminder>, ReminderError>
filter, ordered by priority then
due_at ascending.Source§impl SessionStore for PostgresStorage
impl SessionStore for PostgresStorage
Source§fn create_session(&self, session: &Session) -> Result<(), StorageError>
fn create_session(&self, session: &Session) -> Result<(), StorageError>
Source§fn end_session(
&self,
id: &str,
status: SessionStatus,
ended_at: DateTime<Utc>,
) -> Result<(), StorageError>
fn end_session( &self, id: &str, status: SessionStatus, ended_at: DateTime<Utc>, ) -> Result<(), StorageError>
ended_at.Source§fn list_sessions(
&self,
agent_filter: Option<&str>,
) -> Result<Vec<Session>, StorageError>
fn list_sessions( &self, agent_filter: Option<&str>, ) -> Result<Vec<Session>, StorageError>
Source§fn get_session(&self, id: &str) -> Result<Option<Session>, StorageError>
fn get_session(&self, id: &str) -> Result<Option<Session>, StorageError>
Source§fn set_commit_session(
&self,
commit_id: &ObjectId,
session_id: &str,
) -> Result<(), StorageError>
fn set_commit_session( &self, commit_id: &ObjectId, session_id: &str, ) -> Result<(), StorageError>
Source§impl TaintStore for PostgresStorage
impl TaintStore for PostgresStorage
Source§fn create_taint(&self, taint: &Taint) -> Result<(), StorageError>
fn create_taint(&self, taint: &Taint) -> Result<(), StorageError>
(path, name, kind) uniqueness invariant among unresolved
rows — re-creating a resolved taint with the same triple is
allowed (the old one stays as an audit row).Source§fn resolve_taint(
&self,
id: &str,
resolved_by: &str,
reason: &str,
proof: Option<&str>,
resolved_at: DateTime<Utc>,
) -> Result<(), StorageError>
fn resolve_taint( &self, id: &str, resolved_by: &str, reason: &str, proof: Option<&str>, resolved_at: DateTime<Utc>, ) -> Result<(), StorageError>
id as resolved. Returns
StorageError::Backend (wrapping AlreadyResolved) if the
record is already resolved.Source§fn list_taints(
&self,
path_prefix: Option<&str>,
kind: Option<TaintKind>,
include_resolved: bool,
) -> Result<Vec<Taint>, StorageError>
fn list_taints( &self, path_prefix: Option<&str>, kind: Option<TaintKind>, include_resolved: bool, ) -> Result<Vec<Taint>, StorageError>
Source§fn check_taint(&self, request_path: &str) -> Result<Vec<Taint>, StorageError>
fn check_taint(&self, request_path: &str) -> Result<Vec<Taint>, StorageError>
path matches request_path exactly OR whose path is a
propagating ancestor of request_path. The caller feeds the
result into agentstategraph_taint::evaluate_access.Source§fn get_taint(&self, id: &str) -> Result<Option<Taint>, StorageError>
fn get_taint(&self, id: &str) -> Result<Option<Taint>, StorageError>
None if missing.Source§fn set_taint_commit_id(
&self,
id: &str,
commit_id: &str,
) -> Result<(), StorageError>
fn set_taint_commit_id( &self, id: &str, commit_id: &str, ) -> Result<(), StorageError>
commit_id onto a freshly-inserted taint
after the repository has written the intent commit. A no-op
if the taint is already resolved.