1use vela_protocol::cli_style as style;
7
8mod atlas;
14pub(crate) use atlas::decl_graph;
15mod bounded_file;
16#[allow(dead_code)]
17pub(crate) mod decision_plan;
18mod frontier;
19pub(crate) use frontier::{cli_frontier, cli_read};
20mod write;
21pub(crate) use write::{cli_finding, cli_write, review_work};
22mod tools;
23mod withdrawal;
24pub(crate) use tools::{cli_check, cli_proof};
25mod config;
26pub(crate) mod git_hardened;
27pub(crate) use config::{cli_admin, cli_agents, cli_identity};
28#[allow(dead_code)]
31pub(crate) mod frontier_txn;
32mod operation_journal;
33pub(crate) mod review_material;
34mod server;
35mod target_index;
36pub(crate) mod ui;
37pub(crate) mod workflow;
38pub(crate) use server::{cli_commands, cli_engine, serve};
39pub use server::serve::McpService;
43
44pub mod cli;
45
46pub fn run() {
47 style::init();
52
53 if try_handle_atlas_r2_verify_intercept() {
59 return;
60 }
61
62 crate::cli::run_from_args();
63}
64
65fn try_handle_atlas_r2_verify_intercept() -> bool {
66 let argv: Vec<String> = std::env::args().collect();
67 if argv.len() < 3 {
68 return false;
69 }
70 match (argv[1].as_str(), argv[2].as_str()) {
71 ("conjecture", "verify") => {
72 handle_conjecture_verify(&argv[3..]);
73 true
74 }
75 ("proof-packet", "verify") => {
76 handle_proof_packet_verify(&argv[3..]);
77 true
78 }
79 ("proof-packet", "verify-external") => {
80 handle_proof_packet_verify_external(&argv[3..]);
81 true
82 }
83 _ => false,
84 }
85}
86
87fn handle_conjecture_verify(args: &[String]) {
88 let path = match args.first() {
89 Some(p) => p,
90 None => {
91 eprintln!(
92 "{} usage: vela conjecture verify <path>",
93 style::err_prefix()
94 );
95 std::process::exit(2);
96 }
97 };
98 let body = match std::fs::read_to_string(path) {
99 Ok(b) => b,
100 Err(e) => {
101 eprintln!("{} read {path}: {e}", style::err_prefix());
102 std::process::exit(1);
103 }
104 };
105 let conj: vela_protocol_core::conjecture::Conjecture = match serde_json::from_str(&body) {
106 Ok(c) => c,
107 Err(e) => {
108 eprintln!("{} parse {path}: {e}", style::err_prefix());
109 std::process::exit(1);
110 }
111 };
112 if let Err(e) = conj.verify() {
113 eprintln!("{} witness signature/id invalid: {e}", style::err_prefix());
114 std::process::exit(1);
115 }
116 let cosigs = match conj.verify_cosignatures() {
117 Ok(n) => n,
118 Err(e) => {
119 eprintln!("{} co-signature invalid: {e}", style::err_prefix());
120 std::process::exit(1);
121 }
122 };
123 println!(
124 " {} {} witness:{} cosigners:{} status:{:?}",
125 style::moss("conjecture verified"),
126 conj.id,
127 conj.witness.actor_id,
128 cosigs,
129 conj.status,
130 );
131}
132
133fn handle_proof_packet_verify(args: &[String]) {
134 let path = match args.first() {
135 Some(p) => p,
136 None => {
137 eprintln!(
138 "{} usage: vela proof-packet verify <path>",
139 style::err_prefix()
140 );
141 std::process::exit(2);
142 }
143 };
144 let body = match std::fs::read_to_string(path) {
145 Ok(b) => b,
146 Err(e) => {
147 eprintln!("{} read {path}: {e}", style::err_prefix());
148 std::process::exit(1);
149 }
150 };
151 let packet: vela_edge::proof_packet::ProofPacket = match serde_json::from_str(&body) {
152 Ok(p) => p,
153 Err(e) => {
154 eprintln!("{} parse {path}: {e}", style::err_prefix());
155 std::process::exit(1);
156 }
157 };
158 if let Err(e) = packet.verify() {
159 eprintln!("{} packet invalid: {e}", style::err_prefix());
160 std::process::exit(1);
161 }
162 println!(
163 " {} {} hash:{} signer:{}",
164 style::moss("proof packet verified"),
165 packet.packet_id,
166 &packet.packet_hash[..24],
167 packet.signer_actor_id,
168 );
169}
170
171fn handle_proof_packet_verify_external(args: &[String]) {
172 let path = match args.first() {
173 Some(p) => p,
174 None => {
175 eprintln!(
176 "{} usage: vela proof-packet verify-external <path>",
177 style::err_prefix()
178 );
179 std::process::exit(2);
180 }
181 };
182 let body = match std::fs::read_to_string(path) {
183 Ok(b) => b,
184 Err(e) => {
185 eprintln!("{} read {path}: {e}", style::err_prefix());
186 std::process::exit(1);
187 }
188 };
189 let packet: vela_edge::proof_packet::ProofPacket = match serde_json::from_str(&body) {
190 Ok(p) => p,
191 Err(e) => {
192 eprintln!("{} parse {path}: {e}", style::err_prefix());
193 std::process::exit(1);
194 }
195 };
196 if let Err(e) = packet.verify() {
197 eprintln!("{} packet invalid: {e}", style::err_prefix());
198 std::process::exit(1);
199 }
200 let n = match packet.verify_external_verifications() {
201 Ok(n) => n,
202 Err(e) => {
203 eprintln!("{} external verification invalid: {e}", style::err_prefix());
204 std::process::exit(1);
205 }
206 };
207 println!(
208 " {} {} external:{} (signer:{})",
209 style::moss("proof packet + externals verified"),
210 packet.packet_id,
211 n,
212 packet.signer_actor_id,
213 );
214}