huskies: merge 961
This commit is contained in:
@@ -463,7 +463,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert!(crate::db::read_content("5_story_test").is_some());
|
||||
assert!(crate::db::read_content(crate::db::ContentKey::Story("5_story_test")).is_some());
|
||||
let parsed: Value = serde_json::from_str(&result).unwrap();
|
||||
assert_eq!(parsed["story_id"], "5_story_test");
|
||||
assert_eq!(parsed["from_stage"], "backlog");
|
||||
@@ -495,7 +495,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert!(crate::db::read_content("6_story_back").is_some());
|
||||
assert!(crate::db::read_content(crate::db::ContentKey::Story("6_story_back")).is_some());
|
||||
let parsed: Value = serde_json::from_str(&result).unwrap();
|
||||
// from_stage may be inaccurate when using the content-store fallback
|
||||
// (it lacks stage tracking), but the move itself must succeed.
|
||||
@@ -527,7 +527,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert!(crate::db::read_content("9907_story_idem").is_some());
|
||||
assert!(crate::db::read_content(crate::db::ContentKey::Story("9907_story_idem")).is_some());
|
||||
let parsed: Value = serde_json::from_str(&result).unwrap();
|
||||
// When CRDT is uninitialised the content-store fallback handles the
|
||||
// move, so idempotency detection may not fire. Verify the to_stage
|
||||
|
||||
@@ -349,7 +349,7 @@ mod tests {
|
||||
let story_file = current_dir.join("24_story_test.md");
|
||||
std::fs::write(&story_file, content).unwrap();
|
||||
crate::db::ensure_content_store();
|
||||
crate::db::write_content("24_story_test", content);
|
||||
crate::db::write_content(crate::db::ContentKey::Story("24_story_test"), content);
|
||||
std::process::Command::new("git")
|
||||
.args(["add", "."])
|
||||
.current_dir(tmp.path())
|
||||
@@ -366,7 +366,7 @@ mod tests {
|
||||
let result = tool_move_story_to_merge(&json!({"story_id": "24_story_test"}), &ctx).await;
|
||||
// Content store should still have the item after the move
|
||||
assert!(
|
||||
crate::db::read_content("24_story_test").is_some(),
|
||||
crate::db::read_content(crate::db::ContentKey::Story("24_story_test")).is_some(),
|
||||
"content store should have the story after move"
|
||||
);
|
||||
// Result is either Ok (agent started) or Err (agent failed - acceptable in tests)
|
||||
|
||||
@@ -219,7 +219,7 @@ pub(crate) async fn tool_run_tests(args: &Value, ctx: &AppContext) -> Result<Str
|
||||
// ran passing tests before it died. Only written when running
|
||||
// in a story worktree (worktree_path arg provided).
|
||||
if passed && args.get("worktree_path").is_some() {
|
||||
crate::db::write_content(&format!("{sid}:run_tests_ok"), "1");
|
||||
crate::db::write_content(crate::db::ContentKey::RunTestsOk(&sid), "1");
|
||||
}
|
||||
return serde_json::to_string_pretty(&json!({
|
||||
"passed": passed,
|
||||
|
||||
@@ -171,7 +171,7 @@ pub(super) async fn tool_status(args: &Value, ctx: &AppContext) -> Result<String
|
||||
));
|
||||
}
|
||||
|
||||
let contents = crate::db::read_content(story_id)
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story(story_id))
|
||||
.ok_or_else(|| format!("Story '{story_id}' has no content in the content store."))?;
|
||||
|
||||
// --- Metadata (story 929: CRDT-first, yaml_residue marks gaps) ---
|
||||
|
||||
@@ -284,7 +284,7 @@ mod tests {
|
||||
let bug_id = result.trim_start_matches("Created bug: ").trim();
|
||||
// Bug content should exist in the CRDT content store.
|
||||
assert!(
|
||||
crate::db::read_content(bug_id).is_some(),
|
||||
crate::db::read_content(crate::db::ContentKey::Story(bug_id)).is_some(),
|
||||
"expected bug content in CRDT for {bug_id}"
|
||||
);
|
||||
}
|
||||
@@ -482,7 +482,7 @@ mod tests {
|
||||
let result = tool_close_bug(&json!({"bug_id": "9901_bug_crash"}), &ctx).unwrap();
|
||||
assert!(result.contains("9901_bug_crash"));
|
||||
assert!(
|
||||
crate::db::read_content("9901_bug_crash").is_some(),
|
||||
crate::db::read_content(crate::db::ContentKey::Story("9901_bug_crash")).is_some(),
|
||||
"content store should have the bug after close"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let contents = crate::db::read_content("9906_story_persist")
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story("9906_story_persist"))
|
||||
.expect("story content should exist in CRDT");
|
||||
assert!(
|
||||
contents.contains("## Test Results"),
|
||||
@@ -649,7 +649,7 @@ mod tests {
|
||||
);
|
||||
|
||||
// Criterion must still be unchecked in the CRDT.
|
||||
let contents = crate::db::read_content("9997_empty_branch")
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story("9997_empty_branch"))
|
||||
.expect("story content should still be in CRDT");
|
||||
assert!(
|
||||
contents.contains("- [ ] Implement the feature"),
|
||||
|
||||
@@ -105,7 +105,7 @@ pub(crate) fn tool_show_epic(args: &Value, _ctx: &AppContext) -> Result<String,
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or("Missing required argument: epic_id")?;
|
||||
|
||||
let content = crate::db::read_content(epic_id)
|
||||
let content = crate::db::read_content(crate::db::ContentKey::Story(epic_id))
|
||||
.ok_or_else(|| format!("Epic '{epic_id}' not found in content store"))?;
|
||||
|
||||
let epic_view = crate::crdt_state::read_item(epic_id)
|
||||
|
||||
@@ -140,7 +140,8 @@ mod tests {
|
||||
// Extract the actual spike ID from the result message (format: "Created spike: <id>").
|
||||
let spike_id = result.trim_start_matches("Created spike: ").trim();
|
||||
// Spike content should exist in the CRDT content store.
|
||||
let contents = crate::db::read_content(spike_id).expect("expected spike content in CRDT");
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story(spike_id))
|
||||
.expect("expected spike content in CRDT");
|
||||
assert!(contents.starts_with("---\ntype: spike\nname: \"Compare Encoders\"\n---"));
|
||||
assert!(contents.contains("Which encoder is fastest?"));
|
||||
}
|
||||
@@ -163,7 +164,8 @@ mod tests {
|
||||
let spike_id = result.trim_start_matches("Created spike: ").trim();
|
||||
|
||||
// Spike content should exist in the CRDT content store.
|
||||
let contents = crate::db::read_content(spike_id).expect("expected spike content in CRDT");
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story(spike_id))
|
||||
.expect("expected spike content in CRDT");
|
||||
assert!(contents.starts_with("---\ntype: spike\nname: \"My Spike\"\n---"));
|
||||
assert!(contents.contains("## Question\n\n- TBD\n"));
|
||||
}
|
||||
|
||||
@@ -239,7 +239,8 @@ mod tests {
|
||||
.trim_start_matches("Created story: ")
|
||||
.trim()
|
||||
.to_string();
|
||||
let content = crate::db::read_content(&story_id).expect("story content should exist");
|
||||
let content = crate::db::read_content(crate::db::ContentKey::Story(&story_id))
|
||||
.expect("story content should exist");
|
||||
assert!(
|
||||
content.contains("## Description"),
|
||||
"Description section missing from story: {content}"
|
||||
|
||||
@@ -115,7 +115,10 @@ pub fn list_bug_files(_root: &Path) -> Result<Vec<(String, String)>, String> {
|
||||
} else {
|
||||
Some(item.name)
|
||||
}
|
||||
.or_else(|| crate::db::read_content(&sid).and_then(|c| extract_bug_name_from_content(&c)))
|
||||
.or_else(|| {
|
||||
crate::db::read_content(crate::db::ContentKey::Story(&sid))
|
||||
.and_then(|c| extract_bug_name_from_content(&c))
|
||||
})
|
||||
.unwrap_or_else(|| sid.clone());
|
||||
bugs.push((sid, name));
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ fn create_bug_file_writes_correct_content() {
|
||||
);
|
||||
|
||||
// Check content exists (either in DB or filesystem).
|
||||
let contents = crate::db::read_content(&bug_id)
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story(&bug_id))
|
||||
.or_else(|| {
|
||||
let filepath = tmp
|
||||
.path()
|
||||
@@ -273,7 +273,8 @@ fn create_spike_file_writes_correct_content() {
|
||||
"spike ID must be numeric-only, got: {spike_id}"
|
||||
);
|
||||
|
||||
let contents = crate::db::read_content(&spike_id).expect("spike content should exist");
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story(&spike_id))
|
||||
.expect("spike content should exist");
|
||||
|
||||
assert!(
|
||||
contents.starts_with("---\ntype: spike\nname: \"Filesystem Watcher Architecture\"\n---"),
|
||||
@@ -305,7 +306,7 @@ fn create_spike_file_uses_description_when_provided() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let contents = crate::db::read_content(&spike_id)
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story(&spike_id))
|
||||
.or_else(|| {
|
||||
let filepath = tmp
|
||||
.path()
|
||||
@@ -328,7 +329,7 @@ fn create_spike_file_uses_placeholder_when_no_description() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let contents = crate::db::read_content(&spike_id)
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story(&spike_id))
|
||||
.or_else(|| {
|
||||
let filepath = tmp
|
||||
.path()
|
||||
@@ -437,7 +438,7 @@ fn create_bug_file_without_depends_on_omits_field() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let contents = crate::db::read_content(&bug_id)
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story(&bug_id))
|
||||
.or_else(|| {
|
||||
let filepath = tmp
|
||||
.path()
|
||||
@@ -485,7 +486,7 @@ fn create_refactor_file_without_depends_on_omits_field() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let contents = crate::db::read_content(&refactor_id)
|
||||
let contents = crate::db::read_content(crate::db::ContentKey::Story(&refactor_id))
|
||||
.or_else(|| {
|
||||
let filepath = tmp
|
||||
.path()
|
||||
|
||||
@@ -119,7 +119,7 @@ mod tests {
|
||||
// Also write to the global content store so read_story_content picks up this
|
||||
// content even when a previous test has left a stale entry for the same ID.
|
||||
crate::db::ensure_content_store();
|
||||
crate::db::write_content(story_id, content);
|
||||
crate::db::write_content(crate::db::ContentKey::Story(story_id), content);
|
||||
}
|
||||
|
||||
// --- create_story integration tests ---
|
||||
|
||||
@@ -280,7 +280,7 @@ mod tests {
|
||||
// Also write to the global content store so read_story_content picks up this
|
||||
// content even when a previous test has left a stale entry for the same ID.
|
||||
crate::db::ensure_content_store();
|
||||
crate::db::write_content(story_id, content);
|
||||
crate::db::write_content(crate::db::ContentKey::Story(story_id), content);
|
||||
}
|
||||
|
||||
// --- create_story integration tests ---
|
||||
|
||||
@@ -67,7 +67,7 @@ mod tests {
|
||||
fs::create_dir_all(¤t).unwrap();
|
||||
fs::write(current.join(format!("{story_id}.md")), content).unwrap();
|
||||
crate::db::ensure_content_store();
|
||||
crate::db::write_content(story_id, content);
|
||||
crate::db::write_content(crate::db::ContentKey::Story(story_id), content);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::path::Path;
|
||||
///
|
||||
/// Returns the story content or an error if not found.
|
||||
pub(crate) fn read_story_content(_project_root: &Path, story_id: &str) -> Result<String, String> {
|
||||
crate::db::read_content(story_id)
|
||||
crate::db::read_content(crate::db::ContentKey::Story(story_id))
|
||||
.ok_or_else(|| format!("Story '{story_id}' not found in any pipeline stage."))
|
||||
}
|
||||
|
||||
@@ -341,7 +341,10 @@ mod tests {
|
||||
fn read_story_content_from_content_store() {
|
||||
crate::db::ensure_content_store();
|
||||
let content = "---\nname: Test\n---\n# Story\n";
|
||||
crate::db::write_content("9878_story_read_test", content);
|
||||
crate::db::write_content(
|
||||
crate::db::ContentKey::Story("9878_story_read_test"),
|
||||
content,
|
||||
);
|
||||
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let result = read_story_content(tmp.path(), "9878_story_read_test").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user