huskies: merge 869

This commit is contained in:
dave
2026-04-29 14:51:00 +00:00
parent b9bb1ff804
commit f3e4d5d072
8 changed files with 148 additions and 8 deletions
+14 -4
View File
@@ -108,11 +108,21 @@ pub fn resolve_qa_mode(path: &Path, default: QaMode) -> QaMode {
}
}
/// Resolve the effective QA mode from story content (no filesystem access).
/// Resolve the effective QA mode for a story by story ID.
///
/// Parses front matter from `contents` and returns the `qa` field if present,
/// otherwise returns `default`.
pub fn resolve_qa_mode_from_content(contents: &str, default: QaMode) -> QaMode {
/// Checks the typed `qa_mode` CRDT register first. If the register holds a
/// recognised value (`"server"`, `"agent"`, or `"human"`), returns it.
/// Otherwise falls back to parsing the `qa` YAML front-matter field from
/// `contents`. If neither source provides a value, returns `default`.
pub fn resolve_qa_mode_from_content(story_id: &str, contents: &str, default: QaMode) -> QaMode {
// CRDT register takes precedence over YAML front matter.
if let Some(view) = crate::crdt_state::read_item(story_id)
&& let Some(ref s) = view.qa_mode
&& let Some(mode) = QaMode::from_str(s)
{
return mode;
}
// Fall back to YAML front matter for backward compatibility.
match parse_front_matter(contents) {
Ok(meta) => meta.qa.unwrap_or(default),
Err(_) => default,