Skip to content

feat(node): add Endpoint.get()/getStateOf(), nodeType discriminant, Read.AttributePaths#3681

Merged
Apollon77 merged 11 commits intomainfrom
feat/endpoint-get-nodetype
May 3, 2026
Merged

feat(node): add Endpoint.get()/getStateOf(), nodeType discriminant, Read.AttributePaths#3681
Apollon77 merged 11 commits intomainfrom
feat/endpoint-get-nodetype

Conversation

@Apollon77
Copy link
Copy Markdown
Collaborator

@Apollon77 Apollon77 commented May 3, 2026

Summary

  • Endpoint.get() / getStateOf(): new async read API on client and server endpoints
    • Client node: issues a single batched Matter Read request; optional fabricFilter control
    • Server node: returns a snapshot of local state (no network I/O)
    • Group node: throws InvalidGroupOperationError("Groups do not support reading attributes")
  • nodeType: "server" | "client" | "group": replaces scattered isGroup / isLocalNode boolean properties on Node with a typed discriminant literal
  • Read.AttributePaths: renames Read.Plan to an honest, convention-consistent name (accumulates + deduplicates AttributePath[] for batched reads)

Changes

File Change
packages/node/src/node/Node.ts abstract readonly nodeType: "server" | "client" | "group"
packages/node/src/node/ServerNode.ts nodeType = "server" as const
packages/node/src/node/ClientNode.ts nodeType: "client" | "group" = "client"
packages/node/src/node/ClientGroup.ts nodeType = "group", get()/getStateOf() throw
packages/node/src/endpoint/Endpoint.ts get()/getStateOf(), group guard, AttributePaths usage
packages/protocol/src/action/request/Read.ts Read.PlanRead.AttributePaths
packages/node/src/behavior/system/network/NetworkClient.ts isGroupnodeType === "group"
packages/node/src/behavior/system/software-update/OtaAnnouncements.ts isGroupnodeType === "group"

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings May 3, 2026 12:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with nodeType: "server" | "client" | "group" and update call sites accordingly.
  • Rename Read.Plan to Read.AttributePaths and 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.

Comment thread packages/node/src/endpoint/Endpoint.ts Outdated
Comment thread packages/node/src/endpoint/Endpoint.ts Outdated
Comment thread packages/node/src/endpoint/Endpoint.ts Outdated
Apollon77 and others added 2 commits May 3, 2026 14:46
…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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Comment thread packages/node/src/endpoint/Endpoint.ts
Comment thread packages/protocol/test/action/request/ReadAttributePathsTest.ts Outdated
…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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Comment thread packages/node/src/node/client/ClientNodeInteraction.ts Outdated
Comment thread packages/node/src/endpoint/Endpoint.ts Outdated
Comment thread packages/node/src/endpoint/Endpoint.ts Outdated
…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>
@Apollon77 Apollon77 requested a review from Copilot May 3, 2026 14:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 2 comments.

Comment thread packages/node/src/endpoint/properties/Behaviors.ts
Comment thread packages/node/src/node/client/ClientNodeInteraction.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 6 comments.

Comment thread packages/create/package.json Outdated
Comment thread packages/cli-tool/package.json Outdated
Comment thread packages/node/src/endpoint/Endpoint.ts Outdated
Comment thread packages/node/src/endpoint/Endpoint.ts
Comment thread packages/node/src/endpoint/Endpoint.ts Outdated
Comment thread packages/testing/package.json Outdated
Apollon77 and others added 2 commits May 3, 2026 16:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 1 comment.

Comment thread packages/node/src/endpoint/Endpoint.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Apollon77 Apollon77 merged commit 893d6ba into main May 3, 2026
37 checks passed
@Apollon77 Apollon77 deleted the feat/endpoint-get-nodetype branch May 3, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants