Repository navigation
chore(purchase): remove the dead server-side SQS purchase path - #1812
Conversation
…ge path ApproveExecution now carries the plan-id propagation test, and the shared token check gets its TTL and precedence table (wrong token on an expired row reports invalid, not expired). The SQS-entry duplicates are removed because each has a named twin in approvals_test.go that asserts the same outcome: - ApproveHappyPath: TestManager_ApproveExecution_Success (:83) - FourEyesOn_SelfApproveDenied: ..._FourEyesOn_SQSActorEqualsCreator_Denied (:713) - FourEyesOn_DifferentApproverSucceeds: ..._FourEyesOn_DifferentActor_Allowed (:757) - CancelHappyPath: TestManager_CancelExecution (:851) - ApproveRejectsTokenMismatch: ..._InvalidToken (:178) - ExpiredTokenRejectedBeforeApproverLookup: ..._ExpiredToken (:1079) and TestManager_CancelExecution_ExpiredToken (:1284) Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The case and whitespace insensitive comparison was tested only through the SQS approver check. It is now asserted on authorizeApprovalAction, the production gate, for both sides of the comparison. The SQS-only tests are removed: the missing-actor cases exist only because the SQS message carried the actor (the HTTP twin is TestHandler_approvePurchase_RejectsMissingContactEmail), the mismatch and non-ASCII cases are covered by TestHandler_authorizeApprovalAction_NonASCIILettersNotFolded and the no-approver case by the "no per-account contact email" assertions. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd claim funnel Multi-account ack, redelivery and failure-notification tests now run through ProcessScheduledPurchases (Executed counts the ack), and the claim-pin, save-error and success tests call claimAndExecuteWithin directly with notified rows. The SQS execute_purchase refusal table is removed (every case is a row of TestScheduler_RefusesBeforeClaim), as are the by-ID load error test, the approved-row gate bypass test and the approved-row cap-skip test, which only exercised the SQS-only rules. A funnel-level test keeps the ErrStepCommitmentCap assertion. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unnel The armed Azure savings plan, AWS no-token and ladder recheck tests call claimAndExecuteWithin on notified rows instead of an SQS message. The shared harness plan now carries a step cap so the post-claim cap recheck passes and the guards under test, not the cap, decide the outcome. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The retry redrive and fan-out suites ran the persisted successor through an SQS execute message. They now keep the pending status the retry handler persists and approve it with ApproveAndExecute, the production path, with the same purchase-token assertions. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pause/claim worker is ProcessScheduledPurchases (a pending row is now skipped silently instead of refused), ramp-step root rows run through the sweep, per-account retry rows are pending and approved with ApproveAndExecute, and the claim-race and retention tests call claimAndExecuteWithin and claimAndRedrive. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing in this repo produces an SQS event, so the async purchase path behind it was dead. An aws:sqs event now falls through to the "unrecognized Lambda event shape" error instead of running purchase execution without the 4-eyes and contact gates the HTTP path enforces. The new test and the converted detect, routing and cmd/lambda rows failed before this change (the event routed and returned nil). Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With aws:sqs events no longer routed, handleLambdaSQSEvent and its batch-failure helper are unreachable. Delete them with their tests; the flag loader they used goes in the next commit. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sage Delete the flag, its loader and startup validation, Application .HandleSQSMessage, PurchaseManagerInterface.ProcessMessage, the mock's ProcessMessageFunc and their tests. The os and strconv imports in lambda.go go with the loader. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
handleApproveMessage, handleCancelMessage and their private approver gate (verifyAsyncApprovalActor, loadAsyncExecutionForApproval, matchActorAgainstApprovers, gatherApproverContactEmails) had no caller outside ProcessMessage. The production approver gate is api.Handler.authorizeApprovalAction. Trim the approve and cancel cases, message types and the token/actor fields from the message envelope, and drop the two missing-token subtests (twin: TestManager_ApproveExecution_EmptyToken and the CancelExecution invalid-token test). Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Delete the rest of messages.go (ProcessMessage, handleExecutePurchase, checkAutoExecuteGate, the message types) and its tests, plus the claimAndExecute wrapper whose last callers were re-homed. The cron sweep keeps claimAndExecuteWithin, isMultiAccountAckable and executableByScheduler. The by-ID execute loader and its "approved rows bypass the gate" rule had no production caller. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reword comments that described the removed SQS path, add the CHANGELOG Removed entry (the Lambda rejects aws:sqs events and SQS_REPORT_BATCH_ITEM_FAILURES is no longer read), and note the now unreachable "approved" entry of the claim funnel's from-set in known-issues.md as a follow-up. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…ecuteWithin Main added three integration tests that call claimAndExecute, which this branch removes. Run them through claimAndExecuteWithin on notified rows, like the rest of the file. Refs #399 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Update after opening: main gained 0a59d3a (#1809, a Redshift adoption-window refusal), which adds three integration tests that call
Proof at 7cfc88c:
|
|
APPROVED 7cfc88c by claude-ui-fix-1 Cold review at this SHA, against origin/main 0a59d3a. The lineage gates from #1807 and #1810 are in the base. In production code this PR only removes code and changes comments. It removes:
No guard logic changes. Findings
Every entry point reaches
Repointed Redshift tests (redshift_gate_integration_test.go:98, :161, :201, :223, :239) now call Nothing left on SQS. I grepped Go, config, env names, terraform, cloudformation, arm, iac, scripts, Mutation probes (scratch copy, each reverted):
Results (macOS, throttled):
Gaps:
|
|
APPROVED 7cfc88c by claude-qa-ui-4 Cold review. Outside the deletions, the production changes are comments and the removal of the claimAndExecute wrapper (internal/purchase/manager.go:203-213). No IaC is touched. Guards per path at this head (unchanged from main):
Retry successors, plan-step attach and the ladder execute through those paths. Cancel is a token-pinned conditional update.
Runs (GOMAXPROCS=4, -p 2):
|
Summary
Closes #399 by removing the server-side SQS async purchase-execution path. Nothing ever produced these messages: there's no queue, no event source mapping and no
SendMessageanywhere in the repo, its IaC or the sibling cli/go/mcp repos, andgit log -Sfinds none in history. SoProcessMessage, its approve/cancel/execute-by-ID handlers, the SQS batch handler andSQS_REPORT_BATCH_ITEM_FAILURESwere unreachable money-path code. That included a second, weaker approver gate and an execute-by-ID path that bypassedexecutableByScheduler's web-source rule forapprovedrows.The Lambda now rejects an
aws:sqsevent as unrecognized (internal/server/lambda.go). It is no longer silently processed. If a stray mapping ever existed, Lambda would retry and then DLQ the batch: loud and bounded.How (13 commits, each 400 lines or fewer; +509 -2028)
Re-home every test that went through the SQS path to the direct paths, deleting the old test in the same commit (58c8038 to ddbd504). The direct paths are
ApproveExecution,CancelExecution, the cron sweep,claimAndExecuteWithin,ApproveAndExecuteand the API handlers. Each guard the SQS path enforced is now pinned on the path that remains:TestManager_ApproveExecution_ExpiredToken,CancelExecution_ExpiredToken, newTestValidateApprovalToken_TTLAndPrecedenceTestManager_ApproveExecution_FourEyesOn_TokenActorEqualsCreator_Deniedand its allowed/unresolvable twinsApproverMatchIgnoresEmailCaseProcessScheduledPurchases_WebSourceSkipped,TestScheduler_RefusesBeforeClaim,FourEyesOnSkipsAutoRowarmed_redrive,aws_no_token_redriveandladder_execution_recheck, via the claim funnelpause_claimintegration suiteReject
aws:sqsevents, then remove the batch handler, the env var and the message handlers (782fce1 to 2f04055). The rejection tests landed first.Docs and comments (55dc44e, fe39d83). CHANGELOG,
known-issues.md, and SQS-era wording in comments and test names. Assertions are unchanged.The by-ID execute loader and its "approved rows bypass the gate" rule are deleted, not re-homed: nothing in production called them.
Behaviour change: an
aws:sqsLambda event now returns an error instead of being processed.SQS_REPORT_BATCH_ITEM_FAILURESis no longer read.Verification (at fe39d83, rebased on main 803090d)
go build ./...,go vet ./internal/...andgo vet -tags integrationon purchase, api and server all pass.go test -count=1passes on./internal/purchase/...,./internal/api/...,./internal/server/...and./cmd/lambda/....go test -count=1 -tags integration ./internal/purchase/... ./internal/api/...passes, with Postgres in testcontainers.Mutation probes (each reverted):
handler_purchases.go:304) also acceptrunningfailsTestPauseClaim_RunningWorkerCannotBeReclaimedandRejectsNonPendingStates. This ran before the rebase, at 722e0a92; the rebase didn't change that code.redshift_lineage.go:127) fails all 3 re-homed Redshift gate integration tests.git grep -i 'sqs\|AsyncMessage\|ProcessMessage'only hits CHANGELOG and the tests that pin theaws:sqsrejection (outsidedocs/auditsand lock and sum files).Reviews:
Pass 1 caught
redshift_gate_integration_test.go(added by feat(purchase): refuse a Redshift dispatch while another lineage of the tuple is open #1807 after the plan base) still calling the removedclaimAndExecute. It's fixed in 2f04055: the tests now useclaimAndExecuteWithinwithnotifiedrows.Out of scope
internal/config/store_postgres_recommendations.go:639mentions a "late redelivery" of collection triggers. That's unrelated to this path and untouched.🤖 Generated with Claude Code