Repository navigation
Conversation
- Add ScoreSubmission (queued submission keyed by idempotency key) and
ScoreRecord (final stored result) entities
- Add ScoreConflict to hold field-level mismatches for review, and
ScoreReconciliationReport with a documented per-run report format
- ScoreReconciliationService:
- hourly cron plus manual run, never overlapping
- checks submissions between now - lookback and now - grace, in
batches, against records by idempotency key
- restores missing records from the queue and confirms the
submission; handles a record written concurrently
- flags mismatches as conflicts and marks the record needsReview
without changing its values; no duplicate open conflicts
- one failing submission is counted and does not stop the run
- saves a report every run, including failed runs, with capped
key lists in details
- conflict resolution clears the review flag when none stay open
- Admin-only controller for run, reports and conflicts
- README describing the run, report format, endpoints and settings
- Register ScoreReconciliationModule in AppModule
- 24 unit tests
Closes MindFlowInteractive#478
|
@AwesomeuncleB 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! 🚀 |
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 #478
What does this PR do?
Adds a scheduled job that compares queued score submissions with the stored score records. It restores missing records, flags mismatches for review without overwriting anything, and saves a report for every run.
Why?
Closes #478
Type of change
How was it tested?
npx jest src/score-reconciliation: 24 tests pass.What's included
New module
src/score-reconciliation/(full details in itsREADME.md):score_submissions(queued submission keyed by idempotency key, with statuspending/confirmed/failed) andscore_records(the final stored result, one per idempotency key). Stage 1 (Score Submission Queue with Retry #477) has not landed, so this PR adds the queue table in the shape the reconciliation job needs. The submission queue can write to it directly.score_reconciliation_reports): one row per run with the window, counts (checked,matched,restored,conflictsFlagged,alreadyFlagged,errors), capped key lists indetails, and afailureReasonfor failed runs.now - lookbacktonow - grace, so in-flight retries are left alone.score_reconciliation_conflicts) with field-level differences and marks the recordneedsReview. Its values are never overwritten, and a key never gets a second open conflict.Settings (all optional):
SCORE_RECONCILIATION_ENABLED,SCORE_RECONCILIATION_LOOKBACK_HOURS(72),SCORE_RECONCILIATION_GRACE_MINUTES(10),SCORE_RECONCILIATION_BATCH_SIZE(500)./score-reconciliation/run/score-reconciliation/reports/score-reconciliation/reports/:reportId/score-reconciliation/conflicts?status=open/score-reconciliation/conflicts/:conflictId/resolveAcceptance criteria
Checklist
npm run lintpasses for the new filesnpm run format:checkpassesnpm run typecheck: no new errors (mainalready has 149 existing errors; this PR adds none)npm testpasses for the new suiteCONTRIBUTING.mdRisk & rollout
Additive only. The job does nothing until submissions exist in
score_submissions, and it can be turned off withSCORE_RECONCILIATION_ENABLED=false. Production needs a migration for the new tables.Closes #478