vela-cli 0.915.1

The vela command-line tool: build, check, sign, replay, and publish scientific frontier state.
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
#[cfg(test)]
mod surface_tests {
    //! Pins the released command surface to the clap enum, so the
    //! drift that silently broke `id` and `publish` this cycle (a real
    //! command rejected as "unknown or non-release") can never recur, and
    //! so the curated `help advanced` reference can never omit a command.
    use crate::cli::*;
    use clap::{CommandFactory, Parser};

    /// Building the ~226-node clap tree needs more than a default test
    /// thread's 2 MiB stack (it is fine on the 8 MiB main thread, where the
    /// CLI actually runs), so each test runs its body on a roomy stack.
    fn on_big_stack(f: impl FnOnce() + Send + 'static) {
        std::thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .spawn(f)
            .unwrap()
            .join()
            .unwrap();
    }

    fn released_names() -> Vec<String> {
        Cli::command()
            .get_subcommands()
            .map(|c| c.get_name().to_string())
            .collect()
    }

    #[test]
    fn every_clap_subcommand_is_released() {
        on_big_stack(|| {
            for name in released_names() {
                assert!(
                    is_science_subcommand(&name),
                    "clap exposes subcommand `{name}` but is_science_subcommand rejects it \
                     (a RELEASE_DENY entry, or a derivation bug) — it would 404 at dispatch"
                );
            }
        });
    }

    #[test]
    fn every_subcommand_is_documented_in_advanced_help() {
        on_big_stack(|| {
            let help = strict_help_text();
            for name in released_names() {
                // Commands curated out of the menu (HIDDEN_FROM_ADVANCED_HELP) stay
                // callable but are intentionally not listed; the guard applies
                // only to the canonical surface.
                if HIDDEN_FROM_ADVANCED_HELP.contains(&name.as_str()) {
                    continue;
                }
                let listed = help.lines().any(|l| {
                    let t = l.trim_start();
                    t == name || t.starts_with(&format!("{name} "))
                });
                assert!(
                    listed,
                    "subcommand `{name}` is not listed in `vela help advanced` \
                     (strict_help_text) — add a row so the reference stays complete, \
                     or add it to HIDDEN_FROM_ADVANCED_HELP if it is intentionally off-menu"
                );
            }
        });
    }

    /// Every visible command leads its `--help` with an EXAMPLES block
    /// (gh/clig.dev). The block is an `after_long_help` const in
    /// `cli/help_text.rs`; a new verb without one fails here. `policy` is
    /// intercepted before clap and carries its examples in the hand-rolled
    /// typed command tree and carries the same `after_long_help` contract.
    #[test]
    fn every_visible_command_has_examples() {
        on_big_stack(|| {
            let cmd = Cli::command();
            let mut missing = Vec::new();
            for c in cmd.get_subcommands() {
                if c.is_hide_set() {
                    continue; // hidden (completions) is off-menu
                }
                let has = c
                    .get_after_long_help()
                    .or_else(|| c.get_after_help())
                    .map(|s| s.to_string().contains("EXAMPLES"))
                    .unwrap_or(false);
                if !has {
                    missing.push(c.get_name().to_string());
                }
            }
            assert!(
                missing.is_empty(),
                "these visible commands lack an EXAMPLES block (add a const in \
                 cli/help_text.rs and wire `#[command(after_long_help = …)]`): {missing:?}"
            );
        });
    }

