Skip to content

fix(electron): retain wrapped protocol handler registrations - #8671

Closed
ShuaixinHuang wants to merge 3 commits into
morluto:mainfrom
ShuaixinHuang:codex/fix-electron-protocol-handle-presence
Closed

ShuaixinHuang wants to merge 3 commits into
morluto:mainfrom
ShuaixinHuang:codex/fix-electron-protocol-handle-presence

Conversation

@ShuaixinHuang

@ShuaixinHuang ShuaixinHuang commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #8750 at the author's request: #8750 . Same published branch/HEAD; original discussion and historical validation are preserved below.

Public regression consolidation — 2026-11-03

Removed the duplicate two-row module matrix for the six omitted/null/void handler registrations. Both public CLI and stdio MCP already cover these registrations, exact scheme sets, graph edges and evidence limitations; they now also assert default-protocol versus default-session classification. Distinct domain semantics and legacy refusal controls remain.

The three complete focused files pass 45 tests (37 domain, 6 boundary, 2 compiled public adapters); check:fast passes 2/2 in 52.029s. No production code or assertion was weakened. This HEAD requires fresh hosted CI.

Review follow-up — 2026-11-02

Removed the duplicate graph-only protocol fixture after confirming that both compiled public CLI and stdio MCP tests cover the same six modern registrations, three legacy exclusions, graph nodes/edges and properties, plus evidence authority, observed status and runtime limitations. All remaining boundary controls stay in place. No production behavior changed.

Current validation: the three complete focused files pass 47 tests (39 domain, 6 boundary, 2 public CLI/MCP); prerequisite builds pass. check:fast passes typecheck and lint (2/2 tasks, 52.31s). The historical 48-test result below includes the now-removed duplicate. This new HEAD requires fresh hosted CI.

Supersedes #8639 at the author's explicit request to resubmit all current PRs. Same published branch and HEAD 51a2f60. Original discussion and historical validation remain at #8639. This new PR requires its own hosted CI and new human declarations for this PR ID.

Supersedes #8539 at the author's explicit request to resubmit all current PRs. Same published branch and HEAD 51a2f600a69205ff05015dfca1a1a432f7adfc96. Original discussion and historical validation remain at #8539. This new PR requires its own hosted CI and a new human declaration for this PR ID; prior review declarations are historical.

Supersedes #8490 at the author's explicit request to resubmit this contribution. This new PR uses the same published branch and HEAD 51a2f600a69205ff05015dfca1a1a432f7adfc96. Original discussions and validation are preserved at #8490. The historical results below retain their original execution points; this new PR requires its own hosted CI and a new human declaration for this PR ID.

Supersedes #8256 at the author's explicit request to resubmit the existing PR. This replacement reuses verified head 51a2f60 and preserves the original discussion and validation record at #8174. Historical validation and its limitations below remain at their stated execution points. This new PR must pass its own hosted CI.

Summary

Retain source registrations for protocol.handle("app"), protocol.handle("app", null) and protocol.handle("app", void 0), including the session protocol receiver. The static analyzer currently drops these calls even though Electron installs its own wrapper before invoking the supplied handler on a later request.

This corrects behavior introduced by merged #2978; no separate issue was filed. Searches found no existing PR for this correction.

Problem and expected behavior

On Electron 33.4.11/Windows, each of those handle calls returns without throwing and changes protocol.isProtocolHandled(scheme) from false to true. The equivalent legacy registerStringProtocol calls throw and leave it false. The current shared missing-handler filter treats both APIs as the legacy API, removing the modern calls from the graph and CLI/MCP summary.

The Electron 33.4.11 implementation installs a native callback which invokes the supplied handler only when a request arrives. Registration presence does not establish that the handler can serve a request successfully.

Change and scope

Apply the missing-handler filter only to legacy registration/interception APIs. Preserve existing scheme resolution, receiver/session classification, source-call evidence and uncertainty about successful execution, routing and responses. Two incorrect modern-API negative expectations become legacy-API controls; their refusal assertions remain, with an additional void 0 control. No shared nullish evaluation, schema, provider, authority, budget or target-execution behavior changes.

Contract and boundary impact

  • Semantic owner and earliest changed stage: inspectElectronProtocolNode, then existing graph projection and application summary.
  • Contribution scope fit and linked maintainer decision: ordinary correction within the existing static analysis capability; additional scope decision not applicable.
  • CLI and MCP/tool-catalog contract: existing analysis operations now retain six previously omitted source registrations in the regression fixture; no command, tool or schema changes.
  • Provider, bridge, target-format, or platform compatibility: modern Electron handle and legacy native registration retain their distinct callback behavior.
  • Evidence, artifact, provenance, or reconstruction contract: existing ast-static-analysis source-call observations and successful-registration limitations remain.
  • Target selection, authority, upstream behavior, and cleanup: analysis reads inert files. Separate verification launched only an owned Electron process with a temporary profile, cleaned up its schemes and exited normally; no browser window, protocol requests, OS default-handler changes or user processes were used.
  • Generated metadata, package, or installation impact: none.

Expected effects of the analysis remain:

  • 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.

