feat: generate status-specific action attempt subclasses - #486
Merged
Conversation
Consume the actionAttemptStatuses property annotation from @seamapi/blueprint 1.10.0: each action type class is now further discriminated by status into one final subclass per status. A property annotated with actionAttemptStatuses keeps its generated type on the subclasses for the statuses it lists and is declared with the null type everywhere else, so error is only readable on the error subclass and result only on the success subclass. An unknown status falls back to the action type class and retains the raw status value. This replaces the blanket nullability workaround that forced error into the shared base class and documented error and result as null while pending, and it restores the per-action-type error shapes that the shared error class had collapsed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp
…otations-f216kn' into claude/action-attempt-status-annotations-f216kn
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.
What this means for SDK users
Every action attempt now deserializes to a subclass for its exact
(action_type, status)pair, soerrorandresulthave real types exactly where they exist and the literalnulltype everywhere else:Unknown discriminator values still fall back safely, preserving the raw value: an unknown
action_typegives the baseActionAttempt, an unknownstatusgives the action-type class (e.g.ActionAttempt\LockDoor).A failed attempt without an error object no longer crashes
ActionAttemptFailedError— it falls back to the message "Action attempt failed".Runtime behavior is unchanged — the API always sent
null; the declared types just stopped lying about it.How
Extends #479. Bumps
@seamapi/blueprintto ^1.10.0, which annotates each action-attempt property with the statuses that populate it. Codegen nests a second discrimination level under each action type using the same conventions as #479 (backed enum,tryFrom+match, unrecognized fallback keeping raw values). Properties are placed per status from the annotation alone — nothing is keyed off the nameserror/result. The #479 blanket "error/result nullable everywhere" workaround is removed. Side benefit: the five distinct per-action-type error shapes are now preserved instead of collapsing into one shared class.Verification
New
ActionAttemptTest(10 tests) covers every behavior above. phpunit: 274 tests, 631 assertions green. psalm: 0 errors. Regeneration from a clean install reproduces the diff exactly; onlysrc/Resources/ActionAttempt.phpchanged among generated files.🤖 Generated with Claude Code
https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp