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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// Copyright (C) 2026 Mandeep Patel
// SPDX-License-Identifier: AGPL-3.0-only
//! Typed per-handler reports.
//!
//! Every CLI handler returns one of these structs instead of `()`.
//! In v0.14 the structs are minimal data carriers — the dispatcher
//! discards them via `let _ = handler.await?;`. v0.17 will read
//! the populated fields and emit them as OTel span attributes (per
//! the synthesis §6 matrix).
//!
//! Naming: one type per top-level subcommand. Fields are restricted
//! to ALLOW attributes from the v0.14+ §6 matrix; DENY data
//! (values, URI paths, raw error messages) never lands here.
//!
//! See [[build-plan-v0.14-redact]] §Phase 6 and
//! [[v0.14-plus-synthesis]] §6 for the rationale.
//!
//! # Phase 7 code-review B1: `Drop` does not fire on `secretenv run`
//!
//! The Phase 6 commit message described v0.17 wiring as "the
//! report's `Drop` impl emits the root span." That works for handler
//! paths whose function bodies return normally (`cmd_get`, `cmd_redact`,
//! `cmd_resolve`, `cmd_registry`, `cmd_setup`, `cmd_profile`,
//! `cmd_completions`) but **does not work for `cmd_run`'s exec /
//! pipe-redact happy paths**: both end in `std::process::exit(...)`
//! or `cmd.exec()`, which replace the process / terminate without
//! running Rust destructors. As written, v0.17 would silently emit
//! zero spans for every successful `secretenv run`.
//!
//! **v0.17 must add a pre-exec emission hook** — synchronously
//! flush whatever the v0.17 OTel exporter requires before the
//! `exec()` / `exit()` call. Concretely: in `runner::run_with_options`
//! and `runner::run_with_pipe_redaction`, just before the terminal
//! `exec_with_env(...)` / `std::process::exit(...)`, emit a
//! [`RunReport`]-equivalent span via the v0.17 telemetry sink and
//! flush. The `RunReport` returned to the dispatcher then becomes a
//! no-op for those paths; the other handlers continue to rely on
//! `Drop` emission.
//!
//! v0.14 `#[allow(dead_code)]`: every report field exists for
//! v0.17 emission (whether via `Drop` or pre-exec hook).
use SecretEnvErrorKind;
/// Outcome bucket on every report. v0.17 emits this as
/// `secretenv.command.outcome`.
/// `secretenv run` outcome metadata.
/// Which post-resolution dispatch [`RunReport`] reflects.
/// `secretenv resolve` outcome metadata.
/// `secretenv get` outcome metadata.
/// `secretenv redact` outcome metadata.
/// Which redact-mode-B sub-dispatch the report reflects.
/// `secretenv registry <subcommand>` outcome metadata.
/// `secretenv setup` outcome metadata.
/// `secretenv profile <subcommand>` outcome metadata.
/// `secretenv completions` outcome metadata.