Skip to content

docs(proposals): dos-me migration for criteria ratings, pros and cons (p2) - #1549

Merged
JOY (JOY) merged 5 commits into
devfrom
docs/1543-criteria-migration
Oct 31, 2026
Merged

JOY (JOY) merged 5 commits into
devfrom
docs/1543-criteria-migration

Conversation

@JOY

@JOY JOY (JOY) commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1543

Phase P2 of #1531, decision D10: the DOS-Me migration for JOY to review and apply. Nothing is applied from DOS/Rate: no DDL, no data writes. The runbook is Docs/Proposals/2026-10-31-dos-me-criteria-ratings.md.

Files for JOY

  • Docs/Proposals/2026-10-31-dos-me-criteria-ratings.sql: the migration. It is idempotent and runs in two transactions: first the schema change, then CHECK validation and a backfill of the reviewed masters.
  • Docs/Proposals/2026-10-31-dos-me-criteria-ratings-verify.sql: V1 to V6 must return 0; V7 is for information.
  • Docs/Proposals/2026-10-31-dos-me-criteria-ratings-rollback.sql: one transaction, re-runnable, safe before or after M1+M2.
  • scripts/test-criteria-ratings-proposal.mjs: a Docker replay, added to CI.

What the migration does

  • rate.reviews: adds rating_exact numeric(2,1), verdict, criteria_version, value_score and value_breakdown.
  • rate.review_points and rate.product_points: RLS on, public read. The service role writes both; rate_worker writes product_points only.
  • rate.master_products:
    • rating_score: Bayesian with k = 3 and mu = 4.2, each weight capped at 3, using rating_exact when set. This is the same formula as the web.
    • rating_weight_sum.
    • criteria_scores: a criterion appears only with at least 3 reviews and a weight sum of at least 1.5 (D9). Keys must look like the shared-data keys.
  • Triggers, not wrappers: no existing function is replaced or renamed. Triggers keep the new columns current:
    • on rate.reviews and rate.review_flags, once per statement, when a rating input changes;
    • on rate.master_products, when user_rating_weighted or authentic_review_count changes.
  • Which reviews count:
    • Without M1+M2: the master's own listings.
    • Once M1+M2 is in: the whole Item, including listings with no variant. The result is written to every variant in id order with SKIP LOCKED, as refresh_item_rating does.
  • Locks: the CHECKs are added NOT VALID and validated after the schema change commits.

Replay (Docker): passes locally

  1. Reference stack: apply twice. Check:

    • the ratings: 4.36 overall and criterion display 4.10 from 3 writers;
    • the triggers: an exact star, a flag that takes a review out of the rating and back, the weight cap;
    • the grants: anon, authenticated and worker are refused.

    Then roll back twice.

  2. Apply before M0 and M1+M2. The two sizes become one Item, and both variants show 4.10 with display 3.80. Then check, in order:

    • a vote on the Item path;
    • a review on an Item listing with no variant;
    • a rewrite that changes nothing;
    • a delete.
  3. M1+M2 rollback with this migration in place. V6 flags the stale variant, and re-running the backfill fixes it.

  4. M1+M2 again, then this migration on top, then the rollback.

Review

  • Round 1 (fresh context):

    • The rename-and-wrap of the refresh was unsafe when M1+M2 or its rollback replaces the function.
    • The Item and vote paths bypassed the wrapper.
    • The backfill ran under ACCESS EXCLUSIVE.
    • The verify checks were weak, and criteria keys were not checked.

    Fixed in f75dbcb by moving to triggers.

  • Round 2:

    • Sibling variants could deadlock.
    • Listings with no variant were not refreshed.
    • Unchanged rewrites fired a refresh.
    • The CHECK scans ran under the lock.

    Fixed in 4b12a3b.

  • Known limits (in the runbook):

    • Bulk flag imports refresh once per flag row, because of the existing trg_review_flags_sync_weight.
    • Two concurrent writers can leave older values until the next write, as the live refresh does today.
    • Deleting a listing together with its reviews leaves the values in place until the next write.

    V6 shows all three.

🤖 Generated with Claude Code

… (p2)

