Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

perf(ci): give unclassified top-level trees a merge-queue lane (#76625)

Georges-Antoine Assi9c1792420ae3
diff --git a/.github/scripts/trunk-impacted-targets.js b/.github/scripts/trunk-impacted-targets.js
index 778461fbe882..7502f0a861bb 100644
--- a/.github/scripts/trunk-impacted-targets.js
+++ b/.github/scripts/trunk-impacted-targets.js
@@ -117,6 +117,24 @@ const TRIPWIRES = [
// bin/ appears in the backend, frontend, and E2E path filters alike.
'bin/**',
'patches/**',
+ // Holds the Depot-runner copies of the workflows and composite actions in
+ // .github/, so it decides what runs for everyone the same way.
+ '.depot/**',
+ // The toolchain every suite runs inside. ci-python.yml gates on
+ // .flox/env/manifest.toml for that reason.
+ '.flox/**',
+ // ClickHouse, Postgres, and Temporal configuration mounted by every
+ // docker-compose file, so it defines the services all the suites test
+ // against.
+ 'docker/**',
+ // duckgres.yaml is mounted into the same stack, and intent-map.yaml steers
+ // bin/sandbox and hogli, both already tripwires.
+ 'devenv/**',
+ // Lint rules that run repo-wide: a new rule fails code that merged in a
+ // parallel lane, which is the same conflict .oxlintrc.json is here for.
+ '.semgrep/**',
+ // Holds the markdownlint config, which is the same class of rule change.
+ '.config/**',
'tsconfig.json',
'tsconfig.*.json',
'babel.config.js',
@@ -149,6 +167,60 @@ const TOOLS_INDEPENDENT = [
'infra-scripts',
]
+// Top-level trees that hold a lane instead of falling through to ALL, keyed by
+// directory. Every entry names the suite that would catch a conflict in it, and
+// a tree nobody has placed here still widens, so the list grows by decision
+// rather than by default.
+const STANDALONE_TREES = new Map([
+ // A cargo workspace of its own (cli/Cargo.lock, outside rust/ and outside
+ // the pnpm workspace). ci-cli.yml also builds it from services/mcp sources,
+ // so the two trees have to share a lane.
+ ['cli', ['cli', 'svc:mcp']],
+ // Go service with its own CI. ci-hog.yml ignores livestream/** explicitly,
+ // so its Hog implementation is not covered by the shared hog suite either.
+ ['livestream', ['livestream']],
+ // Another standalone cargo workspace, and nothing in the dev or CI stack
+ // builds it: the UDF binary reaches ClickHouse through its image.
+ ['funnel-udf', ['funnel-udf']],
+ // Terragrunt definitions for dashboards and alerts. No suite compiles them,
+ // and terragrunt-posthog.yaml is the only workflow that reads the tree.
+ ['terraform', ['terraform']],
+ // ci-python.yml validates the policy files through the pr-approval-agent
+ // pytest suite, which already owns that lane.
+ ['.stamphog', ['tools:pr-approval-agent']],
+])
+
+// Editor, IDE, and agent configuration. No suite reads any of it, so one shared
+// lane between the lot costs nothing and keeps the inert set to files that
+// genuinely compile into nothing. Two trees stay off both lists: agent-os/ and
+// share/ hold only markdown today, which the prose rule already claims, and
+// anything else appearing there should widen until someone classifies it.
+//
+// .posthog-code is the entry that looks like an exception and is not. The
+// desktop app does parse .posthog-code/environments/*.toml, but it parses
+// whichever repository a user opens, and EnvironmentService's suite writes its
+// fixtures to a temp directory instead of reading this repository's copy. That
+// suite also covers a file being invalid TOML or off-schema, both of which the
+// service skips, so a config and a parser that disagree leave an environment
+// unlisted rather than failing anything. No suite here would catch the pair, so
+// sharing the desktop product's lane would serialize the two for no validation.
+const REPO_CONFIG_DIRS = [
+ '.claude',
+ '.codex',
+ '.cursor',
+ '.dagster_home',
+ '.husky',
+ '.idea',
+ '.interface-design',
+ '.posthog-code',
+ '.run',
+ '.vscode',
+ '.zed',
+]
+for (const dir of REPO_CONFIG_DIRS) {
+ STANDALONE_TREES.set(dir, ['repo-config'])
+}
+
// Supports the three forms used in TRIPWIRES: `**` spanning directories, `*`
// within a single path segment, and literal names. The two star forms are
// parked on placeholders first so neither rewrites the other's output.
@@ -555,10 +627,21 @@ function computeTargets(changedFiles, context) {
// a README under posthog/ into the backend lane.
//
// The exception is markdown that is a build input: `hogli build:skills`
- // zips products/*/skills/*, and ci-agent-skills.yml gates on those paths
- // and on .agents/. Both fall through to their directory rules below.
- const isSkillSource = top === '.agents' || (top === 'products' && segments[2] === 'skills')
- if (/\.mdx?$/.test(file) && !isSkillSource) {
+ // zips products/*/skills/*, ci-agent-skills.yml gates on those paths and
+ // on .agents/, and ci-python.yml runs the pr-approval-agent suite over
+ // .stamphog/. All of them fall through to their directory rules below.
+ const isBuildInput =
+ top === '.agents' || top === '.stamphog' || (top === 'products' && segments[2] === 'skills')
+
+ // The same suite reads every AGENT_APPROVALS.md wherever it sits, so the
+ // file belongs to that lane rather than to the tree holding it. On the
+ // product lane its own directory rule would give it, a policy change and
+ // a parser change would be free to merge in parallel.
+ if (segments[segments.length - 1] === 'AGENT_APPROVALS.md') {
+ targets.add('tools:pr-approval-agent')
+ continue
+ }
+ if (/\.mdx?$/.test(file) && !isBuildInput) {
inertFiles++
continue
}
@@ -598,6 +681,13 @@ function computeTargets(changedFiles, context) {
targets.add('agents')
continue
}
+ const standalone = STANDALONE_TREES.get(top)
+ if (standalone) {
+ for (const target of standalone) {
+ targets.add(target)
+ }
+ continue
+ }
if (top === 'tools') {
// A file sitting directly under tools/ rather than inside a tool's
// own directory is one of the CI-steering scripts (backend test
diff --git a/.github/scripts/trunk-impacted-targets.test.js b/.github/scripts/trunk-impacted-targets.test.js
index 69ba37bef0f5..1e308816389c 100644
--- a/.github/scripts/trunk-impacted-targets.test.js
+++ b/.github/scripts/trunk-impacted-targets.test.js
@@ -57,6 +57,15 @@ test('every tripwire forces ALL', () => {
'products/alpha/manifest.tsx',
'bin/start',
'.test_durations',
+ // Trees that steer what every suite runs or what it runs against: the
+ // Depot copies of the workflows, the toolchain, the service configs the
+ // stack mounts, and the lint rules that run repo-wide.
+ '.depot/workflows/ci-backend.yml',
+ '.flox/env/manifest.toml',
+ 'docker/clickhouse/config.d/default.xml',
+ 'devenv/duckgres.yaml',
+ '.semgrep/rules/security/prefer-codegen-api.yaml',
+ '.config/.markdownlint-cli2.jsonc',
]
for (const file of tripwireFiles) {
assert.equal(isTripwire(file), true, `${file} should be a tripwire`)
@@ -72,11 +81,77 @@ test('a tripwire anywhere in the change set forces ALL even alongside narrow fil
// target set reads to Trunk as "overlaps nothing", so the PR merges in parallel
// with everything. A new top-level directory must widen, never narrow.
test('an unmapped path forces ALL rather than an empty target set', () => {
- for (const file of ['terraform/main.tf', 'some-new-toplevel/thing.go', 'common/unrecognized/x.ts']) {
+ for (const file of [
+ 'some-new-toplevel/thing.go',
+ 'common/unrecognized/x.ts',
+ // agent-os/ and share/ hold nothing but markdown today, so a file that
+ // is not prose there is as unclassified as a brand new tree.
+ 'share/geoip.py',
+ 'agent-os/generate.py',
+ ]) {
assert.equal(computeTargets([file], CONTEXT), ALL, `${file} should force ALL`)
}
})
+// Each of these went to ALL only because no rule named the directory, which
+// serialized the PR against the whole repo for a change no suite outside its
+// own tree can see.
+test('standalone top-level trees hold a lane instead of widening', () => {
+ assert.deepEqual(computeTargets(['terraform/us/project-2/dashboards.tf'], CONTEXT), ['terraform'])
+ assert.deepEqual(computeTargets(['livestream/auth/jwt.go'], CONTEXT), ['livestream'])
+ assert.deepEqual(computeTargets(['funnel-udf/src/codec.rs'], CONTEXT), ['funnel-udf'])
+})
+
+// funnel-udf and cli are cargo workspaces of their own, outside rust/ and
+// outside its lockfile, so the crate graph must not be consulted for them.
+test('standalone cargo workspaces stay out of the rust crate lanes', () => {
+ const udf = computeTargets(['funnel-udf/src/codec.rs'], CONTEXT)
+ const rust = computeTargets(['rust/shared/src/lib.rs'], CONTEXT)
+ assert.deepEqual(
+ udf.filter((target) => rust.includes(target)),
+ []
+ )
+})
+
+// ci-cli.yml builds the CLI from services/mcp sources, so a lane of its own
+// would let an mcp change and the cli change that consumes it merge in
+// parallel.
+test('cli changes share a lane with the mcp service', () => {
+ const cli = computeTargets(['cli/src/main.rs'], CONTEXT)
+ const mcp = computeTargets(['services/mcp/src/index.ts'], CONTEXT)
+ assert.deepEqual(cli, ['cli', 'svc:mcp'])
+ assert.equal(
+ cli.some((target) => mcp.includes(target)),
+ true
+ )
+})
+
+// The pr-approval-agent suite reads both, and the policy files are markdown
+// that the prose rule would otherwise treat as inert.
+test('stamphog policy files claim the suite that validates them', () => {
+ assert.deepEqual(computeTargets(['.stamphog/policy.yml'], CONTEXT), ['tools:pr-approval-agent'])
+ assert.deepEqual(computeTargets(['.stamphog/review-guidance.md'], CONTEXT), ['tools:pr-approval-agent'])
+ // Wherever it sits, the file belongs to the suite rather than to the
+ // product tree holding it.
+ assert.deepEqual(computeTargets(['products/alpha/AGENT_APPROVALS.md'], CONTEXT), ['tools:pr-approval-agent'])
+ assert.deepEqual(
+ computeTargets(['.stamphog/policy.yml'], CONTEXT),
+ computeTargets(['tools/pr-approval-agent/policy.py'], CONTEXT)
+ )
+})
+
+// Editor and agent configuration no suite reads. One shared lane is enough:
+// these PRs are rare, and the alternative is a lane per tree for files that
+// cannot change any test's outcome.
+test('editor and agent configuration shares one lane', () => {
+ for (const file of ['.vscode/launch.json', '.zed/debug.json', '.husky/pre-commit', '.claude/settings.json']) {
+ assert.deepEqual(computeTargets([file], CONTEXT), ['repo-config'], file)
+ }
+ // Markdown in those trees is still prose, so a PR that only reorganizes an
+ // agent doc claims no lane at all.
+ assert.deepEqual(computeTargets(['.claude/agents/code-reviewer.md'], CONTEXT), ['prose'])
+})
+
test('globs match across directories only through **', () => {
assert.equal(globToRegExp('.github/**').test('.github/workflows/ci.yml'), true)
assert.equal(globToRegExp('products/*/manifest.tsx').test('products/alpha/manifest.tsx'), true)
@@ -398,8 +473,11 @@ test('independent trees stay disjoint so they can share no lane', () => {
const node = computeTargets(['nodejs/src/worker.ts'], CONTEXT)
const service = computeTargets(['services/mcp/src/index.ts'], CONTEXT)
const agents = computeTargets(['.agents/skills/merging-prs/SKILL.md'], CONTEXT)
+ const infra = computeTargets(['terraform/us/project-2/dashboards.tf'], CONTEXT)
+ const live = computeTargets(['livestream/auth/jwt.go'], CONTEXT)
+ const config = computeTargets(['.zed/debug.json'], CONTEXT)
- const sets = [rust, node, service, agents]
+ const sets = [rust, node, service, agents, infra, live, config]
for (let i = 0; i < sets.length; i++) {
for (let j = i + 1; j < sets.length; j++) {
const overlap = sets[i].filter((target) => sets[j].includes(target))