feat(node): add Endpoint.get()/getStateOf(), nodeType discriminant, Read.AttributePaths#3681
Merged
feat(node): add Endpoint.get()/getStateOf(), nodeType discriminant, Read.AttributePaths#3681
Conversation
…ead.AttributePaths - Endpoint.get()/getStateOf() issue batched reads on client nodes and return local state snapshots on server nodes - nodeType: "server" | "client" | "group" replaces isGroup/isLocalNode boolean properties on Node - ClientGroup.get()/getStateOf() throw InvalidGroupOperationError - Read.AttributePaths replaces Read.Plan as dedup accumulator for batched reads Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new endpoint read API (Endpoint.get() / getStateOf()), replaces boolean node-kind flags with a nodeType discriminant, and introduces Read.AttributePaths to accumulate/dedupe attribute paths for batched reads.
Changes:
- Add
Endpoint.get()/Endpoint.getStateOf()for client (batched Matter Read) and server (local snapshot) endpoints; groups reject reads. - Replace
isGroup-style booleans withnodeType: "server" | "client" | "group"and update call sites accordingly. - Rename
Read.PlantoRead.AttributePathsand add tests for dedupe/order behavior.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/protocol/test/action/request/ReadAttributePathsTest.ts | Adds unit tests for Read.AttributePaths ordering and dedupe semantics. |
| packages/protocol/src/action/request/Read.ts | Introduces Read.AttributePaths accumulator/deduper. |
| packages/node/test/node/ClientGroupTest.ts | Verifies group nodes throw on get() / getStateOf(). |
| packages/node/test/endpoint/ErrorsTest.ts | Adds tests for new endpoint read-related error types. |
| packages/node/test/endpoint/EndpointGetTypesTest.ts | Adds compile-time/type-level tests for selector/slice helper types. |
| packages/node/test/endpoint/EndpointGetServerTest.ts | Exercises Endpoint.get() on server nodes (selectors + error cases). |
| packages/node/test/endpoint/EndpointGetClientTest.ts | Exercises Endpoint.get() on client endpoints (selector reads). |
| packages/node/src/node/ServerNode.ts | Implements nodeType = "server". |
| packages/node/src/node/Node.ts | Adds abstract nodeType discriminant to the base node type. |
| packages/node/src/node/ClientNode.ts | Implements nodeType and removes isGroup getter. |
| packages/node/src/node/ClientGroup.ts | Sets nodeType = "group" and overrides get() / getStateOf() to throw. |
| packages/node/src/endpoint/properties/Behaviors.ts | Adds backingFor() helper used by Endpoint.get() path resolution. |
| packages/node/src/endpoint/errors.ts | Adds EndpointBehaviorNotPresentError, AttributeNotPresentError, and EndpointReadFailedError. |
| packages/node/src/endpoint/Endpoint.ts | Implements get() / getStateOf(), selection resolution, path planning, read execution, and slice assembly. |
| packages/node/src/behavior/system/software-update/OtaAnnouncements.ts | Replaces peer.isGroup with peer.nodeType === "group". |
| packages/node/src/behavior/system/network/NetworkClient.ts | Replaces this.#node.isGroup with this.#node.nodeType === "group". |
| CHANGELOG.md | Documents the new endpoint read API feature. |
…wnVersions - Move InvalidGroupOperationError to endpoint/errors.ts to break CJS circular init (Endpoint → ClientGroupInteraction → ClientNodeInteraction → EndpointInitializer) - Group guard in Endpoint#performRead now throws InvalidGroupOperationError - Client reads collect attr-value stream reports and merge over state-view base (handles version-filter empty responses correctly) - GetOptions gains includeKnownVersions to skip version filter injection - ClientNodeInteraction.read skips version filter injection when request fabric-filter doesn't match subscription fabric-filter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mport, visibility - Guard schema access with instanceof ClusterModel before iterating schema.attributes (non-cluster behaviors have no attributes array) - Make ClientStructure.subscribedFabricFiltered public so ClientNodeInteraction can compare fabric-filter settings - Remove explicit chai import from ReadAttributePathsTest (use global expect) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mes, attrNameToId - Normalize isFabricFiltered ?? true before comparing to subscribedFabricFiltered so callers that omit the field still get version filter injection - Fix allowedNames guard: check !== undefined instead of ?.size so an empty Set correctly rejects all attribute names - Precompute attrNameToId map alongside attrs in clusterLookup to replace O(n) schema.attributes.find() with O(1) map lookup - Format fix on includeKnownVersions ternary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Endpoint.get()/getStateOf(): new async read API on client and server endpointsfabricFiltercontrolInvalidGroupOperationError("Groups do not support reading attributes")nodeType: "server" | "client" | "group": replaces scatteredisGroup/isLocalNodeboolean properties onNodewith a typed discriminant literalRead.AttributePaths: renamesRead.Planto an honest, convention-consistent name (accumulates + deduplicatesAttributePath[]for batched reads)Changes
packages/node/src/node/Node.tsabstract readonly nodeType: "server" | "client" | "group"packages/node/src/node/ServerNode.tsnodeType = "server" as constpackages/node/src/node/ClientNode.tsnodeType: "client" | "group" = "client"packages/node/src/node/ClientGroup.tsnodeType = "group",get()/getStateOf()throwpackages/node/src/endpoint/Endpoint.tsget()/getStateOf(), group guard,AttributePathsusagepackages/protocol/src/action/request/Read.tsRead.Plan→Read.AttributePathspackages/node/src/behavior/system/network/NetworkClient.tsisGroup→nodeType === "group"packages/node/src/behavior/system/software-update/OtaAnnouncements.tsisGroup→nodeType === "group"🤖 Generated with Claude Code