`TestBuildTurnEnvironmentToolPolicy` ran every row with the advisor
experiment off and had no general sub-agent row, so only end-to-end
tests checked advisor eligibility and the tools that only root chats
get. This PR adds those checks to the table and deletes nothing; the PRs
above it delete the end-to-end tests.
- The rows run on a server with `ExperimentChatAdvisor`; the new
`RootAdvisorOff` row uses a second server without it. The stored advisor
config says `Enabled: true`, which must not matter: the experiment is
the only gate (`codersdk/chats.go:1277`).
- `Root` now wants the advisor, its guidance, and the five workspace and
five sub-agent tools, and rejects `propose_plan`. The new `GeneralChild`
row rejects all of those and `ask_user_question`. The plan and Explore
rows reject the advisor.
- Every row checks the guidance and the exclusive tool set: only the
advisor when the row wants it, otherwise empty.
### Why it is safe
The rows pass on `main` (`e53cfef8643`), which now includes #30911. Each
of 15 mutants of `turn_environment.go` fails a row:
| Mutant | Row that fails |
| --- | --- |
| Advisor gate ignores the experiment, the root check, plan mode, or
Explore mode | `RootAdvisorOff`, `GeneralChild`, `PlanRoot`,
`ExploreRoot` in that order |
| No advisor guidance, no advisor tool, or no exclusive set | `Root` |
| Root-only tools in every chat, or in none | `GeneralChild`, or `Root`,
`RootAdvisorOff`, `PlanRoot` |
| `ask_user_question` in standard root turns, or in child turns |
`Root`, or `GeneralChild` |
| `propose_plan` in every turn | `Root` |
| Plan children get `write_file`, or plan turns drop `read_file` |
`PlanChild` |
| Plan turns drop approved MCP tools | `PlanRoot` |
The deletion PRs above map each deleted assertion to these rows. Under
the plan and Explore gate mutants, the plan filter and the Explore
allowlist still drop the advisor tool, so those rows fail on the new
guidance and exclusive set checks.
### Review focus
Both servers are built once and never changed, and each row creates its
own chat, so the rows stay parallel.
### Timing
From 5 alternating runs, the table took 0.29 s (median) before this PR
and 0.28 s after.
### Validation
- `go test ./coderd/x/chatd/ -run '^TestBuildTurnEnvironmentToolPolicy$'
-count=10`, and with `-race -count=3`: pass
- `go test -overlay` mutant runs: results above
- the pre-commit hook (gen, fmt, lint, slim build) passed
### Stack
The stack moves advisor eligibility and the root versus child tool split
into `TestBuildTurnEnvironmentToolPolicy` and deletes the end-to-end
tests that only checked them, finishing #30868. #30911 has merged, so
the stack now starts at `main`.
1. #30990 Advisor and general child rows in the tool policy table (this
PR)
2. #30991 Remove the end-to-end advisor gating tests
3. #30992 Remove the end-to-end root and child tool list tests
4. #30993 Fold the duplicate advisor scenarios
> Xum, an AI agent, opened this PR for @ibetitsmike and wrote this
description.