Skip to content

fix(javascript): recover GraphQL operations from exact template text - #1810

Closed
jayhemnani9910 wants to merge 7 commits into
morluto:mainfrom
jayhemnani9910:fix/graphql-leading-interpolation
Closed

jayhemnani9910 wants to merge 7 commits into
morluto:mainfrom
jayhemnani9910:fix/graphql-leading-interpolation

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

Summary

A GraphQL document written the way the Apollo Client docs show fragments, with the fragment interpolated before the operation, is not reported as an endpoint:

const GET_POST_DETAILS = gql`
  ${CORE_COMMENT_FIELDS}
  query CommentsForPost($postId: ID!) { ... }
`;

analyze-javascript-application and analyze-web-bundle report no graphql:query for CommentsForPost. The same document with the interpolation at the end is reported.

No related issue; this is a small follow-up to #1670, so it comes straight as a PR.

Problem and expected behavior

Trigger: a template literal whose text starts with one or more ${...} interpolations, then a named operation.

Before: the template branch in createJavaScriptRpcScan only reads the first quasi (src/domain/javascript/javascriptRpcEndpoints.ts:312-318). For the document above that quasi is just whitespace, so nothing is found. Modern bundles keep tagged templates as template literals, so this hits shipped code too, not only sources.

Expected: leading interpolations hold fragment definitions; the operation that follows them is reported, as it already is when the fragment comes after the operation.

Change and scope

The template branch now walks the quasis in order, skips those that hold only GraphQL ignored tokens (whitespace, commas, comments), and reads the first one with content, using the same header rule as before. The ignored-token loop moves into a small skipGraphqlIgnored function shared with graphqlOperationFromText. A template with text before its first interpolation behaves as before, and an uncooked quasi still stops the scan.

Not included: operations whose selection set starts with a fragment spread (query Q { ...F }); the docs already scope that out.

Contract and boundary impact

  • Semantic owner and earliest changed stage: inert JavaScript static analysis, RPC endpoint recognition (javascriptRpcEndpoints.ts).
  • CLI and MCP/tool-catalog contract: none; the same graphql:* endpoint records, now also for these templates.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: recognizes operations that follow leading fragment interpolations in src/domain/javascript/javascriptRpcEndpoints.test.ts (one leading interpolation; two adjacent ones plus a # comment; a negative control with prose before the operation). It fails on current main ([]) and passes with this change.
  • Base reproduction or other evidence: executed on Linux x64 with rea-agents 6.4.0 and main. A three-document app (Apollo docs GET_POST_DETAILS, GET_DOG, and a mutation with a trailing fragment):
    6.4.0 / main: graphql:mutation AddTodo, graphql:query GetDog
    this branch:  graphql:mutation AddTodo, graphql:query CommentsForPost, graphql:query GetDog
    
    The same page served locally and read through analyze-web-bundle in headless Chrome: GetDog only before, CommentsForPost and GetDog after.
  • User-visible CLI/MCP output: the lines above.
  • Remaining proof gaps: none known.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/domain/javascript/javascriptRpcEndpoints.test.ts src/domain/webBundleAnalyzer.test.ts: 38 passed; the new case fails without the fix.
  • npx vitest run --project domain src/domain/javascript: 841 passed.
  • npm run check:fast: passed.
  • npx vitest run --project <name> for each project except acceptance, after npm run build:cached, on main 914ba83 before rebasing: 7421 passed, 21 failed, 87 skipped, against 7420 / 21 / 87 on untouched 914ba83 with an identical failure list (firmware tests that need Binwalk 3.1.x, ASAR tests whose unpacked companion file is missing here). acceptance was not run (out of memory on this machine).

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux; headless Chrome for analyze-web-bundle.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; inert parsing only.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 12:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T18:53:47.840895Z ee6148e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9acdb41c6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@dandgabr dandgabr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review corrections

  • P2 — Preserve GraphQL lexical state and validate skipped interpolations. In src/domain/javascript/javascriptRpcEndpoints.ts:319-323, the loop restarts skipGraphqlIgnored for each quasi and treats any leading interpolation as skippable. If an earlier quasi ends inside a # comment and the interpolation contributes no newline, a later quasi beginning with query Hidden is still comment text in the concatenated GraphQL document, but the scanner reports it as an operation. More generally, arbitrary dynamic interpolations are not necessarily fragment definitions. Carry comment state across boundaries and only skip interpolations whose fragment semantics are established; otherwise leave the operation unknown.

@jayhemnani9910

Copy link
Copy Markdown
Contributor Author

Thanks, good catch. In 68fb351 the template scan now treats the line an interpolation ends on as unknown, since the interpolation can open or end a # comment. An operation is only recognized when it starts on a later line, and any non-ignored text on that unknown line leaves the template dynamic. That covers both your # ${x}query Hidden case and a bare ${x}query Hidden. New test in javascriptRpcEndpoints.test.ts fails before the change and passes after.

Proving each interpolation is a fragment would need binding resolution, and Apollo fragments are usually imported from another module, so a strict check would drop most real cases. I kept it to the line rule for that reason. Happy to tighten it if you'd rather report nothing after a dynamic interpolation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68fb351a5e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Changes how GraphQL operations are extracted from template literals.

The PR needs the existing fix for losing a known operation at a later uncooked template segment before merging.

Findings

  1. P1 Known operation disappears ▶
Fix with agent prompt
### Issue 1
src/domain/javascript/javascriptRpcEndpoints.ts:undefined-339
A later template segment with no cooked value now discards an operation already found in the prefix. For example, `const doc = String.raw` followed by `` `query Q { f } # ${0}\unicode` `` is valid JavaScript. The invalid escape makes the second segment’s cooked value `null`, so this loop returns `undefined` and loses `Q`. The raw GraphQL text still contains the operation, and the old scanner reported it.

Return `report()` at this boundary, as for an unresolved interpolation. An uncooked first segment should still remain unknown.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR folds exact literal values into template text before looking for a named GraphQL operation.

  • GraphQL scans find operations after literal fragment interpolations.

Whether this PR has been superseded could not be checked because GitHub access was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read template text] --> B{Cooked text available?}
  B -->|No| C[Return no endpoint]
  B -->|Yes| D[Append text]
  D --> E{Next expression}
  E -->|Exact literal| F[Append literal value]
  F --> A
  E -->|Unknown or no expression remains| G[Inspect leading operation header]
  G --> H[Suppress matching child observations]
  H --> I[Return endpoint if found]
