huskies: merge 869
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user