GitNexus/gitnexus/test
DuduPhudu 031e123731
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Gitleaks / gitleaks (push) Waiting to run
Publish / Classify release event (push) Waiting to run
Publish / RC guard (marker + release-PR skip) (push) Blocked by required conditions
Publish / ci (push) Blocked by required conditions
Publish / Publish to npm (push) Blocked by required conditions
Publish / Build & Push RC Docker images (push) Blocked by required conditions
Scorecard / Scorecard analysis (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-cli) (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-web) (push) Waiting to run
fix(group): resolve HTTP consumers through configured clients and constant route tables (#3008)
* fix(group): resolve HTTP consumers through configured clients and constant route tables

Cross-repo linking found almost no frontend consumers because the Node/TS
consumer pattern required two things application code never has: a receiver
literally spelled `axios`, and an HTTP path that is a string literal at the
call site. Real apps call a configured instance and pass the path by reference
from a shared route table, so both halves of every call live in other files.

Widen the pattern to any identifier receiver with an HTTP-verb method, then
admit the match only after PROVING the receiver is an axios instance —
following local aliases, default/named imports and `export *` barrels back to
an `axios.create(...)`, including when that call is an argument to a factory
that decorates and returns the instance. The proof gate is load-bearing:
EXPRESS_SPEC matches `router.get('/x', handler)` as a provider, so admitting a
receiver on spelling alone would re-emit every Express route as a consumer of
itself.

Resolve the path argument through the existing language-agnostic constant fold
(`constant-resolver.ts`, #2391) via a new JS/TS binding, mirroring how
`python-const-resolver.ts` binds the same core. The binding adds the two
JS-shaped facts Python has no analogue for: object-literal route tables
flattened to dotted literal keys (`API_ROUTE_PATH.LINKS`), and export aliasing
(`export default`, `export { a as b }`, `export *`). Templates and `+` concats
fold partially, so a mixed path keeps its known prefix instead of collapsing to
`{param}/{param}/...`.

Cross-file facts come from a `prepareRepo` pre-pass, the hook FastAPI prefix
resolution already uses. The three JS/TS plugins share one pass via a WeakMap
keyed on the orchestrator's memoized file list.

Every resolution floors to `null` (skip) rather than a guess: an ambiguous
import specifier, an unprovable receiver, or a fold that overruns its depth
leaves the call site exactly as unmatched as before. An unresolved path is a
missing contract; a wrong one is a false cross-repo link.

Measured on a real Next.js frontend (874 source files): consumer contracts
7 -> 160, none lost.

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

* fix(group): tighten the JS/TS HTTP consumer proof gates and bound the fold

Addresses the review findings on #3008. Widening the axios consumer query
moved precision out of the tree-sitter pattern and into runtime gates; most
of these are one of those gates leaking.

Keying
- scanBundle normalizes fileRel ONCE and uses that key for both the receiver
  gate and the path fold. isHttpClientRef read the raw value while the fact
  map is written under normalizeRel(rel), so any non POSIX path returned zero
  consumers and a key miss is indistinguishable from "not a client".

Proof
- containsAxiosCreate (subtree containment) becomes bindsAxiosClient: the
  instance must be the bound VALUE, or reachable inside the arguments of a
  wrapping call whose result is bound. An object literal, ternary, array or
  new X(...) binding no longer makes a cache or registry an HTTP consumer.
- A folded first argument must look like a path: no whitespace, not wholly
  numeric, and not starting with an unresolved term. The check runs on the
  ${...} to {param} normalized shape, so a placeholder whose source contains
  spaces does not drop an otherwise anchored path.
- A template or concat whose LEADING term never resolved returns null, which
  is what the docstring always claimed.
- The literal receiver axios with a literal or template argument keeps its
  pre-PR output verbatim, so the widening only adds detections.

Resolution
- resolveJsImport checks ambiguity across ALL candidate extensions, not within
  one, so a .ts/.tsx or .ts/index.ts collision skips instead of picking a
  winner. Two spellings of one module still resolve by precedence.
- A single segment bare specifier with no alias sigil never binds to a repo
  file, so a Node builtin or npm package cannot be "proven" an axios client.
- resolveExportedMember walks every export * edge and returns null when two
  barrels answer differently.
- Imports are collected in a hoisting pre-pass, so a client bound above its
  own import statement is still proven.

Termination and cost
- MAX_EXPR_DEPTH and MAX_CONCAT_TERMS bound the path fold, flattenConcat walks
  the left spine iteratively, and buildImportMap is explicit stack. A file
  nesting template substitutions 4000 deep threw RangeError out of scan, which
  sync.ts records as an unexplained missing repo with every contract dropped.
- MAX_FOLD_LENGTH applies to accumulated output, not per term, and to the raw
  literal fallback. The per term cap was a 2048x amplifier and the result is
  persisted into contractId.
- resolveJsImport is backed by a basename index and memoized per repo, and
  resolveConstant accepts the key set instead of rebuilding it per fold.
  2000 file repo with one bare npm import: 11074 ms to 1250 ms.
- prepareRepo measures its ceiling in bytes, parses inside the try, and skips
  the parse pass entirely when the string axios appears in no candidate file.
  It carries only file identities between its two passes, never their text.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014g48u4WcRZy543Wqp5NhpV

* fix(group): let a path-shaped all-numeric consumer path through the gate

The shape gate rejected any wholly numeric path, which also dropped
`client.get('/123')`. The leading slash is the evidence that separates a
route from a constant that merely folded to digits: a bare "5000" out of
`CONFIG.TIMEOUT` still matches every one-segment provider route and is still
refused, while a path written as a path is kept and normalized to {param}
the same way it always was.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014g48u4WcRZy543Wqp5NhpV

* style: apply prettier to the changed files

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014g48u4WcRZy543Wqp5NhpV

* fix(group): decide the axios receiver on evidence, not only on its spelling

The bare name `axios` was trusted with no proof, which is right for the
convention and wrong for a file that binds that name itself:
`const axios = fakeFactory; const api = axios.create(); api.get('/x')` was
admitted as an HTTP consumer, and so was a test file whose `axios` is a mock
object with a `create` method.

extractJsModuleFacts now records whether the file declares its own top-level
`axios` binding, and the spelling is trusted only when it does not. The other
half of the same fact is that CommonJS was invisible: `const ax =
require('axios')` resolved to nothing at all, and the un-aliased form worked
only because `axios` happened to be the name the spelling shortcut trusted.
Requires are collected alongside imports now, so a receiver is admitted when
it IS the axios module (the bare spelling, or a declared import or require of
'axios' under any name) or when it traces to an `axios.create(...)` instance.

Verified across the receiver matrix: shadowed local, shadowed mock object,
CJS require aliased and not, ESM import aliased and not, express router and a
plain Map all land where they should.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014g48u4WcRZy543Wqp5NhpV

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
2026-08-25 11:34:23 +01:00
..
fixtures fix(kotlin): resolve imports from declared packages (#2990) 2026-08-18 20:47:30 -07:00
helpers fix(kotlin): resolve imports from declared packages (#2990) 2026-08-18 20:47:30 -07:00
integration fix(php): gate imports by Composer autoload map (#2987) 2026-08-25 07:56:41 +01:00
unit fix(group): resolve HTTP consumers through configured clients and constant route tables (#3008) 2026-08-25 11:34:23 +01:00
utils fix(hook): emit MCP query hint when server owns DB lock (#2396) (#2397) 2026-07-08 18:34:05 +01:00