Loading

Reviews (7) · Last reviewed commit: "fix(javascript): preserve distinct folde..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ca2f1e962

ℹ️ 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".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

The prior scanner resumed after a newline across arbitrary dynamic values, which could change GraphQL comment, block-string or definition context. The template owner now folds exact syntax-level values into one known prefix and stops at the first dynamic boundary. An operation header already observed before that boundary is retained, but later operation-looking text remains unknown; no arbitrary interpolation is assumed to be a fragment. Added and adjusted regressions cover exact ignored prefixes, unresolved prefixes and the existing observed-header/dynamic-suffix behavior.

Source inspected at 1ca2f1e; git diff --check passed. Tests, builds, source checks and CI reruns were skipped at the user's explicit request. No passing runtime/provider verification is claimed for this update.

  1. thread 1

The producing template representation now folds exact literal interpolation values before GraphQL interpretation. A fragment/block-string prefix is part of the same document text as the intervening query-looking text; a newline never starts an independent scan across that lexical state. Added the supplied block-string regression. The owner also stops at unresolved dynamic values, retaining only operation headers already visible before them rather than assuming dynamic values are fragments.

Source inspected at 1ca2f1e; git diff --check passed. Tests, builds, source checks and CI reruns were skipped at the user's explicit request. No passing runtime/provider verification is claimed for this update.

@morluto morluto changed the title fix(javascript): recognize GraphQL operations after leading fragment interpolations fix(javascript): recover GraphQL operations from exact template text Oct 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ede6c30731

ℹ️ 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".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Source fix: ede6c307317b441f1d5698f95ea2181b6062e5a8.

The template owner folded an exact child literal but the preorder scan subsequently reported the same literal at its distinct source position. The GraphQL scan now uses one ownership set for text consumed by enclosing representations, covering both compiled-document source bodies and folded template expressions. It marks unwrapped folded literals only after the enclosing template actually reports an operation, preserving independent child observations when the enclosing text has no recognized operation.

