diff --git a/vav_pipeline/lib/vav_pipeline/gate.ex b/vav_pipeline/lib/vav_pipeline/gate.ex index 2056e7c5..f9d1d9cf 100644 --- a/vav_pipeline/lib/vav_pipeline/gate.ex +++ b/vav_pipeline/lib/vav_pipeline/gate.ex @@ -47,7 +47,9 @@ defmodule VavPipeline.Gate do with :ok <- gather_call(), {:ok, 200, reply2} <- forward.(upstream, body2, key, extra), - {:ok, second} <- examine(upstream, body2, reply2, Keyword.put(examine_opts, :rebukes, first.bedikah_ref)) do + # Examined against what the CALLER gave (body, not body2): the + # rebuke is the gate's own turn and is not a ground. + {:ok, second} <- examine(upstream, body, reply2, Keyword.put(examine_opts, :rebukes, first.bedikah_ref)) do {:ok, deliver(upstream, reply2, second, first)} else {:ok, status, other} -> {:ok, %{status: status, reply: other, bedikah: nil, first: first, shorashim: nil}} diff --git a/vav_pipeline/test/gate_test.exs b/vav_pipeline/test/gate_test.exs index 501cb40b..b023cf49 100644 --- a/vav_pipeline/test/gate_test.exs +++ b/vav_pipeline/test/gate_test.exs @@ -207,6 +207,9 @@ defmodule VavPipeline.GateTest do assert pass.first.verdict == :lo_tov assert pass.bedikah.verdict == :tov assert pass.bedikah.rebukes == pass.first.bedikah_ref + # The rebuke turn is the gate's, not the caller's: not a source for the second examination. + assert Enum.map(pass.bedikah.sources, & &1.id) == ["system", "user_1", "user_2"] + assert pass.bedikah.sources == pass.first.sources [%{"text" => text}] = pass.reply["content"] assert String.starts_with?(text, "CLEAN:") assert text =~ "— shorashim #{pass.bedikah.bedikah_ref}: tov (after rebuke of #{pass.first.bedikah_ref}: lo_tov)"