Type work order closure authority
This commit is contained in:
parent
d1bcbae68f
commit
4094c2c71c
7 changed files with 207 additions and 37 deletions
|
|
@ -7468,89 +7468,79 @@ fn closure_family_assertions(
|
|||
);
|
||||
}
|
||||
"repo.work_order" => {
|
||||
let work_order = parse_repo_work_order(&content).ok();
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"work-order-schema-present",
|
||||
content.contains("schema_version = \"epiphany.repo_work_order.v0\""),
|
||||
work_order
|
||||
.as_ref()
|
||||
.is_some_and(RepoWorkOrder::has_canonical_identity),
|
||||
"Committed work order carries the schema version.".to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"work-order-family-present",
|
||||
content.contains("safe_action_family = \"repo.work_order\""),
|
||||
work_order
|
||||
.as_ref()
|
||||
.is_some_and(RepoWorkOrder::has_canonical_identity),
|
||||
"Committed work order carries the safe action family.".to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"work-order-summary-present",
|
||||
content.contains(&compact_summary),
|
||||
work_order
|
||||
.as_ref()
|
||||
.is_some_and(|value| value.summary == compact_summary),
|
||||
"Committed work order contains the accepted pressure summary.".to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"work-order-awaits-hands-review",
|
||||
content.contains("[work_order]")
|
||||
&& content.contains("status = \"awaiting-hands-review\"")
|
||||
&& content.contains("requested_owner = \"Hands\"")
|
||||
&& content.contains("requested_effect = \"branch-local-implementation\""),
|
||||
work_order
|
||||
.as_ref()
|
||||
.is_some_and(RepoWorkOrder::awaits_hands_review),
|
||||
"Committed work order waits for Hands review before implementation consequence."
|
||||
.to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"work-order-antecedents-present",
|
||||
content.contains("[antecedents]")
|
||||
&& content.contains("objective_draft_ref = ")
|
||||
&& content.contains("adoption_request_ref = ")
|
||||
&& content.contains("scheduling_request_ref = ")
|
||||
&& content.contains("mind_adoption_required = true")
|
||||
&& content.contains("self_queue_selection_required = true"),
|
||||
work_order
|
||||
.as_ref()
|
||||
.is_some_and(RepoWorkOrder::has_antecedent_contract),
|
||||
"Committed work order preserves adoption and scheduling antecedents.".to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"work-order-receipt-contract",
|
||||
content.contains("[required_receipts]")
|
||||
&& content.contains("substrate_gate = \"epiphany.substrate_gate.grant\"")
|
||||
&& content.contains("hands_intent = \"epiphany.hands.action_intent\"")
|
||||
&& content.contains("hands_review = \"epiphany.hands.action_review\"")
|
||||
&& content.contains("hands_patch = \"epiphany.hands.patch_receipt\"")
|
||||
&& content.contains("hands_command = \"epiphany.hands.command_receipt\"")
|
||||
&& content.contains("hands_commit = \"epiphany.hands.commit_receipt\"")
|
||||
&& content.contains("soul_verdict = \"epiphany.soul.verification_verdict\"")
|
||||
&& content.contains("mind_commit = \"epiphany.mind.state_commit_receipt\""),
|
||||
work_order
|
||||
.as_ref()
|
||||
.is_some_and(RepoWorkOrder::has_receipt_contract),
|
||||
"Committed work order names the Substrate/Hands/Soul/Mind receipt chain."
|
||||
.to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"work-order-scope-bounded",
|
||||
content.contains("[scope]")
|
||||
&& content.contains("branch_required = true")
|
||||
&& content.contains("allowed_branch_prefix = \"epiphany/\"")
|
||||
&& content.contains("max_changed_paths = 3")
|
||||
&& content.contains("requires_reviewable_diff = true"),
|
||||
work_order
|
||||
.as_ref()
|
||||
.is_some_and(RepoWorkOrder::has_bounded_scope),
|
||||
"Committed work order scopes later action to bounded branch-local reviewable work."
|
||||
.to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"work-order-authority-seals",
|
||||
content.contains("[authority]")
|
||||
&& content.contains("substrate_access_authorized = false")
|
||||
&& content.contains("hands_action_authorized = false")
|
||||
&& content.contains("shell_command_authorized = false")
|
||||
&& content.contains("commit_authorized = false")
|
||||
&& content.contains("publication_authorized = false")
|
||||
&& content.contains("cross_body_mutation_authorized = false")
|
||||
&& content.contains("bifrost_publication_required = true"),
|
||||
work_order.as_ref().is_some_and(RepoWorkOrder::has_authority_seals),
|
||||
"Committed work order denies substrate/shell/commit/action/publication/cross-body authority."
|
||||
.to_string(),
|
||||
);
|
||||
push_assertion(
|
||||
&mut assertions,
|
||||
"work-order-private-seal",
|
||||
content.contains("private_state_exposed = false"),
|
||||
work_order
|
||||
.as_ref()
|
||||
.is_some_and(|value| !value.private_state_exposed),
|
||||
"Committed work order preserves the private-state seal.".to_string(),
|
||||
);
|
||||
}
|
||||
|
|
@ -15380,6 +15370,7 @@ idunn_deployment_authority_required = true
|
|||
"repo.sync_request",
|
||||
"repo.pr_request",
|
||||
"repo.maintainer_review_request",
|
||||
"repo.work_order",
|
||||
"repo.verification_request",
|
||||
"repo.credit_request",
|
||||
"repo.artifact_acceptance_request",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,116 @@
|
|||
#[derive(Debug, Deserialize)]
|
||||
pub(super) struct RepoWorkOrder {
|
||||
pub(super) schema_version: String,
|
||||
pub(super) safe_action_family: String,
|
||||
pub(super) summary: String,
|
||||
pub(super) private_state_exposed: bool,
|
||||
work_order: RepoWorkOrderBody,
|
||||
antecedents: RepoWorkOrderAntecedents,
|
||||
required_receipts: RepoWorkOrderReceipts,
|
||||
scope: RepoWorkOrderScope,
|
||||
authority: RepoWorkOrderAuthority,
|
||||
}
|
||||
|
||||
impl RepoWorkOrder {
|
||||
pub(super) fn has_canonical_identity(&self) -> bool {
|
||||
self.schema_version == "epiphany.repo_work_order.v0"
|
||||
&& self.safe_action_family == "repo.work_order"
|
||||
}
|
||||
|
||||
pub(super) fn awaits_hands_review(&self) -> bool {
|
||||
self.work_order.status == "awaiting-hands-review"
|
||||
&& self.work_order.requested_owner == "Hands"
|
||||
&& self.work_order.requested_effect == "branch-local-implementation"
|
||||
}
|
||||
|
||||
pub(super) fn has_antecedent_contract(&self) -> bool {
|
||||
!self.antecedents.objective_draft_ref.is_empty()
|
||||
&& !self.antecedents.adoption_request_ref.is_empty()
|
||||
&& !self.antecedents.scheduling_request_ref.is_empty()
|
||||
&& self.antecedents.mind_adoption_required
|
||||
&& self.antecedents.self_queue_selection_required
|
||||
}
|
||||
|
||||
pub(super) fn has_receipt_contract(&self) -> bool {
|
||||
let r = &self.required_receipts;
|
||||
r.substrate_gate == "epiphany.substrate_gate.grant"
|
||||
&& r.hands_intent == "epiphany.hands.action_intent"
|
||||
&& r.hands_review == "epiphany.hands.action_review"
|
||||
&& r.hands_patch == "epiphany.hands.patch_receipt"
|
||||
&& r.hands_command == "epiphany.hands.command_receipt"
|
||||
&& r.hands_commit == "epiphany.hands.commit_receipt"
|
||||
&& r.soul_verdict == "epiphany.soul.verification_verdict"
|
||||
&& r.mind_commit == "epiphany.mind.state_commit_receipt"
|
||||
}
|
||||
|
||||
pub(super) fn has_bounded_scope(&self) -> bool {
|
||||
self.scope.branch_required
|
||||
&& self.scope.allowed_branch_prefix == "epiphany/"
|
||||
&& self.scope.max_changed_paths == 3
|
||||
&& self.scope.requires_reviewable_diff
|
||||
}
|
||||
|
||||
pub(super) fn has_authority_seals(&self) -> bool {
|
||||
let a = &self.authority;
|
||||
a.branch_local_only
|
||||
&& !a.substrate_access_authorized
|
||||
&& !a.hands_action_authorized
|
||||
&& !a.shell_command_authorized
|
||||
&& !a.commit_authorized
|
||||
&& !a.publication_authorized
|
||||
&& !a.cross_body_mutation_authorized
|
||||
&& a.bifrost_publication_required
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RepoWorkOrderBody {
|
||||
status: String,
|
||||
requested_owner: String,
|
||||
requested_effect: String,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RepoWorkOrderAntecedents {
|
||||
objective_draft_ref: String,
|
||||
adoption_request_ref: String,
|
||||
scheduling_request_ref: String,
|
||||
mind_adoption_required: bool,
|
||||
self_queue_selection_required: bool,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RepoWorkOrderReceipts {
|
||||
substrate_gate: String,
|
||||
hands_intent: String,
|
||||
hands_review: String,
|
||||
hands_patch: String,
|
||||
hands_command: String,
|
||||
hands_commit: String,
|
||||
soul_verdict: String,
|
||||
mind_commit: String,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RepoWorkOrderScope {
|
||||
branch_required: bool,
|
||||
allowed_branch_prefix: String,
|
||||
max_changed_paths: u64,
|
||||
requires_reviewable_diff: bool,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RepoWorkOrderAuthority {
|
||||
branch_local_only: bool,
|
||||
substrate_access_authorized: bool,
|
||||
hands_action_authorized: bool,
|
||||
shell_command_authorized: bool,
|
||||
commit_authorized: bool,
|
||||
publication_authorized: bool,
|
||||
cross_body_mutation_authorized: bool,
|
||||
bifrost_publication_required: bool,
|
||||
}
|
||||
|
||||
pub(super) fn parse_repo_work_order(text: &str) -> Result<RepoWorkOrder> {
|
||||
toml::from_str(text).context("work order is not valid typed TOML")
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(super) struct RepoVerificationRequest {
|
||||
pub(super) schema_version: String,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,52 @@
|
|||
mod workflow_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn work_order_comment_cannot_counterfeit_hands_authority_seal() {
|
||||
let text = r#"
|
||||
schema_version = "epiphany.repo_work_order.v0"
|
||||
safe_action_family = "repo.work_order"
|
||||
summary = "summary"
|
||||
private_state_exposed = false
|
||||
[work_order]
|
||||
status = "awaiting-hands-review"
|
||||
requested_owner = "Hands"
|
||||
requested_effect = "branch-local-implementation"
|
||||
[antecedents]
|
||||
objective_draft_ref = "objective"
|
||||
adoption_request_ref = "adoption"
|
||||
scheduling_request_ref = "schedule"
|
||||
mind_adoption_required = true
|
||||
self_queue_selection_required = true
|
||||
[required_receipts]
|
||||
substrate_gate = "epiphany.substrate_gate.grant"
|
||||
hands_intent = "epiphany.hands.action_intent"
|
||||
hands_review = "epiphany.hands.action_review"
|
||||
hands_patch = "epiphany.hands.patch_receipt"
|
||||
hands_command = "epiphany.hands.command_receipt"
|
||||
hands_commit = "epiphany.hands.commit_receipt"
|
||||
soul_verdict = "epiphany.soul.verification_verdict"
|
||||
mind_commit = "epiphany.mind.state_commit_receipt"
|
||||
[scope]
|
||||
branch_required = true
|
||||
allowed_branch_prefix = "epiphany/"
|
||||
max_changed_paths = 3
|
||||
requires_reviewable_diff = true
|
||||
[authority]
|
||||
branch_local_only = true
|
||||
substrate_access_authorized = false
|
||||
# hands_action_authorized = false
|
||||
hands_action_authorized = true
|
||||
shell_command_authorized = false
|
||||
commit_authorized = false
|
||||
publication_authorized = false
|
||||
cross_body_mutation_authorized = false
|
||||
bifrost_publication_required = true
|
||||
"#;
|
||||
let work_order = parse_repo_work_order(text).expect("fixture is typed TOML");
|
||||
assert!(!work_order.has_authority_seals());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verification_comment_cannot_counterfeit_soul_verdict_seal() {
|
||||
let text = r#"
|
||||
|
|
|
|||
Reference in a new issue