scud/commands/weave/mod.rs
1pub mod check;
2pub mod explain;
3pub mod gate;
4pub mod log;
5pub mod manage;
6pub mod record;
7pub mod release;
8pub mod status;
9pub mod summary;
10pub mod template;
11
12use clap::Subcommand;
13
14#[derive(Subcommand)]
15pub enum WeaveCommands {
16 /// Evaluate whether an event would be allowed
17 Check {
18 /// Event as JSON string
19 event_json: String,
20 },
21 /// Record that an event occurred (updates locks and event log)
22 Record {
23 /// Event as JSON string
24 event_json: String,
25 },
26 /// Release a specific mutex lock
27 Release {
28 /// Lock key to release
29 lock_key: String,
30 /// Agent releasing the lock (optional)
31 agent: Option<String>,
32 },
33 /// Release all locks held by an agent
34 ReleaseAll {
35 /// Agent whose locks to release
36 #[arg(long)]
37 agent: String,
38 /// Only release locks for this task
39 #[arg(long)]
40 task: Option<String>,
41 },
42 /// Initialize @weave section in active phase SCG
43 Init,
44 /// Add a b-thread to the @weave section
45 Add {
46 /// Thread ID (e.g. "w:1")
47 id: String,
48 /// Thread name
49 name: String,
50 /// Rule type (Mutex, Require, BlockAlways, BlockUntil, RateLimit, Timeout, Partition)
51 rule_type: String,
52 /// Rule spec as key=value pairs
53 #[arg(trailing_var_arg = true)]
54 rule_spec: Vec<String>,
55 },
56 /// Enable a b-thread
57 Enable {
58 /// Thread ID
59 id: String,
60 },
61 /// Disable a b-thread
62 Disable {
63 /// Thread ID
64 id: String,
65 },
66 /// Remove a b-thread
67 Remove {
68 /// Thread ID
69 id: String,
70 },
71 /// List all b-threads
72 List,
73 /// Show active locks, thread summary, and coordinator state
74 Status,
75 /// Show recent events from the event log
76 Log {
77 /// Number of recent events to show
78 #[arg(long, default_value = "20")]
79 tail: usize,
80 },
81 /// Explain why an event would be blocked (verbose output)
82 Explain {
83 /// Event as JSON string
84 event_json: String,
85 },
86 /// Show weave summary for orientation
87 Summary,
88 /// Gate command for PreToolUse hook integration
89 Gate {
90 /// Tool name (e.g. Write, Bash, Edit)
91 #[arg(long)]
92 tool: String,
93 /// Tool input as JSON string
94 #[arg(long)]
95 input: String,
96 },
97 /// Manage built-in b-thread templates
98 Template {
99 #[command(subcommand)]
100 command: TemplateCommands,
101 },
102}
103
104#[derive(Subcommand)]
105pub enum TemplateCommands {
106 /// List available templates
107 List,
108 /// Apply a template (adds disabled b-thread to @weave)
109 Apply {
110 /// Template name
111 name: String,
112 },
113}