Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): t3-code tools keep working after a turn waits over a day #18552

Mergedrobertnisipeanu(GitHub profile, opens in a new tab)merged 6 commits intomain fromrefs/pull/18552/headmerged by juliusmarminge View on GitHub

A provider turn waiting over 24 hours for a question or approval could lose its MCP bearer credential, leaving subsequent t3-code tool calls unauthorized. The server now refreshes credential liveness hourly after provider acceptance while event ingestion remains open. Renewal stops when ingestion exits, and failed touches are logged without aborting ingestion. Startup abandoned before acceptance creates no recurring renewal.

Maintainer takeover of @robertnisipeanu's #18552, preserving contributor history and merging current main. Credit to the author for identifying the long-wait failure and the ingestion lifetime as its boundary. Rebuilt the implementation and reused the current termination fixture instead of retaining the original standalone test setup and registry documentation changes.

The default 24-hour inactivity bound, permissions, and eager revocation remain unchanged. Human review of the authentication-lifetime change is still required; technical validation does not waive that gate.

Validation uses the real MCP registry with Effect TestClock and Deferred milestones. The 54-test baseline passes. Three focused cases bring the run-execution suite to 57 tests: a credential remains valid through 44 simulated hours with ingestion open, expires at hour 44 after ingestion ends at hour 2, and expires after startup is interrupted during the app-context read. The active-turn case fails against unchanged production; all 57 pass with the fix. The six registry tests also pass. Scoped lint, formatting, and server typecheck pass.

One independent full-diff review round by Claude Opus 5.5 and Codex GPT-6-Sol found no code blockers. The abandoned-startup renewal concern from earlier bot feedback is addressed by starting the heartbeat after acceptance and covered by the interruption regression.

Proof is deterministic headless Linux service testing. No real 44-hour provider wait, web client, macOS, Windows, iOS, Android, Electron desktop, remote/relay, or tunnel session was exercised. Screenshots do not demonstrate credential lifetime.

Implemented with Codex GPT-6.1-Sol, tests by Codex GPT-6-Astra, through the Codex harness in T3 Code.

