Skip to content

[2119 by GPT-5.6 Sol] Desktop renderer CSP: restrict cleartext transport to loopback (retry) - #2120

Merged
integry merged 6 commits into
1953-epic-desktop-transport-apifrom
2119/gpt-5.6-sol-desktop-renderer-csp-rest-20260904-1923-yoz
Sep 4, 2026
Merged

integry merged 6 commits into
1953-epic-desktop-transport-apifrom
2119/gpt-5.6-sol-desktop-renderer-csp-rest-20260904-1923-yoz

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #2119

Branch: 2119/gpt-5.6-sol-desktop-renderer-csp-rest-20260904-1923-yoz
Commits: ✅ Changes committed (d57b96e)


AI Processing Completed

Execution Details:

Summary:
Implemented GitHub issue #2119.

Key changes:

  • Removed scheme-wide production http: and ws: renderer access.
  • Added exact, normalizer-validated HTTP/WS sources for the active loopback profile.
  • Injected the profile-specific policy into packaged HTML before renderer scripts execute.
  • Reloads safely when the active loopback policy changes, while request boundaries remain fail-closed.
  • Preserved HTTPS/WSS remote and ProPR Connect support.
  • Added coverage for localhost, .localhost, full IPv4 127/8, IPv6 loopback, remote HTTPS/WSS, LAN hosts, and deceptive hostname forms.

Validation:

  • Desktop suite: 477 passed, 25 platform-specific skipped, 0 failed.
  • Focused security/IPC/session tests: 28 passed.
  • Desktop typecheck passed.
  • Linux x64 package build and packaged artifact inspection passed.
  • Live packaged smoke could not launch because the environment lacks Xvfb/DISPLAY; CI provides xvfb-run.
  • No visual preview generated because the change is not user-visible.

Detailed Logs:

  • Conversation: 66 messages
  • Session: 01a06de0-d04c-7520-9a84-07305ae6210f

Log files stored at:

  • conversation: /tmp/claude-logs/issue-2119-2026-09-04T19-32-52-350Z-conversation.json
  • output: /tmp/claude-logs/issue-2119-2026-09-04T19-32-52-350Z-output.txt
Latest Conversation Messages

This PR was created automatically by ProPR after processing issue #2119.


💡 Need changes?

Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!

…xt transport

Implemented by ProPR AI using gpt-5.6-sol model.

Implementation completed successfully.
@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/ultrafix goal=9 max=3

@propr-dev propr-dev Bot added the ultrafix label Sep 4, 2026
@propr-dev

propr-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 9/10, max cycles: 3)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-5.6-sol

Overall Evaluation

This PR substantially narrows production renderer CSP access, but it needs minor, mandatory changes before merge. The policy lifecycle is not synchronized with persisted or directly selected profiles, and four current Windows checks are also failing.

✅ Canonical cleartext allowlisting — rendererContentSecurityPolicy normalizes candidates and emits exact HTTP and corresponding WS origins only for accepted loopback endpoints.

✅ Pre-script policy injection — Packaged HTML is rewritten by the custom protocol before renderer scripts execute, while the session response header uses the same policy callback.

✅ Strong normalization coverage — Tests cover localhost variants, full IPv4 127/8, IPv6 loopback, and deceptive cleartext host forms.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Policy misses active-profile transitions

  • Required behavior: The packaged policy must contain only the current active loopback profile’s exact HTTP/WS sources. It must work on initial load and remain synchronized when the active profile changes or is cleared.
  • Evidence: apps/desktop/src/main.ts:1165 — normal startup initializes rendererPolicyOrigins only from smoke-test inputs, not the persisted active profile; apps/desktop/src/ipc.ts:167 updates it only after connectionActivate, while successful set-active, active-profile edit, and removal paths do not reconcile the policy.
  • Minimum fix: Initialize the allowlist from the authoritative active profile before the first packaged renderer load, then reconcile and reload it after every successful operation that can change, edit, or clear the active profile. Add coverage for startup, set-active, active-profile edit, and removal transitions.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Exercise the packaged protocol

