Skip to content

fix(javascript): resolve spread and constant kill-signal arguments - #2830

Closed
ahmed0magdy wants to merge 5 commits into
morluto:mainfrom
ahmed0magdy:contrib/child-process-call-facts
Closed

ahmed0magdy wants to merge 5 commits into
morluto:mainfrom
ahmed0magdy:contrib/child-process-call-facts

Conversation

@ahmed0magdy

@ahmed0magdy ahmed0magdy commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2571 and #2572. The original fixes from this PR landed on main in 04672f2 ("Reviewed fixes include … #2830 …"), and both issues are closed. After merging main back into the branch, this PR now carries only the fixes for the three review findings raised on it, in commit 05429ce.

Problem and expected behavior

killSignalName reported null (unknown) for two argument forms where Node's behavior is fully determined by the source:

  • child.kill(...[]): a spread of an empty array literal passes no runtime argument, so Node applies its SIGTERM default. Before, the first raw Babel argument was a SpreadElement, which produced null.
  • const signal = undefined; child.kill(signal): an immutable alias to undefined also gets the SIGTERM default. Before, signal was neither the global undefined spelling nor a literal, which produced null.

Change and scope

All changes are in src/domain/javascript/javascriptSemanticChildProcesses.ts:

  • firstRuntimeArgument: walks the call arguments and expands spreads of array literals, including nested ones, to find the first argument Node actually receives.
    • ...[] gives SIGTERM, ...["SIGINT"] gives SIGINT, and an array hole (...[,]) gives SIGTERM.
    • A spread of anything that isn't an array literal (a parameter, a const array variable) stays null.
  • immutableAliasValue: follows an identifier to its initializer only when the binding is not mutable, semanticStableInitializer gives a single unconditional initializer, and there is no destructuring projection. It follows alias chains with a cycle guard.
    • This is the same rule other producers already apply (for example javascriptSemanticPromises.ts). mutable is false only for const.
    • const s = undefined gives SIGTERM, and const a = "SIGKILL"; const b = a gives SIGKILL.
    • let, var, reassigned bindings, and an alias of a shadowed undefined all stay null.
  • The unused semanticResolutionBlocked import is removed. The merge had brought it back on this branch.

Contribution scope: an ordinary fix within existing boundaries, so a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/javascript/javascriptSemanticChildProcesses.ts (domain semantic IR construction)
  • Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable
  • CLI and MCP/tool-catalog contract: none (no schema or IR type change; signalName is string | null)
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: values only. Some formerly unknown signals are now resolved where the source fully determines them.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable (static analysis; nothing is executed)
  • Generated metadata, package, or installation impact: none

Expected effects:

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added: one test, "expands literal spreads and follows only immutable signal aliases", in the child-process signals block of src/domain/javascript/javascriptSemanticAnalysis.native_bindings.test.ts.
    • Positive cases: ...[], ...["SIGINT"], a const undefined alias, and a const string alias chain.
    • Negative cases, all null: a spread parameter, a spread const array variable, let, a reassigned let, and a shadowed undefined.
  • Base reproduction: the test fails on the merge commit's source (1 failed, 10 passed) and passes with the fix.
  • Remaining proof gaps: spreads of non-literal arrays and numeric signals (kill(9)) still report null. That is intentional: the source doesn't establish the value.

Validation performed

Run with Node 24.18.0 after npm ci:

  • Focused tests: 3 files, 26 tests passed.
  • npm run test:local -- on all JavaScript domain and application tests: 77 files, 1,851 tests passed.
  • npm run check:fast: passed.
  • The pre-commit and pre-push hooks: passed.
  • docs:check: not run, because no contract or generated metadata changed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: not applicable

AI assistance: written with Claude Code; the commits carry a Co-authored-by trailer.

@ahmed0magdy
ahmed0magdy force-pushed the contrib/child-process-call-facts branch from cb1a936 to 43c67f7 Compare October 13, 2026 14:10
@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions P2: medium Medium priority issue labels Oct 13, 2026
@morluto
morluto marked this pull request as ready for review October 13, 2026 14:58
@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:50:41.423933Z 4c51319 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: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues remain.

Summary

The PR extends killSignalName to read literal array spreads and follow immutable signal aliases.

  • Kill calls keep unknown signals separate from the SIGTERM default.

No new actionable issues or security concerns were found. The previous unused-import finding is fixed. The earlier duplicate-check thread was manually resolved without explanation; the current code uses isUnshadowedGlobal.

The merge-base checks differed, so this review used the full PR diff. Checking whether another PR supersedes this one was blocked by unavailable GitHub credentials.

Reviews (6) · Last reviewed commit: "fix(javascript): resolve literal spreads..." · 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: 43c67f75d2

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

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

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

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

