Skip to content

refactor(stack-encrypt)!: remove the seven PlanError variants nothing raises - #1749

Merged
coderdan merged 2 commits into
nextfrom
refactor/stack-encrypt-remove-unraised-plan-errors
Nov 22, 2026
Merged

coderdan merged 2 commits into
nextfrom
refactor/stack-encrypt-remove-unraised-plan-errors

Conversation

@coderdan

Copy link
Copy Markdown
Contributor

Summary

PlanError is the error Stack Encrypt refuses a declaration with. Seven of its variants can no longer be returned, because the plan builder that raised them has been removed. They're now removed too, with their error codes, so the error docs no longer list refusals that can't happen. This breaks only code that matches on these variant names, and no stored byte changes. ADR-0009 now says what replaced DefaultIndex and .via. The match-index docs no longer claim that a field and its query agree "by construction".

Changes

  • Removed variants: IdentityWithoutField, IndexNotDeclared, IndexOptions, MixedCiphers, NoContext, PassthroughIndexed and TargetWithVerbs. Each went with its stack_encrypt::plan_* code, its payload arm and its arm in the dynamic::Reason mapping. index_value is also removed; only IndexOptions used it.
  • Tests: the rows for these variants are dropped. The error-code and Go guest status tests used NoContext as their sample plan error; they now use BindInQuery.
  • ADR-0009: amended to say that a typed field answers through its target type's Answers, and a data plan through Op::answered_by.
  • Docs: the MatchConfig, KeysetCipher::match_terms and Match docs now say how a field and its query agree:
    • a query from the field's reference uses the field's own Match<O>;
    • a data plan reads the field's one match index;
    • a filter derived directly matches only under the field's configuration.
  • CHANGELOG: a "Breaking" entry with upgrade steps.

Verification

  • Before removing each variant, I searched packages/ and languages/: nothing outside tests constructs any of the seven.
  • cargo fmt --check, plus clippy and cargo doc with -D warnings: clean.
  • cargo test -p stack-encrypt --all-features: all test binaries pass.
  • EQL encryption tests: pass.
  • Go guest crate: clippy is clean with --features eql. Nextest passes 82 tests, and 85 with --features eql.
  • Go: guests were rebuilt. go generate ./... produces no drift, and go test ./... passes.
  • cargo-mutants on this commit's diff: 4 mutants, 1 caught, 3 unviable, 0 missed.
  • Not run: golangci-lint, because no Go source changed.

Related

Closes #1671. Part of #1488. Stacked on #1748.

Review notes

  • No codes were renumbered. Error codes are names, not numbers, so the remaining ones don't change.
  • No dynamic::Reason is removed; each remaining reason is still raised elsewhere.
  • No Go status-table entry to remove. The table maps every plan error to STATUS_ENCODING without listing variants, so only its test changed.
  • No corpus or test names a removed code. That covers the conformance corpus and the Go error tests.

@coderdan
coderdan requested a review from a team as a code owner November 22, 2026 13:55
@changeset-bot

changeset-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f8d29e9

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

@coderabbitai

coderabbitai Bot commented Nov 22, 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a2cd7620-c21a-4df1-93e1-294fe005d10a

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The obsolete PlanError cleanup has no active review issues.

No open issues 🎉

What changed in this PR

Removes seven unused PlanError variants left behind by the deleted Stack Encrypt plan builder, completing the cleanup in #1671. This breaks references to the removed variants but leaves stored bytes and remaining error codes unchanged.

Changes:

  • Removes obsolete variants, diagnostic codes, payload handling, and dynamic mappings.
  • Updates error-code and Go guest status tests to use a remaining variant.
  • Clarifies match-query configuration guarantees and documents replacements for DefaultIndex and .via, with upgrade guidance.
File Description
packages/​stack-encrypt/​src/​target/​index.rs Clarifies how field-reference queries use Match<O>.
packages/​stack-encrypt/​src/​sem/​mod.rs Documents configuration agreement and direct-filter limitations.
packages/​stack-encrypt/​src/​plan/​error.rs Removes seven unused variants and their payload handling.
packages/​stack-encrypt/​src/​dynamic/​record.rs Removes obsolete error mappings and test cases.
packages/​stack-encrypt/​src/​codes.rs Updates diagnostic-code and payload tests.
packages/​stack-encrypt/​docs/​adr/​0009-operators-select-the-index-and-a-query-term-is-not-the-stored-term.md Records typed and data-plan operator selection replacements.
packages/​stack-encrypt/​CHANGELOG.md Adds breaking-change guidance and documentation notes.
languages/​golang/​encrypt/​guest/​src/​status.rs Uses BindInQuery in the plan-error status test.
docs/​plans/​2026-10-24-stack-encrypt-api-plan.md Updates the cleanup tracking for #1671.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

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

caught missed unviable timeout
1 0 3 0

Every mutant in the changed lines was caught by a test.

@cipherstash-agent cipherstash-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review attestation

Reviewed a98951b7 · posted from Claude Code · claude-opus-5-5 · effort medium
Sources: code-review (medium) · claude-opus-5-5; rust-security · claude-opus-5-5; mattpocock-skills:code-review · claude-opus-5-5
Skills: code-review, rust-security, mattpocock-skills:code-review, review-cross-check, review-post