Add an integration test that serves renderer.html through the packaged protocol and verifies the effective response header and rewritten meta policy, including IPv6. Existing tests validate generated strings but do not exercise Electron’s actual CSP parsing or header/meta agreement; this is useful defense in depth rather than a separate merge blocker.

Score

The CSP construction is careful and well tested at the unit level, but incomplete policy-state synchronization is a functional and security regression in the changed behavior. The four current Windows check failures further prevent merge readiness.

Score: 5/10


🤖 Review Details

  • Model: GPT-5.6 Sol
  • Time: 2m 2s
  • Tokens: 45,836 (39,605 in / 6,231 out)
  • Cost: $0.34

View Task


💡 Next step: Comment /fix to address F# merge blockers only.
F# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. Suggestions require a separate ordinary follow-up request.

🤖 Review by ProPR

@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/fix F1

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit bce63a7

Addressed 1 AI review comment (IDs: 5545636346)

Summary of Changes

Implemented F1 only.

  • Seeds packaged renderer policy from the persisted active profile before initial window load.
  • Reconciles and reloads policy after profile save/edit, set-active, removal, clearing, and activation.
  • Added focused startup and transition coverage.

Validation:

  • Desktop tests: 480 passed, 25 skipped, 0 failed.
  • Desktop typecheck passed.
  • Linux x64 packaging and artifact inspection passed.
  • git diff --check passed.
  • No visual preview created; this is not user-visible.
  • Changes were not committed, as requested.

🤖 Implementation Details

  • Model: GPT-5.6 Sol (high)
  • Requested By: @integry
  • Time: 7m 48s
  • Tokens: 1,722,267 (1,710,190 in / 12,077 out)
  • Cost: $1.65
  • Subscription usage: Weekly +1%

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Implement fixes for issues found by /review /fix or /fix address the null check issue
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 5545646008✓

Implemented F1 only.

- Seeds packaged renderer policy from the persisted active profile before initial window load.
- Reconciles and reloads policy after profile save/edit, set-active, removal, clearing, and activation.
- Added focused startup and transition coverage.

Validation:

- Desktop tests: 480 passed, 25 skipped, 0 failed.
- Desktop typecheck passed.
- Linux x64 packaging and artifact inspection passed.
- `git diff --check` passed.
- No visual preview created; this is not user-visible.
- Changes were not committed, as requested.

PR: #2120
Comment by: @integry (ID: 5545646008)
Model: gpt-5.6-sol
@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-5.6-sol

Overall Evaluation

The PR substantially improves the packaged renderer CSP by replacing scheme-wide cleartext access with normalized, profile-specific HTTP/WS sources. However, it needs minor changes before merge: two state-synchronization paths can leave the installed CSP out of sync with the active profile. The current Packaged Connect (linux-x64) failure also prevents declaring the head merge-ready, although the supplied evidence does not establish a code-level cause.

✅ Exact cleartext allowlisting — rendererConnectSources revalidates candidates and emits only the normalized loopback HTTP origin and corresponding WS origin.

✅ Secure transport preserved — Production retains scheme-wide HTTPS/WSS support while removing scheme-wide HTTP/WS access.

✅ Strong normalization coverage — Tests cover localhost subdomains, the full supported 127/8 range, IPv6 loopback, LAN addresses, and deceptive hostname forms.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F2: 🔴 Discard leaves stale CSP access

  • Required behavior: Cleartext CSP sources must follow the active loopback profile and be removed when an activation is discarded and the active selection becomes null.
  • Evidence: apps/desktop/src/ipc.ts:193 — connectionDiscard still directly delegates to credentials.discardActivation(value) without invoking the new renderer-policy reconciliation. A successful discard clears activeProfileId, but the previous HTTP/WS sources remain installed and no reload occurs. The rollback at apps/desktop/src/ipc.ts:186 has the same omission.
  • Minimum fix: After a successful explicit or rollback discard, reconcile the current active profile and reload the renderer when the policy changes. Add coverage showing that discarding an active HTTP loopback connection removes its HTTP/WS sources.