Added unrun public static-analysis regressions for string, TypeScript-wrapped string, and exact nested-template interpolation, each expecting one endpoint, plus the no-parent-operation case. Source inspection followed preorder traversal and location-keyed finding retention; no downstream value-only deduplication was added. Tests, typechecks, builds, lint, workloads, and CI reruns were not run, as explicitly requested.

  1. thread 1

Source fix: ede6c307317b441f1d5698f95ea2181b6062e5a8.

The documentation retained the earlier promise of skipping unresolved fragment identifiers and requiring a later line, while the scanner only has proof for exact literal values. The paragraph now describes exact folding, stopping at unknown interpolation boundaries, retaining an already observed leading header before an unknown suffix, and leaving later operations unknown. It explicitly states that fragment identifiers are not resolved or assumed safe; exact literal prefixes have no special newline requirement.

Source inspection compared the scanner branches with the existing unresolved-prefix/comment/block-string coverage and the new reporting-ownership regressions. The unsupported contract is removed without adding speculative binding interpretation. Tests, typechecks, builds, lint, workloads, and CI reruns were not run, as explicitly requested.

  1. thread 1

Source fix: ede6c307317b441f1d5698f95ea2181b6062e5a8.

Addressed using the requested contract-removal option. Identifier interpolation has no proven GraphQL lexical value at this boundary, so the scanner conservatively stops rather than assuming the binding is a safe fragment. Removed the documentation promise that this Apollo identifier flow is supported and documented the actual exact-literal behavior, including unknown prefixes and retention of headers already observed before an unknown suffix.

Source inspection followed literal admission, unknown-boundary handling, and both JavaScript/web consumers of the shared scanner. Existing unresolved-identifier and lexical-context coverage is retained; no speculative fragment resolver or downstream reparsing was introduced. Tests, typechecks, builds, lint, workloads, and CI reruns were not run, as explicitly requested. Resolving fragment bindings remains outside the advertised contract.

  1. thread 1

Source fix: ede6c307317b441f1d5698f95ea2181b6062e5a8.

Folded children and their enclosing template had competing reporting ownership, and location-aware finding keys correctly preserved both. The template now claims the actual unwrapped literal nodes it consumed only when it emits an operation. The existing compiled-document body suppression shares that ownership set, so consumers receive one operation without a second, position-based report or a downstream value-only deduplicator. If no enclosing operation is recognized, independent child observations remain available.

Added unrun public static-analysis regressions covering ordinary strings, TypeScript wrappers, exact nested templates, and the no-parent-report case. Source inspection followed producer traversal and finding retention. Tests, typechecks, builds, lint, workloads, and CI reruns were not run, as explicitly requested.

@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions P2: medium Medium priority issue labels Oct 13, 2026
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Root cause: the template owner marked every exact interpolated child as owned after the parent parser emitted only its first operation. Preorder traversal then suppressed a distinct child operation, losing a valid named query or mutation in both JavaScript and web-bundle analysis.

Structural fix: the owner now suppresses a folded child only when the child parser's operation value and mechanism match the operation actually emitted by the parent. Distinct operations remain available to consumers; the same ownership rule avoids duplicate findings without downstream value-only deduplication.

Source validation: published in PR #1810 at a53a17299a02f72e5bc97352ec605c811ee1ba99; source inspection confirms the comparison and preserved distinct-operation path. No tests, builds, checks, provider work, or CI reruns were run in this continuation.

