Repository navigation
refactor(go)!: move vitaminc's vcffi and vcvalue into the module as encrypt/frame and encrypt/value - #2003
Conversation
|
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
|
Mutation testing (cargo-mutants,
|
coderdan
left a comment
There was a problem hiding this comment.
Code review (/code-review medium) of 5b860a6. Four findings, all checked against the code: one important, below because its file is outside the diff, and three nits inline.
Important: .github/workflows/tests-golang.yml (outside the diff). A change to the value corpus does not run the Go tests that now read it. internal/frame/conformance_test.go and fuzz_test.go read conformance/vitaminc-aead/value-conformance.json, but neither the pull_request nor the push path filter lists conformance/vitaminc-aead/**. The filter lists packages/recipher-frame/** for the storage corpus, and conformance/stack-encrypt/**. Failure scenario: a pull request adds a value vector that the Go codec decodes differently. Only tests-crates.yml runs, it passes on the Rust side, and the Go drift reaches main with no red check.
I will fix all four in this pull request and reply here and on each thread.
|
|
Review follow-up on the path filter, the finding outside the diff: fixed in 1ad6005. |
cipherstash-agent
left a comment
There was a problem hiding this comment.
Review attestation
Reviewed b3981ee5 · posted from Claude Code (scheduled routine) · claude-opus-5-5 · effort medium
Sources: code-review (medium) · claude-opus-5-5; mattpocock-skills:code-review standards and spec axes · model not confirmed. Every finding was verified at b3981ee5 and cross-checked against the existing threads.
Skills: code-review, company-skills:rust-security, mattpocock-skills:code-review, company-skills:review-cross-check, company-skills:review-post
Findings (8): 8 minor — 6 inline, 1 below, 1 in reply.
generalminor The PR body says "Closes #1253", but #1253 item 5 (port the differential fuzzers tolanguages/golang/encrypt/guest) is not done, and the plan's "Still to do" says so; no other issue tracks it. The base isnext, so GitHub will not auto-close it, but closing it by hand on this PR's word leaves item 5 untracked. Use "Refs #1253" or move item 5 to its own issue.
Source: mattpocock-skills:code-review spec axis · model not confirmed
company-skills:rust-security: the Rust changes are comments only; nothing in scope.
Checked and not posted (refuted at head): JSONOpen/NewJSONRead taking frame.Object (unreachable outside the module, since both also need an internal *record.Plan), the corpus skip inside the repository, the FixedWidth test name, the widen.go switches.
Open questions for the author, not defects:
- A nil pointer to an
Encryptableis now a 1-byte plain null where its value is 9 bytes, and the engine pads nothing on anUntypedfield. Generated code cannot reach this, but a program that callsgensupport.Declare(...).Encrypt("v", gensupport.Untyped)itself can. Refuse a nilEncryptablewhere no type is declared? - The CHANGELOG says
ParseInt128,ParseUint128,ParseDecimalandErrNonFiniteDecimalare "unchanged", but their error text now startsframe:, naming an internal package.errors.Isstill matches. encrypt/query.go:122tells callers to pass aframe.Object, a type outside the module cannot name.- The reflect-keyed registry in
internal/frame/public.goversus Go principle #4 ("do not use reflection"), and the removal ofDate.DaysFromCE/Decimal.Normalized: both already in the PR's own open questions.
Generated by Claude Code
|
On the review's open questions:
One thing beyond the doc: several exported |
Phase 2 depends on step 1.6, because the resolver's query form goes there. Step 1.4 checks the single seal first and can keep today's merge of pendings. Step 1.3 says how the new term method relates to the typed term methods. Step 1.1 defines Go's match options as well as sending them. Two citations and two size figures are corrected, and names that arrive with #2003 say so.
70c6a58 to
f97f467
Compare
|
Rebased onto What changed beyond the commit hashes:
Each commit builds and passes |
…module The Go SDK encodes every value that it sends to the guest with vitaminc's Go packages vcffi and vcvalue. go.mod pins them at an untagged commit, so the Go half of the frame codec moves separately from the Rust half (recipher-frame, already in this repository). A final release of the module is refused while that pin stands. This commit copies both packages in unchanged, so the move can be compared with the source file by file: vcffi -> languages/golang/encrypt/frame vcvalue -> languages/golang/encrypt/value Both stay public, as they were in vitaminc, and stay two packages: value holds the value types and imports nothing outside the standard library; frame is the codec and the storage profile. Source: github.com/cipherstash/vitaminc bindings/go/vcffi and bindings/go/vcvalue at commit f1fc9ae74882 (pseudo-version v0.0.0-20261119095843-f1fc9ae74882), the version that go.mod pins, taken from the Go module cache. Each package's go.mod is left out, so the two directories are packages of this module. Each package's MIT LICENSE file comes with it. Nothing imports the copies yet. Their package clauses, their import of vcvalue and the corpus paths of their tests are still vitaminc's; the next commit makes them the module's own.
The copies are still vitaminc's packages under new paths. This commit makes them packages of this module, and changes what the review of the move asked for. Nothing else in the module imports them yet. - Package clauses become frame and value, and frame imports encrypt/value in place of vitaminc's vcvalue. Error text starts with "frame: " or "value: ". - The tests read the value corpus (conformance/vitaminc-aead) and the storage corpus (packages/recipher-frame/testdata) from this repository, and skip, rather than fail, outside it. - What only vitaminc's own binding (vcencrypt) used is removed: the sealed leaves (Sealed, SealedEmptySeq, SealedEmptyMap), TypedNull, FixedType and ErrInvalidFixedType, Plain.Value, Encoder.TypedNull, FixedWidth and VCValueLeaves. The typed null for a nil pointer is built from the tag table, so the codec keeps no list of types. - The Encoder's unsigned methods are Uint8 to Uint128, as Go spells them, not UInt8 to UInt128. - The zero Encoder no longer panics. It keeps nothing, and Err reports that, so a unit test of a type can pass it to EncryptValue. Usable tells the two apart. - Encryptable is declared once, in frame, and the codec uses it directly. - A storage refusal names the program's own type. golangci-lint already allows gosec's G115 (integer width conversions) in the codec, which converts on purpose after checking each limit; the rule now names encrypt/frame and encrypt/value.
The module now encodes with its own copies of the frame codec and the value types, and imports nothing from vitaminc. Each value type is declared once, in encrypt/value. encrypt.Date, Decimal, Int128 and Uint128 stay aliases, as they were of vcvalue's types, so code that names only encrypt types needs no change. New aliases name the rest of what a program writes: encrypt.UUID (with ParseUUID), and encrypt.Encryptable and encrypt.Encoder, which are frame's. One type under two names means the codec encodes and decodes it with no conversion and no registry. Behaviour that changes with the move: - Without FixedWidth, a nil pointer to an Encryptable is written as a null, which the engine pads to the width of the field's declared type. A field that declares no type has no width to pad to, so the stored null's length would show that it is a null: Cipher.Seal refuses a nil Encryptable there, with ErrEncoding. Generated code always declares a type. - stashgen recognises the value types by their names in encrypt or in encrypt/value, so a field may be declared with either. BREAKING CHANGE: code that imports vitaminc's vcvalue or vcffi imports encrypt/value or encrypt/frame instead, or uses the encrypt aliases. The Encoder's unsigned methods are Uint8 to Uint128; what only vitaminc's own binding used (Sealed, TypedNull, FixedType, FixedWidth, VCValueLeaves and the rest) is gone.
…guarded them Nothing in the module imports vitaminc's vcffi or vcvalue any more, so go.mod no longer requires them, and neither do the nested modules (encrypt/encrypttest, encrypt/example, examples/s3), which carried them as indirect requirements through the SDK they replace with a path. go mod tidy in each removes them and their go.sum lines, and changes nothing else. The TEMPORARY comment that explained the pin goes with it. scripts/go-release-version.mjs refused a final version while go.mod pinned a vitaminc module at a pseudo-version, because vitaminc's Go bindings had no tags. The module now has no dependency that could carry such a pin: the codec is in this repository. The rule and its tests go, and release-golang.yml no longer mentions it. A test now checks that the script reads the module path from the tree's go.mod and accepts a final version from main. Refs #1253
… value corpus changes The frame codec came with three fuzz targets in encrypt/frame: FuzzUnmarshal, FuzzUnmarshalCipherText and FuzzUnmarshalStorage. The nightly go-fuzz-campaign job in fuzz.yml now fuzzes them, one matrix row each. They decode bytes in pure Go and run no guest, so their rows build no guest. `mise run go:fuzz` says that it fuzzes the codec as well as the guests' ABI. encrypt/frame's tests read conformance/vitaminc-aead, so tests-golang.yml now starts when that corpus changes. The storage corpus, under packages/recipher-frame, already starts it. scripts/go-binding-test.sh names the codec's new path in a comment.
… record the breaking change vitaminc's vcffi and vcvalue are now encrypt/frame and encrypt/value, so the documents that named vitaminc's Go packages, or the module's own copy under internal/, name these instead: - AGENTS.md lists the two packages with the module's others, and says that encrypt's value types, Encryptable and Encoder are aliases of theirs. - languages/golang/CHANGELOG.md records the move under Breaking, with what changes for code that imported vcvalue or vcffi, and the new aliases and packages under Added. - docs/fuzzing.md lists the codec's three fuzz targets, and the plan for moving vitaminc's code here records stage 3 as done, two packages and all. - The SDK's README, stashgen's README, the conformance READMEs, recipher-frame's STORAGE.md, and comments in the Rust crates whose formats the Go codec matches, point at encrypt/frame. These documents are also rewritten in plain language where the review asked, including comments in Cargo.toml files about the guests' shared ABI. No code changes.
f97f467 to
5aa6552
Compare
|
Change of direction: the packages are moved, not merged. The earlier version of this PR merged
Each type is declared once, so there is no registry and no second copy of a type. The history is now six signed commits from |
The plan's file:line citations now point at next at b939de4, the merge of #2042. They were read at 54e6471. #2042 moved the dynamic record code. The match options' object form and EQL_KEY are now in dynamic/record/plan.rs, and bytes_node and the record decrypt doc are further up dynamic/record.rs. #2003 shifted lines in the Go SDK's query.go and records.go, and the EQL guest builds in tests-golang.yml. Every citation was updated. None could not be.
Summary
The Go SDK no longer imports vitaminc's Go packages
vcffiandvcvalue. They have moved into the module, unchanged in shape:vcffilanguages/golang/encrypt/framevcvaluelanguages/golang/encrypt/valueDate,Decimal,Int128,Uint128,UUID,Objectand the restBoth packages stay public, and each type is declared once.
encrypt.Date,Decimal,Int128andUint128stay aliases, now ofvalue's types, so code that names onlyencrypttypes needs no change. Thego.modpin on an untagged vitaminc commit is gone, and so is the release-script rule that refused a final version while that pin existed. This is the last stage of moving the AEAD code into this repository, and it unblocks a final Go release.Closes #1253. Its item 5, the differential fuzzers, is now #2004. Refs #1831 (stage 3 of the move).
Changes
One commit each:
vcffiandvcvaluecopied byte for byte from the Go module cache, at the version the SDK pinned: vitaminc f1fc9ae74,v0.0.0-20261119095843-f1fc9ae74882. Each keeps its MIT licence. Compare the commit with the source file by file.frameandvalue;frameimportsencrypt/value. Error text starts "frame: " or "value: ".vcencrypt) used them:Sealed,SealedEmptySeq,SealedEmptyMap,TypedNull,FixedType,ErrInvalidFixedType,Plain.Value,Encoder.TypedNull,FixedWidthandVCValueLeaves. The typed null of a nil pointer is built from the tag table, so its bytes are unchanged, and the known-answer tests still pin them.Uint8toUint128, as Go spells them. The zero Encoder no longer panics: it keeps nothing, andErrsays so, so a unit test can pass it toEncryptValue.Encryptableis declared once. A storage refusal names the program's type.encryptgains aliases:UUIDandParseUUID(ofvalue's), andEncryptableandEncoder(offrame's).Encryptableis written as a null, which the engine pads to the width of the field's declared type. On a field with no declared type,Cipher.Sealrefuses it withErrEncoding, so the stored length cannot show a null. Generated code always declares a type.stashgenrecognises the value types by their names inencryptor inencrypt/value.encrypt/encrypttest,encrypt/exampleandexamples/s3drop the vitaminc requirements;go mod tidychanges nothing else.scripts/go-release-version.mjsdrops the rule that refused a final version whilego.modpinned a vitaminc pseudo-version, with its tests. A new test checks that a final version frommainis accepted.go-fuzz-campaigninfuzz.ymlfuzzes the codec's three decoders (FuzzUnmarshal,FuzzUnmarshalCipherText,FuzzUnmarshalStorage), building no guest for them.tests-golang.ymlstarts when the value corpus changes.CHANGELOG.mdhas a Breaking entry saying what changes for code that importedvcvalueorvcffi. Also updated:AGENTS.md,docs/fuzzing.md, the plan's stage 3 "Done" list, the READMEs,STORAGE.md, the conformance docs, and the Rust comments that named the Go codec.What changes for a program
encrypttypes: nothing.vcvalueorvcffi: importencrypt/valueorencrypt/frameinstead, or use theencryptaliases. RenameUInt8…UInt128calls toUint8…Uint128. The removed names above are gone.Verification
On the final tree, rebased on
nextat 54e6471, with all five guests rebuilt:go build,go vet,GOOS=linux GOARCH=386 go vetandgofmt -l(empty) pass in all four modules.STACK_CONFORMANCE_REQUIRED=1 go test ./...passes in all four modules.go generate ./...leaves no drift.mise run go:lintreports 0 issues in each module.go mod tidy -diffis clean in each module.Not run: the Windows and macOS jobs, live tests, the guest import-surface checks, and fuzzing. No Rust code changes; only Rust and Cargo comments.
Review notes
Decided:
Encryptableon a field with no declared type is refused, rather than written as a null whose length would show it is a null.Moved to #2040:
encrypt.Cipher'sQueryTerm,Verify,TargetLimit,Contexts,Seal,OpenandJSONOpentake a*record.Plan, which a program cannot import. This predates the PR, and this PR does not change it. docs(plans): one walk for a record, and host-built stored types #2040's step 2.3 removesQueryTerm; what happens to the other six is asked on docs(plans): one walk for a record, and host-built stored types #2040. (JSONOpen's other argument is now avalue.Object, which a program can import.)Also:
stashgennamesvcvalue.UUIDandvcvalue.Int128through avcvaluePathconstant. Whichever merges second points that atencrypt/value(valuePathhere).docs/sdk-design-principles.mdsays the SDK does not; that has been true of the codec since it was vitaminc's, and this PR does not change it.vcencryptandbindings/gofrom the vitaminc repository.