F3: 🔴 Activation can overwrite newer policy state

  • Required behavior: Dynamic CSP reconciliation must reflect the latest active-profile state, including when profile mutations overlap asynchronously.
  • Evidence: apps/desktop/src/ipc.ts:181 — The activation handler captures activatedOrigin, awaits asynchronous cookie clearing, and then publishes that captured value at line 183. A concurrent setActive, remove, or save operation can complete its own reconciliation during that await, after which the older activation callback overwrites the newer policy permanently.
  • Minimum fix: After cookie clearing, use reconcileRendererActiveProfile(event) to read and publish the current persisted selection instead of publishing the earlier activatedOrigin snapshot. Add a concurrency test where another active-profile mutation completes while activation cookie clearing is pending.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Prefer behavioral startup coverage

The new startup test in apps/desktop/src/smoke-test-authorization.test.ts relies on indexOf checks against main.ts. A behavioral test around policy initialization and first-window creation would detect dead, duplicated, or refactored code that preserves those strings without preserving behavior. This is optional because it does not demonstrate an additional current defect.

Score

The core CSP restriction and normalization are well implemented, but two active-state transitions can leave stale cleartext permissions, and one authoritative packaged check is currently failing.

Score: 6/10


🤖 Review Details

  • Model: GPT-5.6 Sol
  • Time: 2m 43s
  • Tokens: 58,316 (49,597 in / 8,719 out)
  • Cost: $0.51

View Task


💡 Next step: Comment /fix to address F# merge blockers only.
F# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. Suggestions require a separate ordinary follow-up request.

🤖 Review by ProPR

@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/fix F2 F3

Also include these independently verified parts of the same lifecycle correction:

  • Reconcile after a successful authenticationPair, because commitPairedProfile clears activeProfileId when an active profile is re-paired with a changed origin. Add a focused active local-origin re-pair test.
  • Do not retain the IPC event.sender for delayed reloads. Make the policy callback origin-only and, when the latest generation timer fires, resolve and reload the current mainWindow.webContents. Cover renderer replacement plus overlapping transitions so only the latest current renderer receives the reload.
  • For pinned packaged smoke policies, do not install or run dynamic reconciliation or its extra credentials.listProfiles reads. The bce63a7 head regressed all four macOS/Linux Packaged Connect journeys after adding those reads. Preserve the pinned smoke allowlist and deterministic journey state while keeping normal packaged startup and transitions authoritative.
  • Correct the active-origin edit test to match real saveAndDetachCredential semantics: an origin change clears activeProfileId, so reconciliation must publish null rather than keeping the edited profile active.
  • After the patch, run the focused lifecycle and security tests plus all four macOS/Linux packaged Connect journeys.

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit fece985

Addressed 1 AI review comment (IDs: 5545782947)

Summary of Changes

Implemented F2 and F3, scoped to the selected findings.

  • Successful explicit and rollback discards now reconcile the persisted active profile, removing stale loopback HTTP/WS CSP sources.
  • Activation reconciles current state after cookie clearing, preventing older activations from overwriting newer mutations.
  • Policy callbacks are origin-only; delayed reloads resolve the current main renderer and discard superseded generations.
  • Pinned packaged smoke policies no longer install dynamic reconciliation or trigger extra listProfiles() reads.
  • Added focused concurrency, discard, rollback, renderer-replacement, and smoke-policy coverage.

Validation:

  • Focused lifecycle/security tests: 42 passed.
  • Packaged Connect lifecycle/platform tests: 70 passed.
  • Desktop TypeScript check passed.
  • Linux-x64 package and artifact inspection passed.
  • Native Packaged Connect journey attempt was blocked by this container lacking Xvfb/keyring support and root-owned Chrome sandbox setup. Darwin and arm64 targets require their target-native CI runners.
  • No visual preview generated; this change is not visually perceptible.

🤖 Implementation Details

  • Model: GPT-5.6 Sol (high)
  • Requested By: @integry
  • Time: 9m 0s
  • Tokens: 3,609,316 (3,590,599 in / 18,717 out)
  • Cost: $2.92

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Implement fixes for issues found by /review /fix or /fix address the null check issue
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 5545794678✓

Implemented F2 and F3, scoped to the selected findings.

