Skip to main content

orch/backends/
mod.rs

1//! External backend abstraction — trait for issue trackers.
2//!
3//! GitHub Issues is the first implementation. The trait is designed so
4//! Linear, Jira, GitLab, or any issue tracker can be swapped in later.
5
6pub mod github;
7
8use async_trait::async_trait;
9use serde::{Deserialize, Serialize};
10
11/// Opaque identifier from the external system (issue number, Linear ID, etc.)
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct ExternalId(pub String);
14
15/// A mention/comment from the external system (backend-agnostic).
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct Mention {
18    /// Unique identifier for deduplication.
19    pub id: String,
20    /// The comment/mention body text.
21    pub body: String,
22    /// Author of the mention.
23    pub author: String,
24    /// When the mention was created (RFC 3339).
25    pub created_at: String,
26    /// API URL of the issue/PR this comment belongs to.
27    /// Format: https://api.github.com/repos/owner/repo/issues/123
28    pub issue_url: Option<String>,
29}
30
31/// A task as represented in the external system.
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct ExternalTask {
34    pub id: ExternalId,
35    pub title: String,
36    pub body: String,
37    pub state: String,
38    pub labels: Vec<String>,
39    pub author: String,
40    pub created_at: String,
41    pub updated_at: String,
42    pub url: String,
43}
44
45/// Task status values understood by all backends.
46#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
47#[serde(rename_all = "snake_case")]
48pub enum Status {
49    New,
50    Routed,
51    InProgress,
52    Done,
53    Blocked,
54    InReview,
55    NeedsReview,
56}
57
58impl Status {
59    pub fn as_label(&self) -> &'static str {
60        match self {
61            Self::New => "status:new",
62            Self::Routed => "status:routed",
63            Self::InProgress => "status:in_progress",
64            Self::Done => "status:done",
65            Self::Blocked => "status:blocked",
66            Self::InReview => "status:in_review",
67            Self::NeedsReview => "status:needs_review",
68        }
69    }
70
71    pub fn as_str(&self) -> &'static str {
72        match self {
73            Self::New => "new",
74            Self::Routed => "routed",
75            Self::InProgress => "in_progress",
76            Self::Done => "done",
77            Self::Blocked => "blocked",
78            Self::InReview => "in_review",
79            Self::NeedsReview => "needs_review",
80        }
81    }
82}
83
84/// The core trait for external task backends.
85///
86/// Each implementation talks to a different issue tracker.
87/// The engine calls these methods without knowing which backend is active.
88#[allow(clippy::double_must_use)] // async_trait marks its boxed futures must_use twice
89#[async_trait]
90pub trait ExternalBackend: Send + Sync {
91    /// Human-readable name (e.g. "github", "linear", "jira")
92    fn name(&self) -> &str;
93
94    /// Create a task in the external system.
95    async fn create_task(
96        &self,
97        title: &str,
98        body: &str,
99        labels: &[String],
100    ) -> anyhow::Result<ExternalId>;
101
102    /// Fetch a task by its external ID.
103    async fn get_task(&self, id: &ExternalId) -> anyhow::Result<ExternalTask>;
104
105    /// Update task status using idempotent remove + add operations.
106    ///
107    /// Default implementation retries up to 3 times with a fresh snapshot on
108    /// each attempt to narrow the TOCTOU window. Backends that provide a native
109    /// atomic status-update endpoint can override this.
110    ///
111    /// The retry loop:
112    ///   1. Fetches a fresh label snapshot via `get_task`.
113    ///   2. Removes all `status:*` labels except the target via `remove_label`.
114    ///   3. Adds the target label via `set_labels`.
115    ///
116    /// Note: labels removed in a previous attempt are already gone — the retry
117    /// re-evaluates the current state rather than undoing prior work.
118    async fn update_status(&self, id: &ExternalId, status: Status) -> anyhow::Result<()> {
119        let label = status.as_label();
120
121        // Hook for backends that need to auto-create labels (e.g. GitHub).
122        if let Err(e) = self.ensure_status_label(label).await {
123            tracing::warn!(label, err = %e, "ensure_status_label failed, continuing");
124        }
125
126        const MAX_RETRIES: u32 = 3;
127        let mut last_err =
128            anyhow::anyhow!("update_status({label}) failed: all {MAX_RETRIES} attempts exhausted");
129
130        for attempt in 0..MAX_RETRIES {
131            if attempt > 0 {
132                tokio::time::sleep(std::time::Duration::from_millis(500 * u64::from(attempt)))
133                    .await;
134                tracing::debug!(attempt, label, "retrying update_status");
135            }
136
137            // Fresh snapshot on every attempt.
138            let task = match self.get_task(id).await {
139                Ok(t) => t,
140                Err(e) => {
141                    last_err = e;
142                    continue;
143                }
144            };
145
146            // Remove all existing status labels except the target.
147            let mut remove_failed = false;
148            for old in task
149                .labels
150                .iter()
151                .filter(|l| l.starts_with("status:") && l.as_str() != label)
152            {
153                if let Err(e) = self.remove_label(id, old).await {
154                    tracing::warn!(old_label = %old, err = %e, attempt, "remove_label failed");
155                    last_err = e;
156                    remove_failed = true;
157                    break;
158                }
159            }
160            if remove_failed {
161                continue;
162            }
163
164            // Add the target status label.
165            match self.set_labels(id, &[label.to_string()]).await {
166                Ok(()) => return Ok(()),
167                Err(e) => {
168                    tracing::warn!(label, err = %e, attempt, "set_labels failed");
169                    last_err = e;
170                }
171            }
172        }
173
174        Err(last_err.context(format!(
175            "update_status({label}) failed after {MAX_RETRIES} attempts"
176        )))
177    }
178
179    /// List tasks by status.
180    async fn list_by_status(&self, status: Status) -> anyhow::Result<Vec<ExternalTask>>;
181
182    /// List all tasks (open and closed) in a single API call.
183    ///
184    /// This is more efficient than calling `list_by_status` for each status
185    /// when you need counts or details for all statuses.
186    async fn list_all_tasks(&self) -> anyhow::Result<Vec<ExternalTask>> {
187        // Default implementation falls back to calling list_by_status for each status
188        // This will be overridden by GitHub backend for efficiency
189        let statuses = [
190            Status::New,
191            Status::Routed,
192            Status::InProgress,
193            Status::Done,
194            Status::Blocked,
195            Status::InReview,
196            Status::NeedsReview,
197        ];
198        let mut all_tasks = Vec::new();
199        for status in statuses {
200            let tasks = self.list_by_status(status).await?;
201            all_tasks.extend(tasks);
202        }
203        Ok(all_tasks)
204    }
205
206    /// List tasks for closed-issue reconciliation fallback.
207    ///
208    /// Used when `list_all_tasks` fails (e.g., transient API issues).
209    /// Default implementation returns an empty list, meaning no fallback data.
210    async fn list_reconciliation_candidates(&self) -> anyhow::Result<Vec<ExternalTask>> {
211        Ok(Vec::new())
212    }
213
214    /// List open tasks that are routable — no `status:*` label yet, or `status:new`.
215    ///
216    /// Default implementation falls back to `list_by_status(New)`.
217    async fn list_routable(&self) -> anyhow::Result<Vec<ExternalTask>> {
218        self.list_by_status(Status::New).await
219    }
220
221    /// Fetch all open issues for ingest in a single logical call, returning each issue paired
222    /// with its detected status (`None` = unlabeled/routable, `Some(s)` = has status label `s`).
223    ///
224    /// When `since` is `Some(ts)`, only returns issues updated after that ISO 8601 timestamp.
225    /// This is more efficient for periodic syncs.  Use `None` for full sync.
226    ///
227    /// The default implementation calls `list_routable()` followed by `list_by_status()` for
228    /// each active non-new status, deduplicating by ID.  Backends that support bulk listing
229    /// (e.g. GitHub) should override this to fetch all open issues in one API call and
230    /// partition locally, eliminating the 1 + N fan-out.
231    async fn list_active_open_issues(
232        &self,
233        _since: Option<&str>,
234    ) -> anyhow::Result<Vec<(ExternalTask, Option<Status>)>> {
235        let mut seen = std::collections::HashSet::new();
236        let mut result = Vec::new();
237
238        // Routable tasks: unlabeled issues + status:new → no status sync needed.
239        if let Ok(routable) = self.list_routable().await {
240            for task in routable {
241                if seen.insert(task.id.0.clone()) {
242                    result.push((task, None));
243                }
244            }
245        }
246
247        // Remaining active statuses (non-new) that require status sync on first ingest.
248        let active_non_new = [
249            Status::Routed,
250            Status::InProgress,
251            Status::NeedsReview,
252            Status::InReview,
253            Status::Blocked,
254        ];
255        for status in active_non_new {
256            if let Ok(tasks) = self.list_by_status(status).await {
257                for task in tasks {
258                    if seen.insert(task.id.0.clone()) {
259                        result.push((task, Some(status)));
260                    }
261                }
262            }
263        }
264
265        Ok(result)
266    }
267
268    /// Post a comment / activity note.
269    async fn post_comment(&self, id: &ExternalId, body: &str) -> anyhow::Result<()>;
270
271    /// Add metadata labels / tags (additive — does not remove existing labels).
272    /// The GitHub backend uses POST /repos/{repo}/issues/{number}/labels,
273    /// which appends to the existing label set.
274    async fn set_labels(&self, id: &ExternalId, labels: &[String]) -> anyhow::Result<()>;
275
276    /// Remove a label / tag.
277    async fn remove_label(&self, id: &ExternalId, label: &str) -> anyhow::Result<()>;
278
279    /// Get sub-issues (children) of a task.
280    ///
281    /// Returns the list of external IDs for sub-issues.
282    /// Empty list means no sub-issues or sub-issues not supported.
283    async fn get_sub_issues(&self, id: &ExternalId) -> anyhow::Result<Vec<ExternalId>>;
284
285    /// Create a child task and link it as a sub-issue of the parent.
286    ///
287    /// Creates the task via `create_task`, then attempts to establish
288    /// a native sub-issue relationship. Falls back to `parent:{id}` label
289    /// if the native link fails.
290    async fn create_sub_task(
291        &self,
292        parent_id: &ExternalId,
293        title: &str,
294        body: &str,
295        labels: &[String],
296    ) -> anyhow::Result<ExternalId> {
297        // Default: create task with parent label, no native sub-issue link
298        let mut all_labels = labels.to_vec();
299        all_labels.push(format!("parent:{}", parent_id.0));
300        self.create_task(title, body, &all_labels).await
301    }
302
303    /// Ensure a status label exists in the backend system.
304    ///
305    /// Called by the default `update_status` before applying labels.
306    /// GitHub overrides this to auto-create labels on the repo.
307    /// Default is a no-op.
308    async fn ensure_status_label(&self, _label: &str) -> anyhow::Result<()> {
309        Ok(())
310    }
311
312    /// Sync a task to the project board (if configured).
313    ///
314    /// Called when a task is first ingested to ensure it appears on the
315    /// project board immediately, not just when status changes later.
316    /// Returns `Some(node_id)` if the item was added/updated on the project board,
317    /// or `None` if project sync is not configured or failed.
318    /// Default is a no-op returning `None`; GitHub backend implements project board sync.
319    async fn sync_to_project(
320        &self,
321        _id: &ExternalId,
322        _status: Status,
323    ) -> anyhow::Result<Option<String>> {
324        Ok(None)
325    }
326
327    /// Sync a task's estimate to the project board Estimate field.
328    ///
329    /// Called after the router assigns an estimate to a task (via `store_route`).
330    /// Writes the estimate value to GitHub Projects V2 so humans can see it on the board.
331    /// Default is a no-op; GitHub backend implements estimate project sync.
332    async fn sync_estimate_to_project(
333        &self,
334        _id: &ExternalId,
335        _estimate: u8,
336    ) -> anyhow::Result<()> {
337        Ok(())
338    }
339
340    /// Batch-fetch project item estimates for a list of issue node IDs.
341    ///
342    /// Returns a map from issue node ID → estimate value (0 if not set).
343    /// Used during ingestion to populate `tasks.estimate` from GitHub Projects
344    /// when the orch estimate is still 0.
345    /// Default returns an empty map; GitHub backend implements batch estimate fetch.
346    async fn get_project_item_estimates(
347        &self,
348        _issue_node_ids: &[String],
349    ) -> anyhow::Result<std::collections::HashMap<String, u8>> {
350        Ok(std::collections::HashMap::new())
351    }
352
353    /// Check if an open issue with the given title already exists.
354    ///
355    /// Used for deduplication before creating issues. The `label` parameter
356    /// narrows the search to issues with a specific label.
357    /// Default returns `false` (no dedup for backends that don't support it).
358    #[allow(dead_code)]
359    async fn has_open_issue_with_title(&self, _title: &str, _label: &str) -> anyhow::Result<bool> {
360        Ok(false)
361    }
362
363    /// Check if connected and authenticated.
364    async fn health_check(&self) -> anyhow::Result<()>;
365
366    /// Check if a PR/merge request for the given branch has been merged.
367    ///
368    /// Returns false by default (backends that don't track PRs).
369    async fn is_pr_merged(&self, _branch: &str) -> anyhow::Result<bool> {
370        Ok(false)
371    }
372
373    /// Check if PRs for the given branches have been merged, in a single batch.
374    ///
375    /// Returns a map of branch → merged. Backends that support batch queries
376    /// (e.g. via GraphQL) should override this; the default falls back to
377    /// serial `is_pr_merged` calls.
378    async fn batch_is_pr_merged(
379        &self,
380        branches: &[String],
381    ) -> anyhow::Result<std::collections::HashMap<String, bool>> {
382        let mut result = std::collections::HashMap::new();
383        for branch in branches {
384            match self.is_pr_merged(branch).await {
385                Ok(merged) => {
386                    result.insert(branch.clone(), merged);
387                }
388                Err(e) => {
389                    tracing::warn!(branch, err = %e, "failed to check PR merge status");
390                }
391            }
392        }
393        Ok(result)
394    }
395
396    /// Get the authenticated user's username.
397    ///
398    /// Returns None by default (backends that don't support user identity).
399    async fn get_authenticated_user(&self) -> anyhow::Result<Option<String>> {
400        Ok(None)
401    }
402
403    /// Get recent mentions/comments since a given timestamp.
404    ///
405    /// Returns empty by default (backends that don't support mention scanning).
406    async fn get_mentions(&self, _since: &str) -> anyhow::Result<Vec<Mention>> {
407        Ok(vec![])
408    }
409
410    /// Get all comments for a specific task/issue.
411    ///
412    /// Returns empty by default (backends that don't support per-issue comment listing).
413    async fn list_issue_comments(&self, _id: &ExternalId) -> anyhow::Result<Vec<Mention>> {
414        Ok(vec![])
415    }
416
417    /// Acknowledge a newly detected issue (e.g., add a reaction emoji).
418    ///
419    /// Called when an issue is first ingested into the store.
420    /// Default is a no-op; GitHub backend adds an eyes emoji reaction.
421    async fn acknowledge_issue(&self, _id: &ExternalId) -> anyhow::Result<()> {
422        Ok(())
423    }
424
425    /// Acknowledge a mention (comment) by reacting with the eyes emoji.
426    ///
427    /// Called when a new @mention is detected in an issue or PR comment.
428    /// Default is a no-op; GitHub backend adds an eyes emoji reaction to the comment.
429    async fn acknowledge_mention(&self, _comment_id: &str) -> anyhow::Result<()> {
430        Ok(())
431    }
432}
433
434#[cfg(test)]
435mod tests {
436    use super::*;
437    use async_trait::async_trait;
438    use std::sync::{Arc, Mutex};
439
440    /// Mock backend that exercises the default trait `update_status` implementation.
441    ///
442    /// Does NOT override `update_status` — the trait default (retry loop with
443    /// get_task → remove_label → set_labels) is what runs. This means tests
444    /// verify the actual production orchestration logic, not a simplified mock.
445    struct MockBackend {
446        /// Current labels on the (single) tracked issue.
447        labels: Arc<Mutex<Vec<String>>>,
448        /// If set, `remove_label` returns this error for the matching label.
449        remove_err: Option<String>,
450        /// Counter for `set_labels` failures. Each call decrements; fails while > 0.
451        set_labels_fail_count: Arc<Mutex<u32>>,
452    }
453
454    impl MockBackend {
455        fn with_labels(labels: Vec<&str>) -> Self {
456            Self {
457                labels: Arc::new(Mutex::new(labels.into_iter().map(String::from).collect())),
458                remove_err: None,
459                set_labels_fail_count: Arc::new(Mutex::new(0)),
460            }
461        }
462
463        fn current_labels(&self) -> Vec<String> {
464            self.labels.lock().unwrap().clone()
465        }
466    }
467
468    #[async_trait]
469    impl ExternalBackend for MockBackend {
470        fn name(&self) -> &str {
471            "mock"
472        }
473
474        async fn create_task(
475            &self,
476            _title: &str,
477            _body: &str,
478            _labels: &[String],
479        ) -> anyhow::Result<ExternalId> {
480            Ok(ExternalId("1".into()))
481        }
482
483        async fn get_task(&self, _id: &ExternalId) -> anyhow::Result<ExternalTask> {
484            Ok(ExternalTask {
485                id: ExternalId("1".into()),
486                title: "mock".into(),
487                body: "".into(),
488                state: "open".into(),
489                labels: self.current_labels(),
490                author: "user".into(),
491                created_at: "2026-01-01T00:00:00Z".into(),
492                updated_at: "2026-01-01T00:00:00Z".into(),
493                url: "https://example.com".into(),
494            })
495        }
496
497        // update_status is NOT overridden — uses the default trait implementation
498        // which calls get_task, remove_label, set_labels with retry logic.
499
500        async fn list_by_status(&self, _status: Status) -> anyhow::Result<Vec<ExternalTask>> {
501            Ok(vec![])
502        }
503
504        async fn post_comment(&self, _id: &ExternalId, _body: &str) -> anyhow::Result<()> {
505            Ok(())
506        }
507
508        async fn set_labels(&self, _id: &ExternalId, labels: &[String]) -> anyhow::Result<()> {
509            let mut fail_count = self.set_labels_fail_count.lock().unwrap();
510            if *fail_count > 0 {
511                *fail_count -= 1;
512                return Err(anyhow::anyhow!("transient network error"));
513            }
514            drop(fail_count);
515            let mut current = self.labels.lock().unwrap();
516            for l in labels {
517                if !current.contains(l) {
518                    current.push(l.clone());
519                }
520            }
521            Ok(())
522        }
523
524        async fn remove_label(&self, _id: &ExternalId, label: &str) -> anyhow::Result<()> {
525            if let Some(ref err_label) = self.remove_err {
526                if label == err_label {
527                    return Err(anyhow::anyhow!("rate limit (429)"));
528                }
529            }
530            self.labels.lock().unwrap().retain(|l| l != label);
531            Ok(())
532        }
533
534        async fn get_sub_issues(&self, _id: &ExternalId) -> anyhow::Result<Vec<ExternalId>> {
535            Ok(vec![])
536        }
537
538        async fn health_check(&self) -> anyhow::Result<()> {
539            Ok(())
540        }
541    }
542
543    // --- Tests exercise the default trait update_status (retry + remove + add) ---
544
545    #[tokio::test]
546    async fn update_status_replaces_single_old_label() {
547        let backend = MockBackend::with_labels(vec!["status:new", "priority:high"]);
548        let id = ExternalId("1".into());
549        backend
550            .update_status(&id, Status::InProgress)
551            .await
552            .unwrap();
553        let labels = backend.current_labels();
554        assert!(
555            labels.contains(&"status:in_progress".to_string()),
556            "new label added: {labels:?}"
557        );
558        assert!(
559            !labels.contains(&"status:new".to_string()),
560            "old label removed: {labels:?}"
561        );
562        assert!(
563            labels.contains(&"priority:high".to_string()),
564            "non-status label preserved: {labels:?}"
565        );
566    }
567
568    #[tokio::test]
569    async fn update_status_removes_multiple_old_status_labels() {
570        // Simulate state left by a previous partial failure: two status labels
571        let backend = MockBackend::with_labels(vec!["status:in_progress", "status:blocked", "bug"]);
572        let id = ExternalId("1".into());
573        backend.update_status(&id, Status::Done).await.unwrap();
574        let labels = backend.current_labels();
575        let status_labels: Vec<_> = labels.iter().filter(|l| l.starts_with("status:")).collect();
576        assert_eq!(
577            status_labels,
578            vec!["status:done"],
579            "exactly one status label: {labels:?}"
580        );
581    }
582
583    #[tokio::test]
584    async fn update_status_is_idempotent() {
585        let backend = MockBackend::with_labels(vec!["status:done"]);
586        let id = ExternalId("1".into());
587        backend.update_status(&id, Status::Done).await.unwrap();
588        let labels = backend.current_labels();
589        let status_count = labels.iter().filter(|l| l.starts_with("status:")).count();
590        assert_eq!(
591            status_count, 1,
592            "idempotent: still exactly one status label: {labels:?}"
593        );
594    }
595
596    #[tokio::test]
597    async fn update_status_non_status_labels_are_preserved() {
598        let backend =
599            MockBackend::with_labels(vec!["status:routed", "agent:claude", "maintenance"]);
600        let id = ExternalId("1".into());
601        backend
602            .update_status(&id, Status::InProgress)
603            .await
604            .unwrap();
605        let labels = backend.current_labels();
606        assert!(
607            labels.contains(&"agent:claude".to_string()),
608            "agent label preserved: {labels:?}"
609        );
610        assert!(
611            labels.contains(&"maintenance".to_string()),
612            "other label preserved: {labels:?}"
613        );
614    }
615
616    #[tokio::test]
617    async fn update_status_retries_on_transient_set_labels_failure() {
618        let backend = MockBackend::with_labels(vec!["status:new"]);
619        // set_labels fails once, then succeeds on retry
620        *backend.set_labels_fail_count.lock().unwrap() = 1;
621        let id = ExternalId("1".into());
622        backend
623            .update_status(&id, Status::InProgress)
624            .await
625            .unwrap();
626        let labels = backend.current_labels();
627        assert!(
628            labels.contains(&"status:in_progress".to_string()),
629            "label added after retry: {labels:?}"
630        );
631        assert!(
632            !labels.contains(&"status:new".to_string()),
633            "old label removed: {labels:?}"
634        );
635    }
636
637    #[tokio::test]
638    async fn update_status_fails_after_max_retries() {
639        let backend = MockBackend::with_labels(vec!["status:new"]);
640        // set_labels always fails (more failures than retries)
641        *backend.set_labels_fail_count.lock().unwrap() = 10;
642        let id = ExternalId("1".into());
643        let result = backend.update_status(&id, Status::Done).await;
644        assert!(result.is_err(), "should fail after max retries");
645        assert!(
646            result
647                .unwrap_err()
648                .to_string()
649                .contains("failed after 3 attempts"),
650            "error message mentions retry exhaustion"
651        );
652    }
653
654    #[test]
655    fn status_as_label() {
656        assert_eq!(Status::New.as_label(), "status:new");
657        assert_eq!(Status::Routed.as_label(), "status:routed");
658        assert_eq!(Status::InProgress.as_label(), "status:in_progress");
659        assert_eq!(Status::Done.as_label(), "status:done");
660        assert_eq!(Status::Blocked.as_label(), "status:blocked");
661        assert_eq!(Status::InReview.as_label(), "status:in_review");
662        assert_eq!(Status::NeedsReview.as_label(), "status:needs_review");
663    }
664
665    #[test]
666    fn status_serializes_snake_case() {
667        let json = serde_json::to_string(&Status::InProgress).unwrap();
668        assert_eq!(json, "\"in_progress\"");
669    }
670
671    #[test]
672    fn status_deserializes_snake_case() {
673        let status: Status = serde_json::from_str("\"needs_review\"").unwrap();
674        assert_eq!(status, Status::NeedsReview);
675    }
676
677    #[test]
678    fn external_id_clone() {
679        let id = ExternalId("42".to_string());
680        let cloned = id.clone();
681        assert_eq!(id.0, cloned.0);
682    }
683
684    #[test]
685    fn external_task_serializes() {
686        let task = ExternalTask {
687            id: ExternalId("1".to_string()),
688            title: "Test".to_string(),
689            body: "Body".to_string(),
690            state: "open".to_string(),
691            labels: vec!["status:new".to_string()],
692            author: "user".to_string(),
693            created_at: "2026-01-01T00:00:00Z".to_string(),
694            updated_at: "2026-01-01T00:00:00Z".to_string(),
695            url: "https://github.com/test/test/issues/1".to_string(),
696        };
697        let json = serde_json::to_string(&task).unwrap();
698        assert!(json.contains("\"title\":\"Test\""));
699        assert!(json.contains("status:new"));
700    }
701}
702
703#[cfg(test)]
704pub(crate) mod test_helpers;