Governance
Governance for Nexus views — projection policies, access reviews, and view lifecycle control.
Purpose
Multi-strand ordered views with governance, custom ordering, strand input stats, and materialized projections.
This page follows the real source shape for Nexus and explains the workflow a developer is likely to use first.
Developer workflow
Start from the smallest constructor or builder, perform one meaningful operation, inspect the returned state, then add the relevant policy, storage, or network integration. The examples below should be expanded whenever the crate API changes.
Nexus views are deterministic given their inputs. Two peers with the same upstream strands and the same CustomOrdering will produce byte-identical views. Re-derive the view rather than replicate it.
Primary types to know
AllowAllPolicy— models/nexus/src/governance.rsApprovalRecord— models/nexus/src/governance.rsCustomOrdering— models/nexus/src/ordering.rsGovernancePolicy— models/nexus/src/governance.rsGovernanceRules— models/nexus/src/governance.rsIndexOrdering— models/nexus/src/ordering.rsInputStrand— models/nexus/src/strand_input.rsMemoryView— models/nexus/src/view.rsNexus— models/nexus/src/nexus.rsNexusConfig— models/nexus/src/config.rsNexusCursor— models/nexus/src/view.rsPage— models/nexus/src/view.rs
Example shape
use nexus::{GovernanceAuthority, GovernancePolicy};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Authority chooses the trust model: single founder, M-of-N threshold,
// or an allow-list of organizations.
let _single = GovernanceAuthority::SingleKey("a".repeat(64));
let threshold = GovernanceAuthority::MultiKeyThreshold {
founders: vec!["a".repeat(64), "b".repeat(64), "c".repeat(64)],
threshold: 2,
};
let orgs = GovernanceAuthority::OrganizationList(vec![
"did:l1fe:org:trusted".into(),
"did:l1fe:org:partner".into(),
]);
// GovernancePolicy controls participation: explicit approvals, allow-lists,
// and per-org caps. Defaults allow same-org agents without approval.
let policy = GovernancePolicy {
allow_same_org: true,
require_approval: true,
approved_orgs: vec!["did:l1fe:org:trusted".into()],
denied_orgs: vec!["did:l1fe:org:revoked".into()],
max_agents_per_org: Some(8),
};
println!(
"authority(threshold)={:?} approved={} denied={} cap={:?}",
match &threshold {
GovernanceAuthority::MultiKeyThreshold { threshold, .. } => *threshold,
_ => 0,
},
policy.approved_orgs.len(),
policy.denied_orgs.len(),
policy.max_agents_per_org,
);
let _ = orgs;
Ok(())
}