feat(api): expose squash on typed records.create (#972)#985
Open
LiranCohen wants to merge 4 commits into
Open
Conversation
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>
Contributor
Coverage ReportNode (bun test)
Coverage ReportNode coverage not available for this run. |
- 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>
|
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
Exposes
squashon the typedrecords.create. Today the typed wrapper silently drops it:TypedCreateRequestdoesn't declaresquash, and typedcreateforwards an explicit enumerated field list that omits it — soproto.records.create(path, { …, squash: true })no-ops the flag. The low-levelrecords.writealready accepts it (it rides thePartial<DwnMessageParams[RecordsWrite]>), so this is a pure forwarding fix.Closes #972.
Changes
packages/api/src/typed-enbox.ts— addsquash?: truetoTypedCreateRequest; forwardsquash: request.squashin the typedcreatewrite call (mirrors howrecipient/tags/protocolRoleare forwarded).packages/api/tests/typed-protocol.spec.ts— a self-contained$squashprotocol 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.tswriteDelta); this lets them use the typed path instead.Testing
bun run build(full workspacetsc) is green — the change type-checks.typed-protocolspec's harnessbeforeAllpublishes adid:dhtto a Pkarr gateway, which is rejected againstlocalhostin 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