Repository navigation
feat: add fork hooks for chat tools, chat routes and experiments - #27
Conversation
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.
|
@codex review
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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.
|
@codex review
|
There was a problem hiding this comment.
💡 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".
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.
|
@codex review
|
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review
|
There was a problem hiding this comment.
💡 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".
|
@codex review
|
There was a problem hiding this comment.
💡 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".
|
@codex review The two
|
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review
|
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Part of #5
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) joinsExperimentsKnownin aninit, so afork-<feature>experiment works with the CLI flag, the deployment config and the experiment evaluator without an edit todeployment.go.Server.appendForkTools(coderd/x/chatd/fork_tools.go) runs inbuildTurnEnvironmentafterappendRootChatTools. Fork tools gate onServer.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/forkbehind 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.goandcoderd/x/chatd/turn_environment.go.TestExperimentDisplayNames(codersdk/deployment_test.go) changes in two ways. It gains the missingExperimentPluginsentry: #2 added the experiment without it, sogo test ./codersdk/was red onmain. It also checks only the upstream entries ofExperimentsKnown, so a new fork experiment does not have to edit it; fork experiments come last, whichTestForkExperimentsasserts, and getDisplayName's title-case default.No user-visible behavior changes, except that
/api/v2/chats/fork/...answers 404 instead of 400.coderd/x/chatd/ARCHITECTURE.mdgets twoTODO(ibetitsmike)comments for @ibetitsmike to write: one under HTTP endpoints for the/chats/forkmount and one in the generation tool list forappendForkTools.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 probefork-probeentry inForkExperiments.TestForkChatRoutes,TestBuildTurnEnvironment*,TestEndpointsDocumented(builds the whole router and walks every route),./coderd/experiments/;TestForkExperimentson the host.TestForkChatRoutesalso 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.registerForkChatRoutescall,TestForkChatRoutesfails with 400 instead of 404; with the middlewareUsed inside the empty subrouter, it fails with 404 instead of 401; anappendForkToolsthat drops a tool failsTestAppendForkTools.