From 546acc0b18ef0c8fe94b802f0389b0a02ad387d7 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Wed, 4 Nov 2026 14:28:07 -0600 Subject: [PATCH] Make diagnostic AI explanations opt-in --- docs/app-ops.md | 5 +++-- docs/templates/app-ops.md.tmpl | 5 +++-- jeannie | 2 +- lib/jeannie/commands.sh | 11 ++++------- scripts/report-ui | 11 ++++++++--- tests/jeannie/test_status_modes.py | 6 ++++++ 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/docs/app-ops.md b/docs/app-ops.md index c9b340b..bf423dd 100644 --- a/docs/app-ops.md +++ b/docs/app-ops.md @@ -5,8 +5,9 @@ `./jeannie status` defaults to fast mode: it checks current host, cluster, workload, DNS, registry, and public-route health without log scans, OCI backup freshness, or an AI response. `./jeannie status --deep` adds those checks, -restart history, inventory/storage checks, and the optional AI hypothesis. -`--no-local-rca` suppresses the hypothesis; `--verbose` implies deep mode. The +restart history, and inventory/storage checks. Add `--ai` to request an +unverified AI hypothesis for status or a doctor. `--no-local-rca` disables it; +`--verbose` implies deep mode. The report identifies its mode, and fast mode cannot establish backup freshness or the absence of recent errors. Healing collects deep evidence and rejects an explicitly supplied fast status report. diff --git a/docs/templates/app-ops.md.tmpl b/docs/templates/app-ops.md.tmpl index c735980..4f1c15a 100644 --- a/docs/templates/app-ops.md.tmpl +++ b/docs/templates/app-ops.md.tmpl @@ -5,8 +5,9 @@ `./jeannie status` defaults to fast mode: it checks current host, cluster, workload, DNS, registry, and public-route health without log scans, OCI backup freshness, or an AI response. `./jeannie status --deep` adds those checks, -restart history, inventory/storage checks, and the optional AI hypothesis. -`--no-local-rca` suppresses the hypothesis; `--verbose` implies deep mode. The +restart history, and inventory/storage checks. Add `--ai` to request an +unverified AI hypothesis for status or a doctor. `--no-local-rca` disables it; +`--verbose` implies deep mode. The report identifies its mode, and fast mode cannot establish backup freshness or the absence of recent errors. Healing collects deep evidence and rejects an explicitly supplied fast status report. diff --git a/jeannie b/jeannie index 22c02f6..c33be20 100755 --- a/jeannie +++ b/jeannie @@ -110,7 +110,7 @@ Cluster Lifecycle Check Kubernetes/container tooling versions. Operator View And Reports - status [--fast|--deep] [--all|--details|--verbose|--json] Check current health; --deep includes logs and backups. + status [--fast|--deep] [--ai] [--all|--details|--verbose|--json] Check health; --deep includes logs and backups. status --heal-plan Build a guarded self-heal plan from status. status --heal Dry-run auto-eligible self-heal actions. scorecard Compact pass/warn/fail operator scorecard. diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index 00c6cb0..e4e911e 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -2420,9 +2420,6 @@ status_report() { fi if [[ "${requested_mode}" == deep || -n "${heal_mode}" || "${REPORT_UI_VERBOSE}" == true ]]; then JEANNIE_STATUS_MODE=deep - else - # Fast status reports deterministic health without waiting for a model. - local REPORT_UI_LOCAL_RCA=false fi if [[ -n "${heal_mode}" ]]; then @@ -2438,11 +2435,11 @@ status_report() { ((REPORT_UI_FAILURES == 0)) || cascade_status=1 report_ui_render "Jeannie Status" >"${status_json}" report_ui_cleanup - if [[ "${heal_mode}" == "plan" ]]; then - "${REPO_ROOT}/scripts/heal" plan --status-json "${status_json}" --ai - else - "${REPO_ROOT}/scripts/heal" apply --status-json "${status_json}" --ai + local -a heal_args=("${heal_mode}" --status-json "${status_json}") + if truthy "${REPORT_UI_LOCAL_RCA:-false}"; then + heal_args+=(--ai) fi + "${REPO_ROOT}/scripts/heal" "${heal_args[@]}" rm -f "${status_json}" return "${cascade_status}" fi diff --git a/scripts/report-ui b/scripts/report-ui index 7abe5b2..53c8f05 100644 --- a/scripts/report-ui +++ b/scripts/report-ui @@ -3,7 +3,7 @@ REPORT_UI_ONLY="${REPORT_UI_ONLY:-problems}" REPORT_UI_DETAILS=false REPORT_UI_JSON=false -REPORT_UI_LOCAL_RCA="${REPORT_UI_LOCAL_RCA:-true}" +REPORT_UI_LOCAL_RCA="${REPORT_UI_LOCAL_RCA:-false}" # shellcheck disable=SC2034 REPORT_UI_VERBOSE=false REPORT_UI_ROWS_FILE="" @@ -16,7 +16,8 @@ Report UI flags: --all Show ok, informational, skip, warning, and failing items. --details Show the compact report plus detail fields. --json Print structured JSON. - --no-local-rca Do not ask the local AI gateway for the focused RCA summary. + --ai Ask the local AI gateway for an unverified explanation. + --no-local-rca Disable the AI explanation, including when enabled by environment. --verbose Use the older full diagnostic output when supported. EOF } @@ -40,6 +41,10 @@ report_ui_parse_args() { REPORT_UI_JSON=true shift ;; + --ai) + REPORT_UI_LOCAL_RCA=true + shift + ;; --no-local-rca) REPORT_UI_LOCAL_RCA=false shift @@ -253,7 +258,7 @@ report_ui_render() { "${REPO_ROOT}/scripts/report-render" "${args[@]}" <"${REPORT_UI_ROWS_FILE}" - if [[ "${REPORT_UI_JSON}" != "true" ]] && truthy "${REPORT_UI_LOCAL_RCA:-true}"; then + if [[ "${REPORT_UI_JSON}" != "true" ]] && truthy "${REPORT_UI_LOCAL_RCA:-false}"; then report_ui_local_rca "${title}" fi } diff --git a/tests/jeannie/test_status_modes.py b/tests/jeannie/test_status_modes.py index c12b93e..96d04ce 100644 --- a/tests/jeannie/test_status_modes.py +++ b/tests/jeannie/test_status_modes.py @@ -35,6 +35,12 @@ class StatusModeTests(unittest.TestCase): self.assertEqual(result.returncode, 0) self.assertIn("mode=deep ai=false", result.stdout) + def test_ai_is_opt_in_for_either_mode(self): + for mode in ("--fast", "--deep"): + result = self.run_status(mode, "--ai") + self.assertEqual(result.returncode, 0) + self.assertIn("ai=true", result.stdout) + def test_conflicting_modes_are_rejected(self): self.assertNotEqual(self.run_status("--fast", "--deep").returncode, 0) self.assertNotEqual(self.run_status("--fast", "--heal").returncode, 0)