Repository navigation
#882 feat: a stable reason_code on every observation refusal (v0.80.0) - #889
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ObservationResponse.reason_code (an ObservationReasonCode enum in the spec, so the generated client carries it) is set on every `rejected` and null otherwise. The code is the reason's slug; the source_key_id gate is `provenance_conflict` everywhere (its reason text keeps source_key_mismatch / name_provenance_conflict until #888), and free-text validation messages are `invalid`. ObservationRejected now requires a code; resolvers answer REJECTED with a Refusal, a str that carries its code, so text comparisons keep working. A sweep (tests/core/test_refusal_code_sweep.py) holds every refusal site under src/ to a code. The design doc gains the operator's approval and the owned_by_dataset refusal, pulled into scope for the ownership PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_mismatch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e is an ordinary refusal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dataset test Co-Authored-By: Claude Opus 5.5 <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.
Part 1 of 2 for #882, the operator's decisions (comment 7172492503); design approved in comment 7175854705. Design doc:
docs/plans/2026-11-25-reason-code-ownership-design.md.What changes
ObservationResponse.reason_code: anObservationReasonCodeenum in the OpenAPI schema, so the generated client carries it. It is set on everyrejectedandnullotherwise.reasonstays diagnostic text and is unchanged on the wire.:. Three exceptions:source_key_idgate isprovenance_conflicteverywhere. Assignments and the org parent used to saysource_key_mismatch, and names saidname_provenance_conflict. Theirreasontext keeps the old wording until Observations: retire the reason text source_key_mismatch and name_provenance_conflict #888.invalid.unknown_identifier_type.ObservationRejected(code, detail=None)now requires a code.REJECTEDwith aRefusal, astrsubclass that carries.code. Existing callers that compare text keep working.ObservationResponse.rejected(code, reason).src/core/refusals.py.tests/core/test_refusal_code_sweep.pyparsessrc/and fails on any refusal site with no code.tests/core/test_refusals.pyholds the event and citation slugs inside the enum, and maps every name refusal.reason_coderow, "act onreason_code, logreason", and a code table.provenance_conflict.Verification
pytest -m integration): 5609 passed, 8 skipped.scripts/pre-ship.sh: passed.Not in this PR
Part 2 adds
ownershipon reads:self | other | none | datasetonAssignmentDetail, andparent_ownershiponOrgDetail, both folded into the ETag. It also adds theowned_by_datasetrefusal, and the ownership principle with its guard.🤖 Generated with Claude Code