Skip to content

Commit 52f6af8

Browse files
committed
fix(formula): spy the WARN sink through globalThis, and correct the flip docblock (#6132)
Two follow-ups from running the gate list: - `check:type-check-debt` went red: `@objectstack/formula`'s TEST_DEBT ledger records 17 raw tsc errors and the new suite made it 18. The added error was `TS2584: Cannot find name 'console'` — this package compiles with neither the DOM lib nor `@types/node`, which is why the compiler itself reaches the sink through `globalThis`. The test now spies on the same object the compiler writes to, rather than a differently-obtained one, which is also the only version of this spy that cannot go green over a silent sink. Back to 17. - The switch docblock named three test files that do not exist (the suites were consolidated into one). It now names the real file and states the flip's measured blast radius: 10 tests, all in that file, and nothing else. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Bx3H8DJhBsmgDoMp8Tz87T
1 parent 78f4c4c commit 52f6af8

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

packages/formula/src/cel-pushdown-limits.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@
4242
* export const CEL_PUSHDOWN_LIMITS_MODE: CelPushdownLimitsMode = 'fail-closed';
4343
* ```
4444
*
45-
* Two tests are written to go red on that line so the flip cannot be a silent
46-
* one: `cel-pushdown-limits.test.ts` pins the shipped default, and
47-
* `cel-to-filter-limits.rc-grace.test.ts` pins the grace-window behaviour. Both
48-
* name this file in their failure text; flipping the const means updating them
49-
* to the GA expectation, which is already written out in
50-
* `cel-to-filter-limits.ga.test.ts` and exercised there today.
45+
* `cel-to-filter-limits.test.ts` is written to go red on that line so the flip
46+
* cannot be a silent one, and its blast radius is known: flipping the const
47+
* fails exactly that file's "the shipped default is the rc grace window"
48+
* assertion and its `switch = rc-grace` block — 10 tests, measured — and
49+
* nothing else in the repo. The GA expectation they become is already written
50+
* out and passing in the same file's `switch = fail-closed` block, and on the
51+
* RLS path in `plugin-security`'s `rls-pushdown-limits.test.ts`. So the flip is:
52+
* this one const, that one default assertion, and deleting the grace block
53+
* whose behaviour has ended.
5154
*
5255
* Nothing else needs to move at GA. In particular `@objectstack/lint`'s two
5356
* enforceability gates need no edit: `validateRlsPredicateEnforceability` reads

packages/formula/src/cel-to-filter-limits.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,22 @@ const AT_LIMIT = [
5959
},
6060
];
6161

62+
/**
63+
* The WARN's sink, reached the same way the compiler reaches it: through
64+
* `globalThis`. `@objectstack/formula` compiles with neither the DOM lib nor
65+
* `@types/node`, so the bare `console` global has no type in this package — and
66+
* spying on a differently-obtained object than the one under test would be a
67+
* green test over a silent sink.
68+
*/
69+
const maybeConsole = (globalThis as { console?: { warn: (message: string) => void } }).console;
70+
if (!maybeConsole) throw new Error('this suite spies on the WARN sink and needs a host console');
71+
const hostConsole = maybeConsole;
72+
6273
let warn: ReturnType<typeof vi.spyOn>;
6374

6475
beforeEach(() => {
6576
__resetPushdownLimitWarnings();
66-
warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
77+
warn = vi.spyOn(hostConsole, 'warn').mockImplementation(() => {});
6778
});
6879

6980
afterEach(() => {

0 commit comments

Comments
 (0)