Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ba8498bf3
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aca5214e4f
ℹ️ 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".
|
Addressed the four new findings in a67cf2b:
Seven initial regressions fail on the previous implementation. Final validation: 1,164 JavaScript domain tests, six public CLI/MCP tests (including exact before/after configuration sources and retained resource-release links), four setup cleanup boundary tests, full check and docs check pass. The unchanged cross-spawn source still yields its child-process evidence. Main was merged to include upstream's setup cleanup CI repair (98d8470); new-head CI is running. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a67cf2bacd
ℹ️ 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".
|
@greptileai review |
[Medium impact] The changes affect several JavaScript analysis paths but stay within static analysis. Fix the bound-metadata target and missing getter receiver before merging. FindingsFix with agent prompt### Issue 1
src/domain/javascript/javascriptSemanticRequireOrigin.ts:3008-3011
Rebinding a saved bound function checks the original function's metadata instead of the function being rebound:
```javascript
const f = Reflect.set.bind(null, {});
Object.defineProperty(Reflect.set, 'name', {
get() { observe(module); return 'set'; }
});
const g = f.bind(null);
require('fs').readFileSync('kept');
```
Creating `g` reads `f.name`, an unchanged own data property. But `creation.path` still points to `Reflect.set`, so this check records a loader change and removes the real file read. Keep the actual bind target and its metadata read separate from the underlying callable's identity.
### Issue 2
src/domain/javascript/javascriptSemanticRequireOrigin.ts:1909-1913
Expanding an own getter into its raw body loses its `this` receiver:
```javascript
const box = {
owner: module,
get value() { observe(this.owner); return 0; }
};
Object.assign = custom;
Object.assign({}, typeof box.value);
require('fs').readFileSync('wrong');
```
The getter passes the wrapper to `observe`, which can replace its loader. This shortcut returns only the getter body. The later walk reaches `this.owner`, but `exposesModule` does not resolve `this` to `box`, so it can report the final call as native. Carry the getter's receiver through the shared call context, or keep the member read conservative when its body needs that receiver.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThis PR moves built-in identity checks to the reads and captures that select each value.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
Source[Parsed JavaScript] --> Facts[Bindings and recorded writes]
Facts --> Read[Select value at its read]
Read --> Capture[Keep captured identity]
Capture --> Invocation[Resolve call and receiver]
Invocation --> Effects[Report native effects]
Facts --> Invocation
Reviews (63) · Last reviewed commit: "fix(javascript): integrate main and pres..." · Reviewed by Greptile |
|
Addressed both new review findings in 54acace, after integrating current main. The mutation producer now retains each write's source node and records effects on cached Six added semantic regressions fail before this fix and pass afterward. All 1,202 JavaScript domain tests and six compiled public CLI/MCP acceptance tests pass, including graph-level assertions for early reads, saved methods and both late projection forms. Static/architecture checks and documentation checks pass. The shadowed-parameter assertion now follows the current explicit unknown-provenance contract. I also repeated the public CLI analysis of the unchanged published cross-spawn source: the complete Evidence remains identical to the pre-review result, including the child-process finding and the 267,549-byte JSON reply. Two fresh CLI runs per revision took roughly 1 second each; this is a correctness control, not a performance improvement claim. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54acace2cc
ℹ️ 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".
|
Addressed the three additional identity findings in 4ff3e45:
Validation: six new regressions failed before the fix; all 1,211 JavaScript domain tests across 52 files and all six public CLI/MCP tests now pass. The public test compares complete Evidence and pings the MCP server afterward, including direct calls, shared promises writes and reassigned-loader negatives. This remains source-local static analysis: computed loader arguments and caller-dependent runtime effects are not inferred. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ff3e459bf
ℹ️ 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".
|
Addressed the require-mode import and escaped-function findings in 659b676. Require-mode direct origins now publish to the same module-effect owner as literal requires, and namespace reads consume that shared state. Callable-value checks distinguish escaping a captured native function from escaping a containing object that can replace its method. Passing a saved function or named import to Six added regressions failed before this revision. All 1,219 JavaScript domain tests and six public CLI/MCP tests pass afterward, including a TypeScript import-equals/captured-function fixture compared as complete Evidence through both adapters, followed by MCP ping. Static/docs checks pass. The small release-preflight test compatibility fix selects only the runnable job under test instead of requiring steps on unrelated reusable-workflow jobs; the workflow used by the earlier CI merge reproduces that schema mismatch. |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 659b676618
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6729a870e6
ℹ️ 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 { root, members } = electronMemberPath( | ||
| javaScriptExpressionValue(current), | ||
| ); |
There was a problem hiding this comment.
Validate sequence captures at the selected intrinsic read
When an initializer overwrites an intrinsic before selecting it, as in const set=(Reflect.set=replace,Reflect.set), this normalization selects the final member but leaves capturedAt pointing at the entire sequence. Consequently, changedBefore compares the prefix assignment's completion against the sequence's earlier start and incorrectly classifies the captured replacement as native. With function replace(t){t.readFileSync=()=>{}} and fs=require('fs'), set(fs,'readFileSync',null,{}) replaces the filesystem method, but the native distinct-receiver path leaves fs unescaped and can report a subsequent call as a native read. Preserve the selected member's actual capture point, including preceding effects within the initializer.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5a8379d. Intrinsic aliases now use the selected expression's read position. The CommonJS regression suppresses the native read when the sequence overwrites Reflect.set first, and preserves it when the original setter was saved before the overwrite.
| ambientEffectAt( | ||
| ["global", "Object", "prototype", path[0]!], | ||
| node, |
There was a problem hiding this comment.
Check function-prototype setters before preserving a receiver
For function-valued CommonJS built-ins such as require('events'), an inherited setter can reside on Function.prototype, not just Object.prototype. With fs=require('fs'), defining Object.defineProperty(Function.prototype,'hook',{set(v){this.fs.readFileSync=v}}) and then calling Reflect.set(require('events'),'hook',()=>{},{fs}) invokes that setter and replaces the filesystem method on Node 24.15. Here builtinUnchanged remains true and this query finds no Object-prototype write, so the receiver escape is skipped and a subsequent fs.readFileSync can still be reported as native. Include the target's actual prototype-chain effects before proving that no inherited setter can run.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5a8379d. The distinct-receiver proof now checks Function.prototype setters for the function-valued events export. The regression installs an inherited setter and verifies that the later filesystem call loses native provenance.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0242d2b2c6
ℹ️ 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".
| interop.boundIntrinsic(node)?.kind === "known" | ||
| ) | ||
| return; |
There was a problem hiding this comment.
Validate generic bound targets before skipping their escapes
For a CommonJS input such as const fs=require('fs'); Reflect.set=t=>{t.readFileSync=()=>{}}; const set=Function.prototype.bind.call(Reflect.set,null,fs); set('readFileSync',null,{}); fs.readFileSync('wrong'), the bound call invokes the replacement, so the final call performs no filesystem read. The generic-bind path in resolveBoundIntrinsic checks the bound target's capture only when mayObserve is supplied, which this caller omits. Consequently, this new early return skips the conservative escape of fs, and the later invocation takes the native distinct-receiver path, allowing the replaced method to be reported as a native file read. Validate the target capture in the shared invocation owner before publishing or trusting the known bound-intrinsic proof.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 88a6823. Bound-call resolution now consults the intrinsic write history at capture time even when no additional observation callback is supplied. A parser-level test exercises generic and direct binding, an earlier saved callable and an already-bound callable. The affected static-analysis and public CLI/MCP suites passed (1,329 tests).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88a68238a7
ℹ️ 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".
| interop.boundIntrinsic(node)?.kind === "known" | ||
| ) | ||
| return; |
There was a problem hiding this comment.
Preserve captured inputs when bound callables escape
When a bound mutator is invoked through an object property or passed as a callback, this early return drops its captured inputs without ensuring that the eventual invocation can be normalized. For const fs=require('fs'); const set=Reflect.set.bind(null,fs,'readFileSync',()=>{}); const holder={set}; holder.set(); fs.readFileSync('wrong');, the invocation owner cannot resolve holder.set, and generic escape handling does not recover fs from the bound value. The replacement therefore goes unrecorded and the final call is reported as a native file read. Preserve bound-argument reachability in the callable/reference owner when the value leaves the directly resolvable invocation path.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in d0f483b. The member-mutation pass follows the receiver and arguments captured by a bound callable when the callable reaches a consumer. It selects stored property values at the later read and resolves captured inputs at bind time. Tests with plain objects cover a callback argument, an object method, a replaced method, a nested bind and reassignment of the captured variable. Merely creating the callable or reading its name leaves the input unescaped.
| if (captured !== undefined) | ||
| opaqueArguments ||= intrinsicReadChanged( | ||
| captured.capturedAt, | ||
| path, |
There was a problem hiding this comment.
Validate opaque rebinding of bound aliases before dispatch
When a mutable bound-function alias is reassigned by direct eval before use, resolveBoundIntrinsic still follows its source initializer without consulting opaqueCodeMayRebindBinding. For let set=Reflect.set.bind(null); eval('set=t=>{t.readFileSync=()=>{}}'); const fs=require('fs'); set(fs,'readFileSync',null,{}); fs.readFileSync('wrong');, it consequently publishes a known native invocation and treats {} as a distinct receiver, although the replacement actually changes fs.readFileSync. The captured Reflect.set itself is unchanged in this case; validate the alias read with the shared opaque-binding owner before trusting the bound-intrinsic proof.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in d0f483b. Bound intrinsic resolution now checks each mutable alias at its own read. A read after possible rebinding retains the possible intrinsic with unknown dispatch, while a copy made earlier keeps its captured target. The Object.keys regression classified all three calls as known on the previous head. It now yields known, opaque and known for the original read, the later read and the saved copy.
| const results = returned.references; | ||
| if (results.length === 0) return true; |
There was a problem hiding this comment.
Distinguish proven no-value returns from unresolved results
For a fully resolved local function that falls through or executes return;, an empty returned-reference set can correspond to a proven undefined result. In function n(){} Object.assign=(t,v)=>{if(v)v.require=replacement}; Object.assign({},n()); require('fs').readFileSync('kept');, this condition instead treats the result as possible module exposure and records a delegate write, suppressing the native read even though the replacement receives only undefined. Use the callable return/coverage facts to distinguish proven no-value returns from unresolved results, while retaining argument-evaluation effects separately.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in d0f483b. An empty reference set now needs a complete set of ordinary local call targets, each with only bare returns or fallthrough, before it can prove an undefined result. The analysis still visits call arguments. A node:path loader test failed on the previous head for fallthrough, a bare return and a nested function with its own return. All five cases pass now, including the controls for a module argument and a possibly unknown return.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0f483b68b
ℹ️ 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".
| for (const storedPath of boundStorePaths.get(binding)?.values() ?? | ||
| []) { |
There was a problem hiding this comment.
Revisit bound-callable escapes when later stores are discovered
For const fs=require('fs'),h={}; function use(){h.set()} h.set=Reflect.set.bind(null,fs,'readFileSync',()=>{}); use(); fs.readFileSync('wrong'), traversal visits use's body before the store populates boundStorePaths. Fresh evidence beyond the fixed direct property call is that this earlier-declared consumer is never replayed after the store is collected. Bind creation now skips escaping captured inputs, so neither that call nor this lookup retains the reachable fs mutation, allowing the final replaced method to be reported as native. Collect stored-callable facts before processing consumers, or replay dependent escapes when those facts grow.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5a8379d. Bound-callee inputs are resolved after member stores have been indexed, so an earlier-declared function sees the callable stored before its invocation. A paired case binds a separate object and preserves the filesystem read.
| return ( | ||
| invocation?.kind === "known" && | ||
| invocation.path.join(".") === "intrinsic.Object.create" |
There was a problem hiding this comment.
Check opaque global changes before proving Object.create fresh
In CommonJS, eval('Object.create=()=>module'); Reflect.set(module,'require',replacement,Object.create(null)) supplies module as the receiver and replaces its loader. Fresh evidence beyond the repaired receiver-binding cases is that the intrinsic slot itself changes through opaque code: intrinsicReadChanged consults explicit intrinsic writes but not the opaque-global effect facts, so this new branch still proves the call fresh. isSeparateReceiver consequently skips delegate invalidation, allowing a subsequent require('fs').readFileSync('wrong') to be classified as native despite using the replacement loader. Validate the intrinsic at its capture through the shared opaque-global read owner before accepting this allocation proof.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5a8379d. Object.create freshness now checks opaque global effects at each intrinsic capture. The CommonJS regressions distinguish an eval replacement before the capture from a native factory saved before eval.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73857c0708
ℹ️ 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".
| invocation?.kind === "opaque" && | ||
| interop.boundIntrinsic(node.callee) !== undefined |
There was a problem hiding this comment.
Preserve bound captures through unresolved callee aliases
Fresh evidence beyond the repaired stored-property path is const fs=require('fs'); const box={set:Reflect.set.bind(null,fs,'readFileSync',()=>{})}; const {set}=box; set(); fs.readFileSync('wrong');. The destructured binding has a nonempty initializer projection, so resolveBoundIntrinsic returns undefined; neither native dispatch nor this new opaque-only fallback preserves its captured fs. Because bind creation now skips escapes, the replacement goes unrecorded and the final call is reported as a native file read. Preserve bound captures when a projected or branch-valued callee cannot be normalized.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 07d88e7. Invocation now follows selected bound functions through destructuring and conditional aliases and records their inputs at bind time. The regression retains the native read before set() and suppresses the one after it. Capture-time reassignment and independent-object controls also pass; the full related selection passes 7,282 tests across 204 files, together with the build and check:ci.
| ...javaScriptScalarEvaluationSources(value).map((node) => ({ | ||
| node, | ||
| path: [], | ||
| readAt, |
There was a problem hiding this comment.
Separate scalar evaluation effects from result exposure
For a CommonJS source such as Object.assign=(t,v)=>{if(typeof v==='object')v.require=replacement}; Object.assign({},typeof ({owner:module}).owner); require('fs').readFileSync('kept');, the replacement receives only the string "object", and the literal's own data-property read cannot invoke user code. This mapping nevertheless queues the intermediate member value as ordinary module exposure, reaches module, and indexes a nonexistent delegate write, suppressing the native read. Carry an evaluation-only distinction from the scalar-source owner instead of treating intermediate references as values passed to the opaque mutator.
AGENTS.md reference: AGENTS.md:L29-L31
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 07d88e7. Scalar evaluation follows effects in the receiver, computed key, and known getter or local call body while discarding the intermediate property value. A sequential regression passes typeof box.owner and then box.owner to the same replacement and retains only the read between those calls. Controls retain actual getter, call and coercion effects. All 7,282 related tests across 204 files, the build and check:ci pass.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07d88e7fea
ℹ️ 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".
| if ( | ||
| !t.isNewExpression(node) && | ||
| interop.boundIntrinsic(node)?.kind === "known" | ||
| ) | ||
| return; |
There was a problem hiding this comment.
Preserve bound captures when the callable is used as a template tag
For const fs=require('fs'); const set=Reflect.set.bind(null,fs,'readFileSync',()=>{},fs); set``; fs.readFileSync('wrong'), Node 24.15 replaces the filesystem method. This return removes the bind-time escape, but fresh evidence beyond the repaired ordinary-call aliases is that the tagged-template handler still consumes only returnedReferences(node.tag).references, not the new calleeCallResults. A simple identifier tag also supplies no receiver to markReceiver, so neither a mutation nor an escape reaches the captured fs, allowing the replaced method to be reported as native. Preserve bound-input reachability through the shared callable owner for template-tag consumers too.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5a8379d. Template tags now use the same bound-callee input lookup as unresolved calls and constructions. Invoking a tag bound to the filesystem receiver suppresses the later native read; a projected tag bound to a separate object preserves it.
| const property = object.properties[index]!; | ||
| // Object spread creates data properties, so it cannot turn an earlier | ||
| // own data property into an accessor. | ||
| if (t.isSpreadElement(property)) continue; |
There was a problem hiding this comment.
Honor spread overwrites before selecting a getter body
When typeof box.owner is passed to an overwritten mutator and box is {get owner(){observe(module);return 0}, ...{owner:0}}, the later spread definitely shadows the getter, so its body cannot run. Skipping the spread nevertheless selects that obsolete getter through acceptsGetter; scalarEvaluationBodies then treats observe(module) as executed module exposure, indexes a nonexistent delegate write, and suppresses a subsequent native filesystem read. Reuse the existing descriptor-selection owner's spread-overwrite facts before accepting a getter body.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5a8379d. Own-property selection now checks which enumerable keys a spread definitely copies, including nested literals and stable aliases at the time of the spread. The overwritten getter is skipped. A later getter, an unknown spread, and deletion of the source key retain the possible getter effect.
| if ( | ||
| typeof first === "string" && | ||
| ["id", "filename", "loaded"].includes(first) && | ||
| !ambientPathMayHaveChanged(state, ["commonjs-module", first]) |
There was a problem hiding this comment.
Check wrapper metadata writes at the selected read
In CommonJS, Object.assign=(t,v)=>{if(typeof v==='object')v.require=()=>({})}; Object.assign({},module.id); require('fs').readFileSync('kept'); module.id=module passes the original string to the replacement and leaves the loader unchanged before the filesystem read. However, ambientPathMayHaveChanged explicitly ignores timing, so the later module.id assignment defeats this scalar proof; the walk records the earlier mutator call as module exposure and drops kept. Query the ambient-effect owner at readAt, preserving earlier captures, rather than using completed-source coverage.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5a8379d. Wrapper metadata is checked against ambient writes at the selected read, and its proof stays specific to that read. The regressions preserve an earlier module.id string and recognize the object exposed by a later read after reassignment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed90f0db93
ℹ️ 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".
| for (const { callee, at, invocation } of callableReads) { | ||
| const returned = returnedReferences(callee, invocation); | ||
| for (const candidate of returned.calleeCallResults ?? []) | ||
| if (interop.boundIntrinsic(candidate)?.kind === "known") | ||
| markEscaped(candidate, at, [], candidate); |
There was a problem hiding this comment.
Revisit callback argument escapes after indexing bound stores
Fresh evidence beyond the repaired direct-property invocation is this CommonJS callback consumer: const fs=require('fs'),h={};function use(){[0].forEach(h.set)}h.set=Object.defineProperty.bind(null,fs,'readFileSync',{value:()=>{}});use();fs.readFileSync('wrong');. Visiting use escapes h.set before its store is indexed, but this replay examines only callees, not previously escaped arguments. Since bind creation now skips captured-input escapes, the callback's captured fs never reaches the mutation index, allowing the replaced method to remain classified as native. Resolve store facts before processing escape consumers, or replay their dependent inputs too.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5919c17. Callback arguments are now revisited after the member stores are indexed. The regression follows the stored bound callback from an earlier-declared function, and the timing controls distinguish overwrites before and after the callback reads the slot.
| assignedSources?.some( | ||
| (source) => interop.boundIntrinsic(source.node) !== undefined, | ||
| ) |
There was a problem hiding this comment.
Index bound sources selected through conditional stores
Fresh evidence beyond the repaired projected callees is a straight-line stored callback: const fs=require('fs'),h={};h.set=true?Object.defineProperty.bind(null,fs,'readFileSync',{value:()=>{}}):()=>{};[0].forEach(h.set);fs.readFileSync('wrong');. boundIntrinsic cannot normalize a conditional expression, so this condition omits the slot from boundStorePaths; escaping h.set consequently loses its captured fs, even though all stores precede the consumer. Projected RHS aliases have the same problem. Register possible bound sources through the shared reference-selection owner rather than requiring the entire stored expression to normalize as one intrinsic.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5919c17. Both store registration and consumption now follow the selected callable through the shared reference resolver. The tests cover a conditional RHS and a projected alias. Runtime controls also verify that selecting a sibling or changing the original slot after copying it leaves the saved callback unchanged.
| t.isBinaryExpression(node) && | ||
| !["in", "instanceof"].includes(node.operator) | ||
| ) { |
There was a problem hiding this comment.
Separate boolean membership results from module exposure
For CommonJS input Object.assign=(t,k)=>{t[k]=1};Object.assign({},'id' in module);require('fs').readFileSync('kept');, the replacement receives only a boolean, and checking the unmodified wrapper object invokes no user hook. Excluding in from scalar-result handling instead makes exposesModule walk module as an exposed argument, recording a nonexistent delegate write and suppressing the native read. Fresh evidence beyond the repaired typeof cases is this boolean membership result; module instanceof Object exhibits the same loss. Keep the boolean result separate from any operand or hook evaluation effects.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5919c17. The exposure walk now treats a primitive-key membership check on the original CommonJS wrapper, and the wrapper's ordinary instanceof Object check, as boolean results. Replaced constructors, custom hasInstance, key coercion, and proxy traps retain their effects in the regressions.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5919c173cb
ℹ️ 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".
| changedBefore(capture, path) || | ||
| (inherited !== undefined && changedBefore(capture, inherited)) |
There was a problem hiding this comment.
Check opaque global effects before trusting native dispatch
For CommonJS input eval("Reflect.set=t=>{t.readFileSync=()=>{}}");const fs=require('fs');Reflect.set(fs,'readFileSync',null,{});fs.readFileSync('wrong'), ordinary dispatch reaches this query without mayObserve, so the eval-installed replacement is still classified as native. The new distinct-receiver shortcut consequently leaves fs unescaped and can report wrong as a native filesystem read, although the replacement overwrites that method. Fresh evidence beyond the repaired Object.create freshness case is this ordinary-dispatch consumer, which still omits the shared opaque-global check. Consult opaqueCodeMayChangeGlobalRead at the intrinsic's capture before publishing a native proof, preserving functions saved before the opaque effect.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 83b5844. Intrinsic dispatch now checks opaque writes at the point where the method was captured. The CommonJS regression distinguishes saving Reflect.set before eval from saving the Reflect namespace and selecting its method afterward.
| ) => readonly t.Node[] | undefined, | ||
| ): readonly t.Node[] => { | ||
| const sources: t.Node[] = []; | ||
| const pending = [...childNodes(expression)]; |
There was a problem hiding this comment.
Separate delete evaluation from property-value exposure
For CommonJS input const box={owner:module};Object.assign=(t,v)=>{if(v&&typeof v==='object')v.require=()=>({})};Object.assign({},delete box.owner);require('fs').readFileSync('kept'), the replacement receives only a boolean; deleting this ordinary object's property never reads its value. Seeding the walk with the delete operand nevertheless allows the member-selection fallback to reach the original owner:module, recording a nonexistent delegate replacement and suppressing kept. Distinguish delete's receiver/key evaluation from a property-value read using the existing execution facts rather than traversing its operand as an ordinary selected value.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 83b5844. Delete now evaluates the receiver and computed key without reading the final property. The tests retain effects from an intermediate getter, key coercion, a proxy delete trap, and a getter actually evaluated by a comma expression.
| ].map((node) => ({ | ||
| node, | ||
| path: [], |
There was a problem hiding this comment.
Preserve property selections when expanding bound callables
When an untouched bound function is used only for its metadata, as in const f=Reflect.set.bind(null,module,'require',()=>{});Object.assign=(t,k)=>{t[k]=1};Object.assign({},f.name);require('fs').readFileSync('kept'), the replacement receives a string and cannot reach module. This branch ignores the pending ['name'] selection and expands the bound arguments with an empty path, inventing module exposure and suppressing the native read; f.length has the same regression. Resolve the selected bound-function property before expanding captured inputs, so consuming an untouched scalar slot does not expose the callable's captures.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 83b5844. Known bound functions now resolve an untouched name or length before expanding their captured arguments. Replaced data slots and getters remain observable, and a name saved before redefinition retains its original scalar value.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83b584439f
ℹ️ 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".
| "writeFileSync", | ||
| "close", | ||
| "closeSync", | ||
| ...FS_RECEIVER_METHODS.flatMap((method) => [method, `${method}Sync`]), |
There was a problem hiding this comment.
Check mutable delegates before exempting native fs receivers
For CommonJS inputs that replace another fs export, the newly admitted wrappers are not necessarily non-escaping. For example, const fs=require('fs'); fs.writeFileSync=function(){this.readFileSync=()=>{}}; fs.appendFileSync('ignored','x'); fs.readFileSync('wrong') invokes the replacement through native appendFileSync with this === fs, so the last call is not a filesystem read. This expanded whitelist causes originalBuiltinReceiver to discard the receiver escape while checking only writes to appendFileSync itself, allowing the final call to be reported as native. Separate own-data-slot knowledge from non-escaping-call proofs, and check mutable delegates before granting the latter.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0505b10. Native fs wrappers now record the possible effects of a replaced shared delegate at invocation, even when the wrapper was saved earlier or imported by name. The check includes the writeFileSync delegate used by appendFileSync and the readSync helper used by buffered readFileSync. Node controls verify that the replacement receives the fs exports as this. The buffered read is retained before its own delegate can change the next read.
| return true; | ||
| // Even a call that falls through evaluates its arguments. | ||
| pending.push( | ||
| ...value.arguments.map((node) => ({ node, path: [], readAt })), |
There was a problem hiding this comment.
Separate local-call argument effects from result exposure
When a fully resolved local call receives module but returns a primitive, this enqueue treats the argument as though it reached the overwritten mutator. For example, with function scalar(v){return 1}, the sequence Object.assign=(t,v)=>{if(typeof v==='object')v.require=replacement}; Object.assign({},scalar(module)); require('fs').readFileSync('kept') leaves the wrapper loader untouched, yet this walk reaches module, indexes a delegate write, and suppresses the native read. Fresh evidence beyond the repaired no-value-return case is the explicit primitive return: the unconditional argument queue, rather than empty-return handling, introduces this exposure. Consume local-call evaluation facts without forwarding nonescaping arguments as result values.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0505b10. The local-call result walk now evaluates the inputs of a proven inert synchronous function separately from its returned references. Passing module to a function that ignores it preserves the loader. Argument accessors and coercions, a call that modifies its parameter, and a function that returns the wrapper remain observable. The same correction covers an ignored argument on an empty return.
| ["name", "length"].some((key) => | ||
| bindMetadataMayInvokeGetter( | ||
| ["global", ...creation.path.slice(1), key], | ||
| node, |
There was a problem hiding this comment.
Rebinding checks the wrong function
Rebinding a saved bound function checks the original function's metadata instead of the function being rebound:
const f = Reflect.set.bind(null, {});
Object.defineProperty(Reflect.set, 'name', {
get() { observe(module); return 'set'; }
});
const g = f.bind(null);
require('fs').readFileSync('kept');Creating g reads f.name, an unchanged own data property. But creation.path still points to Reflect.set, so this check records a loader change and removes the real file read. Keep the actual bind target and its metadata read separate from the underlying callable's identity.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptSemanticRequireOrigin.ts
Line: 3008-3011
Comment:
**Rebinding checks the wrong function**
Rebinding a saved bound function checks the original function's metadata instead of the function being rebound:
```javascript
const f = Reflect.set.bind(null, {});
Object.defineProperty(Reflect.set, 'name', {
get() { observe(module); return 'set'; }
});
const g = f.bind(null);
require('fs').readFileSync('kept');
```
Creating `g` reads `f.name`, an unchanged own data property. But `creation.path` still points to `Reflect.set`, so this check records a loader change and removes the real file read. Keep the actual bind target and its metadata read separate from the underlying callable's identity.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const known = ownPropertyAt(root, key, node, (method) => { | ||
| bodies.push(method.body); | ||
| return true; | ||
| }); | ||
| return known ? bodies : undefined; |
There was a problem hiding this comment.
Getter expansion loses its receiver
Expanding an own getter into its raw body loses its this receiver:
const box = {
owner: module,
get value() { observe(this.owner); return 0; }
};
Object.assign = custom;
Object.assign({}, typeof box.value);
require('fs').readFileSync('wrong');The getter passes the wrapper to observe, which can replace its loader. This shortcut returns only the getter body. The later walk reaches this.owner, but exposesModule does not resolve this to box, so it can report the final call as native. Carry the getter's receiver through the shared call context, or keep the member read conservative when its body needs that receiver.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptSemanticRequireOrigin.ts
Line: 1909-1913
Comment:
**Getter expansion loses its receiver**
Expanding an own getter into its raw body loses its `this` receiver:
```javascript
const box = {
owner: module,
get value() { observe(this.owner); return 0; }
};
Object.assign = custom;
Object.assign({}, typeof box.value);
require('fs').readFileSync('wrong');
```
The getter passes the wrapper to `observe`, which can replace its loader. This shortcut returns only the getter body. The later walk reaches `this.owner`, but `exposesModule` does not resolve `this` to `box`, so it can report the final call as native. Carry the getter's receiver through the shared call context, or keep the member read conservative when its body needs that receiver.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0505b10c7c
ℹ️ 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".
| recordSemanticFsDelegateCalls(state, callableReads, (site, authority) => | ||
| recordRequiredEffect("fs", [null], "write", site, authority), | ||
| ); |
There was a problem hiding this comment.
Re-run descriptor proofs after adding fs delegate effects
In a CommonJS file with fs=require('fs') and cp=require('child_process'), set fs.writeFileSync=function(){Object.defineProperty(this,'statSync',{set(v){this.cp.spawn=v}})} and then execute fs.appendFileSync('x','x');Reflect.set(fs,'statSync',()=>({}),{cp});cp.spawn('wrong'). Node 24.15 invokes the installed setter and replaces cp.spawn, but reflectSets has already converged before this fs-wide write is recorded. Its earlier own-data proof therefore skips escaping {cp}, leaving the final call eligible for a native spawn effect. Publish these delegate effects inside the mutation fixed point, or replay dependent descriptor proofs when they grow.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| for (const write of writes) | ||
| if ( | ||
| delegates.some((key) => affectsBuiltinPath(write.path, [key])) && |
There was a problem hiding this comment.
Exclude proven UTF-8 fast paths from fs delegate effects
With an existing pathname and explicit 'utf8' or 'utf-8' encoding, native fs.readFileSync takes binding.readFileUtf8 without invoking the shared exports delegates, as checked on Node 24.15. After fs.readSync=function(){this.readFileSync=()=>{}}, both fs.readFileSync('a','utf8') and fs.readFileSync('b','utf8') still invoke the original reader when those files exist. This method-name-only match nevertheless records an fs-wide write after the first call and suppresses the second definite read. Use the parsed invocation arguments to omit delegate effects when the native fast path is proven, while retaining uncertainty for buffer, descriptor, or unknown-encoding paths.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
|
Thank you for this fix! The changes from this PR were reviewed and landed on |
Summary
Preserve Node built-in effects at their actual reads and captures after initial CommonJS support landed on main. Earlier native reads survive later reassignment; replacing the loader, a built-in method or a shared object prevents subsequent calls from being reported as native effects.
Change and scope
Share binding, alias, capture and effect-order analysis across loader provenance, saved methods and Object/Reflect intrinsics. Preserve separate receivers and captured object identities; read descriptor fields when their definition is invoked.
Check a bound intrinsic against the writes recorded before its target was captured, including calls through
Function.prototype.bind. A saved native callable retains its identity after a later replacement. A target first read after replacement has uncertain identity.Track the receiver and arguments of a bound function through callback and stored-property escapes after authored stores are indexed, including conditional and projected selections. A mutable alias is checked at its read, and an earlier saved function keeps its captured identity. An ordinary local call that can only return undefined still evaluates its arguments.
Track computed-key evaluation and coercion independently of scalar results, including nested/optional members, updates and compound assignments under typeof. Opaque changes invalidate ordinary property selections and Reflect own-data/null-prototype proofs at the relevant read.
Follow module exposure through descriptors, copied values, bound inputs, callable returns, await and yield. Keep inherited descriptor/then checks tied to each consumer. Rejected or skipped replacements cannot establish fresh allocation identity.
Account for inherited descriptor values when their origin is uncertain. Reuse receiver proofs while the recorded mutations are unchanged and refresh them after a new mutation.
Select overlapping writes and escapes through a property-path index before applying the existing timing checks. Exact keys avoid rescanning unrelated writes; ancestor, descendant, wildcard and copied-property paths remain conservative.
Integrate main's current accessor, invocation-context, repeated-activation and cache owners. Preserve filesystem and synchronous child-process receiver links, TLS/net method distinctions and conservative argv selections.
Follow bound functions selected through aliases, stored properties and template tags after their stores are indexed. Distinguish scalar evaluation from exposing the selected value, including ordinary wrapper membership checks whose prototype hook lookup remains unchanged at the comparison, honoring getter overrides by literal and stable-alias spreads only when the source key survives until it is copied. Keep intrinsic captures and wrapper metadata tied to their actual reads, including opaque global changes and function-prototype setters.
Owner: JavaScript domain provenance and mutation analysis. No CLI/MCP schema, Evidence identity, dependency or authority change. Analyzed JavaScript is parsed, not executed.
Validation performed
0505b10c7, including main55c4f5633: 7,397 tests in 207 related files pass on Linux with Node 24.22.1. The selection covers the JavaScript domain, affected Playwright suites, public JavaScript and Electron CLI/stdio MCP tests, and verifier command coverage. The build, typecheck, lint, architecture guards, test discovery and 184 Python tests pass.name/lengthgetters, nativefsdelegation through a replaced export, and ignored arguments to source-proven inert local functions. Computed keys, proxies, effectful arguments and returned wrapper references retain their effects.readFileSynccalling mutablereadSync. The original buffered read remains visible before that delegate can change the next read.check:cipassed its fast stage and stopped at five Knip findings also present on clean main. Separate full-tree typed lint reported the same three switch-exhaustiveness findings reproduced on clean main; their source files are unchanged by this PR. Hosted CI checks the current merge.Author readiness
Human owner: @cyanseek