feat: reputation end-to-end — append then query#276
Conversation
Closes ezedike-evan#222 - Add lib/reputation/redact.ts with redactIntent() and hashIntent() - Strip all recipient/PII fields; store only SHA-256 intent hash - Add tests/reputation-redact.spec.ts with property-based tests - 1000-run fast-check assertions confirm zero PII fields and zero PII bytes in written row
Closes ezedike-evan#223 - Add lib/reputation/aggregate.ts with aggregate() and buildScorecards() - Computes fill rate, settle p50/p95, slippage p50/p95 per 7/30/90-day window - Empty aggregate returns "insufficient_data" state - Add app/api/reputation/[anchor]/route.ts serving all three scorecards - Add tests/reputation-aggregate.spec.ts — 19 tests, sample data produces expected aggregates
Closes ezedike-evan#224 - Add lib/reputation/db.ts — SQLite backend (better-sqlite3) with openDb/appendRow/queryRows - Add tests/reputation-e2e.spec.ts — 7 e2e tests using in-memory SQLite - Round trip: redact raw intent → appendRow → queryRows → buildScorecards → assert visible in aggregate - Covers: isolation by anchorId, window boundaries, idempotent append, PII absent from DB row
|
@Ipramking is attempting to deploy a commit to the ezedikeevan's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Ipramking 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! 🚀 |
ezedike-evan
left a comment
There was a problem hiding this comment.
Review — NOT READY TO MERGE (merge conflict + duplicate files)
Thanks for delivering the full e2e stack — the SQLite backend, PII redaction, and round-trip tests are exactly what issue #224 asked for. The implementation is clean and the test isolation (per-anchor, idempotency, window boundaries, PII absence) is comprehensive.
Blocker 1 — Merge conflict
This PR has a merge conflict against main and cannot be merged as-is.
Blocker 2 — Duplicate files from PR #275
This PR includes app/api/reputation/[anchor]/route.ts and lib/reputation/aggregate.ts (and their tests in tests/reputation-aggregate.spec.ts) which are identical to what PR #275 adds. These files will conflict on merge whether #275 goes first or second.
Required fix: Rebase this branch on top of PR #275's branch (or wait for #275 to merge into main, then rebase here). After the rebase, this PR should only carry the net-new files:
lib/reputation/db.tslib/reputation/redact.tstests/reputation-e2e.spec.tstests/reputation-redact.spec.tspackage.json/package-lock.json(forbetter-sqlite3and@types/better-sqlite3)
The duplicated route.ts, aggregate.ts, and reputation-aggregate.spec.ts should be dropped from this branch entirely.
One additional note — better-sqlite3 as devDependency
better-sqlite3 is correctly placed in devDependencies, which is right for test-only use. However, lib/reputation/db.ts sits under lib/ (a path Next.js will include in the production bundle if anything imports it). Please add a comment at the top of db.ts making clear it must never be imported from production app code (only from tests and server-side scripts), or move it to tests/helpers/ so the boundary is structural rather than documented.
Once the rebase is done and the devDependency note is addressed, this will be ready to merge immediately after #275. Please re-request review.
|
Sprint re-review — still blocked. Duplicate files with #275 (sequencing not resolved).
#276 is the intended superset (adds Branch is also CONFLICTING against Action items:
|
ezedike-evan
left a comment
There was a problem hiding this comment.
Reviewed during sprint. The implementation here is clean on its own — but main has since gained a full reputation-aggregate system (computeCorridorAggregate, computeWindowAggregate, groupByCorridor in lib/reputation/aggregate.ts, plus GET /api/reputation/[anchor]) from PRs #364, #365, and #375.
This PR brings a parallel, differently-shaped implementation of the same surface (percentile-based Scorecard/buildScorecards and its own route.ts internals). Merging as-is would leave two competing reputation modules defining the same endpoint and the same conceptual aggregates — an add/add conflict on both aggregate.ts and route.ts that can't be resolved by taking a superset.
This needs a design decision, not a conflict resolution: either (a) rebase onto main and express the percentile/SQLite work as an extension of the existing aggregate.ts API rather than a replacement, or (b) if the percentile approach is preferred, open a focused PR that migrates the existing callers. Happy to merge once it composes with the current reputation surface rather than duplicating it.
- aggregate.ts/route.ts/redact.ts: take main's versions (already contain the unified scorecard + corridor-window API from ezedike-evan#275 and ezedike-evan#274) - keep net-new db.ts (SQLite outcome store) and reputation-e2e.spec.ts - add better-sqlite3 + @types to devDependencies for db.ts - drop CODEBASE_EXPLORATION.md (removed on main, stale branch resurrected it) - fix OutcomeRow cast in e2e test
Summary
lib/reputation/db.ts— SQLite backend usingbetter-sqlite3withopenDb,appendRow,queryRowstests/reputation-e2e.spec.ts— 7 end-to-end tests using an in-memory SQLite databaseTest plan
npm test— 7 e2e tests passanchor-anot visible when queryinganchor-bintentHashinserted twice counts as 1 rowCloses #224