Closes #14076

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

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

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — The server now keeps MCP bearer credentials alive hourly during long-running provider turns and lets them expire when ingestion ends. This is a focused fix, but it changes production authentication lifetime and credential access behavior.

      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 →

      Warning

      Review limit reached

      Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.

      Next included review available in 10 minutes.

      Check out review usage here.

      View limit details

      Limit details: You’ve used all 10 included reviews currently available.

      Learn how review limits work.

      Review configuration:

      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: c5bd94c9-d7af-45ec-a7bc-20561085e97e
      📥 Commits

      Reviewing files that changed from the base of the PR and between 583eeb0899e9962b87e77460a9dd581f651387a4 and 37524f314e301018f6cc6e7ac45094d7442da671.

      📒 Files selected for processing: 2
      • apps/server/src/orchestration-v2/RunExecutionService.test.ts
      • apps/server/src/orchestration-v2/RunExecutionService.ts

      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: 000709a1-b690-4d0c-94f6-82e7110afd00
      📥 Commits

      Reviewing files that changed from the base of the PR and between 0c77b14b7edabedb0c477fb671836ff00b8dafd0 and 583eeb0899e9962b87e77460a9dd581f651387a4.

      📒 Files selected for processing: 2
      • apps/server/src/orchestration-v2/RunExecutionService.test.ts
      • apps/server/src/orchestration-v2/RunExecutionService.ts

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

      📝 Walkthrough

      The run execution service now touches MCP credentials before provider startup and refreshes them hourly during active provider event ingestion. Tests cover credential liveness during long turns, expiry after ingestion ends, and interrupted startup.

      Changes: MCP credential liveness

      Layer / File(s)Summary
      Refresh credentials during event ingestion
      apps/server/src/orchestration-v2/RunExecutionService.ts
      The service logs and ignores failures from the initial credential touch. After provider-turn startup succeeds, it repeats the touch hourly until the provider event fiber completes.
      Verify credential liveness
      apps/server/src/orchestration-v2/RunExecutionService.test.ts
      Tests cover credential resolution through a 44-hour turn, expiry 44 hours after ingestion ends at two hours, and interrupted startup without credential renewal. The test helper can run an effect after signaling ingestion completion.

      Priority: ➖ Normal

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Sequence Diagram(s)

      sequenceDiagram
        participant RunExecutionServiceV2
        participant McpSessionRegistry
        participant ProviderEventFiber
        RunExecutionServiceV2->>McpSessionRegistry: Touch credential before provider startup
        RunExecutionServiceV2->>ProviderEventFiber: Start provider event ingestion
        RunExecutionServiceV2->>McpSessionRegistry: Repeat credential touch hourly
        ProviderEventFiber-->>RunExecutionServiceV2: Complete event ingestion
        RunExecutionServiceV2->>RunExecutionServiceV2: Stop credential refresh

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 583ee

      The change keeps MCP tool credentials valid while a long provider turn is active. No actionable merge-blocking risk was found. The PR author states that human review of the authentication-lifetime change is still required.

      Security architecture risk: 🔵 Low · up to 583ee

      Credentials can remain usable during long-running turns without tool traffic. Renewal starts only after provider acceptance and stops with event ingestion; expiry pruning, permissions, and explicit revocation remain intact. No authentication bypass was established, but concurrent credential replacement and recovery were not fully proven.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • observed — The affected authority is that of existing provider bearer credentials in the server environment. Their scopes contain environment, thread, provider identity, and capabilities. Issuance includes orchestration, worktree, and pull-request capabilities, with preview and device access selected from settings; thread identity alone should not be interpreted as proof that every tool is confined to that thread.

      Security Findings and Attack Paths

      • inferred — A copied credential from a dormant but ingestion-active provider session can remain usable beyond the cutoff it would previously have reached without traffic. Exploitation still requires possession of that bearer secret and endpoint reachability. This is an extended replay opportunity, not an established authentication bypass; an attacker already using a valid token could previously refresh its liveness through successful requests.

      Trust Boundaries and Controls

      • observed — The HTTP middleware resolves the presented bearer into an invocation scope and rejects requests when neither registry nor client authentication succeeds. Capability-check helpers remain unchanged. Credential replacement revokes the prior thread records before issuance, and explicit revocation remains authoritative despite recurring touches.

      Resilience and Maintainability Implications

      • observed — Ingestion closes its subscription on exit, and the refresher races completion of that ingestion fiber. Session release signals subscriber termination before its credential-cleanup finalizer; cleanup distinguishes credential IDs and preserves credentials held by replacements. Renewal itself remains thread-scoped, so this establishes revocation behavior but not complete generation isolation during overlapping recovery.
      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title is concise, conventional, and clearly identifies the fix for t3-code tools after long waits.
      Linked Issues checkPassedIssue #14076 requires MCP credential liveness during a turn that waits longer than 24 hours. RunExecutionService.ts touches the credential before provider startup and starts an hourly refresher afte…
      Out of Scope Changes checkPassedThe changes remain within issue #14076. Production changes update MCP credential liveness for the active provider turn. Test changes provide deterministic coverage for the liveness, termination, and i…
      Description checkPassedPASS. The description covers the problem, implementation, scope, linked issue, verification results, limitations, review status, and tooling. It does not include a direct link to an explicit maintaine…
      Full details: Linked Issues check

      Explanation

      Issue #14076 requires MCP credential liveness during a turn that waits longer than 24 hours. RunExecutionService.ts touches the credential before provider startup and starts an hourly refresher after startup acceptance. The refresher stops when provider event ingestion ends. Touch failures are logged and do not abort ingestion. Tests cover 44 hours with ingestion open, expiry after ingestion ends, and interrupted startup. The 24-hour registry bound remains unchanged.

      Full details: Out of Scope Changes check

      Explanation

      The changes remain within issue #14076. Production changes update MCP credential liveness for the active provider turn. Test changes provide deterministic coverage for the liveness, termination, and interrupted-startup cases. No unrelated restart behavior, credential bound, or permission changes are introduced.

      Full details: Description check

      Explanation

      PASS. The description covers the problem, implementation, scope, linked issue, verification results, limitations, review status, and tooling. It does not include a direct link to an explicit maintainer approval comment, but it clearly states that human approval remains required.

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autofix · 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 assignedjuliusmarminge

    6. Taking over this one for batch server-misc-02. I will preserve your commits, merge current main, rebuild the minimal credential-liveness proof, and run independent reviews. The PR will remain unmerged; the authentication-lifetime approval gate will remain explicit.

    7. juliusmarminge merged thisa2a13b5

    8. juliusmarminge closed this

Sign in to join this conversation.