Skip to content

fix(analysis): tighten TypeScript runner and alias-gap evidence - #4096

Merged
EffortlessSteven merged 4 commits into
mainfrom
swarm/ts-g-runner-signal
Sep 25, 2026
Merged

EffortlessSteven merged 4 commits into
mainfrom
swarm/ts-g-runner-signal

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Four honest-evidence fixes in the TypeScript preview adapter, all inside crates/ripr/src/analysis/language/typescript/:

  1. typescript_path_alias_unresolved default-import false-fire (static_limit.rs): a default import records imported: "default", and name_matches treated that as a match for ANY owner — so import React from 'react' in any uncredited test fired the alias-gap limitation, contradicting the documented contract ("Do NOT emit it for ordinary third-party imports"). A default import now only counts when the local binding name matches the owner name; named-import matching is unchanged. Added negative control (import React from 'react' → no limitation) and positive control (import applyDiscount from '@/applyDiscount' → limitation fires).

  2. Multi-runner silent priority resolution (package.rs): detect_framework resolved first-match-wins (jest > vitest > ...) with no disclosure. New detect_framework_signals collects all distinct matched frameworks; when ≥ 2 match, discovery emits the additive, classification-neutral package limitation typescript_test_runner_ambiguous and caps confidence at medium (the priority pick is arbitrary from evidence). typescript_test_runner: <name> is still emitted. Test pins jest+vitest → ambiguity disclosed, @types/jest + jest still count as ONE signal.

  3. Mocha without lockfile: no command AND no limitation (mod.rs): mocha has no file-target command mapping, so a detected mocha framework with no runner evidence produced neither typescript_verify_command nor any limitation. typescript_test_runner_unresolved is now emitted whenever the inferred command is None — which is exactly what OUTPUT_SCHEMA.md already documents ("emitted when verify_command_for_discovery returns None"). Adapter-level test added.

  4. Fragile package.json substring scanning (package.rs): extract_test_script_value found the first "test": anywhere in the file and json_has_workspaces_field substring-matched "workspaces". Detection now reads fields from a single serde_json parse (ManifestFacts): a "test" key outside scripts is not the test script, "workspaces" inside a string value does not mark a monorepo root, and a framework name inside a free-text value ("description": "jest") is not dependency evidence. Unparseable manifests fail closed. All existing pinned detection tests pass unchanged.

Evidence

  • spec → test → code: 10 new tests (2 alias controls, adapter mocha control, 3 ambiguity, 3 manifest-field honesty, 1 discovery-level ambiguity); all existing pinned tests/goldens expected unchanged (verified by inspection: no fixture package.json has multiple framework signals or mocha, and runner-unresolved goldens come from framework-less repos).

Non-goals

  • No mocha command mapping invented (no spec-table authority for a file-target form).
  • docs/OUTPUT_SCHEMA.md already documents the Fix-3 contract; a follow-up may add the new typescript_test_runner_ambiguous kind to the kinds list (left out to keep this diff inside the analysis lane).

Rollback

Revert this PR; behavior is additive-limitation-only plus false-positive removal.

- typescript_path_alias_unresolved: a default import (imported: "default")
  now only counts as a plausible owner import when the LOCAL binding name
  matches the owner. Previously any default import from any non-relative
  package (e.g. import React from 'react') false-fired the limitation,
  contradicting the documented contract. Named-import matching unchanged.
  Negative control: import React from 'react' emits no limitation; positive
  control: import applyDiscount from '@/applyDiscount' still does.
- detect_framework: collect all distinct framework signals. When two or more
  match (e.g. jest + vitest devDeps), emit the additive, classification-
  neutral package limitation typescript_test_runner_ambiguous and cap
  confidence at medium instead of silently resolving by fixed priority.
  jest+vitest discovery test pins the disclosure.
- mocha fail-closed: typescript_test_runner_unresolved is now emitted
  whenever the inferred verify command is None (mocha has no file-target
  mapping and no lockfile previously produced neither command nor
  limitation), matching the documented OUTPUT_SCHEMA contract.
- package.json detection reads parsed fields via serde_json
  (ManifestFacts) instead of substring scans: a "test" key outside
  scripts is not the test script, the word "workspaces" inside a string
  value does not mark a monorepo root, and a framework name inside a
  free-text value ("description": "jest") is not dependency evidence.
  Unparseable manifests fail closed.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 83a6f40a-db02-488a-9061-476726d89f15

📥 Commits

Reviewing files that changed from the base of the PR and between c1e4d94 and 6c95c25.

📒 Files selected for processing (4)
  • crates/ripr/src/analysis/language/typescript/mod.rs
  • crates/ripr/src/analysis/language/typescript/package.rs
  • crates/ripr/src/analysis/language/typescript/static_limit.rs
  • crates/ripr/src/analysis/language/typescript/tests.rs
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

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