Repository navigation
Fix: 4 issues (#99, #100, #101, #102) - #129
Merged
victorisiguzoruzoma874 merged 2 commits intoOct 18, 2026
Merged
Conversation
Co-authored-by: Simple Agent <agent@simple.dev>
|
@197827 is attempting to deploy a commit to the work Team on Vercel. A member of the Team first needs to authorize it. |
|
@197827 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
- src/db/schema.ts: merged [markers] — model resolved the conflict markers - src/workers/eventListener.ts: merged [markers] — model resolved the conflict markers Co-authored-by: Simple Agent <agent@simple.dev>
victorisiguzoruzoma874
merged commit Oct 18, 2026
a9964ed
into
SynapsVault:main
0 of 2 checks passed
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 #99
Closes #100
Closes #101
Closes #102
Issues
#99 /agent/status reports earnings as verification count times list price
#100 Publisher analytics loads all payments and filters them in JavaScript
#101 Event listener advances the checkpoint even when a handler fails
#102 Event polls can overlap when one poll runs longer than the interval
Summary
For #99, the settled filter depends on how settlement is tracked; if no settled column exists yet, add one to
payments(see schema step) and backfill existing rows as settled. For #100, keep the response shape identical so the existing test'stoMatchObjectassertions still pass; the aggregate query must filter byrecipientAddress = publisher.walletAddressto preserve the current semantics. For #101/#102, the in-flight guard and monotonic checkpoint write are independent of the failed-event retry table; the retry table is optional if the simpler 'stop before first failed event' approach is chosen, but the schema step adds it for completeness. Tests for the event listener should mock the stellar-sdk RPC server and the ledger tracker file path (via LEDGER_TRACKER_PATH env) to avoid touching disk.Changes
totalEarned = totalVerifications * pricePerVerificationwith a SQL aggregate that sums the amounts actually recorded for settled verification payments. Query thepaymentstable joined toverifications(or filter by the settled status/flag on the payments/verifications rows) for records belonging to the agent's wallet (config.PAY_TO/ recipientAddress), and usesum(payments.amount)(cast to numeric) to computetotalEarned. Keep the existing response shape (totalEarned.toFixed(4)). Importsum,sqlfrom drizzle-orm andpaymentsfrom the schema. Do not count rejected or unsettled verifications, and do not use the current list price. Update the test file to add a case with mixed outcomes (settled, rejected, unsettled) asserting only settled amounts are summed; extend the db mock to handle the aggregate query. (src/routes/verify.ts)stats.totalEarnedequals the sum of only the settled payment amounts (not count × price). Update the db mock so the new aggregate query path (sum over payments for settled verifications) is supported alongside the existing verifications/resources selects. (src/routes/verify.agent-status.test.ts)allPayments.filter(...)logic with a single query usingGROUP BY payments.resourceId(joined to the publisher's resources) that computescount(*)andsum(amount)per resource, filtered byrecipientAddress = publisher.walletAddress. Compute the summary totals from the same aggregate result (or a second aggregate over the same filter). ForrecentPayments, run a separate paginated query per resource (or a windowed query) usingORDER BY paid_at DESC LIMIT 5 OFFSET 0instead of slicing in memory. Preserve the existing response shape (totalEarnedas.toFixed(4),totalSales,recentPaymentsfields). Importsum,count,sql,descfrom drizzle-orm. (src/routes/publishers.ts)totalEarned/totalSalesand summary totals) match the previous in-memory implementation's output for the same fixture data. (src/routes/publishers.test.ts)pollEvents, tracklastSuccessfulLedgerstarting atlastLedger; iterate events in ledger order and only advancelastSuccessfulLedgerafter each event's handler completes successfully. On a handler error, break out of the loop (do not advance past the failed event) and log it; then callsaveLastLedger(lastSuccessfulLedger + 1)only if it is greater than the currently stored checkpoint. This ensures a failed event is retried on the next poll. (b) Add a module-levellet pollInFlight = falseguard at the top ofpollEvents: if already true, return immediately; set it true in a try/finally that resets it. (c) MakesaveLastLedgermonotonic: read the current stored value and only write if the new ledger is greater than the stored one. Add tests: one where a handler throws and asserts the checkpoint stays before that event and the event is processed on the next poll; one with a deliberately slow poll asserting at most one poll runs concurrently. (src/workers/eventListener.ts)failed_eventstable (id, eventId, ledger, topic, payload, error, attempts, createdAt) to support recording failed events for retry, and add asettledboolean (orstatusenum) column to thepaymentstable so the agent-status earnings query can filter to settled payments only. Add an index onpayments.resourceIdandpayments.recipientAddressto support the analytics GROUP BY and agent-status sum queries. (src/db/schema.ts)