Phase P2 of #1531 (D2, D3, D9, D10), for JOY to review and apply through
DOS-Me; nothing is applied from DOS/Rate. New review columns (exact
star, verdict, criteria version, value score), rate.review_points and
rate.product_points with RLS, and the master columns rating_score
(Bayesian, k 3, mu 4.2), rating_weight_sum and criteria_scores (D9
thresholds). The live refresh_master_product_rating is renamed to a
base and wrapped, so every caller also runs the new extras function.
Verify and rollback files, and a Docker replay in CI that applies it
on the reference stack and after M0 and M1+M2.

Refs #1543

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
rate Ready Ready Preview Oct 31, 2026 7:10pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 112fca7f-86a1-4d74-ab63-6c7bcc84606c
Commits

Reviewing files that changed from the base of the PR and between 3648fb0 and 2194365.

Files selected for processing: 7
  • .github/workflows/ci.yml
  • .gitignore
  • Docs/Proposals/2026-10-31-dos-me-criteria-ratings-rollback.sql
  • Docs/Proposals/2026-10-31-dos-me-criteria-ratings-verify.sql
  • Docs/Proposals/2026-10-31-dos-me-criteria-ratings.md
  • Docs/Proposals/2026-10-31-dos-me-criteria-ratings.sql
  • scripts/test-criteria-ratings-proposal.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added ci CI/CD workflows and pipelines docs Documentation changes labels Oct 31, 2026
dos[bot]
dos Bot approved these changes Oct 31, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (6 eligible files · 34,783 chars · 2 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base 3648fb0 / head f6bce9e.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

…apper

Review of #1549. Renaming refresh_master_product_rating to a base and
wrapping it broke when M1+M2 or its rollback replaced the function, and
the Item path (refresh_item_rating, votes) bypassed it. The migration
now replaces no function: triggers on reviews, review_flags and
master_products refresh the new columns, scoped like the live refresh
(per master, or the whole Item once M1+M2 is in). The schema change and
the backfill commit separately; criteria keys must look like the
shared-data keys; V3 checks PUBLIC and authenticated too, V4 the
triggers, and V6 recomputes every master. The replay applies it before
and after M1+M2 and through the M1+M2 rollback.

Refs #1543

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dos[bot]
dos Bot approved these changes Oct 31, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (6 eligible files · 49,553 chars · 3 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base 3648fb0 / head f75dbcb.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

…ia ratings

Round 2 review of #1549. Variants of an Item are written in id order
with SKIP LOCKED, as refresh_item_rating does, so two refreshes of
sibling variants never deadlock. Triggers resolve masters from
listings, so a review on an Item listing with no variant refreshes the
Item, and each Item is refreshed once per statement. Only changed
rating inputs fire a refresh. The CHECKs are added NOT VALID and
validated in the backfill transaction; V1 covers product_points. The
replay adds a no-variant review, an unchanged rewrite and its delete;
the runbook lists bulk flag imports, concurrent writers and listing
deletes as known limits.

Refs #1543

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Secret scan job refuses tracked files that match .gitignore. The
three P2 proposal files get the same named exceptions as the earlier
DOS-Me proposals.

Refs #1543

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dos[bot]
dos Bot approved these changes Oct 31, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (6 eligible files · 55,512 chars · 3 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base 3648fb0 / head 4b12a3b.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

dos[bot]
dos Bot approved these changes Oct 31, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (7 eligible files · 56,035 chars · 2 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base 3648fb0 / head 11194fc.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

The web rounded the stored 2-decimal score again for display, so 4.249
showed 4.3. rating_score is numeric(4,3) and the criterion scores keep 3
decimals too; pages round once, to 1 decimal. Replay expectations follow.

Refs #1543

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dos[bot]
dos Bot approved these changes Oct 31, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (7 eligible files · 56,303 chars · 3 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base 3648fb0 / head 2194365.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

@JOY
JOY (JOY) merged commit 1a9cd84 into dev Oct 31, 2026
15 checks passed
@JOY
JOY (JOY) deleted the docs/1543-criteria-migration branch October 31, 2026 19:19

This branch was successfully deployed

1 active deployment
Preview — 21943656 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI/CD workflows and pipelines docs Documentation changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant