Skip to content

feat(javascript): keep syntax facts for a source whose member-mutation phase is refused - #11187

Merged
morluto merged 2 commits into
feat/javascript-member-mutation-settingfrom
feat/javascript-keep-refused-syntax-facts
Nov 15, 2026
Merged

morluto merged 2 commits into
feat/javascript-member-mutation-settingfrom
feat/javascript-keep-refused-syntax-facts

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

When the member-mutation work allowance refused a source during static analysis, the source lost every fact. The application graph then counted it as skipped (parsed_javascript_files: 0), which is the #8294 symptom. import-reference-source failed entirely on such a file. With this PR, a refused source keeps the syntax-level facts that earlier phases produced, and those facts are marked with the phase that was refused. #8294 asks for this: "a bounded partial result (syntax-level inventory) would be preferable to skipping the whole file."

Stacked on #11181, which makes the allowance a runtime setting.

Refs #8294

Problem and expected behavior

  • Before:
    • analyze_javascript_application: if the static phase was refused, the worker threw before its static checkpoint, so only the per-source analysis_failure remained.
    • import-reference-source: the refusal escaped parseReferenceSourceImports and aborted the import.
  • After:
    • analyze_javascript_application:
      • The worker checkpoints memberMutationRefusedJavaScriptStaticAnalysis and then reports the same refusal.
      • That checkpoint holds the static owner's syntax-level facts: parse status partial, the syntax coverage with error count, source map directives (from comment tokens) and vendor markers (from source text).
      • Every finding that depends on member-mutation facts is left out. Its absence is marked by analysis_coverage.examination.status: "not-examined", refused_phase: "member-mutations", an unexamined_reason and a limitation.
      • The source counts as parsed.
      • The semantic phase is not started, because it indexes the same mutations under the same allowance and would only repeat the refused work.
    • import-reference-source: the file keeps its declaration-level and dynamic imports. A limitation records that its CommonJS require calls were not examined, with the setting's recovery.

Change and scope

  • javascriptStaticAnalysis.ts owns the syntax-only result builder.
  • javascriptStaticCoverage.ts:
    • Adds the optional examination.refused_phase field.
    • javaScriptStaticParseStatus now reports partial when examination is not-examined. That state was previously unreachable for parsed syntax.
  • javascriptSemanticWorkAllowance.ts adds isJavaScriptMemberMutationRefusal.
  • The worker composition and reference-source parsing use that predicate. Every other error still propagates unchanged.
  • Not included:
    • Retaining partial findings collected before the refusal. They may have read an incomplete mutation index, so they are dropped.
    • Retaining syntax facts for analyze_web_bundle. A refused script there is still reported as unavailable (reason: resource). Returning a partial WebBundleScriptAnalysis needs its own schema decision and is listed as follow-up.
    • Metering other phases.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the static analysis owner (analyzeParsedJavaScriptStaticSourceSteps family) and parseReferenceSourceImports. Consumers: the application graph builder (unchanged), which now receives a checkpoint where it previously received none.

  • Contribution scope fit and linked maintainer decision: the coordinator approved this for plan W10. No new authority.

  • CLI and MCP/tool-catalog contract: one additive optional output field, analysis_coverage.examination.refused_phase. No input change.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract:

    • A refused source now has a file record with parse_status: "partial" and counts in parsed_javascript_files.
    • Omitted findings are marked as unexamined.
    • Reference-source graphs keep a refused file's import edges, and that file carries a limitation.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated:

    • tests/boundary/javascript/javascriptMemberMutationAllowance.test.ts runs the real application workflow with allowance 8, using both a seed and a runtime override. The refused main.js has parse_status: "partial", complete syntax coverage, examination.status: "not-examined" and refused_phase: "member-mutations", and parsed_javascript_files is 1. With an admitting allowance there is no refused record.
    • src/domain/referenceSourceImportParsing.test.ts (new): with the default allowance, require.call(null, "./other") and import("./lazy") both become relationships. With allowance 1 only the dynamic import is kept, parse_failures is empty, and a limitation names the refused phase and the setting's value and source.
  • Base reproduction:

    • Executed: with parseReferenceSourceImports calling referenceSourceRequireCalls directly (the base behavior), the new reference test fails with Resource constraint during analyze_javascript_semantics: JavaScript member-mutation analysis scheduled more than 1 alias states for one source.
    • Source-derived: for the application test, the base checkpoint is never sent, so the refused-record assertions cannot hold there. I did not run the application test against base.
  • Remaining proof gaps:

    • Not exercised end to end: a source refused during the semantic phase. Its static checkpoint already existed and is unchanged.
    • Not exercised end to end: a parser-recovered source.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run typecheck passed.
  • npm run check:fast passed (2/2 tasks).
  • node scripts/verify/architecture-guards.mjs passed.
  • npm run docs:check passed.
  • npm run test:focused -- tests/boundary/javascript/javascriptMemberMutationAllowance.test.ts: 2 passed.
  • npm run test:local -- src/domain/referenceSourceImportParsing.test.ts: 1 passed. With the fix reverted locally it failed as described above.
  • npm run test:local -- src/domain/javascript/javascriptStaticCoverage.test.ts src/domain/javascript/javascriptMemberMutationCoverage.test.ts src/application/ReferenceSourceImportEntries.test.ts: 49 passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. The output field is optional and additive. Sources that are not refused are unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new reads. The facts come from the already-parsed source.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • 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.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T14:03:42.475706Z
