huskies: merge 960

This commit is contained in:
dave
2026-05-13 13:17:46 +00:00
parent a47fbc4179
commit 77dc09668c
14 changed files with 138 additions and 193 deletions
+9 -7
View File
@@ -42,13 +42,16 @@ pub fn is_config_file(path: &Path, git_root: &Path) -> bool {
path == huskies.join("project.toml") || path == huskies.join("agents.toml")
}
/// Map a pipeline directory name to a (action, commit-message-prefix) pair.
/// Map a typed pipeline stage to a (action, commit-message-prefix) pair.
///
/// Used by the CRDT-to-watcher bridge (in `main.rs`) to derive the action and
/// commit message for `WatcherEvent::WorkItem` events.
pub fn stage_metadata(stage: &str, item_id: &str) -> Option<(&'static str, String)> {
/// Used by the CRDT-to-watcher bridge to derive the action and commit message
/// for `WatcherEvent::WorkItem` events.
pub fn stage_metadata(
stage: &crate::pipeline_state::Stage,
item_id: &str,
) -> (&'static str, String) {
use crate::pipeline_state::Stage;
let (action, msg) = match Stage::from_dir(stage)? {
match stage {
Stage::Upcoming => ("create", format!("huskies: triage {item_id}")),
Stage::Backlog => ("create", format!("huskies: create {item_id}")),
Stage::Coding => ("start", format!("huskies: start {item_id}")),
@@ -66,8 +69,7 @@ pub fn stage_metadata(stage: &str, item_id: &str) -> Option<(&'static str, Strin
Stage::ReviewHold { .. } => ("review_hold", format!("huskies: review_hold {item_id}")),
Stage::Done { .. } => ("done", format!("huskies: done {item_id}")),
Stage::Archived { .. } => ("accept", format!("huskies: accept {item_id}")),
};
Some((action, msg))
}
}
/// Start the filesystem watcher on a dedicated OS thread.
+18 -5
View File
@@ -51,19 +51,32 @@ fn is_config_file_rejects_wrong_root() {
#[test]
fn stage_metadata_returns_correct_actions() {
let (action, msg) = stage_metadata("coding", "42_story_foo").unwrap();
use crate::pipeline_state::{GitSha, Stage};
use chrono::Utc;
let (action, msg) = stage_metadata(&Stage::Coding, "42_story_foo");
assert_eq!(action, "start");
assert_eq!(msg, "huskies: start 42_story_foo");
let (action, msg) = stage_metadata("done", "42_story_foo").unwrap();
let (action, msg) = stage_metadata(
&Stage::Done {
merged_at: Utc::now(),
merge_commit: GitSha(String::new()),
},
"42_story_foo",
);
assert_eq!(action, "done");
assert_eq!(msg, "huskies: done 42_story_foo");
let (action, msg) = stage_metadata("archived", "42_story_foo").unwrap();
let (action, msg) = stage_metadata(
&Stage::Archived {
archived_at: Utc::now(),
reason: crate::pipeline_state::ArchiveReason::Completed,
},
"42_story_foo",
);
assert_eq!(action, "accept");
assert_eq!(msg, "huskies: accept 42_story_foo");
assert!(stage_metadata("unknown", "id").is_none());
}
// ── sweep_done_to_archived (CRDT-based) ─────────────────────────────────