Skip to content

feat(issues): move thread issue links onto thread.issues - #474

Merged
tannerpolley merged 3 commits into
mainfrom
issue-455-451-step-4-move-thread-issue-links-onto
Nov 18, 2026
Merged

tannerpolley merged 3 commits into
mainfrom
issue-455-451-step-4-move-thread-issue-links-onto

Conversation

@tannerpolley

@tannerpolley tannerpolley commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Step 4 of #451 ("Thread links: the data move"). Thread ↔ issue links lived in two places: the fork's issue_thread_links table and upstream's thread.issues[]. Now thread.issues[] is the only store.

Claims write their link. The issue-owned planner (IssueWorkCommands.claimFields) puts the thread.issues[] entry in the same thread.created event as linkedIssue, for both delegated workers and thread.create claims. A worker's claim link replaces links it would otherwise inherit from its parent's thread. Unmanaged children delegated with an issue (reviewers, checkers, writers…) link through upstream's ThreadIssueService after reading the issue's title. The child already exists and runs at that point, so a failed read or link never fails delegate_task: a retry would start a second child. A failed read names the link #<number> and is logged, and worktree preparation still runs.

Backfill at each start (IssueLinkBackfill.ts, after server activation). It runs until the table is empty and every GitHub claim is linked; after that its reads find nothing and cost a few milliseconds.

  • Reads go through the reader connection. For claims, the cheap "already linked" payload check runs first. Only unlinked GitHub claims read their event history.
  • GitHub only. Only github.com claims and rows are linked. Rows on other hosts (the archived Forgejo) are dropped without a link, and their claims stay claims. One summary line logs the counts.
  • Skip rule. A claim is skipped only when its own key once appeared in the thread's link history ($.issues of its thread.created or thread.issue-synced events). A claim made now carries its link from creation, so a missing link means someone removed it. An old claim whose thread later linked a different issue is still linked.
  • Mapping. Tracker github, scope = repository, key = number, project = the thread's, #n display key, source agent. The URL is the claim's own when it has one, otherwise built from host, repository and number. The title is the claim's when it is the same issue, otherwise one upstream IssueService.detail read per distinct issue, four at a time.
  • Rows. Each row is deleted after its command commits. Rows for deleted or missing threads, for issues GitHub reports as not found, and on other hosts are dropped. A transient read failure (network, rate limit) keeps the row for the next start.
  • The command id is fork:issue-link-backfill:<thread>:<host>/<repo>#<n>, so a leftover row replays its receipt. The table stays until a later fork migration drops it. Backfilled links carry the backfill time as linkedAt.

Startup cost, measured on a synthetic database: 2.6M thread events and 1,000 claimed threads, every claim already linked, five runs each.

Claim query Time per start
Before (history check first, every claim) 4,095–4,258 ms
After (linked check first, history only for unlinked claims) 2.2–2.4 ms

Removed: the table reads in IssueLinks.enrich, IssueLinks.link and its refresh stream, issues.unlink (contract, handler, scope, client command), the fork's "Unlink from this thread" menu item and canUnlink (upstream's issue panel already toggles thread.issues[] links), the table from the purge list, and the table insert in scripts/fork-dev/seed.py (seeded claims now carry their link).

linkedIssue stays the claim record. Live work still counts a claim after its link is removed.

Not removed: issues.subscribeLinkRefreshes. Only the table's refresh source is gone. The RPC also carries the roadmap's work-state refresh (runs, requests, background tasks, issue work), and the roadmap still reads through the fork until step 5. Deleting it now would leave live work on the roadmap stale until the 5-minute poll. Step 5 can retire it.

Side effect, no change made: native subagents copy their parent's thread fields, so a worker's native subagent now inherits the claim's link and counts as direct live work on that issue instead of inherited.

Evidence

Surfaces: server and contracts; web loses the fork unlink item (upstream's toggle remains). Mobile is out of scope for fork additions. Providers: Codex and Claude only, as before. No user-facing strings were added.

Closes #455. Part of #451.

🤖 Generated with Claude Code (Claude Opus 5.5, Claude Code harness in T3 Code)

A managed claim now writes its thread.issues[] link in the event that
creates the claimed thread, and unmanaged delegated children link through
upstream's thread link command. A one-time startup backfill moves the
issue_thread_links rows, and claims made before claims carried links, onto
thread.issues[] with commands keyed by thread and issue. The table reads,
issues.unlink and the table's refresh stream are gone; linkedIssue stays the
claim record and still counts as live work after its link is removed.

Closes #455. Part of #451.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tannerpolley and others added 2 commits November 17, 2026 19:03
…started delegation

The backfill checks "already linked" first and reads a claim's event history only when the
claim is unlinked, on the reader connection. Only github.com claims and rows are linked;
other-host rows are dropped and their claims stay claims. A claim is skipped only when its
own key once appeared in the thread's link history, and a claim's own URL is kept. Rows whose
issue is not found are dropped; transient failures keep the row. An unmanaged delegated child
whose issue read fails is linked by its number instead of failing a delegation that started.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tannerpolley
tannerpolley marked this pull request as ready for review November 18, 2026 02:13
@tannerpolley
tannerpolley merged commit f115d1c into main Nov 18, 2026
@tannerpolley
tannerpolley deleted the issue-455-451-step-4-move-thread-issue-links-onto branch November 18, 2026 02:13
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.

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

1 participant