MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / classify_enabled

Function classify_enabled

atomic-cli/src/commands/diagnostics/collect.rs:1199–1270  ·  view source on GitHub ↗

Decide whether an agent's Atomic hooks are active, and on what evidence. "Installed" (a receipt exists) and "enabled" (hooks are in the agent's live configuration) are separate questions: a receipt survives a user deleting the hooks by hand, and the built-in hooks need no receipt.

(
    receipt: Option<&ReceiptLookup>,
    settings: &[SettingsProbe],
)

Source from the content-addressed store, hash-verified

1197/// live configuration) are separate questions: a receipt survives a user
1198/// deleting the hooks by hand, and the built-in hooks need no receipt.
1199fn classify_enabled(
1200 receipt: Option<&ReceiptLookup>,
1201 settings: &[SettingsProbe],
1202) -> (Enabled, Vec<String>) {
1203 let mut evidence = Vec::new();
1204 for probe in settings {
1205 if matches!(
1206 probe.hooks,
1207 HookPresence::Present | HookPresence::Restricted
1208 ) {
1209 evidence.push(format!("Atomic hook commands present in {}", probe.path));
1210 }
1211 }
1212 let unreadable: Vec<String> = settings
1213 .iter()
1214 .filter_map(|probe| match &probe.hooks {
1215 HookPresence::Unreadable(reason) => {
1216 Some(format!("cannot inspect {}: {reason}", probe.path))
1217 }
1218 _ => None,
1219 })
1220 .collect();
1221 if !unreadable.is_empty() {
1222 return (Enabled::Unknown, unreadable);
1223 }
1224 if !evidence.is_empty() {
1225 if settings.iter().any(|probe| {
1226 matches!(
1227 probe.hooks,
1228 HookPresence::Disabled | HookPresence::Restricted
1229 )
1230 }) {
1231 return (
1232 Enabled::Unknown,
1233 vec![
1234 "a settings scope disables hooks; effective enablement cannot be verified"
1235 .to_string(),
1236 ],
1237 );
1238 }
1239 return (Enabled::Yes, evidence);
1240 }
1241 match receipt {
1242 None | Some(ReceiptLookup::Absent) => (Enabled::No, evidence),
1243 Some(ReceiptLookup::Unreadable(reason)) => (
1244 Enabled::Unknown,
1245 vec![format!("integration receipt unreadable: {reason}")],
1246 ),
1247 Some(ReceiptLookup::Found(receipt))
1248 if receipt.settings.is_empty() || settings.is_empty() =>
1249 {
1250 (
1251 Enabled::Unknown,
1252 vec![
1253 "the integration is installed, but its hooks are not in a settings file \
1254 Atomic can inspect"
1255 .to_string(),
1256 ],

Calls 5

pushMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
is_emptyMethod · 0.45
as_strMethod · 0.45