Residuals: runtime/provider behavior and the added regression suite remain unverified under the explicit no-tests scope.

};
for (const [index, quasi] of node.quasis.entries()) {
const cooked = quasi.value.cooked;
if (cooked === undefined || cooked === null) return undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Known operation disappears

A later template segment with no cooked value now discards an operation already found in the prefix. For example, const doc = String.raw followed by `query Q { f } # ${0}\unicode` is valid JavaScript. The invalid escape makes the second segment’s cooked value null, so this loop returns undefined and loses Q. The raw GraphQL text still contains the operation, and the old scanner reported it.

Return report() at this boundary, as for an unresolved interpolation. An uncooked first segment should still remain unknown.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptRpcEndpoints.ts
Line: 339

Comment:
**Known operation disappears**

A later template segment with no cooked value now discards an operation already found in the prefix. For example, `const doc = String.raw` followed by `` `query Q { f } # ${0}\unicode` `` is valid JavaScript. The invalid escape makes the second segment’s cooked value `null`, so this loop returns `undefined` and loses `Q`. The raw GraphQL text still contains the operation, and the old scanner reported it.

Return `report()` at this boundary, as for an unresolved interpolation. An uncooked first segment should still remain unknown.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6fb1dcfe40

ℹ️ 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".

}[] = [];
const report = (): JavaScriptRpcEndpoint | undefined => {
const endpoint = graphqlOperationFromText(pieces.join(""));
if (endpoint !== undefined)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep commented child literals under the template owner

When a literal interpolation is text inside a comment, for example gql# ${"query Hidden { f }"}``, the folded document has no operation, so this guard does not mark the child as owned; preorder traversal then reaches that StringLiteral and `graphqlOperationFromText` reports `Hidden` in both JavaScript consumers even though the cooked GraphQL contains only comment text. The fresh path left after the earlier comment-state fix is that the apparent operation is the child AST node itself, so use the combined lexical result to keep such children from being independently reinterpreted without suppressing children that are actual definitions.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@morluto
morluto force-pushed the fix/graphql-leading-interpolation branch from 6fb1dcf to a244582 Compare October 13, 2026 18:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a244582065

ℹ️ 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".

Comment on lines +344 to +347
if (!literal.found)
// An already observed leading header survives an unknown suffix;
// never resume scanning after this unresolved boundary.
return report();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop reporting children after unknown interpolation

When a dynamic interpolation precedes a direct literal interpolation containing query Hidden { f }, this early return never records the later expression as owned, so pre-order traversal subsequently reports that StringLiteral on its own. If the dynamic prefix evaluates to # , the combined GraphQL document is entirely comment text, yet both JavaScript and web-bundle analysis claim Hidden; this is a separate post-boundary path from the already-reported exact-comment case because the fresh evidence is a literal after an unresolved expression. Associate later children with the unknown template context instead of independently reinterpreting them.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

operation: JavaScriptRpcEndpoint | undefined;
}[] = [];
const report = (): JavaScriptRpcEndpoint | undefined => {
const endpoint = graphqlOperationFromText(pieces.join(""));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use GraphQL whitespace rules when folding

When an exact interpolation contributes NBSP (or \v/\f) before the operation, this joined scan passes it to graphqlOperationFromText, whose JavaScript /\s/u predicate accepts those characters even though GraphQL whitespace is limited to tab, space, and CR/LF (with comma and BOM as other ignored tokens). A template with ${"\u00a0"} immediately before query Q { f } therefore newly emits Q although a conforming GraphQL parser rejects the document, polluting both analyzers; use GraphQL's actual ignored-code-point predicate for folded text.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

jayhemnani9910 and others added 4 commits October 14, 2026 02:46
…tions

An interpolation can open or end a `#` comment, so text on the line where
it ends is not known to be GraphQL. Only recognize an operation that starts
on a later line than the last leading interpolation; otherwise leave the
template dynamic.
@morluto
morluto force-pushed the fix/graphql-leading-interpolation branch from a244582 to ee6148e Compare October 13, 2026 18:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee6148e648

ℹ️ 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".

node: unwrapJavaScriptExpression(expression).node,
operation: graphqlOperationFromText(text),
});
pieces.push(text);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep substitutions separate for unproven template tags

When this TemplateLiteral belongs to a user-defined tagged template, JavaScript passes the cooked segments and values separately; it never performs the concatenation done here, and the tag may ignore or reorder the value. For example, const tag = (s) => s[0] + s[1]; tag`que${"ry"} Q { f }` evaluates to que Q { f }, whereas this scan joins query Q { f } and newly reports Q (the previous quasi/child scans report neither chunk). Since inspect handles every template without proving the tag's semantics, fold only untagged templates or proven tag implementations and otherwise retain an unknown boundary.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

morluto added a commit that referenced this pull request Oct 14, 2026
Preserve CommonJS literal paths and confined ESM URL semantics, including package main fallback, directory intent, Unicode identity, and present opaque modules. Parse extraction inputs at their AST/source owner, retain skipped HTML and source-map coverage, and distinguish endpoint candidates from proven receiver facts. Version structural fingerprints with computed literal contents and propagate them through worker contracts.

