Advanced seams¶
The node facade (node/) is the configuration and observation surface a
host is meant to use: node.Config, node.New, Start, Stop, and the
accessors of node.Node. Together with device/ (the device kit),
contract/ (the port interfaces), schema/ (the embedded matter.js
model), eligibility/ (ecosystem knowledge for the host) and the
cluster/… servers a host adapts, it is the typed surface a host builds
on.
Every package below the facade stays public API (README §API stability), and a host may need one of them. This page lists them: what each gives, when a host needs it, and what it costs — what the facade no longer guarantees once a host goes around it.
What the facade covers¶
A host names none of the packages below for these:
| Need | Facade route |
|---|---|
| The store | Config.Store.Path (the node opens and closes the SQLite file), or Store.DB for the host's own handle |
| DNS-SD | a nil Config.Advertiser: the module's mDNS responder, shaped by Network.MDNS (Off, HostName) and Network.InterfaceCheck (how often it and GeneralDiagnostics compare the host's interfaces; negative disables); Node.MDNSEnabled, MDNSServices, DiagnoseMDNS, TriggerReannounce |
| Attestation | Config.Attestation.Files; Attestation.BlockCommissioningOnError and Node.AttestationError for a host that keeps running on a broken chain |
| Credentials | node.NewCommissioningCredentials, node.NewWindowCredentials(timeout), Commissioning.WindowCredentials, node.ValidateSetupPIN, node.MaxDiscriminator, node.PBKDFIterationsMin/Max, node.PBKDFSaltMin/Max; Node.PairingCodesFor, Node.SetupPayload (the configured passcode, discriminator, vendor and product id with both codes) |
| The commissioning window | Node.Window(): open, kind (WindowOwn, WindowBasic, WindowEnhanced, WindowAdministratorBasic), advertised discriminator and mode, opened-at, deadline and timeout on the node's clock — the value OnWindowTransition receives; Node.OpenOwnWindow (the configured credentials), Node.OpenBasicWindow (the host's), Node.CloseWindow (whoever opened it), Node.SetCommissioningBlocked. The bridge's window type with its Set… wiring is reached only through Node.Bridge(): its SetTransitionHook adds a host hook that runs after the facade's own |
| Health | Config.Health{Interval}, Node.OnHealthSample / OnHealthSampleAsync, Node.Health, Node.LocalAddr |
| Fabrics | Node.FabricInfos, Node.RemoveFabric, Config.Observers, and Node.Observe / Node.ObserveAsync for hooks registered on a running node |
| The served surface | Node.Surface(): the policies' digest, level, profiles, extensions, the effective surface, every decision, the withheld elements and the announced changes; Observers.OnSurfaceChanged for each change as it is announced |
| Sessions | Node.SessionDiagnostics(): each session's id, fabric, peer and local node id, PASE or CASE, subscription count, last activity and idle ages, the session intervals the peer reported in its handshake (PeerIdleInterval, PeerActiveInterval, PeerActiveThreshold), and the session table's occupancy — read-only; Node.Clock() for ages a host computes itself; Observers.OnSessionOpened, OnSessionClosed, OnSubscriptionsChanged report each change with the session's SessionInfo (CASE sessions; matter.js SessionsBehavior events) |
| UniqueID | Node.UniqueID; bootid.EnableRotation() for the development rotation (process-wide, called once before node.New) |
| The served topology | Node.Topology(): the Aggregator's endpoint and each bridged device's key, endpoint, device type and its revision, name, reachability, mounted clusters (id, schema name, revision: node.ClusterInfo) and parts (node.BridgeTopology, node.BridgedDevice); Node.Endpoints(): every endpoint by number with its parent and its Descriptor's PartsList, DeviceTypeList and ServerList (node.EndpointInfo) — the controller's view of the same tree |
| A device's lifecycle | Device.SetReachable, Device.Rename (a persisted label, as a controller writes it), Device.Update (the host's statements: name, addresses — persisted nowhere, a written label wins), Device.EndpointNumber; Aggregator.Add, Remove (the key keeps its endpoint number for its return), Replace, Forget (frees it) |
| A bridged NodeLabel | device.ComposeNodeLabel(base, suffix): the parameter suffix and the 32-byte cap of the generated definition; device.New, Rename and Update cap a name with it |
| Served values and events | Node.ReadAttribute, Node.ReadCluster (node.AttributeValue with its DataVersion and JSON()), Node.Events(node.EventQuery) (node.Event), Observers.OnEvent — the node's own read path and event log without Bridge().Dispatcher() or Bridge().EventLog(); see Observability |
| Who changed an attribute | contract.Change.Origin in every OnChanged callback (OriginHostSet, OriginControllerWrite, OriginCommand) |
| Field and return types | the aliases node.Groups (Config.Groups, Node.Groups), node.Advertiser (Config.Advertiser), node.Snapshotter, Topology, TCPConfig, DiagnosticEvent, HealthSample, MDNSFinding, MDNSService, AttestationFiles, AttestationChain, WindowStatus, DeviceTypeValidationMode, CapabilityMinimaStruct, GeneralDiagnosticsFeatures; the host ports node.OTAImageSource, OTAConsent, OTAConsentState, OTAApplyPolicy (deprecated), OTAUpdateManager, OTAUpdateAttempt, OTAPeer, OTAUpdateStatus, OTAApplier, WiFiReporter, CommissioningApprover, ReverseCommissioner; device.SourceKey |
| The camera's signals to a requestor | camera.Provider.Offer, Answer, IceCandidates, End: the requestor's commands invoked on the session's peer node, fabric and endpoint over a CASE session the node initiates; the node attaches the route (camera.PeerConnector) to every provider it assembles |
| Peers (seam) | Node.Peers() returns the client stack's *peer.Set (nil without Config.Client); no facade route yet, the type stays the controller package's |
| Bindings (seam) | Node.Bindings() returns the *binding.Manager that resolves the Binding servers' entries into peers; no facade route yet |
| The commissioner's collaborators (seam) | controller/commissioner.Context (what a Commissioner works with: the exchange manager, the peer set, the attestation trust store, the clock — matter.js ControllerCommissionerContext) and commissioner.Channel (the PASE carrier when it is not the UDP socket: a BLE connection's BTP session, controller/ble.Channel); a host that commissions through controller/client never builds either |
| A controller program | controller.New(ctx, controller.Config{DB, Attestation, …}) builds the role's stack in one call and Controller.Pair commissions by pairing code, Controller.PairDiscovered a device Controller.Discover found by its passcode; Controller.Registry(), Commissioner(), Fabric() and Peers() are the role's seams, for a host that drives the registry, the commissioner's options, the fabric record or a peer it did not pair through the registry itself; Config.CAKey takes the CA root key out of the database |
| The controller's reads and writes | the role's own types in controller/client (AttributePath, ReadRequest, SubscribeRequest, Report, WriteRequest, Result, StatusError, PeerAddress, Device, Timing, …, with AttributeAt, ClusterAt, CommandAt, EventAt); a written scalar is a spec.Value (spec.Int16(2250), spec.Null[uint16]()); a typed read is the generated <cluster>def.StateFrom over a client cluster or Report.Values |
| What Matter and the ecosystems make of a source | eligibility (Classify, DeriveMatterEligibility, EcosystemForVendor, VendorName, Compat): a package of the typed surface beside schema, not a seam — it imports only contract and schema and reaches nothing below the facade, so it needs no route |
| OTA provider values and image files | node.OTAImage, node.OTAFileDesignator, node.OTABlob (what an OTAImageSource returns), node.OTAConsentGranted … OTAConsentUnknown; node.CreateOTAImage(node.OTAImageOptions) and node.ReadOTAImage (the image file format, node.OTAImageHeader) |
| The ledger's software versions | node.NewDCLClient(node.DCLProductionURL), node.DCLOTAVersions (Lookup, CheckForUpdate, Download — a download stops at the type's MaxImageSize, 256 MiB when unset, with dcl.ErrOTAImageTooLarge as the error's cause; the facade has no route for that sentinel), node.VerifyOTAImage, node.DCLSoftwareVersion |
| Aggregator Actions, EcosystemInformation | node.NewActions(node.ActionsConfig{Host}) for Config.AggregatorServers (node.ActionsHost, ActionRequest); node.NewEcosystemInformation(dir) over a node.EcosystemDirectory, declared with ecosysteminformationdef.Declare{HostServer: …} |
| Root servers a host drives after Start | Node.Root()'s fields, named node.BasicInformationServer, node.OTARequestorServer, node.WiFiNetworkDiagnosticsServer, node.PowerSourceConfigurationServer (its SetSourcesProvider) — RootClusters itself stays the seam |
| FixedLabel and UserLabel on a device | fixedlabeldef.Declare{Initial: fixedlabeldef.Patch{LabelList: &labels}} and userlabeldef.Declare{…} on any device type: the clusters the Base device type allows on every endpoint; Device.FixedLabel() and Device.UserLabel() are their typed servers, and a node keeps a UserLabel list under the device's stable key |
| PowerSource on a bridged device | powersourcedef.Declare{Features: …, Initial: …} on any device type that does not list it: BridgedNode allows PowerSource under the condition BridgedPowerSourceInfo, which the device then states; Device.PowerSource() is the typed server, its EndpointList names the device's own endpoint, and a part refuses it |
| A PowerSource's EndpointList | a declared PowerSource names its own endpoint unless powersourcedef.Declare{Initial: Patch{EndpointList: …}} names others; Status, Description, BatChargeLevel, BatReplaceability and WiredCurrentType take matter.js's defaults |
| ContentControl | contentcontroldef.Declare{ContentControl: port} (Enable/Disable, each feature's commands a further interface of the port) |
| ClosureControl's host state | closurecontroldef.Server.Set(Patch{MainState, CurrentErrorList, OverallCurrentState}): the typed Set reaches the server's own setters (MainState Error with a list raises OperationalError, Disengaged the EngageStateChanged event); closure.ControlServer's SetCurrentPosition, SetMainState, SetErrorList and ReportError stay its server methods on cluster/wire types |
| The EV charger | the kit's energy.EvseServer is the EnergyEvse default: a state machine whose hardware inputs (SetHardwareState, SetFault, the hardware limits, ReportRFID, DiagnosticsComplete) and Close are energyevsedef.Server.Host(), the attributes it computes refused by Set; a charger with an EvseHost is cluster/energy.NewEnergyEvse mounted with energyevsedef.Declare{HostServer: …} (seam), and Host() reaches it too, since it is the kit's type |
| A kit server's own methods | <cluster>def.Server.Host(): the methods of the kit's server that Set, Get and the typed handlers do not reach, as the cluster's Host interface (Host ports); nil over a server that does not implement it |
| ContentAppObserver (seam) | CastingVideoClient serves it optionally, as matter.js's casting-video-client.ts lists it, through the generated contentappobserverdef.Declare; cluster/media.NewContentAppObserver through device.HostServer is the seam for the hand-written server (matter.js's ContentApp lists the cluster as a client, ObserverClient) |
Lower-layer types on Node (seams) |
Node.SessionParameters() (node.SessionParameters), Node.OTAProvider() (node.OTAProviderServer), Node.BDX() (node.BDXResponder), Node.CommissionerControl() (node.CommissionerControlServer), ClientConfig.Names (node.DiscoveryNames): the lower packages' types under names the facade owns, for a host that drives the provider's transfers, the commissioner control or its own DNS-SD cache |
| Window errors | node.ErrAdministratorWindowOpen, ErrCommissioningBlocked, ErrCommissioningWindowAlreadyOpen, ErrCommissioningWindowNotConfigured (the bridge's values, for errors.Is) |
An alias is the type of the lower package under a second name, not a new type: a host that names it does not import the package, and code written against the original keeps compiling.
Source: node/facade.go, node/config.go, node/mdns.go, node/attestation.go, node/credentials.go, node/health.go, node/store_path.go, node/observers.go, node/lifecycle.go (Topology), device/lifecycle.go, contract/ (Change).
Underlying()¶
Every typed server's Underlying() returns the contract.ClusterServer
it wraps. It is a seam for two cases: a host that mounts its own server
type (Declare.HostServer, device.HostServer) and wants it back, and a
host or test that needs the contract value itself (MatterRead,
MatterInvoke). A host that stays on the facade does not type-assert it:
Set, Get and the typed handlers reach the server's state, and Host()
the kit server's own methods.
Costs. A type assertion names the kit's server package and its type, which the facade does not keep stable: the assertion compiles against one server and breaks when the device mounts another.
bridge¶
Gives. Node.Bridge() returns the *bridge.Bridge the node runs on:
the Attach… and Set… ports, Reassemble, the event log
(EventLog; the facade reads it through Node.Events), the controller round-trip statistics (ControllerRTT) and
the hook the facade leaves to the host (SetOnReassembled; a fabric's
installation is node.Observers.OnFabricAdded).
When. A host that records controller round trips, or needs a port the
facade does not configure. The served topology and a device's reachability
have facade routes (Node.Topology, Device.SetReachable; see the table
above); the bridge's Topology stays for the whole endpoint tree with its
cluster servers, NotifyDeviceReachable for a host that assembles its own
endpoints behind Config.Snapshotter. The facade's own ports are listed in
Host ports; the bridge's package doc lists every port in call
order with what a skip costs
(bridge/bridge.go).
Costs. The facade attaches every port in the documented order. An
Attach… call replaces what the facade attached for that port, and with
it the facade's wiring behind it — the fabric fan-out, the window
semantics, the persistence the facade threads through. Four hooks are
the exception: the fabric-removed and fabric-updated hooks of
OperationalCredentials, GeneralCommissioning's commissioning-complete
hook and the window's SetTransitionHook keep the facade's handler in a
slot of its own, and a host's Set… adds a handler that runs after it. A
host that drives
bridge.New itself instead of node.New takes over the whole order, and
bridge.New answers every unattached port with a no-op.
Source: node/node.go (Node.Bridge), bridge/bridge.go (AttachACLLister replaces, on a running bridge at once; Reassemble, SetOnReassembled, Topology, EventLog, ControllerRTT), bridge/receive.go (NotifyDeviceReachable).
endpoint¶
Gives. The Matter-near level: endpoint.Assembler, endpoint.Spec,
endpoint.Topology, the endpoint-number store (endpoint.Store,
endpoint/sqlitestore). ComposeNodeLabel has the facade route device.ComposeNodeLabel.
When. A host that assembles its own topology from its own device model
— its own Spec producer feeding an endpoint.Assembler behind
Config.Snapshotter (a node.Snapshotter); the Endpoint and Topology
values the assembler returns are read-only to the host, and a hand-built
topology loses its DataVersions, Groups and Scenes state, and a written
NodeLabel, on every Reassemble — as
the existing layer stays for it beside the device kit
(ADR 0018). It hands the
facade's group state (Node.Groups) and endpoint persistence
(node.NewEndpointState, the facade's own over the node's store, or the
host's own node.EndpointState in Config.EndpointState) to that
assembler as endpoint.Config.Persistence.
A sensor built from a classified measurement source does not need the
seam: device.Measurement(src) mounts it on a device of the kit.
Costs. With Config.Snapshotter the node builds no assembler and no
Aggregator (Node.Aggregator is nil). Endpoint numbering, erasing
the numbers of devices that are gone (Store.RemoveEndpoint), device-type
validation of the bridged endpoints and the bridged NodeLabel and scene
persistence are the host assembler's to get right.
Source: node/config.go (Config.Snapshotter, Config.EndpointState), node/node.go (New: the assembler only without Topology), node/persist.go (NewEndpointState).
store¶
Gives. The persistence port store.Port (Node.Store): fabrics,
credentials, ACL, groups, subscriptions, settings and the operational
counters, one interface per area. *store.Store implements it over the
schema store.Apply writes, store/memstore in memory.
When. A host that keeps its own values in the settings table (the
reference daemon keeps a blind's position there), a host that hands the
node a store it built on a shared handle or a backend of its own design
(Config.Store.Credentials, any store.Port, proved by
store/storetest), or a host whose migration tool applies the schema
itself (store.Schema). The port and its contract are in
Persistence.
A host that carries the schema in its own migrations follows the
store's: since v0.6.0 it gained matter_thermostat_presets (schema
version 5, v0.8.3, the Thermostat presets) and matter_doorlock_users,
matter_doorlock_credentials and matter_doorlock_schedules (version 6,
v0.8.4, the DoorLock server's users, credentials and schedules) and
matter_icd_registrations (version 7, v0.12.0, an ICD node's Check-In
clients), and version 8 added columns: to matter_fabrics the row's commit
state (pending), its VID verification statement and VVSC and the values a
pending UpdateNOC replaced, to matter_node_identities the NOC, ICAC and
private key a pending UpdateNOC replaced, and to
matter_server_subscriptions the save order (save_seq). Version 9
added matter_resumption's session parameters and the table
matter_owed_fabric_events, version 10 the seal mark of every table that
holds a secret and the DoorLock records' source, version 11
matter_group_key_map's position and matter_resumption's
write_seq, and version 12 matter_resumption's initiator.
store.Store reads and writes on a database at the last
version only (v12); a host that runs store.Migrations() with its own
tool runs every step, through v12, and then calls store.Upgrade once,
which moves the per-fabric VID settings keys into their fabric's columns.
store/migrations/v5.up.sql to v12.up.sql hold the statements; the
tables per version are in Persistence.
Costs. The node writes the same tables. A host that writes a fabric, an ACL row or a group key directly bypasses the fan-out the node runs for the command that writes it (the CASE identity, the operational record, the sessions and subscriptions, the group routing). Read; write only settings of the host's own.
Source: node/node.go (Node.Store, openStores), store/settings.go, store/migrations/ (v5.up.sql … v12.up.sql), store/migrations.go (migrationVersions), examples/reference-bridge/persist.go.
mdns¶
Gives. The advertisers (mdns.Responder, mdns.Noop),
mdns.Diagnose, the optional interface mdns.Enabled.
When. A host with its own advertiser — another mDNS stack on the
machine, a test spy — sets Config.Advertiser.
Costs. A host's advertiser replaces the node's: the subtype records
(the _L<discriminator>._sub answers commissioners filtering by
discriminator need), the broadcast schedule, the clock the node hands it,
the end of the operational broadcast at a CASE connection and the on-demand
announcement work only if the host's advertiser provides them (SetClock,
ServiceConnected, TriggerReannounce; the bridge's session-teardown,
subscription-end and retransmission events take ServiceDisconnected and
ServiceRetransmission, for the session's fabric's operational service
only). Node.Stop closes it either way.
Source: node/mdns.go, node/node.go (New: SetClock), node/reannounce.go, mdns/advertiser.go, mdns/responder.go (NewResponder, ServiceConnected), bridge/securechannel.go (triggerSessionReannounce), bridge/ackpump.go (retransmissionBroadcast), bridge/subscribe.go (AttachSubscriptionManager).
secure/…¶
Gives. secure/attestation (the chain types, LoadChainFiles,
BuildTestChain), secure/setup (the onboarding payload codecs),
secure/spake2, and below them the session, CASE and PASE machinery.
When. A host with a chain the files cannot express — a DAC key held
in an HSM — builds an attestation.Chain and sets
Config.Attestation.Chain (or returns it from Config.Attestation.Provider);
its DAC and PAI must name Config.ProductDescription's vendor and product
id, as a chain Attestation.Files loads must — another product's fails
node.New (from the provider: that commissioner's request) with
attestation.ErrProductMismatch. A host that prints a payload for a node it
does not run encodes it with secure/setup.
A validator that runs without a node — a configuration package, a CLI
that checks a configuration file — imports the bounds from the two leaf
packages directly: secure/setup (IsValidSetupPIN, MaxDiscriminator)
and secure/spake2 (IterationsMin, IterationsMax,
PBKDFMinSaltSize, PBKDFMaxSaltSize), which link no stack behind them
(secure/sessionparams and tlv only). node's re-exports
(node.ValidateSetupPIN, node.MaxDiscriminator, node.PBKDFIterationsMin
and the rest) are for the host that builds the node: importing node for
them links the whole facade, which grew the reference consumer's CLI that
imports its configuration package but no Matter code from 18.4 MB to
32.4 MB (#223).
Costs. Everything else in secure/ is the node's: the session table,
the CASE and PASE responders, the verifier of the commissioning window.
A host that touches them takes the security of the node's commissioning
and sessions into its own hands. Reading them is a facade route,
Node.SessionDiagnostics; the accessors Node.Sessions and
Node.Subscriptions (the aliases node.SessionManager and
node.SubscriptionManager) hand out the mutating managers and are the
seam, for a host that needs what the diagnostics leave out. Closing is
the node's.
Source: node/attestation.go, node/config.go (Attestation.Chain), node/root.go (checkProduct), node/node.go (Sessions, Subscriptions), node/facade.go (the re-exports), secure/setup/setup.go (MaxDiscriminator, IsValidSetupPIN), secure/spake2/spake2.go (IterationsMin, IterationsMax), secure/spake2/wire.go (PBKDFMinSaltSize, PBKDFMaxSaltSize), secure/attestation/files.go (LoadChainFiles).
groups¶
Gives. *groups.Manager: the group table, the key sets, the group
sender.
When. A host with its own assembler mounts the Groups and
ScenesManagement servers over the node's manager (Node.Groups), or
hands the node a manager it built first (Config.Groups).
Costs. One manager must serve the endpoints' Groups servers, the
bridge's group routing and the root's GroupKeyManagement; two managers
over one store diverge in memory. A nil Config.Groups has the node build
the one manager.
Source: node/config.go (Config.Groups), node/node.go (New: groups.NewManager when nil), node/node.go (Node.Groups).
im/subscription¶
Gives. *subscription.Manager (Node.Subscriptions, the alias
node.SubscriptionManager): Active, CountBySession, and Snapshot,
every active subscription as a copy (node.SubscriptionInfo).
When. Rarely: the subscriptions riding on each session are in
Node.SessionDiagnostics (SessionInfo.Subscriptions and
SubscriptionIDs); the manager is for a host that lists them with their
paths.
Costs. The manager's lifecycle is the node's; a host that closes subscriptions itself ends a controller's view without the controller's request.
Source: node/node.go (Subscriptions), im/subscription/manager.go (Snapshot).
diagevent¶
Gives. The diagnostic trace's event type (node.DiagnosticEvent, an
alias of diagevent.Event): the moments that explain a failed pairing,
which the node also serves as DiagnosticLogs.
When. A host that shows the trace. Since v0.10.6 the ring is read
on the facade: Node.DiagnosticEvents, Node.OnDiagnosticEvent and
Node.OnDiagnosticEventAsync, sized by Config.Diagnostics
(Observability).
Costs. None beyond the type: the ring is the node's.
Source: node/facade.go, node/diagnostics.go, node/node.go (diagRing, ringLogs), diagevent/ring.go (Event).
controller/softwareupdate¶
Gives. The update manager the controller runs (softwareupdate.Manager,
its image store Images and the provider ports Manager.ProviderConfig)
below the controller's facade. The provider itself is the controller's
(controller.Config.OTA, served at controller.OTAProviderEndpoint of the
controller's own tree); there is no separate node to start since phase 37.
When. A host that wants the update decisions without the controller's
facade builds a softwareupdate.Manager over its registry and serves the
provider (cluster/core.NewOTAProvider) on a tree of its own.
Costs. The manager's provider identity (Config.ProviderNodeID,
ProviderEndpoint) must be the one the host serves, or the announcements
point nowhere.
Identity. A QueryImage whose vendor and product id are not the ids the
node's attestation validated when it was commissioned
(client.Record.AttestedVendorID/AttestedProductID) is logged as one
Warn line, ota.manager.attested_identity_mismatch, and answered as any
other query: nothing is refused on it. The ids are kept only when the
attestation verified the DAC chain against the trust store up to a
production root, the Certification Declaration is not signed by the Matter
test CD signer and no error finding stands; a node commissioned before the
record kept them, without a trust store, under a test root or a test-signed
declaration, or with a failed attestation or an error finding the policy
accepted, is not judged.
Storage. ImagesConfig.Blobs keeps the image files. A backend whose
own type also implements softwareupdate.BlobStreamer (CreateBlob,
OpenBlob) receives a ledger download as it arrives and is read in place
for every check and BDX transfer; one that does not, MemoryBlobs
included, passes each image through memory whole. Embedding a type that
implements BlobStreamer promotes it, and the embedding type's own Put
and Get are then bypassed for image files. A blob that implements
io.Closer is closed by the BDX server when its transfer ends.
Source: controller/ota.go, controller/ota_provider.go, controller/softwareupdate/manager.go, controller/softwareupdate/provider.go.
controller/topology¶
Gives. The network graph of the controller's commissioned nodes, a
port of matterjs-server's NetworkTopologyService: topology.Build, a
pure function over one topology.Image per node (the root endpoint's
NetworkCommissioning, GeneralDiagnostics, ThreadNetworkDiagnostics and
WiFiNetworkDiagnostics, read by topology.ImageOf), and topology.Service,
which keeps it current — a 2 s debounce after a node's change (a burst
of changes rebuilds at the latest five debounces after its first), a 60 s
periodic rebuild, Refresh re-reading the diagnostics of every online
Thread and Wi-Fi node (four at a time, 30 s at most, concurrent callers
sharing one run) — and calls OnChanged observers only when the graph
moved. Nodes carry matterjs-server's ids ("<node id>", br_<EXTADDR>,
unknown_<EXTADDR>, ap_<BSSID>), kinds, roles and strengths, so a JSON
mapping is one field per field.
Border routers. The controller keeps a passive registry of the Thread
border routers on the LAN (Controller.BorderRouters, package
thread/brdiscovery, after matter.js's BorderRouterRegistry): its DNS-SD
cache admits _meshcop._udp.local and _trel._udp.local, and the registry
keys each border router by its extended address (TXT xa, or a TREL
instance's name) with its extended PAN id, network, vendor and model names,
host name and when it was last seen; an entry no instance carries any more
is pruned 24 h later. topology.New builds with it — a neighbour the
registry knows is a border_router node with those fields, a Thread node
without a network name of its own takes the registry's for its extended
PAN id — and rebuilds on its events. controller.Config.BorderRouters
{Disabled: true} turns it off; topology.Config.BorderRouters names
another registry, and topology.Build(images, entries, now) takes the
entries directly.
When. A host that shows the mesh — the UI's topology page, a server's
get_network_topology:
var changes topology.Changes
changes.Install(&cfg) // before controller.New: the nodes' hooks reach the service
ctrl, err := controller.New(ctx, cfg)
// …
svc := topology.New(ctrl, topology.Config{Changes: &changes, Clock: cfg.Clock})
defer svc.Close()
svc.OnChanged(func(t topology.Topology) { /* push it */ })
Costs. A node's change hook says that a report applied, not which
cluster: every report schedules a debounced rebuild (matterjs-server
filters to the four network clusters), so a burst is bounded at five
debounces, or a node that reports every second would hold every rebuild
off until the periodic one; the hash keeps an unchanged graph from the
observers. An extended address two nodes claim, or an RLOC16 two nodes
of one Thread network claim (an RLOC16 is unique only within a network,
so it is keyed by the extended PAN id), resolves to neither
(matterjs-server keeps the later claim): a neighbour naming it shows as
unknown_<EXTADDR>, and with topology.Config.Logger set the service
logs each such claim once (matter.controller.topology.claim_collision). The route-table edges of matterjs-server are not
built.
Further sources. Nodes the controller has not commissioned join the
graph through Service.AddSource, matterjs-server's addNodeSource: a
topology.Source lists its Images, which the service builds from but
never reads on Refresh; a neighbour matched by RLOC16 links across
sources. go-fabric-server registers its imported test nodes
(import_test_node) this way, so the graph matches what get_nodes
serves, and calls Service.Changed when one is added or removed:
remove := svc.AddSource(testNodes) // a pointer; registering it twice adds it once
defer remove()
// on import or removal of a test node:
svc.Changed() // a debounced rebuild
Source: controller/topology/build.go, controller/topology/thread.go, controller/topology/service.go, thread/brdiscovery/registry.go, client/discovery/watch.go, controller/controller.go (BorderRouters).