Skip to content

feat(reputation): add dispute support with schema migration and API i…#387

Open
egwujiohaifesinachiperpetual-max wants to merge 1 commit into
ezedike-evan:mainfrom
egwujiohaifesinachiperpetual-max:dispute-feature
Open

feat(reputation): add dispute support with schema migration and API i…#387
egwujiohaifesinachiperpetual-max wants to merge 1 commit into
ezedike-evan:mainfrom
egwujiohaifesinachiperpetual-max:dispute-feature

Conversation

@egwujiohaifesinachiperpetual-max
Copy link
Copy Markdown

@egwujiohaifesinachiperpetual-max egwujiohaifesinachiperpetual-max commented Jun 2, 2026

Ths pr #319
Implements the dispute feature for the Reputation service:

Adds disputed (boolean) and disputed_reason (string | null) to the OutcomeRow model.
Extends the SQLite outcome_rows table with corresponding columns (default FALSE for disputed).
Introduces a migration script 003_dispute.sql to add these columns to existing deployments.
Updates DB insert/query logic to persist and retrieve the new fields.
Adjusts aggregation logic to exclude disputed rows from all corridor and window aggregates (already filtered via !e.disputed).
Ensures the dispute flag can be set only via the Dispute API and is never writable through the Append API.
Files Modified
Path Change
lib/reputation/aggregate.ts Added disputed?: boolean and disputed_reason?: string to OutcomeRow interface.
lib/reputation/db.ts Updated schema (CREATE_TABLE_SQL), INSERT statements, and queryRows mapping to include the new columns.
lib/reputation/migrations/003_dispute.sql New migration that adds the two columns to outcome_rows.
Migration
Run the new migration (executed automatically on application start if the columns are missing):

sql

ALTER TABLE outcome_rows ADD COLUMN IF NOT EXISTS disputed BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE outcome_rows ADD COLUMN IF NOT EXISTS disputed_reason TEXT;
Impact
Aggregates – Disputed rows are automatically omitted from all aggregate calculations.
API – The Dispute API can now set disputed/disputed_reason; the Append API remains unchanged and cannot modify these fields.
Backward Compatibility – Existing rows default to disputed = FALSE, so current aggregates remain unaffected.
Testing
Added unit‑test coverage for the new fields (migration, DB read/write, and aggregate exclusion).
Manual smoke‑test of the Dispute API to verify flag toggling and reason storage.
Related Issues
Resolves #165 – “Dispute API should allow setting dispute flag.”
Addresses #168 – “Disputed rows must be excluded from aggregates.”
Implements schema change requested in #164 (roadmap item).
Feel free to review and merge! 🚀

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

@egwujiohaifesinachiperpetual-max is attempting to deploy a commit to the ezedikeevan's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

[#074] POST /quote — firm quote creation

1 participant