Skip to content

feat(store): store pull requests and their issue links (RIG-4034) - #1900

Open
rigel-mintaka wants to merge 1 commit into
mainfrom
compass-obs/rig-4034-t1-pr-store
Open

rigel-mintaka wants to merge 1 commit into
mainfrom
compass-obs/rig-4034-t1-pr-store

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

This PR is part of a stack containing 5 PRs:

  1. main
  2. "feat(store): store pull requests and their issue links (RIG-4034)" (this PR)
  3. feat(forge): read PR timestamps, closing refs and PR list rows (RIG-4034) #1914
  4. feat(board): show linked pull requests on board issues (RIG-4034) #1917
  5. feat(forge): link a created pull request to its issue (RIG-4034) #1926
  6. feat(ingest): hydrate pull requests onto the board (RIG-4034) #1927

Summary

This is the first build slice of the PR-to-issue linkage design (docs/designs/server/compass-issue-model-pr-linkage-amendment/design.md, Plan T1). Nothing calls the new code yet: T2 and T4 wire it in.

  • Proto: CreatePullRequestRequest.issue = 7, carrying a new PullRequestIssueLink message. Go and agent TS are regenerated.
  • Migration 0003_pull_request_links.sql:
    • Adds the pull_requests table, with the PR stored whole as JSONB.
    • Adds pull_request_issue_links (source 1 = explicit, 2 = closing ref) and its issue index.
    • Adds forge_repo_subscriptions.prs_backfilled_at.
    • Both new tables are tenant-scoped: ENABLE and FORCE RLS with the fail-closed policy and explicit grants. A set_updated_at trigger is created on pull_requests.
  • Store:
    • CreatePullRequestWithLink writes the ownership row, the PR row (an existing hydrated row wins) and the explicit link in one transaction.
    • UpsertPullRequest is guarded by recency and replaces closing refs. It returns the issues linked before and after the write.
    • PullRequestsForIssues returns PRs ordered by forge creation time. A PR attaches to an issue through a closing ref only when none of its explicit targets is on the board.
    • FallbackIssuesForTarget.
    • GitHub repos are lowercased at the store boundary. The ownership row keeps the caller's casing so the self-origin lookup still matches.

Verification

  • 10 new pgtests pass, including the 9 that the design names for T1.
  • Each mutation probe turned its test red: no lowercasing, no older-update skip, old links left out of affected, and no explicit link.
  • go test -tags pgtest ./internal/store/... ./server/... ./internal/ingest/... and the non-pgtest store suite pass.
  • golangci-lint reports no new findings; sqlc generate and buf generate are clean.

Risks

This is a new append-only migration. It adds tables, plus one nullable column on an existing table, and changes no existing rows.

Compatibility

The proto field is additive. Old clients leave issue unset.

Documentation

None. The design record already describes the change.

Refs RIG-4034

@trunk-io

trunk-io Bot commented Oct 7, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@linear-code

linear-code Bot commented Oct 7, 2026

Copy link
Copy Markdown

RIG-4034

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-obs-rig-4034-t1-pr-s.compass-eng-docs.pages.dev

Deployed from compass-obs/rig-4034-t1-pr-store at be700a4.

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Back to draft: migration 0003 collides with five open PRs ahead of it in the slot order (#1513, #1752, #1595, #1859, #1602). This PR will be rebased and renumbered when its turn comes.

Adds PullRequestIssueLink to CreatePullRequestRequest, migration 0003
(pull_requests, pull_request_issue_links, prs_backfilled_at), and the
store API the projection reads: CreatePullRequestWithLink,
UpsertPullRequest, PullRequestsForIssues and FallbackIssuesForTarget.

Spec-impact: none. Refs RIG-4034

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@rigel-mintaka
rigel-mintaka force-pushed the compass-obs/rig-4034-t1-pr-store branch from 9362ea1 to be700a4 Compare October 7, 2026 06:21
@rigel-mintaka
rigel-mintaka marked this pull request as ready for review October 7, 2026 11:09
@mattwilkinsonn
mattwilkinsonn added this pull request to stack #1947 October 8, 2026 03:17

This branch has not been deployed

No deployments
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.

2 participants