Skip to content

feat(chatd): gate the workflow tools to deployment owners - #242

Merged
ibetitsmike merged 3 commits into
mainfrom
mike/chat-workflows-1c-owner-gate
Nov 12, 2026
Merged

ibetitsmike merged 3 commits into
mainfrom
mike/chat-workflows-1c-owner-gate

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Part of #226. Third PR of the chat-workflows stack, and a prerequisite for turning the fork-workflows experiment on anywhere.

What this adds

The experiment flag is deployment-wide, so with it on, every member's root chat got run_workflow and await_workflow and could fan out model-backed step children. While the engine is experimental, forkWorkflowTools now also requires the chat owner to hold the deployment owner role:

  • one primary-key read per gated turn, after the cheap in-memory checks, failing closed when the owner row is missing;
  • a role change applies on the owner's next turn, since the gate runs on every tool append;
  • no escape-hatch flag: widening to members is a later decision for Mike;
  • the check lives in the fork file, and appendForkTools only passes the ctx it already has.

Tests

TestForkWorkflowToolsGate now drives real chats: owner gets both tools (RootTurnGetsBothTools), a member-owned chat gets none (MemberOwnerGetsNothing), a missing owner row fails closed, flag-off gets none, plus the existing child, explore, and plan-mode guards, which now use variants of a real parent so each guard is isolated. The workflow fixture's chat owner is an owner so the engine tests keep working. Negative control to follow in an ops slot (chatd tests cannot link on the host).

Notes for reviewers

Xum opened this PR on behalf of @ibetitsmike.

The fork-workflows experiment flag is deployment-wide, so with the flag
on every member's root chat got run_workflow and await_workflow and
could fan out model-backed step children. While the engine is
experimental, the tools now require the chat owner to hold the
deployment owner role: one primary-key read per gated turn, failing
closed when the owner row is missing, with the role change applying on
the owner's next turn. There is no escape hatch; widening to members is
a later decision.

The workflow fixture's chat owner is an owner, and the gate test now
drives real chats: owner gets both tools, a member-owned chat and a
missing owner row get none, on top of the existing experiment, child,
explore, and plan-mode guards.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T12:30:16.692815Z 3a7d0ae 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.

@ibetitsmike

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: bf54781ff5

ℹ️ 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 coderd/x/chatd/fork_workflow.go Resolved
…sible row

- the turn runs under the daemon subject, which has only read_personal
  on users, so the plain GetUserByID in the owner gate failed for every
  real turn and the fail-closed branch removed the tools from owners
  too. The gate now reads the owner row as the system-restricted actor,
  the way UserRBACSubject reads roles for the same purpose.
- MemberOwnerGetsNothing inserted a chat whose owner row does not
  exist, which dies on the chats.owner_id foreign key before the
  fail-closed assertion runs; the stale-owner case is now an in-memory
  chat value, which is all the gate reads.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 3a7d0ae14d

ℹ️ 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".

@ibetitsmike
ibetitsmike merged commit d2a7450 into main Nov 12, 2026
9 checks passed
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merge gates on head 3a7d0ae:

  • fork-ci run 43217796546 passed, and all check runs on the head passed.
  • Codex reviewed 3a7d0ae (receipt comment 6823651637, "Didn't find any major issues"). Both P1s from round 1 were fixed. 0 review threads are unresolved.
  • Negative control: MemberOwnerGetsNothing fails when the gate is neutralized, and the other cases pass (ops verified the log).
  • No live UAT: the gate sits behind the owner role and the fork-workflows experiment, and this PR has no UI.
  • The branch is 0 commits behind main.

With this gate in place, fork-workflows can be enabled for deployment owners only.

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