Skip to content

fix(agent-hooks): managed agent hooks require explicit opt-in - #20691

Open
unempyd wants to merge 1 commit into
stablyai:mainfrom
unempyd:upstream/E
Open

unempyd wants to merge 1 commit into
stablyai:mainfrom
unempyd:upstream/E

Conversation

@unempyd

@unempyd unempyd commented Sep 14, 2026

Copy link
Copy Markdown

ELI5

Orca used to install hooks into 14 other tools' configuration files automatically, on boot, unless you'd explicitly turned that off. If the setting was ever missing or unreadable, it installed anyway. Now it only installs if you've explicitly turned it on.

What Changed

Hooks were installed into other tools' user-global configs on boot; agentStatusHooksEnabled defaulted to true and every check used !== false, so an unset or unreadable setting installed (default-global-settings.ts:211, managed-agent-hook-controls.ts:40-52; #9963). Three call sites in runtime-client-settings.ts (the change-detection before value, and both inside reconcileManagedAgentHooks) still used the same !== false fail-open pattern even in places that should have matched the already-correct isAgentStatusHooksEnabled helper (=== true).

agentStatusHooksEnabled now defaults to false, and every one of these gates is === true: an absent, null, or unreadable setting installs nothing.

Why

Writing into another tool's user-global configuration file is not something that should happen from an absent or unreadable setting — an unset opt-in is not consent. This matches AGENTS.md's documented rule for this codebase: consent is denied by default and fail-closed.

Linked Issue

Related to #9963 (the same issue tracking the shipped-defaults residuals in this area).

Testing

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

constants.test.ts pins the new default (agentStatusHooksEnabled is false). runtime-client-settings-agent-status-hooks-consent.test.ts: an absent agentStatusHooksEnabled plus a disabled-agent update must not call applyAgentStatusHooksEnabled with true, and its shouldContinue callback must also treat unset hooks as disabled, not enabled. On main:

expected 'install' to be 'skip'

Ran: both test files above, every other test file under src/main/agent-hooks/, the touched src/main/ipc/ and src/main/ssh/ fixture files (which construct settings objects this default flows through), and pnpm run tc:node. 95 files / 1025 tests pass. Tested on macOS only; no OS-specific code touched.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Policy change, flagged plainly: this flips agentStatusHooksEnabled's default from true to false, so an existing installation that relied on the implicit install will need the operator to opt in once (a UI toggle for this setting, if one doesn't already exist, is a natural follow-up). I believe default-off is correct for writing into another tool's config without ever asking, but recognize maintainers may prefer default-on for backward compatibility with existing installs. Happy to flip the default if preferred — the fail-closed === true gate at all three call sites is the part I'd ask to keep either way, since that's the part that was inconsistent with this codebase's own isAgentStatusHooksEnabled helper.

Security: this is the fix — installing hooks into other tools' configs now requires explicit, positively-recorded consent. Cross-platform: no OS-specific code touched. Remote SSH: not specific to this change. Mobile: not applicable. Backwards compatibility: no wire shape changed, only the default value of an existing setting and the strictness of three checks against it.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason — N/A, no UI change; backend default/consent-gate fix only.
  • 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) — ran targeted vitest + tc:node locally (see Testing); full pnpm lint/pnpm build left to CI.

Extracted from Odin (github.com/unempyd/odin), a derivative that closes Orca's residual orchestration and safety contracts; all of its changes are offered upstream.

POLICY CHANGE: this flips a previously-implicit default. See the Notes
section below before merging.

Why: hooks were installed into 14 other tools' user-global configs on boot;
`agentStatusHooksEnabled` defaulted to `true` and every check used
`!== false`, so an unset or unreadable setting installed
(`default-global-settings.ts:211`, `managed-agent-hook-controls.ts:40-52`;
stablyai#9963). Three call sites in `runtime-client-settings.ts` (the change-detection
`before`, and both inside `reconcileManagedAgentHooks`) still used the same
`!== false` fail-open check even after the default was fixed elsewhere,
letting a genuinely absent setting -- a load path that dropped it, or a
profile written before this field existed -- read as consent granted and
enter the install path.

