defmodule VavPipeline.LivenessTest do @moduledoc """ Kohen Day 3, restart 1 (2026-09-07): both probes pointed at /kodesh/health; a fresh pod with no manna read "degraded" → 503 → the kubelet killed a live, serving process every three minutes until the kohen wrote today.json. tamid §2.1 check 3: manna absent → WAIT. Not die. /kodesh/live answers one question — must this process be restarted — and looks at nothing that is a wait state. """ use ExUnit.Case, async: false use Plug.Test alias VavPipeline.BigdeiKodesh.Router alias VavPipeline.HaltMonitor @opts Router.init([]) setup do # Make sure no provision exists — the exact state of a fresh pod. File.rm(VavPipeline.Manna.provision_file()) # ...and no halt. halt_monitor_test leaves the monitor halted on some # seeds (0, 191243), and a fresh pod is not halted. if HaltMonitor.halted?(), do: HaltMonitor.resolve("liveness test setup") :ok end test "live is 200 with NO manna, while health is 503 (wait, not die)" do health = conn(:get, "/kodesh/health") |> Router.call(@opts) assert health.status == 503 assert Jason.decode!(health.resp_body)["checks"]["manna_present"] == "fail" live = conn(:get, "/kodesh/live") |> Router.call(@opts) assert live.status == 200 body = Jason.decode!(live.resp_body) assert body["live"] == true assert body["halt_monitor_alive"] == true assert body["halt_status"] == "running" end test "live is 200 while HALTED — a halt is a state, not a death" do HaltMonitor.halt!(:avodah_zarah, "liveness test", "test") try do assert HaltMonitor.halted?() live = conn(:get, "/kodesh/live") |> Router.call(@opts) assert live.status == 200 assert Jason.decode!(live.resp_body)["halt_status"] =~ "halted: avodah_zarah" # And the public ring says so, rather than serving. peah = conn(:post, "/peah/ask", Jason.encode!(%{question: "בראשית ברא אלהים"})) |> put_req_header("content-type", "application/json") |> Router.call(@opts) assert peah.status == 503 assert Jason.decode!(peah.resp_body)["error"]["code"] =~ "HALT_" after HaltMonitor.resolve("liveness test cleanup") end end test "live touches neither manna nor L3 nor the cycle" do VavPipeline.MannaLedger.reset() on_exit(fn -> VavPipeline.MannaLedger.reset() end) before = VavPipeline.MannaLedger.ledger() conn(:get, "/kodesh/live") |> Router.call(@opts) assert VavPipeline.MannaLedger.ledger() == before end end