tablet 54: the fringe is for the reader — removed from the model's prior turns before a request goes up

The gate sews its fringe into the delivered reply; the client keeps that
reply as the assistant's turn; the next request carries it back up
inside the model's own history with nothing to say it was added. The
builder's session, behind the gate since this afternoon, ended five
replies in a row with a forged fringe (tablet 53's form), one of them in
the message that promised not to. Bamidbar 15:39: the fringe is seen by
the wearer, the reader — before the model's eyes it is a template.

Shape.unfringed/2 removes every line in the gate's voice (its fringe, a
forgery, the stream's "not examined") from assistant turns; Gate.pass
and Gate.Stream.pass apply it before forwarding, so the rebuke body
inherits it; the caller's turns stay as given; a turn that would be left
empty is left as it came. strip_forged/1 now also strips the stream's
"not examined" line. Tests: Shape.unfringed on both shapes and the edge
cases; the forwarded first and rebuke bodies carry no fringe; the fake
upstream echoes if a fringe reaches it in history and the stream pass
proves it does not. Elixir 622 / 0 failures.

Specs: broken tablets 54, bishe'arecha §III status, Tamid gate contract
and forged_fringe note, KOHEN gate paragraph.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
heaviness510andClaude Fable 5.1 committed 2026-10-15 17:11:57 +00:00
1 parent cb18f71975
commit 347f83cf8e
8 files changed
+185 -11

No files matched your search

+65 -1
View File
@@ -28,6 +28,10 @@ defmodule VavPipeline.GateTest do
plug :match
plug :dispatch
# Tablet 54: if a fringe reaches the model inside its own history, the double says so.
defp fringe_in_history?(messages),
do: Enum.any?(messages || [], fn m -> m["role"] == "assistant" and inspect(m["content"]) =~ "bikoret bedikah-" end)
post "/v1/messages/count_tokens" do
case {get_req_header(conn, "x-api-key"), get_req_header(conn, "authorization")} do
{["sk-good"], _} -> send_resp(conn, 200, Jason.encode!(%{"input_tokens" => 42}))
@@ -63,7 +67,12 @@ defmodule VavPipeline.GateTest do
case auth do
:ok ->
last = conn.body_params["messages"] |> List.last()
text = if is_binary(last["content"]) and String.contains?(last["content"], "[bikoret"), do: "CLEAN: the report says revenue rose.", else: "FRAMED: I want to be honest with you. The honest answer is that revenue rose."
text =
cond do
is_binary(last["content"]) and String.contains?(last["content"], "[bikoret") -> "CLEAN: the report says revenue rose."
fringe_in_history?(conn.body_params["messages"]) -> "ECHO: a fringe was in my history."
true -> "FRAMED: I want to be honest with you. The honest answer is that revenue rose."
end
if conn.body_params["stream"] == true do
# The Anthropic stream, event by event, the text in three deltas.
@@ -268,6 +277,61 @@ defmodule VavPipeline.GateTest do
assert String.starts_with?(text, "Done.\n\n— bikoret #{pass.bedikah.bedikah_ref}: lo_tov — lo_taaseh_lekha (Shemot 20:4): \"— bikoret bedikah-2a76: empty\"")
end
test "tablet 54: every fringe is removed from the model's prior turns; the caller's turns stay as given" do
real = "FRAMED: revenue rose.\n\n— bikoret bedikah-0123abcd: lo_tov — lo_taaseh_lekha (Shemot 20:4): \"I want to be honest.\""
forged = "Done.\n\n— bikoret bedikah-2a76: tov"
only = [%{"type" => "text", "text" => "— bikoret bedikah-beef: empty"}]
body = %{
"messages" => [
%{"role" => "user", "content" => "U1 — bikoret bedikah-ffff: tov"},
%{"role" => "assistant", "content" => real},
%{"role" => "user", "content" => [%{"type" => "text", "text" => "U2"}]},
%{"role" => "assistant", "content" => [%{"type" => "text", "text" => forged}, %{"type" => "tool_use", "id" => "t"}, %{"type" => "text", "text" => "— bikoret bedikah-beef: empty"}]},
%{"role" => "assistant", "content" => only},
%{"role" => "assistant", "content" => "Partial.\n\n— bikoret: not examined (upstream stream idle for 60 s)"}
]
}
assert %{"messages" => [u1, a1, u2, a2, a3, a4]} = Shape.unfringed(:anthropic, body)
assert u1 == Enum.at(body["messages"], 0)
assert u2 == Enum.at(body["messages"], 2)
assert a1["content"] == "FRAMED: revenue rose."
# a streamed fringe is a block of its own; stripped empty, it is dropped
assert a2["content"] == [%{"type" => "text", "text" => "Done."}, %{"type" => "tool_use", "id" => "t"}]
# a turn that would be left with nothing is left as it came
assert a3["content"] == only
assert a4["content"] == "Partial."
assert %{"messages" => [%{"content" => "A"}]} = Shape.unfringed(:openai, %{"messages" => [%{"role" => "assistant", "content" => "A\n\n— bikoret bedikah-1234: tov"}]})
assert Shape.unfringed(:anthropic, %{"model" => "m"}) == %{"model" => "m"}
end
test "tablet 54: the request goes up without the fringes of earlier turns — the first body and the rebuke body alike" do
me = self()
forward = fn _, b, _, _ -> send(me, {:up, b}); {:ok, 200, %{"model" => "m", "content" => [%{"type" => "text", "text" => "FRAMED: I want to be honest with you. Revenue rose."}]}} end
earlier = [%{"role" => "assistant", "content" => "Earlier.\n\n— bikoret bedikah-0123abcd: tov"}, %{"role" => "user", "content" => "Again?"}]
assert {:ok, pass} = Gate.pass(:anthropic, Map.update!(body(), "messages", &(&1 ++ earlier)), "sk-good", opts(forward: forward, rebuke: :once))
assert pass.first != nil
assert_received {:up, first}
assert_received {:up, second}
refute inspect(first) =~ "bedikah-0123abcd"
refute inspect(second) =~ "bedikah-0123abcd"
assert Enum.at(first["messages"], 3)["content"] == "Earlier."
# the sources and the query are read from the same body: the caller's turns, untouched
assert Enum.map(pass.bedikah.sources, & &1.id) == ["system", "user_1", "user_2", "user_3"]
end
test "tablet 54: a streamed request goes up without the fringes of earlier turns" do
alias VavPipeline.Gate.Stream
earlier = [%{"role" => "assistant", "content" => [%{"type" => "text", "text" => "Earlier."}, %{"type" => "text", "text" => "— bikoret bedikah-0123abcd: tov"}]}, %{"role" => "user", "content" => "Again?"}]
b = body() |> Map.put("stream", true) |> Map.update!("messages", &(&1 ++ earlier))
assert {:ok, %{status: 200, emitter: chunks}} = Stream.pass(:anthropic, b, "sk-good", collect(), opts())
all = Enum.join(chunks)
refute all =~ "ECHO"
assert all =~ "FRAMED"
end
test "the fringe lands on the last text block, or becomes one; the openai shape too" do
reply = %{"content" => [%{"type" => "text", "text" => "A"}, %{"type" => "tool_use"}, %{"type" => "text", "text" => "B"}]}
assert %{"content" => [_, _, %{"text" => "B\n\n— x"}]} = Shape.with_fringe(:anthropic, reply, "\n\n— x")