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