- Successful explicit and rollback discards now reconcile the persisted active profile, removing stale loopback HTTP/WS CSP sources.
- Activation reconciles current state after cookie clearing, preventing older activations from overwriting newer mutations.
- Policy callbacks are origin-only; delayed reloads resolve the current main renderer and discard superseded generations.
- Pinned packaged smoke policies no longer install dynamic reconciliation or trigger extra `listProfiles()` reads.
- Added focused concurrency, discard, rollback, renderer-replacement, and smoke-policy coverage.

Validation:

- Focused lifecycle/security tests: 42 passed.
- Packaged Connect lifecycle/platform tests: 70 passed.
- Desktop TypeScript check passed.
- Linux-x64 package and artifact inspection passed.
- Native Packaged Connect journey attempt was blocked by this container lacking Xvfb/keyring support and root-owned Chrome sandbox setup. Darwin and arm64 targets require their target-native CI runners.
- No visual preview generated; this change is not visually perceptible.

PR: #2120
Comment by: @integry (ID: 5545794678)
Model: gpt-5.6-sol
@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/fix Complete the remaining CSP lifecycle gaps on fece985:

  1. rendererPolicyPinnedForSmoke is still defined as rendererPolicyOrigins.length > 0 && packagedSmokeTest. That is false for PROPR_DESKTOP_CONNECT_SMOKE_TEST and transport smoke, so startup still overwrites their explicitly seeded origins and installs dynamic reconciliation. Define pinning from the explicit smoke modes themselves: transportSmoke, connectSmoke.journeyEndpoint, or an authorized packaged smoke profile origin. Prove Connect and transport smoke skip the persisted-profile startup read and omit the callback; rerun all four Darwin/Linux Packaged Connect journeys.
  2. authenticationPair still delegates directly. A successful commitPairedProfile can clear activeProfileId when re-pairing an active profile at a changed origin. Await pair and reconcile authoritative state afterward; add a focused test expecting null.
  3. The first profile-save test still unrealistically returns activeProfileId profile-a after an origin-changing save. Match saveAndDetachCredential semantics by returning null and assert null reconciliation. Preserve the F2/F3 concurrency and current-renderer fixes.

@propr-dev

propr-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

ℹ️ No authorized review findings were selected.

No files were changed because this /fix command did not select an actionable F# finding. Suggestions require a separate ordinary follow-up request.

View Task Execution


Processing comment ID: 5545902141✓

@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Complete the remaining CSP lifecycle gaps on fece985:

  1. rendererPolicyPinnedForSmoke is still defined as rendererPolicyOrigins.length > 0 && packagedSmokeTest. That is false for PROPR_DESKTOP_CONNECT_SMOKE_TEST and transport smoke, so startup still overwrites their explicitly seeded origins and installs dynamic reconciliation. Define pinning from the explicit smoke modes themselves: transportSmoke, connectSmoke.journeyEndpoint, or an authorized packaged smoke profile origin. Prove Connect and transport smoke skip the persisted-profile startup read and omit the callback; rerun all four Darwin/Linux Packaged Connect journeys.
  2. authenticationPair still delegates directly. A successful commitPairedProfile can clear activeProfileId when re-pairing an active profile at a changed origin. Await pair and reconcile authoritative state afterward; add a focused test expecting null.
  3. The first profile-save test still unrealistically returns activeProfileId profile-a after an origin-changing save. Match saveAndDetachCredential semantics by returning null and assert null reconciliation. Preserve the F2/F3 concurrency and current-renderer fixes.

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 1f4f3bf

Summary of Changes

Implemented the remaining CSP lifecycle fixes:

  • Smoke policy pinning now derives from transport smoke, Connect journey endpoint, or an authorized packaged smoke profile origin.
  • Successful authenticationPair calls now await pairing and reconcile authoritative active-profile state.
  • Added changed-origin active re-pair coverage expecting null.
  • Corrected the origin-changing profile-save test to reconcile null.
  • Preserved F2/F3 concurrency and current-renderer behavior.

Changed files: main.ts, ipc.ts, ipc-lifecycle.test.ts, and smoke-test-authorization.test.ts.

Validation:

  • Focused lifecycle tests: 23 passed.
  • Desktop typecheck: passed.
  • Full desktop suite: 485 passed, 25 platform-specific skipped.
  • Linux x64 package and packaged artifact/fuse inspection: passed.
  • git diff --check: passed.

