huskies: merge 484_story_story_dependencies_in_pipeline_auto_assign

This commit is contained in:
dave
2026-04-04 21:43:29 +00:00
parent 26de009259
commit 5413a26406
6 changed files with 665 additions and 3 deletions
@@ -57,6 +57,18 @@ pub(super) fn is_story_blocked(project_root: &Path, stage_dir: &str, story_id: &
.unwrap_or(false)
}
/// Return `true` if the story has any `depends_on` entries that are not yet in
/// `5_done` or `6_archived`.
///
/// Auto-assign calls this to hold back stories whose dependencies haven't landed.
pub(super) fn has_unmet_dependencies(
project_root: &Path,
stage_dir: &str,
story_id: &str,
) -> bool {
!crate::io::story_metadata::check_unmet_deps(project_root, stage_dir, story_id).is_empty()
}
/// Return `true` if the story file has a `merge_failure` field in its front matter.
pub(super) fn has_merge_failure(project_root: &Path, stage_dir: &str, story_id: &str) -> bool {
use crate::io::story_metadata::parse_front_matter;
@@ -110,4 +122,42 @@ mod tests {
let tmp = tempfile::tempdir().unwrap();
assert!(!has_review_hold(tmp.path(), "3_qa", "99_spike_missing"));
}
#[test]
fn has_unmet_dependencies_returns_true_when_dep_not_done() {
let tmp = tempfile::tempdir().unwrap();
let current = tmp.path().join(".huskies/work/2_current");
std::fs::create_dir_all(&current).unwrap();
std::fs::write(
current.join("10_story_blocked.md"),
"---\nname: Blocked\ndepends_on: [999]\n---\n",
)
.unwrap();
assert!(has_unmet_dependencies(tmp.path(), "2_current", "10_story_blocked"));
}
#[test]
fn has_unmet_dependencies_returns_false_when_dep_done() {
let tmp = tempfile::tempdir().unwrap();
let current = tmp.path().join(".huskies/work/2_current");
let done = tmp.path().join(".huskies/work/5_done");
std::fs::create_dir_all(&current).unwrap();
std::fs::create_dir_all(&done).unwrap();
std::fs::write(done.join("999_story_dep.md"), "---\nname: Dep\n---\n").unwrap();
std::fs::write(
current.join("10_story_ok.md"),
"---\nname: Ok\ndepends_on: [999]\n---\n",
)
.unwrap();
assert!(!has_unmet_dependencies(tmp.path(), "2_current", "10_story_ok"));
}
#[test]
fn has_unmet_dependencies_returns_false_when_no_deps() {
let tmp = tempfile::tempdir().unwrap();
let current = tmp.path().join(".huskies/work/2_current");
std::fs::create_dir_all(&current).unwrap();
std::fs::write(current.join("5_story_free.md"), "---\nname: Free\n---\n").unwrap();
assert!(!has_unmet_dependencies(tmp.path(), "2_current", "5_story_free"));
}
}