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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
use std::path::PathBuf;
use clap::{Args, Subcommand, ValueEnum};
use super::util::trigger_provider_completion_parser;
#[derive(Debug, Args)]
pub(crate) struct PersonaArgs {
#[command(subcommand)]
pub command: PersonaCommand,
/// Explicit harn.toml path or directory. Defaults to nearest harn.toml from cwd.
#[arg(long, global = true, value_name = "PATH")]
pub manifest: Option<PathBuf>,
/// Directory used for durable persona runtime state and event-log data.
#[arg(
long,
global = true,
value_name = "DIR",
default_value = ".harn/personas"
)]
pub state_dir: PathBuf,
}
#[derive(Debug, Subcommand)]
pub(crate) enum PersonaCommand {
/// Scaffold a new Harn-first persona package from a template.
New(PersonaNewArgs),
/// Validate a persona package end-to-end.
Doctor(PersonaDoctorArgs),
/// Validate a persona manifest with the canonical harn-modules schema.
Check(PersonaCheckArgs),
/// List personas declared in the resolved harn.toml.
List(PersonaListArgs),
/// Inspect one persona from the resolved harn.toml.
Inspect(PersonaInspectArgs),
/// Activate an installed package persona with optional authority attenuation.
Activate(PersonaActivateArgs),
/// Deactivate an installed package persona for this project.
Deactivate(PersonaDeactivateArgs),
/// List project-scoped installed persona activations.
Activations(PersonaActivationsArgs),
/// Query durable persona lifecycle, lease, budget, and queue status.
Status(PersonaStatusArgs),
/// Pause a persona; matching events queue until resume drains them.
Pause(PersonaControlArgs),
/// Resume a persona and drain queued events once under leases.
Resume(PersonaControlArgs),
/// Disable a persona; matching events are recorded as dead-lettered.
Disable(PersonaControlArgs),
/// Fire a synthetic schedule tick for a persona.
Tick(PersonaTickArgs),
/// Fire a synthetic external trigger envelope for a persona.
Trigger(PersonaTriggerArgs),
/// Record an expensive-work budget receipt for a persona.
Spend(PersonaSpendArgs),
/// Stream the local universal persona supervision feed.
Supervision(PersonaSupervisionArgs),
}
#[derive(Debug, Args)]
pub(crate) struct PersonaNewArgs {
/// Persona package name, for example `my_release_captain`.
pub name: String,
/// Persona control-flow template.
#[arg(long, value_enum)]
pub template: PersonaTemplateKind,
/// Directory under which the persona package is created.
#[arg(long, value_name = "DIR", default_value = "personas")]
pub output_root: PathBuf,
/// Replace an existing generated package.
#[arg(long)]
pub force: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaDoctorArgs {
/// Persona name or package directory to validate.
pub name: String,
/// Emit a stable JSON report instead of a human-readable table.
#[arg(long)]
pub json: bool,
/// Test timeout for the smoke suite.
#[arg(long, default_value_t = 10_000)]
pub timeout_ms: u64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub(crate) enum PersonaTemplateKind {
#[value(name = "deterministic-sweeper")]
DeterministicSweeper,
#[value(name = "hybrid-classify-then-act")]
HybridClassifyThenAct,
#[value(name = "frontier-judgment-loop")]
FrontierJudgmentLoop,
}
impl PersonaTemplateKind {
pub(crate) fn as_str(self) -> &'static str {
match self {
Self::DeterministicSweeper => "deterministic-sweeper",
Self::HybridClassifyThenAct => "hybrid-classify-then-act",
Self::FrontierJudgmentLoop => "frontier-judgment-loop",
}
}
}
#[derive(Debug, Args)]
pub(crate) struct PersonaCheckArgs {
/// Persona manifest, harn.toml path, or directory containing harn.toml.
#[arg(value_name = "PATH")]
pub path: Option<PathBuf>,
/// Emit typed validation errors as JSON.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaListArgs {
/// Emit a stable JSON array instead of a human-readable table.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaInspectArgs {
/// Persona name to inspect.
pub name: String,
/// Emit stable JSON for cloud platforms or other hosts.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaActivateArgs {
/// Qualified installed persona ID, for example `agents/reviewer`.
pub name: String,
/// Lower autonomy ceiling. Omit to inherit the exported tier.
#[arg(
long,
value_name = "TIER",
value_parser = ["shadow", "suggest", "act_with_approval", "act_auto"]
)]
pub autonomy_tier: Option<String>,
/// Retain one exported tool. Repeat to retain multiple tools.
#[arg(long = "tool", value_name = "NAME", conflicts_with = "no_tools")]
pub tools: Vec<String>,
/// Attenuate the persona to no tools.
#[arg(long, conflicts_with = "tools")]
pub no_tools: bool,
/// Retain one exported capability. Repeat to retain multiple capabilities.
#[arg(
long = "capability",
value_name = "NAME",
conflicts_with = "no_capabilities"
)]
pub capabilities: Vec<String>,
/// Attenuate the persona to no capabilities.
#[arg(long, conflicts_with = "capabilities")]
pub no_capabilities: bool,
/// RFC3339 timestamp to use for deterministic receipts.
#[arg(long, value_name = "RFC3339")]
pub at: Option<String>,
/// Emit a stable JSON receipt.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaDeactivateArgs {
/// Qualified installed persona ID, for example `agents/reviewer`.
pub name: String,
/// RFC3339 timestamp to use for deterministic receipts.
#[arg(long, value_name = "RFC3339")]
pub at: Option<String>,
/// Emit a stable JSON receipt.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaActivationsArgs {
/// Emit a stable JSON array.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaStatusArgs {
/// Persona name to query.
pub name: String,
/// RFC3339 timestamp to use for deterministic budget windows. When
/// omitted, falls back to the current UTC wall clock.
#[arg(long, value_name = "RFC3339")]
pub at: Option<String>,
/// Emit stable JSON for cloud platforms or other hosts.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaControlArgs {
/// Persona name to control.
pub name: String,
/// RFC3339 timestamp to use as "now" for deterministic tests.
#[arg(long, value_name = "RFC3339")]
pub at: Option<String>,
/// Emit stable JSON after applying the control.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaTickArgs {
/// Persona name to wake from its schedule binding.
pub name: String,
/// RFC3339 timestamp to use for deterministic tests.
#[arg(long, value_name = "RFC3339")]
pub at: Option<String>,
/// Estimated expensive-work cost for budget enforcement.
#[arg(long, default_value_t = 0.0)]
pub cost_usd: f64,
/// Estimated token count for budget enforcement.
#[arg(long, default_value_t = 0)]
pub tokens: u64,
/// Emit stable JSON.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaTriggerArgs {
/// Persona name to wake from an external trigger.
pub name: String,
/// Provider name, for example github, linear, slack, or webhook.
#[arg(
long,
value_parser = trigger_provider_completion_parser(),
hide_possible_values = true
)]
pub provider: String,
/// Provider event kind, for example pull_request, check_run, issue, or message.
#[arg(long)]
pub kind: String,
/// Normalized metadata as key=value. Repeat for multiple fields.
#[arg(long = "metadata", value_name = "KEY=VALUE")]
pub metadata: Vec<String>,
/// RFC3339 timestamp to use for deterministic tests.
#[arg(long, value_name = "RFC3339")]
pub at: Option<String>,
/// Estimated expensive-work cost for budget enforcement.
#[arg(long, default_value_t = 0.0)]
pub cost_usd: f64,
/// Estimated token count for budget enforcement.
#[arg(long, default_value_t = 0)]
pub tokens: u64,
/// Emit stable JSON.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaSpendArgs {
/// Persona name to charge.
pub name: String,
/// Cost in USD to record.
#[arg(long)]
pub cost_usd: f64,
/// Tokens to record.
#[arg(long, default_value_t = 0)]
pub tokens: u64,
/// RFC3339 timestamp to use for deterministic tests.
#[arg(long, value_name = "RFC3339")]
pub at: Option<String>,
/// Emit stable JSON.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PersonaSupervisionArgs {
#[command(subcommand)]
pub command: PersonaSupervisionCommand,
}
#[derive(Debug, Subcommand)]
pub(crate) enum PersonaSupervisionCommand {
/// Emit local persona/update frames as newline-delimited JSON.
Tail(PersonaSupervisionTailArgs),
}
#[derive(Debug, Args)]
pub(crate) struct PersonaSupervisionTailArgs {
/// Persona name to stream. When omitted, streams every persona in the local state directory.
#[arg(long)]
pub persona: Option<String>,
/// Replay events strictly after this event-log cursor.
#[arg(long, value_name = "N")]
pub since_event_id: Option<u64>,
/// RFC3339 timestamp accepted for deterministic harness parity.
#[arg(long, value_name = "RFC3339")]
pub at: Option<String>,
/// Keep waiting for new events after the current backlog drains.
#[arg(long)]
pub follow: bool,
/// Accepted for host symmetry; output is always newline-delimited JSON.
#[arg(long)]
pub json: bool,
/// Maximum number of emitted supervision frames.
#[arg(long, value_name = "N")]
pub limit: Option<usize>,
}