Skip to content

Mark only calls into functions that can receive a test context as opaque - #30

Open
tanahiro2010 wants to merge 14 commits into
mainfrom
fix/context-precision
Open

tanahiro2010 wants to merge 14 commits into
mainfrom
fix/context-precision

Conversation

@tanahiro2010

@tanahiro2010 tanahiro2010 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #29: restores precision for ordinary helpers and makes callbacks passed by name consistent with inline ones.

Fixes

  1. Ordinary helpers are no longer opaque_call (fix(test-inventory), affects Vitest, Jest and node:test). Since Fix follow-ups to the node:test runner provider: unique test ids, unread-file reporting and binding resolution #29 inverted the "contextual" gate, any helper that hands its parameter on (function check(x) { expect(x).toBe(2) }) was marked opaque_call when called with a call result (check(svc.price(1))), an imported value, or a let variable. A call is now opaque only when both of these hold:

    • the function can really receive a test context: it is passed by name to the runner, or reached from one with a test's context;
    • it is also reached with something else, or it uses its context in ways not followed: handing it to a call other than a tracked local function, storing it, arguments, a rest parameter.

    A let that is never assigned again is traced like a const. helper(assert) and helper(new AssertionError()) are no_assertion again.
    Safety: every guarantee from Fix follow-ups to the node:test runner provider: unique test ids, unread-file reporting and binding resolution #29 is kept. destr, viaMethod, stored, arguments[0] and rest helpers called with a real t stay inconclusive or credited, never no_assertion.

  2. Callbacks passed by name are consistent (fix(test-inventory)). test('x', viaMethod), stored, args0 and rest were no_assertion, while (t) => viaMethod(t) was inconclusive. A callback passed by name whose context escapes like that is analysed as the test body and is now inconclusive (opaque_call).

  3. Mutable aliases (review). An untraced value derived from a test's context (let c; c = t; check(c), check(t.x), check(wrap(t))) seeds unknownContext, which counts like real reach for the opaque decision. Ordinary values (svc.price(1), imports, lets that never touch a context) still seed nothing.

  4. Reassignment detection (review). neverReassigned recognises every write form: shorthand, nested and array destructuring assignments, defaults in patterns, compound assignments, ++/--, and for…of/for…in heads. A name in a literal whose role cannot be told counts as written.

  5. Table rows (review). The callback of test.each, it.each, describe.each or Vitest's test.for takes a row first and is not a context callback. With test.for, the second parameter is checked as the context.

  6. Context escapes in the test itself (review). A test whose own context goes where it is not followed and that asserts nothing of its own is opaque_call instead of no_assertion. Covered forms: a later argument (second(1, t)), Reflect.apply(fn, null, [t]), fn.call(t), and storing it in an array or object.

  7. Project objects through helper parameters (review). checkObj(svc), where the helper calls o.price(1), is opaque_call when the helper's own analysis resolves no project call, instead of target_not_called.

  8. Side effects through closures (review). An assertion on a variable written by a closure handed to a project call is opaque_call instead of disconnected. The project call can be in the test or anywhere in the file: compose([tuple(mw)])(ctx), app.get('/stream', (c) => streamSSE(c, …)), stream.onAbort(() => …).

  9. Context safety net (review). TestRunnerRecognition.testContext is set for node:test and Vitest; context tracking applies only there, so Jest's done is never a context. When the test's context is used in any way but a direct member call the inventory reads (t.assert.equal(…), t.mock.fn(), t.test(…), ctx.expect(…)) or a member read that reads nothing, the test can no longer be no_assertion or tautological_assertion. "The context" here includes members destructured from it and const aliases or casts of them. Such a test is opaque_call unless one of its project calls is asserted. This does not depend on reach propagation.

  10. Context position and more readings (review):

    • Vitest's test.for passes the context second, and that position is used everywhere: inline callbacks, callbacks passed by name, and reach seeding.
    • ctx.expect(…) and an expect destructured under another name count as assertions.
    • ({ assert }) => check(assert) derives from the context parameter.
    • Writes through casts ((context as any) = fake) count as reassignments.
    • The side-effect scan counts only writers that can run for the analysed test.
  11. Docs: the support matrix (English and Japanese) describes when a test that hands its context on is inconclusive, and the cases above.

Effect on a large project

Static inventory of hono at the pinned benchmark commit (75ff8e3e), default config, 3287 tests:

