Skip to content

Wave 3: resolver follow-ups (#114, #115, #116) - #126

Merged
AndresL230 merged 10 commits into
mainfrom
wave3/resolver-followups
May 27, 2026
Merged

Wave 3: resolver follow-ups (#114, #115, #116)#126
AndresL230 merged 10 commits into
mainfrom
wave3/resolver-followups

Conversation

@AndresL230

@AndresL230 AndresL230 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Wave 3 resolver/detection follow-ups left behind by PR #110, bundled into one PR (the accuracy track's wave/3-resolver-followups):

  • [Detection] Default-import context threading in resolveExportedMatches (A3 follow-up) #114 — default-vs-named import disambiguation. resolveExportedMatches could not tell a default import from a named one, so a named import in a heterogeneous barrel (export { default } from "./a" + export { ask } from "./b") wrongly inherited the default re-export's provider. Threaded an isDefault flag through extractRelativeImportsresolveExportedMatches, split the re-export filter (default bindings follow only export { default }; named/wildcard bindings never do), and encoded the dimension in the cycle-protection visitKey. Also fixed extractRelativeImports to parse the default binding in mixed imports (import gen, { ask } from "x").
  • [Detection] Factory-with-arguments in extractFactoryCallAssignments (A5 follow-up) #115 — factory-with-arguments. extractFactoryCallAssignments matched only no-arg makeClient(). Widened the regex so makeClient(config), makeClient({ apiKey }), multi-arg, and multi-line factory calls resolve.
  • [Detection] Narrow images.generate batchCapable to a separate inlineParallelCapable flag #116inlineParallelCapable flag. openai.images.generate was flagged batchCapable, conflating a true batch endpoint with DALL·E's inline n/count parameter and producing the wrong "use the batch endpoint" suggestion in a loop/fan-out. Added a distinct inlineParallelCapable fingerprint flag, reclassified images.generate, suppressed the concurrency fan-out finding on either flag, and added detectInlineParallel emitting a "use the n/count parameter" suggestion instead.

Built subagent-driven across two file-disjoint tracks (resolver / detector) in parallel worktrees, with per-track spec + code-quality review and a final whole-implementation review.

Test Plan

Follow-ups (non-blocking, to be filed)

inlineParallelCapable is intentionally not yet threaded into the intelligence graph (ApiCallNode), the regex pattern path (local-waste-detector.ts / openai-compatible.ts), the pattern dedup key, or a dashboard badge. The detectors work correctly via the AST path. Only user-visible effect: DALL·E endpoints lose the old (incorrect) "batch" dashboard badge until the badge follow-up lands.

Closes #114
Closes #115
Closes #116

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added Wave 3 resolver follow-ups design and implementation plan for resolving cross-file import and factory resolution improvements.
  • New Features

    • Inline-parallel API detection for endpoints supporting n/count parameters to fetch multiple results in a single request.
    • Improved factory function resolution with argument support.
    • Enhanced default vs. named import disambiguation during cross-file resolution.
  • Tests

    • Expanded test suite coverage for resolver, factory, and inline-parallel detection scenarios.

Review Change Stack

AndresL230 and others added 10 commits May 27, 2026 00:56
Closes-design-for: #114 #115 #116

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…116)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…atches (#114)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ion (#116)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…lAssignments (#115)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
#114, #115)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…h core-scanner + test coverage (#116)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR implements three resolver and detector follow-ups (#114#116) by introducing default-vs-named import context tracking in cross-file resolution, expanding factory argument detection, adding an inlineParallelCapable flag throughout the type/scanner pipeline, and routing inline-parallel waste findings to a dedicated detector while reclassifying OpenAI's images.generate endpoint.

Changes

Wave 3 Resolver and Detector Follow-ups

Layer / File(s) Summary
Type schema for inline-parallel capability
src/scanner/fingerprints/types.ts, src/analysis/types.ts
MethodFingerprint, ApiCallInput, and EndpointRecord gain optional inlineParallelCapable?: boolean field to distinguish endpoints supporting inline n/count parameters from true batch APIs.
Threading inlineParallelCapable through AST and scanner pipeline
src/ast/ast-scanner.ts, src/scanner/core-scanner.ts
AstCallMatch interface extended with inlineParallelCapable field and populated from fingerprint data during class-method, direct SDK, and callback collection scans; flag threaded into ApiCallInput output.
Cross-file resolver: default import threading and factory argument detection
src/ast/cross-file-resolver.ts
ImportedName extended with isDefault boolean to track import kind; resolveExportedMatches() updated to specialize re-export chain following (default imports only follow export { default }, named imports skip default re-exports except when aliased); extractFactoryCallAssignments() regex expanded to match factory calls with arbitrary arguments.
Waste detector routing for inline-parallel cases
src/ast/waste/batch-detector.ts, src/ast/waste/concurrency-detector.ts
detectNPlusOne and unbounded concurrency detection skip when inlineParallelCapable is true; new detectInlineParallel function emits n/count parameter suggestions; integration into detectBatchWaste loop.
OpenAI images.generate reclassification
src/scanner/fingerprints/openai.json
images.generate fingerprint flag changed from batchCapable: true to inlineParallelCapable: true.
Default import threading test and fixtures
src/test/a3-default-import-threading.test.ts, src/test/fixtures/a3-followup/mixed-barrel/*
Test validates that named imports resolve to their own providers (Anthropic) without inheriting default re-export providers (OpenAI), and that default imports resolve correctly through barrel re-exports.
Inline-parallel detector test suite
src/test/ast-inline-parallel.test.ts
Four test cases: inline-parallel with Promise.all fan-out emits n/count suggestions (no batch text); batchCapable in same pattern emits batch findings; Array.from idiom suppression; inline-parallel in unbounded loops triggers suggestions.
Factory with arguments test and fixtures
src/test/factory-with-args.test.ts, src/test/fixtures/factory-args/*
Integration test validates factory argument detection across five client instantiation patterns (no args, config variable, environment, multi-param).
Documentation and CI test wiring
docs/superpowers/plans/2026-05-27-wave3-resolver-followups.md, docs/superpowers/specs/2026-05-27-wave3-resolver-followups-design.md, package.json
Implementation plan and design specification document all three follow-ups with file-impact matrix, task breakdown, and integration steps; test:scanner npm script expanded with three new test invocations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • recost-dev/extension#110 — These resolver follow-ups extend the prior PR's cross-file barrel re-export and factory/DI propagation work by adding default-import context tracking and expanding factory argument detection.
  • recost-dev/extension#90 — Both PRs modify the AST-scanning → API-input threading by extending AstCallMatch/ApiCallInput in src/ast/ast-scanner.ts and src/scanner/core-scanner.ts (this PR adds inlineParallelCapable, the prior PR added span/enclosing context).

Poem

🐰 Wave three hops forth with threading clear,
Default from named, import rewrite near,
Factories flex their argument might,
Inline-parallel detectors shine bright,
Images batch no more—n/count's the way,
Three issues closed, the resolvers play!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.91% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically summarizes the main change: implementing Wave 3 resolver follow-ups addressing issues #114, #115, and #116.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wave3/resolver-followups

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

const c0 = makeClient();
const c1 = makeClient(config);
const c2 = makeClient({ apiKey: process.env.KEY });
const c3 = makeClient(env, options);
const c3 = makeClient(env, options);
const c4 = makeClient(
env,
options,

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/ast/cross-file-resolver.ts (1)

615-623: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Thread middleware default-import context into resolver.

Line 621 hardcodes isDefault to false. For default-imported middleware (import mw from "./mw"), export default callees won’t be resolved, so propagation is skipped.

Suggested fix
         const calleeMatches = resolveExportedMatches(
           mwName,
           resolvedFile,
           registry,
           sourceByFile,
           normalizedKnown,
           0,
-          false
+          importEntry.isDefault
         );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/ast/cross-file-resolver.ts` around lines 615 - 623, The call to
resolveExportedMatches is hardcoding the isDefault flag to false, so
default-imported middleware (mwName) never resolves default exports; compute an
isDefault boolean at the call site based on the middleware import metadata
(i.e., whether mwName was imported as a default), and pass that boolean instead
of false into resolveExportedMatches(mwName, resolvedFile, registry,
sourceByFile, normalizedKnown, 0, isDefault). If necessary, add an isDefault
parameter to intermediate functions that lead to this call so the default-import
context is threaded through from where imports are parsed to this resolver.
🧹 Nitpick comments (1)
docs/superpowers/plans/2026-05-27-wave3-resolver-followups.md (1)

712-717: ⚡ Quick win

Replace machine-specific absolute paths in benchmark steps.

The commands currently depend on /home/andresl/..., which makes the runbook non-portable for other contributors. Please switch these to repo-relative or environment-variable-based paths (for example, $REPO_ROOT) so the instructions are reproducible across dev machines.

Suggested doc patch
- cd /tmp/wave3-fixtures && git fetch --depth 1 origin "$(tr -d '\n\r' < /home/andresl/Projects/recost/extension/.benchmark-fixtures-sha)" && git checkout FETCH_HEAD
- cd /home/andresl/Projects/recost/extension
+ REPO_ROOT="$(pwd)" # run from repo root before this block
+ cd /tmp/wave3-fixtures && git fetch --depth 1 origin "$(tr -d '\n\r' < "$REPO_ROOT/.benchmark-fixtures-sha")" && git checkout FETCH_HEAD
+ cd "$REPO_ROOT"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/superpowers/plans/2026-05-27-wave3-resolver-followups.md` around lines
712 - 717, Replace the machine-specific absolute paths used in the benchmark
commands (notably the git fetch line containing "$(tr -d '\n\r' <
/home/andresl/Projects/recost/extension/.benchmark-fixtures-sha)" and the "cd
/home/andresl/Projects/recost/extension" command) with a repo-relative or
environment-variable-based reference (e.g., use $REPO_ROOT or detect the repo
root with git rev-parse --show-toplevel) and update the commands to read the
.benchmark-fixtures-sha from that variable instead of a hardcoded home path so
the runbook is portable across machines.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/ast/cross-file-resolver.ts`:
- Around line 615-623: The call to resolveExportedMatches is hardcoding the
isDefault flag to false, so default-imported middleware (mwName) never resolves
default exports; compute an isDefault boolean at the call site based on the
middleware import metadata (i.e., whether mwName was imported as a default), and
pass that boolean instead of false into resolveExportedMatches(mwName,
resolvedFile, registry, sourceByFile, normalizedKnown, 0, isDefault). If
necessary, add an isDefault parameter to intermediate functions that lead to
this call so the default-import context is threaded through from where imports
are parsed to this resolver.

---

Nitpick comments:
In `@docs/superpowers/plans/2026-05-27-wave3-resolver-followups.md`:
- Around line 712-717: Replace the machine-specific absolute paths used in the
benchmark commands (notably the git fetch line containing "$(tr -d '\n\r' <
/home/andresl/Projects/recost/extension/.benchmark-fixtures-sha)" and the "cd
/home/andresl/Projects/recost/extension" command) with a repo-relative or
environment-variable-based reference (e.g., use $REPO_ROOT or detect the repo
root with git rev-parse --show-toplevel) and update the commands to read the
.benchmark-fixtures-sha from that variable instead of a hardcoded home path so
the runbook is portable across machines.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1eb61a89-a1ff-475d-80f5-d28373d51a6e

📥 Commits

Reviewing files that changed from the base of the PR and between fe8e239 and 3e1a96b.

📒 Files selected for processing (20)
  • docs/superpowers/plans/2026-05-27-wave3-resolver-followups.md
  • docs/superpowers/specs/2026-05-27-wave3-resolver-followups-design.md
  • package.json
  • src/analysis/types.ts
  • src/ast/ast-scanner.ts
  • src/ast/cross-file-resolver.ts
  • src/ast/waste/batch-detector.ts
  • src/ast/waste/concurrency-detector.ts
  • src/scanner/core-scanner.ts
  • src/scanner/fingerprints/openai.json
  • src/scanner/fingerprints/types.ts
  • src/test/a3-default-import-threading.test.ts
  • src/test/ast-inline-parallel.test.ts
  • src/test/factory-with-args.test.ts
  • src/test/fixtures/a3-followup/mixed-barrel/anthropic-named.ts
  • src/test/fixtures/a3-followup/mixed-barrel/barrel.ts
  • src/test/fixtures/a3-followup/mixed-barrel/consumer.ts
  • src/test/fixtures/a3-followup/mixed-barrel/openai-default.ts
  • src/test/fixtures/factory-args/consumer.ts
  • src/test/fixtures/factory-args/factory.ts

@AndresL230
AndresL230 merged commit 68126a0 into main May 27, 2026
3 checks passed
AndresL230 added a commit that referenced this pull request May 27, 2026
Wave 3 (#114/#115/#116, PR #126) merged; also corrected stale statuses for
waves 7 (#122), 8 (#123), 10 (#124) that merged earlier but were never marked
complete. All platform waves (6-10) + accuracy Wave 3 now shipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant