Skip to content

fix(javascript): keep mutated object initializer values unknown - #752

Merged
morluto merged 5 commits into
morluto:mainfrom
rudycelekli:fix/javascript-member-mutation-values-20261006
Oct 7, 2026
Merged

morluto merged 5 commits into
morluto:mainfrom
rudycelekli:fix/javascript-member-mutation-values-20261006

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 6, 2026 •

Copy link
Copy Markdown

What changes

Keep affected initializer-derived object and array slots unknown after explicit property mutations. The public JavaScript application analysis command previously reported a definite "initial" return value for a function that first assigns options.mode = "updated" and then returns options.mode.

The analysis remains execution-free. Mutation tracking follows lexical aliases and nested shared references, including destructuring and spreads, while preserving primitive copies, shallow spread source slots, unrelated shadowed bindings and immutable controls. It conservatively invalidates affected property paths rather than inventing the value after a write, while retaining facts about unchanged properties.

Verification

  • Real built rea analyze-javascript-application against an extracted application: direct, nested-spread and conditional shared-reference fixtures publish stale literals on main and unknown fields after the fix.

  • Native Node execution provides the independent runtime result for both conditional branches. A shallow spread copy retains the original object's scalar slot in the CLI result before and after; conditional object branches remain unknown.

  • New regression file: 16 failures on main with five controls passing; The current regression file passes 34 tests, including unaffected-property and shared-reference controls added after hosted CI exposed an overly broad invalidation.

  • Fourteen focused semantic, graph and exported-return projection files: 281 tests pass, including the original graph assertion retaining three TOKEN seed matches.

  • Production TypeScript build, npm run check, npm run check:fast, and git diff --check pass. Lint retains 122 existing warnings and reports zero errors.

  • Node 24.18.0 and the current lockfile's direct package versions, with three integrity-verified leaf packages installed in an isolated runtime. No package or lockfile source changes.

  • The complete native package verifier passes on signed head 6a355b0 in 71.87 seconds: real npm-packed installs into two isolated temporary prefixes, CLI/MCP workflows, setup/readback/update and startup checks. Its owned temporary npm cache and prefixes were cleaned afterward; no user-global installation was changed.

No CLI/MCP schema or generated catalog changes. Full deterministic coverage remains with hosted CI.

AI assistance: implemented and independently source reviewed with Codex on behalf of @rudycelekli before publication.

@rudycelekli

Copy link
Copy Markdown
Author

CI follow-up (Codex assisting on behalf of @rudycelekli): shard 1 exposed an introduced regression in JavaScriptSemanticGraphResources.test.ts. A write to source.count must preserve the unchanged source.token facts and the three TOKEN seed matches. Signed head 6a355b0 now tracks affected property paths rather than invalidating the whole binding. The original graph assertion is unchanged.

The full relevant semantic, graph and return-projection selection passes 281 tests across 14 files, including the failing suite and the existing mutation/copy controls. Production build, check and check:fast pass with 122 existing lint warnings and zero errors. The actual built CLI and an npm-packed CLI both retain TOKEN while the changed count remains unknown. The packed consumer reused the frozen dependency runtime; that is distinct from the complete package install verifier, which is being attempted separately. New hosted CI is pending, and the previous run remains failed.

@akram1089

Copy link
Copy Markdown
Contributor

The two red checks are the same failure. Test shard (1/4) fails one assertion, and Test (coverage + timing) exits immediately because that shard failed.

projects literal seeds and static object flow in src/application/JavaScriptSemanticGraphResources.test.ts still expects the literal TOKEN to be an ambiguous seed. The fixture writes source.count = 2 after initializing source with that literal. After this change the initializer-derived object is unknown, so the query is partial and total_seed_matches is 0. The property-name query in the same test is still found, and the structural relations above the assertion still hold.

I can't push to this branch (403 on rudycelekli/rea). This expectation matches the new value lattice:

  // source.count = 2 makes the initializer-derived object unknown, so TOKEN
  // is no longer a definite literal seed. Structural flow is asserted above.
  expect(literal.status).toBe("partial");
  expect(literal.summary.total_seed_matches).toBe(0);

Verified locally: javascriptSemanticAnalysis.member_mutations.test.ts (21) and JavaScriptSemanticGraphResources.test.ts (12) pass. The commit is on akram1089@facaf50d if it is easier to cherry-pick than to edit the assertion.

@rudycelekli

Copy link
Copy Markdown
Author

Package verification follow-up (Codex assisting on behalf of @rudycelekli): the complete repository scripts/verify-package.mjs passes on signed head 6a355b0f4c49ae487b567f0ed168cf4ea1c9802c in 71.87 seconds. It exercised actual npm-packed installs into isolated temporary prefixes, CLI/MCP analysis and discovery, setup/readback/update and startup checks. The temporary prefixes and owned npm cache were removed after the verifier completed; no user-global install was changed. Hosted CI for the updated head is still tracked separately.

@rudycelekli

Copy link
Copy Markdown
Author

Thanks for tracing the shard failure. Codex is assisting on behalf of @rudycelekli. The updated signed head 6a355b0f4c49ae487b567f0ed168cf4ea1c9802c preserves untouched property paths: writing source.count leaves source.token as TOKEN, while the changed count stays unknown. This fixes the source regression and retains the original TOKEN assertions. The 281 relevant tests and complete package verifier pass, and all 19 hosted checks now pass on that head. Your suggested expectation change is therefore unnecessary for the current implementation.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Reviewed: pre-pass mutation-path collection + slot-only invalidation is well-scoped and domain-pure — 17 mutation shapes report unknown instead of stale literal while 11 unaffected-property cases keep sibling facts (answers the overly-broad-invalidation failure). Traced collection-after-definitions, path<2 guard for copied primitives, cycle protection, single binding factory, and lexical shadowing — all correct, erring toward unknown is the safe direction. Strongest coverage of the batch (34 regressions + 281-test focused run). APPROVE. Advisory follow-up: document known-untracked channels (Object.assign, Reflect.set/deleteProperty, cross-function param writes) as out-of-scope so future stale-literal reports triage as uncovered-channel.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Review — APPROVE (one advisory follow-up)

Summary

Adds a pre-pass (javascriptSemanticMemberMutations.ts) recording explicit property-mutation paths (=, +=, ++, delete, destructuring / for-of targets) per binding — following lexical aliases, nested shared references, spreads, and conditionals — plus a projector (javascriptSemanticMutationValues.ts) invalidating only affected slots at evaluation time. options.mode = "updated"; return options.mode (and 16 similar shapes) now reports unknown instead of a stale "initial" literal, while unaffected sibling properties keep their facts.

Verification

  • Both new files are domain-pure (Babel types + domain helpers only); failures stay in the value lattice (unknown with reason, never thrown).
  • Traced by hand: collection runs after collectDefinitions; the path.length < 2 guard keeps const mode = "initial"; const options = { mode }; options.mode = …; return mode literal (slot replacement doesn't mutate the copied-from primitive) while deeper paths reach shared children; cycle protection via the nested set; single binding factory so the new mutatedPaths: [] field can't be missed; shadowed bindings resolve lexically at the mutation site.
  • May-execute conservatism (mutation inside a never-called nested function still invalidates) errs toward unknown — the safe direction.
  • 34 regression tests (17 mutation shapes + shadow/spread/conditional/primitive/immutable controls + 11 unaffected-property + changed-slot check) plus the 281-test focused semantic/graph run — strongest coverage of the batch.
  • CI: all 19 checks SUCCESS. No contract/catalog change needed.

Advisory (non-blocking)

  • src/domain/javascriptSemanticMemberMutations.ts — non-syntactic mutation channels remain untracked and will still read as stale literals, e.g. Object.assign(options, { mode: "updated" }), Reflect.set / deleteProperty, or mutate(options) where the callee writes through its parameter. The file header already scopes this to explicit property mutations; suggest a code comment enumerating the known-untracked channels (or a follow-up issue) so the next stale-literal report triages as "uncovered channel" rather than a regression.

@rudycelekli

Copy link
Copy Markdown
Author

Thanks for the review. Codex is assisting on behalf of @rudycelekli. Signed head 611f23f3b00948434a45d12556bad51f455986db documents the known-untracked channels in docs/javascript-application-workflows.md: Object.assign, Reflect.set/Reflect.deleteProperty, and writes through another function's parameter. Native controls confirm that these can retain an initializer-derived literal after the runtime value changes; the documentation identifies this as an uncovered channel rather than proof of the current value. The source behavior and original assertions are unchanged. Build and required checks pass; the updated hosted run is pending.

@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Rebased onto current main via merge (6b7412f), picking up the merged #764 empty-key migration, #769 builtin defaults, and #794 promise-ownership changes that touch the same semantic files. Auto-merged with no textual conflicts; verified the combined suite: member_mutations + empty_keys + graph builder + builtin defaults + promise ownership + reference import — 111/111 passed, plus npm run check 5/5 and check:fast. The path-prefix invalidation and empty-key handling coexist cleanly.

@morluto
morluto merged commit 6caa38a into morluto:main Oct 7, 2026
19 checks passed
@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Thanks, @rudycelekli, for your work on “fix(javascript): keep mutated object initializer values unknown.” I appreciate your contribution to REA.

darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…uto#752)

* fix(javascript): keep mutated object initializer values unknown

Signed-off-by: Rudy Celekli <[email protected]>

* fix(javascript): retain copied slots while following nested mutations

Signed-off-by: Rudy Celekli <[email protected]>

* fix(javascript): retain facts for unchanged object properties

Signed-off-by: Rudy Celekli <[email protected]>

* docs(javascript): state untracked mutation channels

Signed-off-by: Rudy Celekli <[email protected]>

---------

Signed-off-by: Rudy Celekli <[email protected]>
Co-authored-by: morluto <[email protected]>
@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions labels Oct 14, 2026
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.

3 participants