Skip to content

feat(api): materialize protocol record structure#1464

Merged
LiranCohen merged 5 commits into
mainfrom
feat/protocol-materialization
Jul 24, 2026
Merged

feat(api): materialize protocol record structure#1464
LiranCohen merged 5 commits into
mainfrom
feat/protocol-materialization

Conversation

@LiranCohen

@LiranCohen LiranCohen commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add explicitly bounded typed record materialization for query() and observe(), retaining each canonical Record beside its decoded value
  • expose the minimal { record, value } materialized shape; add children only when direct singleton children are explicitly selected
  • batch selected direct singleton children with one query per child path and wake observed views when those children change
  • add local records.set() for protocol paths that declare $recordLimit.max: 1, with an authoritative grant-backed selection for delegated sessions
  • support scalar or non-empty parentId selections through grouped $recordLimit projection, including an exact-parent LevelDB path that avoids protocol-wide scans
  • keep singleton/path-selection type machinery internal and use straightforward collect, sort, and limit logic for selected parent groups

Closes #1460.

Test plan

  • root lint and lint autofix
  • affected package builds (dwn-sdk-js, api, browser)
  • API type contracts and 113 focused API tests
  • Level store and grouped record-limit tests (105 focused tests)
  • full agent package suite (1,675 passed, 18 skipped)
  • delegated Records.Read grant-required selection test
  • grouped parent projection on Level, MySQL, PostgreSQL, and SQLite (previous PR-head CI)
  • docs MDX/type generation (previous PR-head CI)

Notes

  • materialization requires an explicit page limit and eagerly decodes that page; callers should retain raw Record handles and stream large payloads instead
  • records.set() intentionally targets only the connected tenant local replica; remote targets and protocol-role invocation are outside this first operation

Comment thread packages/api/type-tests/materialized-record.ts Fixed
Comment thread packages/api/type-tests/materialized-record.ts Fixed
Comment thread packages/api/type-tests/materialized-record.ts Fixed
@LiranCohen

Copy link
Copy Markdown
Contributor Author

CI triage for the failed agent shard on head 62e38d4a:

AgentDwnApi > processRequest() > handles RecordsSubscribe message accepted both writes but observed one of two asynchronous callbacks before the test immediately closed the subscription. PR #1464 only changes nested protocol-path subscription scope validation; this test uses a schema-only filter, so that branch is not reached.

The exact process/send RecordsSubscribe tests passed in five consecutive targeted local runs (10/10 cases). Treating this as a load-sensitive pre-existing test race and rerunning only the failed job; no production or test semantics changed to mask it.

@sonarqubecloud

Copy link
Copy Markdown

@LiranCohen
LiranCohen merged commit f8a7ff1 into main Jul 24, 2026
31 checks passed
@LiranCohen
LiranCohen deleted the feat/protocol-materialization branch July 24, 2026 15:41
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.

feat(api): materialize records and protocol-declared singleton children

1 participant