#![allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Wiring {
Wired(&'static str),
Orphaned(&'static str),
Absent,
}
impl Wiring {
pub fn is_enforced(self) -> bool {
matches!(self, Wiring::Wired(_))
}
pub fn as_str(self) -> &'static str {
match self {
Wiring::Wired(_) => "wired",
Wiring::Orphaned(_) => "orphaned",
Wiring::Absent => "absent",
}
}
pub fn rationale(self, locator: &str) -> String {
match self {
Wiring::Wired(sym) => format!("enforced at runtime by `{sym}`"),
Wiring::Orphaned(module) => format!(
"NOT ENFORCED — `{locator}` exists in `{module}` but has no production caller; \
declaring the primitive does not cause it to run (§111 F8)"
),
Wiring::Absent => format!(
"NOT ENFORCED — `{locator}` does not exist in the codebase; \
dangling evidence anchor inherited from the removed Python runtime (§111 F8)"
),
}
}
}
const WIRING_TABLE: &[(&str, Wiring)] = &[
("ProvenanceChain", Wiring::Wired("esk::provenance::ProvenanceChain (via store::audit_chain)")),
("ProvenanceChain.append", Wiring::Wired("esk::provenance::ProvenanceChain::append (via store::audit_chain)")),
("axon.runtime.esk.ProvenanceChain", Wiring::Wired("esk::provenance::ProvenanceChain (via store::audit_chain)")),
("axon.runtime.esk.provenance", Wiring::Wired("esk::provenance (via store::audit_chain)")),
("provenance.py", Wiring::Wired("esk::provenance (via store::audit_chain)")),
("HmacSigner", Wiring::Wired("esk::provenance::HmacSigner (via store::audit_chain)")),
("HmacSigner.random", Wiring::Wired("esk::provenance::HmacSigner::random (via store::audit_chain)")),
("HmacSigner.verify", Wiring::Wired("esk::provenance::HmacSigner::verify (via store::audit_chain)")),
("AnomalyDetector", Wiring::Wired("runtime::immune::detector (via cognitive_io_supervisor, §112.d)")),
("axon.runtime.immune.AnomalyDetector", Wiring::Wired("runtime::immune::detector (via cognitive_io_supervisor, §112.d)")),
("AnomalyDetector + ReflexEngine", Wiring::Wired("runtime::immune::{detector,reflex} (via cognitive_io_supervisor, §112.d)")),
("axon.runtime.immune + esk.eid", Wiring::Wired("runtime::immune (via cognitive_io_supervisor, §112.d)")),
("HealKernel", Wiring::Wired("runtime::immune::heal (via cognitive_io_supervisor, §112.d)")),
("axon.runtime.immune.HealKernel", Wiring::Wired("runtime::immune::heal (via cognitive_io_supervisor, §112.d)")),
("HealDefinition.mode", Wiring::Wired("runtime::immune::heal (via cognitive_io_supervisor, §112.d)")),
("LeaseKernel", Wiring::Wired("store::registry::charge_lease")),
("axon.runtime.lease_kernel.LeaseKernel", Wiring::Wired("store::registry::charge_lease")),
("ReconcileLoop", Wiring::Wired("runtime::reconcile_loop (via cognitive_io_supervisor, §112.e)")),
("axon.runtime.reconcile_loop.ReconcileLoop", Wiring::Wired("runtime::reconcile_loop (via cognitive_io_supervisor, §112.e)")),
("axon.runtime.ensemble_aggregator", Wiring::Wired("runtime::ensemble_aggregator (via cognitive_io_supervisor, §112.c)")),
("ReflexEngine", Wiring::Absent),
("axon.runtime.immune.ReflexEngine", Wiring::Absent),
("EpistemicIntrusionDetector.observe", Wiring::Absent),
("axon.runtime.esk.EpistemicIntrusionDetector", Wiring::Absent),
("axon.runtime.esk.eid.IntrusionEvent", Wiring::Absent),
("axon.runtime.esk.PrivacyBudget", Wiring::Absent),
("axon.runtime.esk.privacy", Wiring::Absent),
("gaussian_noise + PrivacyBudget", Wiring::Absent),
("laplace_noise", Wiring::Absent),
("laplace_noise / gaussian_noise", Wiring::Absent),
("Secret", Wiring::Absent),
("Secret[T] invariant", Wiring::Absent),
("Secret.audit_trail", Wiring::Absent),
("SecretAccess", Wiring::Absent),
("axon.runtime.esk.Secret", Wiring::Absent),
("ShieldDefinition + Secret", Wiring::Absent),
("LeaseKernel + Secret.audit_trail", Wiring::Absent),
("tests/test_phase6_runtime.py::TestSecret", Wiring::Absent),
("LambdaEnvelope.tau", Wiring::Absent),
("NetworkPartitionError", Wiring::Absent),
("axon.runtime.handlers", Wiring::Absent),
("axon.runtime.handlers.base", Wiring::Absent),
];
pub fn wiring_of(locator: &str) -> Option<Wiring> {
WIRING_TABLE
.iter()
.find(|(l, _)| *l == locator)
.map(|(_, w)| *w)
}
pub fn wiring_or_absent(locator: &str) -> Wiring {
wiring_of(locator).unwrap_or(Wiring::Absent)
}
const UNENFORCED_FEATURES: &[&str] = &[
];
pub fn feature_is_enforced(feature: &str) -> bool {
!UNENFORCED_FEATURES.contains(&feature)
}
pub fn unenforced_features() -> &'static [&'static str] {
UNENFORCED_FEATURES
}
#[cfg(test)]
mod tests {
use super::*;
use super::super::frameworks::{EvidenceKind, all_frameworks, controls_for};
#[test]
fn every_runtime_invariant_locator_is_classified() {
let mut unclassified: Vec<String> = Vec::new();
for fw in all_frameworks() {
for c in controls_for(fw) {
if c.evidence_kind == EvidenceKind::RuntimeInvariant
&& wiring_of(c.evidence_locator).is_none()
{
unclassified.push(format!(
"{}:{} → `{}`",
fw.as_str(),
c.control_id,
c.evidence_locator
));
}
}
}
assert!(
unclassified.is_empty(),
"RuntimeInvariant control(s) cite evidence with no entry in WIRING_TABLE.\n\
You must state, on the record, whether the kernel is Wired / Orphaned / Absent.\n\
An unclassified runtime claim is how §111 F8 happened.\n{}",
unclassified.join("\n")
);
}
#[test]
fn wired_rows_point_at_rust_symbols_not_python_paths() {
for (locator, wiring) in WIRING_TABLE {
if let Wiring::Wired(sym) = wiring {
assert!(
!sym.starts_with("axon.runtime") && !sym.contains(".py"),
"locator `{locator}` is marked Wired but its symbol `{sym}` is a Python \
path — a Wired row must cite the real Rust symbol that runs"
);
}
}
}
#[test]
fn only_wired_is_enforced() {
assert!(Wiring::Wired("x").is_enforced());
assert!(!Wiring::Orphaned("runtime::lease_kernel").is_enforced());
assert!(!Wiring::Absent.is_enforced());
}
#[test]
fn the_soc2_cc63_lease_claim_is_now_genuinely_enforced() {
let w = wiring_or_absent("axon.runtime.lease_kernel.LeaseKernel");
assert!(
w.is_enforced(),
"§113.d — `LeaseKernel` is on a production path: `StoreRegistry::charge_lease` runs \
on every resolve of a leased store, so a store operation IS a use of the resource \
and the post-expiry one is the CT-2 Anchor Breach. SOC2 CC6.3 may now cite it and \
MEAN it."
);
assert_eq!(w.as_str(), "wired");
}
#[test]
fn unknown_locator_fails_closed() {
assert!(wiring_of("totally::made::up").is_none());
assert!(!wiring_or_absent("totally::made::up").is_enforced());
}
#[test]
fn the_cognitive_io_features_112_wired_are_now_enforced() {
for f in [
"has_observe",
"has_ensemble",
"has_immune",
"has_reflex",
"has_heal",
"has_reconcile",
] {
assert!(
feature_is_enforced(f),
"`{f}` is driven by the CognitiveIoSupervisor (§112) and must now count"
);
}
}
#[test]
fn lease_and_resource_are_enforced_since_113() {
for f in ["has_lease", "has_resource"] {
assert!(
feature_is_enforced(f),
"§113 — `{f}` is enforced. A `resource` governs what runs (an `axonstore` \
derives its DSN and its POOL SIZE from it), and `lease`'s CT-2 Anchor Breach \
has a moment to fire in: the store operation IS the use of the resource. \
Before §113 that guarantee was structurally IMPOSSIBLE, not merely unwired — \
and an impossible guarantee is one that cannot be KEPT, not merely one that \
cannot be broken."
);
}
for f in ["has_shield", "has_endpoint", "has_compliance_annotation"] {
assert!(feature_is_enforced(f), "`{f}` is wired and must still count");
}
}
#[test]
fn the_unenforced_ledger_is_empty_and_that_emptiness_is_earned() {
assert!(
unenforced_features().is_empty(),
"the ledger is expected empty as of §113. Adding an entry back is CORRECT and \
honest when a kernel does not run — but say so out loud in the fase that adds \
it, because it means the compliance engine can no longer say yes for that \
feature. That admission is the point."
);
}
}