Skip to content

fix(javascript): classify member assignment targets as property writes - #2881

Closed
0x-saurabh wants to merge 4 commits into
morluto:mainfrom
0x-saurabh:fix/javascript-member-write-classification
Closed

0x-saurabh wants to merge 4 commits into
morluto:mainfrom
0x-saurabh:fix/javascript-member-write-classification

Conversation

@0x-saurabh

@0x-saurabh 0x-saurabh commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #2567.

JavaScript semantic analysis classified a member expression as a property write only when its immediate parent was an assignment or update expression. A member that is the target of a destructuring assignment ([o.count] = [2]), a for...of / for...in head (for (o.count of list)), or delete o.count therefore produced a read object operation and a false reads-property relation in the semantic graph, although none of these forms reads the property value.

Problem and expected behavior

Smallest trigger:

const source = { count: 1 };
[source.count] = [2];

ir.objectOperations reported ["read"] and the graph projected a read:/count occurrence with a reads-property relation. The violated invariant is the one the sibling member-mutation analysis already follows: these constructs assign into their target and are writes, so the object operation must be write, the occurrence write:/count, and the relation writes-property. A direct source.count = 2 must stay a write; a plain source.count access, and a member used as a destructuring default value ([v = source.count] = []), must stay reads.

Change and scope

The object collector now classifies a member from its owning write site rather than from its immediate parent. When the traversal enters a write site it records each written member leaf, keyed to that site, through the existing semanticWriteTargets walker; collectMember consumes the entry. Read-before-write is decided from the owning site through a new shared predicate, semanticWriteSiteReadsFirst, so TypeScript-wrapped targets such as source.count!++ or (source.count as number) += 1 keep their property read (previously these were read-only, since the wrapper hid the assignment parent).

The notion of "which constructs are write sites" previously lived inline in javascriptSemanticMemberMutations.ts and again in javascriptElectronMemberWrites.ts. It is now one exported helper, semanticWriteSiteTarget, in javascriptAstValues.ts next to semanticWriteTargets, and the object collector, the member-mutation analysis, the Electron provenance collector, the identifier reference collector, binding assignment, and the symbolic bindings resolver all dispatch through it. No consumer reinterprets the syntax.

Review follow-ups on the same owner:

  • semanticReadsBeforeWrite delegates to semanticWriteSiteTarget and semanticWriteSiteReadsFirst (maintainer commit 5fbeb4313), so identifier references and member operations share one read-before-write rule.
  • Wrapped identifier targets (count! += 1, (count as number)++) are classified from their write site through a new semanticWrappedWriteSite helper, so the reference collector emits the read and the write, and binding assignment sees through the wrapper so the old exact value is not retained.
  • The symbolic bindings resolver (javascriptSymbolicBindings.ts) dispatches through semanticWriteSiteTarget. A direct identifier or member target records its value as before; a destructuring pattern or loop head is flattened with semanticWriteTargets and each leaf conservatively invalidates its root binding, so [table[1]] = [replacement] or for (table[1] of list) no longer leaves a stale bootstrap slot. Wrappers inside a member chain ((table as never)[1]) are unwrapped during the walk, matching the object collector.

Not included: the value-projection side (writes-property relations added from the value analysis) is untouched; this change only removes the false read occurrence and adds the missing write occurrence at the object-operation boundary. No CLI, MCP, or catalog contract changes.

Follow the contribution scope.