    #[test]
    fn policy_has_one_typed_parser_for_every_released_verb() {
        on_big_stack(|| {
            for args in [
                vec!["vela", "policy", "show", ".", "--json"],
                vec!["vela", "policy", "suggest", ".", "--json"],
                vec![
                    "vela",
                    "policy",
                    "draft",
                    "witness-rederivation",
                    ".",
                    "--json",
                ],
                vec!["vela", "policy", "draft", ".", "--from-suggest", "--json"],
                vec![
                    "vela",
                    "policy",
                    "draft",
                    "search-witness",
                    ".",
                    "--packet-root",
                    "sha256:1111111111111111111111111111111111111111111111111111111111111111",
                    "--profile-root",
                    "sha256:2222222222222222222222222222222222222222222222222222222222222222",
                    "--verifier-capsule-root",
                    "sha256:3333333333333333333333333333333333333333333333333333333333333333",
                    "--result-contract-root",
                    "sha256:4444444444444444444444444444444444444444444444444444444444444444",
                    "--json",
                ],
                vec!["vela", "policy", "test", ".", "--json"],
                vec![
                    "vela",
                    "policy",
                    "evaluate-proposal",
                    ".",
                    "vpr_example",
                    "--json",
                ],
                vec![
                    "vela",
                    "policy",
                    "decide",
                    ".",
                    "--activate",
                    "vap_example",
                    "--reason",
                    "bounded rules",
                    "--json",
                ],
                vec!["vela", "policy", "sign", ".", "--yes", "--json"],
                vec![
                    "vela", "policy", "revoke", ".", "--reason", "rotate", "--yes", "--json",
                ],
                vec![
                    "vela",
                    "policy",
                    "retire-legacy",
                    ".",
                    "--reason",
                    "retire",
                    "--as",
                    "agent:test",
                    "--json",
                ],
                vec!["vela", "policy", "log", ".", "--json"],
            ] {
                Cli::try_parse_from(&args).unwrap_or_else(|error| {
                    panic!("typed policy parse failed for {args:?}: {error}")
                });
            }
            assert!(
                Cli::try_parse_from([
                    "vela",
                    "policy",
                    "draft",
                    "witness-rederivation",
                    ".",
                    "unexpected-third-operand",
                ])
                .is_err(),
                "draft must not accept more than its typed operand budget"
            );
            assert!(
                Cli::try_parse_from([
                    "vela",
                    "policy",
                    "draft",
                    "search-witness",
                    ".",
                    "--packet-root",
                    "sha256:1111111111111111111111111111111111111111111111111111111111111111",
                ])
                .is_err(),
                "an incomplete exact binding must fail in the typed parser"
            );
        });
    }

    #[test]
    fn land_execution_binding_is_all_or_nothing_and_file_exclusive() {
        on_big_stack(|| {
            let roots = [
                "--packet-root",
                "sha256:1111111111111111111111111111111111111111111111111111111111111111",
                "--profile-root",
                "sha256:2222222222222222222222222222222222222222222222222222222222222222",
                "--verifier-capsule-root",
                "sha256:3333333333333333333333333333333333333333333333333333333333333333",
                "--result-contract-root",
                "sha256:4444444444444444444444444444444444444444444444444444444444444444",
            ];
            let mut complete = vec![
                "vela",
                "land",
                "--claim",
                "bounded result",
                "--type",
                "computational",
                "--replayability",
                "exact",
            ];
            complete.extend(roots);
            assert!(Cli::try_parse_from(complete).is_ok());
            assert!(
                Cli::try_parse_from([
                    "vela",
                    "land",
                    "--claim",
                    "bounded result",
                    "--type",
                    "computational",
                    "--replayability",
                    "exact",
                    "--packet-root",
                    "sha256:1111111111111111111111111111111111111111111111111111111111111111",
                ])
                .is_err()
            );
            let mut foreign = vec!["vela", "land", "receipt.json"];
            foreign.extend(roots);
            assert!(Cli::try_parse_from(foreign).is_err());
        });
    }

