Repository navigation
Conversation
…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>
2 of 3 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 "theprimary repository" (
stories/branch.ts). ButGithubMirrorService.linkedStory()andGithubAgentTriggerService.findLinkedStory()filter onstories.repository_id = <repo>, so NULL nevermatches. The PR is mirrored, and its head SHA and branch match the story exactly, but it never gets linked.
Fix:
storyRepositoryScope()and use it in those lookups.PRs on related repositories still only match their own stories.
repositoryIdtostart(), so itsidentity 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_usefor 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 viaPOST /workspace-storiesgets its PR linked from apull_requestwebhook. A related repository's PR with the same branch and commit does not link.agent-automation: a typed story's PR runspr-reviewerin that story, not in a newpull-request:Nstory, 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 verifypasses locallyFollow-up, unrelated: reconciliation fails with the documented App permissions (#514).
🤖 Generated with Claude Code