Contract and boundary impact

  • Semantic owner and earliest changed stage: collectJavaScriptSemanticObjects in src/domain/javascript/javascriptSemanticObjects.ts (domain static analysis). The graph projection in JavaScriptSemanticGraphObjectProjection.ts consumes the corrected operation kind unchanged.
  • Contribution scope fit and linked maintainer decision: ordinary static-analysis correctness fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: none. Object operation kinds and relation names already exist; only their assignment to these syntax forms changes.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: semantic-graph output for affected sources gains a writes-property relation and loses a false reads-property relation for the same location. No identity or provenance fields change.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable; static source parsing only.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated (listed per file; the last two bullets are the review follow-ups):

    • src/domain/javascript/javascriptSemanticAnalysis.dataflow.test.ts: seven it.each cases (destructuring assignment, with default, nested, rest, for...of head, for...in head, delete) assert objectOperations is exactly ["write"]; one control asserts a member in a destructuring default value stays ["read"]. Four wrapped read-modify-write cases (source.count!++, source.count! += 1, (source.count as number) += 1, (source.count)++) assert ["read", "write"], and two wrapped write-only cases ((source.count as number) = 2, delete source.count!) assert ["write"]. The existing direct-assignment and read-modify-write cases remain and still pass.
    • src/domain/javascript/javascriptSemanticAnalysis.dataflow.test.ts (wrapped binding targets): count! += 1; (count as number)++; const copy = count! yields reference roles read, write, read, write, read and the binding value becomes unknown; count! = 2 yields a single write.
    • src/domain/javascript/javascriptSymbolicBindings.test.ts: a bootstrap module slot overwritten through a destructuring assignment, a for...of head, or a wrapped member chain makes the later load(1) unknown.
    • src/application/javascript/JavaScriptSemanticGraphBuilder.test.ts: [source.count] = [2] projects a single write:/count occurrence with a resolved writes-property relation to the /count slot and no reads-property relation.
  • Base reproduction or other evidence: executed. With the source files stashed and only the tests applied, the seven new dataflow cases fail (each reports ["read"]); the direct-assignment control and the default-value control pass. The three TypeScript-wrapped read-modify-write cases fail against the first commit of this PR (write-only) and pass after the second. With the fix applied all cases pass.

  • User-visible CLI/MCP output (if applicable): not applicable.

  • Remaining proof gaps: none known for the listed forms. Member targets inside destructuring declarations (const [x] = ...) cannot contain member expressions and are unaffected.

  • 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

  • npm run test:focused -- src/domain/javascript/javascriptSemanticAnalysis.dataflow.test.ts src/domain/javascript/javascriptSymbolicBindings.test.ts src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts src/application/javascript/JavaScriptSemanticGraphBuilder.test.ts — 4 files, 336 tests passed (at 7051da0).
  • Same dataflow and symbolic-bindings test files with the four changed source files reverted to aa3047ad5 (tests only) — the five review follow-up cases fail (two wrapped-identifier, three symbolic-bindings); the rest pass.
  • Same focused run with the three source files stashed (tests only) — the seven new dataflow cases fail with ["read"]; both controls pass. Confirms the regression reproduces on the base.
  • npm run check:fast — typecheck and lint, 2 tasks successful (at 7051da0).
  • npm run check:changed — 89 test files, 2000 tests passed (at 7051da0).
  • git diff --check — clean.
  • Toolchain: Node 24.18.0 (.nvmrc), npm 11.16.0, macOS arm64. No real-provider lane applies.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; pure static JavaScript analysis.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new I/O, process, or network behavior.

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.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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:48:05.359493Z ef85297 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.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Refactors how member assignments in destructuring patterns are classified.

The PR still needs the existing wrapped-export value fix before merging.

Findings

  1. P1 Wrapped exports get wrong values ▶
Fix with agent prompt
### Issue 1
src/domain/javascript/javascriptSymbolicBindings.ts:undefined-960
`#indexWriteSite` now reaches wrapped member targets, but it records `site.right` for every assignment operator. In a module factory, `exports.api = 'prefix'; (exports as any).api += require('electron');` makes `load(1).api` resolve to Electron, although the actual value is a string. `#propertyValue` treats the recorded right-hand side as the final export value, so later analysis follows the wrong value.

Only record an exact value for `=`. Compound assignments need to keep the result unknown unless their full result is calculated.

---

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

Summary

The PR classifies member targets in destructuring assignments, loop heads, and delete as property writes.

  • Member targets in destructuring, loop heads, and delete become property writes.
  • Wrapped identifier assignments keep their read and write roles.
  • Untracked writes invalidate affected symbolic module slots.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Write site] --> B[semanticWriteSiteTarget]
  B --> C[semanticWriteTargets]
  C --> D[Record member and owning site]
  D --> E[collectMember]
  E --> F{semanticWriteSiteReadsFirst}
  F -->|Yes| G[Read and write operations]
  F -->|No| H[Write operation]