main (8060ecb) this PR
opaque_call 816 652
target_not_called 61 157
no_assertion 13 13

The target_not_called rise is the same tests: an opaque call used to hide that they call no project symbol, as on the revision before the inversion.

Full quick-profile run on hono (veritas init --yes, run --profile quick --offline, same commit):

main (8060ecb) this PR
opaque_call 720 658
target_not_called 24 24
inconclusive 3158 3160
tautological_or_disconnected 129 127

No test moves toward tautological_or_disconnected against main. The two runtime-tests/node "Should call onAbort" tests and the two compose tests stay inconclusive, and the two runtime-tests/bun "Should call onAbort" tests move from disconnected to inconclusive.

Tests

packages/test-inventory/test/context-precision.test.ts:

pnpm lint, pnpm typecheck, pnpm test, pnpm build and pnpm test:acceptance pass.

…a test context as opaque

Since the contextual gate was inverted, any helper that hands its parameter on (check(x) { expect(x).toBe(2) }) was opaque_call when called with a call result, an imported value or a let variable, for Vitest and Jest too. A call is now opaque only when the function can really receive a context (it is passed by name to the runner, or reached from one with a test's context) and is also reached with something else, or uses its context in ways not followed: handing it to a call other than a tracked local function, storing it, arguments, a rest parameter. A let never assigned again is traced like a const. helper(assert) and helper(new AssertionError()) are no_assertion again.

A callback passed by name whose context escapes the same way (test('x', viaMethod), stored, arguments, a rest parameter) is analysed as the test body and now inconclusive (opaque_call) instead of no_assertion, matching (t) => viaMethod(t).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T07:08:40.340210Z a50380b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tanahiro2010

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf20517d91

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Benchmark

Base main@8060ecb and head merge of a50380b, measured one after the other on the same runner (linux, Node.js 26.13.1, 4 CPUs). Changes larger than 15% are in bold; smaller ones are within the usual variation between runs.

Fixtures (run --offline --include-proposed)

Fixture Profile Base Head Change Peak memory (base → head)
small-app quick 1.2 s 1.3 s +6% 335 MB → 333 MB
small-app standard 6.3 s 6.3 s +0% 335 MB → 334 MB
small-app deep 19.8 s 18.9 s -5% 331 MB → 336 MB
discount-boundary quick 1.2 s 1.2 s +3% 323 MB → 326 MB
discount-boundary standard 2.7 s 2.7 s -2% 332 MB → 334 MB
discount-boundary deep 7.4 s 7.3 s -1% 331 MB → 335 MB
agent-loop quick 1.2 s 1.1 s -3% 326 MB → 327 MB
agent-loop standard 2.1 s 2.0 s -4% 338 MB → 331 MB
agent-loop deep 5.0 s 4.9 s -2% 333 MB → 332 MB
conflicting-docs quick 1.2 s 1.2 s -6% 326 MB → 323 MB
conflicting-docs standard 2.1 s 2.1 s -2% 334 MB → 333 MB
conflicting-docs deep 7.6 s 7.3 s -4% 334 MB → 332 MB
equivalent-mutants quick 1.1 s 1.1 s -4% 323 MB → 322 MB
equivalent-mutants standard 2.3 s 2.2 s -1% 317 MB → 336 MB
equivalent-mutants deep 2.9 s 2.8 s -4% 333 MB → 332 MB
no-spec quick 1.1 s 1.1 s -2% 328 MB → 322 MB
no-spec standard 2.1 s 2.1 s +3% 324 MB → 330 MB
no-spec deep 3.7 s 3.6 s -3% 334 MB → 330 MB

Open-source projects (run --profile quick --offline)

Project Tests Base Head Change Peak memory (base → head) Not checking project behaviour (base → head)
defu 23 1.7 s 1.7 s -1% 427 MB → 429 MB 0 → 0
ufo 54 1.6 s 1.6 s -0% 366 MB → 368 MB 0 → 0
pathe 62 2.6 s 2.6 s +1% 470 MB → 469 MB 8 → 8
hono 3287 17.3 s 18.5 s +7% 1384 MB → 1372 MB 128 → 126

Raw results are attached to the workflow run as the benchmark artifact.

…e rows, and leave hidden context uses and side effects inconclusive

- An untraced value derived from a test's context (let c; c = t; check(c), check(t.x), check(wrap(t))) seeds a new unknownContext set; a contextual function in it is opaque_call for the calls that may hand it a context, while ordinary values (svc.price(1), an import, a let never touching a context) still seed nothing.
- neverReassigned recognises every write form: shorthand and nested destructuring assignments (resolved with getShorthandAssignmentValueSymbol), array destructuring, defaults in patterns, compound assignments, ++/--, for...of and for...in heads; a name in a literal whose role cannot be told counts as written.
- The callback of a table-driven registration (test.each, it.each, describe.each, Vitest's test.for) takes a row first: it is not a context callback, and with test.for the second parameter is checked as the context.
- A test whose own context goes where it is not followed (a later argument, Reflect.apply, fn.call(t), stored in an array or object) and that asserts nothing of its own is opaque_call instead of no_assertion.
- A helper handed a project object that it calls through its parameter (checkObj(svc) with o.price(1)) is opaque_call when its own analysis resolves no project call, instead of target_not_called.
- An assertion on a variable written by a closure handed to a project call, in the test or anywhere in the file (compose([tuple(mw)])(ctx), app.on(() => { aborted = true })), makes the test opaque_call instead of disconnected.
@tanahiro2010

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3cc493e0e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
…only where runners hand them

- TestRunnerRecognition gains testContext, set for node:test and Vitest. Context tracking (contextReach, context parameters, escape checks) applies only to runners that hand one, so Jest's done is never read as a context.
- Safety net: when a test's context, a member destructured from it, or a const alias or cast of them is used in any way but a direct member call the inventory reads (t.assert.equal(…), t.mock.fn(), t.test(…), ctx.expect(…)) or a member read where it reads nothing, the test can no longer be no_assertion or tautological_assertion. It is opaque_call unless one of its project calls is asserted. This holds whatever reach propagation knows.
- The context's position follows the registration: the second parameter with Vitest's test.for, none with each, for inline callbacks, callbacks passed by name and the seeding of reach. ctx.expect(…) and an expect destructured under another name count as assertions.
- A member destructured from a parameter derives from that parameter (({ assert }) => check(assert)).
- Every write check sees through parentheses, as, satisfies, non-null and type assertions ((context as any) = fake).
- The side-effect scan counts only writers that can run for the analysed test: its own body, hooks of its enclosing suites, module or suite level; not other tests' callbacks or other suites' hooks.
@tanahiro2010

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3da0ee3af5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/test-inventory/src/index.ts Resolved
…point and worklist

The alias loop of the context safety net never ended for const { assert } = t or const { expect } = ctx in a test body: it re-added the destructuring pattern on every round, hanging the inventory. Each declaration is now taken once, and the loop ends when no new alias is found. A member destructured with a const in the body ({ assert } = t, nested { assert: { equal } } = t) is read as the context's member.

Every fixpoint and worklist added for context reach and unread test files (context aliases, contextReach and its contextual sets, the local-module walks for loadsCode and packageCall) also stops at an iteration limit. Past it, its result is read as unknown: context escapes, every function may receive an untraced context, the module may run code. A debug log event (inventory-iteration-cap) records it. setInventoryIterationLimit sets the limit for tests.
@tanahiro2010

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d34d42f210

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/test-inventory/src/index.ts Resolved
…xt and side-effect scans

The safety net and the side-effect writer scan looked inside subtests that are skipped or todo (t.test(name, { skip: true }, fn), t.test.todo), so a test whose only escape was in such a subtest was opaque_call instead of no_assertion. Those bodies are now left out, as analyzeTest already leaves them out of assertions; subtests whose options cannot be read still count.
@tanahiro2010

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0dcbf688a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
…ty net to subtest contexts, and pass the iteration limit per call

- Node runs todo subtests: their bodies are scanned again for side-effect writers and context escapes, and their calls are recorded as run, while their assertions still gate nothing. Only skipped subtests are left out.
- Each running subtest's own context counts for the safety net: an escape in a subtest body (Reflect.apply(check, null, [s])) keeps the test that owns the evidence from no_assertion.
- The safety net treats a context reached through more aliases than assertion counting follows (ALIAS_DEPTH) as unfollowed.
- The iteration limit is an inventoryTests option (iterationLimit) set for the duration of one call, instead of a mutable global exported from the package.
…kip types, and know builtin values

- A function registered both with table rows and with a context (test.each(rows)('row', check) and test('normal', check)) got one context index for the whole file, so a row's fake object could count as an assertion depending on registration order. The context is now resolved per registration while that registration is analysed. A function registered both ways has no known context: the row registration gets no credit, and the context registration is opaque_call, never no_assertion.
- Names of the context inside a type (typeof t, an annotation, the type of satisfies) are not uses of it.
- A helper handed a project value calls no project code through it when the value is a primitive or a builtin of the standard library (Array, Map, Set, Date, RegExp, Promise) whose methods are declared in lib files: no opaque_call for n.toString() on an imported const two = 2.
@tanahiro2010

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf5bbb4276

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
Comment thread packages/test-inventory/src/index.ts Resolved
…, credit nothing a todo subtest asserts, and narrow builtin values

- A call under a skipped subtest (or one whose options cannot be read) at any depth is not run, whatever todo marks sit above or below it, and however the call is reached: through the body, an awaited value or a binding. Calls in skipped subtests were recorded through awaited values before.
- In a todo subtest, a call runs but credits nothing it asserts: no helper assertions, no assertion inside on a project call's result, no observed mock. Its helpers no longer keep a test from no_assertion either.
- Side-effect writers in teardown hooks (afterEach, afterAll, after) are not counted; only setup hooks, module or suite level and the test's own body.
- readsArguments stops at nested functions, methods, accessors, constructors and static blocks, and still walks into arrows, which share arguments.
- The builtin exclusion of the helper-parameter rule now covers only primitives (number, string, boolean, bigint, symbol and their literals), or a const initialised directly with an array of literals, a regular expression, a builtin constructor or Promise.resolve. A value only declared with a builtin type (a project subclass of Promise) stays opaque_call.
@tanahiro2010

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26e35a83a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/test-inventory/src/index.ts Outdated
Comment on lines +11249 to +11252
for (const assertion of assertions)
for (const value of comparedValues(assertion))
for (const node of [value, ...descendants(value)])
if (ts.isIdentifier(node)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore unevaluated closures when collecting assertion reads

When an assertion compares a function without invoking it, this traversal still counts variables captured in its body as observed values. For example, with imported project function run, beforeEach(() => run(() => { hit = true; })) followed by test('empty', () => expect(() => hit).toBeDefined()) now replaces target_not_called with opaque_call. The assertion only checks that the function exists; it never reads hit, so the setup writer cannot influence its result. Filter these identifiers using the existing runsWithin execution predicate, as the assertion-flow analysis already does, so unevaluated closures do not suppress disconnected-test findings.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by 26e35a8.

Comment thread packages/test-inventory/src/index.ts Outdated
Comment on lines +11522 to +11524
// A primitive (`const two = 2`) or a well-known builtin (an array, a map, a date) has only the methods of the
// standard library, which run no project code; anything typed by project declarations, `any` or `unknown` may.
if (builtinValue(argument, checker)) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check builtin objects for method overrides before exempting them

When an exported builtin object has a project-defined method override, this exemption incorrectly proves that calling it cannot execute project code. For example, a project module containing export const names = ['a']; names.at = (index: number) => 'b';, tested through function first(list) { expect(list.at(0)).toBe('b'); } and test('customized builtin', () => first(names)), now receives target_not_called instead of the previous inconclusive opaque_call, even though the assertion executes the project's replacement method. A const binding does not make the object's methods immutable. Check for member overrides, or retain uncertainty for mutable builtin objects, before excluding their method calls.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by 26e35a8.

Comment thread packages/test-inventory/src/index.ts Outdated
Comment on lines +11526 to +11529
return descendants(body).some(
(child) =>
ts.isCallExpression(child) &&
rootIdentifierNode(skipParens(child.expression)) !== undefined &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include constructor invocations through helper parameters

When a local helper instantiates an imported project class through its parameter, this scan misses the execution because new Ctor() is a NewExpression, not a CallExpression. For example, with project export class Service { value = 2; }, function check(Ctor) { expect(new Ctor().value).toBe(2); } called by test('project constructor', () => check(Service)) now receives target_not_called instead of the previous opaque_call, despite executing and checking the project's instance initialization. Include constructor invocations in the parameter-use scan so this unresolved project execution remains inconclusive rather than being diagnosed as absent.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by 26e35a8.

…in objects opaque, see every invocation, and count teardown after an earlier test

- The side-effect scan collects only what an assertion evaluates (runsWithin): expect(() => hit) does not read hit.
- The helper-parameter rule exempts only primitives (number, string, boolean, bigint, symbol and their literals): any object, builtin or not, may have its methods replaced, so arrays, maps, dates and promises stay opaque_call.
- It counts every invocation of the parameter: calls, new, tagged templates, and the parameter handed to a call or new other than an assertion (Reflect.construct(Ctor, []), Reflect.apply(fn, …)).
- A teardown hook writer counts when it runs before the analysed test: afterEach of an enclosing suite once an earlier test of it ran, afterAll of an earlier sibling suite with tests; never for the first test.
@tanahiro2010

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ab164f150

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/test-inventory/src/index.ts Outdated
Comment on lines +3750 to +3751
else if (info.targets.length === 0 && projectValueCalledThroughParameter(node, helper, ctx))
info = { ...info, opaque: true };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve opacity when a helper also has resolved project calls

When a helper mixes a resolved project call with an assertion on a project value received through a parameter, the info.targets.length === 0 guard discards the uncertainty for the latter. For example, function check(o) { value(1); expect(o.price(1)).toBe(2); } called with imported svc now records only the unasserted value call and loses the previous opaque_call, despite checking the project's svc.price result. Consequently, inferredUnlinked in packages/assessment/src/decision.ts treats this test as disconnected rather than inconclusive. Check parameter-mediated execution even when other targets have already been resolved.

Useful? React with 👍 / 👎.

Comment on lines +11359 to +11360
if (!isFunction(current) || !ts.isCallExpression(current.parent)) continue;
const call = current.parent;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude uncalled functions from side-effect writer reach

For a module-level function that is never invoked, this traversal skips its function boundary without establishing that its body can execute. For example, let hit = false; function unused() { svc.run(() => { hit = true; }); } test('empty', () => expect(hit).toBe(false));, with imported project method svc.run, now receives opaque_call instead of the previous target_not_called. The source-wide writer scan finds the assignment and insideHanded accepts the project call inside unused, although nothing calls that function. Require an executable path to the enclosing function before using its writes to suppress disconnected-test findings.

Useful? React with 👍 / 👎.

…l of it

- A helper parameter handed to an assertion that runs it (expect(f).toThrow(), assert.throws(f) and the other running assertions, resolved through nodeAssertCall) is an invocation of a project value, so such helpers are opaque_call again, as on main. An assertion that only compares the value still is not one.
- In a test body, a project function handed directly to a running assertion (assert.throws(explode), expect(explode).toThrow()) counts as a call of it, asserted, as () => explode() does. expect(explode).toBeDefined() and other matchers that only compare it do not.
…eters whatever else the helper calls, and skip dead writers

- A helper that also calls resolved project code (value(1)) no longer hides a project object it calls through its parameter (o.price(1)): the parameter rule applies regardless of other targets.
- A side-effect writer inside a named function that is neither exported nor referenced anywhere in the file never runs and is not counted; any other function may run and still counts.
@tanahiro2010

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a50380bb77

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3827 to +3828
ts.isCallExpression(node) && (isExpectCall(node) || isAssertCall(node)) && runsCallback(node)
? node.arguments.flatMap((argument) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict assertion execution credit to invoked argument positions

For a Node test containing assert.doesNotThrow(() => {}, predicate), where predicate is an imported project function, this loop adds predicate as an asserted project call even though Node never invokes the error predicate when the callback succeeds. The test therefore gains fabricated project coverage and loses its valid target_not_called diagnosis. Inspecting all arguments also mistakes .call's receiver for an executed callback. Select the callback positions using the resolved assertion and invocation form rather than crediting every callable argument.

Useful? React with 👍 / 👎.

Comment on lines +11509 to +11512
const name = ts.isNewExpression(value) ? skipParens(value.expression) : value;

if (!ts.isIdentifier(name)) return false;
let symbol = checker.getSymbolAtLocation(name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve project members passed into assertion helpers

For import * as project from '../src/svc', followed by function check(o) { expect(o.price(1)).toBe(2); } and test('price', () => check(project.svc)), this identifier-only check rejects project.svc. The helper's parameter-mediated call cannot resolve a project target, and the tightened context gate no longer preserves its previous opacity, so the test now receives target_not_called despite executing and asserting project code. Resolve property-access arguments to their project declarations before concluding that parameter-mediated execution is absent.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant