Skip to content

refactor(server): resolve self invocations through one shared helper - #12946

Merged
juliusmarminge merged 1 commit into
t3code/codex-turn-mappingfrom
t3code/self-invocation-resolver
Sep 21, 2026
Merged

juliusmarminge merged 1 commit into
t3code/codex-turn-mappingfrom
t3code/self-invocation-resolver

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

#12747 and #12791 each fixed one place where the server spawned itself with process.execPath plus argv[1], which breaks under the single-executable, and #12747 then reached for node:sea directly inside the ACP adapter. The rest of the server already answers "are we the packaged binary" through the HostProcessIsExecutable reference and resolveNodeExecutable, so this leaves three ways of asking the same question.

This adds resolveSelfInvocation next to resolveNodeExecutable in @t3tools/shared/nodeRuntime: one Effect that returns { command, entrypoint } from HostProcessExecutablePath, HostProcessIsExecutable and HostProcessArguments, plus selfInvocationArgs to build the argv. The ACP adapter takes the resolved value as an option instead of reading the process, and the three adapter factories (Grok, Antigravity, ACP registry) resolve it in their Effect layer. AcpAdapterV2.ts no longer touches process.execPath, process.argv, or node:sea.

The /bin/sh cgroup wrapper from #12791 is unaffected: it no longer spawns Node at all.

Verified: packages/shared nodeRuntime.test.ts (2 new cases, 11 total), apps/server AcpAdapterV2.test.ts / AcpRegistryAdapterV2.test.ts / GrokAdapterV2.test.ts / AntigravityAdapterV2.test.ts (125), vpr typecheck in both packages, lint on touched files. The existing self-contained bridge test now provides HostProcessIsExecutable instead of mocking node:sea.

Claude Fable 5 via Claude Code.

🤖 Generated with Claude Code


Devin Review

The ACP adapter assembled `process.execPath` plus `argv[1]` by hand and
then special-cased the single-executable with `node:sea`, while the rest of
the server already answers "are we the packaged binary" through
`HostProcessIsExecutable`. Add `resolveSelfInvocation` beside
`resolveNodeExecutable` in `@t3tools/shared/nodeRuntime` so there is one
place that knows how another process runs this install's CLI, and thread
the resolved value into the ACP adapter instead of reading the process in
the adapter.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 21, 2026
import * as Schema from "effect/Schema";

import {
HostProcessArguments,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Import this local Effect service module as a namespace rather than adding another service tag as a named import. Please use import * as HostProcess from "./hostProcess.ts" and reference its tags through that public namespace (for example, yield* HostProcess.HostProcessArguments), updating the existing host-process references in this file accordingly.

Posted via Macroscope — Effect Service Conventions

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This file already imported HostProcessEnvironment, HostProcessExecutablePath, HostProcessIsExecutable and HostProcessPlatform by name before this PR (same on main). Adding HostProcessArguments to that list matches the file; switching the whole file to a namespace import is unrelated churn for this change.

@macroscopeapp

macroscopeapp Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Effect Service Conventions found one issue in packages/shared/src/nodeRuntime.ts: the newly consumed local Effect service tag should be accessed through a namespace import. The inline review comment includes the expected fix; it requires updating multiple references, so no self-contained diff is feasible.

Posted via Macroscope — Effect Service Conventions

@macroscopeapp

macroscopeapp Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at d010b48

Macroscope's review found this PR approvable — This PR centralizes existing ACP self-invocation logic and corrects packaged-binary handling without changing schemas, defaults, or production infrastructure. The runtime effect is narrowly limited to launching the existing MCP bridge and is covered by focused tests.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 4.9 KiB — 6.8 KiB ✅
Codex Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Codex Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 20.4 KiB — 29.3 KiB ✅
Codex Live turn messages — 2 — 8 ✅
Claude Total thread wire — 4.9 KiB — 6.8 KiB ✅
Claude Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Claude Live turn WebSocket decoded — 20.8 KiB — 29.3 KiB ✅
Claude Live turn messages — 2 — 8 ✅

Baseline: unavailable · PR result: d010b48 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 106.1 KiB
  • Claude decoded thread snapshot: 106.4 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@juliusmarminge
juliusmarminge merged commit d7df317 into t3code/codex-turn-mapping Sep 21, 2026
23 of 24 checks passed
@juliusmarminge
juliusmarminge deleted the t3code/self-invocation-resolver branch September 21, 2026 21:30
juliusmarminge added a commit that referenced this pull request Sep 23, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 23, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 23, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 23, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 23, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 23, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 24, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 24, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 24, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 25, 2026
…12946)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant