Repository navigation
Conversation
…codes in the integration guide A binding author could not learn four things from the guide that every binding meets: which types the engine accepts, that vitaminc decides whether a null is padded and the type for it comes from the plan, that an opaque value is a storage blob in a format separate from the frame, and how a binding names its own error codes beside the engine's. Each was worked out once for Go and again for TypeScript.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
cipherstash-agent
left a comment
There was a problem hiding this comment.
Review attestation
Reviewed 36bb7df · posted from Claude Code (scheduled routine) · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; mattpocock-skills:code-review standards and spec agents · model unknown; claim-verification agent · model unknown; review-cross-check verification agents · model unknown
Skills: code-review, mattpocock-skills:code-review, company-skills:rust-security, company-skills:review-cross-check, company-skills:review-post, company-skills:run-report
Findings (11): 3 major, 8 minor. All 11 are inline.
The most important one is the first: the new value-model text is written against a ValueFrame that next has already deleted. It merges with no conflicts, but then rustdoc fails and the guide states the old UUID and timestamp rules. Rebase before addressing the rest, because several minor findings (L394-416) will change with that rewrite.
company-skills:rust-security found nothing to add: the change is prose only, and its guidance on errors and nulls does not leak values. One finding was refuted in verification: L702-704 does not duplicate L653-658. One question is left for the author and not raised inline: the Go SDK's own conversion refusals are a sentinel plus text, with no code (for example gensupport/field.go:86). The new rule at L702-704 asks for a code, so should the guide say Go does not meet it yet?
No changeset is needed: stack-encrypt is released by release-plz, and its CHANGELOG already records the guide.
Generated by Claude Code
| A UUID is refused, although vitaminc has a UUID type. So is a logical type | ||
| the engine does not know, and a date, decimal or timestamp outside | ||
| vitaminc's range. [`crate::dynamic::ValueFrame#the-value-model`] holds the | ||
| rule, and [`crate::dynamic::ValueFrame::from_bytes`] refuses a frame that | ||
| breaks it. |
There was a problem hiding this comment.
major This text is stale against the base branch next (612 commits ahead of the merge base ee72307). There ValueFrame is deleted (bfd3136, #1955), UUIDs are accepted as ValueKind::Uuid (#1918), a logical type the engine does not know is carried, and a timestamp keeps the unit the host wrote it in (#1846). The PR merges with no conflicts, but in the merged tree RUSTDOCFLAGS="-D warnings" cargo doc -p stack-encrypt --all-features fails with three unresolved link to crate::dynamic::ValueFrame errors (here and at L412), and line 388 contradicts the guide's own text on next. Rebase onto next and rewrite the value model and nulls sections against dynamic::frame (Frame/OwnedFrame), ValueKind::Uuid and the #1846 unit rule. The docs.rs link at L429 also needs to become recipher-frame.
Source: mattpocock-skills:code-review standards agent · model unknown; orchestrator · claude-opus-5-5
Generated by Claude Code
| and the crate's `STORAGE.md`. The blob is sealed as an ordinary bytes | ||
| value. A ciphertext of an `OpaqueBlob` decrypts as the bytes of its blob, | ||
| and those bytes encrypted as bytes decrypt as the `OpaqueBlob`. So every | ||
| language that writes the same blob writes the same ciphertext. |
There was a problem hiding this comment.
major Sealing is randomised: each leaf gets a fresh data key and nonce (src/cipher.rs:2111-2115), so the same blob seals to a different ciphertext every time. A binding author who writes a cross-language test comparing ciphertexts will find it never passes. Say instead that a ciphertext written by any language opens in any other, and compare blob bytes, not ciphertexts, for determinism.
Source: code-review · claude-opus-5-5; claim-verification agent · model unknown
Generated by Claude Code
| - **Pass the engine's codes on unchanged.** An engine error keeps its own | ||
| code (`stack_encrypt::aead`), help, fields and causes. Do not map engine | ||
| errors onto codes of your own, or group them into coarser kinds: a | ||
| grouping would have to be kept in step with every engine error. |
There was a problem hiding this comment.
major This contradicts the guest status table earlier in this section: status_for_error (languages/golang/encrypt/guest/src/status.rs:122-150) groups engine errors into coarse numbers such as STATUS_ENCODING, and Go adds sentinels such as encrypt.ErrEncoding on top of Diagnostic.Code. A reader will either drop the status fast path or decide the Go SDK breaks the guide. Scope the rule to the engine's error code: never replace or rename it, but a coarser kind may be added as long as the full code still reaches the caller. Also call the table's numbers "status" rather than "code".
Source: code-review · claude-opus-5-5; mattpocock-skills:code-review spec agent · model unknown; claim-verification agent · model unknown
Generated by Claude Code
| Map your language's types onto this list, and refuse anything else before | ||
| it reaches the engine, with an error that names the field and the type. A | ||
| plan's field types ([`crate::dynamic::ValueKind`], section 4) are the same | ||
| list. |
There was a problem hiding this comment.
minor ValueKind is not the same list. It has no kind for null, undefined or passthrough (dynamic/kind.rs:355-357; FromStr refuses "null"), and it adds json. A binding that builds its plan vocabulary from this list will emit refused kinds and never offer json. Say the kinds are the value model's types except null, undefined and passthrough, plus json, and point to the list in section 4.
Source: code-review · claude-opus-5-5; mattpocock-skills:code-review spec agent · model unknown; mattpocock-skills:code-review standards agent · model unknown; claim-verification agent · model unknown
Generated by Claude Code
| - **A null of a fixed-width type** (a boolean, a number, a date, a | ||
| timestamp or a decimal) is a *typed null*. It is padded to the length of | ||
| a value of that type, so once sealed it cannot be told from a value by | ||
| its length. |
There was a problem hiding this comment.
minor A boolean has no typed null. vitaminc-aead's tags.rs:98-100 says a bool's leaf is already as short as a plain null, and ValueKind::Bool maps to None in sealed_null (kind.rs:476-477). Drop the boolean from this list and add: "A boolean's null is the plain null, already as long as a boolean." NullMode::Sealed's rustdoc (record.rs:232-239) has the same wording.
Source: mattpocock-skills:code-review spec agent · model unknown; claim-verification agent · model unknown
Generated by Claude Code
| plan. A field declared with a fixed-width type and `"null": "sealed"` | ||
| seals its nulls padded. A field with `"null": "sql"` stores nothing, and |
There was a problem hiding this comment.
minor "null": "sealed" also requires the field's only index to be equality. An int32 field with an ore index is refused with Reason::SealedNullIndex (record.rs:570-576). Section 4 already states this, so cross-reference it rather than restate part of it.
Source: code-review · claude-opus-5-5; mattpocock-skills:code-review spec agent · model unknown; mattpocock-skills:code-review standards agent · model unknown; claim-verification agent · model unknown
Generated by Claude Code
| - version 1 holds plain scalars only. A date, a timestamp, a decimal, a | ||
| UUID, `undefined` and a passthrough have no storage form and are | ||
| refused. |
There was a problem hiding this comment.
minor This lists frame tags as if they were language types, so it reads as contradicting L467-468, where a uuid::Uuid is stored as 16 bytes. Name the refused items as vitaminc's logical-type nodes: date, timestamp, decimal, typed null (missing here), the logical envelopes that carry vitaminc's UUID, undefined and passthrough. Then say a serde type such as uuid::Uuid is not one of them and is written as bytes or text.
Source: mattpocock-skills:code-review spec agent · model unknown; claim-verification agent · model unknown
Generated by Claude Code
| - Go refuses its logical-type values, such as `encrypt.Date` and | ||
| `encrypt.Decimal`, and a passthrough, with `vcffi.ErrUnwritable`. |
There was a problem hiding this comment.
minor For generated Go code these fields are refused at generate time: stashgen rejects an opaque struct field of encrypt.Date, encrypt.Decimal or a vcvalue type other than Object with "has no storage form" (stashgen/read.go:1481-1495). At run time, opaqueBytes returns encrypt.ErrEncoding wrapping vcffi.ErrUnwritable (gensupport/codec.go:388-394). Describe both.
Source: code-review · claude-opus-5-5; claim-verification agent · model unknown
Generated by Claude Code
| Whichever rule you choose, write it down, and make a refusal name the | ||
| field. |
There was a problem hiding this comment.
minor Go's run-time storage refusals do not name the field. For example, an invalid UTF-8 string in an opaque struct fails with a string is not valid UTF-8, and neither vcffi's goStruct nor gensupport/codec.go:394 adds a path. Rust's storage::Error and Go's generate-time refusals do name it. Either add the path in Go or say here that Go's run-time refusals do not name the field yet.
Source: code-review · claude-opus-5-5 (scope corrected by verification)
Generated by Claude Code
| - **Name your own codes after your binding's crate.** An error that only | ||
| your SDK raises, such as a value your language cannot convert, gets a | ||
| code under its crate's name, never under the engine's: a crate | ||
| `example_binding` raises `example_binding::not_a_string`. Then no code | ||
| of yours can clash with one the engine adds later. |
There was a problem hiding this comment.
minor This treats binding and language SDK as one thing, though §1 of this guide and ADR-0008 keep them apart. An SDK layer written in Python, Elixir or Go has no crate to name its codes after. Suggest: "Name your own codes under a namespace you own: the binding crate for the binding's errors, and your SDK's package or module for the SDK's own."
Source: mattpocock-skills:code-review standards agent · model unknown
Generated by Claude Code
…tack Encrypt The guide and AGENTS.md now name the crate Stack Encrypt, not "the engine", and the Rust layer of an SDK a language binding. Section 1 of the guide gains the rules for a thin binding: send Stack Encrypt's plan as it is, let Stack Encrypt check each row, keep its names, and fix a gap in Stack Encrypt. The checklist gains the same item, and AGENTS.md points to the section. Merging next showed that the value model and null sections were stale: ValueFrame is gone, a UUID is in the value model, an unknown logical type is stored as it arrived in an untyped field, and a host's frame can carry a typed null. Those passages now say so.
The records pull request includes one field with { record, field }, and
starts after Stack Encrypt has a conversion of the encrypted tree and a
call for one field of a plan.
Summary
The language integration guide did not cover four things that every new binding runs into. The Go SDK settled each of them, and the TypeScript SDK had to work them out again. This adds them. It also adds the rules that keep a language binding thin.
The guide is
packages/stack-encrypt/docs/language-integration.md. It is also the rustdoc ofstack_encrypt::dynamic.Changes
Section 1 gets the rules for a thin language binding, and the guide's names change:
dynamic::record::plan. It lets Stack Encrypt check each row and convert each value to its field's kind. It keeps Stack Encrypt's names, such as the outputscandeq. A gap is fixed in Stack Encrypt, not worked around in the binding.AGENTS.mdmakes the same change, and its "Designing a language SDK" section points to the new rules.Section 5, "Control messages and plaintext", gets three parts:
Section 8, "Errors", gets a "Codes" part:
Result, or Go'serrorare the language's choice. The codes are the same in every shape.Section 11's checklist gets two items. One is for the type mapping, nulls, and opaque values. The other is for a thin binding.
The TypeScript SDK plan (
docs/plans/2026-11-22-recipher-typescript-sdk.md) changes step 3 of its build order. The records step includes one field with{ record, field }, and waits for #2029 and #2028.Verification
RUSTDOCFLAGS="-D warnings" cargo doc -p stack-encrypt --no-deps --all-features: clean. Every intra-doc link resolves.cargo test -p stack-encrypt --all-features --doc dynamic: 21 passed, afternextwas merged in.Logical::admitsandleaf.rsin vitaminc-aead, and the testsuuids_and_unknown_logical_typesindynamic/record.rs;leaf.rs, its testa_fixed_width_none_is_a_typed_null_as_long_as_a_some, andNullMode;FrameWriter'styped_nulland ofOwnedFramein vitaminc-aead;STORAGE.mdin vitaminc-aead-frame 0.10.0;OpaqueBlobdecrypting as its blob's bytes: a probe program against the engine;vcffi/storage.goat the versionlanguages/golang/go.modpins.Related
@cipherstash/reciphercannot encrypt a whole object withopaque(..)— write and read the storage blob from a JavaScript value #1822: opaque values in the TypeScript SDK. stack-encrypt:dynamichas no scalar type, so each language SDK writes its own wrapper to callkeyset.encrypt— add a checkedScalarFrame#1825: one value throughkeyset.encrypt. That PR (feat(stack-encrypt): add dynamic::ScalarFrame to seal one runtime-typed value with keyset.encrypt #1827) adds an "Encrypt one value" section to this guide on its own.Review notes
ValueFrame.nexthas since removed it. The merge ofnextbroke three links to it, and showed that the value model and null passages were out of date. Both are rewritten against the code onnext.time.Timein an opaque struct as RFC 3339 text. So it opens as text, not as a timestamp.@cipherstash/reciphercannot encrypt a whole object withopaque(..)— write and read the storage blob from a JavaScript value #1822 said this had not been checked. It is now, and the guide states it.