fix(activity): scope indexed transfers to the workspace - #144
Merged
Merged
Conversation
The Graph activity query is sent with the shared server wallet alongside the workspace's user wallets, so a stored observation also carries transfers made for other workspaces. Settlement and uncertain counts were SQL-scoped to the workspace while the unmatched transfer count was taken from the whole observation, so Payment proof reported one workspace's 11 settlements next to 40 unmatched transfers drawn from every workspace. Filter the observed transfers to the ones this workspace can own before they are matched, listed or counted: the sender is a workspace payer wallet, or the transaction hash is already recorded on a workspace settlement, job or attempt. The attempt hash keeps a stranded server payment visible as unmatched evidence.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
oneshot | a5aacd2 | Sep 13 2026, 02:49 PM |
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.
Problem
Payment proof showed 11 committed settlements next to 40 unmatched transfers. The two numbers came from different scopes.
StudioWalletActivityPort.refreshsends the shared server wallet as a sender alongside the workspace's user wallets, so a stored observation payload carries transfers made for every workspace on the deployment. InJobLedger.activity,recorded_settlement_countanduncertain_job_countare SQL-scoped byworkspace_id, butunmatched_transfer_countand thetransferslist were taken from the whole observation payload. Other workspaces' activity was counted, and listed, as this workspace's unmatched evidence.Change
JobLedger.activitynow filters the observed transfers down to the ones this workspace can own, before they are matched, listed or counted. A transfer is kept when either:resumable_jobs.payment_transaction_hash, or on an attempt'sprovider_transaction_hash.The attempt hash in that union is deliberate: a stranded server payment (funds sent, no settlement row) still has an attempt hash, so it stays visible as unmatched evidence rather than being filtered away with the foreign traffic.
Tests
unmatched_transfer_countstays 0.Verification
tsc -bcleanNot verified against a live Postgres: no database URL available locally and no integration test covers
activity(). The new SQL is plain SQL and the columns are confirmed in migrations 007 and 009.