Repository navigation
Conversation
ADR-0004's scopes and bindings sort a part of a context by whether a query can supply it. That does not say who can read a value. A binding stored in the row restricts no reader, and a tenant ID is not a secret, yet both words read as access control. A part also has no name, so two parts with one value are one context, and a part cannot be added to a value after it is encrypted. ADR-0016 names the parts. A part is a policy, a label or a partition, and only a policy restricts readers. `Policy` is sealed to the key provider's own types, so an application cannot call something a policy that the key provider does not check. `Label` and `Partition` stay open. The field path, the partitions and the labels go into key derivation in a fixed order, each part as its wire name and its value. A refinement adds a label or a policy afterwards by changing the key tag. The record also says how Go declares parts, and what every SDK takes from it. Three records are amended to match. ADR-0004 loses scopes, bindings and the outer names in a nested record's context. ADR-0006 loses the open `Describe` trait, and its `Label` struct becomes `FieldPath`, which is the type #1663 asks for. ADR-0010 says a part added by a refinement is authenticated by the key tag and not by the leaf. No code changes. The plan documents, #1566, #1567, #1683 and #1572 follow separately.
|
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true |
coderdan
added a commit
that referenced
this pull request
Nov 23, 2026
ADR-0016 (PR #1772) decides that a context is a field path and named parts: policies, labels and partitions, with one wire name each. The plan takes its words, its wire names and its rules, and gives the TypeScript form: the built-in parts as functions, parts listed on a record or read from a field, keyset.with(..) to carry them, and .partition(..) on a query. A bare value in .withContext is a note. Phase 2 now waits for the engine to have named parts, not for a design. Phase 1 writes only values with no parts, which are the two forms the ADR says keep their stored bytes, so .withContext moves to phase 2. Refinements are in phase 3, with #1567.
This branch has not been deployed
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
Stack Encrypt is CipherStash's Rust encryption engine. Every value it encrypts is tied to a context: the place the value was written for, such as a table, a column and a tenant. A value decrypts only under the context it was encrypted under.
Today the parts of a context are called scopes and bindings. Those words read as isolation and access control, and neither is: a row ID stored in the row restricts no reader, and a tenant ID is not a secret. This pull request adds a decision record (an ADR) that names the parts by what they protect, and amends three earlier records to match. It changes no code.
After it, a part of a context is one of three kinds:
Changes
New:
packages/stack-encrypt/docs/adr/0016-a-context-is-a-field-path-and-named-parts.mdPolicyis a sealed trait: only the key provider's own types implement it, so an application cannot call something a policy that nothing checks.LabelandPartitionare open.NotBefore,NotAfter,ForSub,ForTenant,TenantId<T>,RecordId<T>andNote<T>.ScopeandBindare removed, and a query narrows with.partition(..).label=,partition=andpolicy=, and oneCipher.With(..)method.Amended: ADR-0004 (one context per target)
Amended: ADR-0006 (descriptors, and
Describeis open)Describeis removed. Nothing takes it as a bound.Labelstruct is renamedFieldPath, so the nameLabelis free for the trait.Amended: ADR-0010 (what a stored value authenticates)
Verification
grep -rn 'docs/adr' scripts/ .github/workflowsfinds nothing.git log --format='%h %G? %an' origin/next..HEADprintsG.Related
Labelis still public, and the Go guest takes a context as path text — removeLabelandIntoLabel#1663. The record namesFieldPathas the type that replaces theLabelstruct.Review notes
Start with the Summary and decisions 1, 2 and 5 of ADR-0016. The rest follows from them.
These points were not each decided one by one, so check them:
not_after,for_sub,tenant_id,record_idandnotewere agreed.not_beforeandfor_tenantare mine.context_fromis left unchanged. It reads a field path from the plaintext, and a field path is a label and a partition. Go'scontext_fieldtag is removed, as agreed.Deferred, with the reason:
CONTEXT.mdglossary still defines "scope" and "binding". It describes the code as it is, so it changes with the code.