The four target-native Darwin/Linux journeys could not be run on this Linux x64 runner: Darwin x64/arm64 and Linux arm64 require their native CI runners, while the local Linux journey also lacks Xvfb and gnome-keyring. No preview was created because the changes are not visually perceptible.


🤖 Implementation Details

  • Model: GPT-5.6 Sol (high)
  • Requested By: @integry
  • Time: 8m 3s
  • Tokens: 3,342,292 (3,328,755 in / 13,537 out)
  • Cost: $2.59

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Implement fixes for issues found by /review /fix or /fix address the null check issue
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 5545905906✓

Implemented the remaining CSP lifecycle fixes:

- Smoke policy pinning now derives from transport smoke, Connect journey endpoint, or an authorized packaged smoke profile origin.
- Successful `authenticationPair` calls now await pairing and reconcile authoritative active-profile state.
- Added changed-origin active re-pair coverage expecting `null`.
- Corrected the origin-changing profile-save test to reconcile `null`.
- Preserved F2/F3 concurrency and current-renderer behavior.

Changed files: [main.ts](/tmp/git-processor/worktrees/integry/propr/pr-2120-followup-2026-09-04T20-10-36/apps/desktop/src/main.ts:1169), [ipc.ts](/tmp/git-processor/worktrees/integry/propr/pr-2120-followup-2026-09-04T20-10-36/apps/desktop/src/ipc.ts:168), [ipc-lifecycle.test.ts](/tmp/git-processor/worktrees/integry/propr/pr-2120-followup-2026-09-04T20-10-36/apps/desktop/src/ipc-lifecycle.test.ts:25), and [smoke-test-authorization.test.ts](/tmp/git-processor/worktrees/integry/propr/pr-2120-followup-2026-09-04T20-10-36/apps/desktop/src/smoke-test-authorization.test.ts:172).

Validation:

- Focused lifecycle tests: 23 passed.
- Desktop typecheck: passed.
- Full desktop suite: 485 passed, 25 platform-specific skipped.
- Linux x64 package and packaged artifact/fuse inspection: passed.
- `git diff --check`: passed.

The four target-native Darwin/Linux journeys could not be run on this Linux x64 runner: Darwin x64/arm64 and Linux arm64 require their native CI runners, while the local Linux journey also lacks Xvfb and gnome-keyring. No preview was created because the changes are not visually perceptible.

PR: #2120
Comment by: @integry (ID: 5545905906)
Model: gpt-5.6-sol
@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-5.6-sol

Overall Evaluation

This PR substantially improves packaged-renderer CSP by replacing scheme-wide cleartext access with normalized loopback origins and synchronizing policy changes with profile lifecycle operations. It needs a localized security correction before merge; 23 checks also remain pending.

✅ Exact cleartext scoping — rendererContentSecurityPolicy admits only normalizer-approved HTTP origins and their corresponding WebSocket origins.

✅ Safe renderer replacement — The generation-based reloader resolves the current webContents only when the latest scheduled reload fires.

✅ Smoke-policy isolation — Transport, Connect-journey, and authorized profile smoke modes preserve their seeded policies without installing dynamic reconciliation.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F4: 🔴 Reconciliation failures retain stale origins

  • Required behavior: The packaged CSP must reflect the authoritative active loopback profile or fail closed when that state cannot be determined. After a successful mutation, a failed profile read currently leaves the previous cleartext origin in rendererPolicyOrigins.
  • Evidence: apps/desktop/src/ipc.ts:117 — reconcileRendererActiveProfile awaits credentials.listProfiles() before invoking the policy callback; if that read rejects after saveProfile, removeProfile, setActiveProfile, or pair has committed, the callback is never invoked and the prior policy remains installed.
  • Minimum fix: Catch an authoritative profile-read failure inside reconciliation, publish null to clear the renderer’s cleartext policy and schedule its reload, then rethrow the original error. Add a focused post-commit read-failure test verifying that the callback receives null.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Add executable smoke pinning tests

The smoke authorization tests inspect main.ts using substring ordering. Executable startup tests with instrumented credentials could directly prove that transport and Connect journey modes perform no extra listProfiles calls and install no reconciliation callback. This is optional because the current implementation’s guards are clear and the packaged journey checks are already pending.

