Repository navigation
Conversation
Parent JavaScriptAnalysisWorker path-created the temp .source file with exclusive writeFile inside the private runtime root; on Windows that can fail with EPERM. Match the Ghidra runtime-file owner and write through windowsPrivateRuntime instead. Co-authored-by: Cursor <[email protected]>
Codex Review SummaryThis 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: 41023ea331
ℹ️ 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 platform = options.platform ?? process.platform; | ||
| options.signal?.throwIfAborted(); | ||
| if (platform === "win32") { | ||
| windowsPrivateRuntime(win32.dirname(path)).writeFile( |
There was a problem hiding this comment.
Release the source handle before per-job deletion
On Windows, runtime_write retains this file's handle in WindowsPrivateRuntime.immutableFiles; the handle allows only FILE_SHARE_READ and remains open until the runtime closes, so the per-job rm at the end of JavaScriptAnalysisWorker.analyze() cannot delete the source file. Every otherwise successful analysis is therefore converted into a cleanup error and the runtime is retained; use an owner operation that permits per-job removal or defer cleanup until the native runtime closes.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
[Medium impact] The change affects source staging in the JavaScript analysis workflow on Windows. Fix the Windows source-file cleanup and blocking write before merging. FindingsFix with agent prompt### Issue 1
src/javascript/analysis/JavaScriptAnalysisSourceTransfer.ts:25-28
The Windows write keeps the source file open until the entire runtime closes. That handle allows only `FILE_SHARE_READ`, so the existing per-source `rm` cannot delete it. `analyze()` then turns an otherwise successful result into a cleanup error and marks the worker unavailable for reuse.
Add an owner-controlled way to remove each completed source without weakening the private file protections. Cover writing through per-source cleanup in a Windows test.
### Issue 2
src/javascript/analysis/JavaScriptAnalysisSourceTransfer.ts:24-29
The Windows branch replaces an asynchronous, abort-aware write with a synchronous native write and `FlushFileBuffers`. If a large source or slow temporary storage makes this take a long time, the parent thread stays blocked. The deadline timer, caller cancellation, and other server requests cannot run until the disk operation finishes.
Use an asynchronous native write that preserves ownership and accepts cancellation. Checking the signal only before the write does not preserve the previous behavior.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThe PR routes Windows JavaScript source transfer through the existing private-runtime owner. POSIX keeps exclusive owner-only file creation.
Acknowledged scope exclusions from Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Parent source transfer] --> B{Platform}
B -->|Windows| C[Native write and flush]
C --> D[Retain immutable source handle]
D --> E[Worker analyzes source]
E --> F[Parent removes per-source files]
F --> G[Retained handle blocks deletion]
G --> H[Cleanup error replaces result]
B -->|POSIX| I[Async exclusive write with signal]
Reviews (1) · Last reviewed commit: "fix(javascript): use Windows private-run..." · Reviewed by Greptile |
| windowsPrivateRuntime(win32.dirname(path)).writeFile( | ||
| win32.basename(path), | ||
| source, | ||
| ); |
There was a problem hiding this comment.
The Windows write keeps the source file open until the entire runtime closes. That handle allows only FILE_SHARE_READ, so the existing per-source rm cannot delete it. analyze() then turns an otherwise successful result into a cleanup error and marks the worker unavailable for reuse.
Add an owner-controlled way to remove each completed source without weakening the private file protections. Cover writing through per-source cleanup in a Windows test.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/javascript/analysis/JavaScriptAnalysisSourceTransfer.ts
Line: 25-28
Comment:
**Source handles block cleanup**
The Windows write keeps the source file open until the entire runtime closes. That handle allows only `FILE_SHARE_READ`, so the existing per-source `rm` cannot delete it. `analyze()` then turns an otherwise successful result into a cleanup error and marks the worker unavailable for reuse.
Add an owner-controlled way to remove each completed source without weakening the private file protections. Cover writing through per-source cleanup in a Windows test.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| if (platform === "win32") { | ||
| windowsPrivateRuntime(win32.dirname(path)).writeFile( | ||
| win32.basename(path), | ||
| source, | ||
| ); | ||
| return; |
There was a problem hiding this comment.
Source writes freeze the server
The Windows branch replaces an asynchronous, abort-aware write with a synchronous native write and FlushFileBuffers. If a large source or slow temporary storage makes this take a long time, the parent thread stays blocked. The deadline timer, caller cancellation, and other server requests cannot run until the disk operation finishes.
Use an asynchronous native write that preserves ownership and accepts cancellation. Checking the signal only before the write does not preserve the previous behavior.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/javascript/analysis/JavaScriptAnalysisSourceTransfer.ts
Line: 24-29
Comment:
**Source writes freeze the server**
The Windows branch replaces an asynchronous, abort-aware write with a synchronous native write and `FlushFileBuffers`. If a large source or slow temporary storage makes this take a long time, the parent thread stays blocked. The deadline timer, caller cancellation, and other server requests cannot run until the disk operation finishes.
Use an asynchronous native write that preserves ownership and accepts cancellation. Checking the signal only before the write does not preserve the previous behavior.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
Closing: Greptile 3/5 with unresolved P1s that make this unsafe to merge as written.
Needs an async, abort-aware write that still permits per-source cleanup without weakening private-runtime protections—and Windows AppContainer verification we do not have here. Happy to revisit with that design. |
Summary
Fixes #8658. Parent
JavaScriptAnalysisWorkersource-transfer used Node exclusivewriteFile(wx, mode0600) inside the worker-owned Windows private runtime root; that path-based create can fail withEPERM. Write through the existing native private-runtime owner instead, matching the Ghidra runtime-file pattern.Problem and expected behavior
After the worker handshake, the parent stages
${id}.sourceunder the private runtime root before sending the request frame. On Windows that root uses a protected DACL and a retained directory handle. Path-based exclusive create is the wrong write boundary there and can fail withEPERM, aborting analysis atsource-transfer.Expected: source-transfer succeeds on Windows by creating the temp source file through
windowsPrivateRuntime.writeFile(runtime_write), without weakening the private DACL. POSIX keeps exclusive owner-onlywxcreate.Change and scope
writeJavaScriptAnalysisSourceTransferat the owning write boundary.win32, callwindowsPrivateRuntime(dirname).writeFile(basename, source)(same owner pattern aswriteGhidraRuntimeFile).writeFilewithflag: "wx",mode: 0o600, and the deadline signal.EPERMis never consulted), cancellation before the Windows write, POSIX exclusive create, and POSIXEPERMpropagation.Intentionally not included: AppContainer DACL / package-SID policy (still open under #5225 / the clarifying questions on #8658); worker-side
.static.json/ transfer-record writes; WebBundle source staging.Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.
Contract and boundary impact
JavaScriptAnalysisWorkerparent source-transfer write intoOwnedWorkerRuntime/PrivateRuntimeRoot; consumers still read${id}.sourceby the same relative name.WindowsPrivateRuntimelease; no new cleanup ownerdocs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): noneExpected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
src/javascript/analysis/JavaScriptAnalysisSourceTransfer.test.ts(Windows native write vs path-createEPERM, cancellation, POSIXwx, POSIXEPERM)writeFilewx/0600at source-transfer) and in-repo Windows private-runtime owner (writeGhidraRuntimeFile/runtime_write). Real Windows host and AppContainer token were not measured in this change.EPERManalyze-javascript-applicationin this PR; AppContainer package-SID behavior remains unverified (see [Windows x64] rea inspect --provider ghidra fails snapshot admission with Win32 5 (EACCES) in an AppContainer process; succeeds from an ordinary shell #5225)For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.
Boundary: producer ownership / projection at the private-runtime write boundary (Windows native vs POSIX exclusive create). Lifecycle: cancellation before Windows write is covered; full worker cleanup lifecycle unchanged.
For evidence-bearing changes:
Validation performed
npm run test:focused -- src/javascript/analysis/JavaScriptAnalysisSourceTransfer.test.ts— 4 passednpm run format:check— passednpm run check:fast(pre-push) — typecheck and lint passedCompatibility, safety, and release
runtime_write; does not add AppContainer package ACE or weaken owner-only POSIX mode0600Author readiness
Human owner: @BeqaKs
Before merge
type(scope): outcome.