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:
1 parent
47025fbfeb
commit
5c63273dba
16 files changed
+1082
-15
No files matched your search
+16
-3
@@ -48,7 +48,12 @@ through the gate — no caller has to supply them), and delivers the reply
|
||||
with its verdict attached. Construction §3.10 (to be written) specifies
|
||||
the protocol. The bedikah endpoint remains for an output brought by hand.
|
||||
|
||||
**Status.** Not built. The ingress and the keys exist; the gate does not.
|
||||
**Status.** Built (2026-10-07): `POST /gate/anthropic/v1/messages`,
|
||||
`POST /gate/openai/v1/chat/completions` — the model's own request shape,
|
||||
the caller's own upstream key, forwarded unchanged; sources = the system
|
||||
prompt and the user turns; Construction §3.10, Tamid §1.1. The upstream
|
||||
call is made in the Vav Pipeline (the Korban socket is serial); the
|
||||
reply enters as korban like every bedikah.
|
||||
|
||||
## II. The hand and between the eyes — Devarim 6:8, 11:18
|
||||
|
||||
@@ -90,7 +95,11 @@ sentences. Shorashim's own responses already carry `disclosure`; the
|
||||
pass-through reply does not. (Every generation: the mark is attached by
|
||||
the gate, never by the model — the model does not sew its own fringe.)
|
||||
|
||||
**Status.** Not built (depends on I).
|
||||
**Status.** Built (2026-10-07): the trailer on the last text block,
|
||||
`X-Shorashim-Bedikah` / `X-Shorashim-Verdict`, and the `shorashim`
|
||||
object on every delivered reply. A reply the model sends with no text
|
||||
block is not delivered; a non-200 from the model passes as it came,
|
||||
marked `none`.
|
||||
|
||||
## IV. The king's copy, from before the priests — Devarim 17:18–20
|
||||
|
||||
@@ -207,7 +216,10 @@ persists.
|
||||
**Architecture.** Gate option `rebuke: once`. The record (`bedikot`)
|
||||
gains a link from the second examination to the first.
|
||||
|
||||
**Status.** Not built (depends on I).
|
||||
**Status.** Built (2026-10-07): `X-Shorashim-Rebuke: once`;
|
||||
`bedikot.rebukes` (migration 20261007000002). The rebuke names the
|
||||
rules, their verses and the sentences; the second reply is examined like
|
||||
the first and delivered marked with both. Never a third.
|
||||
|
||||
## VIII. The scroll as witness; read before all every seventh year — Devarim 31:9–13, 26
|
||||
|
||||
@@ -308,6 +320,7 @@ In the order the text argues it, and by dependency:
|
||||
*Done 2026-10-07.*
|
||||
4. **The gate** (I), with the fringe (III) and the rebuke (VII) — the
|
||||
architecture's centre; the first three make it worth standing at.
|
||||
*Done 2026-10-07.*
|
||||
5. **The hakhel cycle and record** (VIII).
|
||||
6. **The second scroll** — the priests' copy of the mesorah (IV) — the
|
||||
largest work, and the one that turns "no Jewish source named" into
|
||||
|
||||
@@ -293,7 +293,8 @@ Recorded in L3 (`bedikot`, append-only): provenance, query, the output's
|
||||
SHA-256 and length — never the output itself — the sources by id,
|
||||
SHA-256 and length — never their text — vital content, propositions,
|
||||
references, claims with their anchors, authority claims, actions, the
|
||||
sentences read for checks 4–6, the forms found for check 7, trace, violations, verdict.
|
||||
sentences read for checks 4–6, the forms found for check 7, trace, violations, verdict,
|
||||
and at the gate `rebukes` — the ref of the examination this one answers.
|
||||
```
|
||||
|
||||
**Every rule cites its verse** (`bishearecha.md` §X; Devarim 4:2).
|
||||
@@ -362,6 +363,54 @@ Errors: as /courtyard/bedikah, with "side 'a': …" / "side 'b': …" in the
|
||||
message; a missing side is 422.
|
||||
```
|
||||
|
||||
**The gate — between a caller and a model** (`bishearecha.md` §I, §III,
|
||||
§VII; Construction §3.10; `VavPipeline.Gate`). The caller sends the
|
||||
model's own request, in the model's own API shape, under the caller's
|
||||
own upstream key; Shorashim forwards it unchanged, reads the reply as
|
||||
korban 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 delivers the reply with its fringe. Shorashim holds no
|
||||
model key and keeps no conversation.
|
||||
|
||||
```
|
||||
POST /gate/anthropic/v1/messages body: the Anthropic Messages request, unchanged
|
||||
POST /gate/openai/v1/chat/completions body: the OpenAI Chat Completions request, unchanged
|
||||
|
||||
Headers:
|
||||
Authorization: Bearer <courtyard key> (or X-Shorashim-Key: <courtyard key>)
|
||||
x-api-key: <your Anthropic key> forwarded; never stored, never logged
|
||||
Authorization: Bearer <your OpenAI key> with the courtyard key in X-Shorashim-Key
|
||||
anthropic-version: 2023-06-01 forwarded (default when absent)
|
||||
X-Shorashim-Rebuke: once optional — hocheach tochiach
|
||||
|
||||
Response (200): the upstream's reply, with
|
||||
- the fringe appended to its last text block:
|
||||
"\n\n— shorashim bedikah-<ref>: tov"
|
||||
"\n\n— shorashim bedikah-<ref>: lo_tov — <rule> (<verse>): \"<sentence…>\"; …"
|
||||
"… (after rebuke of bedikah-<first>: lo_tov)" when rebuked
|
||||
- headers X-Shorashim-Bedikah, X-Shorashim-Verdict
|
||||
- "shorashim": { bedikah_ref, verdict, violations, anchors, fired: ["<rule> (<verse>): …"],
|
||||
checks, sources: [{id, sha256, length}], model,
|
||||
rebuked?: {first_bedikah_ref, first_verdict}, disclosure }
|
||||
|
||||
Any non-200 from the upstream is returned as it came (X-Shorashim-Verdict: none).
|
||||
A stream request is refused (422): a fringe needs the whole garment.
|
||||
|
||||
Rebuke once: when X-Shorashim-Rebuke is "once" and the first reply is
|
||||
lo_tov, one second request = the first + the first reply as an
|
||||
assistant turn + one user turn naming the rules that fired, their verses
|
||||
and the sentences, asking for the answer again without them. The second
|
||||
reply is examined like the first (its record carries rebukes: <first
|
||||
ref>) and is the one delivered, marked with both. Never a third.
|
||||
|
||||
Manna: one api_calls_external per upstream call, one compute unit per
|
||||
examination; spent → 503 MANNA_DEPLETED before any call. Errors: 401/403
|
||||
(courtyard key), 422 (no upstream key, no messages, stream), 502
|
||||
UPSTREAM_UNAVAILABLE (the gate made no verdict and delivered nothing),
|
||||
503 KORBAN/TALMUDIC_UNAVAILABLE (a 200 from the model is never delivered
|
||||
unexamined).
|
||||
```
|
||||
|
||||
**Anchoring is deterministic and lexical** (`korban_processor/bedikah.py`):
|
||||
a claim is anchored in a source when six consecutive words of it occur
|
||||
there (`quote`), or when at least 60 % of its content words — and at
|
||||
|
||||
@@ -504,6 +504,65 @@ Errors: `{"status": "error", "code": PARSE_ERROR | INVALID_REQUEST | UNKNOWN_ACT
|
||||
|
||||
---
|
||||
|
||||
### 3.10 The Gate — Vav Pipeline between a caller and a model (bishe'arecha §I, §III, §VII)
|
||||
|
||||
**Protocol:** HTTPS outbound from the Vav Pipeline (OTP `inets`/`ssl`,
|
||||
the image's CA bundle, `verify_peer`), one request per pass; the
|
||||
request is the caller's own, in the model's own API shape, under the
|
||||
caller's own upstream key. Shorashim composes no korban here and holds
|
||||
no model key: it carries the request through, reads the reply as korban
|
||||
(§3.9), and delivers the reply with its fringe. The upstream call is
|
||||
made in the Vav Pipeline, not the Korban Processor, because the
|
||||
processor's socket serves one connection at a time with a 15 s call
|
||||
timeout and a model answers in up to 120 s; the reply still enters the
|
||||
processor as every bedikah does.
|
||||
|
||||
```
|
||||
POST /gate/anthropic/v1/messages body: an Anthropic Messages request, unchanged
|
||||
POST /gate/openai/v1/chat/completions body: an OpenAI Chat Completions request, unchanged
|
||||
|
||||
Headers:
|
||||
Authorization: Bearer <courtyard key> the gate (tablet 45) — or X-Shorashim-Key
|
||||
x-api-key: <caller's Anthropic key> forwarded, never stored, never logged
|
||||
Authorization: Bearer <caller's OpenAI key> when X-Shorashim-Key carries the courtyard key
|
||||
anthropic-version: ... forwarded (default 2023-06-01)
|
||||
X-Shorashim-Rebuke: once optional — hocheach tochiach (§VII)
|
||||
```
|
||||
|
||||
**What the gate does with it** (`VavPipeline.Gate`):
|
||||
|
||||
1. Forwards the body unchanged (the `stream` flag is refused: 422 — a
|
||||
fringe needs the whole garment). The upstream's status and body are
|
||||
returned verbatim on any non-200.
|
||||
2. Reads the reply's text (`content[].text` / `choices[0].message.content`)
|
||||
and examines it: provenance from the upstream (`anthropic → claude`,
|
||||
`openai → gpt`); **query** = the last user message's text; **sources**
|
||||
= the system prompt (`system`), each user message's text and document
|
||||
blocks (`user_1`, `user_2`, …) — the prior assistant turns are the
|
||||
model's own output and are not sources. Nothing the caller did not
|
||||
send is read.
|
||||
3. **The fringe** (§III): the delivered reply is the upstream's JSON with
|
||||
(a) a trailer appended to its last text block —
|
||||
`\n\n— shorashim <bedikah_ref>: <verdict>[ — <rule> (<verse>): "<sentence…>"…]`
|
||||
— (b) headers `X-Shorashim-Bedikah`, `X-Shorashim-Verdict`, and (c) a
|
||||
`shorashim` object: `{bedikah_ref, verdict, violations, anchors,
|
||||
checks, rebuked?: {first_bedikah_ref, first_verdict}}`. The mark is
|
||||
attached by the gate, never by the model.
|
||||
4. **Rebuke once** (§VII), when `X-Shorashim-Rebuke: once` and the first
|
||||
reply is `lo_tov`: a second upstream request = the first body +
|
||||
the first reply as an assistant turn + one user turn naming the
|
||||
rules that fired, their verses and the sentences, asking for the
|
||||
answer again without them. The second reply is examined like the
|
||||
first (its `bedikot` row carries `rebukes: <first ref>`), and is the
|
||||
one delivered — with both refs in the fringe. Never a third.
|
||||
5. Manna: one `api_calls_external` per upstream call, one compute unit per
|
||||
examination; depleted → 503 MANNA_DEPLETED before any call is made.
|
||||
|
||||
The gate is stateless: no conversation is kept, no key is kept, the
|
||||
log line is the path class and status (`NoTrackingLogger`). Upstream
|
||||
URLs are configured (`:gate_upstreams`) so the tests run against a local
|
||||
double; the production values are the vendors' endpoints.
|
||||
|
||||
## 4. SHEMEN HAMISHCHAH — Production Configuration
|
||||
|
||||
*Mor d'ror chamesh me'ot, v'kinmon besem machatzito chamishim u'matayim...* — exact recipes.
|
||||
|
||||
Reference in new issue
Block a user