forjar 1.4.2

Rust-native Infrastructure as Code — bare-metal first, BLAKE3 state, provenance tracing
Documentation
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
//! CLI argument structs for platform features:
//! remote state, recipe registry, service catalog,
//! multi-config apply, stack dependency graph.

use clap::Parser;
use std::path::PathBuf;

/// Remote state backend operations.
#[derive(Parser, Debug)]
pub struct StateBackendArgs {
    /// State directory
    #[clap(long, default_value = "state")]
    pub state_dir: PathBuf,

    /// Filter by key prefix
    #[clap(long)]
    pub prefix: Option<String>,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Recipe registry listing.
#[derive(Parser, Debug)]
pub struct RegistryListArgs {
    /// Registry directory
    #[clap(long)]
    pub registry_dir: Option<PathBuf>,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Service catalog listing.
#[derive(Parser, Debug)]
pub struct CatalogListArgs {
    /// Catalog directory
    #[clap(long)]
    pub catalog_dir: Option<PathBuf>,

    /// Filter by category
    #[clap(long)]
    pub category: Option<String>,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Multi-config apply ordering.
#[derive(Parser, Debug)]
pub struct MultiConfigArgs {
    /// Config files to analyze
    #[clap(short, long, required = true)]
    pub file: Vec<PathBuf>,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Stack dependency graph.
#[derive(Parser, Debug)]
pub struct StackGraphArgs {
    /// Config files to analyze
    #[clap(short, long, required = true)]
    pub file: Vec<PathBuf>,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Infrastructure query.
#[derive(Parser, Debug)]
pub struct InfraQueryArgs {
    /// Config file
    #[clap(short, long, default_value = "forjar.yaml")]
    pub file: PathBuf,

    /// State directory
    #[clap(long, default_value = "state")]
    pub state_dir: PathBuf,

    /// Search pattern
    #[clap(long)]
    pub pattern: Option<String>,

    /// Filter by resource type
    #[clap(long = "type")]
    pub resource_type: Option<String>,

    /// Filter by machine
    #[clap(long)]
    pub machine: Option<String>,

    /// Filter by tag
    #[clap(long)]
    pub tag: Option<String>,

    /// Show detailed output
    #[clap(long)]
    pub details: bool,

    /// Live mode (SSH probe)
    #[clap(long)]
    pub live: bool,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Recipe signing.
#[derive(Parser, Debug)]
pub struct RecipeSignArgs {
    /// Recipe file to sign/verify
    pub recipe: PathBuf,

    /// Verify only (don't sign)
    #[clap(long)]
    pub verify: bool,

    /// Signer identity
    #[clap(long)]
    pub signer: Option<String>,

    /// Post-quantum dual signing
    #[clap(long)]
    pub pq: bool,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Preservation checking.
#[derive(Parser, Debug)]
pub struct PreservationArgs {
    /// Config file
    #[clap(short, long, default_value = "forjar.yaml")]
    pub file: PathBuf,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Parallel multi-stack apply.
#[derive(Parser, Debug)]
pub struct ParallelStackArgs {
    /// Config files
    #[clap(short, long, required = true)]
    pub file: Vec<PathBuf>,

    /// Maximum parallel stacks
    #[clap(long, default_value = "4")]
    pub max_parallel: usize,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Saga-pattern multi-stack apply.
#[derive(Parser, Debug)]
pub struct SagaArgs {
    /// Config files
    #[clap(short, long, required = true)]
    pub file: Vec<PathBuf>,

    /// State directory
    #[clap(long, default_value = "state")]
    pub state_dir: PathBuf,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Pull agent / hybrid push-pull.
#[derive(Parser, Debug)]
pub struct PullAgentArgs {
    /// Config file
    #[clap(short, long, default_value = "forjar.yaml")]
    pub file: PathBuf,

    /// State directory
    #[clap(long, default_value = "state")]
    pub state_dir: PathBuf,

    /// Poll interval in seconds (pull mode)
    #[clap(long, default_value = "60")]
    pub interval: u64,

    /// Auto-apply when drift detected
    #[clap(long)]
    pub auto_apply: bool,

    /// Maximum iterations (default: unlimited in pull mode, 1 in push)
    #[clap(long)]
    pub max_iterations: Option<u64>,

