Trust the bundled Memory session hook without saved hashes (#62112)

## Why

The bundled Memory hook needs to supply context at startup and after compaction without requiring saved hook trust.

## What changed

Recognize the exact bundled Memory `SessionStart` declaration as a built-in hook: the `^(startup|compact)$` matcher, `codex_apps` server, `codex_dream_memory.get_mec` tool, and empty input. Carry the expected app connector identity through discovery for dispatch checks, and hide this built-in hook from hook listings while preserving other plugin hooks.

## Testing

Add coverage for exact declaration matching, hook listings without an Apps connection, and a scenario snapshot verifying memory context injection at startup and after compaction without saved trust.

GitOrigin-RevId: edc0e8ffa955227328345f46afecc2a868c0be49
This commit is contained in:
nvogt-oai
2026-11-17 21:40:36 +00:00
committed by copyberry
parent 8fca6ffb92
commit 39a7b53fa4
8 changed files with 305 additions and 11 deletions
+28 -2
View File
@@ -1,5 +1,5 @@
//! Temporary cleanup-hook allowlist shared by local and executor plugin discovery.
//! This narrowly authorizes known MCP cleanup calls; it does not verify plugin signatures.
//! Temporary bundled-hook exceptions. App session hooks require connector and policy checks
//! at dispatch; cleanup hooks retain their existing trust rules. This does not verify signatures.
use codex_config::HookHandlerConfig;
use codex_protocol::protocol::HookEventName;
@@ -111,6 +111,32 @@ const ALLOWLISTED_BUNDLED_HOOKS: &[BundledHook] = &[
},
];
/// Recognizes the bundled SessionStart declaration without starting Apps discovery.
/// The caller must check this connector's identity and approval policy at dispatch.
pub fn bundled_hook_app_connector_id(
plugin_id: &str,
event: HookEventName,
matcher: Option<&str>,
handler: &HookHandlerConfig,
) -> Option<&'static str> {
let HookHandlerConfig::McpTool {
server,
tool,
input,
..
} = handler
else {
return None;
};
(plugin_id == "codex-dream-memory@openai-bundled"
&& event == HookEventName::SessionStart
&& matcher == Some("^(startup|compact)$")
&& server == "codex_apps"
&& tool == "codex_dream_memory.get_mec"
&& input.is_empty())
.then_some("connector_openai_codex_dream_memory")
}
/// Matches a temporary unsigned cleanup exception. App targets additionally require the
/// connector identity for this handler's server and tool from the caller's enabled tool
/// catalog; callers without that catalog must pass `None`.
+1
View File
@@ -10,6 +10,7 @@ pub mod manifest;
use codex_core_plugin_common::plugin_id;
mod provider;
pub use bundled_hooks::bundled_hook_app_connector_id;
pub use bundled_hooks::is_allowlisted_bundled_cleanup_hook;
use codex_config::HookEventsToml;
use codex_utils_absolute_path::AbsolutePathBuf;