Skip to content

docs(stack-encrypt): a guide to building a language integration - #1287

Open
coderdan wants to merge 1 commit into
nextfrom
docs/language-integration-guide
Open

coderdan wants to merge 1 commit into
nextfrom
docs/language-integration-guide

Conversation

@coderdan

Copy link
Copy Markdown
Contributor

Summary

A guide to building a language integration on Stack Encrypt, for an author who is new to CipherStash: what a binding is and what it is not, what crosses it, what the engine expects of the host, and how to prove the result. The Go SDK is the reference, and every rule names where in it the rule is kept. It ships in the crate documentation as stack_encrypt::dynamic::guide, so it renders on docs.rs next to the API it describes.

Stack Encrypt is the Rust encryption engine. Every language other than Rust reaches it through the dynamic module. Until now the knowledge needed to do that was spread over module docs, the Go guest, stack-guest-abi and two ADRs, and a Python integration has started without it.

Changes

  • packages/stack-encrypt/docs/language-integration.md: the guide. Twelve sections, ordered contract before API: binding versus language SDK; native versus WebAssembly; the three operations with the exact dynamic calls and the Go guest's exports (step loop included); the plan grammar; control messages versus plaintext (both frames, no value tree); plaintext hygiene and the heap tests; keys, the token import and the cancellation contract; errors (the status table, se_last_error, no values in messages); versioning and the frozen stored-rows fixtures; one int32 as EQL v4 IntegerEq traced end to end with real bytes; a checklist; where the wire format lives (linked, not restated).
  • packages/stack-encrypt/src/dynamic/mod.rs: pub mod guide includes the file as docs.
  • packages/stack-encrypt/src/lib.rs, docs/sdk-design-principles.md, languages/golang/encrypt/README.md: one pointer each.
  • packages/stack-encrypt/CHANGELOG.md: Unreleased entry.

Verification

  • mise run doc:stack-encrypt (rustdoc, warnings as errors): clean. Every intra-doc link resolves.
  • cargo test -p stack-encrypt --doc --all-features: 46 passed, including the two doctests in the guide. The worked example's frame bytes (the int32 value, the row, the plan) are asserted, not quoted, so the guide fails the build if the engine's bytes move.
  • cargo nextest run -p stack-encrypt --all-features: 684 passed.
  • cargo fmt --check: clean.
  • Every repository path the guide names exists (checked by script); no issue numbers or internal ticket ids in the text.
  • The stored row and the query term in the worked example are quoted from packages/eql/tests/encryption/fixtures/v4_rows.json (row 1, age) and v4_queries.json (age), named in the text so a reader can check them.
  • Not run: nothing else changed. No npm package is affected, so no changeset.

Related

Closes #1254.

Review notes

  • Section 10 is the one to read first: it is where a claim would be wrong if any were. Everything in it is from a fixture or a doctest.
  • Section 5 says the general-purpose value tree is gone and control messages are typed; that is the state of next today.
  • The wire format is deliberately not restated; the guide links vitaminc-aead-frame's docs and the conformance-corpus issue in that repository.

Nothing explained how to build a binding on Stack Encrypt. The knowledge
was spread over the dynamic module's docs, the Go guest's module docs,
stack-guest-abi, ADR-0007 and ADR-0008, and an author had to reconstruct
it from the Go SDK. A Python integration has started without it.

The guide ships in the crate docs as `dynamic::guide`, included from
`docs/language-integration.md`, so it renders on docs.rs beside the API
it describes. It is ordered contract before API: the binding versus the
language SDK; native versus WebAssembly; the three operations and the
Go guest's exports; the plan grammar; control messages versus plaintext,
both frames, neither a tree; the plaintext hygiene rules and the heap
tests that prove them; the step loop, the token import and the
cancellation contract; the status table and se_last_error; versioning
and the frozen stored-rows fixtures; one int32 stored as EQL v4
IntegerEq, traced through encrypt, query and decrypt with the bytes from
the committed fixtures; and a checklist for a new binding. The frame
format stays in vitaminc-aead-frame's documentation and is linked, not
restated.

The frame bytes in the worked example are asserted by doctests, so the
guide fails the build if the engine's bytes move. The stored row and the
query term are quoted from fixtures the Go SDK and Rust both read, named
by file and key.

Linked from the crate docs, the SDK design principles and the Go SDK's
README.

Closes #1254.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 76ea5cb4-c858-4b1a-8e2c-2f6ac21335f3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@changeset-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0df55a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Mutation testing (cargo-mutants, --in-diff, stack-auth + stack-encrypt)

No mutants were generated for the changed lines.

@coderdan
coderdan marked this pull request as ready for review October 19, 2026 12:15
@coderdan
coderdan requested a review from a team as a code owner October 19, 2026 12:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T12:20:03.936765Z 0df55a0 Draft marked ready
🔒 Security Review ✅ Completed 2026-10-19T12:22:35.943830Z 0df55a0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0df55a0ca5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

| 2 | `ENCODING` | malformed input at the boundary; fix the caller |
| 3 | `STATE` | a call out of order: before init, after shutdown, an unknown handle |
| 4 | `INTERNAL` | a bug in the guest; report it |
| 5 | `KMS_UNAUTHORIZED` | refresh the token and retry; the only retryable one |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Limit “only retryable” to token refresh

Calling KMS_UNAUTHORIZED “the only retryable one” incorrectly rules out retrying transient failures reported as KMS_TRANSPORT, such as a timeout or connection failure. The status contract in packages/stack-guest-abi/src/status.rs only designates code 5 as the sole status to handle by refreshing the token; code 9 may still be retryable through the normal transport policy. A binding author following this table would unnecessarily surface recoverable network failures, so qualify this as “the only one retryable after a token refresh” rather than the only retryable status.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

1 participant