Skip to main content

Daemon

Struct Daemon 

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

The resident decision loop: owns the event log, the warm scorer, classifies, records.

Implementations§

Source§

impl Daemon

Source

pub fn open(db_path: impl Into<PathBuf>) -> Result<Self>

Open the daemon backed by the event log at db_path, creating parent dirs.

Source

pub fn apply_taint(&self, event: &TaintEvent)

Apply a taint transition to the session/file taint state.

Fed by the content-tool observation surface (Phase 6.2) and by reset policy. Pure state update — the decision path consults this; it never lets a model change it (spine: rules decide, model only explains).

Persist-then-apply: the transition is written to the durable, append-only taint stream first (so it survives a daemon restart via replay in open), then applied to live in-memory state. The persist is best-effort — a write failure is logged but never panics the daemon or drops protection for the current session; it only risks losing this taint across a future restart.

Segment G: the event’s source_id is redacted before both the persist and the apply. A source identifier is meant to be an identifier only, but a URL can carry a credential (https://u:tok@host/p, a colonless PAT-as-username, ?api_key=…). Normalizing at this single ingest boundary means the redacted form is the only one that ever reaches the append-only (unscrubbable) log row, the replayed state, the provenance trail, or an agent-facing reason.

Source

pub fn apply_write(&self, session: &str, path: &str, cwd: &Path)

Apply a file-write taint transition (V1.1): a tainted session wrote path, so a later reader of that path inherits the session’s taint through TaintEvent::WriteFile.

Gated on the effective policy for the writing session’s cwd — the same [provenance] enabled switch that arms the trifecta floor. With the guard off nothing is recorded: a path label would be inert state the operator explicitly disabled.

A clean session can propagate nothing, so its write is skipped outright (it would be a no-op transition): that keeps frequent benign edits out of the append-only taint stream instead of appending a no-op row per file. Beyond that this follows apply_taint exactly — persist, then apply — and carries no source_id, so there is nothing to redact (segment G). path is an identifier; write content never reaches this boundary.

Source

pub fn apply_read(&self, session: &str, path: &str, cwd: &Path)

Apply a file-read taint transition (V1.1): a session read path, and if an earlier tainted session labelled that path, the reader inherits the taint.

This is the consumer that makes write propagation mean anything — without it TaintEvent::WriteFile fills a map nothing reads, and “the agent exfiltrated what it learned by writing and re-reading a file” stays invisible. Same gating as apply_write: the policy of the reading session’s cwd decides, a clean path is skipped so ordinary reads never touch the append-only taint stream, and an already-tainted reader is a no-op.

Observation only: it never blocks, never enqueues, and never influences a verdict; path is an identifier and the file’s content is never read.

Source

pub fn is_session_tainted(&self, session: Option<&str>) -> bool

Whether the given session has been influenced by untrusted content. A None (untracked) session is reported as not tainted.

Source

pub fn session_provenance(&self, session: &str) -> Option<TaintSet>

The session’s accumulated provenance labels, if any — the in-process read the provenance trail (P6.4) will surface. Source identifiers are already redacted at ingest (see apply_taint), so callers and the eventual IPC view only ever see secret-free ids.

Source

pub fn provenance_trail(&self, cmd: &ProposedCommand) -> Vec<ProvStep>

Build the human-readable provenance trail for a command (P6.4): the session’s untrusted reads, then this command’s sensitive read → egress sink → the trifecta rule that fired. Identifiers only (no secret contents). This is the forensic chain the CLI/TUI renders on a held trifecta and the audit replay uses to reconstruct “everything descended from source X”.

Source

pub fn should_shutdown(&self) -> bool

Whether an authenticated shutdown has been accepted (serve loop should exit).

Source

pub fn kill_switch_engaged(&self) -> bool

Whether the panic kill-switch is currently engaged.

Source

pub fn snapshot_dir(&self) -> &Path

The directory snapshots are stored under.

Source

pub fn with_scorer(self, scorer: Box<dyn Scorer>) -> Self

Swap in a specific scorer (used by tests).

Source

pub fn scorer_name(&self) -> &str

The name of the active Tier-2 scorer backend.

Source

pub fn open_default() -> Result<Self>

Open the daemon at the default database path.

Source

pub fn with_mode(self, mode: Mode) -> Self

Set the operating mode (attended / unattended / notify).

Source

pub fn mode(&self) -> Mode

The current operating mode.

Source

pub fn decide(&self, cmd: &ProposedCommand) -> Verdict

Decide what to do with a proposed command.

Order: (1) load the effective policy (global ← repo) which may set the mode and risk threshold; (2) classify with the Tier-1 rule engine; (3) Tier-2 model — for the ambiguous band only, fill summary+risk and, in unattended mode, apply the graduated threshold (below → allow, at/above → deny); the model summarizes a catastrophic command for the hold card but never changes its decision; (4) apply policy allow/deny (never a catastrophic downgrade); (5) apply decision memory.

Security spine: rules classify; the model only explains and scores the ambiguous band, and its influence is escalation-only. Safe stays on the model-free fast path.

Source

pub fn handle(&self, cmd: ProposedCommand) -> Verdict

Handle one proposal: decide, snapshot if destructive+allowed, record, and — if held — enqueue it for approval. Returns the verdict.

Source

pub fn resolve_pending(&self, id: &str, decision: Decision) -> Result<bool>

Approve or deny a queued command by id: record the human decision (and, on allow, snapshot), then mark the queue entry resolved. The originating caller (MCP poll / shim) executes; this never runs the command itself.

A human may approve any class here — including catastrophic — which is the deliberate human override (the model never can). Returns whether the id was found in the queue.

Source

pub fn resolve(&self, resolution: &Resolution) -> Result<()>

Handle a human’s resolution of a held command: record the final decision and, if requested, remember it for this exact command in this repo.

Source

pub fn observe(&self, obs: &Observation) -> Result<()>

Record an observed filesystem change from the backstop watcher. Logged as agent = "fs-watch", decision Allow (it already happened) — its purpose is to keep the timeline and undo complete for actions that bypassed interception.

Source

pub fn record_shell(&self, cmd: &ProposedCommand) -> Result<()>

Record a shell command from a human shell session (passive recording, no AI-agent hook). Logged as agent = "shell", decision Allow — it is never blocked (the recorder is an audit/undo trail, not a gate). We classify it with the Tier-1 rules so the event carries the real class (a destructive command a DBA ran is flagged in the timeline and kintsugi report), and we snapshot destructive commands so kintsugi undo can recover a human’s mistake. The model never runs on this path.

The hard floor stays honest: this is an audit record of the past, not a gate. The “nothing un-warned” guarantee never applied to commands a human ran outside Kintsugi; the “tamper-evident record of everything” one does, which is exactly what this preserves.

Source

pub fn handle_request(&self, req: Request) -> Response

Dispatch an IPC request to its handler.

Source

pub fn log(&self) -> &EventLog

Borrow the underlying event log (read-only queries).

Auto Trait Implementations§

§

impl !Freeze for Daemon

§

impl !RefUnwindSafe for Daemon

§

impl !Sync for Daemon

§

impl !UnwindSafe for Daemon

§

impl Forget for Daemon

§

impl Move for Daemon

§

impl Send for Daemon

§

impl Unpin for Daemon

§

impl UnsafeUnpin for Daemon

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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<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