    /// Pull mode (daemon loop); default is push (one-shot)
    #[clap(long)]
    pub pull: bool,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// Agent recipe registry.
#[derive(Parser, Debug)]
pub struct AgentRegistryArgs {
    /// Registry directory
    #[clap(long)]
    pub registry_dir: Option<PathBuf>,

    /// Filter by category
    #[clap(long)]
    pub category: Option<String>,

    /// JSON output
    #[clap(long)]
    pub json: bool,
}

/// FJ-2200: CLI arguments for `contracts`.
#[derive(clap::Args, Debug)]
pub struct ContractsArgs {
    /// Show contract coverage report
    #[arg(long)]
    pub coverage: bool,

    /// Path to forjar.yaml (for handler-level analysis)
    #[arg(short, long, default_value = "forjar.yaml")]
    pub file: PathBuf,

    /// JSON output
    #[arg(long)]
    pub json: bool,
}

/// FJ-2300: CLI arguments for `logs`.
#[derive(clap::Args, Debug)]
pub struct LogsArgs {
    /// State directory
    #[arg(long, default_value = "state")]
    pub state_dir: PathBuf,

    /// Filter by machine
    #[arg(short, long)]
    pub machine: Option<String>,

    /// Filter by run ID
    #[arg(long)]
    pub run: Option<String>,

    /// Filter by resource ID
    #[arg(long)]
    pub resource: Option<String>,

    /// Show only failures
    #[arg(long)]
    pub failures: bool,

    /// Show the executed script
    #[arg(long)]
    pub script: bool,

    /// Show logs from all machines
    #[arg(long)]
    pub all_machines: bool,

    /// Follow mode — stream live during apply
    #[arg(long)]
    pub follow: bool,

    /// Garbage-collect old logs
    #[arg(long)]
    pub gc: bool,

    /// Dry-run for --gc (show what would be deleted)
    #[arg(long)]
    pub dry_run: bool,

    /// Keep failed run logs during --gc
    #[arg(long)]
    pub keep_failed: bool,

    /// JSON output
    #[arg(long)]
    pub json: bool,
}

/// FJ-2104: CLI arguments for `build`.
#[derive(clap::Args, Debug)]
pub struct BuildArgs {
    /// Path to forjar.yaml
    #[arg(short, long, default_value = "forjar.yaml")]
    pub file: PathBuf,

    /// Resource to build (must be type: image)
    #[arg(long)]
    pub resource: String,

    /// Load into local Docker daemon after build
    #[arg(long)]
    pub load: bool,

    /// Push to registry after build
    #[arg(long)]
    pub push: bool,

    /// Wrap output in FAR (Forjar Archive) format
    #[arg(long)]
    pub far: bool,

    /// Build inside container sandbox (Docker/Podman)
    #[arg(long)]
    pub sandbox: bool,

    /// JSON output
    #[arg(long)]
    pub json: bool,
}

/// FJ-2101: CLI arguments for `oci-pack`.
#[derive(clap::Args, Debug)]
pub struct OciPackArgs {
    /// Directory to pack into an OCI image
    pub dir: PathBuf,

    /// Image tag (name:tag)
    #[arg(long)]
    pub tag: String,

    /// Output directory for OCI layout
    #[arg(long, default_value = "oci-output")]
    pub output: PathBuf,

    /// JSON output
    #[arg(long)]
    pub json: bool,
}

/// FJ-2001: CLI arguments for `query`.
#[derive(clap::Args, Debug)]
pub struct QueryArgs {
    /// Search query (e.g., "bash", "nginx"). Omit for --health.
    pub query: Option<String>,

    /// State directory
    #[arg(long, default_value = "state")]
    pub state_dir: PathBuf,

    /// Filter by resource type
    #[arg(long = "type")]
    pub resource_type: Option<String>,

    /// Show history
    #[arg(long)]
    pub history: bool,

    /// Show drift status
    #[arg(long)]
    pub drift: bool,

    /// Show stack-wide health summary
    #[arg(long)]
    pub health: bool,

    /// Show timing stats (avg, p50, p95, p99)
    #[arg(long)]
    pub timing: bool,