Loading

Reviews (8) · Last reviewed commit: "fix(javascript): resolve wrapped write t..." · 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: a105aa0e10

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

@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: 561b9232e0

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

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

Changes are present at public head 5fbeb4313890280cc22057d0bbf65578078a96c8. Two consumers duplicated read-before-write classification. The public change routes the site-aware predicate through the shared semantic write-site owner, so both projections use the same rule. Reviewed producer/consumer call graph and git diff --check; tests were not run.

@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: c0065ca243

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

parent.left === node &&
parent.operator !== "=") ||
(t.isUpdateExpression(parent) && parent.argument === node);
semanticWriteSiteTarget(parent) === node &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Carry write-site ownership into wrapped identifier references

For a TypeScript/Flow-wrapped binding target such as (count as number)++ or count! += 1, collectSemanticReferencesSteps still gives semanticIdentifierRole and this predicate the identifier's immediate wrapper parent, so the occurrence is emitted only as a read and the graph has no writes edge; wrapped updates also miss bindAssignment's identifier-only update branch and can leave the old exact value. The fresh evidence beyond the resolved wrapped-member case is the still-immediate-parent call at javascriptSemanticProjection.ts:180-185; carry the owning write site through identifier collection too.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 7051da0. Identifier references now resolve their write site through inert wrappers with a new shared helper, semanticWrappedWriteSite, so count! += 1 and (count as number)++ produce a read and a write reference (and therefore the writes edge), and count! = 2 a write. bindAssignment unwraps the identifier for the assignment and update fast paths, so the binding's old exact value is no longer retained after a wrapped update. delete x deliberately stays a read, as before. Covered in javascriptSemanticAnalysis.dataflow.test.ts ("wrapped binding targets"); both cases fail on the previous head and pass now.

