MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / doctor_check_hooks

Function doctor_check_hooks

src/agents/codex.rs:1395–1440  ·  view source on GitHub ↗

Check hooks.json registers the tracedecay lifecycle hooks, and report Codex hook trust state from the user-level config.

(dc: &mut DoctorCounters, hooks_path: &Path, config_path: &Path)

Source from the content-addressed store, hash-verified

1393/// Check hooks.json registers the tracedecay lifecycle hooks, and report Codex
1394/// hook trust state from the user-level config.
1395fn doctor_check_hooks(dc: &mut DoctorCounters, hooks_path: &Path, config_path: &Path) {
1396 if !hooks_path.exists() {
1397 dc.warn(&format!(
1398 "{} not found — run `tracedecay install --agent codex` to add lifecycle hooks",
1399 hooks_path.display()
1400 ));
1401 return;
1402 }
1403 let hooks = super::load_json_file(hooks_path);
1404 let missing: Vec<&str> = CODEX_MANAGED_HOOKS
1405 .iter()
1406 .filter_map(|hook| {
1407 (!codex_hook_present(&hooks, hook.event, hook.subcommand)).then_some(hook.event)
1408 })
1409 .collect();
1410 if !missing.is_empty() {
1411 dc.warn(&format!(
1412 "tracedecay hook(s) missing for {} in {} — run `tracedecay install --agent codex`",
1413 missing.join(", "),
1414 hooks_path.display(),
1415 ));
1416 return;
1417 }
1418
1419 dc.pass(&format!(
1420 "All {} Codex lifecycle hooks registered in {}",
1421 CODEX_MANAGED_HOOKS.len(),
1422 hooks_path.display()
1423 ));
1424 match load_toml_file(config_path) {
1425 Ok(config) => match codex_plugin_hook_trust_state(&config) {
1426 CodexHookTrustState::Trusted => dc.info(&format!(
1427 "Codex hook trust entries recorded in {} — trust is pinned to hook content, so if hooks changed since trusting (e.g. after update-plugin), run /hooks in Codex to re-trust",
1428 config_path.display()
1429 )),
1430 CodexHookTrustState::Missing(missing) => dc.info(&format!(
1431 "Codex skips new/changed command hooks until trusted — missing trust for {} in {}; run `/hooks` in Codex",
1432 missing.join(", "),
1433 config_path.display()
1434 )),
1435 },
1436 Err(_) => dc.info(
1437 "Codex skips new/changed command hooks until trusted — run `/hooks` in Codex to trust the tracedecay hooks",
1438 ),
1439 }
1440}
1441
1442/// Suggests turning off Codex's native memories *injection* when tracedecay's
1443/// fact-store injection is active, so the model does not receive two parallel

Callers 1

doctor_check_plugin_dirFunction · 0.85

Calls 10

load_json_fileFunction · 0.85
codex_hook_presentFunction · 0.85
load_toml_fileFunction · 0.85
existsMethod · 0.80
warnMethod · 0.80
collectMethod · 0.80
passMethod · 0.80
is_emptyMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected