Repository navigation
Description
Trusted resolved execution context for policy hooks
Tracking use case: erickb336/sage-stack#243. This request concerns a supported runtime contract for policy extensions. It is separate from required-hook failure handling in #41979.
Related reports: #32360 and #50271 cover effective working directory; #40996 covers permission context. This request brings those needs together with executor identity, filesystem namespace, shell resolution, and per-call freshness. If an existing supported interface covers them, please point us to it.
Problem
A policy hook needs the settings that the executor will actually use. Original model arguments do not establish those settings. A hook cannot safely infer execution paths from its own environment when a command selects a different working directory, shell, or remote executor.
In rust-v0.162.1, the exec_command PreToolUse payload contains the command string. The hook cwd uses the local environment cwd, with the turn cwd as fallback. These fields do not attest the pending command's resolved execution context.
Sources checked:
- https://github.com/openai/codex/blob/rust-v0.162.1/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs#L514
- https://github.com/openai/codex/blob/rust-v0.162.1/codex-rs/core/src/tools/registry.rs#L609
- https://github.com/openai/codex/blob/rust-v0.162.1/codex-rs/core/src/hook_runtime.rs#L248
Requested capability
Provide a supported, versioned policy interface for the resolved operation before execution. An extension to an existing hook or a separate runtime callback could satisfy this request. The interface must bind evidence to the authenticated session, actor, turn, and exact tool call.
Required evidence or equivalent trusted checks:
- Selected executor and filesystem namespace, including whether execution is local or remote.
- Effective working directory after resolving omitted, empty, relative, and explicit inputs.
- Effective shell executable, shell type, and invocation/login behavior.
- The lookup settings needed for executable and path policy, including PATH, HOME, and CDPATH, without exposing credentials or a full environment dump.
- Effective sandbox and permission policy, including permitted additions and inherited settings.
- A supported way to evaluate relevant filesystem, symlink, executable identity, and checkout evidence in that same namespace.
Specify when evidence is captured, how rewrites affect it, and what invalidates an earlier decision. A changed executor, directory, permission setting, or operation must require a fresh decision. Evidence for one call must not authorize another. Successful extension policy must preserve native sandbox and approval checks.
The interface must state its limits. Shell startup scripts and arbitrary programs can change behavior after this point. Context metadata is not proof that a command is harmless and does not replace a filesystem sandbox.
Validation examples
- Compare omitted and explicit workdir inputs with the command's actual directory in an isolated fixture.
- Compare requested shell strings with the runtime-selected executable and invocation.
- Exercise inherited and explicit permission settings without bypassing native approvals.
- Verify local and remote namespaces; local filesystem inspection must not stand in for remote evidence.
- Refuse mismatched session, actor, turn, or call identities, stale snapshots, and changed operations.
- Verify denial prevents the operation. Separately cover hook timeout, exception, and transport failure through the fail-closed contract.
Current Sage boundary
Sage can recover original requested arguments from protected native transcripts. Its verified fixture path does not establish a complete installed evaluator. Automatic activation remains disabled. Native probes with simulated model responses establish only the behavior they directly observe.
Evidence limits
The source audit covers rust-v0.162.1. At submission, rust-v0.163.0 is the latest published release; it has not been source-audited or native-tested in this investigation. The cited 0.162.1 source was read directly. This request does not claim a new native comparison run or that every possible runtime interface was exhaustively excluded.
Sage needs a supported producer or a separately designed execution boundary. Model-supplied fields cannot supply runtime authority.
Activity
AndrewDongminYoo commentedon Oct 31, 2026
Additional use case: resolved native subagent settings before spawn
The same resolved-context requirement applies to admitting a native
spawn_agentcall before a child begins work.Observed scope
codex app-server, reportingcodex-cli 0.166.0-alpha.5.1.rust-v0.166.0-alpha.5.1, peeled commitf79b26ccbb3116b052544666a181012fb45dc49b.Why requested arguments are insufficient
Child configuration preparation applies requested model/reasoning overrides, then applies the selected role.
Role application resolves that role from the live parent configuration and loads its role file.
Consequently, pinning a tool argument such as
reasoning_effort: "high"does not establish the final child setting when the role layer subsequently pins a different value.The PreToolUse request and serialized command input expose the calling context and requested tool input, without the prepared child's effective model/effort or role-source provenance.
The generic hook dispatch also permits input rewrites before the handler executes.
Reading the on-disk configuration or inspecting the parent's persisted model/effort cannot establish an unexposed live role override.
Requested extension of this issue
Expose a trusted, versioned pre-spawn settings snapshot outside caller-controlled
tool_input, through the existing hook or an equivalent supported admission callback:A model-authored snapshot inside tool arguments would not provide this evidence.
The payload need not expose prompts, credentials, a full configuration dump or the ambient environment.
Existing native sandbox and approval checks should remain in force.
Acceptance checks and evidence limits
An app-server integration fixture should compare the approved snapshot with the actual persisted child model/effort, exercise a role that overrides the requested effort, and verify zero child creation after a policy denial.
Changed arguments, stale or mismatched identities, and role-file changes between validation and dispatch should not reuse the earlier approval.
This contribution is grounded in the pinned source and the local consumer's denial; no patched producer or end-to-end snapshot implementation was completed.
It does not demonstrate that an incorrect model ran, a native policy was bypassed, or the desktop frontend crashed.
The missing producer-side contract is the remaining integration requirement.
#33314 concerns full-profile application and observable spawn metadata; #44095 concerns spawn/lifecycle correlation.
The specific addition here is making resolved child settings available before admission, with rewrite and dispatch consistency, within this existing trusted-context request.
docs(release): record Alpha preparation and tester access limits (#137)