Skip to content

feat: add fork hooks for chat tools, chat routes and experiments - #27

Merged
ibetitsmike merged 7 commits into
mainfrom
mike/fork-foundation-3-fork-hooks
Nov 9, 2026
Merged

ibetitsmike merged 7 commits into
mainfrom
mike/fork-foundation-3-fork-hooks

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Part of #5

Xum opened this PR on behalf of @ibetitsmike.

Adds the three hooks that fork features use, so each hot upstream file carries one fork line and an upstream sync does not merge into fork logic. All three are empty for now.

  • codersdk.ForkExperiments (codersdk/fork_experiments.go) joins ExperimentsKnown in an init, so a fork-<feature> experiment works with the CLI flag, the deployment config and the experiment evaluator without an edit to deployment.go.
  • Server.appendForkTools (coderd/x/chatd/fork_tools.go) runs in buildTurnEnvironment after appendRootChatTools. Fork tools gate on Server.experiments, like the upstream chatd tools, so the tool list is the upstream list while no fork experiment is on.
  • API.registerForkChatRoutes (coderd/fork_chat_routes.go) mounts /api/v2/chats/fork behind the API key middleware. With no route yet, fork paths answer 404 instead of falling into the /chats/{chat} wildcard, which answers 400 when the path segment is not a UUID.

Upstream edits are one line each, in coderd/chat_routes.go and coderd/x/chatd/turn_environment.go.

TestExperimentDisplayNames (codersdk/deployment_test.go) changes in two ways. It gains the missing ExperimentPlugins entry: #2 added the experiment without it, so go test ./codersdk/ was red on main. It also checks only the upstream entries of ExperimentsKnown, so a new fork experiment does not have to edit it; fork experiments come last, which TestForkExperiments asserts, and get DisplayName's title-case default.

No user-visible behavior changes, except that /api/v2/chats/fork/... answers 404 instead of 400.

coderd/x/chatd/ARCHITECTURE.md gets two TODO(ibetitsmike) comments for @ibetitsmike to write: one under HTTP endpoints for the /chats/fork mount and one in the generation tool list for appendForkTools.

Validation
  • go build ./coderd/... ./codersdk/... ./enterprise/...; go vet ./codersdk/ ./coderd/x/chatd/ ./coderd/; gofmt; git diff --check.
  • go run ./scripts/check-scopes; go run ./scripts/checkexperimentkeys.
  • TestAppendForkTools: the hook returns the same tools with no experiment on and with every upstream experiment on.
  • go test ./codersdk/ passes, also with a probe fork-probe entry in ForkExperiments.
  • On Postgres 17: TestForkChatRoutes, TestBuildTurnEnvironment*, TestEndpointsDocumented (builds the whole router and walks every route), ./coderd/experiments/; TestForkExperiments on the host.
  • TestForkChatRoutes also checks that an unauthenticated request answers 401: chi builds a subrouter's middleware chain only with its first route, so the API key middleware wraps the mount.
  • Negative controls: without the registerForkChatRoutes call, TestForkChatRoutes fails with 400 instead of 404; with the middleware Used inside the empty subrouter, it fails with 404 instead of 401; an appendForkTools that drops a tool fails TestAppendForkTools.

Fork features need to stay out of the hot upstream files so an upstream
sync does not merge into fork logic. Add the three hooks those features
will use, empty, so each hot file carries exactly one fork line:

- codersdk.ForkExperiments joins ExperimentsKnown in an init, so a
  fork-<feature> experiment is accepted by the CLI flag, the deployment
  config and the experiment evaluator without editing deployment.go.
- Server.appendForkTools runs after appendRootChatTools in
  buildTurnEnvironment, and gates on Server.experiments like the
  upstream chatd tools, so the turn tool list stays the upstream list
  while no fork experiment is on.
- API.registerForkChatRoutes mounts /api/v2/chats/fork behind the API
  key middleware. It has no route yet, so fork paths answer 404 instead
  of reaching the /chats wildcard and turning into a 400 from the UUID
  parsing of {chat}. The mount is accepted beside the /chats mount, in
  either order, which the chat route and swagger walk tests confirm.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 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-09T04:56:28.785577Z fc9fb28 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.

…t off

The W0a acceptance asks for a test that the hook returns the tool list
unchanged while no fork experiment is on, with and without the upstream
experiments.
#2 added ExperimentPlugins to ExperimentsKnown without an entry in
TestExperimentDisplayNames, which left go test ./codersdk/ red on main.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@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: 289499d477

ℹ️ 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 codersdk/fork_experiments.go Resolved
Fork experiments come last in ExperimentsKnown, so TestExperimentDisplayNames
checks only the upstream entries and a new fork experiment does not have to
edit that upstream test. TestForkExperiments checks the order.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: bc6508af5b

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

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@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: 081b4caa9e

ℹ️ 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/chat_routes.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

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

ℹ️ 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/ARCHITECTURE.md Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

The two TODO(ibetitsmike) comments in ARCHITECTURE.md are intentional: AGENTS.md has the human author write that document.

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: e266f04cba

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

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: fc9fb283a2

ℹ️ 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 cac7ca5 into main Nov 9, 2026
8 checks passed
@ibetitsmike
ibetitsmike deleted the mike/fork-foundation-3-fork-hooks branch November 9, 2026 05:10
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike as cac7ca5 (squash, head fc9fb28). Before merging, Xum checked fork-ci on the exact head, the clean Codex review on fc9fb28, 0 unresolved threads, and the UAT round 2 pass on fc9fb28, and that d4e1dfc (#26) was deployed healthy first. Two TODO(ibetitsmike) comments in coderd/x/chatd/ARCHITECTURE.md are left for Mike.

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