* docs(scope): clarify lexical binding ownership and wrapper provenance
Checkpoint for #3630. Publishing the implemented source, regression tests, and benchmark harness as a draft PR; full-suite and final scaling validation remain in progress.
* fix(scope): publish #3630 docs/plans
* fix(scope): publish #3630 gitnexus/bench/lexical-binding-provenance
* fix(scope): publish #3630 gitnexus/bench/lexical-binding-provenance/fixtures
* fix(scope): publish #3630 gitnexus/bench/lexical-binding-provenance/results
* fix(scope): publish #3630 gitnexus/src/core/ingestion
* fix(scope): publish #3630 gitnexus/src/core/ingestion/languages/typescript
* fix(scope): publish #3630 gitnexus/src/core/ingestion/languages
* fix(scope): publish #3630 gitnexus/src/core/ingestion/pipeline-phases
* fix(scope): publish #3630 gitnexus/src/core/ingestion/route-extractors
* fix(scope): publish #3630 gitnexus/src/core/ingestion/workers
* fix(scope): publish #3630 gitnexus/test/fixtures/lang-resolution/fetch-wrapper-target-identity/lib
* fix(scope): publish #3630 gitnexus/test/fixtures/lang-resolution/fetch-wrapper-target-identity
* fix(scope): publish #3630 gitnexus/test/fixtures/lang-resolution/fetch-wrapper-target-identity/packages/http
* fix(scope): publish #3630 gitnexus/test/fixtures/lang-resolution/fetch-wrapper-target-identity/packages/http/src
* fix(scope): publish #3630 gitnexus/test/fixtures/lang-resolution/fetch-wrapper-target-identity/server
* fix(scope): publish #3630 gitnexus/test/fixtures/lang-resolution/fetch-wrapper-target-identity/web
* fix(scope): publish #3630 gitnexus/test/integration/resolvers
* fix(scope): publish #3630 gitnexus/test/unit
* fix(scope): publish #3630 gitnexus/test/unit/group
* fix(scope): publish #3630 gitnexus/test/unit/scope-resolution
* fix(scope): publish #3630 gitnexus/test/unit/scope-resolution/typescript
* fix(scope): publish #3630 gitnexus-shared/src/scope-resolution
* fix(scope): treat wrapped assignment targets as writes
`(app) = new Map()`, `(app as T) = x` and `app! = x` assign the same binding as
`app = x`, but route-fact invalidation and the shared pattern walker stopped at
the wrapper, so Express provenance survived the write and produced a false
route. Recurse through parenthesized, as/satisfies and non-null targets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): resolve wrappers through overloads, declarator lists and barrels
Three wrapper shapes lost their identity:
- Bodyless overload signatures were indexed as separate definitions sharing
the implementation's binding, so the binding looked ambiguous and both local
and imported calls were rejected. Signatures now declare no callable.
- Facts for `const base = 0, request = (url) => fetch(url)` followed the first
declarator. The captured name now selects its own declarator.
- An import resolved to a workspace barrel stopped at index.ts. Workers now
record named, star and imported-then-exported re-exports, and resolution
follows them to the declaring module: local and named exports shadow
`export *`, star exports never carry `default`, and conflicting star exports
block the name. No repository-wide name fallback is restored.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(scope): assert closure ownership against the declaration
The closure-write assertion compared one lookup with itself, which also passes
when both are undefined. Compare it with the outer declaration and the shadowing
parameter, and keep the memoization check explicit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(routes): share lexical helpers and release per-file HTTP contexts
- Share binding keys, parameter patterns and transparent expression wrappers
from lexical-bindings instead of four local copies; drop the unused
moduleStem export; name the inferred-source predicates in lookup.
- Key the per-file HTTP context by its tree rather than its ParsedFile.
Workers retain ParsedFiles for the whole chunk, which kept every file's AST
and traversal maps alive until the chunk flushed.
- Index re-exports by name, memoize barrel walks per starting export, and keep
facts without import targets as-is instead of copying them.
- Move TS-only wrapper cases into the TS describe.each instead of branching
inside the per-language loop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): keep wrapper identity for HOCs, CommonJS, object keys and fetch packages
Four definition shapes that main linked by name lost their wrapper identity:
- `const load = useCallback((url) => fetch(url))` and curried HOCs produced no
facts because definition lookup stopped at the call; it now follows the
callable argument, as the structural definition capture does.
- `module.exports = { request }`, `exports.x = …` and `module.exports.x = …`
were not exports, so destructured `require` callers missed the wrapper.
CommonJS export assignments are recorded when `module`/`exports` are the
unshadowed globals, including functions defined inline in the export object.
- An object-literal key or method name was resolved as a lexical binding and
collided with a same-named module wrapper. Only binding identifiers now name
a definition's binding.
- `import fetch from 'node-fetch'` no longer counted as fetch. Imports of known
fetch implementations (node-fetch, cross-fetch, isomorphic-fetch, the fetch
member of undici and whatwg-fetch) are fetch evidence again; parameters and
other local names still are not.
Reference identifiers are also resolved only when their name is bound to a
callable or class region; other identifiers cannot add a reachability edge.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(routes): drive the forwarding fallback case from data and cover re-export merges
Replace the boolean-switched forwarding fallback case with table rows instead
of branching inside the test, and assert that barrel re-export facts survive
worker sub-batch merges.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): reject stale or dirty call-graph exports
The committed comparison named a candidate revision that is not on this branch,
and nothing stopped it. Comparison now requires both exports to come from clean
checkouts and the candidate export to come from the checkout running the
comparison.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): regenerate the call-graph comparison on the reviewed head
Clean baseline 565e50276 and clean candidate 8a5f7b738 on the frozen 432-file
corpus (fingerprint 88be1faf...): exactly one CALLS target changes, the
annotated closure probe `declaredOwner.writeAndRead` now calls `Base.m`
instead of `Foo.m`. The other 431 CALLS and all 11 METHOD_OVERRIDES edges are
unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): emit export provenance and review notes from the comparison
The comparison report carried export provenance and the expected-change
explanation only as hand-added fields, which a regeneration dropped. Emit
both exports' revisions, dirty flags and fingerprints, the unchanged CALLS
and METHOD_OVERRIDES counts, and an optional `--note` explanation directly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): record calibrated scaling reports and the regenerated comparison
Duration-calibrated-v2 runs (5 warmups, 15 measured batches, 500 ms pilot
target) pinned to the same CPU, baseline then candidate back to back:
- Baseline 565e50276 exceeds the 1.8 normalized ceiling on six arms at 4x
input: position-index 7.92, position-deep-completed 4.65, nested-helpers
4.82, nested-helper-chain 14.05, reverse-chain 4.31, name-collisions 2.61
(medians).
- Candidate 94f1a055b passes --check: every arm stays at or below 1.32 at 4x
for both minimum and median, with correct semantic guards on every arm.
The comparison is regenerated from clean exports with its provenance and
review note emitted by the tool: one expected CALLS target change, 431 CALLS
and 11 METHOD_OVERRIDES unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(scope): replace recursion with explicit stacks in new traversals
The binding work added five recursive traversals whose depth follows input
shape: region summaries (callable nesting), barrel resolution (re-export
chain length), pattern binding names (destructuring depth), route-fact write
invalidation (pattern depth), and the position index's max-end tree. Each
now uses an explicit stack with the same visiting order and results.
Regression cases cover the inputs the recursive versions could not handle:
a 20,000-deep destructuring pattern and a 50,000-module re-export chain both
threw RangeError before this change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* perf(routes): avoid a full-tree script walk when building lexical bindings
Route-fact extraction ran 1.78x slower than main on a 512-function file
(87 ms vs 49 ms) because createLexicalBindings walked every AST node in script
to detect collapsed parameter/body environments, which only functions with
parameter defaults or computed keys can have.
- Find functions with the native type search, skip plain parameter lists
without any subtree search, and walk only the formals and bodies of the
rest. Detection is unchanged, except that functions inside syntax-error
regions are now also checked, which can only add fail-closed ambiguity.
- Read each node's id and start position once per lookup instead of
repeatedly crossing into native getters.
The same extraction now takes about 56 ms against 51 ms on main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* perf(routes): walk wrapper evidence with a tree cursor
The wrapper context visited every node through namedChildren, which
materializes each child as a SyntaxNode and records a parent edge by node
id. A tree cursor reads node types and offsets natively, so only the node
types the handlers inspect become SyntaxNodes. Declared identifiers are
keyed by start offset, and the walk records the ancestor facts later
queries need (stored binding, default export, declarator of a name)
instead of a parent map.
On the 512-wrapper scaling input, context construction drops from about
58 ms to 48 ms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): regenerate the call-graph comparison on the cursor walk
The candidate export at 6061ca71b has the same fingerprint as the previous
candidate: the traversal rewrite changes no edge. The one expected target
change and the 431 unchanged CALLS and 11 METHOD_OVERRIDES remain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): record final scaling reports on the cursor walk
Baseline 565e50276 and candidate 61de364ff ran back to back on CPU 23
with the duration-calibrated-v2 protocol. Every candidate check stays at
or below a 1.32 normalized factor against the 1.8 ceiling; the baseline
fails six of nine arms. Workload fingerprints agree except the documented
name-collision false positive in the baseline.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(plan): checkpoint the final review, scaling and suite results for #3630
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): treat export aliases of one wrapper as one star-export target
Star-export candidates were deduplicated by the resolved export name, so
`export { request, request as send }` reached through two barrels counted
as two targets and blocked the import, dropping the consumer's FETCHES
edge. Candidates are now keyed by the declaration each export name names,
matching ECMAScript ResolveExport's binding comparison; distinct
declarations exported under the same name stay ambiguous.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): regenerate scaling and call-graph reports on the alias fix
Baseline 565e50276 and candidate 4d62bd045 ran back to back on CPU 23.
Every candidate check stays at or below 1.22 against the 1.8 ceiling;
the baseline still fails six of nine arms. The CALLS/METHOD_OVERRIDES
export is unchanged (fingerprint 4db24f57), so the comparison only
records the new candidate revision.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(plan): record the export-alias fix and the regenerated reports for #3630
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(scope): keep the type a write gives an undeclared name
A constructor write to a name no scope declares (`client = new ApiClient()`
in sloppy JavaScript) declares nothing, so the lookup stays absent. The
carried constructor fact was dropped on that exit, which lost the receiver
type main had inferred for later reads in the writing scope. The absent
result now carries it, and findReceiverTypeBinding uses it before the
namespace fallbacks. Only complete-claim providers carry such a fact.
Tests pin the carried type per inferred source, the undeclared write, and
preservePosition across a module redirect.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): close the wrapper identity gaps found in review
- CommonJS wrappers captured as their assignment (`exports.x = function`,
`module.exports.x = () =>`) produce facts again: findFunction follows the
assignment's right side.
- Name-only fallback considers only definitions that can be the target: an
unresolvable import names a module-level export, an undeclared global a
top-level function. Nested and unexported helpers no longer erase a
wrapper's edges.
- Only possible wrappers and module-level functions are emitted, and the
routes phase builds the index only when routes and candidate calls exist.
- A rebound binding (later assignment, `var` initializer over a function
declaration, reassigned export) proves no wrapper across files.
- `(<T>x) = ...` is a write; transparent wrappers skip type arguments.
- Calls inside recovered syntax are still collected; instance-field
initializers resolve after the module body, so a later declaration is
visible.
- Local exports are always recorded, so a star export conflicting with a
non-callable export is ambiguous, and fully resolved barrel frames are
shared across walks.
- HTTP hooks run per file under a guard; a failing file or one without a
ParsedFile still records its function names so fallback declines.
- namesFetch is iterative, large patterns no longer spread into push, the
facts cache is keyed by the name node, and the provider context cache
checks its ParsedFile.
Tests cover each case; the behavior rows fail on the previous source.
The TS-only call cases no longer branch inside the test file, call targets
are asserted exactly, the function-type list is drift-checked, and the
persistence test joins the cross-platform worker list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(routes): describe wrapper fallback, barrel and recall boundaries
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): count the new CommonJS fixture's dropped write site
`lib/cjs-member.js` in the fetch-wrapper target-identity fixture writes
`module.exports.arrowRequest`, a member write whose receiver is not typed.
That adds one `receiver-unresolved` write (190 -> 191 all-kind drops,
19 -> 20 writes). Call drops and shape-arm states are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): regenerate scaling and call-graph reports on the review fixes
Baseline 565e50276 and candidate 528ea1478 ran back to back on CPU 23.
Every candidate check stays at or below 1.27 against the 1.8 ceiling; the
baseline still fails six of nine arms. The CALLS/METHOD_OVERRIDES export
is unchanged (fingerprint 4db24f57), so the comparison only records the
new candidate revision.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(plan): checkpoint the review fixes and regenerated reports for #3630
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(routes): share CommonJS checks and trim per-node work
- `isCommonJsGlobal`/`isModuleExports` in lexical-bindings replace the two
copies in fetch-wrapper and framework-route-facts (both resolve the same
scope from the same start position).
- LEXICAL_FUNCTION_TYPES is derived from the TypeScript FUNCTION_NODE_TYPES
instead of a third hand-kept copy; the drift test still pins it.
- `unwrap` reads UNWRAPPED_TYPES, the set the cursor walk mirrors, and the
class-body region is no longer shadowed under the name `deferred`.
- framework-route-facts reads each node's type once per loop iteration.
- The position index returns the latest-starting scope when it already
contains the point, before the max-end tree search; that entry is the
search's rightmost match.
- carried() returns a shared empty set for argument forms that cannot carry
a value, the resolution file set is built without intermediate arrays,
and the routes phase reads the call list once.
No behavior change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): regenerate scaling and call-graph reports on the refactor
Baseline 565e50276 and candidate 3db8657ba ran back to back on CPU 23.
Every candidate check stays at or below 1.32 against the 1.8 ceiling; the
baseline still fails six of nine arms. The CALLS/METHOD_OVERRIDES export
is unchanged (fingerprint 4db24f57). The later main merge (e2a92dab8)
touches no measured file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(plan): checkpoint the simplification pass and its reports for #3630
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Address PR review feedback (#3632)
- Destructuring defaults (`{ fetch = globalThis.fetch } = {}`, renamed,
array and local forms) are alias evidence for their leaf binding and
no longer count a second initialization, which also invalidated
bindings like `[send = other] = values`.
- `export default (request)` records the default export: the value is
unwrapped before the identifier check.
- The HTTP fallback records and the collapsed-environment test row now
say what they stand for.
Regression rows cover each form in JS, TS and TSX and fail on the
previous source; two fixture consumers cover imported wrappers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(bench): refresh lexical binding reports after review fixes
Regenerate clean baseline and candidate measurements at c263c4f72.
All candidate scaling checks pass, the semantic delta remains one CALLS
target, and receiver-resolution counts match the existing baseline.
* docs(plan): checkpoint refreshed review-fix measurements
Record c263c4f72 review fixes, the regenerated scaling and semantic
results, and the passing receiver and CI checks.
---------
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(mcp): report cross-function explain lines 1-based
The interprocedural branch of explain passed the endpoints' and hops'
graph startLine through unchanged. Those are 0-based (tree-sitter rows),
so every cross-function source, sink and hop sat one line above the
function's declaration in an editor, while the intra-procedural findings
of the same response were already 1-based. source.line, sink.line and
hops[].line now go through toDisplayLine like context, query and impact
(#2377), and the response note says these are declaration lines.
The interproc integration block asserts the exact fixture lines: handle on
line 7 of source.ts, runIt on line 6 of sink.ts.
Fixes#3491
* fix(review): remove repaired accuracy allowance
---------
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
* chore(vendor): update tree-sitter-dart to 1.0.0-g0038280
* chore(vendor): rebuild native prebuilds (tree-sitter-dart)
Built by https://github.com/abhigyanpatwari/GitNexus/actions/runs/39212887661
* fix(dart): use native extension type parsing
The upgraded grammar parses extension types directly. The compatibility
rewrite loses generic extension bodies and implements clauses, so capture
the native nodes and register their member ownership instead.
Refresh the Dart capture fingerprint after comparing the old grammar and
emitter over the same fixture corpus. Keep the scaling budget unchanged.
Refs #3633
* chore(vendor): rebuild native prebuilds (tree-sitter-dart)
Built by https://github.com/abhigyanpatwari/GitNexus/actions/runs/39239767139
* fix: repair Dart parity and checkpoint regressions
Remove Dart from the preprocessing fixture inventory after retiring its
hook. Use the parsed body boundary when reading extension-type heritage
so named-record representations retain their implements clauses.
Seed the WAL recovery fixture with the normal checkpoint threshold, then
force one-byte checkpoints only for the deliberately blocked write.
Require an actual error exit instead of accepting a subprocess timeout.
Refs #3633
* chore(vendor): rebuild native prebuilds (tree-sitter-dart)
Built by https://github.com/abhigyanpatwari/GitNexus/actions/runs/39248441688
---------
Co-authored-by: gitnexus-release-bot[bot] <gitnexus-release-bot[bot]@users.noreply.github.com>
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
rExportPatternMatches remembers at most 100,000 matched names per package, so
past that a name reads as not exported once the budget is spent; say so in the
function comment and the provider guide. fastestWithin always runs one attempt,
even when tries is below 1; word the comment to match.
A function parameter or for variable named like the target of pkg::f() makes
the shared free-call fallback refuse the call before the qualified lookup
runs, so the call gets no CALLS edge. Record it under the known limits and
soften the qualified-call header, which claimed the qualifier outranks every
lexical tier. No shared code is changed.
The capture keeps its quotes, so source("") arrived as two characters and
passed the empty-source guard. Test emptiness after stripping the quotes;
targetRaw is unchanged.
declaredClassName kept the backticks of an R6 class name, so a class written
with backticks never matched the roxygen type naming it, unlike a backticked
formal. Compare the bare name.
getRParser assigned the module-level parser before setLanguage ran, so a
failed grammar load left a language-less parser that the next call returned.
Build it locally and cache it once setLanguage has succeeded, as the C#
provider does.
* fix(routes): resolve Express registrations made through helper parameters (#3487)
#3603 made Express receivers provenance-proven, which removed the receiver-
name false positives but also every registration on a function parameter:
a parameter has no binding value, so `app.get(...)` inside a helper never
resolved. On GitNexus's own server that dropped `* /api/mcp`
(`mountMCPEndpoints(app, ...)`) and `GET /` (`registerWebUI(app, ...)`),
and the two SSE progress routes registered by
`mountSSEProgress(app, '/api/.../progress', jobs)` were never found at all
(#3487, item a).
Named function values in the route facts now carry an identity and the
binding id of each parameter (a TypeScript `this` parameter takes no
position, and a parameter written anywhere in the body, nested closures
included, takes none either). Calls to plain functions and to namespace or
default import members are recorded as invocations, keeping only the
arguments that can carry an allocation or a literal path; arguments after a
spread have no position. The resolver resolves a registration whose
receiver, literal path or mounted child is a parameter through each call
site of its function, once per site and in the helper's file. This is one
hop only: a site argument that is itself a parameter does not resolve. When
no call site is recorded, the call is evaluated as written, so an unknown
mount path still suppresses its child router instead of exposing its paths
at the root.
Only calls whose callee is named like a function that registers on its
parameters are evaluated, which keeps resolution at its previous cost on
repositories with many helper calls. A function value's invalidation key now
includes its identity, so a property write on one function
(`Button.displayName = ...`) no longer disables every other. The group
layer shares the resolver, so it gets the same routes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): forward mounted-child parameters and aliased helper imports
Review follow-ups for the helper-parameter forwarding:
- A helper that forwards only its mounted router (`function mountChild(child)
{ app.use('/api', child) }`) was never resolved, because the forwarded
function was chosen from the receiver and path alone. Any parameter among
the receiver and arguments now selects it, as long as all come from one
function.
- A helper called through an aliased import (`{ mountSSEProgress as
mountProgress }`) was filtered out before its call sites were recorded,
since the filter compared only the local name. It now also accepts the
imported name.
- A write to a same-named local declared in a nested block (`{ let app;
app = other; }`) discarded the outer parameter. A write to a binding that
a nested block, function or catch clause declares no longer counts.
- The fixture's `registerWebUI` uses its static directory.
The release tool-accuracy gate now passes `routes.helper-registration`, so
its known-gap allowance is removed. Its expected file moves from the caller
(`api.ts`) to the helper (`progress.ts`): an Express route belongs to the
file of its `app.get` call, which is also where its handler and response
keys are, as for every directly registered route.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): treat destructuring reassignment as a parameter write
`[app] = [other]` reassigns `app`, but the write check compared the whole
target text (`[app]`) with the parameter name, so the parameter stayed
forwardable and later registrations used the call-site argument. A
destructuring target now writes each name it binds; a member target still
writes only a property. Also drops an unused local flagged by CodeQL.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): follow helpers exported under another name
`export { mountRoutes as setup }` records the export as a binding, so the
call-site filter knew the helper only as `mountRoutes` and skipped callers
importing `setup`. An export of a binding to a named function now adds its
exported name too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
* fix(routes): link base-URL fetch calls made through wrapper chains (#3488)
GitNexus's own web client calls `fetchWithTimeout(`${_backendUrl}/api/repos`)`,
which reaches fetch through `resilientFetch` and a local `fetchImpl` alias.
`api_impact` found none of those consumers, for three independent reasons:
- normalizeFetchURL rejected any URL that did not start with `/`, so a
leading base-URL binding dropped the call. It now strips a leading
`${...}` run followed by `/`, with the same rules as the group layer's
consumer normalizer (#3111); the helper moves to route-path.ts so both
layers share it. A path whose every segment is a param (`${base}/${id}`,
`${base}/${id}.json`) is rejected, since it would match every route of
that depth. Interpolations are collapsed brace-balanced before the query
split, so `${repo ? `?repo=${repo}` : ''}` no longer ends the path, and
one glued to the last static segment is treated as a query or suffix.
- The wrapper call collector required a `/`-leading literal, so the same
template never became a wrapper candidate.
- Wrapper detection only looked five AST levels deep for a call to an
identifier named `fetch`. Arrow-const wrappers sit deeper than that, and
`resilientFetch` calls an alias of `globalThis.fetch`. Detection now walks
the whole definition and accepts `globalThis`/`window`/`self.fetch` and
aliases whose value names fetch (through `??`, `||`, `?:`), read from the
AST rather than the text. It records whether the first parameter reaches
fetch's URL argument and which callees receive that parameter. The routes
phase closes the wrapper set over that forwarding: `fetchWithTimeout` is a
wrapper because it forwards its URL to `resilientFetch`. A callee declared
in the caller's file or imported from a relative module must carry a URL
in exactly that module; a package-imported name is followed only when
every recorded function of that name carries one. A fetch caller whose
first parameter is not the URL (`track(event)`) or a same-named function
elsewhere (an IPC `request(channel)`) lends nothing.
When `[param]` matches several sibling routes (`/api/analyze/upload` and
`/api/analyze/:jobId`), the fetch now links to the route whose segments
match by kind instead of the first one registered.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): match wrapper calls by declaring module and decline ambiguous fetch matches
Review follow-ups for #3488:
- A propagated wrapper's name went into a repo-wide set, so a literal call
to an unrelated same-named function in another module was taken as a
fetch. Wrapper call candidates now carry the module declaring a bare
callee when the file declares or imports it relatively, and must reach a
wrapper defined in exactly that module. Package and member callees keep
the name match.
- An alias declared in a nested helper (`const fetchImpl = globalThis.fetch`)
marked an outer call to a same-named parameter as a fetch. An alias now
counts only where its declaring function encloses the call.
- A first parameter redeclared inside the function (`{ const url = ...;
fetch(url) }`) was taken as the URL. A shadowed parameter is no longer
followed.
- A fetch whose `[param]` ties between sibling static routes
(`/api/kinds/foo`, `/api/kinds/bar`) linked to the first registered one.
A tie now links none.
- The fixture's `resilientFetch` returns the last response instead of
rejecting with `undefined`, and its client encodes the repo query value.
The release tool-accuracy gate now passes `api.template-wrapper`, so its
known-gap allowance is removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): keep call-site wrapper names and ignore helpers that never run
- A wrapper call through a renamed relative import (`import { request as
send }`) stored the exported name, so a configured `fetchWrappers` entry
naming the call-site `send` no longer matched. The call keeps its
call-site name and carries the declared name separately for the module
lookup.
- A nested helper bound to a local that is never referenced again (`const
later = () => resilientFetch(url)`) made its enclosing function forward
its URL. Calls inside such a helper are ignored; a helper that is called
or passed on, such as a retry callback, still counts.
- The fixture's `resilientFetch` no longer retries after a timeout or abort.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): let a nested parameter shadow a fetch alias
A function parameter between a fetch alias and a call shadows the alias
there (`function send(fetchImpl) { return fetchImpl(event) }` beside an
outer `const fetchImpl = globalThis.fetch`), so that call no longer marks
the enclosing function as a fetch wrapper. The fixture's retry helper also
stops returning a stale 5xx response after a later attempt throws.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): drop fetch aliases whose name is redeclared with another value
A block that redeclares an alias name with a non-fetch value (`{ const
fetchImpl = other; fetchImpl('/x') }`) let the inner call read as a fetch.
A name declared anywhere in the function with a value that does not name
fetch is no longer an alias, which covers every block-scoped shadow without
lexical scope tracking.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(routes): ignore uncalled nested declarations and shadowed global objects
- An uncalled nested `function helper() { fetch('/x') }` made its enclosing
function a fetch wrapper. Nested function declarations that are never
referenced are now ignored, as unused function-valued locals already were.
- `window.fetch(url)` through a parameter or local named `window` (or
`self`, `globalThis`) was read as the platform fetch. Such a root is now
that value's method. A bare `fetch` parameter is still taken as fetch,
since injecting a fetch implementation is the common reason for it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(bench): refresh the receiver-resolution baseline for the fetch fixture
The new `fetch-base-url-wrapper` fixture in `test/fixtures/lang-resolution`
adds one unresolved TypeScript chain-field call to the committed check
corpus (127 to 128 call drops). Regenerated with
`measure.mjs --update-baseline` after a fresh build and cleared parse caches;
no other counter moved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
* fix(group): read net/http HandleFunc and Handle on proven routers as method-agnostic routes (#1668, #1670)
The Go provider query only matched the literal `http.HandleFunc(...)` with an
identifier or inline handler, so a local `http.NewServeMux()`, a gorilla or
chi router, `Handle(...)`, a method-value handler (`api.ListUsers`) and a raw
string path produced no provider at all (#1668).
It also hard-coded `GET`. A ServeMux registration serves every method unless
its pattern names one, so a POST consumer never paired with the route
(#1670). The provider is now method-agnostic (`*`), the convention Django,
Nest `@All` and Hono `.all` already use and the matcher already pairs with
consumers of every verb. A Go 1.22 pattern (`"POST /p"`,
`"GET host/p/{id}"`) gives its method and drops the host and the `{$}`
anchor, and a gorilla `.Methods(...)` on the route chain gives its verbs.
`HandleFunc`/`Handle` are common names outside HTTP (telebot's
`b.Handle("/start", fn)`), so the receiver must be a proven router: the
net/http package, a binding to `http.NewServeMux()`, gorilla
`mux.NewRouter()` or chi `chi.NewRouter()`, a gorilla
`PathPrefix("/p").Subrouter()` or chi `Route("/p", func(r chi.Router))`
(joining the prefix), or a parameter typed as one of those routers. A
router the file mounts under a stripped or prefixed path (`Mount`,
`StripPrefix`, gorilla `.Handler`) is declined, as is a struct field, since
their registered paths are not their URLs. Routers in `_test.go` files are
httptest mocks and are skipped. Handler naming is shared with the gin/echo
loop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(group): decline mounted router parameters and read HEAD routes as GET
A router parameter passed to `StripPrefix`/`Mount` was never marked mounted,
because the mount scan resolved identifiers through `findBinding`, which
returns nothing for a parameter, so its unprefixed paths were emitted. The
scan now records a parameter by its declaration and the router proof checks
it.
A `"HEAD /x"` pattern or gorilla `.Methods("HEAD")` produced an
`http::HEAD::` provider, while this plugin's `http.Head` consumers are keyed
as GET. Providers now follow the same HEAD-as-GET convention. The plugin
docstring no longer says any receiver is accepted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(group): read http.HandlerFunc conversions and hyphenated method tokens
`http.Handle("/x", http.HandlerFunc(h))` was dropped because the handler
argument is a conversion call; the converted function is now the handler.
A Go 1.22 pattern whose method token contains characters other than
letters (`"M-SEARCH /discover"`) produced no provider; the method now
accepts any HTTP token that starts with a letter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(group): keep HEAD-only Go routes apart from GET consumers
Reading a `"HEAD /x"` pattern or gorilla `.Methods("HEAD")` as GET let
every ordinary GET consumer pair with a route that does not serve GET. The
provider now stays HEAD. A HEAD consumer, which this plugin records as GET,
then misses a HEAD-only route; a missed link is preferred to a false one.
Repeated verbs still collapse.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
readManifestFile checked the size with fs.stat(path) and then read with
fs.readFile(path), which CodeQL reports as a file system race (js/file-system-race).
The file is now opened once (O_NOFOLLOW and O_NONBLOCK where the platform has them),
and the regular-file check, the size cap and the read all use that handle; one byte
past the checked size is read so a file that grows is refused. The DESCRIPTION read
for hidden packages in skipped subtrees now goes through the same reader, so it has
the same cap and fails closed (cannot rule a package out). Tests that spied on
readFile now spy on open; new cases cover the cap boundary, empty file, directory,
symlink and FIFO.
The hook, roxygen, conditional-export and package-less R/ cases exercise checkSafety
only, which the unit tests already drive with a real NAMESPACE load. Each rename
fixture runs a native analyse (about 12 s on Windows), so only the cases that need
the engine stay as fixtures (external-call and local-import NAMESPACE reads,
leading-dot identity, unparseable file, BOM). Adds the package-less R/ unit case.
The grammar skips the mark, so the first-line definition, its CALLS edge and the
rename all work and the mark is kept. Added as a rename fixture; no code change.
NAMESPACE was opened by name, so a symlink in the analysed repository was followed,
unlike DESCRIPTION which is read only when the directory read lists a regular file.
Neither manifest had a size cap (the walker's cap covers source files only). Both
now go through one reader that rejects anything over 4 MiB: a DESCRIPTION that
cannot be read leaves discovery marked incomplete, a NAMESPACE that cannot be read
is treated as absent (rename then refuses).
The argument-scaling ratio gate now repeats a measurement whose ratio is over the
limit (a quadratic query is over it every time, a noisy runner is not). The
absolute bounds take the fastest of up to three attempts that each build their own
state, so a cache warmed by an earlier attempt cannot hide a regression. The
named-import lookup test counts walks of the export set instead of timing 20,000
lookups, as its sibling tests already do.
Pins the rename behaviour with two fixtures (an R/ directory without a package is
refused; a syntax error in an unrelated indexed file refuses with parse_error) and
adds the replacement-function CALLS limitation to the Limits section.
The rename engine reads a definition's simple name as the text after the last '.'
of its qualified name, so the graph symbol .helper never matched the definition
'helper' and every leading-dot rename failed with a misleading stale_graph. The R
provider's canonicalName now keeps a one-word leading-dot name whole (names with a
dot inside, such as area.circle, keep the engine's reading and stay refused).
That would also have let .onLoad, .onAttach and the other functions R calls by
name through, so checkSafety refuses them explicitly.
roxygen2 rebuilds NAMESPACE from @export* tags, so renaming a tagged function
changes the package's public API on the next document() even when the NAMESPACE on
disk and the persisted isExported say it is private. checkSafety now refuses a
top-level function whose directly preceding #' block has an @export* tag. Documents
that a successful rename leaves .Rmd/.qmd/.Rd/pkgdown/roxygen cross-reference
consumers unchanged; the rename result has no provider-owned note field.
parse-worker.ts and languages/r/query.ts imported @eagleoutice/tree-sitter-r
statically. A binding that cannot load (no prebuild, ABI mismatch) therefore
crashed every worker and every module importing the R provider, failing analyze
for all languages. The worker now loads it behind the same guard as the vendored
grammars, through the shared grammar loader, and the query module resolves it on
first use as the Kotlin one does. With the binding removed, analyze indexes the
other languages and skips R files with one logged error.
The NAMESPACE scanner skipped conditional (if/else) bodies, dropped raw-string and
multi-line arguments, and discarded a malformed directive together with everything up
to the next column-0 directive, all silently. Rename treated 'not in the export lists'
as proof of privacy, so it could rename a function whose export() entry the reader had
never seen and leave NAMESPACE naming a missing function.
The scanner now reports when a skipped or discarded region names an export-family
directive, and parseRNamespaceExports also flags an argument of one that it cannot
read. loadRPackageConfig stores that as RNamespaceInfo.exportsUnreadable and rename
refuses with incomplete_semantics. An ordinary NAMESPACE, including conditional
imports, does not set it. The indexed isExported is unchanged. r-provider.md updated.
populateRNamespaceImports and populateRQualifiedCalls replace entries of the
ParsedFile array (import synthesis; any dropped external pkg::fn site), but the
rename guard looks the recorded config up by the original ParsedFile object. A
package file that called stats::sd(), or whose package importFrom()ed a name from
another repository package, therefore read as 'NAMESPACE was not read' and every
rename in it was refused with incomplete_semantics.
Record the config against the objects as received and again against the final
array. Adds rename fixtures for a private and an exported function in a file
with an external qualified call, a private function in a package with a local
importFrom(), and extends the incremental NAMESPACE test with an external call
and an incremental run that reuses the parse cache.
* fix(python): retain nullable factory receiver types
* test(accuracy): remove repaired Python gap allowances
* test(bench): refresh Python capture fingerprint
* fix(python): type `None or call()` assignments like `call() or None`
`None or make_user()` always evaluates to the call, but only the
`call() or None` order matched, so the variable lost the factory's
return type. Add the mirrored boolean pattern, matching the two
conditional-expression orders the PR already supports.
Fixture gains `none_or` (resolves to User.save) and `none_and` (stays
unresolved: `None and x` is always None). The capture golden changes only
for the edited fixture, and the python-scope baseline is re-recorded
(`measure.mjs --check` passes, scaling 1.021).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
After an edit of NAMESPACE alone, the unchanged R/ files are not
re-processed, so the persisted isExported of a newly exported function
stays false and rename read that as proof of privacy. The rename guard now
also uses the NAMESPACE the planner has just loaded from disk (recorded by
the R workspace hook against each parsed file): it refuses when NAMESPACE
exports the name by export(), exportPattern() or S3method(), and fails
closed (incomplete_semantics) when NAMESPACE is gone or unreadable, when
an exportPattern() was dropped or ran out of budget, or when no config was
recorded. The persisted flag remains a second, additive check. The
incremental test now asserts the refusal on the stale index and after
--force; unit cases cover each way NAMESPACE can change. Docs updated.
R leaves an already attached package where it is, so library(a);
library(b); library(a) still lets b mask a. The merger counted the last
call as a fresh attachment, and because the pipeline folds the bindings of
a name in one at a time, a package masked at one step was forgotten at the
next. Remember each package's first attachment, masked ones included, on
the surviving bindings, and flip the expectations that pinned the other
direction (A/B/A -> B, B/A/B -> A) in the unit and pipeline tests.
`publicRepoId` is an HMAC under a key drawn once per process
(`randomBytes(32)`), so the 22-character base64url id is effectively
random on every run. The test asserted `not.toContain('ws')` to show the
id does not leak the path, but any id contains "ws" by chance with
probability 21/4096 (~0.5%). CI hit it on #3624 with
`gt5f4oNtpcwsi6vep8lzQN`.
Across 20,000 fresh keys the old assertion failed 118 times and the new
one 0 times. The test now checks the base64url shape and that the full
path is absent; '/' is outside the alphabet, so a chance match cannot
happen.
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
validateName let ... and ..N through to a misleading name_collision. Reject
them as reserved, say in the message that new names are ASCII-only by design,
and report an old name made only of non-ASCII characters as an unsupported
identifier rather than an infix function or operator.
A formal defaulting to NULL is the usual placeholder of an optional
callback, so classing it as constant let a rename edit the call of the
parameter and drew a false edge to a same-named top-level function. Treat it
as 'maybe': the rename refuses the call and the scope publishes the formal
as a lexical name. Update the provider guide and pin both paths.
rExportPatternMatches answered false for every name once the budget was
spent, so a duplicate definition of a name that had been exported earlier
flipped to private. Remember the names matched while the budget lasted and
answer them from that set; undecided names still read as unexported, which
the documentation now says.
normaliseArg trimmed the text inside quotes and backticks, so export(" a ")
named the symbol a instead of the symbol ' a ', which is what R reads. Trim
only around the argument, and pin it with a parser test and a pipeline case
where a package defines both a and ` a `.
Build the pattern from empty groups so only the length rule is in play, and
check that it compiles, matches 'aa' and not 'a', and that one more
character is refused.
getRTopLevelMethodOwnerName is the setMethod helper and returns null for any
argument node, so the negative assertion could not fail. Use the owner lookup
the R6 path uses, in the positive and the negative case.
The helper listed only 'name <- function', while the indexer also lists
<<- and = definitions, so a generic defined with = never reached the S3
guard. Add cases that go through the helper with each operator.