Skip to content

feat(electron): add autonomous Electron runtime analysis - #464

Merged
morluto merged 15 commits into
mainfrom
codex/electron-agent-runtime-autonomy
Aug 5, 2026
Merged

morluto merged 15 commits into
mainfrom
codex/electron-agent-runtime-autonomy

Conversation

@morluto

@morluto morluto commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

This PR makes REA substantially more autonomous for Electron and JavaScript runtime investigations. It adds bounded, provider-owned Electron actions through Playwright, correlates window/WebContents/process/IPC/timeline events, and makes the resulting Evidence usable by runtime reconciliation.

Root causes resolved

  • Bare file:// Inspector targets have no source identity, so they are now excluded instead of being authorized as the first configured root.
  • Active Electron paths are realpath-canonicalized before containment and permission checks.
  • IPC channels, argument-shape arrays, runtime events, action errors, and scenario evidence are bounded and secret-safe.
  • Popup creation is denied at setWindowOpenHandler; custom Electron sessions are patched as they are created; uncaught exceptions still terminate the target normally.
  • Provider-owned Electron launches carry a run token, verify process lineage, and clean the root plus verified descendant process groups after Playwright closes the app.
  • Coverage now reports preload/renderer boundaries as unavailable unless a renderer-context hook actually ran.
  • Runtime provenance uses process.versions.electron, not the packaged app version.
  • Managed conformance commitments normalize host metadata to portable values so Linux and macOS freshness checks agree.

Validation

  • Full Vitest suite: 326 test files and 1,663 tests passed.
  • npm run check:fast, npm run lint, npm run format:check, and npm run docs:check passed.
  • Real Chrome verifier passed, including browser scenario parity, attach disconnect cleanup, launched-process cleanup, and temporary-profile cleanup.
  • Electron hook/action, passive Inspector, reconciliation, MCP, lifecycle, and permission-policy tests passed.
  • npm run verify:electron built successfully but could not launch because this host has no approved Electron executable and no local Electron package; it requires REA_ELECTRON_EXECUTABLE on a host-provided Electron installation.
  • Playwright lifecycle behavior was checked against the current official Playwright SDK documentation through Context7.

Scope note

The Windows Ghidra review finding is an existing, intentional fail-closed boundary: verified Job Object ownership, private DACL enforcement, and reparse-safe path admission are not implemented, so enabling that provider would overclaim authority. This Electron PR does not weaken that boundary.

Issues

Closes #460
Closes #62
Closes #337
Closes #338
Closes #376

Related broader Electron follow-up work: #64 and #375.

@morluto
morluto marked this pull request as ready for review August 5, 2026 06:59
@cursor

cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

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

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

Comment thread src/ghidra/GhidraProvider.ts Resolved
Comment thread scripts/electron-active-hook.cjs Resolved

@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: 90bea6e796

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

Comment thread src/browser/JavaScriptRuntimeScope.ts Resolved
@morluto morluto changed the title [codex] add autonomous Electron runtime analysis feat(electron): add autonomous Electron runtime analysis Aug 5, 2026

@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: 13b8f4a39f

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

Comment thread scripts/electron-active-hook.cjs Resolved

@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: 227e38444d

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

Comment thread scripts/electron-active-hook.cjs Resolved
Comment thread scripts/electron-active-hook.cjs Resolved
Comment thread scripts/electron-active-hook.cjs Resolved

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

ℹ️ 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: 8c4fd48b1a

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

Comment thread scripts/run-exclusive.mjs Resolved

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

ℹ️ 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 merged commit 8f229ed into main Aug 5, 2026
18 checks passed
@morluto
morluto deleted the codex/electron-agent-runtime-autonomy branch August 5, 2026 11:07

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

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

Comment on lines +258 to +262
if (lineage?.status !== "verified")
return {
cleaned: false,
reason:
"owned Electron lineage was unavailable; helper cleanup was not proven",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject Windows active captures before launch

On win32 this cleanup path requires lineage.status === "verified", but the default process-ownership host returns no process table on Windows, so observeOwnedProcessLineage() cannot verify lineage; a configured Windows caller will still reach electron.launch() first and only then get cleanup_failed. Reject active Electron capture before launching on Windows unless native ownership/cleanup proof exists, rather than running the target and failing after the side effect.

AGENTS.md reference: AGENTS.md:L32-L32

Useful? React with 👍 / 👎.

recordRuntime("process-lifecycle", `child.${method}`, "attempted", {
argument_shapes: args.map((value) => shape(value)),
});
const child = original.apply(this, args);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Propagate the run token into child envs

When the observed app calls child_process.spawn/execFile/exec/fork with an explicit env, Node does not inherit process.env, so this wrapper starts the helper without REA_PROCESS_RUN_ID. The cleanup code validates descendants by that token before signaling, so a long-lived helper with a custom env is treated as unowned and can be left running while the capture reports a cleanup failure; merge the run token into explicit child environments or track those PIDs with equivalent proof.

AGENTS.md reference: AGENTS.md:L32-L32

Useful? React with 👍 / 👎.

case "wait": {
const page =
selectedWindow ??
(await application.firstWindow({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Let untargeted waits complete without windows

Fresh evidence after the earlier window-wait fix is this wait branch: with no window_index, it still calls firstWindow(). Tray/headless Electron apps, or scenarios that intentionally wait before any window is created, therefore record the wait action as failed instead of simply sleeping and returning valid zero-window Evidence.

Useful? React with 👍 / 👎.

darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
* feat: add autonomous Electron runtime analysis

* feat(electron): add lifecycle and boundary telemetry

* feat(electron): capture runtime boundary evidence

* fix(electron): package boundary hook helper

* feat(electron): report active capture coverage

* fix(electron): account for bring-your-own runtime

* feat(electron): expand agent-owned runtime scenarios

* fix(ghidra): keep fixture credentials out of argv

* perf(test): serialize local test and docs workloads

* fix(electron): harden active runtime capture

* fix(inspector): require exact runtime target authorization

* fix(docs): make managed manifest host independent

* fix(ci): make generated catalog portable

* fix: unblock autonomous command and electron flows

* fix(electron): close popup and detached helper gaps
@morluto morluto added enhancement New feature or request area: runtime Process capture and runtime observation labels Oct 14, 2026
@morluto morluto added the provider: electron Analysis provider / engine: electron label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request provider: electron Analysis provider / engine: electron

Projects

None yet

1 participant