Repository navigation
fix(typescript): reach owners passed as values and built by combinators (#13592) - #14993
Conversation
…rs (#13592) The same-module entry graph only followed bare calls, so code reached through a closure read no_static_path: a function passed as a value (`JSON.parse(text, reviver)`, `keys.sort(compare)`), a constant built by a call whose callbacks run when the value is invoked (`const Rule = match(re, (s) => upper(s))`), and the combinator that built it. The graph now records closure edges (AST references to other top-level declarations, minus anything the code binds, anything the module reassigns, type positions and a factory's directly returned functions) and gives an owner reached only along a path with a closure edge a closure entry, bounded at 8 edges. Closure entries continue across importers and read static_unknown whatever the oracle: when the value runs is not modeled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
Mixed call and closure reach says "same-module or callback callers" and keeps the same-module class; reference collection skips the own/returned split when nothing is returned and dedups through sets; an owner keeps at most 32 closure entries; a bare-called combinator constant reads its entry as closure reach. Four more tests pin these and the cross-module closure bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 14 minutes. View limit details
|
…#13592) A member write (obj.x = 1, obj[key]++) no longer marks obj or key as reassigned; a bare or destructuring-shorthand identifier target still does. The closure-entry cap is now pinned by a test, and its comment and spec text say an owner past it reads as before closure reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
…ue_use (#13592) A call-built constant that a function reads gained closure entries, and the module-entry search ran before the module_value_use heuristic, so a test that names the constant itself dropped from weakly_exposed to static_unknown (fixture typescript_module_value_use). Direct value use now wins; closure entries apply only when no test names the constant. typescript_module_value_unused moves no_static_path -> static_unknown: its test calls collect, which reads stop, the reach this PR adds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
…13592) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
…e reach (#13592) total = withLogging(computeTotal) is a call-built constant that passes computeTotal as a value; the test calling total now relates with reach only. No oracle is borrowed and no repair packet is emitted; exposed stays forbidden. Honesty corpus and RIPR-SPEC-0108 rows updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
|
|
Main landed #13592 B2 (module-level const read through a same-module reader). Combined: a B2 value keeps its reader entries; any other call-built constant (a factory product graph node) reads every entry as a closure entry. Both PRs bumped the TS file-fact schema to 9, so this one moves to 10. B2's factory_const test now asserts closure-only entries. Symbol(...) constants are B2 values and exported values are never followed, so typescript_module_value_unused keeps main's no_static_path; the precedence test uses a factory-built sentinel instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLUXKv4U44DhiT1ST6G
#13592) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
EffortlessSteven
left a comment
There was a problem hiding this comment.
VERDICT: BLOCK 4a58b3d
Source review of #14993 at this head. One confirmed defect in the new closure-edge owner, against the mask set this PR itself writes into SPEC-0243.
Blocking: a named function expression's own name is never masked
Trigger. A module with a top-level helper plus
export const label = function helper() { return helper.name; };.
In JS the inner helper binds to the function expression's own name, not the top-level declaration.
Mechanism (source, not inference).
collect_function_as(module_entries.rs:511) callsadd_function_references(name, &func.params, body, &returned, nodes). The declaration's name is the declarator's (label);func.idis passed nowhere.References(line 673) binds only theBindingIdentifiers it visits, andadd_function_referencesvisitsFormalParametersand theFunctionBody(lines 700-701) — never theFunctionnode that carriesfunc.id.- So
all.boundmisseshelper,push_unbound(line 731) keeps it innode.references, andclosure_callees(line 285-296) admits it becausenodes.contains_key("helper")and nothing filters it.
Effect. Every test that names label gives top-level helper a closure entry, so a changed helper reads static_unknown instead of no_static_path. Reach is invented for an owner no test runs — the direction this graph exists to prevent.
Predicate it violates. SPEC-0243 as amended in this PR: "A name the referencing code binds anywhere (parameter, local, inner function, nested callback parameter, catch binding), a name the module ever assigns or updates, and a reference in a type position add no edge." A named function expression is exactly an "inner function", so the spec states a guarantee the code does not implement, in the same commit.
Repair at the seam. Bind the function expression's own name before the references are recorded (insert func.id into all.bound, or visit the Function node instead of params+body), and add two cases to tests/closure_entry_tests.rs: the named expression referencing itself with a top-level same-name declaration, and the same source with no top-level helper (both must stay no_static_path).
Non-blocking: the factory edge ignores its own reassignment, more narrowly than reported
closure_callees inherits nodes.get(factory).returned_references (lines 280-284) and applies reassigned only to the targets (line 293), so a rebound factory still supplies the original returned function's references. Devin's phrasing ("after a factory is reassigned") is too broad: const Rule = makeRule(...) evaluated before the rebinding correctly inherits, because the initializer ran against the original binding. It is wrong only when the factory is rebound before the product's initializer runs, and reassigned_names is order-insensitive, so the code cannot tell those apart. Applying "may hold another value" to the factory is the consistent choice, but the consequence is the same bounded class movement (no_static_path → static_unknown) with no test credit, so I am not blocking on it.
What I checked and what I did not
Checked by source reading: the closure-edge construction, References/push_unbound, the reassignment and hop filters, the SPEC-0243 amendment this PR adds, the new closure_entry_tests.rs case list, and the fixture/expected deltas for verdict movement.
Not established: I did not execute the TypeScript analyzer locally, so this is a static determination of the bound set rather than an observed finding on a fixture; hosted CI would not decide it either, since no case exercises the shape. The cheapest discriminator is the pair of unit tests named above. If the author believes helper is masked somewhere I missed, that test settles it in one run.
This head carried no earlier attestation to supersede: the two reviews at 13:20Z were body-less and therefore were never a disposition.
Next action: repair the binding mask and push; I will re-review the new head at the source stage.
…assigned factories, module values (#13592) - A named function expression's own name binds inside its body, so it is never a closure edge to a same-named top-level declaration (Devin). - A reassigned factory lends its product no returned references (Devin). - A B2 module value continues across importers only on closure entries, matching a value with call entries only (merge-resolution review). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
|
Re the
Proof on 48f206e: Generated by Claude Code |
…; widen precedence comment (#13592) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
|
REVIEW_READY Head: 2ddb823 This records a fresh-context independent reviewer subagent's result on this exact head. It is not the author's own read.
Local proof on 48f206e (2ddb823 changes no code):
Generated by Claude Code |
EffortlessSteven
left a comment
There was a problem hiding this comment.
REVIEW_READY
This records a fresh-context independent reviewer subagent's result on this exact head (2ddb823). The PR comment above has the full scope. The named-function-expression finding from the earlier review is repaired in 48f206e, with a test.
Generated by Claude Code
EffortlessSteven
left a comment
There was a problem hiding this comment.
SOURCE_REVIEW_READY
Source review of #14993 at 2ddb8234aa54e4ce0048e6d79ce7ba774d096120. This supersedes my VERDICT: BLOCK at 4a58b3da.
Blocking finding: repaired
Named function expression self-name. collect_function_as now drops func.id's name (when it differs from the declarator) from the node's references and returned_references.
I checked the mechanism rather than the claim. add_function_references visits params and body only, never func.id, so the expression's own name was never in bound and push_unbound could not filter it — that is exactly the leak I reported. The retain closes that gap for both vectors. The call-built path (Expression::CallExpression) was never affected: it visits the whole initializer with References, whose visit_binding_identifier records the function expression's own name as bound, so push_unbound already dropped it there.
Discriminating test. a_named_function_expression_self_reference_is_not_the_outer_declaration PASSes in hosted shard 1 (run 44167871137, 20:35:31Z). Its anonymous twin asserts helper gets the closure entry ["label"], so removing the mask fails the test; the self-named twin asserts no entry. The test is not vacuous.
a_reassigned_factory_lends_no_returned_references also PASSes (20:35:32Z), with the same positive-twin shape.
Evidence at this head
- Rust tests shard 1 of 2: success. Shard 2 of 2: success. Shard verify: success.
- Rust gates: Strict all-features Clippy, Strict workspace Clippy, Required Rust doctests, Golden and fixture contracts, Verdict corpora, Base still merges cleanly — all success.
Admit PR Candidate: pass at this head (run 44167871137).- The earlier
Ripr Rust Small Resultfailure (run 44167546404, 20:16:25Z) was the admission refusal before the 20:18 attestation, not a test failure: the log reads "source review attestation refused".
Non-blocking observations
- The bare-call text scan still credits a self-named recursive function expression.
function helper(n: number): number { return n; } export const label = function helper(n: number): number { return n <= 0 ? 0 : helper(n - 1); };—label'scall_textscontain the tokenhelper, so a test callinglabelis credited with reaching the top-levelhelperit never calls. This is the pre-existing text-tokencalleesscan inadd_function_node, not the closure surface this PR adds, and the same false edge exists for nested declarations, parameters and locals. The closure path is fixed; the call path is a separate, older limitation. Worth a follow-up issue, not a block here. - The third change has no dedicated test.
(!module_value || entry.closure)inCrossModuleEntries::ofnarrows a call-built constant's cross-module continuation to closure entries.a_cross_module_closure_chain_takes_the_closure_boundcovers a function owner, not a call-built constant, so this narrowing is unguarded by a regression test. - SPEC-0243's "296 caught mutants" is a local corpus measurement I did not reproduce. The schema claim is correct:
TYPESCRIPT_FILE_FACT_SCHEMA_VERSIONis"10".
Not established
Ripr Rust Small Result is not yet green at this head: the gates job's PR evidence step is still running. Source readiness is posted on the source evidence above; final readiness needs that check green on this exact head.
Next action
Root's enqueue call once Ripr Rust Small Result is green on 2ddb8234aa.
|
|
|
FYI: #15286 is a real-world case of the "combinator that built it" shape. A change inside the function returned by A regression test for it would be useful on this PR, with these negative controls:
We are not writing a separate fix in Generated by Claude Code |
|
For #15286, I ran a generated TypeScript control that distinguishes the function a factory returns from a different closure inside the same factory. All cases use the same test body,
The source for the first three rows was: function unrelated(depth: number) {
if (depth === 0) return "unused";
return "other";
}
function factory(fn: (key: string) => string) {
const neverCalled = (depth: number) => {
if (depth === 0) return "nested";
return "other";
};
return function mapKeys(key: string, depth = 1): string {
if (depth === 0) return key;
return fn(key);
};
}
export const upperKeys = factory((key) => key.toUpperCase());Each mutation changes one The sibling case matters for the exact-entry follow-up: promoting a test relation based only on the enclosing I checked out main When resolving this PR's main conflict, please run these one-hunk diffs through |
Main moved the TS file-fact schema to 11 (#15939), so closure moves to 12. Keeps main's build-entry relation tier ahead of the heuristic fallback. Takes main's typescript_adversarial_hoc_wrapped_owner expected files for re-blessing on the merged head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
…in (#13592) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
|
I merged main again (conflicted since 2026-11-18). The new head is 52a8a77.
Factory controls from the #15286 comment, run on the merged head (debug binary at 52a8a77's source). Each case is a one-hunk diff through
This matches the PR's conservative scope:
The returned body and the sibling arrow share the owner Local proof on 52a8a77. Not established locally. The Generated by Claude Code |
EffortlessSteven
left a comment
There was a problem hiding this comment.
REVIEW_READY
This records a fresh-context independent reviewer subagent's result on this exact head (52a8a77). That review covered the second main merge on top of 2ddb823, which was itself reviewed as ready.
- related_tests.rs: the merged order is owner call, then the
ModuleFunctionheuristic, then module entries, then main'sbuild_entry_calltier, then the heuristic fallback. Main's new tier finds nothing forModuleFunctionowners, on main too, so skipping the second heuristic pass hides nothing. - Schema: 12 after #15939's 11, and the pin is updated.
- Main's changes since 2ddb823: none of them can raise closure reach above
static_unknown. #15939's replacement refusal is still applied to the entry's stand-in owner. - Fixture:
typescript_adversarial_hoc_wrapped_ownerstill readsstatic_unknownwith no repair packet, consistent with its SPEC.md and the honesty corpus. - Low note, non-regressive: a test that stubs an inner function but calls its wrapper still relates through a closure entry, as plain module entries already do on main. It reads
static_unknownonly.
Generated by Claude Code
|
|
Main's #15962 took TS file-fact schema 12; closure entries move to 13. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
…ss entries (#13592) Main's #15962 and instance-factory statics build module entries without the closure field; both are call/inheritance reach, so closure is false. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWNFkvBxA39ETvfk7J
EffortlessSteven
left a comment
There was a problem hiding this comment.
REVIEW_READY
This records a fresh-context independent reviewer subagent's result on this exact head (1638b8a). It covers the delta 52a8a77..1638b8a. That is the third main merge, which brought #15962's barrels, heritage and instance-factory statics and #16023's setup mocks, plus the two closure: false additions. 52a8a77 itself was reviewed as ready.
- Construction and forwarding: every
TypeScriptModuleEntryliteral setsclosureexplicitly.- Closure-derived paths only copy the flag:
module_entries.rs:390sets it, andrelated_tests.rs:555/632/646copy it. - Main's import-then-export forwarding and namespace-barrel matching only affect name resolution. A closure entry carried through a barrel keeps
frame.closure, so it still reads opaque.
- Closure-derived paths only copy the flag:
- New entry kinds:
closure: falseis correct for static factories (instance_factories.rs:178) and subclass entries (related_tests.rs:789). Both are class-member owners and never closure-derived. - Schema: 13 after main's 12. The constant, the pin test and the spec line 1104 are consistent, with no stale claim.
- Classifier: main's changes don't touch
module_entry_reach_is_opaque_onlyormodule_entry_reach_includes_closure. - Local evidence on this head:
cargo test -p ripr --lib -- analysis::language::typescriptgives 2785 passed. goldens check, fixtures, verdict-corpus check-all and check-evidence-promotion-honesty also pass. - Low, informational: no test pins a closure entry through an import-then-export barrel. The flag holds by construction, since it is carried on the walk frame.
Generated by Claude Code
Requested by Steven Zimmerman · project thread
Summary
no_static_patheven when tests run it. Three shapes were missed: a function passed as a value (JSON.parse(text, reviver),keys.sort(compare)), a constant built by a call whose callbacks run when the value is invoked (const Rule = match(re, (s) => upper(s)), thenparse(input, Grammar)), and the combinator that built it. The same-module entry graph only followed bare calls.closureentry. The path may take at most 3 bare calls before its first closure edge and at most 8 edges in total, and an owner keeps at most 32 closure entries. Closure entries continue across importers.static_unknownwhatever the oracle. It is neverexposedorweakly_exposed, and it starts no repair, because when the value runs is not modeled.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: n/a
Spec: RIPR-SPEC-0243 rule 2 (new "Closure continuation" paragraph)
ADR: n/a
Plan item: n/a
Governing issue or accepted claim: #13592
Acceptance delta (one sentence): TypeScript owners reached only through a closure (a function passed as a value, a combinator-built constant, its callbacks or its combinator) read
static_unknowninstead ofno_static_pathwhen a test calls the export that leads to them, cutting Stryker-caught false gaps on the eight-package corpus from 619 to 323 against current main with no other verdict change.Candidate Relationships
Candidate branch:
claude/project-thread-dm57grStack parent or prerequisite PR: none (builds on merged #13886 / #14958 / #13719 B2)
Proposed replacement of PR: none
Scope
module_entries.rs: closure edges (References,reassigned_names), closure entries (reachable_through_closures,MODULE_CLOSURE_MAX_HOPS = 8,MAX_CLOSURE_ENTRIES_PER_OWNER = 32).owners.rs: a call-built constant (ModuleFunction) owner that is a graph node (a factory product) gets its entries, all read as closure reach. A B2 value (Symbol(...), literal,new X()) keeps its reader entries as feat(ts): reach a module-level const through a same-module reader (#13592 B2) #13719 reads them. A test that names the constant itself keeps themodule_value_userelation (typescript: a changed exported const (e.g.export const pMapStop = Symbol('stop')) reads no_static_path although tests import and assert on it #8568), so a test that names the constant staysweakly_exposed.related_tests.rs:cross_module_entriescontinues closure entries across importers under the closure bound and prefers a call chain over a closure chain. Newmodule_entry_reach_is_opaque_onlyandmodule_entry_reach_includes_closure.classifier.rs: opaque-only reach readsstatic_unknown, with its own discriminate summary, next step and missing line. Mixed call-plus-closure reach keeps the same-module class and says "same-module or callback callers".closurefield; feat(ts): reach a module-level const through a same-module reader (#13592 B2) #13719 took 9). The classified seam cache is not bumped: its key already binds the analyzer build identity, and the TS verdict change fix(typescript): see calls in template substitutions and after a /* in a comment or string (#13592) #13886 did not bump it either.Scope Classification
Production delta:
static_unknown.Evidence/support delta:
tests/closure_entry_tests.rs(18 tests), spec paragraph, changelog fragment.no_static_path→static_unknown, blessed with a RIPR-SPEC-0243 reason:typescript_adversarial_hoc_wrapped_owner(the test callstotal = withLogging(computeTotal); no oracle borrowed, no repair packet,exposedstill forbidden; honesty corpus and RIPR-SPEC-0108 rows updated).factory_const_keeps_its_previous_no_entry_readingbecomesfactory_const_is_reached_only_as_a_closure: a bare-called factory product gets closure entries only.Single acceptance criterion:
no_static_path, and it never reads better thanstatic_unknown.Non-goals:
test/glob.spec.tsregisters its vendored suite through a localdescribe((it) => it(..., (t) => t.true(...)))and extracts no tests; that is a separate follow-up.Support-tier Impact
Policy Impact
Proof
no_static_pathagreement rises from 42.7% to 56.1% (461/1080 → 412/735). Every moved mutant (345) movedno_static_path→static_unknown, and no other class changed on any of the 8 packages. The 49 missed mutants that moved are the cost of not modeling when a callback runs. (Before #13719 landed, against cedfe04, the same slice measured 723 → 428.)The replay reads the class whatever the analysis completeness. The xtask harness excludes most pathe mutants as
analysis_incomplete, because pathe'stest/utils.spec.tsregisters tests in anObject.entriesloop. So the table counts are not the hosted receipt's figures.Result, failures, or skipped proof:
Claim Boundary
May claim: closure-only reach is related and reads
static_unknown, and the false-gap reduction on this corpus at these revisions.Must not claim: that a callback runs, discrimination, or a change to the hosted spot-check receipt before a rerun. #13592's agreement goal is not met; this is one slice.
Rollback
Revert the squash commit. The file-fact schema bump makes old cache entries read as misses in both directions.
Spec-Test-Code Traceability
Static Language Check
killed,survived,untested,proven, andadequate.propagation_evidence_unknown).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_01UNUoLWNFkvBxA39ETvfk7J