    /// Show change frequency (churn) for resources
    #[arg(long)]
    pub churn: bool,

    /// Show reversibility classification
    #[arg(long)]
    pub reversibility: bool,

    /// Fuse with git log history (RRF ranking)
    #[arg(short = 'G', long = "git-history")]
    pub git_history: bool,

    /// JSON output
    #[arg(long)]
    pub json: bool,

    /// CSV output
    #[arg(long)]
    pub csv: bool,

    /// Show the SQL query that would be executed
    #[arg(long)]
    pub sql: bool,

    /// Show recent events for matched resources
    #[arg(long)]
    pub events: bool,

    /// Show failure history (failed events only)
    #[arg(long)]
    pub failures: bool,

    /// Filter events since timestamp (ISO 8601 or relative like "1h", "7d")
    #[arg(long)]
    pub since: Option<String>,

    /// Filter by resource status (converged, drifted, failed)
    #[arg(long)]
    pub status: Option<String>,

    /// Filter events by run ID
    #[arg(long)]
    pub run: Option<String>,
}

/// FJ-2700: CLI arguments for `run` (dispatch mode task invocation).
#[derive(clap::Args, Debug)]
pub struct RunArgs {
    /// Task resource ID to run
    pub task: String,

    /// Path to forjar.yaml
    #[arg(short, long, default_value = "forjar.yaml")]
    pub file: PathBuf,

    /// Parameter overrides (key=value)
    #[arg(long = "param", value_name = "KEY=VALUE")]
    pub params: Vec<String>,

    /// JSON output
    #[arg(long)]
    pub json: bool,
}

/// FJ-3600: CLI arguments for `dist` (distribution artifact generation).
#[derive(clap::Args, Debug)]
pub struct DistArgs {
    /// Path to forjar.yaml
    #[arg(short, long, default_value = "forjar.yaml")]
    pub file: PathBuf,

    /// Generate shell installer script
    #[arg(long)]
    pub installer: bool,

    /// Generate Homebrew formula
    #[arg(long)]
    pub homebrew: bool,

    /// Generate cargo-binstall metadata
    #[arg(long)]
    pub binstall: bool,

    /// Generate Nix flake
    #[arg(long)]
    pub nix: bool,

    /// Generate GitHub Actions setup action
    #[arg(long)]
    pub github_action: bool,

    /// Generate Debian package spec
    #[arg(long)]
    pub deb: bool,

    /// Generate RPM spec file
    #[arg(long)]
    pub rpm: bool,

    /// Generate all distribution artifacts
    #[arg(long)]
    pub all: bool,

    /// Output file (for single artifact) or directory (with --all)
    #[arg(short, long)]
    pub output: Option<PathBuf>,

    /// Output directory (with --all)
    #[arg(long)]
    pub output_dir: Option<PathBuf>,

    /// JSON output (manifest of generated artifacts)
    #[arg(long)]
    pub json: bool,
}

/// FJ-52: CLI arguments for `image` (autoinstall ISO generation).
#[derive(clap::Args, Debug)]
pub struct ImageArgs {
    /// Path to forjar.yaml
    #[arg(short, long, default_value = "forjar.yaml")]
    pub file: PathBuf,

    /// Target machine name from machines: section
    #[arg(short, long)]
    pub machine: Option<String>,

    /// Generate user-data only (for manual ISO build or PXE)
    #[arg(long)]
    pub user_data: bool,

    /// Generate Android Magisk module ZIP (experimental)
    #[arg(long)]
    pub android: bool,

    /// Path to base Ubuntu ISO (required for --iso)
    #[arg(long)]
    pub base: Option<PathBuf>,

    /// Output path (ISO file or user-data YAML)
    #[arg(short, long)]
    pub output: Option<PathBuf>,

    /// Disk layout: auto-lvm, auto-zfs, or device path (default: auto-lvm)
    #[arg(long, default_value = "auto-lvm")]
    pub disk: String,

    /// Locale (default: en_US.UTF-8)
    #[arg(long, default_value = "en_US.UTF-8")]
    pub locale: String,

    /// Timezone (default: UTC)
    #[arg(long, default_value = "UTC")]
    pub timezone: String,

    /// JSON output
    #[arg(long)]
    pub json: bool,
}