Evidence and regression coverage

  • Real Electron probe: 8 cases, modern/legacy APIs each with omitted, null, undefined and callable handlers. Modern cases all registered; legacy nullish/omitted cases threw and remained unregistered, with the callable control registering. Exit 0, no watchdog termination or stderr. This checks presence only; no custom protocol request was issued.
  • Exact base 47fa6ab3795d547207001ffb01643c0aa39dcad8: the two complete source/graph files produced 3 failed / 43 passed. The compiled public CLI and stdio MCP cases both failed, reporting protocol_registrations: 0 instead of 6.
  • Fixed three complete files: 48 passed (39 domain, 7 filesystem boundary, 2 public CLI/stdio MCP). Both public surfaces return 6 registrations, 6 scheme nodes and 6 handles edges, retaining AST authority and uncertainty. A throwing source fixture stays inert during analysis. Legacy missing/null/void callbacks remain excluded.
  • The first draft used bare undefined as a syntactically known nullish value; this was corrected to unambiguous void 0 before the final baseline and fix results. No shared identifier-resolution expansion was made.

For evidence-bearing changes:

  • 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 test:focused -- src/domain/javascript/electronStaticAnalysisProtocol.test.ts tests/boundary/filesystem/javascript-applications/electronProtocolBoundaries.test.ts tests/acceptance/applications/electronProtocolHandleCli.test.ts — 3 prerequisite build tasks and all 48 tests passed.
  • npm run check:fast — typecheck and lint passed, 2/2 tasks, 19.344s. The initial lint run caught an oversized test describe; the added graph case now has its own describe without suppressions.
  • npm run verify:test-discovery — all 2884 files discovered exactly once.
  • Normal precommit passed; all four committed files match the tested SHA256 hashes. Normal prepush passed, 2/2 cached tasks in 213ms. Working tree clean after the push.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; correction to existing source findings.
  • Real platform coverage: Electron 33.4.11 on Windows x64, plus real compiled CLI and stdio MCP analyzing synthetic source. No Linux/macOS, other Electron version, successful protocol response, or full repository suite claim. The Electron executable came from an existing local cache; no official checksum verification is claimed.
  • Package or release metadata impact: none. Existing owning docs already distinguish source registration from successful runtime behavior; that contract is preserved.
  • Security, privacy, process, or containment review: static analysis never executes its target fixture; real runtime verification used only its owned process/profile and in-process scheme registrations.

Author readiness

Human owner: @ShuaixinHuang

  • 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 replacement preserves the prior PR discussion and validation history at #8256. It reuses the verified published head and requires its own hosted CI.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T01:23:00.804884Z f7b0f17 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the test consolidation preserves coverage of the changed behavior.

Summary

The PR retains source registrations for protocol.handle with omitted, null, or void handlers while keeping legacy callback exclusions.

  • Electron analysis keeps handle calls even without a handler.

Reviews (3) · Last reviewed commit: "test(electron): consolidate handler pres..." · Reviewed by Greptile

@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: 51a2f600a6

ℹ️ 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 +40 to +41
describe("Electron wrapped protocol.handle graph", () => {
it("retains wrapped handle registrations while rejecting missing legacy callbacks", async () => {

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 Remove the duplicate graph-only protocol regression

This case recreates the same six modern registrations and three legacy controls, then repeats the scheme, edge-count, and property assertions in tests/acceptance/applications/electronProtocolHandleCli.test.ts:23-85. Those public CLI/MCP calls already exercise reconstructJavaScriptArtifact through src/application/javascript/JavaScriptApplicationService.ts:90, so this adds no distinct semantic or failure-path coverage and requires maintaining the fixture and assertions twice. Retain the public workflow regression and remove this graph-only duplicate to follow AGENTS.md's explicit requirement to remove redundant tests.

AGENTS.md reference: AGENTS.md:L27-L27

Useful? React with 👍 / 👎.

@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: 201f7cc2c2

ℹ️ 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 +345 to +348
describe("Electron wrapped protocol.handle registrations", () => {
it.each([
["protocol", "default-protocol"],
["session.defaultSession.protocol", "default-session"],

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 Consolidate the duplicated handler matrix into the public regression

These parameterized cases repeat all six omitted/null/void 0 registrations already exercised through both adapters by tests/acceptance/applications/electronProtocolHandleCli.test.ts:23-85. The session classification is also exposed in graph observation properties (src/application/javascript/ElectronBoundaryGraphProtocols.ts:68), so it can be asserted there instead of maintaining a second fixture/assertion matrix. AGENTS.md says to keep module tests for “distinct semantics stronger workflows cannot reliably reproduce”; remove this duplicate and retain any additional assertions in the public regression.

AGENTS.md reference: AGENTS.md:L86-L86

Useful? React with 👍 / 👎.

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

ℹ️ 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 +293 to +294
"a legacy handler without a callback",
'protocol.registerStringProtocol("app");',

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 Remove legacy callback cases duplicated by the public regression

These legacy-handler cases repeat the omitted/null/void 0 controls in tests/acceptance/applications/electronProtocolHandleCli.test.ts:30-32. That public regression asserts the exact six schemes and registration/edge counts through both CLI and stdio MCP, so retaining any legacy registration already makes it fail. These three module cases therefore add no distinct semantics or failure-path coverage. Keep the public controls and remove these rows, leaving the interceptor and privileged-scheme cases intact, to follow AGENTS.md's requirement to reserve module tests for semantics stronger workflows cannot reliably reproduce.

AGENTS.md reference: AGENTS.md:L86-L86

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working provider: electron Analysis provider / engine: electron

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants