Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): forks no longer inherit pull request watches #16623

Mergedjakeleventhal(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/16623/headmerged by juliusmarminge View on GitHub

Problem

Forking a thread that watches a pull request silently starts watching it in the fork too. ThreadForkService spreads the source thread, including each PR link's watch. The watcher reactor selects those links on its next sweep, and projections expose a pending monitor task even though nobody asked the fork to watch.

Reproduction: enable a PR watch on a thread with a finished run, then fork that run. The fork should retain the PR context without inheriting the parent's background responsibility.

Change

Remove watch from each copied PR link when planning the fork. Preserve PR identities, link sources, timestamps, snapshots, stack context, dismissed stack entries, and legacy associations. The source thread is unchanged. The fork can independently start and stop watching later.

This is a four-line server change at the shared fork service used by UI and MCP commands. It applies before native/portable provider continuation and requires no client or wire-contract changes. It prevents new inheritance; it does not alter existing threads or subscriptions.

Scope and approval

This qualifies as the small, focused obvious-bug exception: copying conversation context accidentally duplicates an active subscription. The change only removes that unintended side effect, with regressions for preservation and independent opt-in. No new feature, setting, or unrelated cleanup.

Verification

Base: 8ddf200e8f637eaf9a4f0d3036ece8f1d3869d10 (upstream/main fetched immediately before creating this worktree).

BEFORE — final regression tests against unchanged base source

Temporarily restored only ThreadForkService.ts from the base SHA, ran the final tests below, then restored the fix:

./node_modules/.bin/vp test run apps/server/src/orchestration-v2/ThreadForkService.test.ts apps/server/src/orchestration-v2/ThreadFork.execution.test.ts

Exit 1: 2 failed, 10 passed. Both new tests failed because the fork's PR links still contained watch:

  • preserves pull request context without inheriting any watches: both watched links retained the parent's full watch cursor, including head/check/comment state and wake count.
  • a persisted fork leaves PR watching with its parent until explicitly opted in: reading the fork back through the orchestrator returned the inherited watch rather than the expected association without a watch.

Representative unexpected value from the persisted-fork assertion:

+ "watch": {
+   "conflicting": false,
+   "failedChecks": [],
+   "headSha": null,
+   "passed": false,
+   "passedChecks": [],
+   "remarkIds": [],
+   "remarksThrough": "1970-01-01T00:00:00.000Z",
+   "startedAt": "1970-01-01T00:00:00.000Z",
+   "wakes": 0
+ }
./node_modules/.bin/vp test run apps/server/src/orchestration-v2/ThreadForkService.test.ts apps/server/src/orchestration-v2/ThreadFork.execution.test.ts apps/server/src/orchestration-v2/testkit/ThreadFork.integration.test.ts apps/server/src/orchestration-v2/ThreadStop.test.ts apps/server/src/orchestration-v2/pullRequestWatch.test.ts packages/shared/src/orchestrationV2PendingBackgroundWork.test.ts

Exit 0: 6 files, 76 tests passed (14.44s). The new integrated regression uses the real orchestrator/event sink and isolated in-memory SQLite, with provider execution disabled. It verifies:

  • The persisted fork retains its PR association but has no watch or pending monitor task.
  • The parent's complete thread shell, watch, and pending monitor remain unchanged.
  • A delayed sync/wake carrying the parent's watch is rejected and creates no fork run.
  • Explicit watch opt-in on the fork starts a fresh subscription and pending monitor independently.
  • Opt-out removes only the fork's watch and monitor while preserving its association and leaving the parent unchanged.

The service regression additionally covers multiple watched links, unwatched/manual and dismissed links, PR snapshots and native-stack context, plus legacy linked/branch associations. Existing native Codex/Claude replay and fork-boundary tests pass.

Additional focused checks, all exit 0:

./node_modules/.bin/vp run --filter t3 typecheck
./node_modules/.bin/vp lint apps/server/src/orchestration-v2/ThreadForkService.ts apps/server/src/orchestration-v2/ThreadForkService.test.ts apps/server/src/orchestration-v2/ThreadFork.execution.test.ts
./node_modules/.bin/vp fmt --check apps/server/src/orchestration-v2/ThreadForkService.ts apps/server/src/orchestration-v2/ThreadForkService.test.ts apps/server/src/orchestration-v2/ThreadFork.execution.test.ts
git diff --check

No repo-wide checks, live user threads, live databases/services, deployment, or browser verification. The backend regression provides the relevant before/after evidence; no UI changed.

Model: GPT-6 Astra (high reasoning). Harness: Codex in T3 Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 36dfa93

      Macroscope's review found this PR approvable — This is a small, self-contained server bug fix that prevents forked threads from inheriting background pull-request monitors while preserving all pull-request context and explicit opt-in behavior. Focused unit and integration coverage verifies source-thread isolation and independent fork watching.

      Notes:

      • Diff unchanged. Approvability was decided on eligibility alone.

      No code changes detected at 83cfec6. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 1707b4fd-8e56-4b9e-adfa-f95c14d0f65b
      📥 Commits

      Reviewing files that changed from the base of the PR and between 8ddf200e8f637eaf9a4f0d3036ece8f1d3869d10 and ebaf645e2b16b23ffec57c944f4bb662f8f99896.

      📒 Files selected for processing (3)
      • apps/server/src/orchestration-v2/ThreadFork.execution.test.ts
      • apps/server/src/orchestration-v2/ThreadForkService.test.ts
      • apps/server/src/orchestration-v2/ThreadForkService.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

      📝 Walkthrough
      📝 Walkthrough

      Walkthrough

      Forked threads retain their source pull-request links without inheriting watch data. Tests verify that the parent’s watch remains unchanged and that the fork can independently enable and disable watching.

      Changes

      Fork watch isolation

      Layer / File(s)Summary
      Copy pull-request links without watch state
      apps/server/src/orchestration-v2/ThreadForkService.ts, apps/server/src/orchestration-v2/ThreadForkService.test.ts
      Fork planning copies pull-request links without their watch fields. Tests verify other link data and legacy pull-request fields remain, while the source projection is unchanged.
      Verify independent fork watch behavior
      apps/server/src/orchestration-v2/ThreadFork.execution.test.ts
      The orchestration test verifies that the fork has no inherited watch or pending task, rejects a stale watch-sync update, and can independently enable and disable watching.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to ebaf6

      Forks retain pull-request links without inheriting watches, and no actionable merge risk is identified.

      Security Architecture Review

      Security architecture risk: 🔵 Low · up to ebaf6

      Forked threads retain pull-request context but must explicitly start their own watch. The change reduces unintended background activity, and no introduced security defect was established. Risk remains low rather than minimal because failure and recovery paths were not fully verified.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • observed — The changed behavior concerns subscription initialization on each forked thread. Source project, provider and runtime context continue to be copied as before; the production delta neither adds a credential nor grants a new privilege.

      Security Findings and Attack Paths

      • inferred — No introduced bypass was established in the reviewed fork-to-monitor path. A delayed update carrying the parent’s watch cursor cannot initiate a wake on a newly unwatched fork because the target lacks a matching active watch. This conclusion is limited to that path, not a complete security audit.

      Trust Boundaries and Controls

      • observed — Existing fork handling checks the source runtime modes actually being copied. Existing monitor synchronization is target-thread-local and uses PR identity plus startedAt as a stale-update guard before dispatching agent work; that cursor is a lifecycle control, not an authentication credential.

      Resilience and Maintainability Implications

      • observed — The added persisted regression asserts no inherited pending monitor task, rejection of a stale parent update without a wake run, independent target opt-in and opt-out, and unchanged parent state. Its provider worker is disabled, so these assertions do not verify live provider failure recovery.
      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly summarizes the main change: forked threads no longer inherit pull-request watches.
      Description check✅ PassedThe description covers the problem, change, scope exception, and focused verification results. It also states the checks that were not performed.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Approvability✅ PassedThe pull request changes only ThreadForkService.ts and two server test files. The service change copies pull-request context but removes watch from forked links. This is a focused bug fix, not a p…
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge added labelsmacroscope-review

    5. juliusmarminge merged thisd4004c5

    6. juliusmarminge closed this

Sign in to join this conversation.