fix(wire): tolerate coherence finding codes this build has never heard of - #102
Merged
Conversation
…d of The server publishes `Finding.code` as an open set — codes are added additively as new coherence rules ship. The vendored spec closed it into a generated enum with three variants and no fallback arm, so the first validate response carrying an unfamiliar code failed to deserialize *entirely*: not the one unknown finding, the whole response. An installed CLI that was merely out of date became one that could not read a validate response at all, and every additive server-side rule became a coordinated release. The spec now types `code` as a plain string with the known values in its description, so regenerating drops the enum altogether. That is a stronger fix than a `#[serde(other)] Unknown` arm: there is no closed type left to fall out of, and the unrecognized code survives as the string the server sent rather than collapsing to a variant with no name in it. `partition`'s key function loses the serde round-trip it used to recover the enum's wire spelling, and `validate`'s `code_str` match goes with it — the human and JSON output now print whatever the server said. `severity` deliberately stays closed. It is a two-valued verdict the CLI branches on to choose an exit code, so a third value is a real breaking change that should fail loud rather than fall through to "not an error". Pinned by a test. Re-vendored `openapi.json` and regenerated `wire/` from it, which also picks up the project and branch lifecycle routes and the decisions read surface that had landed on the server since the last vendor. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…fmt's `cargo fmt` (no `-p`) reformats the workspace, and `wire/` is a member — so it rewrote all 87 generated files and the regenerate-and-diff guard failed on every one of them. CI formats the hand-written crate only (`cargo fmt -p hydrate -- --check`) for exactly this reason: the committed wire client must be byte-identical to what `scripts/regen-wire.sh` produces, or the guard cannot tell a real spec drift from a formatting preference. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Additive: `DecisionOut` gains the nullable acceptance criterion, so the generated `decision_out.rs` gains an `Option<String>`. No hand-written code references it — the CLI does not call the decisions routes — but the regenerate-and-diff guard compares the committed crate against the vendored spec, so the two have to move together. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes the CLI half of the open-finding-code contract.
The break
Finding.codeis an open set server-side — codes are added additively as new coherence rules ship. The vendored spec closed it into a generated enum:No catch-all, no
#[serde(other)]. The first validate response carrying a code this build has not heard of fails to deserialize entirely — not the one unfamiliar finding, the whole response. An installed CLI that is merely out of date becomes one that cannot read a validate response at all, and every additive server-side rule becomes a coordinated release.The fix
The server now publishes
codeas a plain string with the known values in its description, so regenerating drops the enum altogether.That is stronger than adding an
Unknownarm: there is no closed type left to fall out of, and the unrecognized code survives as the string the server sent rather than collapsing into a variant with no name in it. A user toldorphan_nodecan search fororphan_node; a user toldUnknowncannot.Consequences in
src/:partition::keyloses theserde_json::to_valueround-trip it used to recover the enum's wire spelling —f.codeis already that string.validate::code_str's three-arm match is deleted; human and JSON output print whatever the server said.severitydeliberately stays closed. It is a two-valued verdict the CLI branches on to pick an exit code, so a third value is a real breaking change that should fail loud rather than fall through to "not an error". Pinned by a test.Regeneration scope
openapi.jsonwas re-vendored andwire/regenerated from it, so this also picks up the project and branch lifecycle routes and the decisions read surface that landed on the server since the last vendor. Nosrc/change was needed for those — they are additive.Tests
Three new tests in
src/cmd/validate.rs: an unknown code deserializes, an unknown code is rendered verbatim, and an unknown severity is still rejected.cargo testgreen (485 tests),cargo clippy -D warningsclean,cargo fmt --checkclean.🤖 Generated with Claude Code