Repository navigation
fix: keep the spark exit transfer until cooperative steps land - #1885
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] This PR appears safe to merge. SummaryKeeps a Spark exit transfer active while any cooperative step in its current recovery remains unconfirmed.
Reviews (1) · Last reviewed commit: "fix: keep the exit transfer while a coop..." · Reviewed by Greptile |
|
Triage: milestone 3.2.0. This PR fixes the Spark emergency exit (#1782), which is 3.2.0 work, and closes no issue, so it carries the milestone itself. |
talosmachina
left a comment
There was a problem hiding this comment.
1 finding (1 P1). Keeps a Spark exit's transfer unsettled while a cooperative step of the recovery is unconfirmed, so its value stays in the in-transfer balance until it lands. Reviewed 780bcbb, full tier, static: Bitkit Android PRs are not built here, so this is reasoned from the code and from CI.
What I checked, and 4 candidates I ruled out
Read in full: settleIfFinished, afterTick and load in SparkExitRepo.kt; isActive, hasLeavesOutstanding, adopt in SparkExitRecord.kt; broadcastReady, broadcastWithoutSdk and the all-confirmed end in SparkExitDriver.kt; confirmedReceived/paidTo in SparkExitFunding.kt; SparkExitState.inTransferSats; the new test.
Call sites traced: settleIfFinished (from afterTick and load), inTransferSats (DeriveBalanceStateUseCase, WalletRepo)
CI: lint red on this diff (detekt ImportOrdering, inline); build-local green; build-and-test still running when this was posted.
Ruled out
- Transfer stuck forever on a cooperative step that never confirms (an
Unverifiedone nodes refuse): the!record.isActivearm still settles it once the exit ends, whichever way it ends, so the new condition cannot hold the transfer past the exit. - Balance double counted after the step confirms:
inTransferSatssubtractsconfirmedReceived, which includes confirmed COOPERATIVE outputs, and the same tick settles the transfer, so the value moves from in-transfer to Savings once. - Recovery without a sweep:
sweepActivityis null, so that arm never fired before either; behaviour unchanged. - Test passing for the wrong reason: the second
load()runs on a fresh SUT (isLoadedis per instance), and the record differs only in the cooperative step's status, somarkSettledis reached through the new condition and nothing else.
Merge confidence: 1/5, CI fails on the change itself (the import order), though the fix is a one-line move.
Reviewer model: claude-opus-5-5
Reasoning effort: Unknown (not recorded in the run metadata available to this reviewer)
|
Fixed the import order that failed Re-review is needed only because of this push: 780bcbb...b03ecad |
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
pwltr
left a comment
There was a problem hiding this comment.
No findings at b03ecad. The import is now in order. The transfer change, which keeps the exit's transfer until every cooperative step confirms, is unchanged and looks right.
Review details
General review
Model: Claude Opus 5.5
Reasoning effort: high
jvsena42
left a comment
There was a problem hiding this comment.
No findings. The transfer stays active while a cooperative step is pending, and !record.isActive still settles it whenever the exit ends; settleOrphanedTransfers is unchanged. Confirmed cooperative outputs count in confirmedReceived, so the same tick settles the transfer, and a rebuild carries earlier confirmed value in earlierReceivedSats. Cooperative-only exits behave as before. The driver is untouched, so nothing new is broadcast or paid.
Device gate: no device check needed: a mixed recovery can't be staged, as the description says, and the change is in-transfer accounting covered by the new test. perf: not relevant.
Reviewer model: Claude Fable 5.2 (claude-fable-5-2), Claude Opus 5.5 (claude-opus-5-5)
Reasoning effort: not exposed
Description
Out of Scope
None.
Design
N/A — no UI changes.
Preview
N/A — the in-transfer amount stays until the cooperative step confirms.
QA Notes
Automated Checks
SparkExitRepoTest:a landed sweep keeps the transfer while a cooperative step is still on its way. The transfer stays while the cooperative step is Ready and settles once it confirms.Not tested