Skip to content

Commit 951b025

Browse files
claude[bot]claude
andauthored
build(trigger-record-change): graduate the package out of the TEST_DEBT ledger (#11489)
`check:type-check-debt --re-measure` reported TEST_DEBT 9 against a measured 0 for `@objectstack/trigger-record-change`. The 0 re-derived on current main (7f30b6b) and holds, so this is a graduation rather than a ceiling lowering. The gate's graduation message offers two remedies as interchangeable. Neither description fitted this package, and both halves were measured before choosing: * "add a `typecheck` script" — it already had one (`tsc --noEmit`). The hole was TESTS_COVERED (src checks, tests hidden by `**/*.test.ts` in the build tsconfig), not COVERED. * "drop the test exclusion" — resolves exactly the 10-file program the ledger scored at 0 (`tsc --showConfig`) and leaves `dist/` byte-identical, but the 7 re-admitted tests import @objectstack/driver-sql, /formula, /objectql and /service-automation, which the build config's program never held: `check:type-source-resolution` goes exit 0 -> exit 1 naming all four, against a shrink-only registry whose own message rules that widening the entry is not the fix. So it takes the sibling-config route the repo already uses for `packages/spec`, `client`, `metadata-core` and `metadata-fs`: a `tsconfig.test.json` named by the `typecheck` script, putting the same 10 files in front of tsc while the build config — the only one that gate reads — is untouched. The ledger entry is deleted in the same commit, as the gate's structural half requires. Claude-Session: https://claude.ai/code/session_015ahemw8RcTgqtxrj15PEZx Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5691b07 commit 951b025

3 files changed

Lines changed: 97 additions & 2 deletions

File tree

packages/triggers/trigger-record-change/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"build": "tsup --config ../../../tsup.config.ts",
1717
"test": "vitest run --passWithNoTests",
18-
"typecheck": "tsc --noEmit"
18+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json"
1919
},
2020
"dependencies": {
2121
"@objectstack/core": "workspace:*",
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// The TEST-layer type-check program (the #5286 mechanism `packages/spec` set and
2+
// PR #5546 / PR #5478 carried to `packages/client`, `packages/metadata-core` and
3+
// `packages/metadata-fs`). `tsconfig.json` beside this one stays exactly as it
4+
// is: it is the BUILD config, and `package.json`'s `typecheck` script NAMES this
5+
// sibling (`tsc --noEmit -p tsconfig.test.json`), because a config no script
6+
// invokes reads as coverage and delivers none.
7+
//
8+
// WHY THE SIBLING AND NOT THE ONE-LINE REMEDY. The type-check-debt gate offers
9+
// two remedies for a hidden test layer -- add a `typecheck` script, or drop the
10+
// `**/*.test.ts` exclusion from `tsconfig.json` -- and presents them as
11+
// interchangeable. For this package NEITHER description fits and the second one
12+
// is a red `main`, both measured before this file was written:
13+
//
14+
// - The `typecheck` script was ALREADY here (`tsc --noEmit`) and always had
15+
// been. This package was never in the "src does not check" hole; it was in
16+
// the "src checks, tests are hidden" one, which is the other ledger.
17+
// - Dropping the exclusion resolves a 10-file program (3 src + 7 tests, `tsc
18+
// --showConfig`) that is byte-for-byte the file set the ledger's re-measure
19+
// scored at 0, and the tsup build is unaffected (entry is `src/index.ts`
20+
// alone, so `dist/` comes out identical and no test file reaches it). It
21+
// still fails: those 7 tests import `@objectstack/driver-sql`,
22+
// `@objectstack/formula`, `@objectstack/objectql` and
23+
// `@objectstack/service-automation`, none of which the BUILD config's
24+
// program has ever contained, so `pnpm check:type-source-resolution` goes
25+
// from exit 0 to exit 1 -- "NEW dist-resolved type import(s) since this
26+
// entry was measured" -- against a registry that is SHRINK-ONLY and whose
27+
// own message rules that widening the entry is not the fix. That gate reads
28+
// each package's `tsconfig.json` and only that one, so the excluded region
29+
// put back HERE leaves its population unchanged.
30+
//
31+
// The remediation it actually asks for -- `paths` rules pointing those four
32+
// dependencies at their source -- is a separate card by that gate's own ruling
33+
// ("Remediation is per-package and lands as its own card, because the switch is
34+
// not free"), and this file does not pre-empt it.
35+
//
36+
// What differs from the build config, and what deliberately does NOT:
37+
// - `exclude` drops `**/*.test.ts` and nothing else. That single subtraction
38+
// IS the hole; `include` already names `src/**/*` and all 7 test files live
39+
// under it, so there is nothing to widen and no glob that could bill this
40+
// layer for a non-test file.
41+
// - `noEmit` is asserted rather than left to the CLI flag, so an editor's TS
42+
// server reading this config cannot emit into `dist/`.
43+
// - MODULE SEMANTICS ARE UNTOUCHED, unlike the `packages/spec` and
44+
// `packages/client` siblings. Those switched to `esnext`/`bundler` because
45+
// the inherited NodeNext compiled their ESM tests as CJS and reported
46+
// errors about the CHECK (TS2835, TS1470, TS2550). Nothing to fix here:
47+
// these tests use no `import.meta` and no extensionless cross-package
48+
// relative imports, and the whole layer compiles at 0 under the inherited
49+
// settings. Matching the program the ledger's 0 was measured over is the
50+
// point -- a different `module` would be a different measurement.
51+
// - `rootDir` IS UNTOUCHED, also unlike those siblings. It stays `./src`
52+
// because every test file is already under it: the re-measure reported
53+
// TS6059 x0, so there is no misconfiguration diagnostic to neutralise and
54+
// widening would only loosen which files may enter the program.
55+
// - STRICTNESS IS UNTOUCHED. `strict`, `noUnusedLocals`, `noUnusedParameters`,
56+
// `noImplicitReturns` and the rest are inherited from the root config.
57+
// Nothing here may loosen a type rule; if a test does not compile, that is
58+
// the finding.
59+
//
60+
// There is NO `test-typecheck-debt.json` beside this config, on purpose -- the
61+
// same call `packages/metadata-core` and `packages/metadata-fs` made. The whole
62+
// test layer compiles at ZERO errors, so a per-file shrink-only ledger would
63+
// hold nothing while costing this package a `tsx` dependency and two more
64+
// scripts. A bare `tsc --noEmit -p tsconfig.test.json` is the strictly stronger
65+
// gate at zero residue: ANY error here is red immediately, with no ledger to be
66+
// added to.
67+
{
68+
"extends": "./tsconfig.json",
69+
"compilerOptions": {
70+
"noEmit": true
71+
},
72+
"include": ["src/**/*"],
73+
"exclude": ["node_modules", "dist"]
74+
}

scripts/check-type-check-coverage.mjs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,28 @@ const EXEMPT = {
706706
// `@objectstack/cli` (146 raw across 65 files, after #8612 repaired the first
707707
// two of its 59 missing import extensions) is deliberately NOT part of that
708708
// graduation -- it is a programme rather than a sitting, and its entry stands.
709+
//
710+
// `@objectstack/trigger-record-change` GRADUATED from this ledger (entry: 9 raw
711+
// TS2353, re-measured 0). It is worth a line here because BOTH remedies the
712+
// graduation message above offers were wrong for it, and that message is what
713+
// the next taker will read:
714+
// - "add a `typecheck` script" -- it already had one, and always had. The
715+
// package was never in DEBT's hole ("src does not check"); it was in this
716+
// ledger's ("src checks, tests are hidden"), which is why the message's
717+
// first branch has nothing to do.
718+
// - "drop the test exclusion" -- MEASURED as a red `main`. It resolves
719+
// exactly the 10-file program this ledger's re-measure scored at 0 and
720+
// leaves `dist/` byte-identical (tsup builds `src/index.ts` alone), but the
721+
// 7 tests it re-admits import four workspace packages the BUILD config's
722+
// program never contained, and `check:type-source-resolution` goes 0 -> 1
723+
// naming them, against a registry that is shrink-only and whose own message
724+
// rules that widening the entry is not the fix.
725+
// So it took the #5286 sibling route (`tsconfig.test.json` named by the
726+
// `typecheck` script), which puts the same 10 files in front of tsc while
727+
// leaving `tsconfig.json` -- the only config that gate reads -- untouched. The
728+
// general lesson, which is this ledger's to carry: the two remedies are
729+
// interchangeable only where the excluded tests import nothing the src layer
730+
// does not, and that is a property to MEASURE per package, never to assume.
709731
const TEST_DEBT = {
710732
'@objectstack/plugin-approvals': {
711733
errors: 348,
@@ -952,7 +974,6 @@ const TEST_DEBT = {
952974
},
953975
'@objectstack/plugin-security': { errors: 11, note: 'TS2739 x8, TS2740 x5, TS2345/TS2322/TS2741 x2 each -- incomplete literals. Re-measured 21 at 5ab08428, up from 20, and still 21 at e8db1a230 after the package gained a test file -- the file count moved, the error count did not (which is why the file count is derived here rather than written down, #5826).' },
954976
'@objectstack/formula': { errors: 17, note: 'TS2591 x6 (`process`), TS2345 x3, TS2352 x3, TS1470 x2, TS2339 x2. Re-measured 17 at 5ab08428, up from 12; the TS2591 half doubled, which is the missing `types:["node"]` again rather than five new defects.' },
955-
'@objectstack/trigger-record-change': { errors: 9, note: 'TS2353 x9 -- still the one unknown-property shape repeated, now in four files. Re-measured 9 at 5ab08428, up from 8.' },
956977
'@objectstack/verify': { errors: 8, note: 'TS2835 x4, TS7006 x4. Re-measured 8 at 5ab08428, up from 6; both classes are the NodeNext pair from the top-of-ledger note.' },
957978
'@objectstack/connector-mcp': { errors: 5, note: 'TS2339 x5. Re-measured 5 at 5ab08428, exact.' },
958979
'@objectstack/connector-openapi': { errors: 5, note: 'TS2339 x5. Re-measured 5 at 5ab08428, exact.' },

0 commit comments

Comments
 (0)