Findings (5): 5 minor — 3 inline, 2 below.

  • packages/stack-encrypt/docs/adr/0009-operators-select-the-index-and-a-query-term-is-not-the-stored-term.md:4 (outside diff) minor Front matter still says amended: 2026-11-10; this PR adds the 2026-11-23 amendment, and the 2026-11-22 (#1737) one never bumped it either. Set amended: 2026-11-23. Source: code-review (medium)
  • docs/plans/2026-10-24-stack-encrypt-api-plan.md:2466 (outside diff) minor The naming table still lists IndexNotDeclared as a confirmed dynamic interface name, while line 2313 records its removal. Drop it, or mark it removed (#1671). Source: code-review (medium)

Every finding was verified at head. No correctness or security defect was found: none of the seven variants is raised at base, and the two refusals that remain (passthrough_with_outputs, outputs_with_target) are still raised. Build not run in this review (offline cargo could not fetch a git dependency); verification was by reading the code.


Generated by Claude Code

Comment thread packages/stack-encrypt/CHANGELOG.md Resolved
Comment thread packages/stack-encrypt/src/sem/mod.rs Resolved
… raises

The plan builder and the chain are gone, and with them the only code that
raised seven `PlanError` variants: `IdentityWithoutField`,
`IndexNotDeclared`, `IndexOptions`, `MixedCiphers`, `NoContext`,
`PassthroughIndexed` and `TargetWithVerbs`. A search of the workspace,
the Go guest and the EQL crates finds no constructor outside tests: each
was only matched in `dynamic::record`'s refusal mapping and listed in the
error-code tests. A reader of the error docs saw refusals that cannot
happen.

Each variant goes with its error code, its payload arm and its arm in the
`dynamic::Reason` mapping; `index_value`, used only by the `IndexOptions`
payload, goes too. No `dynamic::Reason` is removed: the parser still
raises `passthrough_with_outputs` and `outputs_with_target` itself, and
`refused` still covers `TwoContextSources` and `ContextNotStorable`. The
codes are names, not numbers, so the remaining ones are unchanged. The Go
guest's status table maps `Error::Plan(_)` as a whole to
`STATUS_ENCODING` and has no entry per variant; its test now uses
`BindInQuery`. No conformance corpus or Go error test names a removed
code.

ADR-0009 is amended to say what replaced `DefaultIndex` and `.via`: a
typed field answers through its target type's `Answers`, and a data plan
through `Op::answered_by`. The `MatchConfig`, `match_terms` and `Match`
docs no longer claim a field and its query agree "by construction": they
say how a query made from the field's reference takes the field's own
`Match<O>`, and that a filter derived directly matches only under the
field's configuration. No stored byte changes.

Closes #1671
The codes tests imported `IndexSpec` at module level, but only the two
helpers gated on the `dynamic` feature use it, so a build without
`dynamic` (the WASI guest's `--no-default-features` shape, which CI
builds with `-D warnings`) failed on an unused import. The import now
sits in those two helpers.

The CHANGELOG and ADR-0009 no longer say the plan builder raised all
seven variants: `plan::all` raised `MixedCiphers`, the builder the other
six. ADR-0009 names `dynamic::Op::answered_by` rather than `Op`, which
reads as the operator parameter of `Answers<Op, In>`, and its front
matter records the 2026-11-23 amendment. The API plan's naming table no
longer lists `IndexNotDeclared` as a confirmed name, and a rustdoc
paragraph in `sem` is rewrapped.
@coderdan
coderdan force-pushed the refactor/stack-encrypt-remove-unraised-plan-errors branch from a98951b to f8d29e9 Compare November 22, 2026 14:47
@coderdan

Copy link
Copy Markdown
Contributor Author

Review round 1 and the CI failure, addressed in f8d29e9. The branch was rebased onto #1748's new head (ba11786) and force-pushed. The rebase applied with no conflicts.

  • CI, "WASI check, guests and Go (Linux)": wasm:no-http-test runs cargo test -p stack-encrypt --no-default-features with -D warnings. The IndexSpec import in codes.rs is used only by two functions behind the dynamic feature, so it was unused without that feature. The import now sits inside those functions. The failure reproduced locally first, and it now passes.
  • ADR-0009 front matter (review body): now amended: 2026-11-23.
  • API plan naming table (review body): IndexNotDeclared is no longer listed as a confirmed name. The row notes it was removed, because no query takes an index from the caller.
  • The inline findings are answered on their threads.

Checks at f8d29e9:

  • cargo fmt --check passes.
  • clippy with -D warnings passes for --all-features, the default features, --no-default-features, and --no-default-features --features dynamic.
  • The CI task's stack-encrypt step passes locally.
  • cargo test -p stack-encrypt passes with the default features and with --all-features.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the cleanup of obsolete PlanError variants.

No open issues 🎉

Review effort: Balanced

Base automatically changed from refactor/stack-encrypt-record-builds-planned to next November 22, 2026 22:50

@coderdan coderdan left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Human pass. LGTM.

@coderdan
coderdan merged commit cf19e00 into next Nov 22, 2026
58 checks passed
@coderdan
coderdan deleted the refactor/stack-encrypt-remove-unraised-plan-errors branch November 22, 2026 22:52
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.

stack-encrypt: seven PlanError variants and DefaultIndex docs survive the removed builder — remove them and amend ADR-0009

3 participants