use serde_json::{Value, json};
use crate::envelope;
use super::Verb;
pub const RAIL: Verb = Verb {
word: "rail",
params: &["workspace", "agent"],
flags: &[],
summary: "the conversation's spine: every operable commit and what hangs off it",
detail: "One notch per step, each carrying the commit that step read \
against, the spend as of it, and where in the chat its rule sits \
— the points a conversation can be forked from. Beside them, the \
children dispatched from this conversation: who each is, where it \
forked from, what it is doing, what it has spent and the last \
thing it said. A conversation nobody forked from answers notches \
and no children, which is the honest empty case rather than an \
error.",
};
pub const GOVERNING: Verb = Verb {
word: "governing",
params: &["workspace", "agent"],
flags: &[],
summary: "which config commit this conversation resolves its policy from",
detail: "A conversation forks off a commit of a `config/*` lineage, and \
the fork settles which lineage governs it — not which commit. \
This answers the commit it resolves, short and full, which \
lineage it follows, and every path that commit's tree holds. \
Where lineages have diverged over its fork point there is no head \
to follow, so it is held on that fork commit and the answer says \
how many reached it. This is the BARE form; the wire also takes \
`at` (resolve as of another commit), which this seat does not \
compose — `lernie ask` carries it. It REFUSES rather than \
answering absent: a conversation with no policy is never true.",
};
pub const FORK: &str = "fork";
const PARENT: &str = "parent";
const FROM: &str = "from";
const ROLE: &str = "role";
const SKILLS: &str = "skills";
const GOAL: &str = "goal";
pub fn rail(workspace: String, agent: String) -> Value {
RAIL.built(vec![workspace, agent], &[])
}
pub fn governing(workspace: String, agent: String) -> Value {
GOVERNING.built(vec![workspace, agent], &[])
}
pub fn fork(workspace: String, parent: String, from: String, role: String, goal: String) -> Value {
json!({
envelope::OP: FORK,
envelope::WORKSPACE: workspace,
PARENT: parent,
FROM: from,
ROLE: role,
SKILLS: Vec::<String>::new(),
GOAL: goal,
})
}