Skip to main content

evolve_adapters/
signals.rs

1//! Signal types emitted by adapters' `parse_session`.
2
3use std::path::PathBuf;
4
5/// Whether a signal came from an explicit user grade or was inferred.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum SignalKind {
8    /// User explicitly graded the session (`evolve good/bad/thumbs`).
9    Explicit,
10    /// Inferred by the adapter from the session log.
11    Implicit,
12}
13
14/// One parsed signal ready to be persisted. The CLI layer attaches session_id
15/// and recorded_at before inserting into `evolve-storage`.
16#[derive(Debug, Clone, PartialEq)]
17pub struct ParsedSignal {
18    /// Explicit vs implicit source.
19    pub kind: SignalKind,
20    /// Short tag for the signal source (e.g., "tests_passed", "user_clear").
21    pub source: String,
22    /// Normalized score in `[0.0, 1.0]`.
23    pub value: f64,
24    /// Optional JSON payload. MUST NOT contain source code.
25    pub payload_json: Option<String>,
26}
27
28/// Session log material handed to an adapter's `parse_session`.
29#[derive(Debug, Clone)]
30pub enum SessionLog {
31    /// A path to a session transcript file (adapter decides how to read it).
32    Transcript(PathBuf),
33    /// A git commit SHA with optional project root (used by Aider post-commit hooks).
34    /// When `project_root` is `Some`, the Aider adapter will run any configured
35    /// `test-cmd` / `lint-cmd` in that directory to produce real signals.
36    GitCommit {
37        /// Commit SHA.
38        sha: String,
39        /// Project root for executing test/lint commands. `None` means
40        /// skip execution and emit only the baseline observation signal.
41        project_root: Option<PathBuf>,
42    },
43    /// A pre-parsed event payload (used by the proxy's Cursor fallback).
44    ProxyEvent(serde_json::Value),
45}