sealmap-extract 0.4.0

Language-neutral extraction core for sealmap language adapters: raw flow IR, flow lowering, call aggregation, confidence policy, label rules, sym: id builder, token-stream fingerprints and panic-isolated collection
Documentation

sealmap-extract

crates.io docs.rs

The language-neutral half of a sealmap language adapter. A language adapter parses source and walks function bodies into a raw flow; everything after that is shared here, so every language gets flows, labels, ids and confidences by the same rules:

Module Owns
raw the raw flow IR (RawStep, RawCall, Callee, Recv) and walk-time shapers
lower flow normalisation: raw steps plus a call resolver → a model Flow
confidence the confidence lattice, the external-call policy, call-edge aggregation
labels label rules: token spacing, clipping limits, call/condition/closure labels
fingerprint per-symbol sig_hash / body_hash: BLAKE3 over a language-neutral, comment- and whitespace-free token stream
ids the sym: symbol-id builder
isolate per-file collection on big stacks with a panic guard (feature parallel: rayon)

It has no parser dependency; a language adapter brings its own.

use sealmap_extract::raw::{Callee, RawCall, RawStep};
use sealmap_extract::{ids, lower};
use sealmap_model::{CallKind, Confidence, SymbolKind};

let call = |name: &str| {
    RawStep::Call(RawCall::new(Callee::Path(vec![name.into()]), format!("{name}()"), CallKind::Function, 1))
};
let raw = vec![call("load"), RawStep::Loop("for x in xs".into(), vec![call("save")])];

let app = ids::module_id(&ids::package("cargo", "app"), &[]);
let flow = lower::lower_flow(&raw, &mut |c: &RawCall| {
    let Callee::Path(segs) = &c.callee else { return None };
    Some(c.to_call(ids::item_id(&app, SymbolKind::Function, &segs[0]), Confidence::Exact))
})
.unwrap();
let targets: Vec<_> = flow.calls().map(|c| c.target.to_string()).collect();
assert_eq!(targets, ["sym:cargo app . load().", "sym:cargo app . save()."]);

Licence

Licensed under either of Apache License, Version 2.0 or MIT licence, at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 licence, shall be dual licensed as above, without any additional terms or conditions.