Fix: `agentStatusHooksEnabled` defaults to `false`; every one of these gates
is `=== true`; an absent, `null`, or unreadable setting installs nothing.

Test: `constants.test.ts` pins the new default. `runtime-client-settings-
agent-status-hooks-consent.test.ts`: an absent `agentStatusHooksEnabled`
plus a disabled-agent update must not call `applyAgentStatusHooksEnabled`
with `true`, and its `shouldContinue` callback must also treat unset hooks
as disabled. On `main`:

```
expected 'install' to be 'skip'
```

Ran: both test files above, every other test file under
`src/main/agent-hooks/`, the touched `src/main/ipc/` and `src/main/ssh/`
fixture files (which construct settings objects this default flows
through), and `pnpm run tc:node`. All pass. Tested on macOS only; no
OS-specific code touched.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017xLuDWCWWWjzMm64rL13TR
@pullfrog

pullfrog Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Run failed. View the logs →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The change makes agentStatusHooksEnabled disabled by default. Disk settings, startup controls, runtime settings, and hook reconciliation now require an explicit true value. Tests verify disabled behavior for absent and default settings. Relay, PTY, SSH, and WSL fixtures now provide explicit enabled settings where their scenarios require hook-related plumbing.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 9e4cf

Existing profiles can retain managed hook installation after upgrade without a new opt-in. Handle legacy settings before merging the consent-policy change.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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. Analyzed 14 functions across 19 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: managed agent hooks now require explicit opt-in.
Description check ✅ Passed The description is mostly complete. It explains the policy change, implementation, rationale, linked issue, testing, platform coverage, risks, and checklist status. It omits the dedicated Visual Proof…
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.
  • Fix all pre-merge checks with AI

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.

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 46e940b4-d269-4377-83b3-283f04c8fd02

📥 Commits

Reviewing files that changed from the base of the PR and between 2acd2f4 and 9e4cff4.

📒 Files selected for processing (19)
  • src/cli/handlers/agent-hooks.ts
  • src/main/agent-hooks/managed-agent-hook-controls.test.ts
  • src/main/agent-hooks/managed-agent-hook-controls.ts
  • src/main/agent-hooks/wsl-hook-relay-live.integration.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts
  • src/main/ipc/pty-controller-spawn-admission.test.ts
  • src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts
  • src/main/ipc/pty-daemon-spawn-session-identity.test.ts
  • src/main/ipc/pty-hidden-at-spawn-mark.test.ts
  • src/main/ipc/pty-ipc-daemon-provider-fixtures.ts
  • src/main/ipc/pty-ipc-provider-fixtures.ts
  • src/main/ipc/pty-ipc-spawn-drivers.ts
  • src/main/ipc/pty-listener-teardown-and-orphans.test.ts
  • src/main/ipc/pty-serializer-settlement-mapping.test.ts
  • src/main/runtime/runtime-client-settings-agent-status-hooks-consent.test.ts
  • src/main/runtime/runtime-client-settings.ts
  • src/main/ssh/ssh-relay-session-test-fixtures.ts
  • src/shared/constants.test.ts
  • src/shared/default-global-settings.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.

agentYoloDefaultsMigrated: true,
agentStatusHooksEnabled: true,
// Why: installing managed hooks into other tools' configs needs explicit user consent.
agentStatusHooksEnabled: false,

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Handle legacy hook defaults as unconsented.

src/main/persistence/loading-store/normalize-loaded-global-settings.ts preserves stored agentStatusHooksEnabled: true values because the old boolean cannot distinguish the former default from explicit opt-in. The startup hook gate treats true as consent, so legacy profiles can continue installing managed hooks after upgrade. Reset legacy default-on values or add consent provenance before enabling hook installation.

This branch has not been deployed

No deployments
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