镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(github): link pull requests from stories started without a repository - #515

Open
TheGr8OK wants to merge 2 commits into
theam:mainfrom
TheGr8OK:fix/manual-story-pr-link
Open

TheGr8OK wants to merge 2 commits into
theam:mainfrom
TheGr8OK:fix/manual-story-pr-link

Conversation

@TheGr8OK

Copy link
Copy Markdown

What changes

Stories started from the UI, MCP or API now get their agent's pull request linked. The story shows the PR,
its reviews and its CI. PR-triggered agents continue in that story, and a merge marks it done.

Why

Typed stories are stored with repository_id = NULL, and the rest of the code reads NULL as "the
primary repository" (stories/branch.ts). But GithubMirrorService.linkedStory() and
GithubAgentTriggerService.findLinkedStory() filter on stories.repository_id = <repo>, so NULL never
matches. The PR is mirrored, and its head SHA and branch match the story exactly, but it never gets linked.

Fix:

  • Extract the existing NULL-means-primary rule into storyRepositoryScope() and use it in those lookups.
    PRs on related repositories still only match their own stories.
  • When a trigger continues a linked story, pass that story's own repositoryId to start(), so its
    identity lookup still finds the story.

No migration and no API change. I tried writing the primary repository onto typed stories instead, but then
repository disconnect returns 409 repository_in_use for any project that has run one.

Verification

Two new tests (real Postgres). Both fail on main (7f4ddac) and pass here:

  • story-backlog-routes: a story started via POST /workspace-stories gets its PR linked from a
    pull_request webhook. A related repository's PR with the same branch and commit does not link.
  • agent-automation: a typed story's PR runs pr-reviewer in that story, not in a new
    pull-request:N story, and the merge marks it done.

Also: API suite 1150/1150, DB tests 7/7, lint and typecheck clean. I checked it on a self-hosted
instance: a GitHub sync linked a typed story's existing PR.

  • pnpm verify passes locally
  • Behaviour verified beyond the test suite (self-hosted instance)
  • Documentation updated, or no user-facing change

Follow-up, unrelated: reconciliation fails with the documented App permissions (#514).

🤖 Generated with Claude Code

TheGr8OK and others added 2 commits October 28, 2026 20:07
…tory

Stories started from the UI, MCP or API are stored without a repository,
which the rest of Facility reads as the project's primary. The GitHub
mirror and agent triggers matched pull requests on an exact repository id,
so these stories never linked the PR their agent opened, never saw its
reviews or CI, and were not completed on merge.

Share the existing NULL-means-primary rule as storyRepositoryScope() and
use it for the mirror and trigger PR lookups. A trigger that continues a
linked story keeps that story's own repository identity.

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

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.

1 participant