The argument classifier inspected the raw AST node and missed transparent TS/Flow wrappers around undefined. It now unwraps through the expression owner before applying Node's SIGTERM default. Public at f8e5653; no tests ran.

@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

The kill-signal producer recognized omitted arguments and unshadowed undefined, but sent unary void expressions to the literal-string parser even though JavaScript evaluates every void expression to undefined. The producer now unwraps once, recognizes unary void, then uses the shared unshadowed-global check before literal fallback. Source regressions cover void 0 and void signal. Targeted formatting and git diff --check passed; tests were not run under the wave instructions. Published at 8006d9d.

@morluto
morluto force-pushed the contrib/child-process-call-facts branch from 8006d9d to be69cf6 Compare October 13, 2026 18:29

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

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

ahmed0magdy and others added 3 commits October 14, 2026 02:45
kill() substituted SIGTERM whenever the signal argument was not a
string literal, so a parameter or other unresolved value became a
definite SIGTERM fact. Only an omitted argument or the unshadowed
global undefined selects Node's SIGTERM default; any other unresolved
argument now leaves signalName null.

Fixes morluto#2572

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@morluto
morluto force-pushed the contrib/child-process-call-facts branch from be69cf6 to 4c51319 Compare October 13, 2026 18:45

@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: 4c513190fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

morluto 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.
ahmed0magdy and others added 2 commits October 14, 2026 06:05
…-call-facts

# Conflicts:
#	src/domain/javascript/javascriptSemanticAnalysis.native_bindings.test.ts
…gnals

Address review feedback on the kill() signal fact:

- Drop the semanticResolutionBlocked import, which isUnshadowedGlobal
  superseded.
- Expand spreads of array literals before selecting the signal, so
  kill(...[]) reports Node's SIGTERM default and kill(...["SIGINT"])
  reports SIGINT. A spread of anything else stays unknown.
- Follow const aliases whose only write is one unconditional initializer
  (the same !mutable + semanticStableInitializer rule other producers
  use), so `const signal = undefined; kill(signal)` reports SIGTERM.
  let, var, reassigned, and shadowed bindings stay unknown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@ahmed0magdy ahmed0magdy changed the title fix(javascript): read child-process options and kill signals as written fix(javascript): resolve spread and constant kill-signal arguments Oct 14, 2026
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: The one new test in this PR passes on Node 22, 24 and 26. The same test fails on the PR's base and on current main, so it catches the bug and the fix works. Thanks, ahmed0magdy, for the fix.

I tested head 05429ce. Its merge base is 7375ab6, and main was at 40f73f6 (#3735).

Results

I ran the PR's own native-bindings test file. It holds 11 tests. One is new, the spread and alias test.

Source under test Node Result
PR head 05429ce 22.23.1 11 passed
PR head 05429ce 24.18.0 11 passed
PR head 05429ce 26.11.1 11 passed
Merge base 7375ab6 (PR test file, base source) 24.18.0 1 failed, 10 passed
Main 40f73f6 (PR test file, main source) 24.18.0 1 failed, 10 passed
  • The failing test is the new one, on both the base and main. The test expects SIGTERM and SIGINT. It gets null, which means unknown. So main does not already have this fix.
  • The 10 older tests in the file pass in every run.
  • On the base run I swapped one source file in the head tree back to its base version. On the main run I built a full main tree and copied in the PR's test file. Both runs failed in the same way.

Not run

  • Any other test file, and the full suite.
  • Windows and macOS.
  • No review of the code beyond the test file.
Commands
git -C ~/code/rea-mirror/rea.git fetch origin
git -C ~/code/rea-mirror/rea.git archive 05429ce9c5054eae549dbe41058611d17a1907b0 | tar -x -C /tmp/fresh-1015/2830-head
npm ci && npm run build && npm run test:prepare   # Node 24.18.0, all exit 0
node scripts/run-development-tests.mjs focused \
  src/domain/javascript/javascriptSemanticAnalysis.native_bindings.test.ts
# new test: expands literal spreads and follows only immutable signal aliases
# head: exit 0 on Node 22, 24 and 26
# base source swapped in: exit 1 (1 failed, 10 passed)
# fresh main tree (40f73f62b) plus the PR test file: exit 1 (1 failed, 10 passed)
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head: 05429ce
  • Base: 7375ab6
  • Other: the box was shared with other test agents.

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

@morluto

morluto commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks for separating the follow-up. Main now handles omitted arguments, unshadowed undefined and void at the kill-signal owner; literal spreads and immutable aliases described here still appear distinct. Please keep the PR focused on those remaining cases and their unknown controls when updating it.

@morluto

morluto commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks for the analysis fixes. Closing as superseded by #10678, which carries the remaining literal-spread and const-alias handling forward against current main. The earlier changes from this branch are already on main.

@morluto morluto closed this Nov 18, 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 P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants