MOAT
Internals
Crate path, key types, adjacent protocols for MOAT.
MOAT (Multi-Organization Operations & Treaties) lives in protocols/moat-lib. This page covers where to find the implementation, the key Rust types, and how it composes with adjacent protocols.
Source
| Path | Contains |
|---|---|
protocols/moat-lib/src/lib.rs | ProtocolModule impl, operation dispatch |
protocols/moat-lib/src/protocol.rs | core protocol logic |
protocols/moat-lib/src/types.rs | request/response types (derive schemars::JsonSchema) |
protocols/moat-lib/tests/ | unit + integration tests |
schemas/moat/v1/ | published JSON Schemas |
ProtocolModule contract
impl ProtocolModule for MoatProtocol {
fn protocol_name(&self) -> &'static str { "MOAT" }
fn version(&self) -> &'static str { "v1.0.0" }
fn operations(&self) -> Vec<&'static str> {
vec![
"policy_evaluation",
"violation_detection",
"policy_update",
"compliance_query",
"compliance_assertion",
]
}
async fn invoke(&self, op: &str, payload: Value, ctx: &InvokeContext)
-> Result<Response, ProtocolError>
{
match op {
"policy_evaluation" => self.policy_evaluation(payload, ctx).await,
"violation_detection" => self.violation_detection(payload, ctx).await,
"policy_update" => self.policy_update(payload, ctx).await,
"compliance_query" => self.compliance_query(payload, ctx).await,
"compliance_assertion" => self.compliance_assertion(payload, ctx).await,
_ => Err(ProtocolError::UnknownOperation(op.into())),
}
}
}Adjacent
| Relation | Members |
|---|---|
| Consults | — |
| Records to | MAX · MOTET · MOMENT |
| Subject to | MAXIM · MOAT (cross-org) · MOOT (disputes) |
| Settled with | MEAL · MANA · MADE |
Status
Implemented · production-grade.
Tests
cargo test -p moat-lib --all-featuresSee also
ProtocolModuletrait — the contract- Engine pipeline — the 8 stages
- Plugins — author your own