: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(devex): stop trunk lanes over-claiming and under-claiming targets (#79779)
Georges-Antoine Assi35fe9db8b113
diff --git a/.github/scripts/trunk-impacted-targets.js b/.github/scripts/trunk-impacted-targets.jsindex 4eb2d18a8031..aa3137ccd468 100644--- a/.github/scripts/trunk-impacted-targets.js+++ b/.github/scripts/trunk-impacted-targets.js@@ -127,6 +127,12 @@ const RUST = 'rust'// those files can reach.const PRODUCT_SURFACE = 'product-surface'+// The three proto trees, named for their consumers for the same reason. Every+// consumer generates stubs from them, so the set is enumerable: tonic builds+// the rust ones on `cargo build`, and the personhog stubs are checked in for+// both python and nodejs.+const PROTO = 'proto'+// Resolved per file from the rule's own `languages:` declaration rather than// from its path, so it cannot be expressed as a static domain here.const SEMGREP = 'semgrep'@@ -146,9 +152,16 @@ const TRIPWIRE_RULES = [['.github/scripts/trunk-lane-telemetry*.js', UNIVERSAL],['.github/scripts/turbo-discover*.js', UNIVERSAL],['.github/workflows/trunk-impacted-targets.yml', UNIVERSAL],- ['tach.toml', UNIVERSAL],['turbo.json', UNIVERSAL],+ // tach.toml is one of those graphs, so it carries the same self-gating+ // hazard, but every edge it can move lands on a python lane: `tach check`+ // runs in ci-backend.yml, and the two readers of the graph, this script and+ // turbo-discover, use it only to cascade python product lanes. `python`+ // claims all of them, so a PR editing the graph still overlaps every PR+ // whose lanes were computed against the old one.+ ['tach.toml', PYTHON],+// A workflow decides which suites run, so one that defines a single// language's suite can be held to that language's lanes. Everything else// under .github/ stays universal: the list grows by decision, and a@@ -209,22 +222,40 @@ const TRIPWIRE_RULES = [// names are the ones a Python change can rename out from under it.['unit.json.tpl', PYTHON],- // Lockfiles and workspace manifests stay universal. pnpm-workspace.yaml- // lists frontend, nodejs, services, tools, products, and three rust node- // bindings, and pyproject.toml roots every product package, so a resolution- // change in either really does reach almost every lane. The telemetry says- // the same: a lockfile was the widening reason for one PR, against 26 for- // the CI and lint rules split above.- ['pnpm-lock.yaml', UNIVERSAL],- ['pnpm-workspace.yaml', UNIVERSAL],- ['package.json', UNIVERSAL],- ['uv.lock', UNIVERSAL],- ['pyproject.toml', UNIVERSAL],- ['requirements.txt', UNIVERSAL],- ['requirements-dev.txt', UNIVERSAL],- ['rust/Cargo.lock', UNIVERSAL],- ['rust/Cargo.toml', UNIVERSAL],- ['rust/.sqlx/**', UNIVERSAL],+ // The pnpm workspace's lockfile and manifests. A resolution change here can+ // red the python lanes, which install the root package and drive pytest+ // through `pnpm turbo run backend:test`, but a lane is not what catches+ // that: the ci-*.yml path filters decide what runs, so the break lands in+ // the PR's own run. A lane only has to hold the interaction with a second+ // PR, and the shape that reaches a python lane is lockfile drift against a+ // workspace package.json, which needs both PRs to edit pnpm-lock.yaml and+ // so surfaces as a textual conflict git forces a rebase for.+ ['pnpm-lock.yaml', JAVASCRIPT],+ ['pnpm-workspace.yaml', JAVASCRIPT],+ ['package.json', JAVASCRIPT],+ // The python lockfile and manifests, on the same reasoning. Every section+ // of pyproject.toml configures a python tool, and nothing in the pnpm+ // workspace or the cargo one resolves against either file: the two pyo3+ // crates install from PyPI rather than from this checkout, which the+ // uv.lock path-source test holds in place.+ ['uv.lock', PYTHON],+ ['pyproject.toml', PYTHON],+ // The cargo workspace's own lockfile and manifest. What kept them universal+ // was the three crates that are also pnpm packages, and the `rust` domain+ // now names the lanes consuming those, so the radius is covered without+ // claiming every lane in the repo. The workspace's two pyo3 crates do not+ // extend the radius the same way: hogql_parser_rs and deltalite-python are+ // published to PyPI by their own workflows and pinned by version in+ // pyproject.toml, so the python suites install a released wheel rather than+ // building either from this checkout. A resolution change reaches a python+ // lane only through the version bump, which is a pyproject.toml and uv.lock+ // edit claiming those lanes above. ci-rust.yml already narrows a lockfile+ // touch further, by diffing the resolved graph rather than rebuilding+ // everything, which is a step this script cannot take without a cargo+ // toolchain in the compute job.+ ['rust/Cargo.lock', RUST],+ ['rust/Cargo.toml', RUST],+ ['rust/.sqlx/**', RUST],['hogli.yaml', UNIVERSAL],['.github/**', UNIVERSAL],['docker-compose*.yml', UNIVERSAL],@@ -232,10 +263,9 @@ const TRIPWIRE_RULES = [// Decides what lands in the build context of every image built from the// repository root, so it belongs with the Dockerfiles above.['.dockerignore', UNIVERSAL],- ['proto/**', UNIVERSAL],- // schema.json generates posthog/schema.py, and both sides are committed.- ['frontend/src/queries/schema.json', UNIVERSAL],- ['posthog/schema.py', UNIVERSAL],+ ['proto/**', PROTO],+ ['frontend/src/queries/schema.json', PRODUCT_SURFACE],+ ['posthog/schema.py', PRODUCT_SURFACE],// A manifest publishes its product's urls, routes, and tree items into// globals any other product's frontend can reference, and build-products.mjs// compiles every manifest into products.json, which posthog/products.py@@ -253,14 +283,19 @@ const TRIPWIRE_RULES = [['products/*/manifest.tsx', PRODUCT_SURFACE],// Generates the frontend API types from the backend serializers, so a// change lands on both sides of the fe/py split at once.- ['tools/openapi-codegen/**', UNIVERSAL],+ ['tools/openapi-codegen/**', PRODUCT_SURFACE],// Ownership data read by the backend, frontend, and script suites alike.// The root owners.yaml is the fallback every path resolves through when no// nearer file claims it, so it has the same readers as the tooling. A// product's own owners.yaml is not here: it keeps its product lane.['tools/owners/**', UNIVERSAL],['owners.yaml', UNIVERSAL],- ['.test_durations', UNIVERSAL],+ // pytest-split timing data, and nothing else reads it.+ ['.test_durations', PYTHON],+ // Left universal: the quarantine list covers all three suites at once, and+ // playwright.quarantine.ts and replay-shared's jest.config.js read it+ // alongside pytest, so an entry for a flaky frontend test moves a+ // frontend lane.['.test_quarantine.json', UNIVERSAL],// bin/ appears in the backend, frontend, and E2E path filters alike.['bin/**', UNIVERSAL],@@ -920,7 +955,10 @@ function discoverRustCrates(repoRoot) {const text = fs.readFileSync(full, 'utf8')const name = parseCrateName(text)if (name) {- crates.push({ dir: relative, name, text })+ // A package.json beside the Cargo.toml means the crate also+ // builds an npm package, so its lane extends past rust/.+ const publishesNpmPackage = fs.existsSync(path.join(dir, 'package.json'))+ crates.push({ dir: relative, name, text, publishesNpmPackage })}}}@@ -1015,8 +1053,28 @@ function parseCrateDependencies(tomlText, crateNames) {return [...deps]}+// Dependencies no Cargo.toml declares, because they are not compile-time edges:+// the key crate spawns the listed ones as binaries at run time. The cargo graph+// cannot see that, so the reverse closure would stop short of the spawner and+// leave it free to merge in parallel with a change to a service it executes.+//+// Mirrors the [[package-rule]] on-affected block in+// rust/affected-services/determinator-rules.toml, which exists for this same+// blind spot on the CI side. The two lists have to be changed together, which a+// test asserts, and loadRustGraph gives up the whole graph rather than dropping+// an edge if a crate named here stops existing.+const RUNTIME_SPAWN_EDGES = new Map([+ [+ 'personhog-test-harness',+ ['personhog-replica', 'personhog-router', 'personhog-leader', 'personhog-writer', 'personhog-identity'],+ ],+])+// Returns null when the crate graph can't be built. Callers must treat null as-// "unknown dependents" and report every rust target, never as "no dependents".+// "unknown dependents" and widen to every target, never as "no dependents".+// Widening past the rust lanes is deliberate: without the graph the script+// cannot tell which crate a rust path belongs to either, so the rust targets+// alone would not be a superset of what the change can break.function loadRustGraph(repoRoot) {try {const crates = discoverRustCrates(repoRoot)@@ -1028,14 +1086,29 @@ function loadRustGraph(repoRoot) {for (const crate of crates) {dependsOn.set(crate.name, parseCrateDependencies(crate.text, crateNames))}+ // A crate renamed out from under the runtime map would otherwise drop+ // its edge silently, which is the under-reporting direction, so an+ // unresolvable entry gives up the whole graph instead.+ for (const [spawner, spawned] of RUNTIME_SPAWN_EDGES) {+ const unknown = [spawner, ...spawned].filter((crate) => !crateNames.has(crate))+ if (unknown.length > 0) {+ console.error(+ `Runtime spawn edges name crates that no longer exist (${unknown.join(', ')}); ` ++ 'widening to every target until RUNTIME_SPAWN_EDGES is updated'+ )+ return null+ }+ dependsOn.set(spawner, [...new Set([...dependsOn.get(spawner), ...spawned])])+ }+ const nativeBindings = new Set(crates.filter((crate) => crate.publishesNpmPackage).map((crate) => crate.name))// Longest directory first so rust/common/hogvm resolves to its own crate// rather than to rust/common.const byDir = crates.map((crate) => ({ dir: crate.dir, name: crate.name })).sort((a, b) => b.dir.length - a.dir.length)- return { dependsOn, byDir }+ return { dependsOn, byDir, nativeBindings }} catch (error) {- console.error(`Rust crate graph unavailable (${error.message}); reporting every rust target`)+ console.error(`Rust crate graph unavailable (${error.message}); widening to every target`)return null}}@@ -1071,6 +1144,13 @@ const pyProduct = (product) => `py:product:${product}`const feProduct = (product) => `fe:product:${product}`const rustCrate = (crate) => `rust:crate:${crate}`+// The lanes that import a native module built from the cargo workspace.+// nodejs/package.json is the only dependent of the three binding packages+// (@posthog/cyclotron, @posthog/hogvm-node, @posthog/replay-anonymizer) today,+// and the test suite re-derives that from pnpm-workspace.yaml so a second+// dependent fails there rather than silently going unclaimed here.+const NATIVE_BINDING_CONSUMER_LANES = ['node:ingestion']+// Every target this script can emit. A widening decision names this set instead// of the "ALL" sentinel, so the set intersection Trunk computes is unchanged// while the target list stays readable: the telemetry can show which lanes a@@ -1173,6 +1253,9 @@ function addJavaScriptLanes(targets, context) {// also claims the independent tools/ lanes. Those exist because the Python// toolchain spans tools/, and no tool in that list loads products.json or globs// the manifests.+//+// `query-schema` reaches the same set through different readers, so it shares+// this function while keeping its own domain name for the telemetry.function addProductSurfaceLanes(targets, context) {targets.add('py:core')targets.add('fe:core')@@ -1197,7 +1280,7 @@ function addRustLanes(targets, context) {// The nodejs lane on its own. No tripwire resolves to it, because a file that// can break the ingestion suite can almost always break more than that. The-// rust rules below still need to name it without dragging in the frontend.+// rust and proto rules still need to name it without dragging in the frontend.const NODE = 'node'function addNodeLanes(targets) {@@ -1205,12 +1288,27 @@ function addNodeLanes(targets) {return true}+// proto/README.md's consumer table is the source for this set, and the stubs+// themselves are the check on it: every consumer commits generated code, so a+// tree that reads a proto without one would be reading nothing. The nodejs half+// takes the node domain rather than the javascript one because the stubs land+// only in nodejs/src/common/generated; no frontend or services package imports+// them.+function addProtoLanes(targets, context) {+ if (!addRustLanes(targets, context)) {+ return false+ }+ addPythonLanes(targets, context)+ return addNodeLanes(targets)+}+const DOMAIN_LANES = new Map([[PYTHON, addPythonLanes],[JAVASCRIPT, addJavaScriptLanes],[RUST, addRustLanes],[NODE, addNodeLanes],[PRODUCT_SURFACE, addProductSurfaceLanes],+ [PROTO, addProtoLanes],])// Returns false when the file's domain is universal, which is the caller's cue@@ -1523,9 +1621,20 @@ function computeTargets(changedFiles, context) {const seeds = [...targets].filter((target) => target.startsWith('rust:crate:')).map((target) => target.slice('rust:crate:'.length))- for (const crate of reverseClosure(seeds, rustGraph.dependsOn)) {+ const affectedCrates = reverseClosure(seeds, rustGraph.dependsOn)+ for (const crate of affectedCrates) {targets.add(rustCrate(crate))}+ // A crate that also builds an npm package compiles into a native module+ // the JS workspace imports, so the closure does not end at rust/. The+ // dependents are found through package.json rather than Cargo.toml,+ // which is why the crate graph alone stops one edge short.+ const bindings = rustGraph.nativeBindings || new Set()+ if (affectedCrates.some((crate) => bindings.has(crate))) {+ for (const target of NATIVE_BINDING_CONSUMER_LANES) {+ targets.add(target)+ }+ }}if (targets.has('rust:unresolved')) {@@ -1640,8 +1749,10 @@ module.exports = {tripwireDomain,ALL,JAVASCRIPT,+ NATIVE_BINDING_CONSUMER_LANES,PYTHON,REPO_ROOT,+ RUNTIME_SPAWN_EDGES,RUST,UNIVERSAL,}diff --git a/.github/scripts/trunk-impacted-targets.test.js b/.github/scripts/trunk-impacted-targets.test.jsindex c12127140681..0179434765b6 100644--- a/.github/scripts/trunk-impacted-targets.test.js+++ b/.github/scripts/trunk-impacted-targets.test.js@@ -9,6 +9,8 @@const test = require('node:test')const assert = require('node:assert/strict')+const fs = require('node:fs')+const path = require('node:path')const {computeTargets,@@ -27,7 +29,10 @@ const {tripwireDomain,ALL,JAVASCRIPT,+ NATIVE_BINDING_CONSUMER_LANES,PYTHON,+ REPO_ROOT,+ RUNTIME_SPAWN_EDGES,RUST,UNIVERSAL,} = require('./trunk-impacted-targets')@@ -103,15 +108,9 @@ const WORKSPACE_CONTEXT = {// runs against.test('a universal tripwire claims every known target', () => {const tripwireFiles = [- 'pnpm-lock.yaml',- 'uv.lock',- 'rust/Cargo.lock',- 'tach.toml',- 'proto/events.proto',- 'frontend/src/queries/schema.json',- 'posthog/schema.py','bin/start',- '.test_durations',+ // Read by pytest, jest, and playwright alike, so no one domain holds it.+ '.test_quarantine.json',// 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 markdownlint config every tree's prose obeys.@@ -140,13 +139,57 @@ test('a change to the lane rules themselves stays universal', () => {'.github/scripts/trunk-lane-telemetry.js','.github/scripts/turbo-discover.js','.github/workflows/trunk-impacted-targets.yml',- 'tach.toml','turbo.json',]) {assert.deepEqual(computeTargets([file], CONTEXT), EVERYTHING, file)}})+// tach.toml is read by the lane rules too, so it carries the same hazard, but+// the only lanes its graph can move are python ones. Claiming them all still+// overlaps any PR whose lanes were computed against the previous graph.+test('the tach graph claims the python lanes rather than every lane', () => {+ assert.deepEqual(computeTargets(['tach.toml'], CONTEXT), computeTargets(['mypy.ini'], CONTEXT))+})++// A pnpm resolution change can red the python suites, which run through+// `pnpm turbo run backend:test`, but the PR's own CI run is what catches that.+// The interaction a lane exists to prevent needs a second PR editing the same+// lockfile, which git already stops as a textual conflict. The python side is+// the mirror image, and neither workspace resolves against the other's files.+// Only the root files narrow: a product's own manifests keep the product's lanes.+test('a lockfile claims its own toolchain rather than every lane', () => {+ for (const file of ['pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json']) {+ assert.deepEqual(computeTargets([file], CONTEXT), computeTargets(['.oxlintrc.json'], CONTEXT), file)+ }+ for (const file of ['uv.lock', 'pyproject.toml']) {+ assert.deepEqual(computeTargets([file], CONTEXT), computeTargets(['mypy.ini'], CONTEXT), file)+ }+ assert.equal(computeTargets(['products/alpha/package.json'], CONTEXT).includes('py:product:alpha'), true)+})++// Every consumer of a proto commits the stubs generated from it, so the set is+// enumerable rather than open-ended: tonic for the crates, and checked-in+// personhog stubs for python and nodejs. The frontend and services lanes are+// the ones this buys, and a new consumer tree has to fail here.+test('a proto claims its three consumer toolchains rather than every lane', () => {+ const targets = computeTargets(['proto/personhog/types/v1/person.proto'], CONTEXT)+ for (const target of ['py:core', 'py:product:alpha', 'rust:crate:shared', 'node:ingestion']) {+ assert.equal(targets.includes(target), true, target)+ }+ assert.equal(targets.includes('fe:core'), false)+ assert.equal(targets.includes('svc:mcp'), false)++ const generatedDirs = [+ 'posthog/personhog_client/proto/generated',+ 'nodejs/src/common/generated/personhog',+ 'rust/personhog-proto',+ ]+ for (const dir of generatedDirs) {+ assert.equal(fs.existsSync(path.join(REPO_ROOT, dir)), true, `${dir} is the stub tree its lane stands for`)+ }+})+// A tripwire held to one language claims every lane running that language and// nothing else, which is the whole point: a frontend lint rule no longer// serializes against Rust, and a backend one no longer serializes against the@@ -313,7 +356,7 @@ test('the widest tripwire in a change set wins', () => {assert.equal(scoped.includes('py:product:alpha'), true)assert.equal(scoped.includes('fe:core'), false)// A universal one still swallows everything.- assert.deepEqual(computeTargets(['products/alpha/backend/api.py', 'pnpm-lock.yaml'], CONTEXT), EVERYTHING)+ assert.deepEqual(computeTargets(['products/alpha/backend/api.py', 'hogli.yaml'], CONTEXT), EVERYTHING)})// The single most dangerous failure mode: an unclaimed path yielding an empty@@ -397,7 +440,7 @@ test('an incomplete context falls back to the ALL sentinel', () => {})test('tripwire domains are reported for telemetry', () => {- assert.equal(tripwireDomain('pnpm-lock.yaml'), UNIVERSAL)+ assert.equal(tripwireDomain('hogli.yaml'), UNIVERSAL)assert.equal(tripwireDomain('.oxlintrc.json'), JAVASCRIPT)assert.equal(tripwireDomain('mypy.ini'), PYTHON)assert.equal(tripwireDomain('.github/workflows/ci-rust.yml'), RUST)@@ -505,6 +548,153 @@ test('a rust path outside every known crate widens', () => {assert.deepEqual(computeTargets(['rust/not-a-crate/file.rs'], CONTEXT), EVERYTHING)})+// A binding crate compiles into a native module the JS workspace imports, so+// the lane cannot stop at rust/. A PR changing the binding and a PR changing+// its caller in nodejs/ must not come out disjoint.+test('a crate that builds an npm package claims the lanes importing it', () => {+ const bindingContext = {+ ...CONTEXT,+ rustGraph: { ...CONTEXT.rustGraph, nativeBindings: new Set(['consumer']) },+ }+ // Reached through the closure rather than directly: `shared` is not itself a+ // binding, but what it compiles into ships inside one.+ const viaDependency = computeTargets(['rust/shared/src/lib.rs'], bindingContext)+ assert.equal(viaDependency.includes('node:ingestion'), true)++ const direct = computeTargets(['rust/consumer/src/lib.rs'], bindingContext)+ assert.equal(direct.includes('node:ingestion'), true)++ // A crate no binding depends on keeps its own lane.+ const unrelated = computeTargets(['rust/unrelated/src/main.rs'], bindingContext)+ assert.deepEqual(unrelated, ['rust:crate:unrelated'])+})++// The cargo lockfile, the manifest, and the sqlx offline data resolve nothing+// outside the cargo workspace, so the lanes they can break are the rust ones+// plus whatever reaches them through a native module, rather than every lane in+// the repo.+test('the cargo workspace tripwires claim the rust lanes rather than every lane', () => {+ const bindingContext = {+ ...CONTEXT,+ rustGraph: { ...CONTEXT.rustGraph, nativeBindings: new Set(['consumer']) },+ }+ for (const file of ['rust/Cargo.lock', 'rust/Cargo.toml', 'rust/.sqlx/query-0a1b.json']) {+ const targets = computeTargets([file], bindingContext)+ assert.equal(isTripwire(file), true, `${file} should still be a tripwire`)+ assert.deepEqual(+ targets.filter((target) => target.startsWith('rust:crate:')),+ ['rust:crate:consumer', 'rust:crate:shared', 'rust:crate:unrelated'],+ `${file} should claim every crate`+ )+ assert.equal(targets.includes('node:ingestion'), true, `${file} reaches the native module consumers`)+ assert.equal(targets.includes('py:core'), false, `${file} should not claim the python lanes`)+ assert.equal(targets.includes('fe:core'), false, `${file} should not claim the frontend lanes`)+ }+})++// The two lists below are the same rule written twice, once for the merge queue+// and once for CI's selective builds. Nothing but this test stops them drifting,+// and the failure is silent in both directions: an edge the queue drops lets two+// conflicting PRs merge in parallel.+test('the runtime spawn edges match the determinator package rules', () => {+ const rulesToml = fs.readFileSync(path.join(REPO_ROOT, 'rust/affected-services/determinator-rules.toml'), 'utf8')+ const names = (block, key) => {+ const match = block.match(new RegExp(`${key}\\s*=\\s*\\[([^\\]]*)\\]`))+ return match ? [...match[1].matchAll(/"([^"]+)"/g)].map((m) => m[1]).sort() : []+ }+ const packageRules = rulesToml+ .split(/^\s*\[\[package-rule\]\]\s*$/m)+ .slice(1)+ .map((block) => ({ onAffected: names(block, 'on-affected'), markChanged: names(block, 'mark-changed') }))++ const fromScript = [...RUNTIME_SPAWN_EDGES]+ .map(([spawner, spawned]) => ({ onAffected: [...spawned].sort(), markChanged: [spawner] }))+ .sort((a, b) => a.markChanged[0].localeCompare(b.markChanged[0]))+ const fromRules = packageRules.sort((a, b) => a.markChanged[0].localeCompare(b.markChanged[0]))++ assert.deepEqual(fromScript, fromRules)+})++// The consumer lanes are declared rather than derived, so a second dependent+// appearing anywhere in the pnpm workspace has to fail here. Reads the real+// workspace for that reason: a synthetic one cannot notice the new dependent.+test('nodejs is still the only workspace package importing a rust binding', () => {+ const workspaceGlobs = parseWorkspacePackageGlobs(+ fs.readFileSync(path.join(REPO_ROOT, 'pnpm-workspace.yaml'), 'utf8')+ )+ // pnpm's package globs are one level deep, so a trailing /* expands by+ // listing the directory. Negations exclude a package rather than add one.+ const expand = (glob) => {+ if (glob.startsWith('!')) {+ return []+ }+ if (!glob.endsWith('/*')) {+ return [glob]+ }+ const parent = path.join(REPO_ROOT, glob.slice(0, -2))+ if (!fs.existsSync(parent)) {+ return []+ }+ return fs+ .readdirSync(parent, { withFileTypes: true })+ .filter((entry) => entry.isDirectory())+ .map((entry) => path.posix.join(glob.slice(0, -2), entry.name))+ }+ const packageDirs = workspaceGlobs.flatMap(expand)++ const bindingPackages = new Set()+ for (const dir of packageDirs) {+ if (!dir.startsWith('rust/')) {+ continue+ }+ const manifest = path.join(REPO_ROOT, dir, 'package.json')+ if (fs.existsSync(manifest)) {+ bindingPackages.add(JSON.parse(fs.readFileSync(manifest, 'utf8')).name)+ }+ }+ assert.ok(bindingPackages.size > 0, 'expected the rust workspace to publish npm packages')++ const dependentDirs = []+ for (const dir of packageDirs) {+ if (dir.startsWith('rust/')) {+ continue+ }+ const manifest = path.join(REPO_ROOT, dir, 'package.json')+ if (!fs.existsSync(manifest)) {+ continue+ }+ const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'))+ const deps = { ...pkg.dependencies, ...pkg.devDependencies, ...pkg.optionalDependencies }+ if (Object.keys(deps).some((name) => bindingPackages.has(name))) {+ dependentDirs.push(dir)+ }+ }+ assert.deepEqual(+ dependentDirs.sort(),+ ['nodejs'],+ `NATIVE_BINDING_CONSUMER_LANES (${NATIVE_BINDING_CONSUMER_LANES.join(', ')}) must cover every dependent`+ )+})++// The cargo lockfile claims no python lane, which holds only while every python+// package resolves from a registry. The workspace does contain two pyo3 crates,+// and the python suites install them as released wheels pinned by version, so a+// cargo resolution change cannot reach a python lane without a pyproject.toml+// and uv.lock bump that is universal anyway. Switching either to a local build+// would break that, and it would break it silently, so it has to fail here.+test('no python package is built from a path inside the cargo workspace', () => {+ const lock = fs.readFileSync(path.join(REPO_ROOT, 'uv.lock'), 'utf8')+ const localSources = [...lock.matchAll(/source = \{ (?:editable|directory|path|virtual) = "([^"]+)"/g)].map(+ (match) => match[1]+ )+ assert.notEqual(localSources.length, 0, 'uv.lock parse produced nothing, so the assertion below is vacuous')+ assert.deepEqual(+ localSources.filter((source) => source.startsWith('rust/')),+ [],+ 'a python package built from rust/ needs its lanes added to the rust/Cargo.lock tripwire'+ )+})+// The crate lanes are the ceiling for anything configuring the workspace as a// whole, and a file sitting at rust/ is that by construction: the Dockerfiles// its images build from, the compose stack, the dotfiles, the license.@@ -1019,11 +1209,16 @@ test('CI-steering scripts directly under tools/ widen', () => {assert.deepEqual(computeTargets(['tools/snob_backend_test_selection_shadow.py'], CONTEXT), EVERYTHING)})-// Both sit on the fe/py boundary: openapi-codegen generates the frontend types-// from backend serializers, and owners is read by both suites.+// Both are tripwires rather than falling through to the tools/ rule, which+// would give them the python product lanes and nothing else. openapi-codegen+// generates the frontend types from the backend serializers, so it claims both+// sides of the fe/py split, and owners is read by both suites.test('cross-domain tools are tripwires rather than backend-only', () => {- assert.deepEqual(computeTargets(['tools/openapi-codegen/config.ts'], CONTEXT), EVERYTHING)- assert.deepEqual(computeTargets(['tools/owners/owners/__init__.py'], CONTEXT), EVERYTHING)+ assert.deepEqual(+ computeTargets(['tools/openapi-codegen/config.ts'], CONTEXT),+ computeTargets(['frontend/src/products.json'], CONTEXT)+ )+ assert.deepEqual(computeTargets(['tools/owners/posthog_owners/__init__.py'], CONTEXT), EVERYTHING)})// Prose overlaps only other prose, and has to reach that lane through thediff --git a/.github/scripts/trunk-lane-telemetry.test.js b/.github/scripts/trunk-lane-telemetry.test.jsindex 1a68f213db01..c41ff9a0a242 100644--- a/.github/scripts/trunk-lane-telemetry.test.js+++ b/.github/scripts/trunk-lane-telemetry.test.js@@ -55,7 +55,7 @@ test('the ALL sentinel still reports no targets but is flagged', () => {// its weight, and it is not recoverable from the paths alone once the split// exists.test('tripwire domains are counted alongside the files', () => {- const props = buildProperties(['.oxlintrc.json', 'mypy.ini', 'pnpm-lock.yaml'], UNIVERSE, UNIVERSE)+ const props = buildProperties(['.oxlintrc.json', 'mypy.ini', 'hogli.yaml'], UNIVERSE, UNIVERSE)assert.deepEqual(props.tripwire_domains, { javascript: 1, python: 1, universal: 1 })})diff --git a/proto/README.md b/proto/README.mdindex 4b6eccf5db5a..ccf01a011fa9 100644--- a/proto/README.md+++ b/proto/README.md@@ -18,11 +18,11 @@ proto/## Consumers-| Proto | Rust | Python |-| ----------------- | -------------------------------------------- | -------------------------------------------------------- |-| `cymbal/` | `rust/cymbal-proto` (auto via tonic) | — |-| `personhog/` | `rust/personhog-proto` (auto via tonic) | `posthog/personhog_client/proto/generated/` (checked in) |-| `kafka_assigner/` | `rust/kafka-assigner-proto` (auto via tonic) | — |+| Proto | Rust | Python | Node.js |+| ----------------- | -------------------------------------------- | -------------------------------------------------------- | ---------------------------------------------------- |+| `cymbal/` | `rust/cymbal-proto` (auto via tonic) | — | — |+| `personhog/` | `rust/personhog-proto` (auto via tonic) | `posthog/personhog_client/proto/generated/` (checked in) | `nodejs/src/common/generated/personhog` (checked in) |+| `kafka_assigner/` | `rust/kafka-assigner-proto` (auto via tonic) | — | — |## Updating protosdiff --git a/rust/affected-services/determinator-rules.toml b/rust/affected-services/determinator-rules.tomlindex 989a2511a09d..a6285bfd24c1 100644--- a/rust/affected-services/determinator-rules.toml+++ b/rust/affected-services/determinator-rules.toml@@ -94,6 +94,10 @@ mark-changed = []# deps like personhog-proto flow through the graph already). Mark the# harness affected whenever a service it spawns changes so the CI gate# runs against those changes.+#+# The merge queue needs the same edge to keep a harness change out of a lane+# parallel to one of these services, so it is mirrored in RUNTIME_SPAWN_EDGES in+# .github/scripts/trunk-impacted-targets.js. Change both; a test compares them.[[package-rule]]on-affected = ["personhog-replica",