Skip to content

#451 step 4: Move thread issue links onto upstream thread.issues #455

Closed

Description

@tannerpolley

Part of #451. Step 4 of 7, after step 3. Plan: #451 (comment) ("Thread links: the data move" and "Order", item 4).

Managed claims write a thread.issues[] link in the same commit as the claim. A one-time command backfill at server start, keyed so that repeats do nothing, moves issue_thread_links rows and claims without links. Then delete the table reads, issues.unlink and the refresh stream. linkedIssue stays as the claim record.

Done: server tests cover a repeated backfill, a deleted thread, a failed title read, and claim plus link in one commit.

Activity

  1. tannerpolley commented on Nov 18, 2026

    @tannerpolley
    OwnerAuthor

    T3 Code status: Done

    Issue: #455 #451 step 4: Move thread issue links onto upstream thread.issues

    Thread: thread:delegated-task:command%3Amcp%3A53eed4d4-49de-4205-ba6f-a35a0b15b7c9%3Adelegate-task%3Aissue-455-451-step4-2026-11-18

    Model: claude-opus-5-5

    Branch: issue-455-451-step-4-move-thread-issue-links-onto

    Updated: 2026-11-18T02:13:22.332Z

  2. tannerpolley commented on Nov 18, 2026

    @tannerpolley
    OwnerAuthor

    T3 Code closeout: done

    Issue: #455 #451 step 4: Move thread issue links onto upstream thread.issues
    Thread: thread:delegated-task:command%3Amcp%3A53eed4d4-49de-4205-ba6f-a35a0b15b7c9%3Adelegate-task%3Aissue-455-451-step4-2026-11-18
    Model: claude-opus-5-5
    Branch: issue-455-451-step-4-move-thread-issue-links-onto
    Completed: 2026-11-18T01:47:45.707Z

    Issue #455 is implemented in draft PR #474. It closes #455, references #451, and is not merged.

    What changed

    • Claims carry their link. When the planner (IssueWorkCommands.claimFields) creates a claimed thread, the same thread.created event now holds both linkedIssue and its thread.issues[] entry. This covers delegated workers and thread.create claims. Reviewers, checkers, writers and other children that take an issue without claiming it now link through upstream's ThreadIssueService after reading the issue title.
    • Startup backfill. apps/server/src/issues/IssueLinkBackfill.ts runs once after server activation. It follows the plan: field mapping, the claim's title when it's the same issue, otherwise one upstream IssueService.detail read per distinct issue, four at a time. Each thread.issue.link command gets an id built from the thread and the issue. A failed title read keeps the row for the next start, and rows for deleted or missing threads are dropped. Each row is deleted after its command commits.
    • One addition beyond the plan. The backfill skips a claim whose thread has ever had a thread.issue-synced event. A claim made now carries its link from the start, so a missing link means someone removed it. Without this check, the next start would put that link back.
    • Removed: the table reads in IssueLinks.enrich, IssueLinks.link and its refresh stream, and issues.unlink (contract, handler, scope, client command). Also gone: the fork's "Unlink from this thread" menu item and the canUnlink flag, because upstream's issue panel already toggles these links. The table is out of the purge list, and the seed script now writes claim links instead of table rows.
    • linkedIssue stays the claim record, and a claim still counts as live work after its link is removed.

    Decision for you: issues.subscribeLinkRefreshes is still there. I removed only the table's refresh source. That stream also drives the roadmap's live-work refresh (runs, requests, background tasks), and the roadmap still reads through fork code until step 5. Deleting it now would leave live work stale on the roadmap until its 5-minute poll. I recommend retiring it in step 5; the PR says so.

    Tests

    • New IssueLinkBackfill.test.ts, using a real orchestrator on an in-memory database. It covers:

      • a repeated run adding no events;
      • deleted and missing threads having their rows dropped;
      • a failed title read keeping its row, with a later run linking it;
      • a removed claim link staying removed;
      • a leftover row reusing its earlier command result and adding no event.

      This is a new file because no existing test covered the new module.

    • IssueReviewDelegation.fork.test.ts checks that a worker's thread.created event carries the claim and its link together.

    • Other existing tests now seed links in thread.issues[]. The focused runs all pass (57 tests in the last run).

    vp run check:changed

    All testing used synthetic databases; ~/.t3/userdata was never touched. Nothing in the diff touches completion delivery. I stopped two duplicate type-check jobs of mine by PID after confirming their working directory was this worktree.

    PR #474, head 3a5ee87, checks and reviews: none reported yet (draft, just opened).

  3. tannerpolley commented on Nov 18, 2026

    @tannerpolley
    OwnerAuthor

    T3 Code closeout: done

    Issue: #455 #451 step 4: Move thread issue links onto upstream thread.issues
    Thread: thread:delegated-task:command%3Amcp%3A53eed4d4-49de-4205-ba6f-a35a0b15b7c9%3Adelegate-task%3Aissue-455-451-step4-2026-11-18
    Model: claude-opus-5-5
    Branch: issue-455-451-step-4-move-thread-issue-links-onto
    Completed: 2026-11-18T02:13:22.718Z

    I fixed all four items from the Checker's review. Main is merged in (clean, no rebase), the fixes are pushed, and the PR body is updated.

    1. Startup cost: the backfill now checks "already linked" first and reads event history only for claims that are still unlinked. Its reads use the reader connection. On a synthetic database with 2.6M events and every claim already linked, the claim query went from about 4.2 s per start to about 2.3 ms. The table is in the PR body.
    2. GitHub only: only github.com claims and rows get links. Forgejo rows are dropped without a link, Forgejo claims stay claim records, and one summary line logs the counts. A claim's own URL is used for its link when it has one.
    3. Skip rule: a claim is skipped only when its own key once appeared in the thread's link history. In the Checker's case (old claim on Same UI and tools for Codex and Claude (tasks, option questions, subagents) #15, thread later linked fix(server): check each issue worktree once, concurrently #99) the claim now gets its Same UI and tools for Codex and Claude (tasks, option questions, subagents) #15 link.
    4. delegate_task: once the child exists, linking can no longer fail the call. A failed issue read names the link #<number> and logs it, and the child's run is still prepared.

    Rows for issues GitHub reports as not found are now dropped; network or rate-limit failures keep the row for the next start. docs/operations/fork.md and the PR body now say the backfill runs at each start until the table is empty and every GitHub claim is linked, after which it finds nothing to do. The PR body also mentions that a worker's native subagents inherit the claim's link and count as direct live work; I made no change for that.

    Each fix has a test, including Forgejo-host claim and row cases, the #15/#99 case, a not-found row, and the isolated-reviewer case where the issue read fails. The focused tests pass (27). vp run check:changed passes everything except type checking, which fails only on the three known apps/mobile errors from #449. The McpHttpServer.test.ts error from last round is gone now that main has #472.

    PR #474, head d5f0a74, checks and reviews: none reported yet (draft).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions