Hook protocol and session storage are both event-oriented but have different stability. Hook stdin/stdout is a user-facing integration contract; session JSONL is primarily CodeN’s own recovery format. You may inspect sessions, but do not treat internal record shapes as a third-party API without a version-migration strategy.
Exit code 2 on a controllable event counts as an explicit block (blocked); blocks on UserPromptSubmit and Stop use decision/reason in stdout JSON, while PreToolUse and PermissionRequest use permissionDecision/decision.
Exit code 0 with empty stdout is a no-op; other failures (non-zero, timeout, output/input over limit, invalid JSON) count as hook failures with a warning and never block.
Common fields: schemaVersion, hookEventName, sessionId, optional turnId, cwd, permissionMode, followed by the event payload. The input limit is 1MB (over limit counts as a failure).
PreToolUse hook decision (including updatedInput and additionalContext).
After an input update, re-validate everything: schema (fails as hook.invalid_updated_input), structured file path, risk classification, and permissions.
Policy layer (manual/smart/auto).
When a human is needed, fire the PermissionRequest hook (reason: "policy"; "hook" when a hook requested human review).
Human confirmation (inline in CLI/TUI).
Execute the tool and fire PostToolUse/PostToolUseFailure.
processed per protocol (decision/context/system message)
exit 2 (controllable events)
explicit block
non-zero, timeout, over limit, invalid JSON, illegal fields
hook.failed: diagnostic stderr (≤2000 chars, scrubbed) and fail open
Fail-open means: decision hooks that fail produce no decision, and permissions continue through the policy layer; unsafe scenarios are decided by that layer (a failed PermissionRequest never silently allows).
coden--resume# list sessions for the current workspace
coden--resume<session-id># resume a specific session
Resume rebuilds system messages (fresh system prompt, tool catalog, and skill name list), restores message history, the compaction summary and range, and the last saved thinking level.
Trailing unfinished tool calls are repaired as runtime.interrupted: tool execution did not complete... errors with a recorded warning.
Corrupt mid-file records raise a per-line error; only an incomplete final line is ignored with a warning.
Thinking-level resolution on resume: explicit --thinking > saved session value > user/project config > default; an explicit override is written back to the session.