What issue are you seeing?
The generated hook command output JSON schemas currently allow hookSpecificOutput.hookEventName to be any value from the global hook event enum for several hook-specific output payloads.
For example, the pre-tool-use.command.output schema accepts any HookEventNameWire value for hookSpecificOutput.hookEventName, even though that hook-specific output is only valid for PreToolUse.
Affected output schemas:
permission-request.command.output.schema.json
post-tool-use.command.output.schema.json
pre-tool-use.command.output.schema.json
session-start.command.output.schema.json
user-prompt-submit.command.output.schema.json
This makes the published schemas less precise than the runtime contract and can mislead external hook authors or schema-driven tooling into producing invalid combinations such as a PreToolUse hook-specific output with hookEventName: "PostToolUse".
What steps can reproduce the bug?
- Inspect a generated hook command output schema such as
codex-rs/hooks/schema/generated/pre-tool-use.command.output.schema.json.
- Find
properties.hookSpecificOutput.properties.hookEventName.
- Observe that it references the global hook event enum instead of constraining the value to the matching hook event.
Current shape:
{
"hookEventName": {
"$ref": "#/definitions/HookEventNameWire"
}
}
This permits unrelated hook event names inside an event-specific output payload.
What is the expected behavior?
Each hook-specific output schema should constrain hookSpecificOutput.hookEventName to the literal hook event name for that output type.
Expected shape:
{
"hookEventName": {
"const": "PreToolUse",
"type": "string"
}
}
The expected constants by schema are:
permission-request.command.output.schema.json: PermissionRequest
post-tool-use.command.output.schema.json: PostToolUse
pre-tool-use.command.output.schema.json: PreToolUse
session-start.command.output.schema.json: SessionStart
user-prompt-submit.command.output.schema.json: UserPromptSubmit
This should match the existing pattern used by hook command input schemas, where hookEventName is already represented as an event-specific string constant.
Additional information
I already have a potential patch that fixes this issue in my computer.
What issue are you seeing?
The generated hook command output JSON schemas currently allow
hookSpecificOutput.hookEventNameto be any value from the global hook event enum for several hook-specific output payloads.For example, the
pre-tool-use.command.outputschema accepts anyHookEventNameWirevalue forhookSpecificOutput.hookEventName, even though that hook-specific output is only valid forPreToolUse.Affected output schemas:
permission-request.command.output.schema.jsonpost-tool-use.command.output.schema.jsonpre-tool-use.command.output.schema.jsonsession-start.command.output.schema.jsonuser-prompt-submit.command.output.schema.jsonThis makes the published schemas less precise than the runtime contract and can mislead external hook authors or schema-driven tooling into producing invalid combinations such as a
PreToolUsehook-specific output withhookEventName: "PostToolUse".What steps can reproduce the bug?
codex-rs/hooks/schema/generated/pre-tool-use.command.output.schema.json.properties.hookSpecificOutput.properties.hookEventName.Current shape:
{ "hookEventName": { "$ref": "#/definitions/HookEventNameWire" } }This permits unrelated hook event names inside an event-specific output payload.
What is the expected behavior?
Each hook-specific output schema should constrain
hookSpecificOutput.hookEventNameto the literal hook event name for that output type.Expected shape:
{ "hookEventName": { "const": "PreToolUse", "type": "string" } }The expected constants by schema are:
permission-request.command.output.schema.json:PermissionRequestpost-tool-use.command.output.schema.json:PostToolUsepre-tool-use.command.output.schema.json:PreToolUsesession-start.command.output.schema.json:SessionStartuser-prompt-submit.command.output.schema.json:UserPromptSubmitThis should match the existing pattern used by hook command input schemas, where
hookEventNameis already represented as an event-specific string constant.Additional information
I already have a potential patch that fixes this issue in my computer.