Skip to content

fix(mcp): resolve thread IDs across connected environments - #347

Merged
lastobelus merged 4 commits into
lastcode/mainfrom
port/upstream/cross-environment-thread-read
Oct 9, 2026
Merged

lastobelus merged 4 commits into
lastcode/mainfrom
port/upstream/cross-environment-thread-read

Conversation

@lastobelus

@lastobelus lastobelus commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Pasting a thread ID from another connected environment stopped at a local database miss. t3_thread_read now checks the initiating client’s authenticated environment connections after a local miss, so copied IDs work without an @ mention.

Remote reads stay within that client’s session. Delegated work, launched threads, and forwarded messages inherit the initiating run’s authorization; queued messages and replays cannot replace it. Requester bindings are capped at 10,000 and expire after seven inactive days; valid use refreshes them. Runs without a connected authorized client report an unavailable environment instead of borrowing another client’s access. External OAuth MCP access stays local.

Reads return the first matching destination without waiting for stalled connections. Thread reads and lists include the owning environment and a scoped link for pagination and navigation on web, desktop, and mobile. New links encode each ID separately; clients continue to resolve existing scoped and local links. Agent guidance uses the returned link. Local child-result acknowledgments are preserved.

Validation: focused regression suites covering broker authorization, concurrent lookup, legacy links, and MCP results; affected server, web, mobile, and shared typechecks; focused lint; clean local correctness review. GitHub CI and Codex review passed on the final commit; all review threads are resolved.

Integrated browser verification remains incomplete because the managed preview could not establish listener ownership. No visual layout changed.

Model: GPT-6.1-Sol. Harness: Codex.

Read pasted thread IDs through connected clients when the local environment
cannot find them. Return the owning environment and scoped links so reads,
pagination, and navigation stay on the correct connection.

Carry-Group: upstream-bugfixes
Carry-Observation: Provider thread reads can discover references across the client's authenticated environment connections without transferring credentials between servers.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T05:15:52.602919Z 00a78ac Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f658fd20fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/server/src/mcp/ThreadReadBroker.ts Resolved
Comment thread packages/shared/src/threadLinks.ts Resolved
Keep cross-environment reads within the authenticated session that started
an input, including delegated work, launched threads, and forwarded messages.
Encode scoped link segments separately and preserve existing thread links.

Carry-Group: upstream-bugfixes
Carry-Observation: Remote thread discovery must use the initiating client's authenticated connections; scoped references must preserve every valid ID.
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c7b2789a4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/shared/src/threadLinks.ts Resolved
Search connected destinations concurrently and return the first matching
history. Preserve uncached legacy link targets and include scoped links
in thread-list results so agent guidance matches the tool output.

Carry-Group: upstream-bugfixes
Carry-Observation: Stalled connections must not delay a reachable thread, and returned references must remain usable without cached thread records.
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d2f09af25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/server/src/mcp/ThreadReadBroker.ts Resolved
Expire inactive requester bindings and cap retained authorizations while
refreshing recently used entries. Evicted inputs cannot inherit another
client's access, and replay checks continue to protect existing messages.

Carry-Group: upstream-bugfixes
Carry-Observation: Requester authorization must remain bounded during a long-lived server process without weakening message/session isolation.
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 00a78ac45c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lastobelus
lastobelus merged commit 63236ae into lastcode/main Oct 9, 2026
34 checks passed
@lastobelus
lastobelus deleted the port/upstream/cross-environment-thread-read branch October 9, 2026 05:29
lastobelus added a commit that referenced this pull request Oct 9, 2026
Consolidate input authorization and inherited run access in the thread-read broker. Reuse caller state for local reads, simplify concurrent destination lookup, and share regression fixtures.

Model: Claude Opus 5.5. Harness: Claude Code.

Carry-Group: incubator
Carry-Fix: #347
Carry-Observation: Cross-environment thread-read routing and its authorization tests form one feature; this cleanup keeps their ownership together.
lastobelus added a commit that referenced this pull request Oct 9, 2026
Pass the caller run into broker reads and inherited input authorization so a later input cannot lend its client access. Extend deterministic coverage for source advancement during reads, sends, and launches.

Model: Claude Opus 5.5. Harness: Claude Code. Validation: GPT-6.1-Sol through Codex.

