Skip to content

feat(plugins): bind worker and panel approval to exact bytes and recheck before every start - #30637

Merged
nwparker merged 9 commits into
mainfrom
nwparker/plugins-v2-2-approval
Oct 28, 2026
Merged

nwparker merged 9 commits into
mainfrom
nwparker/plugins-v2-2-approval

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​482 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​461
Prod 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​206 $\color{#cf222e}{\Huge{\mathbf{−}}}$​69 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​137

ELI5

When you approve a plugin that runs code (a background worker or a panel), the approval now covers those exact files. If the files change, Orca asks you to look again before running them. Each time a worker starts or restarts after a crash, Orca first checks that its files are still the ones you approved. When a plugin updates while its worker is running, the worker restarts on the new code instead of staying stopped.

What Changed

1. Approval tied to exact files (plugin-consent-fingerprint.ts, plugin-discovery.ts)

  • Before: approval for a worker or panel plugin covered only its permissions and whether it had a worker. An update could swap the plugin's code without asking again.
  • After: the approval also names the content hash of the installed files. This applies to v2 plugins with a panel or worker profile and to v1 plugins with a worker or panel. Any update to their files means approving again.
  • Unchanged: data-only plugins keep their current approvals. Plugins loaded from a local development folder aren't tied to their files, so saving a file doesn't re-prompt.

2. Integrity check before every start (plugin-worker-manager.ts, plugin-worker-startup.ts, plugin-worker-controller.ts)

  • Before: the content check ran once and was cached. Files changed between a crash and its automatic restart still ran.
  • After: the controller gives the manager one uncached check. It runs before every start, including crash restarts, and replaces the old cached first check, so nothing is hashed twice. A worker that is already running is reused without re-hashing.
  • Approval: approval is re-checked at the same points. A plugin whose approval is revoked stops restarting instead of counting as a crash.
  • Stopping: stopping a worker doesn't wait for a check that is still running.

3. Restart on update (plugin-worker-controller.ts)

  • Before: an update stopped a running worker, which stayed stopped until the next command or event.
  • After: once a refresh has stopped every worker that changed, it restarts each one that was running, once, on the new code, through the same approval and integrity check. The restart is skipped if Orca is shutting down or a newer refresh has started. Workers that weren't running stay stopped until something needs them.

Why

  • Tie approval to bytes. Without it, approving a plugin once lets every later update run new code silently. That is the main risk the approval step exists to stop. Asking existing worker and panel plugins to approve again once is an acceptable cost while the feature is experimental.
  • Integrity check, not a sandbox. Node still reads files after the check, so a local process with write access can race it. What the check does catch is swapped or corrupted files between restarts, at the cost of one hash per actual start.
  • Restart only workers that were running. Restarting every installed worker after a refresh would wake plugins nobody is using.

Linked Issue

None — this is part of the plugin platform rework (maintainer change).

Visual Proof

The only visible change is the re-approval notice in the plugin review dialog, now one short line.

  • Before: "Permissions, the worker trust tier, or instructional content changed since you last reviewed this plugin. Review it again before it can run."
  • After: "This plugin changed since you approved it. Review it to run it again."
  • Translations: updated in all six bundled languages.

The layout, the dialog, and when it appears are unchanged; it now also appears after an update to a worker or panel plugin's files.

Testing

  • Approval tests: a changed file hash requires approving again for v1/v2 workers and panels; data packs stay approved. Discovery gives an installed v2 worker a new approval identity when its files change.

  • Worker tests:

    • Files changed between start and crash restart are refused before a new process starts.
    • A plugin whose approval is revoked during the check never starts.
    • A running worker restarts once on its updated files, and not again on an unchanged refresh.
    • Shutting down during that restart doesn't leave a worker running.
  • Updated tests: existing tests now use the new approval identity. They approve an updated bundled worker the way a user would, or verify the integrity check at start time.

  • Dialog test: updated for the new notice.

  • Platforms: macOS, run locally; Linux and Windows run in CI.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: an approval no longer covers code the user didn't see. A tamper check runs before every worker start.
  • Compatibility: existing worker and panel plugins ask for approval once after this ships. Nothing on the wire changes; approval values stay opaque strings.
  • SSH and remote hosts: the host that runs the worker does the checks.
  • Performance: one content hash per worker start (not per command). A refresh now waits for the restarts it triggers.
  • Depends on: PR1 (manifest v2 profiles and pinned releases), which depends on the stdin fix PR.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason — copy change described above; screenshot not captured
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — plugin tests, check:code-quality:changed, pnpm tc:node and tc:web pass; CI covers the rest

@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch from 1d1caf5 to 723ffee Compare October 19, 2026 11:01
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch from 27af974 to 226c0a1 Compare October 19, 2026 12:07
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch from 723ffee to 0db147c Compare October 19, 2026 12:07
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch from 226c0a1 to 8f9a8a3 Compare October 19, 2026 21:41
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch from 0db147c to 9fc2023 Compare October 19, 2026 21:41
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch from 8f9a8a3 to 880ad10 Compare October 21, 2026 06:29
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch from 9fc2023 to f828fed Compare October 21, 2026 06:30
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch from 880ad10 to 54639b8 Compare October 21, 2026 12:22
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch from f828fed to dc669ca Compare October 21, 2026 12:22
@nwparker
nwparker marked this pull request as ready for review October 21, 2026 12:24
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch from 54639b8 to dfff513 Compare October 21, 2026 20:09
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch from dc669ca to c3cce13 Compare October 21, 2026 20:09
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch from dfff513 to b324ef1 Compare October 24, 2026 11:42
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch 2 times, most recently from b90df10 to f27a26e Compare October 25, 2026 05:23
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch 2 times, most recently from c4aafc0 to a22710d Compare October 26, 2026 12:04
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch from f27a26e to 7a56a37 Compare October 26, 2026 12:04
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch from a22710d to 96880d1 Compare October 28, 2026 04:57
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch 2 times, most recently from dce92a3 to b7a4a3c Compare October 28, 2026 05:29
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch from 96880d1 to df3870b Compare October 28, 2026 10:53
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch from b7a4a3c to 00d3122 Compare October 28, 2026 10:53
@nwparker
nwparker force-pushed the nwparker/plugins-v2-1-manifest-git branch from df3870b to 2c1552c Compare October 28, 2026 20:21
@nwparker
nwparker changed the base branch from nwparker/plugins-v2-1-manifest-git to main October 28, 2026 20:37
Consent for any plugin that runs code (a v2 sandboxed-ui or trusted-worker
profile, or a v1 manifest with a worker or panel) now names its installed
content hash, so an update cannot swap code under an old approval. Shipped
v1 installs re-prompt once. Data packs keep their fingerprints, and dev
trees stay unbound so a save doesn't re-prompt. The re-review notice is one
short line.
The content verifier cached its first check, so bytes swapped between a
crash and its restart still ran. The controller now hands the manager one
uncached verifyBeforeSpawn hook that runs before every spawn, including
crash restarts, and replaces the cached first-start check, so nothing is
hashed twice and a running worker is reused without hashing. It is an
integrity check, not a sandbox: Node still reads files after it. Approval
is re-asserted at the same points, so a revoked plugin stops restarting
instead of counting as a crash, and cancellation does not wait on a hash.
A refresh that changes a running worker's spec used to stop it and wait for
the next command or event. Reconcile now restarts it once on the new spec
after every stop, through the same approval and integrity path, and skips
the restart if a newer reconcile or dispose has taken over. Idle workers
stay lazy.
Approval of worker and panel plugins now names their exact bytes, so
switching the demo plugin from its installed copy to the dev folder asks
for review again; the journey approves the dev copy before using it.
@nwparker
nwparker force-pushed the nwparker/plugins-v2-2-approval branch from 00d3122 to 2e3e915 Compare October 28, 2026 20:38
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e2299550-f99d-4606-9d33-031b6353c6df
Commits

Reviewing files that changed from the base of the PR and between 6ccc67b and 4617ab6.

Files selected for processing: 6
  • config/flaky-test-pattern-baseline.txt
  • src/main/plugins/plugin-git-repository.integration.test.ts
  • src/main/plugins/plugin-git-repository.ts
  • src/main/plugins/plugin-service.ts
  • src/main/plugins/plugin-worker-controller.test.ts
  • src/main/plugins/plugin-worker-controller.ts
Walkthrough

Consent fingerprints now include executable plugin content, and worker specifications carry reviewed content hashes. Worker activation verifies current approval and content before spawning, while reconciliation can restart running workers when their specifications change. Git subprocesses restrict allowed protocols. The changes also update consent messaging and add tests for content approval, worker lifecycle behavior, and Git checkout behavior.

Priority: Normal

Merge Risk: Low · previous review 6ccc6

This change binds plugin approval to the installed file bytes and re-checks them before every worker start. The one remaining concern is minor. A stricter Git protocol allowlist set in Orca's environment would be widened to allow SSH. Merging is low risk, and the allowlist can be intersected in a follow-up.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes binding plugin approval to exact bytes and rechecking integrity before worker starts.
Description check Passed The description covers the required sections, explains the user impact and implementation, documents testing and platform coverage, and records the remaining CI checks. It omits visual attachments and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description covers the required sections, explains the user impact and implementation, documents testing and platform coverage, and records the remaining CI checks. It omits visual attachments and an issue link, but identifies the change as maintainer work and explains the UI change in text.

Full details: Docstring Coverage

Explanation

Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 24 files. (6 skipped: 6 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[High impact] The PR changes approval and start checks for executable plugins.

The PR still needs the earlier fix for workers that call the host while restarting during a refresh.

Findings

  1. P1 Refresh breaks worker startup ▶

Summary

The PR ties installed worker and panel approval to their exact files and checks worker files before every start.

  • Worker and panel approvals now identify the installed plugin bytes.
  • Workers check their approved bytes and approval before every start.
  • Refresh restarts active workers once when their approved version changes.
  • Plugin downloads use only HTTPS and SSH Git transports.
  • The flaky-test baseline keeps the same entries in updated order.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Worker start or crash restart] --> B[Check approval]
  B --> C[Wait for worker slot]
  C --> D[Check exact files]
  D --> E[Recheck approval]
  E --> F[Start worker]
  G[Refresh finds changed worker] --> H[Stop old worker]
  H --> A
Loading

Reviews (3) · Last reviewed commit: "test(plugins): shrink the flaky-test bas..." · Reviewed by Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9457fa8f-2268-4d12-ba26-c4d30658be01
Commits

Reviewing files that changed from the base of the PR and between 6c54b4f and 6ccc67b.

Files selected for processing: 30
  • src/main/plugins/__mocks__/plugin-uninstall-log-test-fixture.ts
  • src/main/plugins/plugin-content-integrity.ts
  • src/main/plugins/plugin-discovery.test.ts
  • src/main/plugins/plugin-discovery.ts
  • src/main/plugins/plugin-git-repository.integration.test.ts
  • src/main/plugins/plugin-git-repository.ts
  • src/main/plugins/plugin-service-integrity.test.ts
  • src/main/plugins/plugin-service-reconciliation.test.ts
  • src/main/plugins/plugin-service.ts
  • src/main/plugins/plugin-uninstall-log-retention.test.ts
  • src/main/plugins/plugin-uninstall-ordering.test.ts
  • src/main/plugins/plugin-worker-controller.test.ts
  • src/main/plugins/plugin-worker-controller.ts
  • src/main/plugins/plugin-worker-manager.ts
  • src/main/plugins/plugin-worker-reconciliation.ts
  • src/main/plugins/plugin-worker-refresh-admission.test.ts
  • src/main/plugins/plugin-worker-reviewed-content.test.ts
  • src/main/plugins/plugin-worker-spawn-spec.ts
  • src/main/plugins/plugin-worker-startup.ts
  • src/renderer/src/components/settings/PluginConsentDialog.test.tsx
  • src/renderer/src/components/settings/PluginConsentDialog.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/plugins/plugin-consent-fingerprint.test.ts
  • src/shared/plugins/plugin-consent-fingerprint.ts
  • tests/e2e/plugin-demo.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

…s before awaiting refresh on shutdown, and narrow inherited Git protocol allowlists
isCurrentApproved: (plugin) =>
this.findValidPlugin(plugin.pluginKey) === plugin && this.canStartPluginWork(plugin),
isCurrentApproved: (spec) => isApprovedWorkerSpec(spec, resolveApproved(spec.pluginKey)),
isApprovalKept: (spec) => isApprovedWorkerSpec(spec, resolveApproved(spec.pluginKey, true)),

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 Refresh breaks worker startup

isApprovalKept now lets a crashed worker restart while contentPacksReady is false. But its host calls still use getGrantedCapabilities, which returns null during that pause. A plugin that awaits orca.host.call() during activation therefore gets consent_required despite still being approved.

An uncaught rejection ends activation and counts as another crash. A slow refresh can exhaust the remaining retries, and the unchanged refresh then skips that worker instead of recovering it. Wait for the pause to end before starting the worker, or keep its approved host calls available through the same pause.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Leaving as is: the refresh pause denies host calls to every running worker, not just restarts, and lasts one file reread; a restart that lands in it now fails one attempt and backs off instead of ending recovery outright.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed. The refresh pause also denies host calls to workers that were already running, and a restart that hits the pause gets the normal retry/backoff rather than failing recovery immediately. Given the pause is limited to the refresh reread, leaving this as-is is reasonable; my earlier comment overstated the restart-specific impact.

@nwparker
nwparker merged commit 9015f13 into main Oct 28, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant