Result Default Guard - #81
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018zr2wzeYJD6T3PQ3nWy53B
A result that is invalid while carrying no errors is neither a success nor a failure. Writing it over CloudEvents emitted a failure payload with an empty errors array that this library's own reader rejects, and the HTTP paths failed only incidentally, with messages naming neither the result nor the default instance. Every public API that consumes a result in order to write it out now routes through the new ResultObjectExtensions.MustNotBeDefaultInstance guard clause, which throws one ArgumentException naming the default instance as the cause and Result.Ok/Result.Fail as the remedy. This covers both sites per transport, so the guard cannot be bypassed by constructing the public wrapper structs directly. Note that only Result<T> with a reference type or a nullable value type can take that shape: Result encapsulates a Result<Unit>, and IsValid tests _value is not null, which a value type always satisfies. The guards on the Result-typed sites are therefore unreachable today and are kept for uniformity - see ai-plans/0080-1-plan-deviations.md. Closes #80 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WwGeQai3zfz6wYLeNQx8Ag
Both notes in "Here is Your Space" moved to where the knowledge is used, leaving the section empty for the next round of notes. Why the two evaluation catch filters in MetadataValueReconstructor exclude OperationCanceledException is now a comment at both filters: an aborted generation pass must propagate rather than be downgraded to an unsupported value. That the contract is not observable through the generator's public surface is a blind spot, so it joins the other "do not read as adequate coverage" entries in tests/AGENTS.md, naming the trigger that would make it testable. A README.md for the source generator project was considered and rejected for now; the reasoning is in the plan deviations file. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WwGeQai3zfz6wYLeNQx8Ag
Document the exact invalid-without-errors predicate and identify a default instance as its usual source, so custom IResultObject values are not mislabeled. Strengthen the tests with genuinely non-default custom structs and correct the deviations record's housekeeping history.
10 tasks
Minimum allowed line rate is |
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 #80