MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / looks_like_id

Function looks_like_id

crates/openshell-sandbox/src/mechanistic_mapper.rs:402–420  ·  view source on GitHub ↗

Heuristic: does a path segment look like an opaque identifier?

(segment: &str)

Source from the content-addressed store, hash-verified

400
401/// Heuristic: does a path segment look like an opaque identifier?
402fn looks_like_id(segment: &str) -> bool {
403 if segment.is_empty() {
404 return false;
405 }
406 // Pure numeric
407 if segment.chars().all(|c| c.is_ascii_digit()) && segment.len() >= 2 {
408 return true;
409 }
410 // UUID-ish (contains dashes, 32+ hex chars)
411 let hex_only: String = segment.chars().filter(char::is_ascii_hexdigit).collect();
412 if hex_only.len() >= 24 && segment.contains('-') {
413 return true;
414 }
415 // Long hex string (hash, token)
416 if hex_only.len() >= 16 && segment.len() == hex_only.len() {
417 return true;
418 }
419 false
420}
421
422/// Extract just the binary name from a full path.
423fn short_binary_name(path: &str) -> String {

Callers 1

generalise_pathFunction · 0.85

Calls 2

lenMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected