Skip to content

feat(server): per-principal runner (fork) - #3

Closed
caniko wants to merge 2 commits into
feat/oidc-principalsfrom
feat/principal-runner
Closed

caniko wants to merge 2 commits into
feat/oidc-principalsfrom
feat/principal-runner

Conversation

@caniko

@caniko caniko commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Fork-only, stacked on #2. A signed-in principal's work runs as that person's Linux user through t3 runner, a unix-socket service started by t3-runner@<user>.

  • Through the runner: Codex app-server, Claude SDK (spawnClaudeCodeProcess), terminal PTYs and setup scripts. Git, gh and other processes run through the runner when their cwd is inside a principal's thread worktree.
  • Fail closed: providers with no runner path (cursor, opencode, grok, pi, fx, muse, acpRegistry, antigravity) refuse to open for principal threads. A missing runner, or a cwd owned by several principals, also fails closed.
  • Runner guards: it refuses to run as root, confines cwd to the user's home and --allow-root, and refuses overrides of HOME, PATH, loader and shell variables. Socket permissions (0660) are the auth boundary.

Known gap: git work in a project root outside any thread worktree still runs as the server user, because projects carry no owner yet.

Council review

Rounds: 1 (question: close as superseded by #6)

Delegate Round 1
Claude Opus 5.5 8/10
GPT-6.1 Sol 9/10

🤖 Generated with Claude Code

…its runner

On a shared server, a signed-in person's agents must run as their own
Linux user, not as the server's. `t3 runner` serves spawn requests on a
unix socket (socket-activated or --socket, 0660), refuses root, confines
cwd to the user's home and --allow-root dirs, and refuses overrides of
HOME, PATH, loader and shell variables. PrincipalExecution picks the
thread owner's runner for non-default principals and fails closed when it
is missing; the default principal still spawns in-process. Codex
app-server, the Claude SDK (via spawnClaudeCodeProcess) and terminal PTYs
(and so setup scripts) go through it.
… user

Providers without a runner path (cursor, opencode, grok, pi, fx, muse,
acpRegistry, antigravity) now refuse to open for a thread owned by a
non-default principal instead of running as the server user. Git, gh and
other server processes whose cwd lies in a principal's thread worktree go
through that principal's runner (GitVcsDriverCore.executeRaw and
ProcessRunner), so checkpoints and diffs run as the owner. A cwd owned by
several principals, or a missing runner, fails closed.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 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-11-02T10:06:15.840197Z a249863 PR opened
ℹ️ 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.

@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: a249863dd3

ℹ️ 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 on lines +118 to +119
child.stdout!.on("data", (chunk: Buffer) => send({ t: "out", s: "stdout", d: encode(chunk) }));
child.stderr!.on("data", (chunk: Buffer) => send({ t: "out", s: "stderr", d: encode(chunk) }));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply backpressure to runner output

When a runner-launched process produces output faster than the client consumes it, these listeners keep reading even after sendFrame signals socket backpressure. The queued frames can grow without bound and exhaust runner memory; pause the child streams when the socket is full and resume them on drain.

Useful? React with 👍 / 👎.

const { socketPath } = options;
if (NodeFs.existsSync(socketPath)) {
if (!(await isStale(socketPath))) throw new Error(`A runner is already listening on ${socketPath}.`);
NodeFs.unlinkSync(socketPath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve non-socket files at the configured path

If the configured path already exists as a regular file, the connect probe fails with ECONNREFUSED, so this treats it as stale and deletes it before starting the runner. Check the existing entry’s type and only unlink a stale socket; otherwise, fail without removing unrelated data.

Useful? React with 👍 / 👎.

FROM orchestration_v2_projection_threads
WHERE deleted_at IS NULL
AND json_extract(payload_json, '$.ownerPrincipal') IS NOT NULL
AND json_extract(payload_json, '$.ownerPrincipal') != ${DEFAULT_PRINCIPAL_ID}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include the default principal in worktree owner conflicts

If a default-owned thread and a non-default thread share a worktree path, this filter omits the default owner, leaving only the non-default owner in the result. spawnerForPath then routes Git and other processes for that path through the non-default user instead of failing closed, so include default ownership when detecting ambiguous paths.

Useful? React with 👍 / 👎.

Comment on lines +999 to 1002
const child = yield* (runnerSpawner ?? commandSpawner)
.spawn(
ChildProcess.make(executable, commandInput.args, {
cwd: commandInput.cwd,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep temporary Git indexes accessible to the runner

When a non-default thread uses selected-file commits, prepareCommitContext creates its temporary index in a server-owned directory and passes that path as GIT_INDEX_FILE. Git now runs as the principal's runner user, which cannot traverse that directory, so selected-file commits fail with a permission error; create the temporary index under the runner identity or otherwise make it accessible.

Useful? React with 👍 / 👎.

@caniko

caniko commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Note

🤖 Claude Opus 5.5 responding on behalf of caniko

Superseded by #6, which rebased these commits onto the 20261104 nightly and merged them into main. Open review findings are carried in #2 (comment).

@caniko caniko closed this Nov 8, 2026
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