    #[test]
    fn repository_maintenance_modes_are_exactly_one_and_help_is_truthful() {
        on_big_stack(|| {
            let migrate = [
                "vela",
                "migrate",
                ".",
                "--profile",
                "../frontier-profile.yaml",
                "--target-candidate",
                "../target-index-candidate.json",
                "--as",
                "reviewer:repository-administrator",
                "--reason",
                "bind the exact repository",
            ];
            assert!(Cli::try_parse_from(migrate).is_err());
            for mode in ["--check", "--apply"] {
                let mut args = migrate.to_vec();
                args.push(mode);
                assert!(Cli::try_parse_from(args).is_ok(), "{mode} must parse alone");
            }
            let mut both = migrate.to_vec();
            both.extend(["--check", "--apply"]);
            assert!(Cli::try_parse_from(both).is_err());

            let seal = [
                "vela",
                "target-index",
                "seal",
                ".",
                "--candidate",
                "../target-index-candidate.json",
            ];
            assert!(Cli::try_parse_from(seal).is_err());
            for mode in ["--check", "--apply"] {
                let mut args = seal.to_vec();
                args.push(mode);
                assert!(Cli::try_parse_from(args).is_ok(), "{mode} must parse alone");
            }
            let mut both = seal.to_vec();
            both.extend(["--check", "--apply"]);
            assert!(Cli::try_parse_from(both).is_err());

            let migrate_help = match Cli::try_parse_from(["vela", "migrate", "--help"]) {
                Ok(_) => panic!("--help must exit through clap"),
                Err(error) => error.to_string(),
            };
            assert!(!migrate_help.contains("--check --apply"));
            assert!(migrate_help.contains("Exact acting identity"));
            assert!(crate::cli::help_text::SERVE.contains("--http 3741"));
            assert!(!crate::cli::help_text::SERVE.contains("hub.constellate.science"));
        });
    }

    /// The v0.912 product surface, guarded in both directions. A dropped
    /// command and an unreviewed addition both fail this test.
    const V0912_VISIBLE: &[&str] = &[
        "actor",
        "agents",
        "artifact",
        "check",
        "ci",
        "config",
        "doctor",
        "finding",
        "frontier",
        "gate",
        "id",
        "init",
        "land",
        "log",
        "migrate",
        "next",
        "policy",
        "proof",
        "reproduce",
        "review",
        "serve",
        "sign",
        "status",
        "verify",
        "work",
    ];
    const V0900_HIDDEN: &[&str] = &["completions", "target-index"];

    #[test]
    fn v0900_surface_is_exact_both_directions() {
        on_big_stack(|| {
            let cmd = Cli::command();
            let mut visible: Vec<String> = Vec::new();
            let mut hidden: Vec<String> = Vec::new();
            for c in cmd.get_subcommands() {
                if c.is_hide_set() {
                    hidden.push(c.get_name().to_string());
                } else {
                    visible.push(c.get_name().to_string());
                }
            }
            visible.sort();
            hidden.sort();
            let want_visible: Vec<String> = V0912_VISIBLE.iter().map(|s| s.to_string()).collect();
            let want_hidden: Vec<String> = V0900_HIDDEN.iter().map(|s| s.to_string()).collect();
            assert_eq!(
                visible, want_visible,
                "the VISIBLE surface drifted — a removal broke the porcelain, or an \
                 addition must be a deliberate baseline change"
            );
            assert_eq!(
                hidden, want_hidden,
                "the HIDDEN surface drifted — hiding/unhiding is a deliberate act"
            );
        });
    }

    #[test]
    fn retired_verbs_are_not_reachable() {
        on_big_stack(|| {
            for name in [
                "history",
                "accept-batch",
                "normalize",
                "ingest",
                "claim",
                "campaign",
                "lean",
                "attempt",
                "transfer",
                "experiment",
                "registry",
                "publish",
                "clone",
                "workspace",
                "attest",
                "receipt",
                "submit",
                // the v0.738 hard cut: ten verbs retired into the loop
                "inbox",
                "propose",
                "accept",
                "record",
                "pack",
                "attach",
                "queue",
                // the v0.900 product cut: replaced or moved out of core
                "atlas",
                "credit",
                "diff",
                "foundry",
                "hub",
                "proposals",
                "publication",
                "reproduce-external",
                "state",
            ] {
                assert!(
                    !is_science_subcommand(name),
                    "retired verb `{name}` is still reachable — the cut regressed"
                );
            }
        });
    }

    #[test]
    fn proposal_scoped_verification_commands_parse_exactly() {
        on_big_stack(|| {
            assert!(
                Cli::try_parse_from([
                    "vela",
                    "verify",
                    "attach",
                    ".",
                    "attachment.json",
                    "--proposal",
                    "vpr_fixture",
                    "--as",
                    "verifier:independent",
                    "--json",
                ])
                .is_ok()
            );
            assert!(
                Cli::try_parse_from([
                    "vela",
                    "reproduce",
                    ".",
                    "--proposal",
                    "vpr_fixture",
                    "--json",
                ])
                .is_ok()
            );
        });
    }
}