Score

The core CSP design and lifecycle coverage are strong, but the post-commit failure path can leave a stale cleartext origin installed and must be made fail-closed. Current checks report no failures, although most remain pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-5.6 Sol
  • Time: 2m 1s
  • Tokens: 59,468 (53,267 in / 6,201 out)
  • Cost: $0.45

View Task


💡 Next step: Comment /fix to address F# merge blockers only.
F# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. Suggestions require a separate ordinary follow-up request.

🤖 Review by ProPR

@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/fix F4

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit d85fd53

Addressed 1 AI review comment (IDs: 5546029099)

Summary of Changes

Implemented F4 only.

  • Reconciliation now publishes null when the authoritative profile read fails, clearing stale cleartext CSP origins before rethrowing.
  • Added a post-save commit regression test verifying the callback receives null.
  • No visual preview generated; behavior is not user-visible.

Validation:

  • Desktop typecheck passed.
  • Desktop suite: 486 passed, 25 skipped, 0 failed.
  • git diff --check passed.
  • Changes were not committed, as requested.

🤖 Implementation Details

  • Model: GPT-5.6 Sol (high)
  • Requested By: @integry
  • Time: 3m 38s
  • Tokens: 403,046 (399,348 in / 3,698 out)
  • Cost: $0.96

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Implement fixes for issues found by /review /fix or /fix address the null check issue
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 5546036208✓

Implemented F4 only.

- Reconciliation now publishes `null` when the authoritative profile read fails, clearing stale cleartext CSP origins before rethrowing.
- Added a post-save commit regression test verifying the callback receives `null`.
- No visual preview generated; behavior is not user-visible.

Validation:

- Desktop typecheck passed.
- Desktop suite: 486 passed, 25 skipped, 0 failed.
- `git diff --check` passed.
- Changes were not committed, as requested.

PR: #2120
Comment by: @integry (ID: 5546036208)
Model: gpt-5.6-sol
@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-5.6-sol

Overall Evaluation

The PR substantially improves packaged-renderer CSP handling, but it needs a small correctness fix before merge because concurrent reconciliation reads can publish stale policy state.

✅ Exact cleartext scoping — Production CSP generation removes scheme-wide HTTP/WS access and admits only normalized loopback HTTP origins and their corresponding WebSocket origins.

✅ Fail-closed lifecycle handling — Startup initializes the policy before window creation, smoke policies remain pinned, and failed authoritative reads clear the dynamic policy.

✅ Renderer-safe reloads — Delayed reloads resolve the current mainWindow.webContents and coalesce overlapping scheduled reloads without retaining an IPC sender.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F5: 🔴 Stale reconciliation can win

  • Required behavior: Dynamic CSP reconciliation must reflect the latest authoritative active profile after overlapping mutations; an older asynchronous read must not overwrite a newer policy.
  • Evidence: apps/desktop/src/ipc.ts:113 — reconcileRendererActiveProfile independently awaits credentials.listProfiles() and then unconditionally publishes its result, with no generation or ordering guard. If an earlier read resolves after a later mutation’s read, it can overwrite the newer origin; apps/desktop/src/main.ts:1294 then accepts that stale callback as the latest policy state and schedules a reload for it.
  • Minimum fix: Add a monotonic reconciliation generation so only the most recently started reconciliation may publish either its resolved origin or its fail-closed null. Add a test where the first profile read is delayed, a second reconciliation publishes a newer origin, and the first then resolves or rejects without changing that newer policy.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Prefer behavioral smoke coverage

The smoke authorization tests inspect main.ts using string positions. This verifies the current source layout but could miss a later unguarded profile read or callback registration elsewhere. A startup test with mocked credentials and IPC registration would more directly prove that transport and Connect journey modes perform no dynamic reads or callback installation. This is optional because the present guards themselves are correct.

Score

The core security design and most lifecycle transitions are well implemented, but the out-of-order reconciliation race can leave the renderer with a stale cleartext allowlist or block its actual active endpoint. Pending checks should also complete after the localized correction.

Score: 6/10


