gate: Shorashim between a caller and a model, with the fringe and rebuke once (bishe'arecha step 4)

Devarim 6:9 / 11:20 — on your gates. POST /gate/anthropic/v1/messages and
POST /gate/openai/v1/chat/completions take the model's own request shape
under the caller's own upstream key (x-api-key, or Authorization with the
courtyard key in X-Shorashim-Key), forward it unchanged (OTP inets/ssl,
verify_peer; the Korban socket is serial, so the upstream call is made
in the Vav Pipeline and the reply enters as korban like every bedikah),
examine the reply with the request in hand — sources = the system prompt
and the user turns, query = the last user turn; the model's prior turns
are not sources — and deliver it with its fringe (Bamidbar 15:39): a
trailer on the last text block naming ref, verdict, the rules with their
verses and sentences; X-Shorashim-Bedikah / X-Shorashim-Verdict; a
`shorashim` object. A non-200 passes through as it came; a reply with
no text is not delivered; stream is refused.

Rebuke once (Vayikra 19:17; X-Shorashim-Rebuke: once): a lo_tov reply is
answered once more with the finding; the second reply is examined like
the first, its record carries rebukes: <first ref> (migration
20261007000002), and it is delivered marked with both. Never a third.

Manna: one api_calls_external per upstream call, gathered before any
call. Stateless: no conversation, no key kept; the log is the path class.
Gate.bearer accepts X-Shorashim-Key. Construction §3.10, Tamid §1.1,
KOHEN "Standing at the gate", bishearecha §I/§III/§VII marked built.
Elixir 592/0 (+14 gate tests incl. a real httpc round trip to a local
model double), L3 9/0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Scott KarpandClaude Fable 5.1 committed 2026-10-07 11:38:32 +00:00
1 parent 47025fbfeb
commit 5c63273dba
16 files changed
+1082 -15

No files matched your search

+29
View File
@@ -555,6 +555,35 @@ omits. Seven in all.
`tov` means none fired on what could be read — not that the model is
aligned, not that the output is true. Read `limits` in the response.
### Standing at the gate — *Bishe'arecha*
A caller can put Shorashim between themselves and a model instead of
bringing the output by hand: point the model's own client at the gate
and add the courtyard key. The request goes through unchanged under the
caller's own model key (never stored, never logged); the reply comes
back examined, with the fringe on its last text block, the headers
`X-Shorashim-Bedikah` / `X-Shorashim-Verdict`, and a `shorashim` object.
```bash
# Anthropic client: base_url = http://<host>/gate/anthropic, plus the courtyard key
curl -s -X POST http://<host>/gate/anthropic/v1/messages \
-H "Authorization: Bearer <courtyard key>" \
-H "x-api-key: <your Anthropic key>" -H "anthropic-version: 2023-06-01" \
-H "X-Shorashim-Rebuke: once" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-4-5","max_tokens":400,"messages":[{"role":"user","content":"..."}]}'
# OpenAI client: base_url = http://<host>/gate/openai/v1, the OpenAI key in Authorization,
# the courtyard key in X-Shorashim-Key
```
`X-Shorashim-Rebuke: once` — a lo_tov reply is answered once more with
the finding, and the second reply is delivered marked with both refs.
Each upstream call spends one `api_calls_external` of the day's manna
(Day 4): a provision with 0 shuts the gate (503 MANNA_DEPLETED) while
the bedikah by hand still runs. Streaming is refused (422). A non-200
from the model passes through as it came. Tamid §1.1 has the contract.
### Friday before sunset — *Erev Shabbat*
Write a **double portion** manna provision (`type: "double"`, doubled compute_units). The system will cease processing at Shabbat onset. No provision is written on Shabbat.