rightkit_agent_engine_protocol/traits.rs
1use crate::artifact::{ArtifactApproval, ArtifactRow, ArtifactVerdict};
2
3/// The persistence contract the gated `artifact_trust` tools (P2 A3) write through — the **only**
4/// path that stamps an artifact's trust-bearing fields (verdict, approvals, shippable).
5///
6/// Ported from `IArtifactTrustStore`. The C# interface uses nullable return types for
7/// "not found"; we use `Option<ArtifactRow>` here.
8pub trait ArtifactTrustStore {
9 /// Resolve an artifact by its id (across any session).
10 fn get_artifact(&self, id: &str) -> Option<ArtifactRow>;
11
12 /// Resolve an artifact by (session, path) — the convenience lookup for an agent's own output.
13 fn get_artifact_by_path(&self, session_id: &str, path: &str) -> Option<ArtifactRow>;
14
15 /// Stamp `verdict` onto the artifact (A3). The caller has already enforced juror≠producer;
16 /// the verdict's `bound_hash` is the artifact's current `content_hash` at call time.
17 fn attach_verdict(
18 &mut self,
19 artifact_id: &str,
20 verdict: ArtifactVerdict,
21 ) -> Option<ArtifactRow>;
22
23 /// Append a human-gate `approval` to the artifact. Runtime-only — never reached through
24 /// agent tool dispatch; this is the runtime's direct path.
25 fn record_approval(
26 &mut self,
27 artifact_id: &str,
28 approval: ArtifactApproval,
29 ) -> Option<ArtifactRow>;
30
31 /// Mark the artifact `shippable` (A3) — the finalize / shippable-intent signal later gates hang on.
32 fn finalize_artifact(&mut self, artifact_id: &str) -> Option<ArtifactRow>;
33}
34
35/// The single seam between thin drivers (CLI, UI, future remote client) and the runtime.
36///
37/// Ported from `ISessionConduit`. The C# interface uses `ValueTask` and `IAsyncEnumerable`
38/// which are .NET async primitives; in Rust these are replaced with trait method signatures
39/// using a generic event type. Concrete async implementations will use `tokio::sync` channels
40/// or similar — this trait defines the logical contract only (no async/futures here to keep
41/// this crate I/O-free).
42pub trait SessionConduit {
43 type Error: std::fmt::Debug;
44
45 /// Submit a command into the runtime. Thread-safe.
46 fn submit(&self, op: crate::op::Op) -> Result<(), Self::Error>;
47}