Skip to content

swapwallet: project credit operations into the canonical activity log (#774) - #840

Merged
darioAnongba merged 1 commit into
mainfrom
dario/774-credit-projector
Jul 1, 2026
Merged

swapwallet: project credit operations into the canonical activity log (#774)#840
darioAnongba merged 1 commit into
mainfrom
dario/774-credit-projector

Conversation

@darioAnongba

@darioAnongba darioAnongba commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Closes the producer-coverage gap roasbeef flagged on #776: credit-only sends (#830) reach the wallet feed only at read time (collectCreditEntries), never through Runtime.emit. PR #817's projector hooks the swap monitor, cooperative-leave submit, and deadline overlay — but not credit. If the read path were cut over to the store without this, credit-only sends would vanish from the canonical log, exactly the #829 class of bug this epic exists to kill.

Change

  • The credit projector loop (credit_projector.go, pollCreditOps) and the credit-pay pending emit (router.go, sendCreditInvoiceIntent) now route through projectAndEmit instead of emit, so credit rows land in the canonical activity store, not only in the live subscriber fan-out.
  • No new subscription protocol: the existing 5s poll already produces the WalletEntry updates and only fires on a state change; the store's changesRow suppression means the coarse re-poll of unchanged rows appends no duplicate events. Backfill already covers credit via listActivitycollectCreditEntries.

Tests

  • TestCreditProjectorWritesToStore: the projector persists the credit rows it owns (credit-only pay keyed by payment hash, credit receive keyed by op id) into the store, and a re-poll of unchanged state projects nothing further.
  • Existing credit-projector emit tests still pass unchanged.

make build, make lint-changed-local, and the swapwallet unit suite pass.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request ensures that credit-only sends are correctly projected and persisted into the canonical activity store before being emitted. Specifically, it replaces calls to emit with projectAndEmit in both pollCreditOps (using the root context) and sendCreditInvoiceIntent (using a non-cancelable context to prevent write cancellations on client disconnects). Additionally, a new unit test TestCreditProjectorWritesToStore and a helper method ids() have been added to verify this behavior. No review comments were provided, so there is no additional feedback.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@darioAnongba
darioAnongba force-pushed the dario/774-activity-store-foundation branch from 46d8afa to 4477c4f Compare July 1, 2026 16:53
@darioAnongba
darioAnongba force-pushed the dario/774-credit-projector branch from 12569d3 to 205ca3e Compare July 1, 2026 16:54
Base automatically changed from dario/774-activity-store-foundation to main July 1, 2026 17:19
@darioAnongba darioAnongba self-assigned this Jul 1, 2026
Route the credit projector loop and the credit-pay pending emit through
projectAndEmit so credit-only sends and credit receives are written to
the canonical activity store, not only fanned to live subscribers.
Without this they reach the feed only at read time, so they would vanish
from the store once the read path cuts over to it. The store suppresses
no-op re-projections, so the coarse credit re-poll appends no duplicate
events. Backfill already covers credit via the read-path collector.
@darioAnongba
darioAnongba force-pushed the dario/774-credit-projector branch from 205ca3e to 623c36c Compare July 1, 2026 17:35
@darioAnongba
darioAnongba merged commit c537de4 into main Jul 1, 2026
20 of 21 checks passed
@darioAnongba
darioAnongba deleted the dario/774-credit-projector branch July 1, 2026 18:07
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.

1 participant