Repository navigation
fix(typescript): follow bounded barrel re-export chains to the owner - #4502
Conversation
The TypeScript preview adapter reported no_static_path for changed
functions whose tests import them through a barrel. Real repro:
unjs/ufo eb29945 / 5cd9e67 import `withBase`/`withoutBase` from "../src",
a directory whose src/index.ts is `export * from "./utils"`. The import
specifier resolved to module `src`, which matched no barrel (the star edge
was recorded for `src/index`), and only one hop was ever followed.
ReExportIndex (related_tests.rs, the existing owner) now:
- resolves a directory specifier to its `index` module only when no file
module of that name exists;
- follows `export { N } from` and `export * from` chains inside the repo
for at most MAX_REEXPORT_HOPS (4) hops with a cycle guard;
- records each module's own exported names, so a star hop forwards a name
only when the target module actually exports it; ambiguous star names,
`export *` of `default`, over-deep chains and cycles fail closed;
- skips type-only `export type ... from` statements.
The re-export relation also gains the body-local shadow guard.
Proof: reexport_chain_tests (11 tests through ReExportIndex::build and
find_related_tests; 9 fail on main), new fixtures
typescript_reexport_directory_star_barrel (no_static_path -> exposed) and
typescript_reexport_barrel_other_name (negative control), and a re-bless
of typescript_reexport_two_hop_limit, whose two-hop named chain is now
within the bound (no_static_path -> exposed). RIPR-SPEC-0095 updated.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vnx74g4Sw9wuFrowxNf2d
…ed findings #4429 (merged to main after this patch was cut) renders exposed findings at info severity; the two fixtures this change moves to exposed now carry it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PD6CY5kNL5Z4BT2T3M32Yc
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedNext included review available in 46 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (45)
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. Comment |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
EffortlessSteven
left a comment
There was a problem hiding this comment.
Exact-head review of 6b95bcb: no blocking findings.
Inspected ReExportIndex (typescript/related_tests.rs), module_export_facts, the relation wiring and the fixtures:
- Resolution order matches ECMAScript
ResolveExport: explicit/rename entries, then the module's own exports, then star sources;defaultnever crosses a star hop; a revisited(module, name)pair returns NotFound (cycle), and depth pastMAX_REEXPORT_HOPSreturns Unknown, whichresolve_to_ownertreats as no credit. - Ambiguity: two star sources resolving the same name to different bindings return Unknown; identical bindings through two paths are accepted, which is correct (same binding).
canonical_moduleprefers a file module overdir/index, matching the TS/Node lookup order; an unknown path stays unchanged and matches nothing.- Credit still requires
target_module == owner_moduleand the owner's own name (ordefaultfor a default-exported owner), plus a call of the imported local in the test body; the new shadow guard removes credit when the test body redeclares that local. - Type-only exports (
export type,export type * from, interface/type declarations) contribute no value names. - Fixtures:
typescript_reexport_directory_star_barrel(positive),typescript_reexport_barrel_other_name(negative),typescript_reexport_two_hop_limitre-blessed to exposed; 6b95bcb only changeswarningtoinfofor #4429's RIPR-SPEC-0122 rule. - Local on this head: typescript lib tests 586 passed, goldens check exit 0, precommit exit 0, clippy
-p ripr --all-targetsclean.
Residual, non-blocking: an explicit export { N } from './A' whose target A is unread (over read caps) resolves to A's binding by assertion; the owner comparison still requires A to be the owner's file, so it cannot credit a different owner.
Bot reviews pending at submission; Gemini is out of quota (missing).
Generated by Claude Code
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b95bcb0ac
ℹ️ 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".
…be binding A describe- or beforeEach-scoped declaration of the imported local name shadows the import for every test in that scope. The re-export arm only checked the test body, so it credited the barrel owner anyway. Proof: describe_scoped_shadow_of_barrel_import_does_not_credit fails without the guard and passes with it; TS lib tests 587 passed; goldens check exit 0; precommit exit 0; clippy -p ripr clean. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PD6CY5kNL5Z4BT2T3M32Yc
…ocked A test that mocks the barrel it imports the owner through (or an intermediate hop) executes the mock, but the re-export arm only checked mocks of the owner's own file and credited re_export_chain_followed. On the new fixture typescript_adversarial_mocked_barrel that read exposed. The resolver now treats a mocked module anywhere on the chain as Unknown. Graduated as honesty corpus case ts_mocked_barrel_unrelated_assertion (must_not_promote, maximum_class weakly_exposed). Proof: mocked_import_barrel_does_not_credit and mocked_intermediate_barrel_does_not_credit fail without the guard; mock_of_a_module_off_the_chain_keeps_the_credit is the positive control; goldens check exits 1 without the guard and 0 with it; honesty gate pass; TS lib tests 590 passed; clippy -p ripr and -p xtask clean; precommit 0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PD6CY5kNL5Z4BT2T3M32Yc
EffortlessSteven
left a comment
There was a problem hiding this comment.
Exact-head self-review of 8619646. It covers the two review-repair commits on top of the head I reviewed earlier, 6b95bcb.
- cdfc210: in
owner_call_relation, the re-export arm now refuses a local found intest.scope_bindings. That matches the constructor and direct-import arms. The negative test puts the shadow in an enclosingdescribe. It fails without the guard and passes with it. - 8619646:
resolve_to_ownertakes&TypeScriptTest, which clears the clippy arg-count lint. It builds a mocked-module predicate frommocks_in_file, using the same normalization as imports pluscanonical_module, and it reusesroot_relative_mock_names_module. An unresolved mock specifier returns false, so it fails closed.resolve_exportchecks the canonicalized module on every frame, so the import barrel and each hop are covered. The owner module itself is still covered by the earliertest_mocks_owner_moduleguard. The rename-export branch (import_module == owner_module) returns before the mock check, but the owner-module guard already covers that case. - Oracle grip: two unit negatives and one positive control. The fixture
typescript_adversarial_mocked_barrelreadexposedbefore the fix (re_export_chain_followed) and readsno_static_pathafter it.goldens checkexits 1 without the guard. The honesty gate asserts over the golden, andgoldens checkbinds that golden to the analyzer. Corpus casets_mocked_barrel_unrelated_assertionassertsmust_not_promoteandmaximum_class: weakly_exposed. - Local results: TS lib 590 passed, goldens 0, honesty pass, precommit 0, and clippy clean on
-p riprand-p xtask. - The Devin perf note stays as is, with the reasons given on its thread. CodeRabbit and Gemini reviews are missing, not clean.
No open findings from this pass. Hosted CI on this head is pending.
Generated by Claude Code
…tory through 9a4f598 Row 16 and the #3913 bullet now name swarm #4523 (94e0c74) as the evidence that clears them once synced. Known limitations adds the check-output review-comments route rendering no cards (#4524, fix #4581). Inventory adds #4496, #4523, #4502, #4517. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AYyUnjaq9zD4WsBujWEUpk
…cribe shadows Two review findings on the loop extractor (Devin): - A loop over a possibly empty iterable (`const rows = []`, a `let`, an import, a parameter) was walked, so a test that never registers could expose the owner. A loop is now walked only when its iterable is a non-empty array/object literal, Object.entries/keys/values of one, or a const whose innermost binding in scope is a single declaration of one; a counted for needs literal bounds. Other loops stay unwalked and disclosed as typescript_test_extraction_partial. - A loop variable or describe parameter reusing an imported owner's name was credited as a direct/imported/alias/class-method call. Scope bindings now record whether they are file-level; any other level shadows the called name in every owner-call arm. Proof: with the shadow guard disabled, the loop-variable and describe-parameter end-to-end tests (and the #4502 describe-scope barrel test) fail; with the non-empty proof disabled, the zero-iteration end-to-end test and both not-walked tests fail. ufo eb29945/5cd9e67 replay still reads 3 exposed and 5 weakly_exposed. TS lib 602 passed; goldens 0; honesty pass; precommit 0; clippy ripr and xtask clean. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PD6CY5kNL5Z4BT2T3M32Yc
…backs (#4593) * fix(typescript): extract tests declared inside loops and forEach callbacks Tests registered in a `for`, `for...of` or `for...in` body or a `.forEach` callback at file or describe level were never extracted, so suites written like unjs/ufo left the owners they call reading `no_static_path`. The extractor now walks those bodies, shadows enclosing bindings with the loop variables or callback parameters, and names a computed title `<computed title, line N>` under its describe. Relations still come only from the test body. Loops over a literally empty array and loops whose target is not a declaration are not walked and stay disclosed as `typescript_test_extraction_partial` (RIPR-SPEC-0027). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014vnx74g4Sw9wuFrowxNf2d * test(typescript): keep the partial-extraction collapse test on an unindexed shape Top-level template-literal titles are now extracted, so the #4429 collapse test wraps its registration in an `if` block, the same still-unindexed shape its sibling test uses. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PD6CY5kNL5Z4BT2T3M32Yc * fix(typescript): walk only loops known to run, and honor loop and describe shadows Two review findings on the loop extractor (Devin): - A loop over a possibly empty iterable (`const rows = []`, a `let`, an import, a parameter) was walked, so a test that never registers could expose the owner. A loop is now walked only when its iterable is a non-empty array/object literal, Object.entries/keys/values of one, or a const whose innermost binding in scope is a single declaration of one; a counted for needs literal bounds. Other loops stay unwalked and disclosed as typescript_test_extraction_partial. - A loop variable or describe parameter reusing an imported owner's name was credited as a direct/imported/alias/class-method call. Scope bindings now record whether they are file-level; any other level shadows the called name in every owner-call arm. Proof: with the shadow guard disabled, the loop-variable and describe-parameter end-to-end tests (and the #4502 describe-scope barrel test) fail; with the non-empty proof disabled, the zero-iteration end-to-end test and both not-walked tests fail. ufo eb29945/5cd9e67 replay still reads 3 exposed and 5 weakly_exposed. TS lib 602 passed; goldens 0; honesty pass; precommit 0; clippy ripr and xtask clean. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PD6CY5kNL5Z4BT2T3M32Yc * fix(typescript): do not walk a loop whose binding shadows the runner API A loop variable or forEach parameter named test, it or describe shadows the runner inside the body, so its calls register nothing (Codex). Such a loop is no longer walked. A counted for with a non-admitting literal condition (false, 3 < 1) is covered by the existing negative test. Proof: loop_binding_named_like_the_runner_api_is_not_a_registration fails with the guard disabled; TS lib 603 passed; goldens 0; precommit 0; clippy -p ripr clean. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PD6CY5kNL5Z4BT2T3M32Yc --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steven · project thread
Summary
Before: on unjs/ufo eb29945 and 5cd9e67, every changed line of
withBase/withoutBasereadno_static_pathwith 0 related tests. The tests writeimport { withoutBase } from "../src", a directory whosesrc/index.tsisexport * from "./utils". ripr resolved../srcto a module namedsrc, which matched no barrel (the star edge was recorded forsrc/index), and it followed only one hop.After: a directory specifier resolves to its
indexmodule when no file module of that name exists, andexport */export { N } fromchains are followed inside the repository for up to 4 hops. The ufo barrel shape now relates the importing tests.How (
ReExportIndexintypescript/related_tests.rs, the existing owner): each module records its own exported names, so a star hop forwards a name only when the target module exports it. It fails closed on:export *ofdefault;describe-scoped redeclaration of the imported name;Type-only
export type ... fromstatements are skipped. A test that imports only another name from the same barrel stays unrelated.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: accuracy replay on real OSS, ledger
accuracy/2026-09-28-oss-replay-ledger.md(defect T1)Spec: RIPR-SPEC-0095 (TypeScript bounded re-export test discovery), updated; RIPR-SPEC-0108 corpus case added
ADR: n/a
Plan item: 0.11 release accuracy
Governing issue or accepted claim: this PR
Acceptance delta (one sentence): a TypeScript test importing a changed function through a bounded in-repo barrel chain is related to it.
Candidate Relationships
Candidate branch:
claude/land-accuracy-patches-9bpkh0Stack parent or prerequisite PR: none. Follows #4477 (Python re-exports). The TS loop-declared-tests fix lands after this one. Together they move ufo eb29945/5cd9e67 from 8
no_static_pathfindings to 3exposedand 5weakly_exposed.Scope
Scope Classification
Non-goals: factory products (defu's
createDefu(), ledger T3),tsconfigpath aliases beyond the existing resolver, and tests declared in loops (next PR).Support-tier Impact
Policy Impact
Proof
On this head (8619646), based on main 11d12ab:
reexport_chain_tests: 15 tests throughReExportIndex::buildandfind_related_tests. 9 of the original 11 fail on main.typescript_reexport_directory_star_barrel(ufo shape): moves fromno_static_pathtoexposed.typescript_reexport_barrel_other_name: a negative control that stays unrelated.typescript_reexport_two_hop_limitre-blessed: its two-hop named chain is now inside the bound, so it moves fromno_static_pathtoexposed.describe-scoped shadow (Codex P1). Its negative test fails without the guard.typescript_adversarial_mocked_barrelreadexposed, and it now readsno_static_path. It graduated to the honesty corpus asts_mocked_barrel_unrelated_assertion.goldens checkexits 1 without the guard. Unit negatives cover a mocked import barrel and a mocked intermediate hop. The positive control, a mock of an off-chain module, keeps the credit.Claim Boundary
May claim: TypeScript tests that import a name through up to 4 in-repo
export */export { N } fromhops relate to the owner, unless a module on the chain is mocked.Must not claim: that factory products, dynamic re-exports or package-boundary barrels are traced.
Rollback
Revert the squash commit. The four fixtures and the corpus case revert with it.
Spec-Test-Code Traceability
typescript/tests/reexport_chain_tests.rs, fixtures abovetypescript/related_tests.rs,typescript/types.rs,typescript/classifier.rs,typescript/mod.rstypescript_adversarial_mocked_barrel.ripr/traceability.tomlupdatedStatic Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.🤖 Generated with Claude Code
https://claude.ai/code/session_01PD6CY5kNL5Z4BT2T3M32Yc