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
chore: files changed crates/openhuman-core/src/integrations/composio/contract/profile.rs,crates/open
Steven Enamakele96dbd3cbe14
diff --git a/crates/openhuman-core/src/integrations/composio/contract/profile.rs b/crates/openhuman-core/src/integrations/composio/contract/profile.rsdeleted file mode 100644index 5570dd5d00..0000000000--- a/crates/openhuman-core/src/integrations/composio/contract/profile.rs+++ /dev/null@@ -1,298 +0,0 @@-//! Who the user is on a connected account: the identifier kinds, how each one-//! is canonicalised, and what a loaded set of identities looks like.-//!-//! A provider hands back one [`ProviderUserProfile`] per connection. The engine-//! crate expands that into one facet row per identifier, so the self-identity-//! matcher can answer "is this message *from the user*?" with a-//! `(toolkit, kind, canonical value)` lookup rather than a fuzzy comparison.-//! [`IdentityKind`] is that matching axis and [`canonicalize`] is the routine-//! both sides of the comparison run.-//!-//! # Why canonicalisation is contract vocabulary-//!-//! Because equality of canonical forms is the matcher's *only* test. The value-//! is canonicalised once when a profile is persisted and again when a candidate-//! identifier is checked against it — no `COLLATE NOCASE`, no per-call-//! lowercasing. If the writer and the reader ran two different implementations-//! of that routine, the matcher would fail open: a user's own Slack messages-//! would stop being recognised as theirs, silently, with nothing to catch it.-//! Those two calls are on opposite sides of the module boundary, which is what-//! puts [`canonicalize`] here and not in the engine.-//!-//! The same argument covers [`normalize_connection_identifier`]: it produces-//! the key segment a facet row is *stored under*, so writer and reader must-//! spell it identically or a disconnect leaves rows behind and the removed-//! account keeps being treated as the user.-//!-//! # What is not here-//!-//! Persisting a profile, loading the identities back and deleting a-//! connection's rows: those are `identity_store`'s, over a JSON file in the-//! workspace.--use serde::{Deserialize, Serialize};--/// Normalized user profile shape returned by every provider.-///-/// The shared fields (`display_name`, `email`, `username`, `avatar_url`,-/// `profile_url`) cover what a desktop UI needs to render a connected-account-/// card. Anything provider-specific — Gmail's `messagesTotal`, Notion's-/// workspace ids — goes into [`extras`](Self::extras), so callers do not widen-/// the shape every time a new toolkit lands, and so an identifier a provider-/// only exposes there (a Slack screen name, for instance) is still available to-/// the row expansion.-#[derive(Debug, Clone, Default, Serialize, Deserialize)]-pub struct ProviderUserProfile {- /// Composio toolkit slug the profile was fetched from, e.g. `"gmail"`.- pub toolkit: String,- /// The connection the profile belongs to; `None` on toolkit-wide fetches.- pub connection_id: Option<String>,- /// Human display label, when the provider exposes one.- pub display_name: Option<String>,- /// Primary email address on the connected account.- pub email: Option<String>,- /// Platform username or screen name, without any leading `@`.- pub username: Option<String>,- /// URL of the account's avatar image.- pub avatar_url: Option<String>,- /// URL of the account's public profile page.- pub profile_url: Option<String>,- /// Provider-specific extras (raw JSON object).- #[serde(default)]- pub extras: serde_json::Value,-}--/// Shape of an identifier persisted against a connection.-///-/// A closed set of identifier dimensions, so the-/// self-check is a direct `(toolkit, kind, value)` lookup. The string form is-/// the last segment of the stored facet key, which makes every variant name a-/// durable value rather than a label.-#[derive(Debug, Clone, Copy, PartialEq, Eq)]-pub enum IdentityKind {- /// Platform-canonical immutable id — a Slack `U123ABC`, a Notion UUID.- UserId,- /// Email address.- Email,- /// An `@`-style screen name, canonicalised without the leading `@`.- Handle,- /// E.164 phone number.- Phone,- /// Human display label. A weak signal — never auto-promotes to "is self".- DisplayName,- /// Not for matching; kept for UI and prompt rendering.- AvatarUrl,- /// Not for matching; kept for UI and prompt rendering.- ProfileUrl,-}--impl IdentityKind {- /// The stored key segment for this kind.- ///- /// Durable: it is the last segment of a persisted facet key, so renaming a- /// variant's string orphans every row filed under the old one.- pub fn as_str(self) -> &'static str {- match self {- Self::UserId => "user_id",- Self::Email => "email",- Self::Handle => "handle",- Self::Phone => "phone",- Self::DisplayName => "display_name",- Self::AvatarUrl => "avatar_url",- Self::ProfileUrl => "profile_url",- }- }-- /// Parse a stored key segment back into a kind.- ///- /// Returns `None` for anything unrecognised — including the legacy- /// `username` segment written before the identifier rewrite. Callers skip- /// those rows rather than failing the load, so one stale row cannot make a- /// user's whole identity set unreadable.- pub fn parse(s: &str) -> Option<Self> {- Some(match s {- "user_id" => Self::UserId,- "email" => Self::Email,- "handle" => Self::Handle,- "phone" => Self::Phone,- "display_name" => Self::DisplayName,- "avatar_url" => Self::AvatarUrl,- "profile_url" => Self::ProfileUrl,- _ => return None,- })- }-- /// Confidence the matcher records on a row of this kind.- ///- /// Hard kinds auto-promote a chunk to "is self"; weak kinds require- /// corroboration. A display name is deliberately low — two people share a- /// name far more often than they share a user id.- pub fn confidence(self) -> f64 {- match self {- Self::UserId | Self::Phone => 1.00,- Self::Email => 0.95,- Self::Handle => 0.70,- Self::DisplayName => 0.40,- Self::AvatarUrl | Self::ProfileUrl => 0.50,- }- }-- /// Whether this kind is a real identity signal worth running through the- /// matcher, as opposed to a UI-only field.- pub fn is_matchable(self) -> bool {- matches!(- self,- Self::UserId | Self::Email | Self::Handle | Self::Phone | Self::DisplayName- )- }-}--/// Canonicalize a raw identifier for storage and lookup.-///-/// The same routine runs on the entity side at match time, so equality of-/// canonical forms is the matcher's only test. Returns `None` for an empty or-/// whitespace-only value — storing one would match every chunk that happened to-/// carry a blank sender.-pub fn canonicalize(kind: IdentityKind, raw: &str) -> Option<String> {- let trimmed = raw.trim();- if trimmed.is_empty() {- return None;- }- Some(match kind {- IdentityKind::Email => trimmed.to_lowercase(),- IdentityKind::Handle => trimmed.trim_start_matches('@').to_lowercase(),- IdentityKind::Phone => trimmed- .chars()- .filter(|c| c.is_ascii_digit() || *c == '+')- .collect(),- IdentityKind::DisplayName => trimmed.split_whitespace().collect::<Vec<_>>().join(" "),- IdentityKind::UserId | IdentityKind::AvatarUrl | IdentityKind::ProfileUrl => {- trimmed.to_string()- }- })-}--/// Every identifier known for one `(source, connection)` pair, collapsed into-/// one row.-///-/// This is the read shape: the store holds one facet per identifier, and a-/// loader groups them back into this so a caller does not have to reassemble an-/// account from seven rows.-#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]-#[serde(default)]-pub struct ConnectedIdentity {- /// Toolkit slug the identity came from, normalised.- pub source: String,- /// Connection identifier, normalised — see- /// [`normalize_connection_identifier`].- pub identifier: String,- /// Human display label, when one was stored.- pub display_name: Option<String>,- /// Canonicalised email address.- pub email: Option<String>,- /// Canonicalised screen name, without the leading `@`.- pub handle: Option<String>,- /// Canonicalised phone number.- pub phone: Option<String>,- /// Platform-canonical immutable id.- pub user_id: Option<String>,- /// Avatar image URL.- pub avatar_url: Option<String>,- /// Public profile URL.- pub profile_url: Option<String>,-}--/// Render a compact prompt section for a set of identities.-///-/// Skips `user_id` (not human-readable) and prefixes a handle with `@`. Returns-/// an empty string — rather than a bare heading — when there is nothing worth-/// showing, so a caller can concatenate the result unconditionally.-///-/// Every value is flattened onto one line and has `|` replaced before it is-/// joined with `|` separators: an identifier is user-controlled text arriving-/// from a third-party provider, and a display name containing a newline would-/// otherwise let it forge additional prompt lines.-pub fn render_connected_identities_section(identities: &[ConnectedIdentity]) -> String {- if identities.is_empty() {- return String::new();- }- let mut out = String::from("## Connected Identities\n\n");- for id in identities {- let mut fields = Vec::<String>::new();- if let Some(v) = id.display_name.as_deref() {- let v = sanitize_prompt_value(v);- if !v.is_empty() {- fields.push(v);- }- }- if let Some(v) = id.email.as_deref() {- let v = sanitize_prompt_value(v);- if !v.is_empty() {- fields.push(v);- }- }- if let Some(v) = id.handle.as_deref() {- let v = sanitize_prompt_value(v);- if !v.is_empty() {- fields.push(format!("@{v}"));- }- }- if let Some(v) = id.profile_url.as_deref() {- let v = sanitize_prompt_value(v);- if !v.is_empty() {- fields.push(v);- }- }- if fields.is_empty() {- continue;- }- let identifier = sanitize_prompt_value(&id.identifier);- out.push_str(&format!(- "- {} ({}): {}\n",- title_case(&id.source),- identifier,- fields.join(" | ")- ));- }- if out.trim() == "## Connected Identities" {- return String::new();- }- out-}--/// Normalize a raw toolkit slug or connection id into the form facet keys are-/// stored under.-///-/// Lowercases, replaces every character outside `[a-z0-9_-]` with `_`, and-/// trims leading and trailing underscores. Writer and reader must both call-/// this: a caller passing a raw connection id to a delete would otherwise match-/// no rows, and the disconnected account would keep being treated as the user.-pub fn normalize_connection_identifier(raw: &str) -> String {- let mut out = String::with_capacity(raw.len());- for ch in raw.chars() {- let lower = ch.to_ascii_lowercase();- if lower.is_ascii_alphanumeric() || lower == '-' || lower == '_' {- out.push(lower);- } else {- out.push('_');- }- }- out.trim_matches('_').to_string()-}--fn title_case(raw: &str) -> String {- let mut chars = raw.chars();- match chars.next() {- Some(first) => first.to_ascii_uppercase().to_string() + chars.as_str(),- None => String::new(),- }-}--fn sanitize_prompt_value(raw: &str) -> String {- let replaced = raw.replace(['\n', '\r', '\t'], " ").replace('|', "/");- replaced.split_whitespace().collect::<Vec<_>>().join(" ")-}--#[cfg(test)]-#[path = "profile_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/profile_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/profile_tests.rsdeleted file mode 100644index b89310ea95..0000000000--- a/crates/openhuman-core/src/integrations/composio/contract/profile_tests.rs+++ /dev/null@@ -1,239 +0,0 @@-//! Tests for the identity vocabulary — the pure-data half.-//!-//! The facet-store half (persisting a profile, loading identities back, the-//! self-identity lookups, the disconnect delete) is tested in the engine crate-//! next to the store it drives. What is pinned here is what both sides of the-//! module boundary have to compute identically: the stored key segments, the-//! canonical form each kind reduces to, and the identifier normalisation a-//! delete has to reproduce exactly to match the rows a write created.--#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]--use super::{- canonicalize, normalize_connection_identifier, render_connected_identities_section,- ConnectedIdentity, IdentityKind, ProviderUserProfile,-};--const ALL_KINDS: [IdentityKind; 7] = [- IdentityKind::UserId,- IdentityKind::Email,- IdentityKind::Handle,- IdentityKind::Phone,- IdentityKind::DisplayName,- IdentityKind::AvatarUrl,- IdentityKind::ProfileUrl,-];--#[test]-fn every_identity_kind_round_trips_through_its_stored_segment() {- for kind in ALL_KINDS {- assert_eq!(- IdentityKind::parse(kind.as_str()),- Some(kind),- "the stored segment for {kind:?} does not parse back"- );- }-}--#[test]-fn the_stored_segments_are_the_durable_strings() {- assert_eq!(IdentityKind::UserId.as_str(), "user_id");- assert_eq!(IdentityKind::Email.as_str(), "email");- assert_eq!(IdentityKind::Handle.as_str(), "handle");- assert_eq!(IdentityKind::Phone.as_str(), "phone");- assert_eq!(IdentityKind::DisplayName.as_str(), "display_name");- assert_eq!(IdentityKind::AvatarUrl.as_str(), "avatar_url");- assert_eq!(IdentityKind::ProfileUrl.as_str(), "profile_url");-}--#[test]-fn an_unknown_segment_parses_to_none_rather_than_a_wrong_kind() {- // `username` is the legacy segment written before the rewrite; a loader- // skips those rows instead of failing the whole identity set.- assert_eq!(IdentityKind::parse("username"), None);- assert_eq!(IdentityKind::parse(""), None);- assert_eq!(IdentityKind::parse("USER_ID"), None);-}--#[test]-fn only_the_matchable_kinds_are_matchable() {- assert!(IdentityKind::UserId.is_matchable());- assert!(IdentityKind::Email.is_matchable());- assert!(IdentityKind::Handle.is_matchable());- assert!(IdentityKind::Phone.is_matchable());- assert!(IdentityKind::DisplayName.is_matchable());- // UI-only fields never enter the matcher.- assert!(!IdentityKind::AvatarUrl.is_matchable());- assert!(!IdentityKind::ProfileUrl.is_matchable());-}--#[test]-fn a_display_name_never_outranks_a_hard_identifier() {- // The ordering is what stops two people sharing a name from being treated- // as one another; the absolute numbers matter less than the ranking.- assert!(IdentityKind::UserId.confidence() > IdentityKind::Handle.confidence());- assert!(IdentityKind::Email.confidence() > IdentityKind::Handle.confidence());- assert!(IdentityKind::Handle.confidence() > IdentityKind::DisplayName.confidence());-}--#[test]-fn every_confidence_is_a_probability() {- for kind in ALL_KINDS {- let confidence = kind.confidence();- assert!(- (0.0..=1.0).contains(&confidence),- "{kind:?} reports a confidence outside 0..=1"- );- }-}--#[test]-fn an_email_canonicalises_case_insensitively() {- assert_eq!(- canonicalize(IdentityKind::Email, " [email protected] ").as_deref(),- Some("[email protected]")- );-}--#[test]-fn a_handle_loses_its_at_sign_and_its_casing() {- assert_eq!(- canonicalize(IdentityKind::Handle, "@AliceW").as_deref(),- Some("alicew")- );-}--#[test]-fn a_phone_keeps_only_digits_and_the_country_plus() {- assert_eq!(- canonicalize(IdentityKind::Phone, "+1 (555) 010-9999").as_deref(),- Some("+15550109999")- );-}--#[test]-fn a_display_name_collapses_its_whitespace_but_keeps_its_casing() {- assert_eq!(- canonicalize(IdentityKind::DisplayName, " Alice W. ").as_deref(),- Some("Alice W.")- );-}--#[test]-fn an_opaque_identifier_is_only_trimmed() {- // A platform id is case-significant; lowercasing `U123ABC` would stop it- // matching the sender field it is compared against.- assert_eq!(- canonicalize(IdentityKind::UserId, " U123ABC ").as_deref(),- Some("U123ABC")- );- assert_eq!(- canonicalize(IdentityKind::ProfileUrl, " https://x/Alice ").as_deref(),- Some("https://x/Alice")- );-}--#[test]-fn a_blank_identifier_canonicalises_to_nothing() {- // Storing an empty canonical form would match every chunk carrying a blank- // sender, which is the matcher failing open.- for kind in ALL_KINDS {- assert_eq!(canonicalize(kind, " "), None, "{kind:?} accepted a blank");- assert_eq!(canonicalize(kind, ""), None, "{kind:?} accepted an empty");- }-}--#[test]-fn normalising_an_identifier_is_idempotent() {- // A delete re-normalises what a write already normalised; if the routine- // were not idempotent the second pass would miss the stored rows.- let once = normalize_connection_identifier("Conn ID/42!");- assert_eq!(normalize_connection_identifier(&once), once);- assert_eq!(once, "conn_id_42");-}--#[test]-fn normalising_lowercases_and_replaces_and_trims() {- assert_eq!(normalize_connection_identifier("GMAIL"), "gmail");- assert_eq!(normalize_connection_identifier("a.b:c"), "a_b_c");- assert_eq!(normalize_connection_identifier("__lead__"), "lead");- assert_eq!(normalize_connection_identifier("keep-me_1"), "keep-me_1");-}--fn identity(source: &str, identifier: &str) -> ConnectedIdentity {- ConnectedIdentity {- source: source.into(),- identifier: identifier.into(),- ..ConnectedIdentity::default()- }-}--#[test]-fn rendering_no_identities_yields_nothing_at_all() {- assert_eq!(render_connected_identities_section(&[]), "");-}--#[test]-fn rendering_identities_with_no_showable_fields_yields_nothing() {- // A bare heading with no rows under it is worse than no section: it spends- // prompt budget telling the model nothing.- let identities = [identity("gmail", "conn-1")];- assert_eq!(render_connected_identities_section(&identities), "");-}--#[test]-fn rendering_prefixes_a_handle_and_skips_the_opaque_user_id() {- let identities = [ConnectedIdentity {- display_name: Some("Alice W".into()),- email: Some("[email protected]".into()),- handle: Some("alicew".into()),- user_id: Some("U123ABC".into()),- ..identity("slack", "conn-1")- }];- let rendered = render_connected_identities_section(&identities);-- assert!(rendered.starts_with("## Connected Identities\n\n"));- assert!(rendered.contains("- Slack (conn-1): Alice W | [email protected] | @alicew"));- assert!(- !rendered.contains("U123ABC"),- "the opaque user id is not human-readable and must not be rendered"- );-}--#[test]-fn rendering_neutralises_a_value_that_would_forge_prompt_lines() {- // Every field here is third-party text the user does not control. A newline- // or a pipe in a display name must not be able to invent a row.- let identities = [ConnectedIdentity {- display_name: Some("Bob\n- Admin (root): owner".into()),- email: Some("b|[email protected]".into()),- ..identity("gmail", "conn-2")- }];- let rendered = render_connected_identities_section(&identities);-- assert_eq!(- rendered.lines().filter(|l| l.starts_with("- ")).count(),- 1,- "a value with a newline forged an extra row"- );- assert!(rendered.contains("Bob - Admin (root): owner"));- assert!(rendered.contains("b/[email protected]"));-}--#[test]-fn a_provider_profile_round_trips_with_its_open_extras() {- let profile = ProviderUserProfile {- toolkit: "slack".into(),- connection_id: Some("conn-1".into()),- display_name: Some("Alice".into()),- extras: serde_json::json!({ "handle": "alicew" }),- ..ProviderUserProfile::default()- };- let json = serde_json::to_string(&profile).expect("serialize");- let back: ProviderUserProfile = serde_json::from_str(&json).expect("deserialize");-- assert_eq!(back.toolkit, "slack");- assert_eq!(back.connection_id.as_deref(), Some("conn-1"));- assert_eq!(back.display_name.as_deref(), Some("Alice"));- assert_eq!(back.extras["handle"], "alicew");-}diff --git a/crates/openhuman-core/src/integrations/composio/contract/tasks.rs b/crates/openhuman-core/src/integrations/composio/contract/tasks.rsdeleted file mode 100644index 74ec2c67a1..0000000000--- a/crates/openhuman-core/src/integrations/composio/contract/tasks.rs+++ /dev/null@@ -1,206 +0,0 @@-//! The provider-agnostic work-item envelope: what a task fetch asks for, and-//! what it hands back.-//!-//! This is the second of the two things a Composio provider does. `sync`-//! persists upstream items into the memory store as passive context;-//! `fetch_tasks` *returns* [`NormalizedTask`]s so the host can enrich them and-//! route them onto the agent's todo board. Every native task provider (GitHub,-//! Notion, Linear, ClickUp) maps its upstream payload into this one envelope,-//! which is why the envelope — and not the payloads — is what crosses the bus.-//!-//! # A note on the wire casing-//!-//! [`NormalizedTask`], [`TaskContainer`] and [`TaskFetchFilter`] serialise-//! `camelCase`; the enums serialise `snake_case`. That is not an oversight: the-//! structs are read by the task-source UI, which is TypeScript, while the enum-//! tags are also written into a card's `source_metadata` and compared as-//! strings on the Rust side. Both forms are persisted — treat every field name-//! and every variant name as a compatibility surface.--use serde::{Deserialize, Serialize};--/// What kind of work an ingested task implies.-///-/// GitHub's issues-and-pull-requests search returns both shapes and the job-/// differs fundamentally — *resolve* an issue versus *review* a pull request —-/// so providers tag each task and the enrichment phrases the objective and the-/// agent prompt accordingly. Providers that do not distinguish (Notion, Linear,-/// ClickUp) leave this [`Generic`](Self::Generic).-#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]-#[serde(rename_all = "snake_case")]-pub enum TaskKind {- /// No issue/pull-request distinction — the default for non-code providers.- #[default]- Generic,- /// A tracker issue: the job is to resolve or implement it.- Issue,- /// A pull request: the job is to review it — read the diff, give feedback.- PullRequest,-}--impl TaskKind {- /// Stable lowercase tag, mirrored into the card's `source_metadata`.- pub fn as_str(&self) -> &'static str {- match self {- TaskKind::Generic => "generic",- TaskKind::Issue => "issue",- TaskKind::PullRequest => "pull_request",- }- }-}--/// How the GitHub task-source fetch reaches GitHub.-///-/// Shipped desktop users connect GitHub through Composio OAuth — no `gh` on-/// `PATH`, no `GITHUB_TOKEN` — while local development and self-hosted setups-/// often have the reverse. [`Auto`](Self::Auto) does the right thing for both;-/// the other two force a path when the user wants one.-#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]-#[serde(rename_all = "snake_case")]-pub enum GithubFetchMode {- /// Try the connected Composio account first; fall back to local `gh` or- /// REST only when Composio is unavailable.- ///- /// The safe default: no regression for shipped users, still a true fallback- /// for local and development setups.- #[default]- Auto,- /// Force the connected Composio account — the classic shipped-app path.- Composio,- /// Force the local `gh` CLI or REST with a `GH_TOKEN` / `GITHUB_TOKEN`- /// environment token.- Local,-}--/// A provider-agnostic, structured work item returned by a task fetch.-///-/// `source_id` is left empty by providers and stamped by the host's task-source-/// pipeline with the originating source id — a provider has no knowledge of-/// which configured source asked for the fetch.-#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]-#[serde(rename_all = "camelCase")]-pub struct NormalizedTask {- /// The upstream provider's stable id for the item — issue, task or page id.- pub external_id: String,- /// The task source that produced this task. Empty until the pipeline- /// stamps it.- #[serde(default)]- pub source_id: String,- /// Toolkit slug, e.g. `"github"`.- pub provider: String,- /// Whether this task is an issue, a pull request, or undifferentiated.- ///- /// Drives intent-aware objective and prompt phrasing during enrichment.- #[serde(default)]- pub kind: TaskKind,- /// Human-readable title, as the provider spells it.- pub title: String,- /// Body text or description, when the provider returns one.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub body: Option<String>,- /// Canonical web URL for the item.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub url: Option<String>,- /// Provider-native status string, e.g. `"open"` or `"todo"`.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub status: Option<String>,- /// Whoever the item is assigned to upstream.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub assignee: Option<String>,- /// Due date as an ISO-8601 string, when the provider exposes one.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub due: Option<String>,- /// Provider-native labels or tags.- #[serde(default)]- pub labels: Vec<String>,- /// Provider-native priority string.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub priority: Option<String>,- /// Last-updated ISO-8601 timestamp — used for cursor advancement and- /// edit-aware dedup (`{external_id}@{updated_at}`).- #[serde(default, skip_serializing_if = "Option::is_none")]- pub updated_at: Option<String>,- /// The raw upstream payload, retained for enrichment and debugging.- #[serde(default)]- pub raw: serde_json::Value,-}--/// A selectable upstream task container — a board, database or list.-///-/// Populates a picker so the user chooses from a list instead of pasting a raw-/// id. Today this is a Notion database; later a Linear team or a ClickUp list.-/// Surfaced to the task-source UI as `{ id, title }`.-#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]-#[serde(rename_all = "camelCase")]-pub struct TaskContainer {- /// Provider-native id, e.g. a Notion database id, used as the filter id.- pub id: String,- /// Human-readable label for the picker.- pub title: String,-}--/// Provider-agnostic filter passed into a task fetch.-///-/// The host builds this from a user-configured, per-provider filter spec. Each-/// provider reads only the fields that apply to it — GitHub reads `repo` and-/// `labels`, Notion reads `database_id`, Linear and ClickUp read `team_id` —-/// and ignores the rest. [`extra`](Self::extra) is a free-form escape hatch-/// surfaced in the UI for advanced provider-native query fragments.-#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]-#[serde(rename_all = "camelCase")]-pub struct TaskFetchFilter {- /// Scope to items assigned to — or involving — the authenticated user.- #[serde(default)]- pub assignee_is_me: bool,- /// GitHub fetch-path selector. Defaults to [`GithubFetchMode::Auto`].- #[serde(default)]- pub github_fetch_mode: GithubFetchMode,- /// GitHub `owner/name` repository scope.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub repo: Option<String>,- /// GitHub label filter.- #[serde(default)]- pub labels: Vec<String>,- /// Issue or task state filter, e.g. `"open"` or `"todo"`.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub state: Option<String>,- /// Notion database — board — id.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub database_id: Option<String>,- /// Notion status property filter.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub status: Option<String>,- /// Linear or ClickUp team — workspace — id.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub team_id: Option<String>,- /// ClickUp list id.- #[serde(default, skip_serializing_if = "Option::is_none")]- pub list_id: Option<String>,- /// Free-form provider-native filter fragment, for advanced users.- #[serde(default)]- pub extra: serde_json::Value,- /// Hard cap on how many tasks a single fetch returns. `0` means "unset";- /// see [`effective_max`](Self::effective_max).- #[serde(default)]- pub max: u32,-}--impl TaskFetchFilter {- /// Effective per-fetch item cap.- ///- /// `max` is `#[serde(default)]`, so an unset filter arrives as `0`. Reading- /// that literally would mean "fetch nothing", which is never what a caller- /// who omitted the field wanted, so an unset cap becomes a safe bound of 25- /// instead.- pub fn effective_max(&self) -> usize {- if self.max == 0 {- 25- } else {- self.max as usize- }- }-}--#[cfg(test)]-#[path = "tasks_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/tasks_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/tasks_tests.rsdeleted file mode 100644index f669e5cd22..0000000000--- a/crates/openhuman-core/src/integrations/composio/contract/tasks_tests.rs+++ /dev/null@@ -1,139 +0,0 @@-//! Tests for the task-fetch envelope — the pure-data half.-//!-//! The provider mappings that populate a [`super::NormalizedTask`] live in the-//! engine crate with the providers that own them. What is pinned here is the-//! envelope itself: the wire casing the task-source UI reads, the enum tags-//! that end up in a card's `source_metadata`, and the unset-cap rule that would-//! otherwise read as "fetch nothing".--#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]--use super::{GithubFetchMode, NormalizedTask, TaskContainer, TaskFetchFilter, TaskKind};--#[test]-fn every_task_kind_tag_matches_its_serde_form() {- for kind in [TaskKind::Generic, TaskKind::Issue, TaskKind::PullRequest] {- let json = serde_json::to_string(&kind).expect("serialize");- assert_eq!(- json,- format!("\"{}\"", kind.as_str()),- "as_str and the serde form disagree for {kind:?}"- );- }-}--#[test]-fn task_kind_tags_are_the_stable_strings() {- assert_eq!(TaskKind::Generic.as_str(), "generic");- assert_eq!(TaskKind::Issue.as_str(), "issue");- assert_eq!(TaskKind::PullRequest.as_str(), "pull_request");-}--#[test]-fn an_undifferentiated_task_defaults_to_generic() {- assert_eq!(TaskKind::default(), TaskKind::Generic);- assert_eq!(NormalizedTask::default().kind, TaskKind::Generic);-}--#[test]-fn the_github_fetch_mode_defaults_to_auto() {- // `Auto` is the safe default: a shipped user with no `gh` on `PATH` still- // reaches GitHub through the connected Composio account.- assert_eq!(GithubFetchMode::default(), GithubFetchMode::Auto);- assert_eq!(- TaskFetchFilter::default().github_fetch_mode,- GithubFetchMode::Auto- );-}--#[test]-fn every_github_fetch_mode_round_trips_through_its_snake_case_tag() {- let cases = [- (GithubFetchMode::Auto, "\"auto\""),- (GithubFetchMode::Composio, "\"composio\""),- (GithubFetchMode::Local, "\"local\""),- ];- for (mode, wire) in cases {- let json = serde_json::to_string(&mode).expect("serialize");- assert_eq!(json, wire, "wire form changed for {mode:?}");- let back: GithubFetchMode = serde_json::from_str(&json).expect("deserialize");- assert_eq!(back, mode);- }-}--#[test]-fn a_normalized_task_serialises_camel_case_for_the_ui() {- let task = NormalizedTask {- external_id: "42".into(),- source_id: "src-1".into(),- provider: "github".into(),- kind: TaskKind::PullRequest,- title: "Fix the thing".into(),- updated_at: Some("2026-08-25T10:00:00Z".into()),- ..NormalizedTask::default()- };- let json = serde_json::to_value(&task).expect("serialize to value");- let object = json.as_object().expect("task serialises as an object");-- assert!(object.contains_key("externalId"));- assert!(object.contains_key("sourceId"));- assert!(object.contains_key("updatedAt"));- assert_eq!(object["kind"], "pull_request");- // Absent optionals are skipped rather than emitted as null, so the UI can- // distinguish "the provider had nothing" from "the field is new".- assert!(!object.contains_key("body"));- assert!(!object.contains_key("url"));-}--#[test]-fn a_normalized_task_round_trips() {- let task = NormalizedTask {- external_id: "7".into(),- provider: "linear".into(),- title: "Ship it".into(),- labels: vec!["p1".into()],- raw: serde_json::json!({ "id": 7 }),- ..NormalizedTask::default()- };- let json = serde_json::to_string(&task).expect("serialize");- let back: NormalizedTask = serde_json::from_str(&json).expect("deserialize");- assert_eq!(back, task);-}--#[test]-fn a_normalized_task_decodes_from_the_minimum_an_older_peer_wrote() {- // Every field beyond the three required ones carries `#[serde(default)]`,- // so a peer built before any of them existed still decodes.- let back: NormalizedTask =- serde_json::from_str(r#"{"externalId":"1","provider":"notion","title":"t"}"#)- .expect("deserialize minimal");- assert_eq!(back.external_id, "1");- assert_eq!(back.source_id, "");- assert_eq!(back.kind, TaskKind::Generic);- assert!(back.labels.is_empty());-}--#[test]-fn an_unset_cap_becomes_a_safe_bound_rather_than_zero() {- assert_eq!(TaskFetchFilter::default().effective_max(), 25);-}--#[test]-fn an_explicit_cap_is_honoured() {- let filter = TaskFetchFilter {- max: 3,- ..TaskFetchFilter::default()- };- assert_eq!(filter.effective_max(), 3);-}--#[test]-fn a_task_container_serialises_the_picker_shape() {- let container = TaskContainer {- id: "db-1".into(),- title: "Roadmap".into(),- };- let json = serde_json::to_value(&container).expect("serialize to value");- assert_eq!(json["id"], "db-1");- assert_eq!(json["title"], "Roadmap");-}