Reviewed fixes include #1810, #1840, #2642, #2700, #2702, #2714, #2803, #2960, #2968, #2986, #3035, and #3036.

Validation: 158 resolver tests passed; public CLI/MCP module lookup controls, package-main/Unicode workflows, and six builtin workflows passed in the current compiled lane. Worker schema/fingerprint regressions passed. Large public pdf.js completion and real Electron analysis remain unverified.
@jayhemnani9910

Copy link
Copy Markdown
Contributor Author

@morluto main has moved and this branch now conflicts. Should I rebase it onto main and run the full test suite on the result, or are you still pushing to it? I'll leave the branch alone until you say.

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: Head ee6148e passes its own 26 tests on Node 22, 24 and 26. Main af6a998 already finds a query that follows a leading fragment, this PR's first goal. This head chooses to leave that case unknown, so main and the PR now disagree on purpose.

I tested the head as pushed. GitHub says it conflicts with main. A text merge of the three files gives 5 conflicts in the source, 1 in the test file and 0 in the docs.

What main has and what is left

Main took the first design, in commit b58adaf, which names this PR. It skips quasis that hold only ignored tokens. Then it reads the next one. This head folds only exact literal values and stops at any other interpolation. I ran one fixture through the built CLI on main and on this head. Node 24.18.0 and 26.11.1 gave the same lists.

Case in the fixture Main This head
A plain named query reported reported
Fragment name, then a query on the next line reported not reported
Two fragment names, a comment, then a mutation reported not reported
Comment line, fragment name, then a query on the next line reported not reported
Query on the same line as a fragment name reported not reported
Comment, empty constant, query on the same line reported not reported
Comment, empty text, query on the same line reported not reported
Query inside a split block string reported not reported
Ignored text in a literal, then a query reported reported
Query inside one literal once once
Two operations, the second in a literal both both
Fragment, then a query in a literal reported reported

The last four rows match on both sides. The comment and block string rows hold text that GraphQL treats as hidden. Main reports it. This head does not. The cost is the Apollo rows, which this head drops.

Tests

Check Node 22.23.1 Node 24.18.0 Node 26.11.1
PR test file on head (26 tests) pass pass pass
Same file, source put back to merge-base 0bc422d not run 1 fails not run
PR test file copied onto main not run 3 fail 3 fail
Main's test file on main (63 tests) not run pass pass
Main's test file copied onto head not run 30 fail 30 fail

The 3 failures on main are the unknown prefix, comment and block string tests. The 30 on head are mostly tests from later main commits that this branch lacks. The names are in the raw log. I did not check each one by hand. One of them is the leading fragment test.

Not run

  • The browser check for web bundles.
  • Head merged onto main. I only counted text conflicts.
  • Review points on the latest head, such as user-defined tags.
  • Windows and macOS. The full suite and the acceptance tests.

Thanks, Jay Hemnani, for the report and the fixtures. Jay asked on 2026-10-14 whether to rebase. That question is still open.

The call is morluto's. Report the Apollo style, as main does now, or keep it unknown, as this head does.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head: ee6148e
  • Base: 0bc422d
  • Other: main af6a998; another test job shared the box
Commands
npm ci && npm run build && npm run test:prepare
npm run test:focused -- src/domain/javascript/javascriptRpcEndpoints.test.ts
node scripts/rea.mjs analyze-javascript-application <fixture-dir> --json
git merge-file -p <head-file> <base-file> <main-file>

Each run sat under nice and systemd-run with MemoryMax=6G. The fixture is one app.js with 13 templates: one fragment definition and one per row above.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@jayhemnani9910

Copy link
Copy Markdown
Contributor Author

Main already has the leading-fragment fix in b58adaf, and per @CassieFox23's table it reports every case this PR set out to fix, while this head leaves several of them unknown. Closing this so it doesn't sit in conflict with main. If you want the exact-literal folding from this branch on top of main, say so and I'll open a smaller PR for just that part.

@jayhemnani9910
jayhemnani9910 deleted the fix/graphql-leading-interpolation branch October 20, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants