From 56067ee0550106ea249ce447371fae405a0f7939 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 8 Sep 2026 15:16:38 +0000 Subject: [PATCH] fix(formula): give the test-typecheck program the node typings its two fixture-loading tests already assumed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `packages/formula` declared no `@types/node` and its test program named no `types`, so `node:fs` / `node:path` / `node:url` and `import.meta.url` never resolved in `tsconfig.test.json`. Adds the devDependency and the `types` entry, and re-records the shrink-only ledger. Ledger, measured on this branch with NO test file edited: before 5 file(s) / 15 error(s) / 12 pinned signature(s) after 3 file(s) / 7 error(s) / 4 pinned signature(s) The card's title generalised the cause to all 15; measured, it is 8 of the 15 — the whole of src/rls-predicate.test.ts and src/skill-catalog-sync.test.ts, which both GRADUATED. The surviving 7 are three unrelated classes in three other files and are not this cause. `tsconfig.json` — the BUILD config — is untouched, per its sibling's recorded rationale, and `packages/formula/dist` is byte-identical across the change (6 files, per-file sha256). Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01ADLdAs2pVcH17h9tZKWMBg --- packages/formula/package.json | 1 + packages/formula/test-typecheck-debt.json | 13 +----- packages/formula/tsconfig.test.json | 51 ++++++++++++++++++++--- pnpm-lock.yaml | 3 ++ 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/packages/formula/package.json b/packages/formula/package.json index 245d12721f..20d659f2b0 100644 --- a/packages/formula/package.json +++ b/packages/formula/package.json @@ -24,6 +24,7 @@ "@objectstack/spec": "workspace:*" }, "devDependencies": { + "@types/node": "^26.2.0", "typescript": "^6.0.3", "vitest": "^4.1.10" }, diff --git a/packages/formula/test-typecheck-debt.json b/packages/formula/test-typecheck-debt.json index 4ae4c5e935..00555be02e 100644 --- a/packages/formula/test-typecheck-debt.json +++ b/packages/formula/test-typecheck-debt.json @@ -1,5 +1,6 @@ { "_comment": "Per-file tsc error debt of the @objectstack/formula TEST layer (#5286). `tsconfig.test.json` compiles `src/**/*.test.ts` — which `tsconfig.json` excludes and therefore no gate ever read — and every file below still carries errors from before that gate existed. THIS FIELD IS GENERATED: every regeneration rewrites it from scripts/check-test-typecheck.mts, and the EXACT ratchet below requires a regeneration on every repair — so an edit made here is gone by the next one. Anything true of THIS package goes in the sibling `_note` field, which is authored, is preserved verbatim, and is never written by the generator (#12624). This comment states NO cause for the errors, deliberately: the classes differ per package and per file, they move as the debt is paid down, and a cause written here is rewritten verbatim into every ledger by every regeneration — so it outlives its own repair and cannot be corrected in the file where it is read. Measure instead, before repairing anything: `tsc --noEmit --pretty false -p tsconfig.test.json` in the package prints the real classes with their TS codes. Each entry maps a file to its per-SIGNATURE error counts, never to a bare total (#13470): a signature is the TS code plus the diagnostic message with structural type blobs collapsed, and it carries NO line or column — so the pin survives edits that move code around, and only stops matching when the error itself becomes a different error. EXACT ratchet, judged by re-running tsc: a file that gains errors is red, a file that loses them is red until its number is re-recorded, a file that reaches zero is red until its entry is deleted, a signature that ARRIVES or VANISHES is red even when the file total is unchanged, and a file NOT listed here may have no errors at all. Regenerate with: pnpm --filter @objectstack/formula gen:test-typecheck-debt", + "_note": "#16297 paid down 8 of the 15 errors this ledger held, with NO test file edited: `@types/node` became a devDependency of this package and `tsconfig.test.json` gained `\"types\": [\"node\"]`, so the node typings finally reach the TEST program. `tsconfig.json` — the BUILD config — was deliberately not touched, and `packages/formula/dist` was measured byte-identical across the change. The 8 were the entire content of `src/rls-predicate.test.ts` and `src/skill-catalog-sync.test.ts`: TS2591 x6 naming `node:fs` / `node:path` / `node:url` as bare specifiers, and TS2339 x2 reading `import.meta.url`. Both files GRADUATED, so their entries are gone from `entries` and any error either of them gains is now red on arrival. WHAT THAT CARD GOT WRONG, recorded here because the number will outlive the card: it was titled \"15 of its test-typecheck ledger errors have one cause\", and measured, the cause was 8 of the 15 — exactly the set `tsconfig.test.json`'s header had named all along, before the card generalised it to the file total. The entries that remain are three unrelated classes in three other files (TS2739 in cel-to-filter, TS2345 in matches-filter-temporal-conformance, TS2352 in normalize); none of them is the node-typings cause and none was expected to move. The separating measurement is cheap and repeatable: `tsc --noEmit --pretty false -p tsconfig.test.json --types node`, run on the pre-repair tree with no package-local devDependency at all, already reported exactly these same 7.", "entries": { "src/cel-to-filter.test.ts": { "TS2739: Type '…' is missing the following properties from type '…': id, organization_id, team_member_ids, department": 1 @@ -10,18 +11,6 @@ }, "src/normalize.test.ts": { "TS2352: Conversion of type '…' to type '…' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.": 3 - }, - "src/rls-predicate.test.ts": { - "TS2339: Property 'url' does not exist on type 'ImportMeta'.": 1, - "TS2591: Cannot find name 'node:fs'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.": 1, - "TS2591: Cannot find name 'node:path'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.": 1, - "TS2591: Cannot find name 'node:url'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.": 1 - }, - "src/skill-catalog-sync.test.ts": { - "TS2339: Property 'url' does not exist on type 'ImportMeta'.": 1, - "TS2591: Cannot find name 'node:fs'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.": 1, - "TS2591: Cannot find name 'node:path'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.": 1, - "TS2591: Cannot find name 'node:url'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.": 1 } } } diff --git a/packages/formula/tsconfig.test.json b/packages/formula/tsconfig.test.json index 55dcec61a1..e06caaf7a4 100644 --- a/packages/formula/tsconfig.test.json +++ b/packages/formula/tsconfig.test.json @@ -73,17 +73,58 @@ // one that loses one is red until re-recorded, one that reaches zero is red // until its entry is deleted, a signature that ARRIVES or VANISHES is red even // at an unchanged file total, and a file NOT listed there may have no errors at -// all. 24 of the 29 files carry no entry, so any error any of them gains is red -// on arrival. This layer holds ZERO `@ts-expect-error` directives (grepped with -// a positive control — the same grep hits `packages/spec/src`), so no pin here -// was silently dead. +// all. At 6a1e38244, 24 of the 29 files carried no entry, so any error any of +// them gains is red on arrival. This layer holds ZERO `@ts-expect-error` +// directives (grepped with a positive control — the same grep hits +// `packages/spec/src`), so no pin here was silently dead. +// +// ⭐ REPAIRED (#16297) — the repair the paragraph above described as real and +// deliberately deferred. `@types/node` is now a devDependency of this package +// and this file names `"types": ["node"]`. It goes HERE and not in +// `tsconfig.json` for the reason this header opens with: that file is the BUILD +// config and stays exactly as it is. Measured, not assumed: `packages/formula/ +// dist` is byte-identical across the change (6 files, sha256 per file, built +// before and after on the same tree), so nothing published moves and the test +// program alone gains the typings its two fixture-loading tests already assumed. +// Ledger effect, with NO test file edited: 15 -> 7 errors, 5 -> 3 files, +// 12 -> 4 signatures. 26 of the 29 files now carry no entry. +// +// ⚠️ A COUNT CORRECTION that repair earned in its turn. #16297 is titled +// "15 of its test-typecheck ledger errors have one cause". Measured here, the +// node-typings cause is **8 of the 15** — precisely the TS2591 x6 + TS2339 x2 +// named in the paragraph above, confined to `src/rls-predicate.test.ts` and +// `src/skill-catalog-sync.test.ts`. That paragraph always said 8; the card +// generalised it to the file total. The 7 that SURVIVE are three unrelated +// classes in three OTHER files — TS2739 x1 (`src/cel-to-filter.test.ts`), +// TS2345 x3 (`src/matches-filter-temporal-conformance.test.ts`), TS2352 x3 +// (`src/normalize.test.ts`) — and none of them is this cause. +// +// ⚠️ `types` REPLACES rather than merges, exactly like the `paths` note above, +// so naming `["node"]` also ENDS whatever automatic `@types/*` inclusion this +// program had. Measured before naming it: the only package in the reachable +// `node_modules/@types` is `node` itself, and the ledger reading above is the +// proof that the replacement subtracted nothing. +// +// ⚠️ OF THE TWO LINES, THIS ONE IS THE LOAD-BEARING ONE, and the pair was +// measured in both directions on a fully built closure rather than reasoned +// about. `tsc -p tsconfig.test.json --types node` with NO package-local +// devDependency at all already reports 7 — the entry alone does the whole job, +// resolving `@types/node` from the root hoist. The complementary leg is the one +// worth knowing: the devDependency WITHOUT this entry reports 15, unchanged, +// so ⛔ adding `@types/node` to `package.json` on its own would have been a +// no-op that looked like a repair. The devDependency earns its line by making +// the dependency declared instead of borrowed, and it is the pairing +// `packages/spec` (#5286), `packages/verify`, `packages/cli` and +// `packages/drivers/driver-mongodb` all use. + { "extends": "./tsconfig.json", "compilerOptions": { "noEmit": true, "module": "esnext", "moduleResolution": "bundler", - "lib": ["ES2022"] + "lib": ["ES2022"], + "types": ["node"] }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4cdfa54ea0..8393cb6cd6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1099,6 +1099,9 @@ importers: specifier: workspace:* version: link:../spec devDependencies: + '@types/node': + specifier: ^26.2.0 + version: 26.2.0 typescript: specifier: ^6.0.3 version: 6.0.3