feat: add GET /api/internal/reconciliation/diff/:streamId (#593)#805
Merged
greatest0fallt1me merged 3 commits intoJun 29, 2026
Merged
Conversation
Implements Streampay-Org#593. Returns a structured field-by-field diff between DB and on-chain state for a single stream. - GET /api/internal/reconciliation/diff/:id - HMAC-signed internal service auth (concealed 404 on failure) - Allowed services: ops-automation, reconciliation-worker - Catches SorobanError from fetchStream (treat as no on-chain record) - Structured JSON logging with correlation IDs - 10 tests covering auth guard, happy paths, and error paths - No regressions (pre-existing: 40 suites / 138 tests failing)
|
@Awointa 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! 🚀 |
4 tasks
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 #593
Summary
Adds a focused read endpoint that returns a structured field-by-field diff
between the DB record and on-chain state for a single stream — without
triggering a full reconciliation run.
Changes
app/api/internal/reconciliation/diff/[id]/route.ts(new) — GET handlerapp/api/internal/reconciliation/diff/[id]/route.test.ts(new) — 10 testsCHANGELOG.md— [Unreleased] entryEndpoint
GET /api/internal/reconciliation/diff/:streamIdAuth: HMAC-signed service-to-service headers (
ops-automationorreconciliation-worker). Route is concealed behind404on any auth failure.200 response:
{ "data": { "streamId": "stream_2", "checkedAt": "2026-06-29T08:38:45Z", "inSync": false, "diffs": [ { "field": "released_amount", "dbValue": "1000000000", "onChainValue": "1100000000", "toleranceApplied": false } ], "db": { "id": "stream_2", "recipient_address": "…", "status": "ACTIVE", … }, "onChain": { "id": "stream_2", "recipient_address": "…", "status": "ACTIVE", … } }, "meta": { "auth": { "keyId": "current", "timestamp": "…" } } } 404 — stream unknown to both DB and on-chain, or any auth failure. Testing 10 tests covering: - Auth guard: no headers, invalid signature, unknown key, disallowed service - Happy path: in-sync stream, stream with diff, stream with no on-chain record, checkedAt timestamp, service name reflection - Error path: unknown stream ID Tests: 10 passed, 10 total — 0 regressions against baseline (pre-existing: 40 suites / 138 tests) Notes - onChainClient.fetchStream throws SorobanError for missing streams; the route catches it and treats it as onChain: null rather than propagating. - Follows the same auth/logging/error-envelope patterns as POST /api/internal/reconciliation.