Fix care-plan review loop: route on decision, fail closed - #147
Merged
jaideepr97 merged 1 commit intoAug 24, 2026
Merged
Conversation
The UI/contract (ReviewAction) submit the review outcome as `decision`, but the workflow switch (CheckCarePlanReview) and the BFF state derivation keyed on `.action`, which is never present. Every review fell through to the switch default -> WriteFHIR, so clicking "Request changes" (reject) silently wrote the plan as active instead of looping to regenerate, and previousFeedback never reached the UI. - workflow: route CheckCarePlanReview on .careplanReview.decision (approve / request_changes); change the defaultCondition from WriteFHIR to ReviewCarePlan so an unrecognized decision fails CLOSED (never auto-writes). - bff: infer_current_state + map_to_run_detail read .decision (not .action) for routing state and previousFeedback. - tests: cover approve->WriteFHIR, request_changes->GenerateBundle loop, and previousFeedback surfacing on the second round. (Fail on the old .action code.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
samschifman
approved these changes
Aug 24, 2026
jaideepr97
approved these changes
Aug 24, 2026
This was referenced Aug 25, 2026
Closed
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.
Sam flagged verifying the reject/feedback loop — it was broken, in the fail-open direction.
Bug
The UI + contract (
ReviewAction) submit the review outcome asdecision, but the workflow switch and BFF state derivation keyed on.action, which is never present:CheckCarePlanReview(acp-writer-workflow.yaml) —.careplanReview.action == "approve" | "request_changes", withdefaultCondition: WriteFHIR.sonataflow_client.py—infer_current_state/map_to_run_detailread.get("action").Since
.actionis always null, every review fell through to the default →WriteFHIR. So clicking “Request changes” (reject) silently wrote the plan asactiveinstead of looping to regenerate, andpreviousFeedback/reviewIterationnever reached the UI. Approve only “worked” because the default happened to also beWriteFHIR.Not caught earlier because the mock BFF (#136) and MSW mocks key on the contract field
decision— only the real SonataFlow path had the mismatch.Fix
.careplanReview.decision; changedefaultConditionfromWriteFHIRtoReviewCarePlanso an unrecognized/missing decision fails closed (never auto-writes) — ties to Harden clinical review pipeline to fail safe #47.infer_current_state+map_to_run_detailread.decisionfor routing state andpreviousFeedback.test_bff_review_mapping.pycovers approve→WriteFHIR, request_changes→GenerateBundle loop, andpreviousFeedbackon round 2. Verified failing on the old.actioncode, passing after.The UI is already correct (sends
decisionper the contract); no UI change needed.Deploy note
Workflow change is
oc apply(SonataFlow dev profile, no build); the BFF change needs anacp-writer-bffimage rebuild + rollout.Generated by Claude Code under the supervision of Khaled Sulayman