1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Location: ./crates/cpex-core/src/identity/hook.rs
// Copyright 2025
// SPDX-License-Identifier: Apache-2.0
// Authors: Teryl Taylor
//
// `IdentityHook` — the `HookTypeDef` marker for the IdentityResolve
// hook family. Plugins implement `HookHandler<IdentityHook>`; the
// framework dispatches into them at request entry to populate
// `Extensions.security.subject` / `.client` / `.caller_workload` /
// `Extensions.raw_credentials` before any tool / resource / prompt
// hook runs.
//
// # Single hook name (for now)
//
// v0 registers under the single name `identity.resolve`. If a future
// slice introduces an `identity.validate` phase that uses the same
// payload + result shape (e.g. a post-resolve consistency check),
// it can share `IdentityHook` and register under `identity.validate`
// via the multi-name registration path — same pattern as CMF's
// `cmf.tool_pre_invoke` / `cmf.llm_input` / etc. sharing `CmfHook`.
// Phases with a different payload shape (e.g. TokenDelegate) get
// their own hook type rather than reusing this one.
//
// # Lifecycle
//
// This file defines the *types*. Lifecycle wiring — when the
// framework calls `invoke_named::<IdentityHook>(...)`, how results
// merge back into `Extensions` — lands in sub-step B / C of slice 2.
use cratePluginResult;
use IdentityPayload;
/// Primary hook name for IdentityResolve handlers. Used as the
/// registry key when a host registers the handler via the standard
/// `register_handler` path.
pub const HOOK_IDENTITY_RESOLVE: &str = "identity.resolve";
cratedefine_hook!