Repository navigation
Conversation
capture_electron_scenario launched the target with the operator's real HOME, temp directory and Electron profile. A capture could read and change existing app data, caches and saved logins, every capture of a .js entry shared one persistent 'Electron' profile, and launching an app the operator already runs handed the launch to that instance through the single-instance lock. Add profile: isolated | real. Omitted means isolated: the provider owns a private 0700 root, redirects HOME/TMPDIR/TMP (and Windows TEMP, USERPROFILE, APPDATA, LOCALAPPDATA) into it, and the active hook sets Electron's home, appData, temp, logs and crashDumps paths before application code runs, stopping the launch if it cannot. The root is removed after the owned processes are released and is retained with the cleanup error otherwise. profile real keeps the previous behaviour as an explicit choice. The tool description no longer claims updater effects are blocked.
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: 1e0b39e7c0
ℹ️ 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".
| } catch (cause: unknown) { | ||
| await profile.remove(); | ||
| throw cause; |
There was a problem hiding this comment.
Retain the profile owner when initialization rollback fails
If profile initialization fails in chmod or mkdir and the subsequent profile.remove() also fails, create() rejects without returning or retaining the allocated profile. The provider's profile variable therefore remains undefined, so its cleanup path and later close() cannot retry removal. Fault-injecting initialization and rollback failures leaves the directory present and produces an error without cleanup metadata or a cleanup lease; the rollback error also replaces the original failure. Retain the allocated owner through the resource scope when rollback fails, preserving both the initialization failure and retryable cleanup authority.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
[Medium impact] The default-profile change affects active Electron captures, not the other observation workflows. Fix X11 display access and satisfy the failed-cleanup ownership requirement before merging.
|
| ...operatorElectronEnvironment(environment, platform, profile !== undefined), | ||
| ...profile?.environment(platform), |
There was a problem hiding this comment.
Isolated captures lose X11 access
If a Linux desktop uses $HOME/.Xauthority without setting XAUTHORITY, the new default profile prevents Electron from opening the X11 display. The launch replaces HOME with an empty private directory but only forwards XAUTHORITY when already set. Electron then looks for the display cookie in the private home.
Resolve the existing authority-file path before replacing HOME, while preserving an explicit XAUTHORITY, as the desktop reader already does.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/browser/PlaywrightElectronActiveProvider.ts
Line: 463-464
Comment:
**Isolated captures lose X11 access**
If a Linux desktop uses `$HOME/.Xauthority` without setting `XAUTHORITY`, the new default profile prevents Electron from opening the X11 display. The launch replaces `HOME` with an empty private directory but only forwards `XAUTHORITY` when already set. Electron then looks for the display cookie in the private home.
Resolve the existing authority-file path before replacing `HOME`, while preserving an explicit `XAUTHORITY`, as the desktop reader already does.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| } catch (cause: unknown) { | ||
| await profile.remove(); | ||
| throw cause; |
There was a problem hiding this comment.
Failed setup loses cleanup ownership
If profile setup fails and profile.remove() also fails, create() loses the directory's cleanup owner and replaces the original setup error. The provider never receives the profile, so neither another capture nor close() can retry removal.
This violates the repository requirement, “Retain ownership of resources whose cleanup failed,” which must be satisfied before merging. Register cleanup ownership as soon as the root exists and preserve both failures.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/browser/ElectronCaptureProfile.ts
Line: 44-46
Comment:
**Failed setup loses cleanup ownership**
If profile setup fails and `profile.remove()` also fails, `create()` loses the directory's cleanup owner and replaces the original setup error. The provider never receives the profile, so neither another capture nor `close()` can retry removal.
This violates the repository requirement, “Retain ownership of resources whose cleanup failed,” which must be satisfied before merging. Register cleanup ownership as soon as the root exists and preserve both failures.
**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| profile: electronCaptureProfileSchema | ||
| .optional() | ||
| .describe( | ||
| "Omit for isolated. isolated: the app runs with a private temporary home, temp directory and Electron profile that REA deletes after the capture, so it cannot read or change the operator's existing app data and starts without saved login state. real: the app uses the operator's HOME and its normal Electron profile, so it can read and change existing app data, caches and saved logins, and if the same app is already running it may hand the launch to that instance.", |
There was a problem hiding this comment.
Profile description overstates file protection
The new profile description promises that an isolated app “cannot read or change” existing app data. Redirecting default paths does not provide that protection: the app keeps normal filesystem access, and app-selected paths remain accessible. Callers may mistake a private profile for a security sandbox.
Qualify the advertised description to say that default paths are redirected, not that existing files are protected.
How this was verified: The capture redirects environment and Electron paths, while the app keeps host filesystem privileges and access to paths it chooses.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/electronActiveObservation.ts
Line: 91
Comment:
**Profile description overstates file protection**
The new `profile` description promises that an isolated app “cannot read or change” existing app data. Redirecting default paths does not provide that protection: the app keeps normal filesystem access, and app-selected paths remain accessible. Callers may mistake a private profile for a security sandbox.
Qualify the advertised description to say that default paths are redirected, not that existing files are protected.
> **How this was verified:** The capture redirects environment and Electron paths, while the app keeps host filesystem privileges and access to paths it chooses.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Thank you for the careful research here, especially the macOS path findings. The maintainer decided to keep active Electron captures on the real app profile. Running against a logged-in app is the common workflow, and no problems with it have been reported, so the private-profile default and profile option will not be merged. The single-instance handoff you found is a real correctness bug. A capture of an app that is already running gets handed to the running instance. That is fixed separately in #10989: the hook stops the launched instance when its lock request is refused, and the capture fails with |
Summary
capture_electron_scenariolaunched the target Electron app with the operator's realHOME, temp directory and Electron profile. A capture could read and change the operator's existing app data, caches and saved logins, and nothing in the request let the caller choose otherwise.This adds
profile: "isolated" | "real". Omitting it meansisolated: the app runs with a private temporary profile that REA owns and deletes."real"keeps the previous behavior as an explicit caller choice. The tool description also stops claiming that updater effects are blocked.No open issue tracks profile isolation; this implements the maintainer's structural-audit decision D7 ("Electron capture scope: research and address").
User-visible change: by default, active Electron captures no longer see saved logins or existing app data. To capture against the operator's real profile, pass
"profile": "real".Problem and expected behavior
Observed on macOS with stock Electron 44.7.0, driving a REA-authored probe app through
PlaywrightElectronActiveProvider(no third-party app was run):app.getPath('userData')was~/Library/Application Support/Electron, the operator's real directory, and the run updated its mtime.home,os.homedir()andos.tmpdir()were also the real ones..jsentries, so the app is namedElectron. As a result, every such capture shared one persistent profile, and state carried over from one capture to the next.requestSingleInstanceLock()returnedfalse. Per the Electron docs, that second instance forwards its argv to the running one. So capturing an app the operator already has open hands REA's launch, including the caller's arguments, to the operator's running instance.HOMEdoes not isolate Electron on macOS, because Cocoa paths ignore$HOME.--user-data-dirmoves userData but leavesappDataandhomereal. Callingapp.setPath('appData'|'home'|...)from the pre-app-rhook moves everything:userData,sessionDataand the lock followappData.Expected: a capture does not touch the operator's real app profile unless the caller explicitly asks for it.
Change and scope
ElectronCaptureProfileis the new owner of the per-capture private root. It is created with mode 0700 and contains thehome,appData,temp,logsandcrashDumpsdirectories. It also provides the environment to launch with:HOME,TMPDIR,TMP, and on WindowsTEMP,USERPROFILE,APPDATAandLOCALAPPDATA. In isolated mode the realHOMEDRIVE/HOMEPATHare not forwarded.scripts/electron-active-hook.cjsreads the one-timeREA_ELECTRON_CAPTURE_PROFILEhandoff and callsapp.setPathfor each path before application code runs. If any path cannot be applied, it fails closed: it writes a stderr message and exits with code 78, so the app never runs against the real profile instead.ElectronCaptureCleanupgains anelectron_profilelease that is released only after the owned process family is released. If process cleanup cannot be verified, the profile stays retained with the cleanup error, and a later retry or close removes it in that order. A launch that never produced an application still removes its profile, and if that removal fails the profile is retained.isolatedinterpretation happens once, incanonicalizeInput(application layer). The canonical input type requiresprofile. I used.optional()rather than a schemadefaultso the advertised-dialectdefaultbaseline does not grow.resolved_profile. The first limitation in the result states the mode and what it does not isolate.Intentionally not included (proposed follow-ups):
--no-sandboxbecause REA does not passchromiumSandbox. The browser-scenario sibling passeschromiumSandboxEnabled(env). Adopting the same rule would change behavior on Linux hosts without user namespaces or a SUIDchrome-sandbox, and I have no real Linux run to verify it.--use-mock-keychain,--password-store=basic). It is unverified whether Electron 44safeStoragehonors these, and testing it on macOS risks touching the real login keychain.The research and options are in the structural-audit report 17 (local), decision D7.
Contract and boundary impact
ElectronCaptureProfile(resource owner) together withcanonicalizeInput(owns the profile choice). Consumers: provider launch env, hook, cleanup owner, projection limitations, Evidence parameters.profileoncapture_electron_scenario(MCP and the CLI JSON request). The description text changed. The result schema is unchanged; one limitation string was added.parametersgainsresolved_profile. The reconciliation parser usespassthrough, andscenario_sha256still covers only the caller's scenario.Expected effects:
(These are the tool's existing effects. This PR reduces which files it changes by default.)
Evidence and regression coverage
Tests added or updated:
tests/boundary/browser/electronActiveHook.test.ts: the hook applies all five paths before app code and consumes the handoff. WhensetPathis rejected or a path is malformed, the process exits with code 78 and no app code runs. All 3 cases fail against theorigin/mainhook (checked by swapping the file in).PlaywrightElectronActiveProvider.test.ts:isolatedandreal: isolated redirectsHOME/TMPDIR/TMPinto an existingrea-electron-profile-*root, ignores a forged ambient handoff, and removes the root after a failed launch.close().ElectronActiveObservationService.test.ts: omitted →isolated, the caller-selected mode reaches the provider, and Evidence recordsresolved_profile.profile.electronMcp.test.tssplitsresolved_profileout of the scenario digest check.Base reproduction: the probe run against the unchanged provider showed the real
userData/home/tmpvalues above. Lifecycle regressions covered: cleanup retry, mixed outcomes (process failure + profile), and launch failure. The existing cancellation-during-cleanup tests now run with the isolated profile by default and pass.User-visible output: the first limitation of an isolated capture now reads "The application ran with a private temporary home, temp directory and Electron profile that REA deletes after the capture; …".
Remaining proof gaps: no Linux or Windows real-Electron run. Keychain isolation is not attempted.
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
npm run check:fast: passed (typecheck + lint).npx oxfmt --check <changed files>: passed.npm run docs:check: passed.npm run test:local -- src/browser/PlaywrightElectronActiveProvider.test.ts src/browser/PlaywrightElectronActiveProjection.test.ts src/browser/ElectronCaptureCleanup.test.ts src/electron/ElectronFuseCleanup.test.ts src/application/javascript/ElectronActiveObservationService.test.ts src/contracts/toolEffects.test.ts src/browser/PlaywrightElectronActiveFuses.test.ts: all passed.npm run test:focused -- tests/boundary/mcp/advertisedDialect.test.ts tests/boundary/mcp/electronMcp.test.ts tests/acceptance/tools/localToolContracts.test.ts tests/boundary/cli/scenarioCliInputDiagnostics.test.ts tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts tests/acceptance/applications/electronInvalidPaths.test.ts tests/boundary/browser/electronActiveHook.test.ts tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts tests/boundary/process/darwinProcessRunTokenReader.test.ts: all passed after the final changes.electronMcpandadvertisedDialectwere rerun after their fixes.isolated:userData,appData,home,os.homedir()andtmpwere all insiderea-electron-profile-*. The real~/Library/Application Support/Electronmtime was unchanged, and the root was gone afterwards.real: the real paths, as before.REA_ELECTRON_EXECUTABLE=… npm run verify:electron: fails before the active stage in thereconcile_javascript_runtimeMCP probe with "MCP tool arguments exceed the configured input element allowance (1024)". That failure is independent of this change.profileforced torealand thenisolated(twice each), failed identically in both modes: "did not observe the readiness IPC round trip", with the post-crashwaitfailing with "Page crashed". Actions, IPC count (5), timeline count (133) and event kinds were identical across modes, so isolation does not change this pre-existing lane result.Compatibility, safety, and release
"profile": "real". The maintainer may prefer a!marker for this default change.Author readiness
Human owner:
Before merge
type(scope): outcome.Migration
BREAKING CHANGE:
capture_electron_scenarionow runs the app with a private temporary profile by default. Captures that relied on the app's saved logins or other existing state must now pass"profile": "real". Example:{"app": "/Applications/Example.app", "steps": [...]}previously ran with the user's real profile. It now runs isolated. Add"profile": "real"to keep the old behaviour. The change is breaking because the default changes what the launched app can read and write, and no compatibility shim can preserve both defaults.