Files
magpie/docs
yetone 7fcf642eed gateway: the request archive doesn't put an unmasked route back on masking (#3973)
wangbinyq (#3973, Discord #feedback): after v0.1.1840, with the request
archive on, a request to a provider set to go unmasked was still masked
whole before it was sent. ea53eb126 skipped masking only when
bodiesKeptAway() was false (internal/gateway/redact.go:272, called at
gateway.go:1947), and that was true whenever archiveDest() was on, or an
observer wanted bodies, so the archive put the masking pass back on
every request's way, the masked copy kept only for the archive.

Now an unmasked route is never masked on its way, whatever is on:
- The archive keeps the request as it went, as the log and recent calls
  do. Its secrets are taken out by redact.ScrubJSON in the background
  upload, as every archived body's are; the reply half was already as
  the local model wrote it.
- An observer that wants bodies (OTLP export, a JS plugin's) is handed
  them masked as before, masked once when withBodies first hands them
  over after a try (Call.maskIn, laterMasked), not before the send.
- bodiesKeptAway and serve's masked/plain swap are gone. count_tokens,
  embeddings, Jev and web search never read the archive switch.

docs/subsystems/gateway-routing.md says so.

Run on mote at this tree (rebased onto 6bec526f7):
- gofmt -l internal: none. GOOS=linux/windows go vet -tags nogui
  ./internal/gateway: ok (before the rebase, no gateway change since
  but upstream's own).
- go test -tags nogui -count=1 -timeout 45m ./...: 76 ok, no FAIL.
  (A run at the older base had TestPluginStreamsPastTheBudgetWait red,
  red alone too there; fixed upstream in 7fd77a944, green at this head.)
- Rebased again onto 9e33962c0 before the push (26 files, none in
  internal/gateway): go build -tags nogui ./... ok, and
  TestUnmaskedRouteIsNotMasked, TestArchive*, TestObserver*,
  TestPromptText* ok at the pushed head.
- TestUnmaskedRouteIsNotMasked gains "the request archive is on" and
  "the archive is on, unset", and checks what the observer and the
  bucket get.
- Broken by hand: with origin/main's gateway.go, redact.go and
  capture.go, "the request archive is on" is red ("masked 1 times,
  want masking false") and the observer case red (log masked).

Not run: a real magpie serve with the archive on against a local model
(ea53eb126's sandbox benchmark covers the archive-off case); a real S3
bucket; the GUI suite (no GUI file changed).
2026-10-28 16:53:54 +08:00
..