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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
/// Comply subcommands for PMAT compliance checking and migration
#[derive(Debug, Clone, Subcommand)]
pub enum ComplyCommands {
/// Check project compliance with current PMAT version
#[command(visible_aliases = &["status"])]
Check {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Exit with error if non-compliant
#[arg(long)]
strict: bool,
/// Show only failures (breaking changes/incompatibilities)
#[arg(long)]
failures_only: bool,
/// Output format
#[arg(short = 'f', long = "format", value_enum, default_value = "text")]
format: ComplyOutputFormat,
/// Additional project paths to include in cross-stack health checks
#[arg(long, value_name = "PATH")]
include_project: Vec<PathBuf>,
},
/// Migrate project to latest PMAT standards
Migrate {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Target PMAT version (defaults to current binary version)
#[arg(long)]
version: Option<String>,
/// Dry run (show what would be migrated without changing files)
#[arg(long)]
dry_run: bool,
/// Skip backup creation (NOT RECOMMENDED)
#[arg(long)]
no_backup: bool,
/// Force migration even if breaking changes detected
#[arg(long)]
force: bool,
},
/// Upgrade project to a specific quality enforcement style (e.g., Popperian)
Upgrade {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Target style (e.g., "popperian")
#[arg(short = 't', long = "target", default_value = "popperian")]
target: String,
/// Dry run (show what would be upgraded)
#[arg(long)]
dry_run: bool,
},
/// Show changelog since project's PMAT version
Diff {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Start version for changelog (defaults to project version)
#[arg(long)]
from: Option<String>,
/// End version for changelog (defaults to current binary)
#[arg(long)]
to: Option<String>,
/// Show only breaking changes
#[arg(long)]
breaking_only: bool,
},
/// Update hooks and configs to latest versions
Update {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Update only hooks
#[arg(long)]
hooks: bool,
/// Update only configs
#[arg(long)]
config: bool,
/// Dry run (show what would be updated)
#[arg(long)]
dry_run: bool,
},
/// Initialize .pmat/project.toml with current version
Init {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Force overwrite existing project.toml
#[arg(long)]
force: bool,
},
/// Install git hooks for mandatory work tracking (W-006)
/// Blocks commits without active tickets per master-plan-pmat-work-system.md
#[command(visible_aliases = &["install", "hooks"])]
Enforce {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Skip confirmation prompt
#[arg(short = 'y', long = "yes")]
yes: bool,
/// Remove all PMAT hooks (disable enforcement)
#[arg(long)]
disable: bool,
/// Output format
#[arg(short = 'f', long = "format", value_enum, default_value = "text")]
format: ComplyOutputFormat,
},
/// Generate compliance report (W-009)
Report {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Include ticket history
#[arg(long)]
include_history: bool,
/// Output format
#[arg(short = 'f', long = "format", value_enum, default_value = "markdown")]
format: ComplyOutputFormat,
/// Write output to file
#[arg(short = 'o', long = "output")]
output: Option<PathBuf>,
},
/// Layer 2 (Genchi Genbutsu): Evidence-based review checklist (COMPLY-045)
/// Generates a reviewer checklist with reproducibility, hypothesis, and trace evidence.
Review {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Output format
#[arg(short = 'f', long = "format", value_enum, default_value = "markdown")]
format: ComplyOutputFormat,
/// Write output to file
#[arg(short = 'o', long = "output")]
output: Option<PathBuf>,
},
/// Layer 3 (Governance): Generate audit artifact with sovereign trail (COMPLY-045)
/// Requires clean git state. Produces signed compliance evidence.
Audit {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Output format
#[arg(short = 'f', long = "format", value_enum, default_value = "json")]
format: ComplyOutputFormat,
/// Write output to file
#[arg(short = 'o', long = "output")]
output: Option<PathBuf>,
},
/// Generate file health baseline for ratchet enforcement
/// Scans source files, calculates health metrics, saves to .pmat/file-health-baseline.json
Baseline {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Preview what would be generated without writing files
#[arg(long)]
dry_run: bool,
},
/// Generate .pmat/binding-index.json, O(1) caches, and contracts/work/*.yaml
/// Enables CB-1350 differential obligation verification at commit time.
#[command(visible_aliases = &["refresh", "rb"])]
RefreshBindings {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
},
/// Override verification level ratchet for a binding (escape hatch for CB-1330).
/// Records signed entry in .pmat-metrics/ratchet-overrides.jsonl, expires in 14 days.
#[command(visible_aliases = &["override"])]
RatchetOverride {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Binding/function name to override
#[arg(long)]
binding: String,
/// Current (higher) level being overridden from
#[arg(long)]
from: String,
/// Target (lower) level being overridden to
#[arg(long)]
to: String,
/// Reason for the override
#[arg(long)]
reason: String,
/// Associated work item ID
#[arg(long = "work-item")]
work_item: Option<String>,
},
/// Validate non-code asset layout contracts (README, Dockerfile, SVG, etc.)
/// Runs CB-1320..1326 checks on a specific asset or all assets.
#[command(visible_aliases = &["av"])]
AssetValidate {
/// Project path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Specific asset to validate (readme, dockerfile, svg, changelog, badges, book, forjar)
#[arg(long)]
asset: Option<String>,
},
/// Cross-crate duplication detection (CC-001 through CC-005)
/// Detects copy-paste duplication, API divergence, and churn correlation across workspace crates.
#[command(visible_aliases = &["cc", "xc"])]
CrossCrate {
/// Workspace root path (defaults to current directory)
#[arg(short = 'p', long = "path", default_value = ".")]
path: PathBuf,
/// Explicit crate paths (comma-separated)
#[arg(long = "crates", value_delimiter = ',', num_args = 1..)]
crates: Option<Vec<PathBuf>>,
/// Minimum similarity threshold for clone detection (0.0-1.0)
#[arg(long = "similarity-threshold", default_value = "0.80")]
similarity_threshold: f64,
/// Window in days for churn correlation (CC-004)
#[arg(long = "churn-window-days", default_value = "7")]
churn_window_days: u32,
/// Comma-separated list of rules to run (e.g., "cc001,cc002")
#[arg(long = "rules")]
rules: Option<String>,
/// Output format
#[arg(short = 'f', long = "format", value_enum, default_value = "text")]
format: ComplyOutputFormat,
/// Write output to file
#[arg(short = 'o', long = "output")]
output: Option<PathBuf>,
/// Exit with error code 1 if findings detected
#[arg(long)]
strict: bool,
/// Save current finding counts as ratchet baseline
#[arg(long = "save-baseline")]
save_baseline: bool,
},
}
/// Comply output formats
#[derive(Debug, Clone, clap::ValueEnum, PartialEq)]
pub enum ComplyOutputFormat {
/// Human-readable text format
Text,
/// JSON format for CI/CD
Json,
/// Markdown report format
Markdown,
/// SARIF format for GitHub Code Scanning (delegates contract checks to pv lint)
Sarif,
}
/// Project diagnostics output formats (lltop Tab 8)
#[derive(Debug, Clone, Copy, Default, clap::ValueEnum, PartialEq, Eq)]
pub enum ProjectDiagOutputFormat {
/// Human-readable summary with status icons
#[default]
Summary,
/// JSON format for CI/CD
Json,
/// Markdown report format
Markdown,
/// Andon-style visualization (Toyota Way)
Andon,
}
/// Output format for perfection score (master-plan-pmat-work-system.md)
#[derive(Debug, Clone, Copy, Default, clap::ValueEnum)]
pub enum PerfectionScoreOutputFormat {
/// Human-readable text format
#[default]
Text,
/// JSON format for CI/CD
Json,
/// Markdown report format
Markdown,
}