Carry-Group: incubator
Carry-Fix: #347
Carry-Observation: Preserve the original initiating-run access boundary while consolidating cross-environment read authority.
lastobelus added a commit that referenced this pull request Oct 9, 2026
Cross-environment thread reads repeated input authorization in client dispatch, thread creation, send, and launch. Each read also loaded its caller twice. This cleanup consolidates that logic in `ThreadReadBroker`, reuses the loaded caller, and simplifies the first-success destination search.

Reads and inherited authorization retain the caller's captured run, so a later input cannot lend another client's access. The existing raw-ID lookup, pagination, delegated reads, scoped links, and destination permissions are preserved. Shared test fixtures retain the regression cases and now cover source advancement during reads, sends, and launches. The cleanup removes 69 implementation lines and 76 test lines overall across ten files.

Validation:
- 205 focused server tests and 8 client-runtime tests passed after rebasing onto main.
- The three suites affected by the captured-run correction passed all 22 tests.
- The server package typecheck and all four activity regressions passed after correcting a snapshot fixture type mismatch caught by CI.
- Focused lint, formatting, and server/client-runtime typechecks passed during implementation. Astra High's follow-up review was clean after correcting its run-authority finding.
- After refreshing onto current main, all 22 server regressions and 8 client-runtime tests passed again. Local Quick CI deferred because capacity was busy; the required GitHub checks validate the refreshed commit. No presentation components or wire contracts changed.

Follow-up to #347.

Implementation: Claude Opus 5.5 through Claude Code. Review: GPT-6-Astra High through Codex. CI repair, validation, and delivery: GPT-6.1-Sol through Codex.

Carry-Source-Ref: refs/lastcode/carry-sources/pr-351/9be983a05cfcb793ce427ef5a923da297b0ff218
Carry-Source-Base: c01ce20
Carry-Source-Head: 9be983a
lastobelus added a commit that referenced this pull request Nov 16, 2026
…ion (#741)

Upstream already tests peer-link snooze clearing, card completion and outcome notification (added in https://redirect.github.com/pingdotgg/t3code/pull/20058, fixture later refactored in https://redirect.github.com/pingdotgg/t3code/pull/26944). LastCode also carried a diagnostic-only addition to that test, `491ad0c4ba27fd683cd2ed2eec040b7a274651d6` ("test: show the peer-link outcome when wake fails"). Carrying it means replaying an edit to an upstream test on every checkpoint, which adds churn without adding coverage.

This PR removes the `JSON.stringify(cardOf(a))` diagnostic argument from the `snoozedUntil` `toBeNull` assertion in `apps/server/src/peer/PeerLinkRequests.test.ts` (one file, 5 lines). No test case or behavioral assertion is removed, and there is no runtime change.

The fixture and API adaptations from `7be36ba46e0733f9144d3a040a017d4b6a435cc5` stay. They are now the only LastCode delta in this test:

- `ActionResume` and `ThreadReadBroker` provisioning. See #347 and #351 for the `ThreadReadBroker` dependency, and #509 for the Action metadata read dependency.
- The archive child disposition fields.

This should reduce replay churn on this test. It does not claim to remove all future drift. An archived run shows one replay conflict here, but the original Full CI failure log is unavailable, so this PR doesn't claim to identify or fix that failure's cause.

Validation:

- All 25 peer-link tests pass.
- The changed-file check passes: 27 tests, affected typechecks, format, lint, GraphQL and knip.
- Saved Quick CI passed on head `b95125df9c8ee12f2a8614aa05c54d327fdbebea` against base `006e9d3b50a50df3d21ed3061e9185b186845b1b`.

Local review: 2 rounds with gpt-6.1-terra (xhigh), approved.

Carry-Group: incubator
Carry-Supersedes: 491ad0c4ba27fd683cd2ed2eec040b7a274651d6

GPT-6.1 Sol through Codex. Local review: GPT-6.1 Terra xhigh. PR wording: Claude Sonnet 5.5.

Carry-Source-Ref: refs/lastcode/carry-sources/pr-741/b95125df9c8ee12f2a8614aa05c54d327fdbebea
Carry-Source-Base: 006e9d3
Carry-Source-Head: b95125d
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.

1 participant