Skip to content

fix(mcp): submissions.get score from evaluations + FK — GHB-191#91

Merged
Gastonfoncea merged 1 commit into
mainfrom
gastonfoncea09/ghb-191-bug-submissionsget-falla-con-schema-cache-error-en-prod
May 15, 2026
Merged

fix(mcp): submissions.get score from evaluations + FK — GHB-191#91
Gastonfoncea merged 1 commit into
mainfrom
gastonfoncea09/ghb-191-bug-submissionsget-falla-con-schema-cache-error-en-prod

Conversation

@Gastonfoncea
Copy link
Copy Markdown
Collaborator

Summary

Fixes GHB-191submissions.get failing in prod with "Could not find a relationship between 'submissions' and 'issue_pda' in the schema cache".

Two bugs found, both fixed here:

  • Missing FK: submissions.issue_pda → issues.pda was never declared. Postgrest needs it for the embed bounty:issue_pda(creator). Added with NOT VALID because prod has 16 orphan auto_rejected submissions from early devnet testing (bounties that no longer exist).
  • Wrong column: the tool was selecting score from submissions, but score lives in evaluations (one row per source: stub | opus | genlayer + retries). Rewritten to fetch the most recent evaluation in a second query and return { score, score_source, rank } so agents know where the number came from.

Changes

  • packages/db/src/schema.ts — declared FK submissions.issuePda → issues.pda
  • packages/db/drizzle/0022_submissions_issue_pda_fk.sql — new migration (NOT VALID) already applied to prod manually
  • packages/db/drizzle/meta/_journal.json — entry for 0022
  • apps/mcp/lib/tools/submissions/get.ts — query rewrite (no more bogus score, added evaluations lookup, new response shape)
  • apps/mcp/tests/tools/submissions.test.ts — 4 tests covering 403, pending state, scored with source, scored without eval row

New response contract

{
  "submission": {
    "id": "...",
    "state": "scored",
    "solver": "...",
    "pr_url": "...",
    "score": 78,
    "score_source": "genlayer",
    "rank": 2,
    "opus_report_hash": "..."
  }
}
state score score_source rank
pending null null null
scored / winner / auto_rejected latest eval score source of that eval submissions.rank

Test plan

  • Typecheck (db + mcp + monorepo via pre-commit hook)
  • Tests passing (42/42 in mcp, 4 new on submissions)
  • FK applied to prod, verified via pg_constraint (convalidated=false as expected for NOT VALID)
  • After merge + Vercel deploy: smoke test against prod with curl
  • Cleanup deuda: investigate 16 orphan submissions, delete, then ALTER TABLE submissions VALIDATE CONSTRAINT submissions_issue_pda_issues_pda_fk;

🤖 Generated with Claude Code

The Supabase embed `bounty:issue_pda(creator)` failed in prod with a schema
cache error because no FK was declared between submissions.issue_pda and
issues.pda. Adding the FK with NOT VALID (16 orphan rows from early devnet
testing exempted).

The tool was also selecting `score` from submissions — that column doesn't
exist there. Score lives in evaluations (one row per source: stub | opus |
genlayer + retries). Now the tool fetches the most recent evaluation and
returns { score, score_source, rank } so agents know where the number came
from and can correlate with submission state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Gastonfoncea Gastonfoncea requested a review from tomazzi14 as a code owner May 15, 2026 22:47
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

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

Project Deployment Actions Updated (UTC)
gh-bounty-frontend Ready Ready Preview, Comment May 15, 2026 10:49pm
ghbounty-mcp Ready Ready Preview, Comment May 15, 2026 10:49pm

@Gastonfoncea Gastonfoncea merged commit 056fbfb into main May 15, 2026
5 checks passed
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