Architecture¶
go-fabric plays both Matter roles from one module. This page describes how the pieces fit, where a host connects, and which boundaries are decisions rather than backlog. The decision records carry the reasoning behind each choice; this page is the map.
Two roles¶
| Device / bridge side | Commissioner / controller side | |
|---|---|---|
| What it is | a Matter node: commissioned by a controller, serves clusters | a Matter administrator: discovers, commissions and drives other nodes |
| Entry point | node (facade) or bridge (composition root) |
controller/..., driven by e.g. examples/reference-controller |
| Typical host | a home-automation gateway that exposes its devices to Apple Home, Google Home, Alexa | a controller daemon, a test harness, a gateway that also pairs devices |
| Decision | the original scope | ADR 0020 |
A host can use one role or both. A node that sends to other nodes —
bindings, group commands, an OTA provider, CommissionerControl — runs a
small client stack of its own (node.Config.Client).
Two rules that explain the layout¶
Rich model, dumb bridge. The module owns the Matter wire format and
nothing about devices. Which data point becomes which attribute, which
product maps to which device type, lives in the host behind the port
contracts in contract. contract imports the standard
library only, so a host's types never leak into the module and the module's
release cadence never leaks into the host.
bridge is the composition root, node the facade over it.
bridge depends on every other device-side package and on no host type;
the host hands it a topology through a Snapshotter callback. Every
collaborator beyond its constructor arguments arrives through an
Attach…/Set… call, and an unattached port is a no-op — a half-wired
bridge still answers, wrongly. The package doc of
bridge/bridge.go lists every port in call order,
with what skipping it costs. node does that wiring for you from one
node.Config: the root endpoint, the Aggregator, persistence,
commissioning windows, OTA, the client stack. Start with node; drop to
bridge only when you need a port node does not expose.
The device-side request path¶
transport/udp, transport/tcp datagrams and framed streams
→ transport/message message framing, counters
→ transport/mrp reliability: acks, retransmissions
→ secure/channel session keys, decryption, privacy
→ bridge (receive, im_gate) routing and the IM gates (§8.5.7-style)
→ im Read | Write | Invoke | Subscribe | Timed
→ endpoint (dispatcher) path → endpoint → cluster, ACL and privilege checks
→ cluster/... a contract.ClusterServer
→ the host through the cluster's host port
Handshakes branch off before im: PASE (secure/spake2) while a
commissioning window is open, CASE (secure/sigma) for operational
sessions, both into the session registry (secure/operational).
Reports flow the other way through the subscription engine
(im/subscription).
The controller-side stack¶
client/discovery DNS-SD browse for commissionable and operational nodes
controller/ble BLE scanner, the Central seam, the BTP commissioning channel (transport/btp)
client/exchange unsecured and secure sessions, exchanges, MRP (initiator side; none over BTP)
client/handshake PASE and CASE as initiator, CASE responder for reconnects
controller/ca the fabric's root CA, NOC issuance
controller/attestation DAC → PAI → PAA, Certification Declaration, revocation hook
controller/dcl CSA Distributed Compliance Ledger client (opt-in)
controller/commissioner the commissioning flow (ControllerCommissioningFlow), incl. the Wi-Fi / Thread network steps
client/interaction Read, Write, Invoke, Subscribe as a client
client/peer peer sets, address monitoring, session resumption
controller/client a typed image of each remote node, the registry, sqlstore
The five client/ packages are the client machinery, not the role: the
device side uses them too (binding sends to bound peers through them,
node builds its client stack from them), so they sit in the
model-and-protocol layer and binding and node import them downward
(ADR 0026 principles 1 and 12).
They lived under controller/ before v0.10.0; the old import paths
forwarded to them until v0.12.0, which removed them.
The order of openStack in
examples/reference-controller/cli/stack.go
is the canonical construction order.
Where the data model comes from¶
parity/schema.json: the matter.js element model, extracted at a pinned commit and embedded.schema,cluster/spec,device: generated from it — lookups, every cluster definition, every device type. Never hand-edited.cluster: the servers, hand-written where a cluster has behaviour, the generated standard server otherwise (ADR 0013, ADR 0017).
A refresh of the snapshot is a review decision; regenerating Go from it is mechanical and guarded by tests that fail on drift.
The served surface¶
What a controller sees of a node — per endpoint its device types and per
server cluster its revision, FeatureMap, AttributeList, AcceptedCommandList,
GeneratedCommandList and events — is a value: surface's
Surface, canonically ordered, hashable and diffable. The device layer
decides it before it builds a server: it lists the candidate elements with
their provenance (device type, cluster conformance, host declaration), the
node's policies (node.Config.Surface, the same for every device;
device.Options.Surface must match or Add refuses the device) judge
each one — Refuse over Remove over Warn over Keep, a mandatory element
never removed — and the servers are built from what they keep.
Device.Surface() and Node.Surface() report the effective surface, read
from the built servers through the function the dispatcher serves them
with, and every decision. One policy is built in and judges first: the
reference policy refuses an element a server declares as an Ahead of
matter.js register row (surface.AheadSet; Thermostat MSCH and TEVT, the
root's TimeSynchronization features, the Thread NetworkCommissioning
variant) unless surface.Policies.Extensions enables that row
(surface.ErrExtensionNotEnabled); otherwise the zero-value policies keep
everything, so a node that selects no ahead element composes as it did
before. The second built-in policy composes at a specification level
(surface.Policies.Level, the daemon's --spec-level): a Matter revision
matter.js has shipped, whose table (schema.Levels, schema/levels_gen.go)
is generated from matter.js's release tags (parity/levels/), never from
connectedhomeip's XML (spec levels). The
third axis is the controller profile (surface.Policies.Profiles, the
daemon's --profile), generated from the evidence register
notes/parity/controller_profiles.md:
only a row of the confidence Reproduced removes an element, every other
row that names a served element is a warning decision in the report, and a
profile's level applies when no explicit level is set. The
reference daemon prints its report
with --dump-surface, and make surface-check holds it as a committed
snapshot (script/surfacecheck): every change of what the daemon serves
is a review diff. Once the node has assembled its topology, Node.Surface()
reads the assembled endpoints, so the clusters the endpoint assembler mounts
on a bridged endpoint (Descriptor, BridgedDeviceBasicInformation, Identify,
Groups, ScenesManagement, Binding) and the BridgedNode device type are part
of it (Report.Assembled). The node persists each endpoint's effective
surface next to its ConfigurationVersion, and when an endpoint comes back —
after a restart, a reassembly or a Replace — with a different surface it
announces the change: it raises that endpoint's and, once, the root's
ConfigurationVersion, bumps the DataVersion of its Descriptor and changed
clusters, and logs surface changed with the diff (Report.Changed).
ADR 0030
records the decision.
Package map¶
| Area | Packages |
|---|---|
| Facade and composition | node, bridge, device, endpoint, contract, surface (the served surface and its policies) |
| Clusters | cluster/core (the system set), cluster/spec (generated definitions), cluster/media, cluster/onoff, cluster/levelcontrol, cluster/light, cluster/measurement, … |
| Interaction Model | im, im/subscription |
| Security | secure/... (PASE, CASE, channel, attestation, setup codes, operational sessions), commissioning |
| Transport | transport/udp, transport/tcp, transport/mrp, transport/message, mdns |
| Controller | controller/... (above) |
| Group and data | groups, binding, bdx, bdx/otaimage |
| Persistence | store, endpoint/sqlitestore, controller/client/sqlstore |
| Codec and model | tlv, schema, parity |
| Time | clock (the time port every package reads), clock/clocktest (the test clock) |
| Test support (public API) | bridge/bridgetest, endpoint/endpointtest, surface/surfacetest, clock/clocktest, fabrictest (in-process devices and controllers on an in-memory network) |
Everything outside internal/ is public API under the
deprecation window,
in force again since 2026-11-18 with four consumers: an identifier
v0.23.0 marks is removable in v0.25.0, and every removal names its
replacement in the migration guide.
The facade (node/, device/, contract/, the typed cluster packages,
controller/) is built and reviewed to the principles of
ADR 0025; what stays public below
it is an advanced seam, documented as such. Every layer behind it is held to
ADR 0026.
The layers and their allowed direction are held by script/archcheck
(ADR 0026).
Boundaries that are decisions¶
| Out | Why | Record |
|---|---|---|
| Thread radio | needs hardware and a border router; a commissioner can still hand a device a Thread dataset; an existing OpenThread Border Router is managed over its REST API instead (thread/otbr, cluster/threadbr) |
concept v3, ADR 0027 |
| Bluetooth on a commissioned node | the device side serves BLE only while the node has no fabric: an uncommissioned node is commissioned over BLE through a contract.BLEPeripheral (node.Config.Network.BLE), and a node with a fabric never touches the radio; the commissioner's BLE is decided |
ADR 0031, ADR 0024 |
| The camera's media path | the module serves the camera and WebRTC clusters (milestone 6); capturing, encoding and streaming the media are the host's, behind camera.*Port (camera guide) |
matter.js comparison |
| CSA certification | not pursued; certifiability is the goal | ADR 0011 |
The facade is the host's boundary too: a host configures and observes a
node through node/ and builds on device/, contract/, schema/,
eligibility/ and the cluster/… servers. What stays public below it —
bridge, endpoint, store, mdns, secure/…, groups,
im/subscription, diagevent — and what going around the facade costs is
on Advanced seams;
Migrating to the facade maps each
symbol a host reaches today to its route.
How parity is held¶
matter.js is the gold standard for behaviour; connectedhomeip is the
authority for tool behaviour matter.js does not model. Every behaviour cites
its matter.js source in a // Mirrors … comment, every deliberate
divergence is catalogued in
by_design.md, and standing guards —
schema parity, wire fixtures, the negative-write table, the chip data model
cross-check, the chip certification families — fail the build when the port
drifts. The parity contract lists them.