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
Merge remote-tracking branch 'refs/remotes/upstream/main' into pr/5521\n
Steven Enamakelf6a4b37e4424
diff --cc src/openhuman/integrations/task_sources/pipeline.rsindex 73fa080441,3866bd4a56..682a16d7dc--- a/src/openhuman/integrations/task_sources/pipeline.rs+++ b/src/openhuman/integrations/task_sources/pipeline.rs@@@ -93,31 -128,9 +128,15 @@@ async fn run_inner_reason: FetchReason,outcome: &mut FetchOutcome,) -> Result<(), String> {- let provider = get_provider(source.provider.as_str()).ok_or_else(|| {- format!(- "no native provider registered for '{}'",- source.provider.as_str()- )- })?;-- let ctx = ProviderContext {- config: Arc::new(config.clone()),- toolkit: source.provider.as_str().to_string(),- connection_id: source.connection_id.clone(),- usage: Default::default(),- max_items: None,- sync_depth_days: None,- };-let fetch_filter = filter::to_fetch_filter(&source.filter, source.max_tasks_per_fetch);- let tasks = provider.fetch_tasks(&ctx, &fetch_filter).await?;+ let tasks = fetch_tasks_unavailable(source, &fetch_filter)?;outcome.fetched = tasks.len();+ // A fetch returns at most `fetch_filter.effective_max()` tasks (a hard+ // per-fetch cap). When the provider returns a full page we cannot tell+ // "these are all the currently-open tasks" from "the rest were truncated+ // out of this window", so `current_external_ids` below is NOT a reliable+ // authority on what still exists upstream — and must not drive deletions.+ let hit_fetch_cap = tasks.len() >= fetch_filter.effective_max();let current_external_ids: HashSet<String> =tasks.iter().map(|task| task.external_id.clone()).collect();diff --cc src/openhuman/integrations/task_sources/pipeline_tests.rsindex 42d284daf1,ebe9bfda0a..7efa08a6ed--- a/src/openhuman/integrations/task_sources/pipeline_tests.rs+++ b/src/openhuman/integrations/task_sources/pipeline_tests.rs@@@ -181,119 -94,20 +94,104 @@@ async fn refusal_records_a_fetch_historlet config = test_config(&tmp);let source = add_github_source(&config);- let first = run_source_once(&config, &source, FetchReason::Manual).await;- assert_eq!(first.routed, 2, "error={:?}", first.error);- assert_eq!(route::board_cards(&config).await.unwrap().len(), 2);+ let _ = run_source_once(&config, &source, FetchReason::Manual).await;- // Simulate the provider returning only currently-open/matching tasks:- // task 2 was closed or no longer matches the source filter.- register_provider(Arc::new(StubProvider {- tasks: vec![canned_task("1", "Keep task", "2025-01-01T00:00:00Z")],- }));-- let second = run_source_once(&config, &source, FetchReason::Manual).await;- assert_eq!(second.fetched, 1);- assert_eq!(second.routed, 0);- assert_eq!(second.skipped_dupe, 1);- assert_eq!(second.pruned, 1);- assert!(second.error.is_none());-- let cards = route::board_cards(&config).await.unwrap();- assert_eq!(cards.len(), 1);- assert!(cards[0].title.contains("Keep task"));-- let ingested = store::list_ingested(&config, &source.id, 10).unwrap();- assert_eq!(ingested.len(), 1);- assert_eq!(ingested[0].external_id, "1");+ // `run_source_once` records the failed pass so the UI can show why a+ // source has never ingested anything, rather than looking silently idle.+ let sources = store::list_sources(&config).unwrap();+ let recorded = sources.iter().find(|s| s.id == source.id);+ assert!(+ recorded.is_some(),+ "source must still be listed after a refused fetch"+ );}+#[tokio::test]+async fn full_page_fetch_skips_prune_then_resumes_below_cap() {+ let _guard = registry_lock();+ let tmp = TempDir::new().unwrap();+ let config = test_config(&tmp);++ // A source capped at 2 tasks per fetch, so a 2-task fetch is a full page+ // and cannot be trusted as the complete set of currently-open tasks.+ let source = store::add_source(+ &config,+ ProviderSlug::Github,+ None,+ Some("Capped source".into()),+ FilterSpec::Github {+ repo: Some("o/r".into()),+ labels: vec![],+ assignee_is_me: true,+ state: None,+ fetch_mode: Default::default(),+ extra: json!({}),+ },+ 1800,+ SourceTarget::TodoOnly,+ 2,+ )+ .unwrap();++ // Pass 1: two tasks routed onto the board.+ register_provider(Arc::new(StubProvider {+ tasks: vec![+ canned_task("1", "Task one", "2025-01-01T00:00:00Z"),+ canned_task("2", "Task two", "2025-01-02T00:00:00Z"),+ ],+ }));+ let p1 = run_source_once(&config, &source, FetchReason::Manual).await;+ assert_eq!(p1.routed, 2, "error={:?}", p1.error);+ assert_eq!(route::board_cards(&config).await.unwrap().len(), 2);++ // Pass 2: a FULL PAGE (len == cap) that omits task 1 — it was pushed out of+ // the top-2 window, not closed. Pruning here (the pre-fix behaviour) would+ // delete task 1's card; the fix must keep it because the fetch is truncated.+ register_provider(Arc::new(StubProvider {+ tasks: vec![+ canned_task("2", "Task two", "2025-01-02T00:00:00Z"),+ canned_task("3", "Task three", "2025-01-03T00:00:00Z"),+ ],+ }));+ let p2 = run_source_once(&config, &source, FetchReason::Manual).await;+ assert_eq!(p2.fetched, 2);+ assert_eq!(+ p2.pruned, 0,+ "a full-page fetch must not prune tasks truncated out of the window"+ );+ assert_eq!(p2.routed, 1, "task 3 is new");+ assert_eq!(p2.skipped_dupe, 1, "task 2 is unchanged");+ let cards = route::board_cards(&config).await.unwrap();+ assert_eq!(cards.len(), 3, "task 1's card survives the truncated fetch");+ let ids: Vec<String> = store::list_ingested(&config, &source.id, 10)+ .unwrap()+ .into_iter()+ .map(|r| r.external_id)+ .collect();+ assert!(+ ids.contains(&"1".to_string()),+ "task 1 stays in the dedup ledger, not deleted and re-minted"+ );++ // Pass 3: a SUB-CAP fetch (1 < 2) is a complete view, so a genuinely-missing+ // task is now a reliable deletion signal — pruning resumes. Tasks 1 and 3+ // are absent and get pruned.+ register_provider(Arc::new(StubProvider {+ tasks: vec![canned_task("2", "Task two", "2025-01-02T00:00:00Z")],+ }));+ let p3 = run_source_once(&config, &source, FetchReason::Manual).await;+ assert_eq!(p3.fetched, 1);+ assert_eq!(+ p3.pruned, 2,+ "a below-cap fetch prunes the genuinely-absent tasks"+ );+ let cards_after = route::board_cards(&config).await.unwrap();+ assert_eq!(cards_after.len(), 1, "only task 2 remains after the prune");+ assert!(cards_after[0].title.contains("Task two"));+}+#[tokio::test]async fn missing_provider_surfaces_error_in_outcome() {- let _guard = registry_lock();let tmp = TempDir::new().unwrap();let config = test_config(&tmp);