[PR #3794] [CLOSED] fix(javascript): resolve timer handles at cancellation reads #5904

Closed
opened 2026-10-31 01:10:19 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3794
Author: @Xinglan233
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: fix/timer-handle-writes-3358


📝 Commits (1)

  • 8bbb638 fix(javascript): resolve timer handles at cancellation reads

📊 Changes

6 files changed (+344 additions, -24 deletions)

View changed files

📝 docs/javascript-application-workflows.md (+6 -0)
➕ src/domain/javascript/javascriptSemanticAnalysis.timer_handles.test.ts (+130 -0)
📝 src/domain/javascript/javascriptSemanticAsyncEffects.ts (+65 -19)
📝 src/domain/javascript/javascriptSemanticDataEffectHelpers.ts (+4 -3)
📝 src/domain/javascript/javascriptSemanticMutationInitializers.ts (+25 -2)
➕ tests/acceptance/applications/javascriptTimerHandlesCli.test.ts (+114 -0)

📄 Description

Summary

Prepared with assistance from Codex. Fixes #3358.

An overwritten timer handle no longer produces a resolved cancellation link to its old timer. Unchanged handles still resolve, and a later direct timer assignment can replace the earlier target.

Problem and expected behavior

In this fixture, line 4 receives null, so it must not resolve to the timer on line 2. The unchanged control on lines 5–6 should keep its resolved link.

function work() {}
let handle = setTimeout(work, 100);
handle = null;
clearTimeout(handle);
const stable = setTimeout(work, 100);
clearTimeout(stable);

The old matcher pairs schedules and cancellations by lexical binding ID. A unique binding match does not establish the binding's value at the cancellation.

Change and scope

Select the handle's existing initializers at the cancellation read. Resolve only one preceding, unconditional, unprojected schedule in the same callable. Reuse the existing statement-order and transparent result-source helpers, including TypeScript wrappers and await. Uncertain writes or activation order retain candidates or timer unknowns.

This corrects the existing static-analysis workflow. A separate maintainer decision for a new capability is not applicable. General interprocedural value tracking remains outside this change.

Contract and boundary impact

  • Semantic owner and earliest changed stage: JavaScript domain timer-handle resolution.
  • Contribution scope fit and linked maintainer decision: ordinary correctness fix within existing static analysis; not applicable.
  • CLI and MCP/tool-catalog contract: arguments and schemas unchanged; cancellation relations and uncertainty corrected.
  • Provider, bridge, target-format, or platform compatibility: JavaScript/TypeScript source analysis; no provider change.
  • Evidence, artifact, provenance, or reconstruction contract: preserve source identity and ranges. New analyses can have different graph commitments; retained Evidence remains unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: target source remains inert. Tests close owned MCP sessions and clean temporary fixtures.
  • Generated metadata, package, or installation impact: no tracked metadata or package changes; generated outputs remain ignored.

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.

These effects describe the target workflow. Verification launches owned local CLI/MCP processes without executing the target fixture.

Evidence and regression coverage

  • Tests added or updated: 25 domain cases and two real CLI/MCP scenarios. Coverage includes replacement timers, writes before/after cancellation, future schedules, callable ownership, conditional writes, loops, shadowing, projections, updates, compound assignments, declarator order, TypeScript wrappers and awaited handles.

  • Base reproduction: the latest checked main, d69acc3455c33f90a2fc4381db43d38b6af50622, still fails 17 of the 25 new domain cases; eight controls pass. The public CLI and actual stdio MCP reproduce the six-line fixture with identical complete Evidence.

  • User-visible CLI/MCP output: base has 4 -> 2 resolved, 6 -> 5 resolved, and zero timer unknowns. The candidate retains only 6 -> 5 resolved and adds a timer unknown at line 4. The second scenario checks replacement targets and a cross-callable candidate plus unknown.

  • Remaining proof gaps: unsupported expression order, loops and interprocedural activation remain conservative. Static identity does not establish execution.

  • 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

Validated on Linux x64 with Node 24.18.0, npm 11.16.0 and locked dependencies, after rebasing onto d69acc345.

  • npm run build:cached on the latest base — passed; the candidate runtime build also passed.
  • node node_modules/vitest/vitest.mjs run --project domain src/domain/javascript --maxWorkers=2 — 70 files, 1,709 tests passed.
  • npm run test:focused -- src/domain/javascript/javascriptSemanticAnalysis.timer_handles.test.ts src/application/javascript/JavaScriptSemanticGraphResources.test.ts tests/acceptance/applications/javascriptTimerHandlesCli.test.ts tests/acceptance/applications/javascriptBuiltinDefaultsCli.test.ts — four files, 45 tests passed, including actual CLI/MCP workflows.
  • npm run check — passed; lint reported 0 errors and 1,428 warnings.
  • npm run docs:check — passed, including five README consistency tests.
  • npm run verify:test-discovery — all 1,302 test files discovered exactly once.
  • Independent base/candidate public probes — CLI/MCP Evidence parity, MCP ping and owned transport close passed.
  • git diff --check — passed; final diff reviewed for credentials and unrelated changes.

Earlier verification included an existing Electron stress-test timeout while competing with compilation; isolated and complete reruns passed without increasing its timeout. Original fixtures, complete CLI/MCP Evidence and failed-attempt logs were preserved.

Compatibility, safety, and release

  • Breaking changes or migration steps: no schema migration. Reanalyze sources to obtain corrected semantic Evidence.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux Node CLI/MCP only. No native provider is required for this workflow; no Windows, macOS or live-browser qualification is claimed.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: self-owned fixtures are analyzed as text. Public regression fixtures throw if executed. No target execution, injection or mutation capability is added.
  • Full repository CI, test and coverage suites were not run locally.

Author readiness

Human owner: @Xinglan233

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

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3794 **Author:** [@Xinglan233](https://github.com/Xinglan233) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/timer-handle-writes-3358` --- ### 📝 Commits (1) - [`8bbb638`](https://github.com/morluto/rea/commit/8bbb638ba00110c8647d8d0ba854ddc69879617b) fix(javascript): resolve timer handles at cancellation reads ### 📊 Changes **6 files changed** (+344 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `docs/javascript-application-workflows.md` (+6 -0) ➕ `src/domain/javascript/javascriptSemanticAnalysis.timer_handles.test.ts` (+130 -0) 📝 `src/domain/javascript/javascriptSemanticAsyncEffects.ts` (+65 -19) 📝 `src/domain/javascript/javascriptSemanticDataEffectHelpers.ts` (+4 -3) 📝 `src/domain/javascript/javascriptSemanticMutationInitializers.ts` (+25 -2) ➕ `tests/acceptance/applications/javascriptTimerHandlesCli.test.ts` (+114 -0) </details> ### 📄 Description ## Summary Prepared with assistance from Codex. Fixes #3358. An overwritten timer handle no longer produces a resolved cancellation link to its old timer. Unchanged handles still resolve, and a later direct timer assignment can replace the earlier target. ## Problem and expected behavior In this fixture, line 4 receives `null`, so it must not resolve to the timer on line 2. The unchanged control on lines 5–6 should keep its resolved link. ```js function work() {} let handle = setTimeout(work, 100); handle = null; clearTimeout(handle); const stable = setTimeout(work, 100); clearTimeout(stable); ``` The old matcher pairs schedules and cancellations by lexical binding ID. A unique binding match does not establish the binding's value at the cancellation. ## Change and scope Select the handle's existing initializers at the cancellation read. Resolve only one preceding, unconditional, unprojected schedule in the same callable. Reuse the existing statement-order and transparent result-source helpers, including TypeScript wrappers and `await`. Uncertain writes or activation order retain candidates or timer unknowns. This corrects the existing static-analysis workflow. A separate maintainer decision for a new capability is not applicable. General interprocedural value tracking remains outside this change. ## Contract and boundary impact - Semantic owner and earliest changed stage: JavaScript domain timer-handle resolution. - Contribution scope fit and linked maintainer decision: ordinary correctness fix within existing static analysis; not applicable. - CLI and MCP/tool-catalog contract: arguments and schemas unchanged; cancellation relations and uncertainty corrected. - Provider, bridge, target-format, or platform compatibility: JavaScript/TypeScript source analysis; no provider change. - Evidence, artifact, provenance, or reconstruction contract: preserve source identity and ranges. New analyses can have different graph commitments; retained Evidence remains unchanged. - Target selection, authority, upstream behavior, and cleanup details: target source remains inert. Tests close owned MCP sessions and clean temporary fixtures. - Generated metadata, package, or installation impact: no tracked metadata or package changes; generated outputs remain ignored. Expected effects: - [x] 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. These effects describe the target workflow. Verification launches owned local CLI/MCP processes without executing the target fixture. ## Evidence and regression coverage - Tests added or updated: 25 domain cases and two real CLI/MCP scenarios. Coverage includes replacement timers, writes before/after cancellation, future schedules, callable ownership, conditional writes, loops, shadowing, projections, updates, compound assignments, declarator order, TypeScript wrappers and awaited handles. - Base reproduction: the latest checked main, `d69acc3455c33f90a2fc4381db43d38b6af50622`, still fails 17 of the 25 new domain cases; eight controls pass. The public CLI and actual stdio MCP reproduce the six-line fixture with identical complete Evidence. - User-visible CLI/MCP output: base has `4 -> 2 resolved`, `6 -> 5 resolved`, and zero timer unknowns. The candidate retains only `6 -> 5 resolved` and adds a timer unknown at line 4. The second scenario checks replacement targets and a cross-callable candidate plus unknown. - Remaining proof gaps: unsupported expression order, loops and interprocedural activation remain conservative. Static identity does not establish execution. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed Validated on Linux x64 with Node 24.18.0, npm 11.16.0 and locked dependencies, after rebasing onto `d69acc345`. - `npm run build:cached` on the latest base — passed; the candidate runtime build also passed. - `node node_modules/vitest/vitest.mjs run --project domain src/domain/javascript --maxWorkers=2` — 70 files, 1,709 tests passed. - `npm run test:focused -- src/domain/javascript/javascriptSemanticAnalysis.timer_handles.test.ts src/application/javascript/JavaScriptSemanticGraphResources.test.ts tests/acceptance/applications/javascriptTimerHandlesCli.test.ts tests/acceptance/applications/javascriptBuiltinDefaultsCli.test.ts` — four files, 45 tests passed, including actual CLI/MCP workflows. - `npm run check` — passed; lint reported 0 errors and 1,428 warnings. - `npm run docs:check` — passed, including five README consistency tests. - `npm run verify:test-discovery` — all 1,302 test files discovered exactly once. - Independent base/candidate public probes — CLI/MCP Evidence parity, MCP ping and owned transport close passed. - `git diff --check` — passed; final diff reviewed for credentials and unrelated changes. Earlier verification included an existing Electron stress-test timeout while competing with compilation; isolated and complete reruns passed without increasing its timeout. Original fixtures, complete CLI/MCP Evidence and failed-attempt logs were preserved. ## Compatibility, safety, and release - Breaking changes or migration steps: no schema migration. Reanalyze sources to obtain corrected semantic Evidence. - Real Hopper/Ghidra, browser, or OS coverage: Linux Node CLI/MCP only. No native provider is required for this workflow; no Windows, macOS or live-browser qualification is claimed. - Package or release metadata impact: none. - Security, privacy, process, or containment review: self-owned fixtures are analyzed as text. Public regression fixtures throw if executed. No target execution, injection or mutation capability is added. - Full repository CI, test and coverage suites were not run locally. ## Author readiness <!-- The human owner completes these declarations before requesting review. AI agents must not attest to human review or readiness on the owner's behalf. --> Human owner: @Xinglan233 - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:10:19 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5904
No description provided.