feat: add pricing quality controls
Quality / test (push) Canceled after 0s

Add robust outlier detection, stale valuation metadata, and audited seller-scoped market-value overrides with migration and tests.
This commit is contained in:
2026-09-09 01:19:51 -04:00
parent ba88814af0
commit 75c0e89511
12 changed files with 141 additions and 3 deletions
@@ -10,6 +10,9 @@ test('records an owned pricing observation and calculates a valuation', async ()
assert.equal(sellerId, 'seller-1');
return { status: 'CREATED', observation };
},
async markOutliersForSeller() {
return { status: 'UPDATED' };
},
async calculateForSeller() {
return { status: 'CALCULATED', valuation: { valueMinor: 2500 }, observations: [] };
},
@@ -23,4 +26,12 @@ test('records an owned pricing observation and calculates a valuation', async ()
assert.equal(observation.priceMinor, 2500);
const valuation = await service.calculate({ sellerId: 'seller-1', inventoryItemId: 'inventory-1' });
assert.equal(valuation.valuation.valueMinor, 2500);
});
test('requires a reason for an audited market-value override', async () => {
const service = createPricingService({ pricingRepository: { async createOverride() { throw new Error('should not run'); } } });
await assert.rejects(
() => service.override({ sellerId: 'seller-1', actorUserId: 'user-1', inventoryItemId: 'inventory-1', valueMinor: 2000, reason: 'x' }),
(error) => error.code === 'OVERRIDE_REASON_REQUIRED' && error.statusCode === 400,
);
});