Skip to content

feat(hooks): add managed hooks#15937

Open
viyatb-oai wants to merge 9 commits intocodex/viyatb/hooks-trust-precedencefrom
codex/viyatb/hook-safety-controls
Open

feat(hooks): add managed hooks#15937
viyatb-oai wants to merge 9 commits intocodex/viyatb/hooks-trust-precedencefrom
codex/viyatb/hook-safety-controls

Conversation

@viyatb-oai
Copy link
Copy Markdown
Collaborator

@viyatb-oai viyatb-oai commented Mar 27, 2026

Summary

Adds a managed-policy control for lifecycle hooks and surfaces a startup warning when hooks are loaded.

Changes

  • Add allow_managed_hooks_only / allowManagedHooksOnly to config requirements and app-server protocol surfaces.
  • Apply the new requirement to requirements.toml, MDM-managed requirements_toml_base64, and cloud requirements; legacy managed_config.toml remains limited to approval_policy and sandbox_mode.
  • Skip non-managed hooks.json files when the managed-only requirement is enabled.
  • Emit a startup warning that hooks run arbitrary shell commands outside the sandbox and list the loaded hooks.json files.
  • Show the new requirement in TUI debug config output and document it in docs/config.md.

Why

Hooks are privileged by design and run outside the sandbox. This makes that behavior explicit at startup and gives admins a lockdown option that still allows managed hooks.

@viyatb-oai viyatb-oai changed the title [codex] add managed hooks lockdown feat(hooks): add managed hooks Mar 27, 2026
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch from f29a621 to a16d990 Compare March 27, 2026 19:49
@viyatb-oai viyatb-oai changed the base branch from main to codex/viyatb/hooks-trust-precedence March 27, 2026 19:50
@eternal-openai
Copy link
Copy Markdown
Contributor

Thanks for this, looks very directionally correct and spec adherent -- will review again later when you think it's out of draft mode

@viyatb-oai viyatb-oai marked this pull request as ready for review March 30, 2026 17:21
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hooks-trust-precedence branch from 9401e5f to f0f222a Compare March 31, 2026 04:39
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch from a16d990 to 6c5ea83 Compare March 31, 2026 04:40
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hooks-trust-precedence branch from f0f222a to 456697a Compare April 6, 2026 19:40
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch from 6c5ea83 to b7976a4 Compare April 6, 2026 19:40
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hooks-trust-precedence branch from 456697a to c564cda Compare April 7, 2026 03:04
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch from b7976a4 to 4f8689d Compare April 7, 2026 03:06
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hooks-trust-precedence branch from c564cda to 647f61a Compare April 7, 2026 03:41
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch from 4f8689d to 36587f3 Compare April 7, 2026 03:42
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hooks-trust-precedence branch from 647f61a to c22dec5 Compare April 7, 2026 03:53
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch 2 times, most recently from 1a06341 to 85609af Compare April 7, 2026 04:09
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hooks-trust-precedence branch from 15872f2 to 6b3ef89 Compare April 7, 2026 04:45
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch from 85609af to e00bbff Compare April 7, 2026 04:45
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hooks-trust-precedence branch from 6b3ef89 to d22f07a Compare April 7, 2026 17:59
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch from e00bbff to b7f9332 Compare April 7, 2026 18:00
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hooks-trust-precedence branch from d22f07a to 8110afa Compare April 7, 2026 19:25
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch 2 times, most recently from 50ae0cd to 513683c Compare April 7, 2026 21:05
viyatb-oai and others added 4 commits April 7, 2026 14:48
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/hook-safety-controls branch from 513683c to 5ab034b Compare April 7, 2026 21:49
Copy link
Copy Markdown
Contributor

@eternal-openai eternal-openai left a comment

Choose a reason for hiding this comment

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

Amazing work !

viyatb-oai and others added 2 commits April 17, 2026 18:15
eternal-openai added a commit that referenced this pull request Apr 23, 2026
## Summary

Support the existing hooks schema in inline TOML so hooks can be
configured from both `config.toml` and enterprise-managed
`requirements.toml` without requiring a separate `hooks.json` payload.

