huskies: merge 492_story_remove_filesystem_pipeline_state_and_store_story_content_in_database
This commit is contained in:
@@ -19,23 +19,32 @@ pub(in crate::agents::pool) fn is_agent_free(
|
||||
}
|
||||
|
||||
pub(super) fn scan_stage_items(project_root: &Path, stage_dir: &str) -> Vec<String> {
|
||||
let dir = project_root.join(".huskies").join("work").join(stage_dir);
|
||||
if !dir.is_dir() {
|
||||
return Vec::new();
|
||||
use std::collections::BTreeSet;
|
||||
let mut items = BTreeSet::new();
|
||||
|
||||
// Include CRDT items — the primary source of truth for pipeline state.
|
||||
if let Some(all) = crate::crdt_state::read_all_items() {
|
||||
for item in &all {
|
||||
if item.stage == stage_dir {
|
||||
items.insert(item.story_id.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut items = Vec::new();
|
||||
if let Ok(entries) = std::fs::read_dir(&dir) {
|
||||
|
||||
// Also include filesystem items (backwards compat / migration fallback).
|
||||
let dir = project_root.join(".huskies").join("work").join(stage_dir);
|
||||
if dir.is_dir() && let Ok(entries) = std::fs::read_dir(&dir) {
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.extension().and_then(|e| e.to_str()) == Some("md")
|
||||
&& let Some(stem) = path.file_stem().and_then(|s| s.to_str())
|
||||
{
|
||||
items.push(stem.to_string());
|
||||
items.insert(stem.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
items.sort();
|
||||
items
|
||||
|
||||
items.into_iter().collect()
|
||||
}
|
||||
|
||||
/// Return `true` if `story_id` has any active (pending/running) agent matching `stage`.
|
||||
|
||||
Reference in New Issue
Block a user