From 8f39559792d1d00823adfb5b139d0c387108eff9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Oct 2026 05:21:38 +0000 Subject: [PATCH] test(client): the envelope caller census never enters `.cache/` `pnpm objectui:build` shallow-clones objectui into `.cache/objectui-/` when there is no `../objectui` sibling. The census walk started at the repo root and skipped only build and VCS directories, so it counted objectui's own SDK call site as a 29th site of this repo and three section-3 assertions went red on an untouched main. Add `.cache` to SKIP_DIRS, the house skip-set shape most repo walkers here already carry, and pin it in section 1 on a throwaway temp root: a planted `.cache/objectui-*` checkout leaves the sites, their receiver split and the files scanned unchanged, with a positive control proving the same walk counts the planted site once it is handed it. Claude-Session: https://claude.ai/code/session_01RWZbGvPFcRKvUqASZtunCU Co-Authored-By: Claude --- .../client/src/envelope-caller-census.test.ts | 53 ++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/packages/client/src/envelope-caller-census.test.ts b/packages/client/src/envelope-caller-census.test.ts index be1811eb8bd..cbf54580cb8 100644 --- a/packages/client/src/envelope-caller-census.test.ts +++ b/packages/client/src/envelope-caller-census.test.ts @@ -125,7 +125,8 @@ */ import { describe, it, expect } from 'vitest'; -import { readdirSync, readFileSync, statSync } from 'node:fs'; +import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; import { dirname, join, relative, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; // The `.mjs` specifier is deliberate; `scripts/js-comment-mask.d.mts` beside it @@ -163,8 +164,19 @@ const METHODS: ReadonlyArray = [ ['automation', 'trigger'], ]; +/** + * Directory NAMES the walk never enters, at any depth. + * + * [#22153] `.cache` is here because `pnpm objectui:build` (`scripts/build-console.sh`) + * shallow-clones the whole objectui source tree into `.cache/objectui-/` when + * there is no `../objectui` sibling, and that tree carries objectui's own SDK + * call site. Walked, it is counted as a site of THIS repo and §3 reds on an + * untouched `main` for anyone who followed the Console build. `.cache/` is + * gitignored and no tracked path has a `.cache` segment, so skipping it drops + * nothing this census is about. §1 pins it on a planted checkout. + */ const SKIP_DIRS = new Set([ - 'node_modules', 'dist', 'build', 'coverage', '.git', '.next', '.turbo', 'out', + 'node_modules', 'dist', 'build', 'coverage', '.git', '.next', '.turbo', 'out', '.cache', ]); const CODE_EXT = /\.(ts|tsx|js|mjs|cjs)$/; @@ -657,6 +669,43 @@ describe('#13079 §1 — the population actually swept', () => { expect(tops.has('examples')).toBe(true); expect(tops.has('apps')).toBe(true); }); + + it('[#22153] never enters `.cache/` — an objectui checkout left by `pnpm objectui:build` moves no count', () => { + // Assembled from parts for the reason §6 gives: this file is inside the + // walked tree, so a call shape spelled whole here would BE a counted site. + const NS = 'analytics'; + const OWN = `export const rows = async (client: any) => (await client.${NS}.query({ cube: 'orders' })).rows;\n`; + const CHECKOUT = `export class Adapter {\n client: any;\n async aggregate(q: unknown) {\n return this.client.${NS}.query(q);\n }\n}\n`; + const shape = (c: Census) => c.sites.map((s) => [s.file, s.method, s.receiver]); + + // A throwaway root under the system temp directory, never this repo's own + // `.cache/`: planting there would race every other walker in a parallel run. + const root = mkdtempSync(join(tmpdir(), 'os-census-cache-')); + try { + mkdirSync(join(root, 'packages', 'client', 'src'), { recursive: true }); + writeFileSync(join(root, 'packages', 'client', 'src', 'own.test.ts'), OWN); + const before = scanCallSites(root); + expect(shape(before)).toEqual([['packages/client/src/own.test.ts', 'analytics.query', 'sdk']]); + + // `build-console.sh` names its clone `.cache/objectui-<12-hex sha>`. + const checkout = join(root, '.cache', 'objectui-0123456789ab'); + mkdirSync(join(checkout, 'packages', 'data-objectstack', 'src'), { recursive: true }); + writeFileSync(join(checkout, 'packages', 'data-objectstack', 'src', 'index.ts'), CHECKOUT); + + // Positive control: the same walk and matcher DO count the planted + // site once they are handed it, so the equality below is the skip at + // work and not a fixture the census could never have read. + expect(shape(scanCallSites(checkout))).toEqual([ + ['packages/data-objectstack/src/index.ts', 'analytics.query', 'sdk'], + ]); + + // THE PIN: sites, their receiver split and the files scanned are all + // unchanged with the checkout present. + expect(scanCallSites(root)).toEqual(before); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }); }); describe('#13079 §2 — positive controls on the matcher itself', () => {