Skip to content

Static Structure — Packages, Types and Dependency Rules ​

Read top-down: which packages exist and which direction dependencies may flow, then which types live inside them. Both diagrams express the same rule set — the component diagram states it as CI-enforced import assertions, the class diagram as type-level edges.

UML note: mermaid subgraphs express component boundaries and arrows the allowed dependency directions; classDiagram carries type structure with <<trait>> / <<enum>> markers. Reverse or cross-layer dependencies are forbidden (CI import assertions).

Module Boundaries and Dependency Rules ​

Module Dependency Rules (an executable definition of high cohesion, low coupling) ​

#RuleViolationCI
1codec may only import moonbitlang/coreAny internal dependency = redimport assertion
2storage / metadata must not import the broker/handlers layerLayer inversion = redimport assertion
3The client package must not import any server packageBroken dual-platform isolation = redimport assertion
4Cross-cutting packages (observability/admin/security/sim) may be called by the core or call codec/core interfaces; the core must never import observability implementations in reverseUncontrolled observability overhead = redimport assertion
5Cross-module data exchange goes through immutable values/traits only — no shared mutable handles (the BytesView borrow exception is decode-path-only)Review red linereview checklist

Component ↔ Quality-Attribute Mapping (excerpt) ​

ComponentPrimary attributes carried
codecZero overhead, clear semantics (single enum source)
storage / metadataReliability, fault tolerance (quarantine), eventual consistency
delivery / consumptionFunctional correctness, observability (conservation metrics)
replicationHigh availability, distributed fault tolerance, eventual consistency
observability / admin / securityObservability, operational safety, security
simTest infrastructure — side-effect traits in prod code are the zero-overhead premise

Core Type Structure ​

Dependencies point strictly downward (client → codec is independent; within the server, net/codec ← core modules ← admin/observability). Traits are marked «trait». This diagram is the type-level expression of the dependency rules in the table above.

Design Notes (against the coupling rules) ​

  1. Isolation: codec (Frame/FrameDecoder/ErrCode) has zero internal dependencies and is shared by server and client; no server-side class imports the client package, and MortarClient depends only on codec/Conn. These are restatements of rules 1 and 3 in the Module Dependency Rules table above — the table is authoritative and is what CI enforces; this diagram is the type-level view of the same two rules.
  2. The Disk/Clock/Net/Rng traits (only Disk shown) let the core modules run inside the simulation — production and simulation differ only in the impl.
  3. GroupCoordinator.assign is a pure-function slot; incrementality is locked by the CB3 property.
  4. MetricsRegistry is allowlist-registered; QuantileStream has the three-operation interface.