huskies: merge 503_bug_depends_on_pointing_at_an_archived_story_is_silently_treated_as_deps_met_surprising_users

This commit is contained in:
dave
2026-04-09 18:27:25 +00:00
parent 8b2e068d3e
commit 41515e3b8f
6 changed files with 393 additions and 3 deletions
@@ -14,8 +14,8 @@ use super::scan::{
is_story_assigned_for_stage, scan_stage_items,
};
use super::story_checks::{
has_merge_failure, has_review_hold, has_unmet_dependencies, is_story_blocked,
read_story_front_matter_agent,
check_archived_dependencies, has_merge_failure, has_review_hold, has_unmet_dependencies,
is_story_blocked, read_story_front_matter_agent,
};
impl AgentPool {
@@ -24,6 +24,14 @@ impl AgentPool {
/// A story is only promoted if it explicitly lists `depends_on` AND every
/// listed dependency has reached `5_done` or `6_archived`. Stories with no
/// `depends_on` are left in the backlog for human scheduling.
///
/// **Archived dep semantics:** a dep in `6_archived` counts as satisfied (since
/// stories auto-sweep from `5_done` to `6_archived` after 4 hours, and the
/// dependent story would normally already be promoted by then). However, if a
/// dep was already in `6_archived` when the dependent story was created (e.g. it
/// was abandoned/superseded before the dependent existed), a prominent warning is
/// logged so the user can see the promotion was triggered by an archived dep, not
/// a clean completion.
fn promote_ready_backlog_stories(&self, project_root: &Path) {
use crate::io::story_metadata::parse_front_matter;
@@ -49,6 +57,17 @@ impl AgentPool {
if has_unmet_dependencies(project_root, "1_backlog", story_id) {
continue;
}
// Warn if any deps were satisfied via archive rather than via clean done.
let archived_deps = check_archived_dependencies(project_root, "1_backlog", story_id);
if !archived_deps.is_empty() {
slog_warn!(
"[auto-assign] Story '{story_id}' is being promoted because deps \
{archived_deps:?} are in 6_archived (not cleanly completed via 5_done). \
These deps may have been abandoned or superseded. If this promotion is \
unintentional, remove the depends_on or manually move the story back to \
1_backlog."
);
}
// All deps met — promote from backlog to current.
slog!("[auto-assign] Story '{story_id}' deps met; promoting from backlog to current.");
if let Err(e) =
@@ -623,6 +642,53 @@ mod tests {
);
}
// ── Bug 503: archived-dep promotion visibility ─────────────────────────────
/// A backlog story whose dep is in 6_archived must still be promoted
/// (archived = satisfied), but the promotion must not silently skip the warning
/// path. This test verifies the promotion itself fires; the warning is a
/// slog_warn! side-effect that we can't easily assert on in unit tests.
#[tokio::test]
async fn auto_assign_promotes_backlog_story_when_dep_is_archived() {
let tmp = tempfile::tempdir().unwrap();
let root = tmp.path();
let sk = root.join(".huskies");
let backlog = sk.join("work/1_backlog");
let current = sk.join("work/2_current");
let archived = sk.join("work/6_archived");
std::fs::create_dir_all(&backlog).unwrap();
std::fs::create_dir_all(&current).unwrap();
std::fs::create_dir_all(&archived).unwrap();
std::fs::write(
sk.join("project.toml"),
"[[agent]]\nname = \"coder-1\"\nstage = \"coder\"\n",
)
.unwrap();
// Dep 490 is in 6_archived (e.g. a CRDT spike that was archived/superseded).
std::fs::write(archived.join("490_spike_crdt.md"), "---\nname: CRDT Spike\n---\n")
.unwrap();
// Story 478 depends on 490 (the archived spike).
std::fs::write(
backlog.join("478_story_dependent.md"),
"---\nname: Dependent\ndepends_on: [490]\n---\n",
)
.unwrap();
let pool = AgentPool::new_test(3001);
pool.auto_assign_available_work(root).await;
// Story 478 must be promoted to 2_current/ even though dep 490 is only in
// 6_archived (not in 5_done), because archived = satisfied.
assert!(
current.join("478_story_dependent.md").exists(),
"story 478 should be promoted to 2_current/ when dep 490 is in 6_archived"
);
assert!(
!backlog.join("478_story_dependent.md").exists(),
"story 478 must be removed from 1_backlog/ after promotion"
);
}
/// Stories in backlog with NO depends_on must NOT be auto-promoted.
#[tokio::test]
async fn auto_assign_does_not_promote_backlog_story_without_deps() {