The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix: exclude stale coverage-only sources
Steven Enamakelf9a14177a56e
diff --git a/crates/openhuman-core/src/flows/types.rs b/crates/openhuman-core/src/flows/types.rsdeleted file mode 100644index 92a47a235c..0000000000--- a/crates/openhuman-core/src/flows/types.rs+++ /dev/null@@ -1,493 +0,0 @@-//! The [`Flow`] entity: a saved automation workflow definition.-//!-//! Wraps `tinyflows::model::WorkflowGraph` with the metadata OpenHuman needs to-//! store, list, and track runs for a saved flow. The graph itself is the-//! portable, tinyflows-owned contract (validated + migrated on load); this-//! struct is the OpenHuman-side record around it.--use serde::{Deserialize, Serialize};-use serde_json::Value;-use tinyflows::model::WorkflowGraph;--/// How a flow run was started. Stamped onto the run's Langfuse trace as a-/// `trigger:<kind>` tag plus `trigger` metadata so runs can be filtered by-/// origin in the Langfuse UI.-#[derive(Debug, Clone, Copy, PartialEq, Eq)]-pub enum FlowRunTrigger {- /// An explicit run request over RPC/CLI (the Workflows UI "Run" button).- Rpc,- /// A `FlowScheduleTick` cron dispatch (`schedule` trigger node).- Schedule,- /// A `ComposioTriggerReceived` dispatch (`app_event` trigger node).- AppEvent,- /// A human-in-the-loop resume of a paused run (`flows_resume`).- Resume,-}--impl FlowRunTrigger {- /// Stable snake_case identifier used in Langfuse tags/metadata.- pub fn as_str(&self) -> &'static str {- match self {- FlowRunTrigger::Rpc => "rpc",- FlowRunTrigger::Schedule => "schedule",- FlowRunTrigger::AppEvent => "app_event",- FlowRunTrigger::Resume => "resume",- }- }-}--/// The result of validating a candidate `tinyflows` graph without persisting-/// it — returned by `openhuman.flows_validate` (PHASE 3c) and used to surface-/// structural errors and non-fatal warnings (e.g. "this trigger kind never-/// fires automatically yet") to an authoring surface *before* a flow is saved.-///-/// A graph is `valid` when it passes `tinyflows::validate::validate_all` after-/// migration; `errors` carries **every** structural error when it does not (a-/// pre-validation failure — unparseable JSON or an unmigrateable schema — is-/// still a single entry). `warnings` is orthogonal to validity — a `valid`-/// graph can still carry warnings (it saves and enables fine, it just won't-/// behave as an author might expect), and an invalid graph reports no warnings-/// (there's nothing to warn about a graph that won't compile).-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]-pub struct FlowValidation {- /// True when the graph is structurally valid (migrates + validates).- pub valid: bool,- /// Human-readable structural validation errors (empty when `valid`). As of- /// the multi-error work this carries **all** independent structural- /// problems in one pass — an author fixing five costs one validate call,- /// not five round-trips. See [`FlowValidation::error_details`] for the- /// machine-readable, per-node form.- pub errors: Vec<String>,- /// Structured, machine-readable counterpart to [`FlowValidation::errors`]:- /// one entry per structural error, carrying a stable `code`, the anchoring- /// `node_id` when node-specific, and the human `message`. Additive and- /// `#[serde(default)]` so existing clients that only read `errors` are- /// unaffected; agent tools and richer UIs consume this to attach errors to- /// the right node and switch on `code`.- #[serde(default, skip_serializing_if = "Vec::is_empty")]- pub error_details: Vec<FlowValidationError>,- /// Non-fatal warnings: the graph is accepted, but something about it is- /// worth flagging (e.g. an unfired trigger kind). Never blocks save/enable.- pub warnings: Vec<String>,-}--/// A single structural validation error in machine-readable form — the-/// structured counterpart to a [`FlowValidation::errors`] string.-///-/// Mirrors `tinyflows::error::ValidationError` (via its `code()` / `node_id()`-/// accessors) so a host surface can attach the error to a specific node and-/// switch on a stable `code` rather than parsing the `message`. `field` is-/// reserved for future config-level errors that can name the offending config-/// key; it is `None` for today's graph/edge-level checks.-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]-pub struct FlowValidationError {- /// Stable, machine-readable identifier for the error kind (e.g.- /// `missing_trigger`, `unknown_node`, `invalid_condition_routing`).- pub code: String,- /// Human-readable description — identical to the matching- /// [`FlowValidation::errors`] string.- pub message: String,- /// The node id this error is anchored to, when node-specific; `None` for- /// graph-wide errors (missing trigger, schema-too-new, multiple triggers).- #[serde(default, skip_serializing_if = "Option::is_none")]- pub node_id: Option<String>,- /// The offending config field, when the error is config-key-specific.- /// Reserved for future use; `None` today.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub field: Option<String>,-}--/// The result of importing a workflow definition (native tinyflows JSON or an-/// n8n export) via `openhuman.flows_import` (PHASE 4d) — the normalized,-/// migrated + validated [`WorkflowGraph`] plus any non-fatal import warnings-/// (unmapped n8n node types, untranslated expressions, a synthesized/demoted-/// trigger, …).-///-/// **Import never persists.** This is the same contract as-/// [`FlowValidation`]: the graph comes back ready for the editable canvas as a-/// *draft*, and only the user's explicit Save (the existing `flows_create`-/// gate) writes it. A structurally invalid graph is reported as an `Err` on the-/// RPC (validation is authoritative), not as an `FlowImport` with `valid:-/// false` — there is no partial-import row.-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]-pub struct FlowImport {- /// The normalized workflow graph, migrated to the current schema and- /// structurally validated. Ready to open on the canvas as an unsaved draft.- pub graph: WorkflowGraph,- /// Non-fatal import warnings surfaced next to the draft. Empty for a clean- /// native import; an n8n import populates it with any approximations made.- pub warnings: Vec<String>,-}--/// A snapshot of a flow's graph captured just before an update overwrote it —-/// the safety rail behind `flows_rollback` / `get_flow_history` (audit F6).-///-/// Rows live in the `flow_revisions` table, capped (e.g. last 20 per flow).-/// `graph` is the prior graph as raw JSON so a snapshot never fails to load-/// even if the schema later evolves.-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]-pub struct FlowRevision {- /// Stable revision id (UUID).- pub id: String,- /// The flow this snapshot belongs to.- pub flow_id: String,- /// The flow's graph at the time this revision was captured (raw JSON).- pub graph: Value,- /// The flow's name at capture time.- pub name: String,- /// The flow's `require_approval` at capture time.- pub require_approval: bool,- /// RFC3339 time the snapshot was captured (i.e. when it was superseded).- pub created_at: String,-}--/// Where a [`FlowDraft`] came from — carried through so the UI can label a-/// draft and the agent can reason about it.-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]-#[serde(rename_all = "snake_case")]-pub enum DraftOrigin {- /// Created from a chat/copilot build turn.- Chat,- /// Created from the canvas (e.g. "new workflow", or an accepted proposal).- Canvas,- /// Created from an import (native tinyflows JSON or an n8n export).- Import,-}--impl DraftOrigin {- /// The serde wire discriminator, for logging.- pub fn as_str(&self) -> &'static str {- match self {- Self::Chat => "chat",- Self::Canvas => "canvas",- Self::Import => "import",- }- }-}--/// A durable, core-managed **draft** of a workflow graph — the shared working-/// copy the agent tools and the canvas both read/write across turns and reloads-/// (audit F5).-///-/// Stored as a plain JSON file on disk (`{workspace_dir}/flows/drafts/<id>.json`),-/// not in SQLite — trivially inspectable and deletable, no schema/migration.-/// A draft is **never live**: promoting it (`flows_draft_promote`) runs the-/// existing `flows_create`/`flows_update` gates (same forced `require_approval`-/// floor, same human-in-the-loop) and removes the file. `graph` is a raw JSON-/// value (not a typed `WorkflowGraph`) because a work-in-progress draft is-/// explicitly allowed to be incomplete or not-yet-valid.-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]-pub struct FlowDraft {- /// Stable draft id (UUID). Distinct from any `flow_id`.- pub id: String,- /// The saved flow this draft edits, if any. `None` for a from-scratch draft- /// (promote → `flows_create`); `Some` for an edit of an existing flow- /// (promote → `flows_update`).- #[serde(default, skip_serializing_if = "Option::is_none")]- pub flow_id: Option<String>,- /// Human-readable name carried into the flow on promote.- pub name: String,- /// The work-in-progress graph as raw JSON (may be incomplete/invalid).- pub graph: Value,- /// Where the draft originated.- pub origin: DraftOrigin,- /// RFC3339 creation time.- pub created_at: String,- /// RFC3339 last-update time.- pub updated_at: String,-}--/// A saved automation workflow: a `tinyflows` graph plus OpenHuman-side-/// bookkeeping (enablement, run history summary).-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct Flow {- /// Stable identifier (UUID) for this flow.- pub id: String,- /// Human-readable name shown in the Workflows UI.- pub name: String,- /// One line saying what this automation is *for*, authored by whoever- /// built it.- ///- /// Lives here rather than on `tinyflows::model::WorkflowGraph` for the- /// same reason [`Flow::name`] does: it is catalogue metadata about a saved- /// automation, not part of the executable graph, and the engine never- /// reads it. Keeping it host-side also means the vendored crate does not- /// have to change for a field only this catalogue consumes.- ///- /// Empty is a real and common state — every flow saved before this field- /// existed has one, and the builder does not force a description. Readers- /// must handle that rather than rendering a blank line;- /// `flows::catalogue` falls back to describing the graph's shape.- #[serde(default)]- pub description: String,- /// Whether this flow may currently be triggered (B2) / run.- pub enabled: bool,- /// The validated, migrated workflow graph.- pub graph: WorkflowGraph,- /// RFC3339 creation timestamp.- pub created_at: String,- /// RFC3339 last-update timestamp.- pub updated_at: String,- /// RFC3339 timestamp of the most recent run, if any.- pub last_run_at: Option<String>,- /// Outcome of the most recent run: `"completed"` | `"pending_approval"` | `"failed"`.- pub last_status: Option<String>,- /// "Require approval for outbound actions" (issue B2). When `true`, the- /// approval gate does NOT auto-allow this flow's `TrustedAutomation- /// { Workflow }` trust root — every external_effect tool/HTTP call the- /// flow makes still parks for a real decision, regardless of how the run- /// was triggered. See `crates/openhuman-core/src/security/approval/gate.rs` and- /// `crates/openhuman-core/src/agent/turn_origin.rs::TrustedAutomationSource::Workflow`.- #[serde(default)]- pub require_approval: bool,-}--/// One step of a persisted [`FlowRun`] (run-history inspector).-///-/// As of issue G2 (live run observation) these are persisted **incrementally**-/// as each non-trigger node finishes, by-/// `flows::observability::FlowRunObserver::on_step_finish`, which maps a live-/// `tinyflows::observability::ExecutionStep` (carrying real `status` +-/// `duration_ms`) onto this type. The prior post-hoc reconstruction from-/// `RunOutcome.output["nodes"]` (see `flows::ops::reconstruct_steps`) now only-/// fills in steps the observer missed (e.g. a trigger node, which does not-/// emit an `on_step_finish`) — those carry no `status`/`duration_ms` and keep-/// the `port` the reconstruction recovers.-#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]-pub struct FlowRunStep {- /// The node's id within the flow's graph.- pub node_id: String,- /// The node's emitted items for this run (`output["nodes"][id]["items"]`,- /// or the live `ExecutionStep.output` when observed incrementally).- pub output: serde_json::Value,- /// The output port the node routed on, if it picked one (branching /- /// switch nodes) — `output["nodes"][id]["port"]`. Only recovered by the- /// post-hoc reconstruction; the live observer does not carry a port.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub port: Option<String>,- /// Live step outcome, when this step was observed incrementally:- /// `"success"` | `"error"`. `None` for a step recovered post-hoc.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub status: Option<String>,- /// Wall-clock duration of the node's executor in milliseconds, when- /// observed incrementally. `None` for a step recovered post-hoc.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub duration_ms: Option<u64>,- /// Data-binding diagnostics from the engine: each config `=`-expression- /// that resolved to `null` during this step, as- /// `{ "location": "args.to", "expression": "=item.to" }`. Lets the run- /// view point at the exact unresolved wiring. Empty for clean steps and- /// for steps recovered post-hoc.- #[serde(default, skip_serializing_if = "Vec::is_empty")]- pub diagnostics: Vec<serde_json::Value>,-}--/// A resolvable connection the flows UI / agent picker can attach to a node's-/// `connection_ref`. Aggregated by `openhuman.flows_list_connections` from two-/// host-side sources:-///-/// - **Composio connected accounts** (`kind = "composio"`) — each active OAuth-/// integration instance, emitted as a ready-to-use-/// `"composio:<toolkit>:<connection_id>"` ref (the exact shape-/// `tinyflows::caps::composio_connection_id` parses back on execution).-/// - **Named HTTP credentials** (`kind = "http"`) — each stored injection-/// template, emitted as `"http_cred:<name>"` (the shape-/// `tinyflows::caps::http_cred_name` parses).-///-/// **Security contract:** carries only non-secret identity — the-/// `connection_ref` string plus a display label (and toolkit/scheme hints).-/// It NEVER carries secret material (OAuth tokens, bearer tokens, passwords,-/// API keys). Those stay server-side and are injected only inside the-/// `tinyflows::caps` adapters at execution time.-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]-pub struct FlowConnection {- /// The ready-to-use `connection_ref` value to stamp onto a node:- /// `"composio:<toolkit>:<connection_id>"` or `"http_cred:<name>"`.- pub connection_ref: String,- /// Source kind: `"composio"` | `"http"`.- pub kind: String,- /// Human-readable label for the picker, e.g. `"Gmail · [email protected]"`- /// or `"stripe (bearer)"`. Never contains secret material.- pub display: String,- /// Composio toolkit slug (`kind = "composio"` only), e.g. `"gmail"`.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub toolkit: Option<String>,- /// HTTP credential injection scheme (`kind = "http"` only):- /// `"bearer"` | `"basic"` | `"header"`. Not a secret.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub scheme: Option<String>,- /// The connected account's own platform user id (`kind = "composio"`- /// only), e.g. Slack's `"U123ABC"` — resolved from the provider profile- /// synced via `SLACK_TEST_AUTH`/auth.test on connection sync (see- /// `memory_sync::composio::providers::profile::load_connected_identities`).- /// Non-secret identity metadata: lets the workflow builder wire a- /// self-targeted action (e.g. "DM me") to the user's own account instead- /// of guessing a public channel. `None` when no identity has synced yet.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub platform_user_id: Option<String>,-}--/// A persisted record of one `flows_run` / `flows_resume` invocation, for the-/// B3 run-history inspector. Written by `flows::store` from `flows::ops`.-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct FlowRun {- /// Stable identifier for this run — the same value as `thread_id` (the- /// tinyflows checkpointer key), so a run row can be found either way.- pub id: String,- /// The flow this run belongs to.- pub flow_id: String,- /// The tinyflows checkpointer thread id (needed to `flows_resume`).- pub thread_id: String,- /// Run status. Not an enum (kept a free-form `String` for forward-compat- /// with statuses added by newer builds), but the vocabulary is fixed:- /// `"running"` | `"completed"` | `"completed_with_warnings"` |- /// `"pending_approval"` | `"failed"` | `"cancelled"` (issue G4 — a run- /// cancelled via `flows_cancel_run`, or a parked `pending_approval` run- /// swept by the TTL expiry) | `"interrupted"` (bug B42 — a run whose future- /// was dropped mid-flight, reconciled either by the in-process- /// `RunRowFinalizer` drop-guard or the boot-time orphan sweep, so a- /// cancelled/timed-out/crashed run always settles to a terminal row instead- /// of wedging at `running`). `"completed_with_warnings"` (run honesty,- /// PR2) is a terminal status like `"completed"`, but at least one settled- /// [`FlowRunStep`] carries non-empty `diagnostics` (a `=`-binding that- /// resolved to `null`) even though no step outright errored. All of- /// `completed` / `completed_with_warnings` / `failed` / `cancelled` /- /// `interrupted` are terminal.- pub status: String,- /// RFC3339 timestamp when the run started.- pub started_at: String,- /// RFC3339 timestamp when the run last settled — stamped for every terminal- /// status (completed/paused/failed/cancelled/`"interrupted"`; the B42- /// drop-guard and boot sweep stamp it exactly like a normal terminal- /// write). `None` only while a run row is still `"running"`.- pub finished_at: Option<String>,- /// Reconstructed per-node steps (see [`FlowRunStep`]).- #[serde(default)]- pub steps: Vec<FlowRunStep>,- /// Node ids paused awaiting human approval when `status ==- /// "pending_approval"`; empty otherwise.- #[serde(default)]- pub pending_approvals: Vec<String>,- /// Human-readable failure reason. Set when `status == "failed"`, and also- /// when `status == "interrupted"` (bug B42) — there it carries the- /// reconciliation reason (tool abort / chat turn end / app restart) so the- /// run-details sidebar can explain *why* the run stopped instead of- /// rendering a bare terminal state.- #[serde(default)]- pub error: Option<String>,- /// Content hash of the graph this run was executing when it parked at- /// `status == "pending_approval"` (T-M1 — stale-approval guard). `None`- /// for a run that never parked, or for a row written before this pin- /// existed (a legacy `pending_approval` row) — `flows_resume` treats a- /// `None` on a currently-parked row as "unknown, allow with a warning"- /// rather than a hard refusal, so upgrading mid-park cannot strand an- /// in-flight approval. See `flows::ops::compute_graph_hash` and- /// `flows_resume`'s doc for the full mechanics.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub graph_hash: Option<String>,-}--/// Lifecycle status of a [`FlowSuggestion`] discovery card.-///-/// A freshly discovered suggestion starts `New`. The user can `Dismiss` it (it-/// stays persisted so a later discovery run can dedupe against it and won't-/// re-surface a rejected idea) or act on it — once the suggestion's flow is-/// actually saved via `flows_create`, the frontend marks it `Built`.-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]-#[serde(rename_all = "snake_case")]-#[derive(Default)]-pub enum SuggestionStatus {- /// Freshly discovered, awaiting the user's decision. The default.- #[default]- New,- /// The user dismissed the card; kept for dedupe, never re-surfaced.- Dismissed,- /// The user built (saved) a flow from this suggestion.- Built,-}--impl SuggestionStatus {- /// The stable lowercase token persisted in SQLite / crossed over RPC.- pub fn as_str(self) -> &'static str {- match self {- Self::New => "new",- Self::Dismissed => "dismissed",- Self::Built => "built",- }- }-- /// Parse a persisted/RPC token back into a status. Unknown tokens fall- /// back to [`SuggestionStatus::New`] (forward-compatible with any status a- /// newer build might persist), so a stale row never hard-errors a read.- pub fn from_str_lossy(s: &str) -> Self {- match s {- "dismissed" => Self::Dismissed,- "built" => Self::Built,- _ => Self::New,- }- }-}--/// A concrete, buildable workflow idea proposed by the `flow_discovery` agent-/// (the "Flow Scout"). Persisted to the `flow_suggestions` table and surfaced-/// as a card in the Flows page "Suggested for you" section.-///-/// **Not a graph.** A suggestion is a *pitch* the user can accept, not a-/// validated [`WorkflowGraph`]. Its [`Self::build_prompt`] is the natural-language-/// brief handed to the `workflow_builder` agent when the user clicks "Build-/// this"; that agent turns it into a real graph proposal for the user to save.-/// This keeps the discovery agent read-only and the authoring pipeline unchanged.-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]-pub struct FlowSuggestion {- /// Stable identifier (a content hash of the normalized title, so re-running- /// discovery dedupes identical ideas rather than piling duplicates).- pub id: String,- /// Short, human-friendly title, e.g. `"Auto-file email receipts"`.- pub title: String,- /// One-sentence description of what the workflow would do, e.g.- /// `"When a Gmail receipt arrives, add a row to your expenses sheet."`- pub one_liner: String,- /// Why this is being suggested to *this* user — grounded in what the agent- /// observed (a recurring thread, a stated goal in memory, a connected app),- /// e.g. `"You forward receipts to yourself most weeks."`- pub rationale: String,- /// Which trigger the workflow would likely use, as a hint for the card and- /// the builder: `"schedule"` | `"app_event"` | `"manual"` (free-form; only- /// those three self-fire in this host).- #[serde(default, skip_serializing_if = "Option::is_none")]- pub trigger_hint: Option<String>,- /// Plain-language outline of the steps, one per element, e.g.- /// `["Watch Gmail for receipts", "Extract amount + vendor", "Append a Sheet row"]`.- #[serde(default)]- pub steps_outline: Vec<String>,- /// `connection_ref` values the agent grounded against real- /// `flows_list_connections` output (never invented), so the card can show- /// "uses your Gmail" and the builder can stamp them verbatim.- #[serde(default)]- pub suggested_connections: Vec<String>,- /// Real Composio action slugs the agent grounded via `search_tool_catalog`- /// (never hallucinated). Empty when the workflow is HTTP/agent-only.- #[serde(default)]- pub suggested_slugs: Vec<String>,- /// The natural-language brief handed to `workflow_builder` on "Build this".- /// Self-contained: trigger + steps + connections, enough for the builder to- /// author a graph without re-deriving the idea.- pub build_prompt: String,- /// Agent's self-rated confidence in `[0.0, 1.0]` that this is a genuinely- /// useful, buildable automation for the user — used to rank cards.- #[serde(default)]- pub confidence: f64,- /// Lifecycle status (see [`SuggestionStatus`]).- #[serde(default)]- pub status: SuggestionStatus,- /// RFC3339 timestamp when the suggestion was first discovered.- pub created_at: String,- /// The `flows_discover` run that produced this suggestion (correlation for- /// observability); `None` for suggestions authored outside a tracked run.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub source_run_id: Option<String>,-}--#[cfg(test)]-#[path = "types_tests.rs"]-mod tests;diff --git a/scripts/ci/coverage-presence-allowlist.txt b/scripts/ci/coverage-presence-allowlist.txtindex acb3a8c584..15f2162aef 100644--- a/scripts/ci/coverage-presence-allowlist.txt+++ b/scripts/ci/coverage-presence-allowlist.txt@@ -36,3 +36,10 @@ crates/openhuman-core/src/desktop/accessibility/helper/swift_focus.rscrates/openhuman-core/src/desktop/accessibility/helper/swift_paste.rscrates/openhuman-core/src/desktop/accessibility/helper/swift_ax_actions.rscrates/openhuman-core/src/desktop/accessibility/helper/swift_overlay.rs++# Medulla is deliberately not forwarded by the desktop product: it is a+# library/TUI-facing integration whose network client must not be compiled into+# the shipped Tauri app. `openhuman-embed` keeps the matching typed facade+# behind its `medulla` feature, so this Linux product-coverage lane cannot+# produce records for it.+crates/openhuman-embed/src/medulla.rs