Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion crates/ruff_cpp_codegen/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,14 @@ mod tests {
// generated text stops compiling in the consumer repo (operator-gated,
// rarely run) — this catches the render side in-env. (baton-auditor
// boundary guard.)
for field in ["name:", "params:", "ret:", "is_const:", "is_static:", "overrides:"] {
for field in [
"name:",
"params:",
"ret:",
"is_const:",
"is_static:",
"overrides:",
] {
assert!(
s.contains(field),
"rendered MethodSig literal must carry the `{field}` field"
Expand Down
5 changes: 4 additions & 1 deletion crates/ruff_csharp_spo/examples/validate_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ fn main() {
let ndjson = std::fs::read_to_string(std::env::args().nth(1).unwrap()).unwrap();
match ruff_csharp_spo::load(&ndjson) {
Ok(triples) => println!("LOAD OK: {} triples", triples.len()),
Err(e) => { println!("LOAD FAILED: {e}"); std::process::exit(1); }
Err(e) => {
println!("LOAD FAILED: {e}");
std::process::exit(1);
}
}
}
28 changes: 21 additions & 7 deletions crates/ruff_python_spo/examples/odoo_nav_probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,33 @@
use ruff_python_spo::{NavVocab, extract_odoo_nav_edges_with_report};

fn main() {
let root = std::env::args().nth(1).expect("usage: odoo_nav_probe <addon_root>");
let root = std::env::args()
.nth(1)
.expect("usage: odoo_nav_probe <addon_root>");
// Vocab: the account-addon core screens (normalized model names).
let screens = [
"account_move", "account_move_line", "res_partner", "res_company",
"account_account", "account_journal", "account_payment",
"account_bank_statement", "account_analytic_line", "account_tax",
"account_move",
"account_move_line",
"res_partner",
"res_company",
"account_account",
"account_journal",
"account_payment",
"account_bank_statement",
"account_analytic_line",
"account_tax",
];
let vocab = NavVocab { screens: screens.iter().map(|s| (*s).to_string()).collect() };
let vocab = NavVocab {
screens: screens.iter().map(|s| (*s).to_string()).collect(),
};
let (edges, report) = extract_odoo_nav_edges_with_report(std::path::Path::new(&root), &vocab);
println!(
"py={} xml={} raw_act_window={} files_with_edges={} edges={}",
report.py_files, report.xml_files, report.raw_act_window_refs,
report.files_with_edges, edges.len()
report.py_files,
report.xml_files,
report.raw_act_window_refs,
report.files_with_edges,
edges.len()
);
for e in &edges {
println!(" {} -> {} [{}] {}", e.source, e.target, e.via, e.file);
Expand Down
39 changes: 32 additions & 7 deletions crates/ruff_python_spo/examples/odoo_view_probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,39 @@ fn main() {
let target = ViewTarget {
model: "account_move".into(),
receivers: vec![],
fields: ["partner_id","date","amount_total","amount_untaxed","amount_tax",
"invoice_date","invoice_date_due","journal_id","currency_id","state",
"ref","narration","invoice_line_ids","line_ids","payment_state"]
.iter().map(|s| (*s).to_string()).collect(),
fields: [
"partner_id",
"date",
"amount_total",
"amount_untaxed",
"amount_tax",
"invoice_date",
"invoice_date_due",
"journal_id",
"currency_id",
"state",
"ref",
"narration",
"invoice_line_ids",
"line_ids",
"payment_state",
]
.iter()
.map(|s| (*s).to_string())
.collect(),
};
let (sets, report) = extract_odoo_view_field_sets_with_report(std::path::Path::new(&root), &[target]);
println!("xml={} view_records={} hits={}", report.xml_files, report.view_records, report.views_with_hits);
let (sets, report) =
extract_odoo_view_field_sets_with_report(std::path::Path::new(&root), &[target]);
println!(
"xml={} view_records={} hits={}",
report.xml_files, report.view_records, report.views_with_hits
);
for s in sets.iter().take(6) {
println!(" {} fields={}/{} referenced", s.view, s.fields.len(), s.referenced.len());
println!(
" {} fields={}/{} referenced",
s.view,
s.fields.len(),
s.referenced.len()
);
}
}
9 changes: 8 additions & 1 deletion crates/ruff_python_spo/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ use crate::{RawMethod, expr_str};
/// ruby's `AR_MUTATORS`: deliberately narrow (not every call, just the ORM's
/// own mutator vocabulary) per `.claude/knowledge/fuzzy-recipe-codebook.md`
/// §2.
const ORM_MUTATORS: &[&str] = &["create", "write", "unlink", "update", "copy", "flush_recordset"];
const ORM_MUTATORS: &[&str] = &[
"create",
"write",
"unlink",
"update",
"copy",
"flush_recordset",
];

/// Analyse a method into its decorator + body facts.
pub(crate) fn analyze_method(func: &StmtFunctionDef) -> RawMethod {
Expand Down
11 changes: 9 additions & 2 deletions crates/ruff_python_spo/src/odoo_nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,11 @@ class AccountMove(models.Model):
write(&dir, "models/account_move.py", PY_ACTION);
let v = vocab(&["account_move_line"]);
let (edges, report) = extract_odoo_nav_edges_with_report(&dir, &v);
assert_eq!(edges.len(), 1, "exactly the literal-res_model edge: {edges:?}");
assert_eq!(
edges.len(),
1,
"exactly the literal-res_model edge: {edges:?}"
);
assert_eq!(edges[0].source, "account_move");
assert_eq!(edges[0].target, "account_move_line");
assert_eq!(edges[0].via, "act_window_return");
Expand Down Expand Up @@ -532,7 +536,10 @@ class MoveExt(models.Model):
// `account_move_lines` (plural) deliberately does NOT match.
let v = vocab(&["account_move_lines"]);
let (edges, report) = extract_odoo_nav_edges_with_report(&dir, &v);
assert!(edges.is_empty(), "exact matching must reject the plural: {edges:?}");
assert!(
edges.is_empty(),
"exact matching must reject the plural: {edges:?}"
);
assert_eq!(report.raw_act_window_refs, 2);
cleanup(dir);
}
Expand Down
5 changes: 4 additions & 1 deletion crates/ruff_ruby_spo/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,10 @@ class M
end
"#,
);
assert!(funcs[0].writes.is_empty(), "ivar or-asgn must not be a field write");
assert!(
funcs[0].writes.is_empty(),
"ivar or-asgn must not be a field write"
);
assert!(funcs[0].guarded_writes.is_empty());
}

Expand Down
5 changes: 4 additions & 1 deletion crates/ruff_spo_triplet/src/exam_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ mod tests {
#[test]
fn malformed_region_row_with_no_separator_is_skipped() {
let cfg = parse("region=bogus\nregion=left:left_nav\n");
assert_eq!(cfg.regions, vec![("left".to_string(), "left_nav".to_string())]);
assert_eq!(
cfg.regions,
vec![("left".to_string(), "left_nav".to_string())]
);
}
}
2 changes: 1 addition & 1 deletion crates/ruff_spo_triplet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ pub use ir::{
};
pub use nav_digest::build_nav_digest;
pub use ndjson::{ParseError, from_ndjson, to_ndjson};
pub use reassemble::{cpp_projection, reassemble};
pub use quad::{MenuQuad, PurposeRole, PurposeRule, classify_purpose};
pub use reassemble::{cpp_projection, reassemble};
pub use recipe::{RecipeCentroid, classify, is_recoverable};
pub use region::{RegionFact, RegionSubject, region_triples};
pub use structured_names::{
Expand Down
65 changes: 55 additions & 10 deletions crates/ruff_spo_triplet/src/nav_digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ pub fn build_nav_digest(triples: &[Triple], config: &ExamConfig) -> String {
} else {
"leaf"
};
let _ = writeln!(out, "{node} loc={loc} purpose={purpose} id={id} action={action}");
let _ = writeln!(
out,
"{node} loc={loc} purpose={purpose} id={id} action={action}"
);
}

out
Expand Down Expand Up @@ -581,7 +584,12 @@ mod tests {
"form",
Provenance::Inferred,
),
Triple::new("app:Invoice", Predicate::Purpose, "list", Provenance::Inferred),
Triple::new(
"app:Invoice",
Predicate::Purpose,
"list",
Provenance::Inferred,
),
]
}

Expand Down Expand Up @@ -702,17 +710,44 @@ Invoice loc=Invoice purpose=list id=- action=root
..ExamConfig::default()
};
let triples = vec![
Triple::new("app:Root", Predicate::SurfacesConcept, "root_c", Provenance::Authoritative),
Triple::new("app:Mid", Predicate::SurfacesConcept, "mid_c", Provenance::Authoritative),
Triple::new("app:Leaf", Predicate::SurfacesConcept, "leaf_c", Provenance::Authoritative),
Triple::new("app:Mid", Predicate::PartOf, "app:Root", Provenance::Inferred),
Triple::new("app:Leaf", Predicate::PartOf, "app:Mid", Provenance::Inferred),
Triple::new(
"app:Root",
Predicate::SurfacesConcept,
"root_c",
Provenance::Authoritative,
),
Triple::new(
"app:Mid",
Predicate::SurfacesConcept,
"mid_c",
Provenance::Authoritative,
),
Triple::new(
"app:Leaf",
Predicate::SurfacesConcept,
"leaf_c",
Provenance::Authoritative,
),
Triple::new(
"app:Mid",
Predicate::PartOf,
"app:Root",
Provenance::Inferred,
),
Triple::new(
"app:Leaf",
Predicate::PartOf,
"app:Mid",
Provenance::Inferred,
),
Triple::new("app:Leaf", Predicate::Purpose, "form", Provenance::Inferred),
];
let digest = build_nav_digest(&triples, &config);
// Leaf's location is the full ancestor classid path, root-first.
assert!(
digest.contains("Leaf loc=0x0900/0x0910/0x0911 purpose=form id=0x0911 action=navigate"),
digest.contains(
"Leaf loc=0x0900/0x0910/0x0911 purpose=form id=0x0911 action=navigate"
),
"leaf must lower to the pure radix path 0x0900/0x0910/0x0911:\n{digest}"
);
// Root: parentless, has no out-edge here, so it is a leaf node with its
Expand All @@ -727,8 +762,18 @@ Invoice loc=Invoice purpose=list id=- action=root
#[test]
fn menu_quad_conflicting_part_of_is_order_independent() {
let mut triples = vec![
Triple::new("app:Leaf", Predicate::PartOf, "app:Zparent", Provenance::Inferred),
Triple::new("app:Leaf", Predicate::PartOf, "app:Aparent", Provenance::Inferred),
Triple::new(
"app:Leaf",
Predicate::PartOf,
"app:Zparent",
Provenance::Inferred,
),
Triple::new(
"app:Leaf",
Predicate::PartOf,
"app:Aparent",
Provenance::Inferred,
),
];
let forward = build_nav_digest(&triples, &config());
triples.reverse();
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.95"
channel = "1.97.1"
Loading