🤖 Review Details

  • Model: GPT-5.6 Sol
  • Time: 2m 34s
  • Tokens: 69,127 (60,847 in / 8,280 out)
  • Cost: $0.50

View Task


💡 Next step: Comment /fix to address F# merge blockers only.
F# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. Suggestions require a separate ordinary follow-up request.

🤖 Review by ProPR

@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/fix F5

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit c0bcb4c

Addressed 1 AI review comment (IDs: 5546127517)

Summary of Changes

Implemented F5 only.

  • Added a monotonic reconciliation generation in ipc.ts.
  • Stale successful reads and stale failures can no longer overwrite the latest renderer policy.
  • Added race tests covering both delayed resolution and rejection in ipc-lifecycle.test.ts.

Verification:

  • IPC lifecycle tests: 17 passed
  • Desktop TypeScript check: passed
  • git diff --check: passed

No visual preview was created because this change is not user-visible. No commit was made.


🤖 Implementation Details

  • Model: GPT-5.6 Sol (high)
  • Requested By: @integry
  • Time: 3m 13s
  • Tokens: 516,959 (512,171 in / 4,788 out)
  • Cost: $0.64

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Implement fixes for issues found by /review /fix or /fix address the null check issue
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 5546142663✓

Implemented F5 only.

- Added a monotonic reconciliation generation in [ipc.ts](/tmp/git-processor/worktrees/integry/propr/pr-2120-followup-2026-09-04T20-34-37/apps/desktop/src/ipc.ts:85).
- Stale successful reads and stale failures can no longer overwrite the latest renderer policy.
- Added race tests covering both delayed resolution and rejection in [ipc-lifecycle.test.ts](/tmp/git-processor/worktrees/integry/propr/pr-2120-followup-2026-09-04T20-34-37/apps/desktop/src/ipc-lifecycle.test.ts:135).

Verification:

- IPC lifecycle tests: 17 passed
- Desktop TypeScript check: passed
- `git diff --check`: passed

No visual preview was created because this change is not user-visible. No commit was made.

PR: #2120
Comment by: @integry (ID: 5546142663)
Model: gpt-5.6-sol
@integry

integry commented Sep 4, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-5.6-sol

Overall Evaluation

The PR substantially improves packaged-renderer CSP isolation, but it needs one localized error-path correction before merge. Current checks have no reported failures, though most remain pending.

✅ Exact cleartext scoping — Production CSP generation admits only normalized loopback HTTP origins and their corresponding WebSocket origins.

✅ Authoritative lifecycle updates — Successful profile mutations reconcile against persisted active-profile state, with generation guards preventing stale reads from publishing obsolete policies.

✅ Smoke policy stability — Transport, Connect journey, and authorized profile smoke modes retain pinned policies without additional profile reads or dynamic callbacks.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F6: 🔴 Reconcile when activation rollback fails

  • Required behavior: After an activation has committed, every failure path must leave the dynamically managed renderer CSP either synchronized with authoritative state or conservatively cleared.
  • Evidence: apps/desktop/src/ipc.ts:202 — the activation catch block awaits discardActivation() before reaching reconciliation, and only reconciles when it returns discarded: true. If rollback rejects—or returns false after state has changed—the handler exits without updating the policy, leaving the pre-activation origin installed despite uncertain post-commit state.
  • Minimum fix: Run authoritative reconciliation, with its existing fail-closed null behavior, in a finally around the rollback attempt and regardless of the discarded result. Preserve the operation rejection and add focused coverage for rollback rejection.

Suggestions

These are optional follow-ups and are not sent to /fix.

No suggestions.

Score

The main security design and normal lifecycle handling are strong, but the uncovered post-commit failure path can leave the new CSP state inconsistent and must be corrected before merge.

Score: 6/10


🤖 Review Details

  • Model: GPT-5.6 Sol
  • Time: 3m 12s
  • Tokens: 62,613 (52,290 in / 10,323 out)
  • Cost: $0.57

View Task


💡 Next step: Comment /fix to address F# merge blockers only.
F# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. Suggestions require a separate ordinary follow-up request.

🤖 Review by ProPR

@integry
integry merged commit 5f168b9 into 1953-epic-desktop-transport-api Sep 4, 2026
27 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant