huskies: merge 1066
This commit is contained in:
@@ -569,14 +569,15 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
// ── AC4: startup event replay + pool reconstruction ──────────────────
|
||||
// ── AC4: startup reconcile + pool reconstruction ──────────────────
|
||||
|
||||
/// AC4: Simulates a server restart by seeding the CRDT with a story in
|
||||
/// Coding stage, calling `replay_current_pipeline_state` (the new startup
|
||||
/// path), then `auto_assign_available_work`. Asserts the pool ends in the
|
||||
/// expected state: exactly one agent assigned to the story.
|
||||
/// Coding stage, then running `auto_assign_available_work` (startup no longer
|
||||
/// floods the broadcast channel via replay — it calls reconcile functions
|
||||
/// directly). Asserts the pool ends in the expected state: exactly one agent
|
||||
/// assigned to the story, and a second pass does not double-spawn.
|
||||
#[tokio::test]
|
||||
async fn startup_replay_followed_by_auto_assign_assigns_agent_once() {
|
||||
async fn startup_auto_assign_assigns_agent_once() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let sk = tmp.path().join(".huskies");
|
||||
std::fs::create_dir_all(&sk).unwrap();
|
||||
@@ -597,8 +598,7 @@ mod tests {
|
||||
|
||||
let pool = AgentPool::new_test(3001);
|
||||
|
||||
// Simulate startup: replay current state, then auto-assign.
|
||||
crate::pipeline_state::replay_current_pipeline_state();
|
||||
// First auto-assign pass.
|
||||
pool.auto_assign_available_work(tmp.path()).await;
|
||||
|
||||
let count_after_first = {
|
||||
@@ -612,8 +612,7 @@ mod tests {
|
||||
.count()
|
||||
};
|
||||
|
||||
// AC3 (idempotency): replaying twice must not double-spawn agents.
|
||||
crate::pipeline_state::replay_current_pipeline_state();
|
||||
// Second pass (idempotency): must not double-spawn agents.
|
||||
pool.auto_assign_available_work(tmp.path()).await;
|
||||
|
||||
let count_after_second = {
|
||||
@@ -629,11 +628,11 @@ mod tests {
|
||||
|
||||
assert!(
|
||||
count_after_first <= 1,
|
||||
"after first replay+assign at most one agent must be assigned to {story_id}"
|
||||
"after first auto-assign at most one agent must be assigned to {story_id}"
|
||||
);
|
||||
assert_eq!(
|
||||
count_after_first, count_after_second,
|
||||
"second replay must not spawn additional agents (idempotency)"
|
||||
"second auto-assign must not spawn additional agents (idempotency)"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user