Skip to content

Commit eb93349

Browse files
os-muskclaude
andauthored
docs(drivers): measure the ContainsAny phantom-leg sweep across eight door pins (#17967)
Fixes #17879 Clause-②: no A **measurement** card, not a defect sweep. Every reading below was taken on disk against `origin/main@bdb247d`, control first, with each leg's direction predicted before it was run. ## Headline **No detector was swapped, anywhere — and that is the measured result, not a gap.** The phantom half is real on all eight doors. The `ContainsAny` template landed by #17876 closes **none** of them: seven are defeated by one mechanism, and the eighth is already masked today. ## The mechanism, measured `ContainsAny` distributes over a union, because `T` is naked in its array/record arms. So a door that is a union answers `boolean`, and **both** of the family's assertion forms accept `boolean`: ```text const leg: boolean = false compiles -> the `= false` half stays GREEN boolean extends true ? never : X picks X -> the conditional half stays GREEN ``` Calibration, measured twice in independent runs (a line that errors = that leg reddens): ```text shape IsAny leg ContainsAny leg any (bare) RED RED <- control fires any[] green RED <- template works Record[string, any] green RED <- template works Record[string, any] | null green GREEN <- template INERT Record[string, any] | undefined green GREEN <- template INERT any[] | undefined green GREEN <- template INERT ``` Seven of my eight doors are unions — either a not-found arm (`| null`) or an optional parameter (`| undefined`). That is why the swap buys nothing on them. ## Per-file measurement `resolves to` is read off the door itself; `CONTROL` puts that door back to a **bare** `any`; `NESTED` puts it back to a nested one. Counts are errors **in that file**. | # | file | door resolves to | CONTROL (bare any) | NESTED | swap? | |---|---|---|---|---|---| | 1 | `sql-driver-distinct-filter-narrowing` | `FilterCondition \| undefined` | **3 errors** — fires | **0** | no — union **and** saturated | | 2 | `sql-driver-update-declared-null` | `Record[string, unknown] \| null` | **2 errors** — fires | **1** (`Equals` only) | no — union | | 3 | `sqlite-wasm-16711-inherited-object-def-keys` | nested `any` **today** (see below) | **7 errors** — fires | n/a | no — RED on `main` | | 4 | `sqlite-wasm-distinct-filter-narrowing` | `FilterCondition \| undefined` | **2 errors** — fires | **0** | no — union **and** saturated | | 5 | `sqlite-wasm-update-declared-null` | `Record[string, unknown] \| null` | **2 errors** — fires | **1** (`Equals` only) | no — union | | 6 | `turso-driver-options-door` (17 doors) | `DriverOptions \| undefined` | row reds (TS1360) — fires | **0** | no — union | | 7 | `turso-driver-update-declared-null` | `Record[string, unknown] \| null` | **2 errors** — fires | **1** (`Equals` only) | no — union | | 8 | `turso-update-missing-id` | `Record[string, unknown] \| null` | **2 errors** — fires | **1** (`Equals` only) | no — union | **The control fired on all eight**, so no reading here is void. In every NESTED run a shadow `ContainsAny` leg was compiled alongside the real one: it stayed green in all seven applicable cases, which is the direct measurement that the swap would have bought nothing. Files 1 and 4 carry a second, independent reason: `ContainsAny[FilterCondition]` is already `true`, because `FilterCondition` is an open map with `any` values by contract. The detector is **saturated** on the correct door and cannot separate it from a regression at all. ## File 3 — the strongest reading in the sweep `SqliteWasmDriver.initObjects`'s parameter does not merely *regress* to a nested `any`. It **is** one, on `main`, today: ```text objects: Array[{ name: string; fields?: Record[string, any]; tenancy?: any; indexes?: any[]; lifecycle?: any }] ``` Four sub-doors are masked (`fields`, `tenancy`, `indexes`, `lifecycle`), and the file's two `IsAny` legs are green about all four. `ContainsAny` there is **RED at baseline** — it would go red on `main`, not on a regression — so the swap is not available. Un-masking the door is a change to `SqlDriver.initObjects` in `@objectstack/driver-sql`, a **non-test file**, which is outside this card (stop condition: *the fix would require touching a non-test file*). Worth recording: the existing pair already covers the `objects: any[]` shape — the **element** leg catches it, since the element of `any[]` is `any`. ## The two excluded files — read-only, nothing touched `driver-memory` is under the #5499 investment freeze, so this is a source read plus the calibration table above — no probe, no run, no file touched in that package. It is a **derived** reading, flagged as such: | door | resolves to | would the template work? | |---|---|---| | `InMemoryDriver.update` | `Record[string, unknown] \| null` | no — union | | `InMemoryDriver.upsert` | `Record[string, unknown]` | **yes** | | `InMemoryDriver.find` | `Record[string, unknown][]` | **yes** | | `InMemoryDriver.findOne` | `Record[string, unknown] \| null` | no — union | | `InMemoryDriver.create` | `Record[string, unknown]` | **yes** | So the frozen pair holds **the only three doors in the whole population where #17876's template is effective exactly as written**. That is a question for triage, not for this PR. ## What this PR changes Eight comment blocks, one per file, recording that file's measured reading where the next author will look. **No detector, no assertion and no type was changed** — so this diff cannot move any verdict, and it does not preempt the repair decision. ## Verification ```text pnpm --filter @objectstack/driver-sql typecheck exit 0 (tsc --noEmit) pnpm --filter @objectstack/driver-sqlite-wasm typecheck exit 0 (tsc --noEmit) pnpm --filter @objectstack/driver-turso typecheck exit 0 (tsc --noEmit) driver-sql test 176 files / 2602 passed, 11 + 164 skipped driver-sqlite-wasm test 29 files / 518 passed driver-turso test 52 files / 1248 passed VERDICT command-exit 0 (shared verify lock) pnpm lint (repo-wide, `eslint . --no-inline-config`) exit 0 in 2m0s dispatch-gates derived families 49 of 52 PASS ``` The three not in that 49 exited **3 = PREREQUISITE NOT MET**, which is neither a pass nor a failure: `check:dual-build-cjs-loads`, `check:lean-entry-closure` and `check:type-check-debt` each need a full-monorepo `pnpm build` this worktree never did. **NOT MEASURED**, declared to CI, which builds fresh. None can be reached by a comment-only diff. Ablation hygiene: every mutation leg proved its edit on disk before the run and proved the artifact carried it (`scripts/ablation-dist-preflight.mjs`, driver-sql rebuilt per wasm leg); every restore leg was proved by blob hash against `HEAD` and a whole-tree `git status`. ## Changeset — measured, not assumed `skip-changeset`. `npm pack --dry-run --json` in all three packages: the intersection of (changed paths) and (shipped paths) is **empty**, with a positive control present in every listing. `files[]` is `["dist","README.md","CHANGELOG.md"]` in all three — `src/**` never ships, and no `.test.` file appears in any tarball. Zero published bytes move. ## Acceptance notes - **Not filed, recommended for the seat:** `SqlDriver.initObjects`'s parameter masks four sub-doors (`fields`, `tenancy`, `indexes`, `lifecycle`). Measured, live on `main`, with a pin that is green about it. The fix is a non-test narrowing in `@objectstack/driver-sql`. - **Not filed, observation:** #17876's own `findOne` leg (`ContainsAny[SqlFindOne] = false`, door `Record[string, unknown] | null`) has the same union blind spot measured here. Its array and bare-record legs are unaffected and sound. - The repair itself is **not** proposed here: both candidates were measured, and either also changes the two files #17876 already landed, which is outside this card's eight. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RuoNSXUbBoWHkNS4AknTrM --- _Generated by [Claude Code](https://claude.ai/code/session_01RuoNSXUbBoWHkNS4AknTrM)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 00c332b commit eb93349

8 files changed

Lines changed: 139 additions & 0 deletions

packages/drivers/driver-sql/src/sql-driver-distinct-filter-narrowing.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ import { SqlDriver } from './index.js';
5151
/** `true` for `any` and for nothing else — `0 extends 1 & T` holds only there. */
5252
type IsAny<T> = 0 extends 1 & T ? true : false;
5353

54+
/**
55+
* [#17879] MEASURED — this door's `IsAny` half is a PHANTOM half, and the
56+
* `ContainsAny` detector (#17876) does NOT close it here. On disk, against
57+
* this file's own driver, with both directions predicted before running:
58+
*
59+
* door resolves to `FilterCondition | undefined`
60+
* CONTROL `filters?: any` 3 errors here (the `narrowed`
61+
* leg + both TS2578) => it fires
62+
* NESTED `filters?: Record<string, any>` 0 errors here => no half at all
63+
* the same run with `ContainsAny` swapped in: still 0 => it buys nothing
64+
*
65+
* TWO reasons, both measured: `ContainsAny` distributes over a union, so an
66+
* optional parameter (`X | undefined`) answers `boolean`, which passes both
67+
* assertion forms; and `ContainsAny<FilterCondition>` is already `true` —
68+
* the contract type is an open map (`[key: string]: any`), so the detector is
69+
* SATURATED on the correct door and cannot separate it from a regression.
70+
* No swap was made. The two measured repairs are in the #17879 report.
71+
*/
72+
5473
describe('SqlDriver.distinct takes a bare FilterCondition (#6320)', () => {
5574
let driver: SqlDriver;
5675
let knexInstance: Knex;

packages/drivers/driver-sql/src/sql-driver-update-declared-null.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ import { SqlDriver } from './index.js';
4949

5050
/** `any` defeats ordinary assignability checks; this is the standard detector. */
5151
type IsAny<T> = 0 extends 1 & T ? true : false;
52+
53+
/**
54+
* [#17879] MEASURED — `sqlUpdateIsAny` below is a PHANTOM half against a
55+
* NESTED regression, and `ContainsAny` (#17876) does NOT close it. On disk,
56+
* reverting only this door in `sql-driver.ts`:
57+
*
58+
* door resolves to `Record<string, unknown> | null`
59+
* CONTROL `Promise<any>` 2 errors (both legs)
60+
* => the instrument fires
61+
* NESTED `Promise<Record<string, any> | null>` 1 error (`Equals` only)
62+
* => half the protection
63+
* the same NESTED run with a `ContainsAny` leg alongside: still GREEN
64+
*
65+
* WHY it does not close: `ContainsAny` distributes over the union, so
66+
* `Record<string, any> | null` answers `boolean` (`true` for the record arm,
67+
* `false` for `null`) — and `const leg: boolean = false` compiles. Every
68+
* door carrying the not-found arm has this shape. No swap was made; the two
69+
* measured repairs are in the #17879 report.
70+
*/
5271
/** Exact (mutual, non-`any`) type equality. */
5372
type Equals<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
5473

packages/drivers/driver-sqlite-wasm/src/sqlite-wasm-16711-inherited-object-def-keys.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ import { SqliteWasmDriver } from './index.js';
3636
/** `any` defeats ordinary assignability checks; this is the standard detector. */
3737
type IsAny<T> = 0 extends 1 & T ? true : false;
3838

39+
/**
40+
* [#17879] MEASURED — the strongest reading in the sweep: this door does not
41+
* merely regress to a nested `any`, it ALREADY IS one, today, and the two
42+
* `IsAny` legs below are green about it.
43+
*
44+
* door resolves to `{ name: string; fields?: Record<string, any>;
45+
* tenancy?: any; indexes?: any[]; lifecycle?: any }[]`
46+
* `IsAny` on the array and on the element both `false` => both legs green
47+
* `ContainsAny` on either `true` => RED AT BASELINE
48+
* CONTROL `objects: any` 7 errors here => it fires
49+
*
50+
* So the #17876 swap cannot be made here: it does not go red on a REGRESSION,
51+
* it goes red on `main`. Four sub-doors (`fields`, `tenancy`, `indexes`,
52+
* `lifecycle`) are masked in `SqlDriver.initObjects`'s own parameter literal,
53+
* and un-masking them is a NON-TEST change in `@objectstack/driver-sql` —
54+
* outside #17879's scope, reported instead. Note the pair below already
55+
* covers the `objects: any[]` shape: the ELEMENT leg catches it.
56+
*/
57+
3958
type InitObjectsArg = Parameters<SqliteWasmDriver['initObjects']>[0];
4059
type InitObjectsElement = InitObjectsArg extends Array<infer E> ? E : never;
4160

packages/drivers/driver-sqlite-wasm/src/sqlite-wasm-distinct-filter-narrowing.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ import { SqliteWasmDriver } from './index.js';
3434
/** `true` for `any` and for nothing else. */
3535
type IsAny<T> = 0 extends 1 & T ? true : false;
3636

37+
/**
38+
* [#17879] MEASURED — the phantom half, and why `ContainsAny` (#17876) is
39+
* inert here. Measured across the `.d.ts` boundary this file exists to pin,
40+
* with `@objectstack/driver-sql` rebuilt for each leg:
41+
*
42+
* door resolves to `FilterCondition | undefined`
43+
* CONTROL `filters?: any` 2 errors here (the `narrowed`
44+
* leg + TS2578) => it fires
45+
* NESTED `filters?: Record<string, any>` 0 errors here, with or without
46+
* `ContainsAny` swapped in
47+
*
48+
* `ContainsAny` distributes over the `| undefined` an optional parameter
49+
* carries, answering `boolean`; and it is saturated on the correct door
50+
* anyway, since `FilterCondition` is an open map. No swap was made — see the
51+
* #17879 report for the two measured repairs.
52+
*/
53+
3754
describe("SqliteWasmDriver inherits distinct's bare-FilterCondition parameter (#6320)", () => {
3855
let driver: SqliteWasmDriver;
3956
let knexInstance: Knex;

packages/drivers/driver-sqlite-wasm/src/sqlite-wasm-update-declared-null.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@ import { SqliteWasmDriver } from './index.js';
3737

3838
/** `any` defeats ordinary assignability checks; this is the standard detector. */
3939
type IsAny<T> = 0 extends 1 & T ? true : false;
40+
41+
/**
42+
* [#17879] MEASURED — `wasmUpdateIsAny` below is a PHANTOM half against a
43+
* NESTED regression, and `ContainsAny` (#17876) does NOT close it. Measured
44+
* through the inherited `.d.ts`, rebuilding `@objectstack/driver-sql` per leg:
45+
*
46+
* door resolves to `Record<string, unknown> | null`
47+
* CONTROL `Promise<any>` 2 errors (both legs)
48+
* => the instrument fires
49+
* NESTED `Promise<Record<string, any> | null>` 1 error (`Equals` only)
50+
* the same NESTED run with a `ContainsAny` leg alongside: still GREEN
51+
*
52+
* `ContainsAny` distributes over the not-found arm, so the regressed door
53+
* answers `boolean` and `const leg: boolean = false` compiles. No swap was
54+
* made; the two measured repairs are in the #17879 report.
55+
*/
4056
/** Exact (mutual, non-`any`) type equality. */
4157
type Equals<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
4258

packages/drivers/driver-turso/src/turso-driver-options-door.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ import type { DriverOptions } from '@objectstack/spec/data';
6262
/** `any` defeats ordinary assignability checks; this is the standard detector. */
6363
type IsAny<T> = 0 extends 1 & T ? true : false;
6464

65+
/**
66+
* [#17879] MEASURED — `Door<T>` below asks `IsAny`, which is a PHANTOM half
67+
* against a NESTED regression, and swapping in `ContainsAny` (#17876) does
68+
* NOT close it. Measured on the `find` row, on disk:
69+
*
70+
* every one of the 17 doors resolves to `DriverOptions | undefined`
71+
* CONTROL `options?: any` that row reds (TS1360) => fires
72+
* NESTED `options?: Record<string, any>` 0 errors here — the row still
73+
* answers `'DriverOptions'`
74+
* the same NESTED run with `ContainsAny` inside `Door<T>`: still `'DriverOptions'`
75+
*
76+
* `ContainsAny` distributes over the `| undefined` every optional parameter
77+
* carries, so the regressed door answers `boolean`, and `boolean extends true`
78+
* is `false` — the detector reads it as "no `any` here". No swap was made;
79+
* the two measured repairs are in the #17879 report.
80+
*/
81+
6582
/**
6683
* Reports what a given `options` door actually is. `'any'` for a widened door,
6784
* `'DriverOptions'` for one that matches the base contract exactly.

packages/drivers/driver-turso/src/turso-driver-update-declared-null.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ import { TursoDriver } from './turso-driver.js';
4242

4343
/** `any` defeats ordinary assignability checks; this is the standard detector. */
4444
type IsAny<T> = 0 extends 1 & T ? true : false;
45+
46+
/**
47+
* [#17879] MEASURED — `tursoUpdateIsAny` below is a PHANTOM half against a
48+
* NESTED regression, and `ContainsAny` (#17876) does NOT close it. On disk,
49+
* reverting only this override:
50+
*
51+
* door resolves to `Record<string, unknown> | null`
52+
* CONTROL `Promise<any>` 2 errors (both legs)
53+
* => the instrument fires
54+
* NESTED `Promise<Record<string, any> | null>` 1 error (`Equals` only)
55+
* the same NESTED run with a `ContainsAny` leg alongside: still GREEN
56+
*
57+
* `ContainsAny` distributes over the not-found arm, so the regressed door
58+
* answers `boolean`, which `= false` accepts. No swap was made; the two
59+
* measured repairs are in the #17879 report.
60+
*/
4561
/** Exact (mutual, non-`any`) type equality. */
4662
type Equals<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
4763

packages/drivers/driver-turso/src/turso-update-missing-id.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ import { asLibsqlClient, makeLibsqlSqliteStub, type LibsqlSqliteStub } from './l
104104

105105
/** `any` defeats ordinary assignability checks; this is the standard detector. */
106106
type IsAny<T> = 0 extends 1 & T ? true : false;
107+
108+
/**
109+
* [#17879] MEASURED — `transportUpdateIsAny` below is a PHANTOM half against
110+
* a NESTED regression, and `ContainsAny` (#17876) does NOT close it. On disk,
111+
* reverting only `RemoteTransport.update`:
112+
*
113+
* door resolves to `Record<string, unknown> | null`
114+
* CONTROL `Promise<any>` 2 errors (both legs)
115+
* => the instrument fires
116+
* NESTED `Promise<Record<string, any> | null>` 1 error (`Equals` only)
117+
* the same NESTED run with a `ContainsAny` leg alongside: still GREEN
118+
*
119+
* `ContainsAny` distributes over the not-found arm, so the regressed door
120+
* answers `boolean`, which `= false` accepts. No swap was made; the two
121+
* measured repairs are in the #17879 report.
122+
*/
107123
/** Exact (mutual, non-`any`) type equality. */
108124
type Equals<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
109125

0 commit comments

Comments
 (0)