Repository navigation
fix(ladder): net tranches completed between the E read and the locked in-flight sum - #850
Merged
Merged
Conversation
… in-flight sum PlanAndSaveLadderRun now adds completed tranches settled after ladderSettleAnchor(asOf) to the locked in-flight figure. asOf is captured before the layer-state (E) read, so a tranche completing in between is netted (counted twice if E already has it: a safe under-buy). The anchor is asOf minus ladderSettleSkewMargin to cover app/DB clock skew. Safe only once the visibility adapter (executor PR5a) lands. Closes #843 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Member
Author
Gate verdict (Opus 5.5, money path): APPROVE at
|
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 #843
What
PlanAndSaveLadderRunnow adds completed tranches settled afterladderSettleAnchor(asOf)(asOf minusladderSettleSkewMargin, 1 min) to the locked in-flight figure, using the sharedsettledLadderCommitpredicate from #849.asOfis the handler'snow, captured beforeGetLayerStates(E), so a tranche that goes fired->completed between the E read and the locked SUM is netted. If E already contains it, it is counted twice: a safe, bounded under-buy that heals next cadence. Never a miss.lockedLadderCommit).ladderSettleAnchoris the shared helper the fix(ladder): amending a tranche down then up over-buys past target (checkLadderRunTotal) #842 amend path must reuse.PlanAndSaveLadderRun,interfaces.go,GetInFlightLadderCommitUSDHr, stale netting comment inhandler_ladder.go.Safety condition
This is safe only once the visibility adapter (executor PR5a) lands: a tranche must be marked completed only after its commitment is visible through the same source as E, and visibility must not revert. Nothing completes tranches today.
Verification (real PostgreSQL 17, local macOS; Linux via CI)
TestLadderB1_TrancheCompletingBetweenEReadAndLockedSumIsNetted; real store and schema, FIXTURE capability that completes the tranche insideGetLayerStatesand returns stale E): FAILS on origin/main (re-plans 5, want 0), passes with the fix.Labels mirror #843.
🤖 Generated with Claude Code
Summary by CodeRabbit