pub use crate::adversarial::{
full_catalog, run_gauntlet, Defendant, DefendantCatalog, GauntletFinding, GauntletReport,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AgentTaskKind {
Implementor,
Prosecutor,
Defender,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AgentTask {
pub kind: AgentTaskKind,
pub op_id: String,
pub instruction: String,
}
#[inline]
pub fn task_stream_for_op(op_id: &str) -> Vec<AgentTask> {
vec![
AgentTask {
kind: AgentTaskKind::Implementor,
op_id: op_id.to_string(),
instruction:
"Fix: submit the op spec, reference function, WGSL source, category, and metadata."
.to_string(),
},
AgentTask {
kind: AgentTaskKind::Prosecutor,
op_id: op_id.to_string(),
instruction:
"Fix: write tests that kill every selected mutation and catch every defender."
.to_string(),
},
AgentTask {
kind: AgentTaskKind::Defender,
op_id: op_id.to_string(),
instruction:
"Fix: submit a plausible wrong reference that preserves as many laws as possible."
.to_string(),
},
]
}
#[inline]
pub fn enforce_current_registry() -> GauntletReport {
let specs = crate::spec::op_registry::all_specs();
let catalogs = full_catalog();
run_gauntlet(&catalogs, &specs)
}
pub struct Layer5AdversarialEnforcer;
impl crate::enforce::EnforceGate for Layer5AdversarialEnforcer {
fn id(&self) -> &'static str {
"layer5_adversarial"
}
fn name(&self) -> &'static str {
"layer5_adversarial"
}
fn run(&self, _ctx: &crate::enforce::EnforceCtx<'_>) -> Vec<crate::enforce::Finding> {
let report = enforce_current_registry();
let messages: Vec<String> = report
.escaped()
.into_iter()
.map(|finding| {
format!(
"Fix: defendant `{}` escaped detection on op `{}`; the test suite is not strong enough to catch it. Declare an additional law or strengthen archetypes until this defendant is caught.",
finding.defendant_id, finding.target_op_id,
)
})
.collect();
crate::enforce::finding_result(self.id(), messages)
}
}
pub const REGISTERED: Layer5AdversarialEnforcer = Layer5AdversarialEnforcer;