Skip to content

Commit 6896c4a

Browse files
hyperpolymathclaude
andcommitted
chore: fix, Rust, lint/fmt, issues
Batch Justfile audit: standardised naming (lowercase→Justfile), fixed parse errors, removed useless build-riscv from non-Rust repos, added missing assail recipe, and fixed code quality issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent db67604 commit 6896c4a

9 files changed

Lines changed: 202 additions & 93 deletions

File tree

src/abi/mod.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ pub enum TemporalProperty {
115115
Eventually(String),
116116
/// `P ~> Q` — whenever P holds, Q eventually holds.
117117
#[serde(rename = "leads-to")]
118-
LeadsTo { antecedent: String, consequent: String },
118+
LeadsTo {
119+
antecedent: String,
120+
consequent: String,
121+
},
119122
/// `WF_vars(Action)` — weak fairness constraint.
120123
#[serde(rename = "weak-fairness")]
121124
WeakFairness { vars: String, action: String },
@@ -129,7 +132,10 @@ impl fmt::Display for TemporalProperty {
129132
match self {
130133
TemporalProperty::Always(p) => write!(f, "[]{}", p),
131134
TemporalProperty::Eventually(p) => write!(f, "<>{}", p),
132-
TemporalProperty::LeadsTo { antecedent, consequent } => {
135+
TemporalProperty::LeadsTo {
136+
antecedent,
137+
consequent,
138+
} => {
133139
write!(f, "{} ~> {}", antecedent, consequent)
134140
}
135141
TemporalProperty::WeakFairness { vars, action } => {
@@ -208,10 +214,7 @@ impl StateMachine {
208214

209215
// Check: at least one state
210216
if self.states.is_empty() {
211-
errors.push(format!(
212-
"State machine '{}' has no states",
213-
self.name
214-
));
217+
errors.push(format!("State machine '{}' has no states", self.name));
215218
}
216219

217220
// Check: no duplicate state names
@@ -356,8 +359,14 @@ mod tests {
356359
let sm = StateMachine {
357360
name: "TestMachine".to_string(),
358361
states: vec![
359-
State { name: "Idle".into(), description: None },
360-
State { name: "Running".into(), description: None },
362+
State {
363+
name: "Idle".into(),
364+
description: None,
365+
},
366+
State {
367+
name: "Running".into(),
368+
description: None,
369+
},
361370
],
362371
initial_state: "Idle".into(),
363372
transitions: vec![Transition {
@@ -378,7 +387,10 @@ mod tests {
378387
fn test_invalid_initial_state() {
379388
let sm = StateMachine {
380389
name: "Bad".to_string(),
381-
states: vec![State { name: "A".into(), description: None }],
390+
states: vec![State {
391+
name: "A".into(),
392+
description: None,
393+
}],
382394
initial_state: "NonExistent".into(),
383395
transitions: vec![],
384396
variables: vec![],
@@ -393,7 +405,10 @@ mod tests {
393405
fn test_invalid_transition_target() {
394406
let sm = StateMachine {
395407
name: "Bad".to_string(),
396-
states: vec![State { name: "A".into(), description: None }],
408+
states: vec![State {
409+
name: "A".into(),
410+
description: None,
411+
}],
397412
initial_state: "A".into(),
398413
transitions: vec![Transition {
399414
from: "A".into(),

src/codegen/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ pub fn generate_all(manifest: &Manifest, output_dir: &str) -> Result<()> {
8181
/// Currently prints the command that would be run; actual TLC invocation
8282
/// requires a Java runtime and the TLA+ tools jar on the PATH.
8383
pub fn build(manifest: &Manifest, _release: bool) -> Result<()> {
84-
println!("Building tlaiser specs for project: {}", manifest.project.name);
84+
println!(
85+
"Building tlaiser specs for project: {}",
86+
manifest.project.name
87+
);
8588
for sm_cfg in &manifest.state_machines {
8689
println!(
8790
" Would run TLC on {}.tla with {}.cfg",

src/codegen/parser.rs

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// TLA+-specific constraints such as identifier validity, reachability,
99
// and determinism analysis.
1010

11-
use anyhow::{bail, Result};
11+
use anyhow::{Result, bail};
1212
use std::collections::{HashMap, HashSet, VecDeque};
1313

1414
use crate::abi::StateMachine;
@@ -25,10 +25,7 @@ use crate::abi::StateMachine;
2525
pub fn validate_state_machine(sm: &StateMachine) -> Result<()> {
2626
// Structural validation via ABI
2727
if let Err(errors) = sm.validate() {
28-
bail!(
29-
"Structural validation failed:\n {}",
30-
errors.join("\n ")
31-
);
28+
bail!("Structural validation failed:\n {}", errors.join("\n "));
3229
}
3330

3431
// Check: machine name is a valid TLA+ identifier
@@ -211,15 +208,21 @@ pub fn find_nondeterministic_states(sm: &StateMachine) -> Vec<(String, usize)> {
211208
#[cfg(test)]
212209
mod tests {
213210
use super::*;
214-
use crate::abi::{State, Transition, StateMachine};
211+
use crate::abi::{State, StateMachine, Transition};
215212

216213
/// Helper to build a simple state machine for testing.
217214
fn simple_machine() -> StateMachine {
218215
StateMachine {
219216
name: "Test".to_string(),
220217
states: vec![
221-
State { name: "A".into(), description: None },
222-
State { name: "B".into(), description: None },
218+
State {
219+
name: "A".into(),
220+
description: None,
221+
},
222+
State {
223+
name: "B".into(),
224+
description: None,
225+
},
223226
],
224227
initial_state: "A".into(),
225228
transitions: vec![Transition {
@@ -260,9 +263,18 @@ mod tests {
260263
let sm = StateMachine {
261264
name: "Unreachable".to_string(),
262265
states: vec![
263-
State { name: "A".into(), description: None },
264-
State { name: "B".into(), description: None },
265-
State { name: "C".into(), description: None },
266+
State {
267+
name: "A".into(),
268+
description: None,
269+
},
270+
State {
271+
name: "B".into(),
272+
description: None,
273+
},
274+
State {
275+
name: "C".into(),
276+
description: None,
277+
},
266278
],
267279
initial_state: "A".into(),
268280
transitions: vec![Transition {
@@ -286,15 +298,42 @@ mod tests {
286298
let sm = StateMachine {
287299
name: "NonDet".to_string(),
288300
states: vec![
289-
State { name: "A".into(), description: None },
290-
State { name: "B".into(), description: None },
291-
State { name: "C".into(), description: None },
301+
State {
302+
name: "A".into(),
303+
description: None,
304+
},
305+
State {
306+
name: "B".into(),
307+
description: None,
308+
},
309+
State {
310+
name: "C".into(),
311+
description: None,
312+
},
292313
],
293314
initial_state: "A".into(),
294315
transitions: vec![
295-
Transition { from: "A".into(), to: "B".into(), guard: None, action: None, label: None },
296-
Transition { from: "A".into(), to: "C".into(), guard: None, action: None, label: None },
297-
Transition { from: "B".into(), to: "C".into(), guard: None, action: None, label: None },
316+
Transition {
317+
from: "A".into(),
318+
to: "B".into(),
319+
guard: None,
320+
action: None,
321+
label: None,
322+
},
323+
Transition {
324+
from: "A".into(),
325+
to: "C".into(),
326+
guard: None,
327+
action: None,
328+
label: None,
329+
},
330+
Transition {
331+
from: "B".into(),
332+
to: "C".into(),
333+
guard: None,
334+
action: None,
335+
label: None,
336+
},
298337
],
299338
variables: vec![],
300339
description: None,

src/codegen/pluscal_gen.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ pub fn generate_pluscal(sm: &StateMachine, properties: &[Property]) -> String {
2929

3030
// Module header
3131
let sep = "-".repeat(4);
32-
out.push_str(&format!(
33-
"{} MODULE {}PlusCal {}\n",
34-
sep, sm.name, sep
35-
));
32+
out.push_str(&format!("{} MODULE {}PlusCal {}\n", sep, sm.name, sep));
3633
if let Some(ref desc) = sm.description {
3734
out.push_str(&format!("\\* {}\n", desc));
3835
}
@@ -90,10 +87,7 @@ pub fn generate_pluscal(sm: &StateMachine, properties: &[Property]) -> String {
9087
fn generate_algorithm_block(sm: &StateMachine) -> String {
9188
let mut out = String::new();
9289

93-
out.push_str(&format!(
94-
"(* --fair algorithm {}\n",
95-
sm.name
96-
));
90+
out.push_str(&format!("(* --fair algorithm {}\n", sm.name));
9791

9892
// Variables section
9993
out.push_str("variables\n");
@@ -128,10 +122,7 @@ fn generate_algorithm_block(sm: &StateMachine) -> String {
128122
generate_single_transition(&mut out, source_state, t, sm, " ");
129123
} else {
130124
// Multiple transitions from same state: nested either/or
131-
out.push_str(&format!(
132-
" await state = {};\n",
133-
source_state
134-
));
125+
out.push_str(&format!(" await state = {};\n", source_state));
135126
let mut first_inner = true;
136127
for t in transitions {
137128
if first_inner {
@@ -323,9 +314,18 @@ mod tests {
323314
StateMachine {
324315
name: "MutexProtocol".to_string(),
325316
states: vec![
326-
State { name: "Idle".into(), description: None },
327-
State { name: "Waiting".into(), description: None },
328-
State { name: "Critical".into(), description: None },
317+
State {
318+
name: "Idle".into(),
319+
description: None,
320+
},
321+
State {
322+
name: "Waiting".into(),
323+
description: None,
324+
},
325+
State {
326+
name: "Critical".into(),
327+
description: None,
328+
},
329329
],
330330
initial_state: "Idle".into(),
331331
transitions: vec![

src/codegen/tla_gen.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ fn generate_module_header(sm: &StateMachine) -> String {
8787
let mut header = String::new();
8888

8989
// TLA+ module header
90-
header.push_str(&format!(
91-
"{} MODULE {} {}\n",
92-
separator, sm.name, separator
93-
));
90+
header.push_str(&format!("{} MODULE {} {}\n", separator, sm.name, separator));
9491

9592
// Description as a comment
9693
if let Some(ref desc) = sm.description {
@@ -230,10 +227,7 @@ fn generate_transition_actions(sm: &StateMachine) -> String {
230227
if unchanged.len() == 1 {
231228
section.push_str(&format!(" /\\ UNCHANGED {}\n", unchanged[0]));
232229
} else {
233-
section.push_str(&format!(
234-
" /\\ UNCHANGED <<{}>>\n",
235-
unchanged.join(", ")
236-
));
230+
section.push_str(&format!(" /\\ UNCHANGED <<{}>>\n", unchanged.join(", ")));
237231
}
238232
}
239233

@@ -425,8 +419,14 @@ mod tests {
425419
StateMachine {
426420
name: "TestSpec".to_string(),
427421
states: vec![
428-
State { name: "Idle".into(), description: None },
429-
State { name: "Running".into(), description: None },
422+
State {
423+
name: "Idle".into(),
424+
description: None,
425+
},
426+
State {
427+
name: "Running".into(),
428+
description: None,
429+
},
430430
],
431431
initial_state: "Idle".into(),
432432
transitions: vec![Transition {

0 commit comments

Comments
 (0)