We couldn’t complete this review. Comment @codex review to try again.
dd3de83 PR opened
ℹ️ 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge, with no outstanding actionable findings.

Summary

Refused JavaScript sources now retain syntax-level facts without presenting missing findings as examined.

  • Application analysis keeps syntax facts when member-mutation work is refused.
  • Reference imports keep non-require edges when require analysis is refused.

Reviews (2) · Last reviewed commit: "test(javascript): compare the reference-..." · Reviewed by Greptile

@morluto
morluto force-pushed the feat/javascript-keep-refused-syntax-facts branch from dd3de83 to 7bfd08e Compare November 15, 2026 14:11
@morluto
morluto force-pushed the feat/javascript-member-mutation-setting branch from 0e901bc to 063dd30 Compare November 15, 2026 14:21
…n phase is refused

A source refused by the member-mutation work allowance during static analysis lost every fact, so the application graph counted it as skipped. Reference-source import failed outright on such a file.

Checkpoint the parser, comment and text facts the static owner can still state, with parse status partial, examination not-examined and refused_phase member-mutations, before reporting the refusal; the semantic phase is not started because it indexes the same mutations. Reference-source import keeps the file's declaration-level imports and records that its CommonJS require calls were not examined.

Refs #8294
@morluto
morluto force-pushed the feat/javascript-keep-refused-syntax-facts branch from 7bfd08e to 9e121ad Compare November 15, 2026 14:22
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai please review the latest commit (9e121ad). Issue 1 from the previous review, which flagged the frozen refusal wording in referenceSourceImportParsing.test.ts, is addressed there. The test now asserts the kept relationships and compares the limitation with the owning formatter's remediationAction. The branch is also rebased onto the updated #11181.

@morluto
morluto merged commit 49ec3f6 into feat/javascript-member-mutation-setting Nov 15, 2026
1 check passed
@morluto
morluto deleted the feat/javascript-keep-refused-syntax-facts branch November 15, 2026 14:38
morluto added a commit that referenced this pull request Nov 15, 2026
…etting (#11181)

* feat(javascript): make the member-mutation work allowance a runtime setting

The member-mutation alias-state allowance from #11144 was a fixed constant, so a refused source could not be admitted without a code change.

Register javascript.member_mutation_alias_states (default 524288, 1 to 8388608 alias states) with the launch seed REA_JAVASCRIPT_MEMBER_MUTATION_ALIAS_STATES. The application, web bundle and reference-source boundaries resolve it from the accepted operation snapshot and launch environment, refuse a malformed seed before analysis, and send it to the workers with each source. A refusal names the setting, its effective value, source and range, and the recovery; worker parents rebuild it from the allowance they sent.

Refs #8294

* fix(javascript): keep the setting and recovery of a refused web script

A web bundle script refused by the member-mutation allowance kept only its reason and reported limits, so the public unknown lost the setting, value, source and recovery. Carry the refusal's structured limit and remediation on the per-script result and its javascript_analysis unknown, grouping scripts only when that recovery agrees. Assert structured limit facts and the owning formatter's recovery instead of fixed wording.

* fix(browser): keep only registered setting limits on a refused web script

* feat(javascript): keep syntax facts for a source whose member-mutation phase is refused (#11187)

* feat(javascript): keep syntax facts for a source whose member-mutation phase is refused

A source refused by the member-mutation work allowance during static analysis lost every fact, so the application graph counted it as skipped. Reference-source import failed outright on such a file.

Checkpoint the parser, comment and text facts the static owner can still state, with parse status partial, examination not-examined and refused_phase member-mutations, before reporting the refusal; the semantic phase is not started because it indexes the same mutations. Reference-source import keeps the file's declaration-level imports and records that its CommonJS require calls were not examined.

Refs #8294

* test(javascript): compare the reference-source refusal with its owning formatter

* feat(javascript): keep a refused web script's parse and text facts

A captured script whose member-mutation phase was refused lost every fact in analyze_web_bundle, so it was neither counted as parsed nor kept its vendor markers.

The analyzer now returns the script as unavailable with partial facts: refused phase, parse status and the inferences read from script text alone. Findings gathered before the refusal are dropped, because they may have read an incomplete mutation index. The worker parent states the refusal and its setting recovery from the allowance it sent, through the same helper the isolated analyzer uses for every unavailable script. The bundle counts the script as parsed, keeps its text inferences, and its javascript_analysis unknown carries refused_phase.

Refs #8294

* chore(mcp): record the member-mutation setting in the advertised summary

* fix(javascript): rebuild a parked source worker when the member-mutation allowance changes

A worker parked on a resource scope was reused when heap, timeout and precision matched, but its requests carry the allowance it was built with. After update_analysis_settings accepted a new allowance, the next analysis on that scope kept the old one.

The reuse check now compares the allowance's value and source, so a changed setting gets a worker built with it. The web bundle worker already takes the allowance per script.
@morluto morluto added the enhancement New feature or request label Nov 22, 2026
@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant