Skip to content

fix(web): /agent-rank H2H 1:1 — comparison logs, shared row mapper, re-rank companion carry - #75

Merged
BIBOYANG425 merged 1 commit into
mainfrom
fix/agent-rank-h2h-log-parity
Jul 13, 2026
Merged

fix(web): /agent-rank H2H 1:1 — comparison logs, shared row mapper, re-rank companion carry#75
BIBOYANG425 merged 1 commit into
mainfrom
fix/agent-rank-h2h-log-parity

Conversation

@BIBOYANG425

@BIBOYANG425 BIBOYANG425 commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Why

Owner: "for journal intake, I still feel like the H2H comparison is still incomplete and stay true to the H2H comparison flow from the webapp, should be replicate 1:1."

PR #70 unified the placement engine (both surfaces run one createCeremonyDriver / RankingSession), so the comparison sequence was already identical. This PR closes the three remaining measurable deltas between the /agent-rank in-iMessage ceremony and the main webapp movie flow.

What

  1. Comparison logs — the webapp persists one comparison_logs row per H2H choice (RankingAppPage.handleCompareLog); the agent ceremony dropped them. AgentRankPage now passes onCompare to RankingFlowModal and writes the exact same column set through the tokened client (RLS verified: insert-own policy, auth.uid() = user_id — the fragment JWT is a real user token).

  2. Row mapper fork — the page kept a local copy of rowToRankedItem that dropped watched_with_user_ids. Because placement upserts watched_with_user_ids: placed.watchedWithUserIds ?? [], every re-rank through the card silently wiped the user's companions. The mapper now lives in services/agentRankRows.ts (exact webapp mirror, unit-tested) and the page consumes it.

  3. Re-rank seed — the ceremony seed for an already-ranked film now carries existing.watchedWithUserIds so the modal restores and re-persists them.

Known intentional differences (not bugs)

  • The card's notes step hides the "watched with" friend picker — there is no app session under the fragment JWT, and FriendTagInput's search rides the module client. Companions are preserved (per feat: remove theater features, add comparison ranking UI, scaffold Da… #2), just not editable in-card.
  • Post-placement, the webapp opens the journal sheet; the card ends on "go tell chris" — the verdict beat lives in the iMessage thread by design.

Tests

  • agentRankCeremonyParity.test.ts extended: per-scenario comparison-log parity (same choices → identical persisted rows on both surfaces, column-for-column), structural checks that the page wires onCompare with the webapp's column set and the re-rank seed carries companions.
  • New agentRankRows.test.ts: mapper field parity incl. the watched_with_user_ids wipe regression, empty-array normalization, bracket fallback, and a no-forked-mapper structural check.
  • Full suite: 46 files / 728 tests green.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Comparison activity is now recorded during agent ranking sessions.
    • Re-ranking preserves existing companion information.
  • Bug Fixes

    • Ranking data now consistently retains optional details, including viewing companions.
    • Agent ranking behavior and comparison records are aligned across supported surfaces.
  • Tests

    • Expanded coverage verifies ranking parity, comparison logs, field mapping, and re-ranking data preservation.

…e-rank companion carry

Three remaining deltas between the /agent-rank in-iMessage ceremony and the
main webapp movie flow, closed so the card's H2H replicates the webapp 1:1:

1. Comparison logs: the webapp persists one comparison_logs row per H2H
   choice (RankingAppPage.handleCompareLog); the agent ceremony dropped them.
   AgentRankPage now passes onCompare to RankingFlowModal and writes the
   exact same column set through the tokened client (RLS: insert-own,
   auth.uid() = user_id — the fragment JWT is a real user token).

2. Row mapper fork: the page kept a local copy of rowToRankedItem that
   dropped watched_with_user_ids. Because placement upserts
   watched_with_user_ids = placed.watchedWithUserIds or [], every re-rank
   through the card silently WIPED the user's companions. The mapper now
   lives in services/agentRankRows (exact webapp mirror, unit-tested) and the
   page consumes it.

3. Re-rank seed: the ceremony seed for an already-ranked film now carries
   existing.watchedWithUserIds so the modal restores and re-persists them.

Parity suite extended: per-scenario comparison-LOG parity (same choices lead
to identical persisted rows on both surfaces), structural checks that the
page wires onCompare with the webapp's column set and that the re-rank seed
carries companions, plus mapper field-parity tests (wipe regression locked).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
movie-list Ready Ready Preview, Comment Jul 13, 2026 7:53pm
movie-list-mvp Ready Ready Preview, Comment Jul 13, 2026 7:53pm

@supabase

supabase Bot commented Jul 13, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project emulyralduiitxuigboj because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f3df4baf-3823-4e2b-8039-231c2c39ae38

📥 Commits

Reviewing files that changed from the base of the PR and between 6a2a67d and 161d8e7.

📒 Files selected for processing (4)
  • pages/AgentRankPage.tsx
  • services/__tests__/agentRankCeremonyParity.test.ts
  • services/__tests__/agentRankRows.test.ts
  • services/agentRankRows.ts

📝 Walkthrough

Walkthrough

AgentRankPage now uses a shared row mapper, records H2H comparison choices, preserves companion IDs during reranking, and connects logging to RankingFlowModal. Tests validate mapper normalization, page wiring, and parity of complete comparison logs.

Changes

Agent rank parity

Layer / File(s) Summary
Shared ranking-row mapper
services/agentRankRows.ts
Adds rowToRankedItem with field normalization, type and bracket fallbacks, and conditional watchedWithUserIds mapping.
Agent rank logging integration
pages/AgentRankPage.tsx
Uses the shared mapper, inserts comparison-log rows through Supabase, preserves companion IDs during reranking, and wires onCompare into RankingFlowModal.
Parity and mapper validation
services/__tests__/agentRankCeremonyParity.test.ts, services/__tests__/agentRankRows.test.ts
Validates complete comparison-log parity, mapper defaults, shared-mapper usage, comparison-log persistence, and reranking seed preservation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RankingFlowModal
  participant AgentRankPage
  participant comparison_logs
  RankingFlowModal->>AgentRankPage: onCompare(log)
  AgentRankPage->>comparison_logs: insert comparison choice
  comparison_logs-->>AgentRankPage: success or error
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main /agent-rank H2H changes: comparison logging, shared row mapping, and companion carry on re-rank.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agent-rank-h2h-log-parity

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

Comment @coderabbitai help to get the list of available commands.

@BIBOYANG425
BIBOYANG425 merged commit b46b460 into main Jul 13, 2026
6 checks passed
@BIBOYANG425
BIBOYANG425 deleted the fix/agent-rank-h2h-log-parity branch July 13, 2026 19:59
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.

1 participant