diff --git a/apps/opsproof/README.md b/apps/opsproof/README.md index d097628..5139de9 100644 --- a/apps/opsproof/README.md +++ b/apps/opsproof/README.md @@ -66,6 +66,14 @@ and presents bounded command-output excerpts, observed state, missing evidence, and root-cause hypotheses. Route input is restricted to Kubernetes application names and cannot become arbitrary Jeannie arguments. +The authenticated Orange Pi storage card and failing K3s runtime/storage rows +link to `/incidents/opi5/k3s-storage`. That exact route collects +`doctor opi5 --json` and can propose only `doctor opi5 --repair-k3s` when the +evidence specifically reports the guarded stale read-only mount signature. +Approval and execution revalidate the same evidence and fixed argument shape; +the host-side recovery independently refuses busy mounts, ambiguous disks, +filesystem identity mismatches, and pinned cluster identity mismatches. + For warning or failing evidence, the same page now builds a proposal-only view model tied to the Doctor execution and evidence IDs. It shows the exact focused Jeannie/Holmes action, preconditions, risk, deterministic validation, diff --git a/apps/opsproof/overlay/handlers/proposal/proposal.go b/apps/opsproof/overlay/handlers/proposal/proposal.go index 3dc0e71..77623d4 100644 --- a/apps/opsproof/overlay/handlers/proposal/proposal.go +++ b/apps/opsproof/overlay/handlers/proposal/proposal.go @@ -50,7 +50,11 @@ func Store(request *web.Request) *web.Response { if err != nil { return web.Fail(err) } - argumentsJSON, _ := json.Marshal([]string{scope, target, "--ai"}) + arguments, ok := services.RemediationArguments(scope, target) + if !ok { + return web.Abort(http.StatusForbidden) + } + argumentsJSON, _ := json.Marshal(arguments) operator := models.CurrentUser(request) proposal := models.RemediationProposal{ Scope: scope, Target: target, DoctorExecutionID: incident.ExecutionID, @@ -112,7 +116,7 @@ func Approve(request *web.Request) *web.Response { if err := json.Unmarshal([]byte(proposal.ArgumentsJSON), &arguments); err != nil { return web.Fail(err) } - if len(arguments) != 3 || arguments[0] != proposal.Scope || arguments[1] != proposal.Target || arguments[2] != "--ai" { + if !services.ValidRemediationArguments(proposal.Scope, proposal.Target, arguments) { return web.Abort(http.StatusForbidden) } @@ -177,7 +181,7 @@ func Execute(request *web.Request) *web.Response { if err := json.Unmarshal([]byte(proposal.ArgumentsJSON), &arguments); err != nil { return web.Fail(err) } - if len(arguments) != 3 || arguments[0] != proposal.Scope || arguments[1] != proposal.Target || arguments[2] != "--ai" { + if !services.ValidRemediationArguments(proposal.Scope, proposal.Target, arguments) { return web.Abort(http.StatusForbidden) } diff --git a/apps/opsproof/overlay/resources/js/pages/Welcome.tsx b/apps/opsproof/overlay/resources/js/pages/Welcome.tsx index dd0ae51..0130455 100644 --- a/apps/opsproof/overlay/resources/js/pages/Welcome.tsx +++ b/apps/opsproof/overlay/resources/js/pages/Welcome.tsx @@ -81,6 +81,16 @@ function doctorCommand(row: StatusRow) { return './jeannie doctor debian'; } +function incidentHref(row: StatusRow) { + if (row.area === 'Kubernetes apps') { + return `/incidents/cluster/${encodeURIComponent(row.check)}`; + } + if (row.area === 'Orange Pi' && (row.check === 'K3s runtime' || row.check === 'K3s storage mount')) { + return '/incidents/opi5/k3s-storage'; + } + return ''; +} + function LiveOverview({ overview }: { overview: Overview }) { const grouped = overview.rows.reduce>((areas, row) => { (areas[row.area] ??= []).push(row); @@ -161,9 +171,9 @@ function LiveOverview({ overview }: { overview: Overview }) { {doctorCommand(row)} - {row.area === 'Kubernetes apps' && ( + {incidentHref(row) && ( Open evidence → @@ -333,15 +343,14 @@ export default function Welcome({ laravelVersion, overview, operator }: Props) { - + Open live SSD evidence +

- Demo mode cannot submit changes + Live evidence is recollected before proposal, approval, and execution

diff --git a/apps/opsproof/overlay/services/jeannie.go b/apps/opsproof/overlay/services/jeannie.go index a3175bf..44fbc75 100644 --- a/apps/opsproof/overlay/services/jeannie.go +++ b/apps/opsproof/overlay/services/jeannie.go @@ -116,14 +116,20 @@ func (client *JeannieClient) Status(ctx context.Context) (StatusSnapshot, error) } func (client *JeannieClient) Doctor(ctx context.Context, scope string, target string) (IncidentSnapshot, error) { - if scope != "cluster" || !kubernetesApplicationName.MatchString(target) { + if !ValidDoctorTarget(scope, target) { return IncidentSnapshot{}, errors.New("unsupported Doctor target") } if client.BaseURL == "" || client.Token == "" { return IncidentSnapshot{}, errors.New("Jeannie API connection is not configured") } - completed, err := client.execute(ctx, "doctor", []string{scope, target, "--json"}, 60*time.Second) + args := []string{scope, target, "--json"} + nextCommand := "./jeannie doctor cluster " + target + " --details" + if scope == "opi5" { + args = []string{"opi5", "--json"} + nextCommand = "./jeannie doctor opi5 --details" + } + completed, err := client.execute(ctx, "doctor", args, 60*time.Second) if err != nil { return IncidentSnapshot{}, err } @@ -134,7 +140,7 @@ func (client *JeannieClient) Doctor(ctx context.Context, scope string, target st snapshot.Scope = scope snapshot.Target = target snapshot.ExecutionID = completed.ID - snapshot.NextCommand = "./jeannie doctor cluster " + target + " --details" + snapshot.NextCommand = nextCommand snapshot.Proposal = buildRemediationProposal(snapshot) snapshot.CollectedAt = time.Now().UTC().Format(time.RFC3339) return snapshot, nil @@ -160,6 +166,37 @@ func buildRemediationProposal(incident IncidentSnapshot) RemediationProposal { if len(proposal.EvidenceIDs) == 0 { return proposal } + if incident.Scope == "opi5" { + storageFailure := false + for _, evidence := range incident.Evidence { + if evidence.Area == "Orange Pi diagnostics" && evidence.Check == "K3s storage evidence" && + (evidence.Status == "warn" || evidence.Status == "fail") && strings.Contains(evidence.Summary, "Stale read-only K3s mount") { + storageFailure = true + break + } + } + if !storageFailure { + return proposal + } + proposal.Status = "blocked" + proposal.Summary = "Recover the stale Orange Pi K3s runtime only after the guarded storage workflow revalidates the mounted device and pinned cluster identity." + proposal.Action = "./jeannie doctor opi5 --repair-k3s" + proposal.RiskLevel = "high" + proposal.Preconditions = []string{ + "Revalidate that the cited stale read-only mount evidence is current.", + "Require failed or inactive K3s and exactly one unmounted USB ext4 candidate.", + "Verify the candidate filesystem against the pinned K3s CA before replacing the mount.", + "Supply an operator-reviewed rollback procedure.", + } + proposal.RiskNotes = []string{ + "The recovery stops private K3s workloads and changes host mount state.", + "A wrong storage identity could expose an unrelated filesystem, so device names are never trusted.", + "The workflow refuses busy mounts, ambiguous candidates, and cluster identity mismatches.", + } + proposal.Rollback = "No automatic rollback is assumed. Keep K3s stopped and the candidate unmounted if any identity or readiness validation fails." + proposal.Validation = []string{"./jeannie doctor opi5", "./jeannie status cluster"} + return proposal + } proposal.Status = "blocked" proposal.Summary = "Ask the focused Jeannie Doctor and Holmes workflow to diagnose, apply a supported targeted repair, and validate the result." @@ -181,7 +218,31 @@ func buildRemediationProposal(incident IncidentSnapshot) RemediationProposal { } func ValidDoctorTarget(scope string, target string) bool { - return scope == "cluster" && kubernetesApplicationName.MatchString(target) + return (scope == "cluster" && kubernetesApplicationName.MatchString(target)) || (scope == "opi5" && target == "k3s-storage") +} + +func RemediationArguments(scope string, target string) ([]string, bool) { + if scope == "cluster" && kubernetesApplicationName.MatchString(target) { + return []string{"cluster", target, "--ai"}, true + } + if scope == "opi5" && target == "k3s-storage" { + return []string{"opi5", "--repair-k3s"}, true + } + return nil, false + +} + +func ValidRemediationArguments(scope string, target string, arguments []string) bool { + expected, ok := RemediationArguments(scope, target) + if !ok || len(arguments) != len(expected) { + return false + } + for index := range expected { + if arguments[index] != expected[index] { + return false + } + } + return true } type execution struct { diff --git a/apps/opsproof/overlay/services/jeannie_test.go b/apps/opsproof/overlay/services/jeannie_test.go index 95cea44..79734fb 100644 --- a/apps/opsproof/overlay/services/jeannie_test.go +++ b/apps/opsproof/overlay/services/jeannie_test.go @@ -128,8 +128,64 @@ func TestDoctorNormalizesEvidenceAndRejectsArbitraryTargets(t *testing.T) { if _, err := client.Doctor(context.Background(), "cluster", "n8n;shutdown"); err == nil { t.Fatal("expected unsafe target to be rejected") } - if ValidDoctorTarget("debian", "docker") { - t.Fatal("only the cluster application drill-down is enabled in this slice") + if !ValidDoctorTarget("opi5", "k3s-storage") || ValidDoctorTarget("opi5", "docker") || ValidDoctorTarget("debian", "docker") { + t.Fatal("Doctor target allowlist does not match the supported cluster and K3s storage routes") + } +} + +func TestK3sStorageEvidenceBuildsOnlyTheGuardedRepair(t *testing.T) { + proposal := buildRemediationProposal(IncidentSnapshot{ + Scope: "opi5", + Target: "k3s-storage", + Evidence: []IncidentEvidence{{ + ID: "C01", Status: "fail", Area: "Orange Pi diagnostics", Check: "K3s storage evidence", + Summary: "Stale read-only K3s mount; the mounted device is no longer detected", + }}, + }) + if proposal.Action != "./jeannie doctor opi5 --repair-k3s" || proposal.Status != "blocked" { + t.Fatalf("unexpected K3s storage proposal: %#v", proposal) + } + arguments, ok := RemediationArguments("opi5", "k3s-storage") + if !ok || !ValidRemediationArguments("opi5", "k3s-storage", arguments) || ValidRemediationArguments("opi5", "k3s-storage", []string{"opi5", "--ai"}) { + t.Fatalf("unexpected K3s remediation arguments: %#v", arguments) + } +} + +func TestDoctorCollectsFocusedK3sStorageEvidence(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) { + switch request.URL.Path { + case "/v1/execute": + var payload struct { + Command string `json:"command"` + Args []string `json:"args"` + } + if err := json.NewDecoder(request.Body).Decode(&payload); err != nil { + t.Fatal(err) + } + if payload.Command != "doctor" || strings.Join(payload.Args, " ") != "opi5 --json" { + t.Fatalf("unexpected K3s Doctor payload: %#v", payload) + } + response.WriteHeader(http.StatusAccepted) + _, _ = response.Write([]byte(`{"id":"doctor-k3s","status":"queued"}`)) + case "/v1/executions/doctor-k3s": + _ = json.NewEncoder(response).Encode(RemoteExecution{ + ID: "doctor-k3s", Status: "failed", + Output: `{"title":"Jeannie Doctor: opi5","rows":[{"status":"fail","area":"Orange Pi diagnostics","check":"K3s storage evidence","summary":"Stale read-only K3s mount; the mounted device is no longer detected"}]}`, + }) + default: + http.NotFound(response, request) + } + })) + defer server.Close() + + client := NewJeannieClient(server.URL, "test-token") + client.PollInterval = time.Millisecond + incident, err := client.Doctor(context.Background(), "opi5", "k3s-storage") + if err != nil { + t.Fatal(err) + } + if incident.NextCommand != "./jeannie doctor opi5 --details" || incident.Proposal.Action != "./jeannie doctor opi5 --repair-k3s" { + t.Fatalf("unexpected K3s incident: %#v", incident) } } diff --git a/cmd/jeannie-server/main.go b/cmd/jeannie-server/main.go index 83bd58c..e62ba6f 100644 --- a/cmd/jeannie-server/main.go +++ b/cmd/jeannie-server/main.go @@ -126,13 +126,14 @@ func (w *statusWriter) Write(body []byte) (int, error) { } type server struct { - mu sync.RWMutex - exec map[string]*execution - repoRoot string - token string - temporal client.Client - requests map[string]*requestMetric - authFailures uint64 + mu sync.RWMutex + exec map[string]*execution + repoRoot string + token string + allowK3sRepair bool + temporal client.Client + requests map[string]*requestMetric + authFailures uint64 } func main() { @@ -142,10 +143,11 @@ func main() { } root, _ = filepath.Abs(root) s := &server{ - exec: make(map[string]*execution), - repoRoot: root, - token: os.Getenv("JEANNIE_SERVER_TOKEN"), - requests: make(map[string]*requestMetric), + exec: make(map[string]*execution), + repoRoot: root, + token: os.Getenv("JEANNIE_SERVER_TOKEN"), + allowK3sRepair: strings.EqualFold(os.Getenv("JEANNIE_REMOTE_K3S_REPAIR"), "true"), + requests: make(map[string]*requestMetric), } if os.Getenv("JEANNIE_EXECUTION_MODE") == "temporal" { address := os.Getenv("JEANNIE_TEMPORAL_ADDRESS") @@ -274,6 +276,10 @@ func (s *server) execute(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusForbidden, map[string]string{"error": "command is not remotely enabled"}) return } + if request.Command == "doctor" && len(request.Args) == 2 && request.Args[0] == "opi5" && request.Args[1] == "--repair-k3s" && !s.allowK3sRepair { + writeJSON(w, http.StatusForbidden, map[string]string{"error": "remote K3s storage recovery is disabled"}) + return + } if request.Command == "goose-graph" && (len(request.Args) == 0 || (request.Args[0] != "update" && request.Args[0] != "context")) { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "interactive goose-graph actions require a terminal; use context through the API"}) return diff --git a/cmd/jeannie-server/main_test.go b/cmd/jeannie-server/main_test.go index 5dbf0ac..fa4d85b 100644 --- a/cmd/jeannie-server/main_test.go +++ b/cmd/jeannie-server/main_test.go @@ -219,6 +219,24 @@ func TestRemoteGooseGraphRejectsInteractiveActions(t *testing.T) { } } +func TestRemoteK3sStorageRepairRequiresExplicitServerPolicy(t *testing.T) { + payload, _ := json.Marshal(executeRequest{Command: "doctor", Args: []string{"opi5", "--repair-k3s"}}) + server := &server{exec: make(map[string]*execution), repoRoot: t.TempDir()} + + response := httptest.NewRecorder() + server.execute(response, httptest.NewRequest(http.MethodPost, "/v1/execute", bytes.NewReader(payload))) + if response.Code != http.StatusForbidden { + t.Fatalf("disabled policy returned %d, want %d", response.Code, http.StatusForbidden) + } + + server.allowK3sRepair = true + response = httptest.NewRecorder() + server.execute(response, httptest.NewRequest(http.MethodPost, "/v1/execute", bytes.NewReader(payload))) + if response.Code != http.StatusAccepted { + t.Fatalf("enabled policy returned %d, want %d: %s", response.Code, http.StatusAccepted, response.Body.String()) + } +} + func TestDoctorRetrievalLabArgumentsReachAPIWorker(t *testing.T) { repo := t.TempDir() if err := os.WriteFile(filepath.Join(repo, "jeannie"), []byte("#!/bin/sh\nprintf '%s\\n' \"$@\"\n"), 0755); err != nil { diff --git a/docs/doctor-overview.md b/docs/doctor-overview.md index 4b5c012..1817022 100644 --- a/docs/doctor-overview.md +++ b/docs/doctor-overview.md @@ -194,7 +194,12 @@ verifies the CA and bind mount, starts K3s, and checks the live cluster identity It does not format a disk, run filesystem repair, or recreate the cluster. If any mount is busy or a check fails, recovery stops; the report identifies the last failure and further investigation is needed. A healthy K3s API does not -prove application health. The local runtime repair is refused through the API. +prove application health. Remote recovery remains disabled unless the Jeannie +API is deployed with +`JEANNIE_REMOTE_K3S_REPAIR=true`. When enabled, the API accepts only the +explicit `doctor opi5 --repair-k3s` recovery path. The host-side storage, +mount, pinned-CA and cluster-identity guards remain authoritative, and any +failed guard stops the recovery. The Gitea runner has a specific diagnosis: it compares the live Argo CD revision and Deployment with the committed zero-replica configuration, then diff --git a/docs/opsproof-architecture.md b/docs/opsproof-architecture.md index f753103..437cbbd 100644 --- a/docs/opsproof-architecture.md +++ b/docs/opsproof-architecture.md @@ -71,6 +71,10 @@ confirmed by deterministic validation. - Constrain incident routes to known target types, collect focused Doctor JSON server-side, and expose bounded evidence excerpts rather than executable commands or the complete private response. +- Treat `opi5/k3s-storage` as a dedicated target, not a free-form host route. + It may execute only the identity-pinned `doctor opi5 --repair-k3s` workflow + when the API policy is enabled and current evidence has the exact stale + read-only mount signature. - Bind every remediation proposal to one Doctor execution and its evidence IDs. Keep the proposal blocked when identity, current-evidence validation, or a target-specific rollback is absent; rendering a command never grants the diff --git a/infra/jeannie-temporal/deploy-remote.sh b/infra/jeannie-temporal/deploy-remote.sh index 8a344a9..982bebf 100644 --- a/infra/jeannie-temporal/deploy-remote.sh +++ b/infra/jeannie-temporal/deploy-remote.sh @@ -6,11 +6,16 @@ repo_root="${JEANNIE_PHASE2_REPO_ROOT:-${install_dir}/repo}" server_addr="${JEANNIE_SERVER_ADDR:-0.0.0.0:8787}" server_token="${JEANNIE_SERVER_TOKEN:?JEANNIE_SERVER_TOKEN is required}" temporal_ui_port="${JEANNIE_TEMPORAL_UI_PORT:-8233}" +allow_k3s_repair="${JEANNIE_REMOTE_K3S_REPAIR:-false}" if ! [[ "${temporal_ui_port}" =~ ^[0-9]+$ ]] || ((temporal_ui_port < 1 || temporal_ui_port > 65535)); then echo "JEANNIE_TEMPORAL_UI_PORT must be a TCP port between 1 and 65535." >&2 exit 1 fi +if [[ "${allow_k3s_repair}" != true && "${allow_k3s_repair}" != false ]]; then + echo "JEANNIE_REMOTE_K3S_REPAIR must be true or false." >&2 + exit 1 +fi command -v docker >/dev/null 2>&1 || { echo 'Docker is required on Debian' >&2; exit 1; } command -v go >/dev/null 2>&1 || { echo 'Go is required on Debian' >&2; exit 1; } @@ -52,6 +57,7 @@ JEANNIE_SERVER_REPO_ROOT=${repo_root} JEANNIE_EXECUTION_MODE=temporal JEANNIE_TEMPORAL_ADDRESS=127.0.0.1:7233 JEANNIE_TEMPORAL_TASK_QUEUE=jeannie +JEANNIE_REMOTE_K3S_REPAIR=${allow_k3s_repair} EOF sudo chown root:"$(id -gn)" /etc/jeannie/temporal.env sudo chmod 640 /etc/jeannie/temporal.env diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index 6e0991a..b79fdbc 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -5333,7 +5333,9 @@ deploy_api() { local target="${JEANNIE_SSH_TARGET:-debian-lab}" local staging="${JEANNIE_API_STAGING_DIR:-/tmp/jeannie-api}" local server_token="${JEANNIE_SERVER_TOKEN:-${JEANNIE_REMOTE_TOKEN:-}}" + local allow_k3s_repair="${JEANNIE_REMOTE_K3S_REPAIR:-true}" local quoted_token + local quoted_allow_k3s_repair if [[ -z "${server_token}" ]]; then echo "Set JEANNIE_SERVER_TOKEN before deploying the Jeannie API." >&2 @@ -5342,17 +5344,18 @@ deploy_api() { if [[ "$(uname -s)" == "Linux" ]] && [[ -r /etc/os-release ]] && grep -q '^ID=debian$' /etc/os-release; then - JEANNIE_SERVER_TOKEN="${server_token}" bash "${REPO_ROOT}/infra/jeannie-temporal/deploy-remote.sh" + JEANNIE_SERVER_TOKEN="${server_token}" JEANNIE_REMOTE_K3S_REPAIR="${allow_k3s_repair}" bash "${REPO_ROOT}/infra/jeannie-temporal/deploy-remote.sh" return 0 fi quoted_token="$(printf '%q' "${server_token}")" + quoted_allow_k3s_repair="$(printf '%q' "${allow_k3s_repair}")" echo "Staging the Jeannie API on ${target}..." tar -czf - cmd internal infra go.mod jeannie lib scripts homelab.yml | ssh -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new "${target}" \ "rm -rf '${staging}' && mkdir -p '${staging}' && tar -xzf - -C '${staging}'" ssh -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new "${target}" \ - "cd '${staging}' && JEANNIE_SERVER_TOKEN=${quoted_token} bash infra/jeannie-temporal/deploy-remote.sh" + "cd '${staging}' && JEANNIE_SERVER_TOKEN=${quoted_token} JEANNIE_REMOTE_K3S_REPAIR=${quoted_allow_k3s_repair} bash infra/jeannie-temporal/deploy-remote.sh" echo "Jeannie API deployed on ${target}." } diff --git a/scripts/doctor-focus b/scripts/doctor-focus index 4b2cfb3..0da7b45 100644 --- a/scripts/doctor-focus +++ b/scripts/doctor-focus @@ -469,8 +469,8 @@ doctor_focus() { if [[ "${1:-}" == opi5 && "${2:-}" == --repair-k3s ]]; then [[ $# == 2 ]] || { echo "Usage: ./jeannie doctor opi5 --repair-k3s" >&2; return 2; } require_debian_server "doctor opi5 --repair-k3s" - if [[ "${JEANNIE_REMOTE_SERVER:-false}" == true ]]; then - echo "K3s storage recovery requires the local Debian CLI." >&2 + if [[ "${JEANNIE_REMOTE_SERVER:-false}" == true && "${JEANNIE_REMOTE_K3S_REPAIR:-false}" != true ]]; then + echo "K3s storage recovery through the Jeannie API is disabled." >&2 return 2 fi record_change_journal "doctor-k3s-storage" "$@" diff --git a/tests/jeannie/test_doctor_focus.py b/tests/jeannie/test_doctor_focus.py index 4b706e4..3a96912 100644 --- a/tests/jeannie/test_doctor_focus.py +++ b/tests/jeannie/test_doctor_focus.py @@ -272,7 +272,7 @@ doctor_focus_holmes_fix n8n''' evidence = next((root / "artifacts").glob("focused.*/holmes-evidence.json")) self.assertIn("FailedMount", evidence.read_text()) - def test_k3s_storage_repair_is_refused_through_remote_api(self): + def test_k3s_storage_repair_requires_remote_api_policy(self): code = r''' source "$1" require_debian_server() { :; } @@ -282,9 +282,22 @@ JEANNIE_REMOTE_SERVER=true doctor_focus opi5 --repair-k3s ''' result = subprocess.run(["bash", "-c", code, "test", str(DOCTOR)], text=True, capture_output=True) self.assertEqual(result.returncode, 2) - self.assertIn("requires the local Debian CLI", result.stderr) + self.assertIn("through the Jeannie API is disabled", result.stderr) self.assertNotIn("unexpected", result.stdout) + def test_k3s_storage_repair_uses_guarded_script_when_remote_policy_is_enabled(self): + code = r''' +source "$1" +require_debian_server() { :; } +record_change_journal() { printf 'journaled\n'; } +python3() { printf '%s\n' "$*"; } +JEANNIE_REMOTE_SERVER=true JEANNIE_REMOTE_K3S_REPAIR=true doctor_focus opi5 --repair-k3s +''' + result = subprocess.run(["bash", "-c", code, "test", str(DOCTOR)], text=True, capture_output=True) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("journaled", result.stdout) + self.assertIn("doctor-k3s-storage.py repair", result.stdout) + def test_narrative_does_not_invent_or_execute_a_fix(self): with tempfile.TemporaryDirectory() as temp: rows = Path(temp) / "rows" diff --git a/tests/jeannie/test_privacy_services_pipeline.py b/tests/jeannie/test_privacy_services_pipeline.py index e5fabc2..e69e290 100644 --- a/tests/jeannie/test_privacy_services_pipeline.py +++ b/tests/jeannie/test_privacy_services_pipeline.py @@ -108,8 +108,8 @@ class OpsProofPipelineTests(unittest.TestCase): self.assertIn("Server-side, authenticated, fail-closed", page) self.assertIn("status all --json", page) self.assertIn("Command-backed evidence", page) - self.assertIn("Operator approval required", page) - self.assertIn("Demo mode cannot submit changes", page) + self.assertIn("Open live SSD evidence", page) + self.assertIn("Live evidence is recollected", page) self.assertIn("Live read-only inventory", page) self.assertIn("Desired: declared intent satisfied", page) self.assertIn("bearer token retained server-side", page) @@ -140,6 +140,8 @@ class OpsProofPipelineTests(unittest.TestCase): self.assertIn("ReadyForApproval bool", client) self.assertIn('proposal.Status = "blocked"', client) self.assertIn('"./jeannie doctor cluster " + incident.Target + " --ai"', client) + self.assertIn('"./jeannie doctor opi5 --repair-k3s"', client) + self.assertIn('target == "k3s-storage"', client) auth_handler = ( ROOT / "apps/opsproof/overlay/handlers/authentication/authentication.go" @@ -174,7 +176,7 @@ class OpsProofPipelineTests(unittest.TestCase): self.assertIn("EvidenceFingerprint", proposal_handler) self.assertIn("CommandAllowed", proposal_handler) self.assertIn("LockForUpdate", proposal_handler) - self.assertIn('arguments[2] != "--ai"', proposal_handler) + self.assertIn("ValidRemediationArguments", proposal_handler) proposal_page = ( ROOT / "apps/opsproof/overlay/resources/js/pages/Proposal.tsx"