Repository navigation
test(ladder): cover the handler's in-flight fetch error branch - #1218
Conversation
ladderTestStore.inFlightErr was never set, so the executeLadderRun branch that handles a failed in-flight commitment read inside PlanAndSaveLadderRun had no coverage. Add two tests that set it: - executeLadderRun returns "persist ladder run: <store error>" with the store error still in the chain (errors.Is). - runLadderConfigs counts the config Errored and nothing else. Both assert that no ladder run or tranche rows are saved, no purchase execution or history is written and no PurchaseLayer/ReshapeBuffer call is made. The handler already fails loudly here; this is test-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 1 billable file and costs up to $0.25. Or wait 8 minutes for your next included review. View limit details
Comment |
|
Independent review 2 (claude-fleet, cold): APPROVE 1591a6d Findings (none blocking):
Attacked: mutation probes on the production branch (handler_ladder.go:345-348 and processOneLadderConfig:270-273), in a scratch copy, each restored and confirmed identical with
Also checked:
Verified locally, with GOTOOLCHAIN=go1.26.10 and no cloud credentials, under the heavy lock:
Reviewed by an independent agent with no author context (second reviewer). Review only: nothing was pushed, and the GitHub review state is unchanged. |
|
VERDICT: APPROVE 1591a6d Independent adversarial review of PR #1218 (closes #1180) at 1591a6d, base main. Test-only: it adds internal/server/handler_ladder_inflight_test.go and changes no production code. The PR meets #1180's acceptance criteria. A test sets Findings: none blocking.
Attacked:
|
|
Local verification at |
|
Merged by IAmJSD's agent at IAmJSD's request (IAmJSD is acting owner while the maintainers are away), under the bar IAmJSD set: 1 approving independent review(s) on |
Summary
Test-only.
ladderTestStore.inFlightErr(ininternal/server/handler_ladder_test.go) was declared and honored by the fakePlanAndSaveLadderRun, but no test set it. So theexecuteLadderRunbranch that handles a failed in-flight commitment read had no coverage. In production that read isPostgresStore.PlanAndSaveLadderRun->lockedLadderCommit, inside the per-config lock.Root cause: a coverage gap, not a behavior bug. On current main the handler already fails loudly on this error: it returns
persist ladder run: %wandprocessOneLadderConfigcounts the configErrored. No production code changes.New file
internal/server/handler_ladder_inflight_test.go. It is a sibling file, so it does not touch the hunks inhandler_ladder.go/handler_ladder_test.gothat open PR #1199 edits. It adds:TestExecuteLadderRun_InFlightFetchError_FailsLoudAndPersistsNothing:executeLadderRunreturns an error,errors.Isfinds the store's error in the chain, and the message is exactlypersist ladder run: <store error>.TestRunLadderConfigs_InFlightFetchError_CountsErrored: the same error sent through the per-config loop gives exactlyLadderRunResult{Errored: 1}, neverPlanned.Both tests check that nothing was saved or submitted:
ladder_runsrow (savedRun/savedRuns) and noladder_tranchesrows, so there is nothing for the fire task to submit later;SavePurchaseExecution/SavePurchaseHistory;PurchaseLayer/ReshapeBuffercalls.Small counting wrappers record these, so the checks are counted assertions rather than the absence of a
t.Fatal.The fixture would otherwise plan a positive purchase (low-water 10, target 8, nothing existing). That means a swallowed error would visibly save a run with an 8 $/hr tranche.
Closes #1180
Verification
All evidence is unit/mock-store level. There is no real Postgres, cloud or purchase path. Tests ran with
AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/nullbecause this machine's default AWS profile is invalid.Mutation proof. Each mutation replaced only the
if err != nil { return fmt.Errorf("persist ladder run: %w", err) }branch afterPlanAndSaveLadderRuninexecuteLadderRun. Each was run withgo test ./internal/server/ -run InFlightFetchError -count=1, then the original was restored (git diffonhandler_ladder.gois empty):in.plan(nil), thenSaveLadderRun+SaveLadderTranches, return nilPlanned:1, Errored:0; run and tranches saved)return nilPlanned:1)"persist ladder run failed"ErrorIs)The tests passed against the unchanged handler as soon as they were written. That is expected, because this PR adds coverage and does not fix a bug. The fail-before evidence is the mutation table above.
Out of scope / notes
handleLadderRunreturns(result, nil)even when every config isErrored. Per-config isolation is the documented design (runLadderConfigs), and theErroredcounter is the failure signal. UnlikehandleProcessScheduledPurchases(chore(iac): no alert reaches anyone; instantiate monitoring and wire failure notifications #714), the scheduler therefore sees a successful task. I left this alone: changing it would affect every per-config error kind, not only this branch. A maintainer may want a separate issue for it.PostgresStore.PlanAndSaveLadderRunin-flight read error (rollback under the lock) is not exercised here. This PR covers the handler's branch with the mock store only.Maintainer: please mirror the issue's triage labels onto this PR:
impact/internal,type/chore,triaged,priority/p3,severity/low,urgency/this-quarter,effort/xs.🤖 Generated with Claude Code