This gives enterprise admins a way to ship managed hook policy through
the existing requirements channel while still leaving script delivery to
MDM or other device-management tooling, and it keeps `hooks.json`
working unchanged for existing users.

This also lays the groundwork for follow-on managed filtering work such
as #15937, while continuing to respect project trust gating from #14718.
It does **not** implement `allow_managed_hooks_only` itself.

NOTE: yes, it's a bit unfortunate that the toml isn't formatted as
closely as normal to our default styling. This is because we're trying
to stay compatible with the spec for plugins/hooks that we'll need to
support & the main usecase here is embedding into requirements.toml

## What changed

- moved the shared hook serde model out of `codex-rs/hooks` into
`codex-rs/config` so the same schema can power `hooks.json`, inline
`config.toml` hooks, and managed `requirements.toml` hooks
- added `hooks` support to both `ConfigToml` and
`ConfigRequirementsToml`, including requirements-side `managed_dir` /
`windows_managed_dir`
- treated requirements-managed hooks as one constrained value via
`Constrained`, so managed hook policy is merged atomically and cannot
drift across requirement sources
- updated hook discovery to load requirements-managed hooks first, then
per-layer `hooks.json`, then per-layer inline TOML hooks, with a warning
when a single layer defines both representations
- threaded managed hook metadata through discovered handlers and exposed
requirements hooks in app-server responses, generated schemas, and
`/debug-config`
- added hook/config coverage in `codex-rs/config`, `codex-rs/hooks`,
`codex-rs/core/src/config_loader/tests.rs`, and
`codex-rs/core/tests/suite/hooks.rs`

## Testing

- `cargo test -p codex-config`
- `cargo test -p codex-hooks`
- `cargo test -p codex-app-server config_api`

## Documentation

Companion updates are needed in the developers website repo for:

- the hooks guide
- the config reference, sample, basic, and advanced pages
- the enterprise managed configuration guide

---------

Co-authored-by: Michael Bolin <mbolin@openai.com>
morozow pushed a commit to morozow/codex that referenced this pull request Apr 23, 2026
## Summary

Support the existing hooks schema in inline TOML so hooks can be
configured from both `config.toml` and enterprise-managed
`requirements.toml` without requiring a separate `hooks.json` payload.

This gives enterprise admins a way to ship managed hook policy through
the existing requirements channel while still leaving script delivery to
MDM or other device-management tooling, and it keeps `hooks.json`
working unchanged for existing users.

This also lays the groundwork for follow-on managed filtering work such
as openai#15937, while continuing to respect project trust gating from openai#14718.
It does **not** implement `allow_managed_hooks_only` itself.

NOTE: yes, it's a bit unfortunate that the toml isn't formatted as
closely as normal to our default styling. This is because we're trying
to stay compatible with the spec for plugins/hooks that we'll need to
support & the main usecase here is embedding into requirements.toml

## What changed

- moved the shared hook serde model out of `codex-rs/hooks` into
`codex-rs/config` so the same schema can power `hooks.json`, inline
`config.toml` hooks, and managed `requirements.toml` hooks
- added `hooks` support to both `ConfigToml` and
`ConfigRequirementsToml`, including requirements-side `managed_dir` /
`windows_managed_dir`
- treated requirements-managed hooks as one constrained value via
`Constrained`, so managed hook policy is merged atomically and cannot
drift across requirement sources
- updated hook discovery to load requirements-managed hooks first, then
per-layer `hooks.json`, then per-layer inline TOML hooks, with a warning
when a single layer defines both representations
- threaded managed hook metadata through discovered handlers and exposed
requirements hooks in app-server responses, generated schemas, and
`/debug-config`
- added hook/config coverage in `codex-rs/config`, `codex-rs/hooks`,
`codex-rs/core/src/config_loader/tests.rs`, and
`codex-rs/core/tests/suite/hooks.rs`

## Testing

- `cargo test -p codex-config`
- `cargo test -p codex-hooks`
- `cargo test -p codex-app-server config_api`

## Documentation

Companion updates are needed in the developers website repo for:

- the hooks guide
- the config reference, sample, basic, and advanced pages
- the enterprise managed configuration guide

---------

Co-authored-by: Michael Bolin <mbolin@openai.com>
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.

2 participants