Repository navigation
routes: dispute management endpoints - #72
Merged
joelpeace48-cell merged 1 commit intoAug 25, 2026
Merged
Conversation
Adds the dispute lifecycle API (src/routes/disputes), registered under the v1 prefix: - POST /disputes — raise a dispute against a settlement with a reason and optional evidence. Evidence content is stored alongside a sha256 commitment (contentHash) — the value that would go on-chain — kept as a separate field from day one so wiring in real off-chain storage and an on-chain commit call later doesn't change the data model. - GET /disputes — role-scoped: buyers/sellers only see disputes they're a party to, adjudicators see everything. - POST /disputes/:id/evidence — either original party may add evidence, rejected once the dispute's window has closed (server-enforced, not just left to the contract). - POST /disputes/:id/resolve — adjudicator-only, records the outcome. - A notification is logged on every lifecycle transition (raised, evidence-added, resolved). Role and identity are read from x-role/x-user-id headers for now, since the repo has no auth/session layer yet to hang this off of — the role-scoping and window-enforcement logic itself is real and tested per role. Tests cover the full lifecycle, cross-role access denial, adjudicator-only resolution, window enforcement, and unauthenticated rejection. Closes FinesseStudioLab#58.
5 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.
Problem
The dispute flow is the protocol's differentiator, and there was no API surface for it: a buyer couldn't raise a dispute, an adjudicator couldn't see the queue, and neither party could attach evidence.
What this adds
New module
src/routes/disputes/, registered under thev1prefix:POST /disputes— raise a dispute against a settlement with a reason and optional evidence.GET /disputes— role-scoped: buyers/sellers only see disputes they're a party to; adjudicators see everything.POST /disputes/:id/evidence— either original party may add evidence, rejected once the dispute's window has closed. The deadline is enforced server-side (not left only to the contract).POST /disputes/:id/resolve— adjudicator-only, records the outcome.Evidence handling follows the same principle as inference payloads elsewhere in this service: each evidence item is stored with a sha256
contentHashkept as a field separate from the rawcontentfrom day one, so wiring in real off-chain storage plus an on-chain commit call later is a swap of one function rather than a data-model change.Role and identity are currently read from
x-role/x-user-idheaders, since the repo doesn't yet have an auth/session layer to hang this off of — the role-scoping and window-enforcement logic itself is real and fully tested per role, and swapping the header read for a real identity middleware later is a one-function change.Testing
src/routes/disputes/index.test.tsuses Fastify'sinjectto cover the full lifecycle:npm run lint,npm run build,npm test, andnpm audit --audit-level=highare all clean on this branch.Scope note
This PR touches
src/routes/v1/index.ts(registering the new plugin) in addition to the newsrc/routes/disputes/**files. No other PR open against this issue tracker (#44,#54) touches that file orpackage.json, so this should merge independently of the other two regardless of order.Closes #58.