Comment on lines +98 to +102
export const semanticWriteSiteTarget = (node: t.Node): t.Node | null => {
if (t.isAssignmentExpression(node)) return node.left;
if (t.isUpdateExpression(node)) return node.argument;
if (t.isUnaryExpression(node, { operator: "delete" })) return node.argument;
if (t.isForOfStatement(node) || t.isForInStatement(node)) return node.left;

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 Invalidate symbolic bundle tables for flattened targets

When a detected bundle table is overwritten through a destructuring target such as [table[1]] = [replacement], JavaScriptSymbolicBindings still uses its own dispatch at javascriptSymbolicBindings.ts:107-112 and passes the whole ArrayPattern to #indexWrite, so no slot is recorded or invalidated and wrapped-call analysis can continue reporting APIs from the replaced factory. Route this affected consumer through the new write-site owner and flatten its targets conservatively as well.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 7051da0. JavaScriptSymbolicBindings now dispatches through semanticWriteSiteTarget. A direct identifier or member target records its value as before; a destructuring pattern or loop head is flattened with semanticWriteTargets and each leaf conservatively invalidates its root binding (the existing dynamic-path behavior), so [table[1]] = [replacement] and for (table[1] of list) no longer leave a stale bootstrap slot. The member walk also unwraps inert wrappers, matching the object collector. Three new cases in javascriptSymbolicBindings.test.ts fail on the previous head and pass now.

@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: aa3047ad59

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

Comment on lines +475 to +476
const writeTarget = semanticWriteSiteTarget(node);
if (writeTarget !== null) markTarget(writeTarget, node);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Normalize reference-store targets before escape analysis

When a member store is wrapped by TypeScript syntax, such as (external.slot as unknown) = source, this branch unwraps it for markTarget, but the preceding semanticIterationSources call uses an independent pattern walker that only recognizes a bare MemberExpression (javascriptSemanticIterationSources.ts:79). It therefore emits no reference-store, so source never receives an escaped path and can remain an exact object even after being exposed through an arbitrary receiver; normalize that producer through the same write-target owner before applying either effect.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

* {@link semanticWriteTargets} flattens to its written leaves.
*/
export const semanticWriteSiteTarget = (node: t.Node): t.Node | null => {
if (t.isAssignmentExpression(node)) return node.left;

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 Project wrapped CommonJS exports through the write owner

For a wrapped or destructured export target such as (module.exports.run as unknown) = handler or ({ handler: module.exports.run } = impl), this owner and semanticWriteTargets identify the member write, but collectCommonJsExport still passes the raw node.left to commonJsExportName (javascriptSemanticProjection.ts:462-467), which rejects wrappers and patterns. No commonjs-export module link is emitted, so cross-file composition loses the exported run; have that consumer inspect the owner's normalized target leaves and preserve the corresponding RHS projection when available.

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

Useful? React with 👍 / 👎.

) {
this.#indexWrite(
direct,
t.isAssignmentExpression(site) ? site.right : site,

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 Wrapped exports get wrong values

#indexWriteSite now reaches wrapped member targets, but it records site.right for every assignment operator. In a module factory, exports.api = 'prefix'; (exports as any).api += require('electron'); makes load(1).api resolve to Electron, although the actual value is a string. #propertyValue treats the recorded right-hand side as the final export value, so later analysis follows the wrong value.

Only record an exact value for =. Compound assignments need to keep the result unknown unless their full result is calculated.

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

Comment:
**Wrapped exports get wrong values**

`#indexWriteSite` now reaches wrapped member targets, but it records `site.right` for every assignment operator. In a module factory, `exports.api = 'prefix'; (exports as any).api += require('electron');` makes `load(1).api` resolve to Electron, although the actual value is a string. `#propertyValue` treats the recorded right-hand side as the final export value, so later analysis follows the wrong value.

Only record an exact value for `=`. Compound assignments need to keep the result unknown unless their full result is calculated.

---

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

@morluto
morluto force-pushed the fix/javascript-member-write-classification branch from 7051da0 to a916e54 Compare October 13, 2026 18:25

@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: a916e54f12

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

* has a wrapper as its immediate parent, so the parent alone cannot say that
* the identifier or member is written.
*/
export const semanticWrappedWriteSite = (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Normalize wrapped targets for result-binding projection

When a data-effectful call is assigned through a newly supported wrapper, such as child! = spawn(...), assignedSemanticResultBindings still passes the raw owner.left to projectedPatternBindings (javascriptSemanticDataEffectHelpers.ts:41-50), whose walker has no wrapper case. It therefore returns no result binding, so child-process interactions, resource releases, async handles, and request consumers remain unlinked even though the reference and binding IR now records the write; normalize this target through the shared owner before projection.

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

Useful? React with 👍 / 👎.

): void => {
if (t.isAssignmentExpression(node)) {
if (t.isIdentifier(node.left))
const left = unwrapJavaScriptExpression(node.left).node;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Route binding dispatch through the write-site owner

bindAssignment still independently dispatches assignment, update, and for-in/of syntax instead of using the new semanticWriteSiteTarget owner. A future write-form or normalization correction can therefore update object, mutation, Electron, and symbolic projections while leaving binding definitions and values stale; obtain the target from the owner once, then retain only the value-specific handling here and deliberately ignore identifier deletes.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

) {
this.#indexWrite(
direct,
t.isAssignmentExpression(site) ? site.right : site,

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 compound symbolic writes inexact

Within a detected bundle module, a wrapped compound target such as (module.exports.count as number) += 2 now reaches this branch, but every assignment expression records site.right as the exact exported value. #propertyValue later evaluates that node directly even though the runtime result depends on the previous count (and a logical assignment may not write at all), producing false exact literals or APIs; only plain = should store its RHS, while read-modify writes should be invalidated or modeled from the shared read-first fact.

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

Useful? React with 👍 / 👎.

0x-saurabh and others added 4 commits October 14, 2026 02:38
Member expressions that are the target of a destructuring assignment,
a for...of or for...in head, or a delete expression were recorded as
property reads because the object collector only recognized a direct
assignment or update parent. The semantic graph then projected a false
reads-property relation and no write occurrence for these forms.

Classify a member from its owning write site instead: the collector
records the written member leaves when it enters a write site, using the
existing semanticWriteTargets walker. The set of write-site constructs
now lives in one exported helper, semanticWriteSiteTarget, shared with
the member-mutation analysis that already treated these forms as writes.

Fixes morluto#2567

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Keying each written member to its owning write site lets the object
collector decide read-before-write from that site, so TypeScript-wrapped
targets such as source.count!++ or (source.count as number) += 1 keep
their property read instead of becoming write-only. The predicate lives
beside semanticWriteSiteTarget as semanticWriteSiteReadsFirst.

The Electron member-write collector now dispatches through
semanticWriteSiteTarget too, removing the last inline copy of the
write-site cascade.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…te-site owner

Identifier references classified a wrapped target such as count! += 1
or (count as number)++ from its immediate wrapper parent, so the
occurrence was a read only and binding assignment kept the old exact
value. A new shared helper, semanticWrappedWriteSite, finds the write
site through inert wrappers; the reference collector and binding
assignment use it, so wrapped updates emit the read and the write.

The symbolic bindings resolver kept its own write-site cascade and
passed whole destructuring patterns to its index walk, so a bootstrap
table slot overwritten through [table[1]] = [...] or a loop head stayed
resolvable. It now dispatches through semanticWriteSiteTarget, flattens
pattern and loop-head targets with semanticWriteTargets, and
conservatively invalidates each leaf's root binding. The member walk
unwraps inert wrappers, matching the object collector.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@morluto
morluto force-pushed the fix/javascript-member-write-classification branch from a916e54 to ef85297 Compare October 13, 2026 18:38

@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: ef85297599

ℹ️ 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 +944 to +945
const left = unwrapJavaScriptExpression(node.left).node;
if (t.isIdentifier(left))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Normalize wrapped targets in interop reassignment proofs

When TypeScript wraps the reassignment in the already-supported Rolldown interop pattern, for example let electron = require("electron"); electron! = __toESM(electron, 1);, this branch now adds the assignment definition, but createSemanticModuleInterop.origin still requires a bare assignment.left at javascriptModuleInterop.ts:570-583. The conversion therefore becomes unprovable, and electronExport at javascriptSemanticAnalysis.ts:588-592 rejects the reassigned binding, dropping subsequent BrowserWindow, IPC, and other Electron findings; normalize that proof through the shared write target as well.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

Comment on lines +944 to +945
const left = unwrapJavaScriptExpression(node.left).node;
if (t.isIdentifier(left))

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 Preserve ordering for wrapped assignment initializers

When a wrapped reassignment follows an alias read inside a getter, such as let x = old; const y = x; x! = replacement; return y, the initializer recorded here has no statement position because directInitializerPosition only accepts a bare parent.left at javascriptSemanticMutationInitializers.ts:56-66. semanticReadInitializers therefore retains the future replacement initializer while resolving y, so a later holder.selected.mode = value is projected onto both old and replacement even though runtime returns only old; normalize the LHS in that ordering helper.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Oct 14, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Track module writes and escapes at their owner, preserve capture and reassignment ordering, and share CommonJS/default namespace identity without erasing parent-slot changes. Carry write sites into ambient alias resolution and use parsed write targets across consumers. Deduplicate returned-reference work with cycle context; retain unchanged temporal selection identity so provenance memoization stays effective.

Reviewed fixes include #2041, #2465, #2830, #2881, and #2948. Remove superseded mutation representations and the ineffective per-markValue dedup layer.

Validation: 380 focused JavaScript tests passed under a 384 MiB heap cap, including the previously aborting 30-level/128-call alias regression. Six public CLI/MCP builtin tests passed. Exact pdf.js completed-workflow performance remains unmeasured.
@CassieFox23

Copy link
Copy Markdown
Contributor

Heads up: main already has this change in 04672f2. The code is in src/domain/javascript/javascriptSemanticMemberMutations.ts. It is listed on tracker #3582. If this PR still adds something main doesn't have, please say so here and I'll take it off the list. Thanks for the fix!

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

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Superseded by the delivered change on main: fb4b8a470. Member-assignment targets are property writes, with direct/destructured/loop/delete and read-control coverage in the owning semantic analysis. Closing this earlier proposal. Current main qualification passed: https://github.com/morluto/rea/actions/runs/38690953281.

@morluto morluto closed this Oct 15, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks @saurabh-sol for the JavaScript member-write classification case. Main preserves that write evidence in the shared parser.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(javascript): member assignment targets appear as property reads

4 participants