Skip to content

feat(llc): GitHub PR ↔ work item linking for LLC adapters #9625

Description

@mrveiss

Problem

When an LLC agent (running via ClaudeCodeAdapter) opens a GitHub PR, there is no way to:

  • Link that PR to the work item it was created for
  • Surface the PR status on the work item board
  • Auto-close or transition the work item when the PR merges
  • Block work item completion on PR CI status

Agents currently commit and push but the connection between code change and work item is lost.

Solution

  1. PR metadata on work items: add linked_pr_urls: list[str] field to LLCWorkItem model and migration
  2. Agent SDK method: expose POST /api/llc/work-items/{id}/link-pr endpoint accepting {pr_url, pr_number, repo}
  3. GitHub webhook: on pull_request events (opened, closed, merged), match PR body/branch name patterns (autobot-llc/{work_item_id} or Closes #llc-{id}) and auto-link
  4. Status sync: when linked PR merges → work item transitions to in_review; when PR is closed without merge → add comment to work item
  5. Board display: work item cards show linked PR status badge (open/draft/merged/closed)

Analogy

Paperclip's inheritExecutionWorkspaceFromIssueId + checkout worktree system keeps PRs tied to issues throughout the lifecycle.

Acceptance Criteria

  • Agent can call PATCH /api/llc/work-items/{id} with linked_pr_url during heartbeat
  • GitHub webhook receives PR events and auto-links PRs whose branch matches llc/{work_item_id}
  • Work item status auto-transitions on PR merge
  • Frontend shows PR status badge on work item card
  • Branch naming convention documented in autobot-llc skill

Parent

Closes part of #8207 (Phase 3 — Heartbeat + Adapters) / #8204

Activity

  1. self-assigned this
    on Jun 5, 2026
  2. mrveiss commented on Jun 8, 2026

    @mrveiss
    OwnerAuthor

    Security requirement carried over from #9657 (closed — code didn't exist yet)

    When this issue introduces a GitHub webhook handler, it must fail closed (the prior fail-open finding had no code to fix because no handler exists yet):

    • Return 503 when GITHUB_WEBHOOK_SECRET is unset — never process unauthenticated webhooks.
    • Return 401 when the x-hub-signature-256 header is missing.
    • Verify the HMAC-SHA256 signature before parsing/json.loads the body.
    • Add tests covering all three failure modes.
  3. github-actions commented on Jun 13, 2026

    @github-actions
    Contributor

    PR #10061 (merged to Dev_new_gui) references this issue with a close keyword.

    feat(llc): GitHub PR ↔ work-item linking for LLC adapters (#9625)

    If this issue is fully resolved, close it manually. If work remains, no action is needed.

  4. mrveiss commented on Jun 13, 2026

    @mrveiss
    OwnerAuthor

    ✅ Closed — implementation + integration verified, merged to Dev_new_gui.

    Merge commit: fd774e20 (PR #10061, squashed)

    What shipped

    • linked_pr_urls JSONB column on llc_work_items + migration 20260612_056_llc_pr_linking (revises head 20260612_055)
    • POST /api/llc/webhooks/github — fail-closed webhook (503 without GITHUB_WEBHOOK_SECRET, 401 on bad HMAC-SHA256), resolves the work item from branch (llc/{id}, autobot-llc/{id}, llc-{id}) or PR body (Closes #llc-{id}), validates the PR URL against the webhook repo, transitions to in_review on merge, comments on close-without-merge
    • POST /api/llc/work-items/{id}/link-pr — IDOR-guarded agent endpoint with the same strict URL validation
    • 🔗 PR badge on Kanban work-item cards
    • Docs: docs/llc/github-pr-integration.md (branch convention + webhook setup), linked from docs/llc/_index.md; live autobot-llc skill updated with the branch convention + link-pr endpoint

    Acceptance criteria

    • Agent can link a PR — POST /api/llc/work-items/{id}/link-pr (and PATCH already accepted arbitrary fields)
    • GitHub webhook auto-links PRs whose branch matches llc/{work_item_id} (and autobot-llc/, llc-, plus PR-body Closes #llc-{id})
    • Work item status auto-transitions to in_review on PR merge
    • Frontend shows a PR status badge on the work item card
    • Branch naming convention documented in the autobot-llc skill + docs/llc/

    Integration: llc/api/__init__.py:54 mounts github_webhooks_router; llc/api/work_items.py:79 consumes validate_github_pr_url; _item_to_dict exposes linked_pr_urls.

    Verification: 36 new tests in test_github_webhooks.py (all pass); CI green on smoke-test, code-quality, migration-matrix, llc-e2e, llc-wiring-audit, api-wiring, startup-import-smoke, hardened-smoke-test, duplication-guard.

    Note: ported and hardened prior unmerged work from local branch issue-MVA-3716-pr-linking (never PR'd, 1540 commits stale), fixing its gaps — the original commit referenced the model column and router registration but never actually added them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions