xRayySummers on X (0.1.1877, Linux, AstrLink Guard turned on in
Settings -> Privacy): in one minute masking took 1.2s to 290s, and each
request whose wait ended was "gateway: masking failed, so nothing was
sent".
Cause: the model reads on the CPU one chunk at a time on one turn,
about 6 KB a second on 8 Linux cores. A burst of requests with text it
hadn't read (new tool results, subagents at once) queued behind each
other, and the turn goes round between chunks, so all of them finished
near the end of the burst. Turned on by the user, the wait had no
bound, and when anything ended it (the client, a deadline) masking.model
panicked: the request was held back whole, and even the finds already
cached for its history were thrown away (backend.find returned nil).
Not a reload (60-90ms) and not a lock in redact.
Now:
- pii.FindContext, when the wait ends, answers with what was known of
the texts (its cache: earlier turns' history, chunks read meanwhile)
and a *pii.Partial saying how many it hadn't read.
- masking.model waits at most strictWait (15s) for the user's model,
defaultWait (2s) for the default's as before. Past it, the model's
finds mask what it read and the rules mask the rest alone; the request
goes. Nothing the rules mask goes as written. Logged once a minute.
- A model that fails (not on disk, didn't load, held back after a
failure) still holds the user's requests back, as before: broken, not
busy.
- masking.find gives a model that doesn't stop for ctx 100ms (handBack)
to hand back what it knew, so a partial answer racing ctx.Done isn't
dropped.
- docs/subsystems/gateway-routing.md says so, with the numbers below.
Run:
- Reproduced with the real AstrLink Guard (guard-7216b6a3) on Linux
(wsl-run, magpie-desktop, GOMAXPROCS=8), a throwaway test not
committed: load 63-87ms, reload on a request 57ms, a 125 KB history
20.8s first read and 66us cached; six requests at once with 67-145 KB
of new text each took 62, 91, 92, 108, 108 and 110s on the old code.
With this change each went at 15.0s with the history's 14 finds and
the model's finds for 1 to 4 of its 9 texts.
- mote-run at df9376592 plus this change: gofmt -l clean; go vet of
internal/pii, masking, gateway for darwin, GOOS=linux and
GOOS=windows ok; go test -timeout 45m ./internal/pii/...
./internal/masking/... ./internal/redact/... ./internal/gwmw/...
./internal/gateway/ all ok (gateway 459s).
- wsl-run and win-run: go test ./internal/pii/... ./internal/masking/...
ok.
- After the rebase onto origin/main (no overlap in these files): the
same pii and masking tests again through mote-run, ok.
Broken by hand, each red:
- backend.partial back to `return nil, waitErr(ctx)`:
TestStoppedRequestKeepsWhatWasRead fails (no Partial).
- strict mode waiting with no deadline:
TestStrictModelStalledIsTheRulesForWhatItDidntRead fails at its bound
("held the request with no bound").
- strict mode panicking on a Partial as the old code did: the same test
fails ("held back").
Not tried: the reporter's machine, and a real Claude Code burst through
the gateway with the model on; the reproduction called the model's
backend directly.