Skip to content

fix: spark exit repeat fee ask notification - #1333

Merged
ovitrif merged 2 commits into
masterfrom
fix/spark-exit-withdrawn-reminder
Nov 16, 2026
Merged

ovitrif merged 2 commits into
masterfrom
fix/spark-exit-withdrawn-reminder

Conversation

@ovitrif

@ovitrif ovitrif commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1324

Description

  • Fixes a Spark exit fee ask asked again after a withdrawal posting no notification: withdrawing an ask (isFundingAskWithdrawn) now also forgets the exit's fired funding- reminders in sparkExitReminders, not only its delivered notifications. A later ask for the same requiredSats reuses the id funding-<requiredSats>, so before this reminderDate saw it as fired for 30 days and posted nothing.
  • The forget runs synchronously in dismissDeliveredFundingNotifications, before the same tick's scheduleReminders reads the remembered dates, so that run never puts the id back.
  • Background runs (runInBackground) now check for a withdrawn ask too, as the foreground tick does, so an ask a background run withdraws gets the same cleanup.

Found by Greptile in #1323 (comment).

Out of Scope

None.

Design

N/A — no UI changes.

Preview

N/A — no user-visible changes.

QA Notes

Setup

N/A — no device testing required: staging a withdrawn fee ask and a repeat ask for the same amount needs a Spark exit on regtest with controlled fee builds; the unit test covers the reminder bookkeeping.

Journeys

N/A — not drivable; see Manual Tests.

Manual Tests

N/A

Automated Checks

  • added SparkExitTests.swift — a fee ask withdrawn and asked again for the same amount posts a reminder, while another step's fired reminder stays remembered

Evidence

  • SparkExitTests and SparkExitReviewTests pass on this PR's head on an iPhone 17 simulator.
  • swiftformat --lint passes on the changed files.

Gaps

  • The test drives the reminder helpers (forgettingFundingReminders, keepingFired, reminderDate), not UNUserNotificationCenter or the background run's wiring.

Models used

  • Planning/scoping: claude-opus-5-5 (reasoning: medium)
  • Implementation: claude-opus-5-5 (reasoning: medium)
  • Review: Not performed

A withdrawn fee ask now forgets that its reminder fired, so a later ask for the same amount posts a notification again.
@ovitrif ovitrif self-assigned this Nov 14, 2026
@ovitrif
ovitrif requested review from a team, ben-kaufman and pwltr and removed request for a team November 14, 2026 01:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T01:39:52.445878Z 727fe2e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 727fe2e0ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Managers/SparkExitManager.swift Resolved
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The change is limited to fee-reminder notifications for Spark exits.

The background withdrawal path needs the same cleanup before this fix is ready to merge.

Findings

  1. P1 Background requests still stay silent ▶

Summary

Clears remembered funding reminders when a foreground tick withdraws a fee ask.

  • Spark exits can remind users again when the same fee ask returns.

Reviews (1) · Last reviewed commit: "fix: spark exit repeat fee ask notificat..." · Reviewed by Greptile

Comment thread Bitkit/Managers/SparkExitManager.swift Resolved

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings. When a fee ask is withdrawn, dismissDeliveredFundingNotifications now also drops the exit's funding- ids from the remembered reminders, so a later ask for the same requiredSats (same id) is no longer treated as fired for 30 days. Reviewed 727fe2e, light tier (one function in SparkExitManager.swift, plus the test).

What I checked, and 3 candidates I ruled out

Read: tick(), afterTick, scheduleReminders, reminderDate, keepingFired, notificationId, isFundingAskWithdrawn and clearReminders in SparkExitManager.swift.

Ordering traced: the class is @MainActor. tick() calls dismissDeliveredFundingNotifications synchronously right after isFundingAskWithdrawn, then afterTick runs scheduleReminders, which reads rememberedReminders() after the UserDefaults write. So that same tick cannot put the forgotten id back through keepingFired.

Ruled out

  • The forgotten id coming back from kept: isFundingAskWithdrawn requires record.phase == .running, so the plan for updated holds no funding reminder and kept has no funding- id.
  • Forgetting more than the withdrawn ask: the filter matches the same ids the delivered notification removal already matched (this exit's prefix plus funding-). Other steps' fired reminders stay, and the test asserts that for 1-h3000.
  • A concurrent writer of sparkExitReminders: scheduleReminders and clearReminders run on the main actor too, and every tick path is serialised by isTicking.

Build: not built here. iOS does not build on this Linux reviewer, so this is reasoned from the code. SwiftFormat passed; Run Tests was still running when this review was posted.

Merge confidence: 4/5, no findings and the change is covered by testAFeeAskAskedAgainAfterAWithdrawalPostsAReminder, but the unit tests had not finished in CI at review time.

Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the run's metadata available to this reviewer does not carry the setting)

A background run that withdraws a fee ask now takes back its notification and forgets its fired reminder, as a foreground tick does.

@pwltr pwltr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed ba1e87f. No issues found.

Withdrawing a fee ask now drops the exit's fired funding-<sats> and await-funding-<sats> ids from sparkExitReminders, so a later ask for the same amount posts again. Other steps' fired reminders stay. The write happens synchronously before afterTick runs scheduleReminders, so keepingFired can't restore the id in the same run. runInBackground now runs the same check against the record it started from. A fee ask that funding actually satisfied keeps its 30-day memory, as before.

Review details

General review
Model: Claude Opus 5.5
Reasoning effort: high

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings at ba1e87f65.

Checked:

  • The withdrawal path now removes only this exit's funding- / await-funding- ids from sparkExitReminders (SparkExitManager.swift:1604-1610), on the foreground tick and, since ba1e87f, on background runs. A later same-amount ask (funding-<requiredSats>) now notifies again instead of staying silent for 30 days.
  • Ordering: the class is main-actor isolated and the reminders write happens before the same run schedules reminders, so that run cannot re-add the forgotten id.
  • Funds: the driver, isFundingAskWithdrawn, funding adoption and the in-flight savings-payment check are untouched; only notification bookkeeping changes. A re-ask still requires the same unconfirmed-payment conditions as before, and an earlier payment stays adoptable or sweepable at the funding address.
  • Parity: Android posts the funding alert on every transition into NeedsFunding with no per-amount memory, so this brings iOS in line; no Android twin needed.
  • No upgrade concern: SparkExitManager.swift is not in v3.1.1. Not performance-relevant (one UserDefaults read/write per withdrawal).

⚠️ Device gate: not run — reaching a withdrawn fee ask needs a Spark exit forced into needsFunding through an unverified rebuild (a chain host that fails to read a step across two checks), which needs fault injection in the chain backend that is not available on my setup. The approval rests on the code trace, SparkExitTests, and green CI; the notification repost is still unrun on a device.

Reviewer model: claude-opus-5-5 (primary review and coordination)
Reasoning effort: not exposed (subagent), default (coordinator)

@ovitrif

ovitrif commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Merging with a merge commit: approved by @pwltr and @jvsena42 on ba1e87f, CI green, no open threads.

@ovitrif
ovitrif merged commit ff2f786 into master Nov 16, 2026
21 of 22 checks passed
@ovitrif
ovitrif deleted the fix/spark-exit-withdrawn-reminder branch November 16, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: spark exit fee ask asked again after a withdrawal posts no notification

4 participants