@coasys/ad4m / Exports / ConsensusRule
Interface: ConsensusRule
Consensus rule for a flow-state transition (or a top-level zero-state flow's completion). Distinct DID counting with optional role restriction.
Design doc §7:
{ n: 1 }— any agent's proposal advances (default).{ n: 2 }— two distinct agents must agree.{ n, fromRole }— only agents matching the role query count.
fromRole reuses ModelQuery (design §7.2) so role definitions live
entirely in the ontology — communities can invent roles like
"Reviewer" / "Guardian" without any code change.
Table of contents
Properties
Properties
fromRole
• Optional fromRole: ModelQuery
Optional role restriction. When set, only DIDs returned by the role
query are counted. Two evaluation shapes (design §7.2):
Shape 1 — didProperty present: run once, extract DIDs from matches.
Shape 2 — $did templated in where: run per candidate.
The executor refuses a rule with a key it does not know, anywhere in
the rule (a misspelt fromRole, or grantedByFlow inside it), and a
key written twice. addFlow rejects such a definition before storing
it, with an error naming the state and the key. A definition that
arrived by sync is refused when read: the edge fires for nobody and the
executor log names the key. It does not drop the key and read a wider
gate.
Defined in
core/src/shacl/SHACLFlow.ts:192 (opens in a new tab)
n
• n: number
Required count of distinct qualifying DIDs.