[PR #2252] [MERGED] fix(process): add an opt-in Swift module cache #5119

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2252
Author: @charan-rathore
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @morluto

Base: main ← Head: fix/2218-caller-swift-module-cache


📝 Commits (4)

  • 10a6c0c fix(process): add an opt-in Swift module cache
  • c09dd48 Merge remote-tracking branch 'origin/main' into codex/fold-pr-2252
  • d62e3b9 fix(process): preserve caller-owned Swift module caches
  • 35f0cdf fix(process): bypass xcrun lookup for explicit Swift toolchains

📊 Changes

4 files changed (+392 additions, -38 deletions)

View changed files

📝 docs/process-capture.md (+49 -0)
📝 src/process/DarwinProcessRunTokenReader.ts (+58 -18)
📝 src/process/ProcessOwnershipObservation.ts (+25 -6)
📝 tests/boundary/process/darwinProcessRunTokenReader.test.ts (+260 -14)

📄 Description

Fixes #2218.

Behavior

Permit caller-selected compilation paths for REA's existing macOS ownership helper:

  • REA_DARWIN_MODULE_CACHE_PATH creates and forwards a caller-owned cache using both -module-cache-path and CLANG_MODULE_CACHE_PATH. Preserve the authored path, including whitespace. The cache survives helper close/cancellation; per-run helper/compiler intermediates remain REA-owned and are removed.
  • REA_DARWIN_SWIFTC_PATH plus an absolute, compatible SDKROOT invokes an installed Swift compiler directly with -sdk, bypassing xcrun's separate lookup cache. xcrun --no-cache refreshes entries and is not claimed as write-free. Missing/relative prerequisites and a missing direct compiler give actionable errors naming the selected setting and retain bounded compiler outcomes.
  • Unset/empty settings retain xcrun swiftc and Swift's shared reusable cache. Ambient CLANG_MODULE_CACHE_PATH alone still does not change that default. No compiler/SDK repair, global developer-setting edits, sandbox provisioning, target execution or disabled ownership verification is introduced.

Contributor preservation

Keep charan-rathore's earlier PR, original commit and public cache-setting name as canonical. Folded NIU-123370's #2260 compiler-flag, host selection, cleanup and real-compiler coverage with coauthor credit. The direct compiler selection completes the remaining lookup-cache part of the issue.

Validation

29 Darwin ownership boundary tests passed, including a real selected compiler/SDK and cache, direct/missing compiler prerequisites, waiter cancellation, retry, compile-close cleanup, exact process identities and growing process-table behavior. npm run check and npm run docs:check passed. Standards and issue-spec findings were fixed and re-reviewed.

Real public CLI static analysis of an inert two-file JavaScript application succeeded on macOS with Node 24.18.0/npm 11.16.0, Xcode's installed Swift compiler and matching macOS SDK, network denied, and writes restricted to a dedicated directory (plus /dev/null). A separate narrow /bin/ps execution exception is required because macOS's process inspector is setuid; this read-only inspector is outside that sandbox policy. An outside-directory write probe was denied. Both cold and warm runs returned complete Evidence, retained 53 cache entries and left the temporary directory empty.

Private cache run Wall time CPU user + system Maximum RSS reported by time
Cold 2.39 s 1.85 + 0.37 s 318,701,568 bytes
Warm 1.24 s 1.05 + 0.23 s 305,774,592 bytes

These are representative completed-task observations, not a default-path speed comparison. Peak simultaneous process-family memory and task token usage were not measured; time's maximum RSS is not presented as the family peak. Both outputs were 43,322 bytes, which does not establish token savings.

A blanket sandbox without the /bin/ps exception rejected process inspection with spawn EPERM and returned cleanup_incomplete; REA preserved uncertainty instead of bypassing ownership checks. The documented process-inspection prerequisite is separate from cache/toolchain configuration. No claim is made about every write made by arbitrary toolchains/providers. The original author's earlier real-compiler timeout remains historical; the consolidated boundary suite and the selected installed toolchain passed here.


🔄 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/2252 **Author:** [@charan-rathore](https://github.com/charan-rathore) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/2218-caller-swift-module-cache` --- ### 📝 Commits (4) - [`10a6c0c`](https://github.com/morluto/rea/commit/10a6c0c731f25ee28ff958f1214fb10295f46bb9) fix(process): add an opt-in Swift module cache - [`c09dd48`](https://github.com/morluto/rea/commit/c09dd48e78c50e9ff7e883294b2ce6b3fd10787d) Merge remote-tracking branch 'origin/main' into codex/fold-pr-2252 - [`d62e3b9`](https://github.com/morluto/rea/commit/d62e3b9a0926e12ad03f138b1f0277dd4430459b) fix(process): preserve caller-owned Swift module caches - [`35f0cdf`](https://github.com/morluto/rea/commit/35f0cdf1dd8c0f65acbcbf3b9ed4983e3a180b44) fix(process): bypass xcrun lookup for explicit Swift toolchains ### 📊 Changes **4 files changed** (+392 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `docs/process-capture.md` (+49 -0) 📝 `src/process/DarwinProcessRunTokenReader.ts` (+58 -18) 📝 `src/process/ProcessOwnershipObservation.ts` (+25 -6) 📝 `tests/boundary/process/darwinProcessRunTokenReader.test.ts` (+260 -14) </details> ### 📄 Description Fixes #2218. ## Behavior Permit caller-selected compilation paths for REA's existing macOS ownership helper: - `REA_DARWIN_MODULE_CACHE_PATH` creates and forwards a caller-owned cache using both `-module-cache-path` and `CLANG_MODULE_CACHE_PATH`. Preserve the authored path, including whitespace. The cache survives helper close/cancellation; per-run helper/compiler intermediates remain REA-owned and are removed. - `REA_DARWIN_SWIFTC_PATH` plus an absolute, compatible `SDKROOT` invokes an installed Swift compiler directly with `-sdk`, bypassing `xcrun`'s separate lookup cache. `xcrun --no-cache` refreshes entries and is not claimed as write-free. Missing/relative prerequisites and a missing direct compiler give actionable errors naming the selected setting and retain bounded compiler outcomes. - Unset/empty settings retain `xcrun swiftc` and Swift's shared reusable cache. Ambient `CLANG_MODULE_CACHE_PATH` alone still does not change that default. No compiler/SDK repair, global developer-setting edits, sandbox provisioning, target execution or disabled ownership verification is introduced. ## Contributor preservation Keep charan-rathore's earlier PR, original commit and public cache-setting name as canonical. Folded NIU-123370's #2260 compiler-flag, host selection, cleanup and real-compiler coverage with coauthor credit. The direct compiler selection completes the remaining lookup-cache part of the issue. ## Validation 29 Darwin ownership boundary tests passed, including a real selected compiler/SDK and cache, direct/missing compiler prerequisites, waiter cancellation, retry, compile-close cleanup, exact process identities and growing process-table behavior. `npm run check` and `npm run docs:check` passed. Standards and issue-spec findings were fixed and re-reviewed. Real public CLI static analysis of an inert two-file JavaScript application succeeded on macOS with Node 24.18.0/npm 11.16.0, Xcode's installed Swift compiler and matching macOS SDK, network denied, and writes restricted to a dedicated directory (plus `/dev/null`). A separate narrow `/bin/ps` execution exception is required because macOS's process inspector is setuid; this read-only inspector is outside that sandbox policy. An outside-directory write probe was denied. Both cold and warm runs returned complete Evidence, retained 53 cache entries and left the temporary directory empty. | Private cache run | Wall time | CPU user + system | Maximum RSS reported by `time` | |---|---:|---:|---:| | Cold | 2.39 s | 1.85 + 0.37 s | 318,701,568 bytes | | Warm | 1.24 s | 1.05 + 0.23 s | 305,774,592 bytes | These are representative completed-task observations, not a default-path speed comparison. Peak simultaneous process-family memory and task token usage were not measured; `time`'s maximum RSS is not presented as the family peak. Both outputs were 43,322 bytes, which does not establish token savings. A blanket sandbox without the `/bin/ps` exception rejected process inspection with `spawn EPERM` and returned `cleanup_incomplete`; REA preserved uncertainty instead of bypassing ownership checks. The documented process-inspection prerequisite is separate from cache/toolchain configuration. No claim is made about every write made by arbitrary toolchains/providers. The original author's earlier real-compiler timeout remains historical; the consolidated boundary suite and the selected installed toolchain passed here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:04:06 +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#5119
No description provided.