.agents/skills/tidb-test-guidelines/references/planner-guide.md
Define placement rules for optimizer tests under pkg/planner/core, with casetests grouped by type.
pkg/planner/core/casetest/<type>pkg/planner/core/casetest/<type>/testdatapkg/planner/core or pkg/planner/core/tests unless there is a strong, existing test suite to extend.Planner/core and non-core packages are peers. Place tests in their owning package directory when the code is not part of planner/core:
pkg/planner/core.pkg/planner/cardinalitypkg/planner/funcdeppkg/planner/memopkg/planner/planctxpkg/planner/utilpkg/planner/indexadvisorpkg/planner/implementationpkg/planner/cascades/...binaryplancascadescbotestch (CH benchmarks and datasets)correlateddagenforcemppflatplanhintindexindexmergeinstanceplancachejoinlogicalplanmppparallelapplypartitionphysicalplantestplancacheplanstatspushdownrulescalarsubquerytpcdstpchvectorsearchwindowspkg/planner/core/casetest/<type>/main_test.go and one or more *_test.go files.testdata in the same directory.BUILD.bazel shard_count.pkg/planner/core/casetest/<type> and keep testdata in pkg/planner/core/casetest/<type>/testdata.pkg/planner/core or pkg/planner/core/tests unless extending an existing suite.EXPLAIN format = 'plan_tree'.plan_tree. This includes pkg/planner/core/casetest/stats_test.go, pkg/planner/core/casetest/planstats, analyze-focused CBO suites under pkg/planner/core/casetest/cbotest, and any suite whose setup depends on load stats. These tests are format-sensitive, and EXPLAIN ANALYZE format = 'plan_tree' is not supported.EXPLAIN format = 'cost_trace' rather than plan_tree.explain for connection / EXPLAIN format='plan_cache' style; do not rewrite those assertions to plan_tree.EXPLAIN format = 'plan_tree' when the assertion is about the final chosen plan. Keep the nearby suite's existing format only for warning text, hint applicability, or other format-sensitive output.