gaubeebangeel on X: with masking on, first tokens on a cloud server
came at 30-40s, 10-15s with it off.
Where the time goes, measured on a 60-turn Claude Code Messages body
(367-414 KB, a 4 KB tool result a turn; TestRealLatencyOfALongSession,
gated on GUARD_REAL_DIR, run in WSL on a Ryzen AI MAX+ 395):
- The rules are not it: 89ms for the body cold, 13ms warm (the rule
memo); 7-11ms on mote's M5 Pro (BenchmarkMaskLongSession,
BenchmarkScrubCodexTurn).
- AstrLink Guard on the CPU is: ~7 KB/s on its 4 cores (GOMAXPROCS=32),
~3 KB/s on one (GOMAXPROCS=2). A turn whose new text the model reads
waits for it: 16 KB of new tool output is 3.0-3.5s on 4 cores and
7.8-8.2s on one. That part is the model's reading and stays.
- With the model turned on (strict, 15s), a resumed or never-read
history was read on every request, until the 15s ran out, though the
vendor had that text already and it goes as it went on the same route
(redact's sentSpans): its finds only feed learnLate. 4 cores: 15.1,
15.0, 15.0, 7.8s, then 0.85s. 1 core: 15s on eight requests in a row,
then 7.9s, then 1.9s.
Now a request with a bound that waits for every text (masking's strict
wait) marks what it goes without, as a Bounded one does (backend.sent),
and once all that is left is what an earlier request sent unread, it is
answered with a *Partial (afterSent): what it adds was read, the rest
has the rules' masking, as on the same route it had. The model reads on
into the backlog after the request, to the request's own bound, and
keeps what it finds for the next one. While it waits, a strict request
counts only what it adds for the queue, so it goes before a backlog
read on by an earlier request. A strict request with no bound still
reads everything; Bounded (the default) is unchanged.
After, same body, same box: 4 cores 15.1s (the first request: all new
text), then 0.97, 1.3, 1.4, 2.3, 3.0, 3.1, 3.1, 3.1, 2.9s; 1 core 15.1s,
then 2.1, 4.6, 4.5, 4.8, 4.7, 4.6, 5.7, 4.5, 4.9s. Those later turns
come back to back, so each shares the CPU with the backlog read on
after the one before; with an agent's think time between them it is
read meanwhile.
What changes in what is masked: on the same route, nothing in what a
text goes as. A value the model would find late in a backlog text masks
new text from the request after the read, not from the one it went
with. On another route (the user picked another provider), a backlog
text has the model's finds of now, none until it is read, and goes with
the rules' masking alone; before, it was read for up to 15s, newest
first.
Run (WSL magpie-desktop, at this commit rebased on 005178104):
go test ./internal/pii ./internal/masking ./internal/redact,
go test -run "Mask|Redact|Privacy|Model|Partial" ./internal/gateway,
go test -race -count=5 on TestStrictRequestGoesBeforeTheBacklog,
TestBounded* and TestNewestTextReadFirst, go vet (linux, windows,
darwin) on pii and masking, and the latency runs above with the real
AstrLink Guard files.
Broken by hand: with early forced false,
TestStrictRequestGoesBeforeTheBacklog goes red ("the request waited for
the history an earlier one sent unread", 20s).
Not run: the full suite (mote and mica each had suites queued on
suite.lock); Privacy Filter (pf-serve) on a CPU, which shares
backend.find; the queue-order change has no unit test of its own (a
fair one races the turn's hand-over), only the latency runs.