use super::{Error, subagent};
use std::path::Path;
pub(crate) const REVIEWER_ROLE: &str = "reviewer";
pub(crate) fn reviewer_goal(parent_worktree: &Path, parent_branch: &str) -> Result<String, Error> {
let parent_goal = std::fs::read_to_string(parent_worktree.join(subagent::GOAL_FILE))?;
Ok(format!(
"You are the reviewer for branch `{parent_branch}`.\n\
\n\
In your context is that branch's transcript and its prior summaries\n\
under `summary/`, up to the compaction point you were forked off. The\n\
compactor forked beside you is about to squash that span out of the\n\
branch's context, so what you do not carry out of it now stops being\n\
inspectable — review before it is forgotten.\n\
\n\
Your tree also carries this workspace's own skills under `skills/`,\n\
checked out fresh from the config commit that governs the branch, and\n\
the workspace's durable facts document where the lineage carries one.\n\
Those are what you may edit, and your edits do not land: they are\n\
staged as a proposal an operator reads, accepts or rejects. An empty\n\
proposal is the expected outcome and costs nobody anything.\n\
\n\
Judge what is worth outliving the span against the dispatching\n\
branch's own goal, not your own preferences:\n\
\n\
<dispatching-branch-goal>\n\
{parent_goal}\n\
</dispatching-branch-goal>\n"
))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_goal_names_the_branch_and_quotes_its_goal() {
let dir = tempfile::TempDir::new().unwrap();
std::fs::write(dir.path().join("goal.md"), "ship the thing\n").unwrap();
let g = reviewer_goal(dir.path(), "20260101-p1").unwrap();
assert!(g.contains("reviewer for branch `20260101-p1`"), "{g}");
assert!(
g.contains("<dispatching-branch-goal>\nship the thing\n\n</dispatching-branch-goal>"),
"{g}"
);
}
#[test]
fn a_dispatching_branch_with_no_goal_declines() {
let dir = tempfile::TempDir::new().unwrap();
assert!(reviewer_goal(dir.path(), "20260101-p1").is_err());
}
}