Skip to content

feat(api): expose squash on typed records.create (#972)#985

Open
LiranCohen wants to merge 4 commits into
mainfrom
feat/972-typed-squash
Open

feat(api): expose squash on typed records.create (#972)#985
LiranCohen wants to merge 4 commits into
mainfrom
feat/972-typed-squash

Conversation

@LiranCohen

Copy link
Copy Markdown
Contributor

Summary

Exposes squash on the typed records.create. Today the typed wrapper silently drops it: TypedCreateRequest doesn't declare squash, and typed create forwards an explicit enumerated field list that omits it — so proto.records.create(path, { …, squash: true }) no-ops the flag. The low-level records.write already accepts it (it rides the Partial<DwnMessageParams[RecordsWrite]>), so this is a pure forwarding fix.

Closes #972.

Changes

  • packages/api/src/typed-enbox.ts — add squash?: true to TypedCreateRequest; forward squash: request.squash in the typed create write call (mirrors how recipient/tags/protocolRole are forwarded).
  • packages/api/tests/typed-protocol.spec.ts — a self-contained $squash protocol fixture; asserts the directive reaches the write message descriptor when set and is absent when not.

Why

Consumers (notesd's CRDT collaboration) write $squash-compacting snapshot records to bound delta-history growth. They currently use a low-level raw-API workaround behind a seam (src/store/delta-repo.ts writeDelta); this lets them use the typed path instead.

Testing

  • bun run build (full workspace tsc) is green — the change type-checks.
  • The new spec exercises the forward path. Note: the typed-protocol spec's harness beforeAll publishes a did:dht to a Pkarr gateway, which is rejected against localhost in a bare local env — so the spec runs in CI, not bare-local. (This affects the whole spec equally, not this change.)

Post-deploy monitoring

No additional operational monitoring required — additive optional field on a client API wrapper; no server/agent/protocol change.

🤖 Generated with Claude Code

Add squash?: true to TypedCreateRequest and forward it to the low-level
records.write (which already accepts it via the Partial<RecordsWrite> params).
Lets consumers write a $squash-compacting snapshot through the typed API
instead of the low-level escape hatch. + typed-protocol spec covering the
forward (on a self-contained $squash protocol) and the omitted-when-unset case.

Verified: workspace build (tsc) green. Runtime spec runs in CI (local run blocked
by the did:dht/Pkarr-localhost harness requirement).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Node (bun test)

Package Line Coverage Status
agent 75.4% ⚠️ Below 96% target
api 73.3% ⚠️ Below 96% target
browser 100.0%
dids 98.9%
dwn-clients 25.1% ⚠️ Below 96% target

⚠️ Some packages are below the 96% coverage target. The report is informational and does not fail CI.

Coverage Report

Node coverage not available for this run.

Browser Coverage (informational)
Package Chromium Firefox WebKit
agent 81.9% 81.9% 81.9%
api 100.0% 100.0% 100.0%
browser 53.8% 53.8% 53.8%
common 94.0% 94.0% 94.0%
crypto 99.4% 99.4% 99.4%
dids 97.4% 97.4% 97.4%
dwn-sdk-js 94.3% 94.3% 94.3%

Browser coverage is informational only (subset of tests).

LiranCohen and others added 3 commits June 9, 2026 03:41
- typed-squash.spec.ts (NEW, offline unit): forwarding contract verified via a
  fake DwnApi — squash:true forwarded; undefined (not false) when unset; forwarded
  alongside every other create field; per-call scoping. Runs without the agent/DWN
  harness (verified locally green).
- typed-protocol.spec.ts (CI, real stack): + end-to-end compaction (a squash write
  purges older siblings), + backstop rejection on a non-$squash path (error
  surfaced, not swallowed), + data round-trip through a squashing write.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
no-multi-spaces + mocha/consistent-spacing-between-blocks (repo runs eslint with --max-warnings 0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…sh paths

squash:true on a path that doesn't declare $squash:true is REJECTED with
ProtocolAuthorizationSquashNotEnabled (protocol-authorization-validation.ts),
not silently ignored. Fixes a misleading 'No-op on paths without $squash'.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

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): expose squash on TypedCreateRequest (typed records.create)

1 participant