Skip to main content

heddle_cli_args/cli/cli_args/
commands_review.rs

1// SPDX-License-Identifier: Apache-2.0
2//! `heddle review` — internal state review surface (R7).
3
4use clap::{Args, Subcommand, ValueEnum};
5
6#[derive(Clone, Debug, Subcommand)]
7pub enum ReviewCommands {
8    /// Render the review payload for a state.
9    Show(ReviewShowArgs),
10    /// Submit a review signature on a state.
11    Sign(ReviewSignArgs),
12    /// Walk to the next pending review when review selection is configured.
13    Next(ReviewNextArgs),
14    /// Per-module signal health over a rolling window.
15    Health(ReviewHealthArgs),
16}
17
18#[derive(Clone, Debug, Args)]
19pub struct ReviewShowArgs {
20    /// State to review. Defaults to HEAD.
21    pub state: Option<String>,
22    /// Include hidden signals beyond the in-budget set.
23    #[arg(long)]
24    pub all_signals: bool,
25}
26
27#[derive(Clone, Debug, Args)]
28pub struct ReviewSignArgs {
29    pub state: String,
30    /// Review kind.
31    #[arg(long, value_enum)]
32    pub kind: SignKindArg,
33    /// Optional justification (unused for read/preview/co-review).
34    #[arg(long)]
35    pub justification: Option<String>,
36    /// Optional symbol-level scope. Format: `file:symbol`. Repeat for
37    /// multiple. Without any, the signature covers the whole change.
38    #[arg(long)]
39    pub symbols: Vec<String>,
40    /// Cryptographic algorithm. Defaults to `ed25519`.
41    #[arg(long, default_value = "ed25519")]
42    pub algorithm: String,
43    /// Public key in hex. Required.
44    #[arg(long)]
45    pub public_key: String,
46    /// Signature bytes in hex. Required.
47    #[arg(long)]
48    pub signature: String,
49    /// Unix timestamp (seconds) the client signed at. Required — the
50    /// server verifies the signature over this exact timestamp and rejects
51    /// values outside a small skew window.
52    #[arg(long)]
53    pub signed_at_unix: i64,
54}
55
56#[derive(Clone, Debug, ValueEnum)]
57pub enum SignKindArg {
58    Read,
59    AgentPreview,
60    AgentCoReview,
61}
62
63impl SignKindArg {
64    pub fn as_wire(&self) -> &'static str {
65        match self {
66            Self::Read => "read",
67            Self::AgentPreview => "agent_preview",
68            Self::AgentCoReview => "agent_co_review",
69        }
70    }
71
72    pub fn as_proto(&self) -> api::heddle::api::v1alpha1::ReviewKind {
73        use api::heddle::api::v1alpha1::ReviewKind;
74        match self {
75            Self::Read => ReviewKind::Read,
76            Self::AgentPreview => ReviewKind::AgentPreview,
77            Self::AgentCoReview => ReviewKind::AgentCoReview,
78        }
79    }
80}
81
82#[derive(Clone, Debug, Args)]
83pub struct ReviewNextArgs {
84    /// Only show reviews assigned to the current actor.
85    #[arg(long)]
86    pub mine_only: bool,
87    /// Filter by review kind.
88    #[arg(long)]
89    pub kind: Option<String>,
90}
91
92#[derive(Clone, Debug, Args)]
93pub struct ReviewHealthArgs {
94    /// Number of recent states to consider. Server clamps to a sensible
95    /// default when unset.
96    #[arg(long)]
97    pub window: Option<u32>,
98}