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
use std::path::PathBuf;
use clap::{Args, Subcommand};
#[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 {
/// 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),
/// 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),
}
#[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 Harn Cloud, Burin Code, or other hosts.
#[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 Harn Cloud, Burin Code, 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)]
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,
}