Skip to main content

levi_core/entities/
dependency.rs

1use myko::prelude::*;
2
3/// blocker blocks blocked. id = "{blocker_task_id}->{blocked_task_id}" —
4/// deterministic, so `dep add` is idempotent and `dep rm` is a plain DEL.
5#[myko_item]
6pub struct Dependency {
7    pub project_id: String,
8    pub blocker_task_id: String,
9    pub blocked_task_id: String,
10    /// Set when the blocker lives in another project (cross-project dep).
11    #[serde(default)]
12    pub blocker_project_id: Option<String>,
13    /// Consumption branch for cross-project resolution; None = the foreign
14    /// project's default branch.
15    #[serde(default)]
16    pub blocker_ref: Option<String>,
17    /// Agent-authored note on *how* the dependency is consumed (e.g.
18    /// "cargo: crates.io myko ^4.24"). levi never parses it.
19    #[serde(default)]
20    pub via: Option<String>,
21}
22
23pub fn dependency_id(blocker: &str, blocked: &str) -> String {
24    format!("{blocker}->{blocked}")
25}
26
27/// Deterministic id for a cross-project dependency.
28pub fn foreign_dependency_id(blocker_project: &str, blocker: &str, blocked: &str) -> String {
29    format!("{blocker_project}/{blocker}->{blocked}")
30}
31
32/// The ladder/cache key for a foreign blocker.
33pub fn foreign_key(project_id: &str, task_id: &str) -> String {
34    format!("{project_id}/{task_id}")
35}