Commit Graph
99 Commits
Author SHA1 Message Date
yetone eef99e4bbe redact: a value on both Masked words and Never mask is masked; Never mask still beats the user's rules
TakaNaShi_ShiKi on X asked for a way to keep a value from being masked.
That exists already: Settings › Privacy › When a value is found ›
Never mask (RedactAllow, Options.Allow, since b00c82acf), and a click
on a masked value in a request's masking record adds it there
(/api/masking/allow). It is applied in apply() to every span, whichever
finder found it: magpie's rules, the user's rules, the local model and
known values. Nothing new is wired for it here.

What was undecided was the order between it and the user's own lists.
apply() let a Never mask value go even when the same value was one of
the user's Masked words, and an allowed value hid a masked word inside
it (Masked word "kelvarn", Never mask "team.inbox@kelvarn.io": the
word went out). The value menu already refuses Never mask on a Masked
word ("One of your Masked words"), but the settings list doesn't.

Decided: of two things the user asked for, the one that keeps a value
from the vendor wins. A Masked word is masked even when Never mask
lists it, and a Masked word inside a value Never mask lets go is
masked. Never mask still wins over every finder, the user's own rules
included: a value named there is the exception to the user's pattern
(rule PROJ-\d{4}, Never mask PROJ-0001: PROJ-0001 goes as written,
PROJ-0002 is masked). Matching is unchanged: a whole value, any case.
A user with a value on both lists before this sees it masked from the
next request on.

Test: TestMaskedWordsWinOverAllow (new). Broken by hand (apply()
restored): FAIL "a value on both lists went as written: \"deploy on
build-01, mail team.inbox@kelvarn.io, …\"" and "a masked word inside an
allowed value". Restored: ok. TestAllowLetsAValueGo still passes.

Run (mote-run, at eb7ce732a): gofmt -l internal/redact (empty), go vet
./internal/redact/, go test -count=1 ./internal/redact/... ok.
Not tried: a running magpie; no GUI change, so no GUI run in this
commit.

docs/subsystems/gateway-routing.md says the order beside Never mask.
2026-11-08 11:49:18 +08:00
yetone 2d90c7c565 redact: a hex number (0x and up to 16 hex digits) goes as written, whatever the local model takes it for
TakaNaShi_ShiKi on X: in reverse-engineering notes, an address written
as inline code, `0x004EA5E0`, went to the vendor as {{SECRET_6kkmmxxd}},
and the vendor's model lost the data it was asked about.

Which finder took it: no rule. With Secrets and Personal on and every
kind on, the rules alone mask none of the values in the new test (the
"by the rules" checks in TestHexNumberGoesAsWritten). The local model
did. Asked for real (Privacy Filter and AstrLink Guard from this Mac's
cache, copied to mote, MAGPIE_EVAL_CACHE), on a notes table:
  Privacy Filter: secret 0.679 on 0x0058C210 (beside "密钥表")
  AstrLink Guard: secret 0.625 on the same
  Privacy Filter, "The license check is at `0x004EA5E0`; the key table
  at `0x0058C210`.": account_number 1.000 and 0.995 on both
  Privacy Filter, "key: 0x004EA5E0": secret 0.992
modelFits let them through: hexRe, which holds back a bare hex run
unless a key's name is right before it, asks lower case and no 0x, and
numberLike reads 0x004EA5E0 as a number, so ACCOUNT took it too. That
is the sibling, with the real model's evidence; PHONE did not take one
in the fake-model test, and decimal numbers already have their own
checks (numberNamedSecret), so nothing wider is changed.

Now modelTakes takes no value of any kind that is 0x or 0X and 1 to
16 hex digits (hexLiteral, a 64-bit value: an address, a constant, a
flag). No cue is asked, unlike a bare hex run: the function at an
address is often named for a key (DecryptKey: 0x004EA5E0), and
secretCued would read that as "key:". A longer 0x value (a 64-digit
private key, a 128-bit 0x+32) is masked as before.

Tests:
- TestHexNumberGoesAsWritten (new): the reporter-shaped table row, a
  cued address, 0X upper case, 0xFFFFFFFFFFFFFFFF, a 64-bit x64dbg
  base; none masked by the rules, nor as secret, account_number or
  private_phone from the model; 0x+64 and 0x+32 still masked.
- TestMaskEval: cases hex-addresses and hex-addresses-en, with the real
  models' recordings added (only these two entries; the rest of the
  recordings were left as committed, since re-recording on mote moved
  other cases' scores slightly).
- Broken by hand: the hexLiteral check taken out of modelTakes.
  TestHexNumberGoesAsWritten FAILs with eight masks
  ("0x004EA5E0" as secret: masked "...`{{SECRET_7bm7qoxm}}`...", as
  account_number "{{ACCOUNT_rcgox2br}}", 0xFFFFFFFFFFFFFFFF and
  0x00007ff6a1b20000 as secret), and TestMaskEval/privacy-filter FAILs
  with 'hex-addresses: "0x0058C210" was masked, and should go as
  written' and both hex-addresses-en values. Restored: both pass.

Run (mote-run, at base 4ab1191bc): gofmt -l internal/redact (empty),
go vet ./internal/redact/, go test -count=1 ./internal/redact/... ok.
Not tried: the reporter's own text (not posted in full); a running
magpie with the model on.

docs/subsystems/gateway-routing.md says it beside the EVM address rule.
2026-11-08 11:48:50 +08:00
yetone 2b2abec457 redact: a one-word name the model flags goes out only beside a thing's word, never alone or in tool arguments
With a model that labels Rina a PERSON, at origin/main 49c9491b7, these
went out unmasked through 4e7661adc's app-name exemption (thingNamed):
a tool_use {"recipient":"Rina"} and user content "Rina" (namesOnly took
one capitalized word for a list of app names), "Rina's Mac won't boot"
and "Rina uses Windows at home" (an app's or a system's word anywhere in
the clause, thingWords, counted as a cue).

thingNamed now:
- treats a possessive right after the word ('s, ’s) as a person's;
- no longer takes a thing word (or a Chinese one, zhThingWords, now
  gone) anywhere in the clause as a cue: only the word right before or
  after counts (using X, the X app, X vs, X 这个软件), or the item's
  place in a list of apps;
- takes a text of names only when it has two of them at least.
personFits never applies the exemption in a tool call's arguments
(Options.args, set by MaskJSON under args or an "arguments" string).

Cases 4e7661adc was written for that are exactly the leak, and are
masked now (filed as #5506):
- "Muesli" alone (thingname_test, and eval case app-alone, now Keep
  with Known #5506 for Privacy Filter);
- "Which is better for notes on my Mac, Cicada or Mimi?" and the
  "Cicada 和 Mimi 呢" half of "Parakeet 这个软件很好用,Cicada 和 Mimi
  呢?", whose only cue is elsewhere in the sentence. They are taken out
  of TestAppNamesNotPersons; "Parakeet 这个软件很好用。" stays.
- TestPersonBesideAppStillMasked's lone "Mimi" was let go "by design";
  it is masked now.
The rest of TestAppNamesNotPersons (the bare list, "Cicada and Mimi",
the Markdown list, switched to, crashes, using, vs, apps like) and every
other eval case pass unchanged.

TestFirstNameNearAThingMasked holds the four reported texts, ’s,
"Send the license to Rina." and three bodies (user text, tool_use input,
a function_call's arguments string), and that "using Rina" and "the Rina
app" still go as written. Broken by hand: with thingname.go, model.go,
redact.go and json.go as on main it fails on all 9 masked cases (and the
lone Mimi); with only the args flag forced off, the two tool-argument
cases with an app's word beside the name ("install Rina", "using Rina")
go out.

Run at 4c0e22aa7, this stack's head on origin/main c6b7bbedf, on mote:
- gofmt -l clean on the changed files.
- go vet -tags nogui, GOOS=linux go vet -tags nogui (./internal/redact
  ./internal/gateway) and GOOS=windows go vet ./internal/redact: clean.
- go test -tags nogui ./internal/redact ./internal/gateway -count=1
  -timeout 45m: ok (redact 2.6s, gateway 1837s at load ~100).
Not run: go test ./... (the change is internal/redact only) and the
GUI suite (no GUI file touched).
2026-11-06 18:36:19 +08:00
yetone d7714b3f3b redact: every tool call's arguments are the tool's, mcp_tool_use and Responses *_call included
With Secrets and Personal masking on, at origin/main 49c9491b7, an
Anthropic mcp_tool_use block's input was not counted as tool arguments:
scan knew only tool_use and server_tool_use. The protocol's key-name
exemptions (data, url, signature, *_id) then held inside what the model
wrote, so a phone under "data", a card under "customer_id", an email
under "signature" and an sk-ant key in a "url" went out as written. The
same held for every object-shaped tool call outside those two: a
Responses function_call, mcp_call or tool_search_call's arguments, a
custom_tool_call's input, a local_shell_call/shell_call/computer_call's
action, an apply_patch_call's operation, and a Chat Completions (or
Ollama) tool_calls[].function.arguments or legacy function_call given as
an object. scan's first look also searched for `"tool_use"` with its
quote, which `"mcp_tool_use"` doesn't contain, so a body with no tools
array skipped the walk altogether.

toolArgs now names the class: the input of any *_tool_use, the
arguments, input, action or operation of any *_call, and the
arguments/args under function, function_call or functionCall (Gemini's
args as before). The first look searches for `tool_use"`, `_call"` and
"arguments". A call's own id, name and server_name stay as they are
(they are siblings of the arguments, not under them).

TestEveryToolCallsArgumentsAreMasked loops over all 15 shapes with a
phone under data, an sk-ant key in a url, a card under customer_id and an
email under signature, and checks ids, name and server_name are kept.
Broken by hand: with json.go as on main it is red for mcp_tool_use, chat
tool_calls, chat function_call and the 8 Responses types, each value
"went out"; tool_use, server_tool_use and both Gemini shapes passed on
main too.

Not tried: a real vendor request with an mcp_tool_use replayed; the
masked values come back through the same restore as any tool_use's.

Run at 4c0e22aa7, this stack's head on origin/main c6b7bbedf, on mote:
- gofmt -l clean on the changed files.
- go vet -tags nogui, GOOS=linux go vet -tags nogui (./internal/redact
  ./internal/gateway) and GOOS=windows go vet ./internal/redact: clean.
- go test -tags nogui ./internal/redact ./internal/gateway -count=1
  -timeout 45m: ok (redact 2.6s, gateway 1837s at load ~100).
Not run: go test ./... (the change is internal/redact only) and the
GUI suite (no GUI file touched).
2026-11-06 18:36:19 +08:00
yetone dc133b88fe redact: an address before a file's extension (alice.smith@acme.com.pdf) is masked
With Secrets and Personal masking on, at origin/main 49c9491b7,
`attach /Users/me/Invoices/alice.smith@acme.com.pdf`,
`export-rina.k@fastmail.com.png` and `john@gmail.com.jpg` went out as
written, and so did the local model's EMAIL on them. b855cfee9 (#3029)
read every host ending in a file extension (fileHost) as a file's name,
so the real domain before the extension never counted.

realEmail now takes the file extensions off such a host (fileStem:
acme.com.tar.gz is acme.com) and judges what is left: a domain with a
mail TLD is an address, and the whole match, extension and all, is
masked. A host with no domain before the extension (@2x.jpg, @3x.png,
@final.pdf, @base.json) or a scale before a domain-like extension
(icon@2x.zip) stays a file's, as #3029 needs. The model's EMAIL goes
through realEmail too (modelTakes), so it follows.

TestEmailInAFileNameIsMasked covers the three reported shapes, a .tar.gz
and a JSON path, by the rules and by the model, and that the #3029 kind
still goes as written. Broken by hand: with redact.go as on main it
fails 10 ways (each case "0 masked", rule and model). TestFileNameIsNoEmail
and TestMoreFileNamesAreNoEmail (#3029) pass unchanged.

Not done: the extension is kept inside the placeholder, not outside it;
emailAt refuses a span that stops before ".pdf", and the whole value
comes back on restore all the same.

Run at 4c0e22aa7, this stack's head on origin/main c6b7bbedf, on mote:
- gofmt -l clean on the changed files.
- go vet -tags nogui, GOOS=linux go vet -tags nogui (./internal/redact
  ./internal/gateway) and GOOS=windows go vet ./internal/redact: clean.
- go test -tags nogui ./internal/redact ./internal/gateway -count=1
  -timeout 45m: ok (redact 2.6s, gateway 1837s at load ~100).
Not run: go test ./... (the change is internal/redact only) and the
GUI suite (no GUI file touched).
2026-11-06 18:36:19 +08:00
yetoneandggbdpq 53c81a2700 redact: 白名单 is read as a word, not a name (tianyk, #4087)
With the local model on, 白名单 went out as a name placeholder 821 times
in three days: the model took it for a name, and the reader's list of
ordinary words (zhWords, zhNounEnds), which every Chinese-name find is
checked against (zhWordNotName), had no word for it. 白名 is now in
zhWords and 单 in zhNounEnds, so the model's find goes as written and
never becomes a known value.

Of the report's other rows: node_modules and 连续 are already left as
written at this tree (probed with a fake model finding each as a name
and a path). 时按 and 时隐藏, the model's finds cut across two words
(超时+按住, 超时+隐藏), are still masked; this change does not cover them.

Changed from the contributor's patch: its second half, a gate in
knownSpans that let a known PERSON value go wherever it reads as a word,
is not taken. Every PERSON finder already asks zhWordNotName, so the
only values that gate let go are names masked where a role said a person
was meant: with it, "联系人:白名单" masked and the next request's
"白名单说明天到" went out as written. The test now checks that case and
resets the known values around itself.

Run (mote): go test -tags nogui ./internal/redact/... ./internal/pii/...
./internal/masking/... (ok), -shuffle=on ./internal/redact/ (ok);
go vet -tags nogui ./internal/redact/...; gofmt -l (empty).
Broken by hand: with the old zhname.go, TestModelMisreadsNotMasked and
TestKnownWordTakenForANameGoesAsWritten fail (开启{{PERSON_…}}之后);
with the patch's knownSpans gate put back, TestKnownWordTakenForANameGoes
AsWritten fails ("a name masked once left as written: 白名单说明天到").
Not tried: the reporter's real AstrLink Guard model on their requests.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 10:06:51 +08:00
yetoneandggbdpq e4b0555a17 redact: a timestamp under a token's field name is not masked as a secret (#5002)
"access_token_expires_at": "2026-08-30T11:44:31.312645+08:00" went out as
"{{SECRET_…}}:44:31.312645+08:00": the field's name has token in it, and
the SECRET rule took the timestamp's head up to the hour (its colons are
not a secret's characters), so 2026-08-30T11 was masked and the rest was
sent as written. The same happened after 令牌是, 密钥为, token 是,
SERVER_KEY: and DB_PASS:, and in a tool call's arguments the whole value
was masked by its field's name (namedSecret).

An RFC 3339 timestamp, whole or its head to the hour, is now left as
written there (timestampValue, beside versionValue and pathValue in
fieldAt, keyAt and namedSecret). The exemption is by the value's shape,
not the key's name: a value that only starts as a timestamp
(2026-08-30T11x9k2abc) still masks, and a secret beside the timestamp in
the same tool call still masks.

Changed from the contributor's patch: the patch deleted fieldAt's doc
bullet for the next-field rule (nextField), which still exists; it is
kept.

Run (mote): go test -tags nogui ./internal/redact/... ./internal/pii/...
./internal/masking/... (ok); go vet -tags nogui ./internal/redact/...;
gofmt -l (empty).
Broken by hand: with the old fieldvalue.go, json.go and redact.go,
TestTimestampIsNoSecret fails on the reporter's line with the same
output as the report ("{{SECRET_2ojutfrk}}:44:31.312645+08:00") and on
the other lines.
Not tried: the local masking model on the reporter's whole request.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 10:06:51 +08:00
yetone 4e7661adce redact: an app's one-word name the model took for a person's goes as written
Reported by ylorn. on Discord (11-06): choosing apps in Alma, a question
about one app was answered with another's facts. Privacy Filter took the
apps' names (Cicada, Mimi, Phosphor, Parakeet, Muesli) for people's: in a
bare list of them, alone, and in the Markdown list of apps the assistant
answered with (probed on the real model: ~0.99 each). The follow-up
questions ("How about Mimi?", "Phosphor vs Parakeet") it did not flag, so
they went as written while the history held the names as placeholders;
Phosphor and Parakeet (8 bytes) then became known values and were masked
everywhere. The vendor could not tell which placeholder was which app.

Restore was not the cause: placeholders are a keyed hash of kind and value,
one per value, and restore maps each back to its own value in any case
(TestManyNamesRestoreEachToItself, a guard: it passes on the old code too).

personFits now lets one ASCII word go when what is around it says a thing
and nothing says a person (thingNamed, internal/redact/thingname.go): a
person's word beside it (my colleague, Hi, Mr, said, told) masks; a thing's
word beside it (using, switched to, the ... app, vs, apps like, 这个软件)
lets go; else its sentence decides (he/she/relations/greetings/said mask;
app/macOS/subscription/vs/软件 let go); else a list item among items that
speak of apps, or a text of capitalized names only, lets go.

Trade-off, by design: a single first name alone, or a first name in a
sentence that speaks of an app with nothing of a person ("Mimi uses the
app daily"), goes as written. A full name (John Smith), a Chinese name
(张伟), and a first name beside a relation, a greeting, said or a pronoun
are masked as before.

Run (mote, worktree at 84ad780b6 + this):
- go test ./internal/redact/... ./internal/pii/... ./internal/masking/...
  ./internal/otlp/... ./internal/sessions/... ./internal/settings/... ok
- go test -run 'Mask|Redact|Privacy|Person|Known' ./internal/gateway
  ./internal/gui ok
- TestMaskEval re-recorded with both real models (MAGPIE_EVAL_CACHE);
  only the 12 new cases' recordings are added, old entries kept as they
  were (mote's re-record drifted 4 AstrLink and 2 Privacy Filter entries
  by score; not taken in). New cases app-names, app-alone, app-markdown
  (real Privacy Filter flags), app-compare/vs/list/using/zh (model finds
  none; guard), app-and-person, app-and-full-name, app-and-zh-name,
  greeting (person controls).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/redact ok.

Broken by hand:
- the personFits hook off: TestAppNamesNotPersons red 9/9,
  TestPersonBesideAppStillMasked red on the 3 apps, TestMaskEval red on
  app-names (5), app-alone, app-markdown (3) with the real recordings.
- thingNamed always true: TestPersonBesideAppStillMasked red on Mimi (x2),
  Laura, Daniel.

Not tried: a real Alma chat through the gateway with the model on; Windows
and Linux runs (pure Go string code, vetted for both); the full suite runs
after the push.
2026-11-06 09:28:25 +08:00
yetone 76f00399c5 redact: a ping between two pieces of a placeholder no longer leaves it in the agent's arguments (#5287)
The Writer holds an event whose text ends in part of a placeholder and
joins it with the next piece. A keepalive event in between (Anthropic's
ping, Responses' response.in_progress or response.queued) made it write
the held piece as it was. The rest of the placeholder came in the next
piece, and neither piece could be restored. A slow model writing a masked
value through Claude Code's Write/Edit put {{SECRET_…}} or a stray { on
disk. magpie-community/plugins#738 committed two German texts as
{{SECRET_5dz6uy27}} and {{SECRET_2zh6t2jw}}.

Keepalive events now go out ahead of the held piece, which stays held for
its continuation. This covers every route that restores through
redact.Writer (Anthropic, Responses, Codex backend, plugins). Chat's
keepalive is a comment, which was already passed through (#2402), and
Gemini has none.

Run on mote at fe6533ad8 (= origin/main when pushed):
- go test ./internal/redact ./internal/masking: ok.
- go test ./internal/gateway -run 'Keepalive|Masked|Mask|Redact|Ping|Quiet|Restore|Placeholder': ok.
- GOOS=linux and GOOS=windows go vet of internal/redact and internal/gateway: ok.
- gofmt -l: clean.

Broken by hand: with writer.go back at main, both new tests are red.
- TestWriterHeldAcrossKeepalive: "anthropic ping cut at 49", a stray {.
- TestMaskedToolArgsSplitAroundPing: the agent's partial_json is
  {"content":"mail {{EMAIL_asf2pa5q}}"}.

Not tried:
- The false positive itself. None of the regex rules mask plausible German
  texts for these strings (Mask and MaskJSON with Secrets+Personal), so it
  was most likely the local model. That wasn't run, and the PR's German is
  unknown.
- A real Anthropic or Codex session.
- Placeholders the vendor sends back after a magpie restart. Values are
  kept in memory only, and that is unchanged.
- The full suite runs after the push.
2026-11-05 05:13:24 +08:00
yetoneandggbdpq e737dff447 redact: a dotted name a call is made on is no secret to the masking model (#4444)
kewab's redaction shot: gctx.GetInt64("user_id") went out with
gctx.GetInt64 replaced by a made-up key. No rule reaches such a span;
the local model called it a SECRET, and modelFits let it through.

modelFits's SECRET case now turns away an identifier path (identPath)
that a '(' touches: the name a call is made on. ggbdpq's patch (via
gua2100) asked notCode there, the rules' check, which also skips a name
with a space before its '(' and one after a colon that a comma follows.
The model is asked about prose too, and there those are secrets: with
notCode, "tell Bob it is Pw7nK4xQ9rTe (rotated today)" and "note:
hunterTwoThree, keep it" went out as written. Only the touching '(' is
taken.

Run at this tree on mote: go test ./internal/redact ./internal/usage
-count=1: ok. gofmt -l clean.
Broken by hand: the guard gone: TestModelMisreadsNotMasked red on
gctx.GetInt64; the patch's notCode in its place: TestModelFindsStill
Masked red on the three prose secrets above.
Not tried: the real local masking model (the tests use the stand-in
model the suite's other model finds use).

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-03 05:08:39 +08:00
yetone 5ec2375688 gateway: a call's HTTP headers both ways, masked, folded under its bodies
usrname1833 on Discord asked to see the raw request and response HTTP
headers (查看原始请求和原始响应的http头), to debug as with a capture.
magpie kept the client's request headers and its own response headers
only in the request archive, and nothing of what went upstream.

Now a call keeps its headers both ways (internal/gateway/wire_headers.go):
- the client's, as they reached magpie: headerLogged in Handler() clones
  them for every request that isn't a GET, HEAD or OPTIONS;
- each request magpie sent upstream for the call: method, address,
  headers, and the answer's status, protocol, headers and time, or the
  error. rpmTransport (under s.client) records it as it is sent;
  provider.SendsThroughPlugin records a plugin account's hand-off, shown
  as handed to the plugin, since the plugin's own request to its vendor
  is made in Bun and magpie doesn't see it (the view says so). The first
  8 tries are kept, the rest counted.
Recording copies each header map; nothing is masked or sorted as a
request goes. Secrets are taken out when the headers are read
(Call.Headers): by what each header is (new redact.SecretHeader, now
behind redact.ScrubHeader: Authorization, cookies, x-api-key, api-key,
any *-Key, *-Token, *-Secret, *-Auth, *-Signature, but Idempotency-Key
and a count of tokens such as anthropic-ratelimit-tokens-remaining),
any Bearer or Basic value, and redact.Scrub on the rest; an address
loses its password, a secret-named query value (?key=) and its fragment.
They live with the call in the 40-call ring; /api/gateway/call gives
them as "headers". The request archive keeps the upstream ones as
"upstream" beside the request's and response's headers, masked the same
way. No body is stored that wasn't before.

GUI: under a recent call's bodies on Gateway and a request's on Routing,
"HTTP headers" folds open the client's headers, then each upstream
request beside its answer (wireHeadersView, plugins/usage/page.js); the
archive's copy shows its upstream requests too. Strings in all four
languages. docs/subsystems/gui-shell.md describes it.

Also changed by SecretHeader: the request archive no longer masks a
rate-limit count header (…-tokens-remaining), which the old name rule
took for a token. (provider.SecretHeader, which backups use, is another
function and unchanged.)

Tests: TestRecentCallHeadersBothWays (a fake vendor; the client's key and
cookie, magpie's upstream key and the vendor's Set-Cookie all masked;
status, protocol and response headers kept), TestRecentCallHeadersEachTry
(a 429 then the next key, both kept in order), TestPluginHandOffHeaders,
TestScrubURL, TestSecretHeaderRealNames (real header names both ways),
TestArchiveOnThisComputer and TestRecentCallBodiesOnDemand extended,
call-headers.test.cjs (Gateway, Routing and the archive's copy; chromium
and webkit; en at 1100px, zh, zh-TW, ja, de at 380px and Routing at 440;
nothing out of the box, no left-border accent).

Run (on mote, macOS 27.2, through mote-run, unless named):
- Full suite at ebd22b1b4 (the same change on 5daba8337): gofmt -l
  empty, GOOS=windows go vet ./... ok, GOOS=linux go vet -tags nogui
  ./... ok, go test -count=1 -timeout 45m ./...: every package ok but
  four tests, none in this change's code, each filed:
  TestEveryRouteHasACommandOrIsNamed (internal/cli,
  /api/usage/checkin-account from e87140242, #4826),
  TestCodexPoolSaysTheClientsVersion (#4807: another test's Codex
  identity, passes alone, 3 of 3 here), TestMainWindowCorners/macOS_26_SDK
  (#3949, macOS 27), TestClosingWindowMarksPageOutOfSight (passes
  alone; filed #4924).
- Rebased on a3768cdd1 (it changed internal/gateway, routing/client.js
  and i18n.js): gofmt, go vet, Linux (nogui) and Windows vet of
  internal/... ok; go test of internal/gateway, gui, redact, provider:
  ok but TestCodexPoolSaysTheClientsVersion (#4807, ok 3 of 3 alone
  with this change's gateway tests) and TestMainWindowCorners (#3949);
  TestCoreScriptBudget ok. GUI: call-headers, routing-bodies,
  recent-call-bodies, request-archive and i18n-keys, 58 of 58.
- Rebased again on 2c90922b0 (app.js and internal/provider, no file of
  this change): TestCoreScriptBudget and TestRecentCall* ok;
  i18n-keys plus call-headers 24 of 24 three times out of four at load
  ~130 on mote. The first try had 1 red of 24 whose name was lost
  (its output was grepped, not kept); it did not come back in 3 runs.
- At the pushed head, rebased on 898c314b7, then 3e61d814e and 8d4d8b2d5 (gateway search, redact; vet, internal/redact and the header tests again ok) (app.css, app.js, i18n.js,
  gui-shell.md and internal/gateway changed): gofmt, vet of gateway and
  gui ok; TestCoreScriptBudget, TestRecentCall*, TestRouteCall,
  TestPluginHandOffHeaders, TestArchiveOnThisComputer, TestScrubURL ok;
  i18n-keys, call-headers, routing-bodies, recent-call-bodies 54 of 54.
- call-headers.test.cjs 20 of 20 (chromium and webkit; en at 1100, zh,
  zh-TW, ja, de at 380; Routing at 440), screenshots looked over.
- GUI: not the whole suite. mote had three other sessions' full GUI
  suites running and the Linux box one, so 131 files the change can
  reach (gateway*, routing bodies/log/steady/story/time, recent*,
  call-*, request-archive, masking*, usage*, i18n*, gui-*, account-eye)
  ran on the Windows box: 1739 of 1862. Every red file was run again at
  5daba8337 on the same box: routing-bodies, gateway-card,
  gateway-systemone, masking-demo, usage-ledger's Requests and the rest
  are red there too (Windows WebKit and Windows-only), and account-eye,
  routing-log-icons, usage-ledger-leave and -probe pass alone at this
  change. call-headers' 4 webkit Routing reds on Windows are
  routing-bodies' own (".rt-day" never visible in Windows WebKit).

Broken by hand, each then put back:
- ScrubHeader back on the name rule: TestSecretHeaderRealNames red
  ("a count of tokens: [REDACTED]").
- rpm.go's upstreamBegins taken out: TestRecentCallHeadersBothWays,
  TestRecentCallHeadersEachTry, TestArchiveOnThisComputer and
  TestRecentCallBodiesOnDemand red.
- scrubHeaders off the sent headers: TestPluginHandOffHeaders red with
  the plugin's key shown.
- Gateway client.js's toggle taken out: the 5 chromium recent-call GUI
  tests red.

Not tried:
- The whole GUI suite (above), and the GUI on Linux.
- A real account or the real app: only fakes.
- What a plugin sends its vendor (made in Bun, not seen by magpie; the
  view says so), and headers Go's transport adds itself
  (Accept-Encoding, Content-Length).
- magpie's own requests (System One's decision, titles, search) keep no
  headers; a gateway served by another magpie shows none.

Asked by usrname1833 on Discord.
2026-11-03 02:25:23 +08:00
yetone 8d4d8b2d5f redact: a field set to nothing takes nothing from the next one (mx_albert)
mx_albert on Discord (#feedback): with Secrets masking on, this command
line went to the vendor with 127.0.0.1 replaced:

  env -i PATH HOME UI_USER= UI_PASSWORD= UI_ADDR=127.0.0.1:39117 DATA_DIR=/tmp/x ./syncer serve

The SECRET rule (a name with password/secret/token/api_key, then = or :)
lets a space stand after the separator, for `password = hunter2` in a
config. UI_PASSWORD is set to nothing, so the rule took the next word,
UI_ADDR=127.0.0.1, as its value and masked it as {{SECRET_…}}:39117;
once masked it was a known value and went masked wherever it came again.
The other field rules (*_KEY / *_PASS, key, 密码, 密钥, "token 是") had the
same shape.

Now a value that is an assignment of its own after a space (UI_ADDR=,
addr=, --listen=; an = with something other than = after it, so a
base64 value's padding is never one) is the next field: the match is
dropped and the search goes on from that value, which is read with its
own name (fieldMatches, nextField). UI_ADDR's address goes as written;
UI_PASSWORD= UI_TOKEN=t0k3nValue2 still masks the token, as UI_TOKEN's.

Old data: what was masked before is known only in memory, so after the
update's restart 127.0.0.1 in that line goes as written for every user;
a conversation carrying it sends it as written from then on (one prompt
cache miss).

Tests: TestEmptyFieldTakesNotTheNext (the reporter's literal line, plus
0.0.0.0, [::1], localhost:port, logfmt, --flag=, and the CJK and
"token 是" rules, every category on) and TestSecretBesideEmptyFieldMasks
(hunter2pass9, a token after the empty field, a *_KEY, a base64 value,
password = with spaces).

Run at this head on mote: go test ./internal/redact ./internal/masking
./internal/otlp ./internal/pii ./internal/sessions ./internal/settings
./plugins/redact all ok; ./internal/gateway and ./internal/gui (nogui)
-run 'Redact|Mask|Privacy|Secret' ok, gateway
TestLoopGuardLeavesOrdinaryRepliesAlone ok (it reads the doc page);
GOOS=linux and GOOS=windows go vet ./internal/redact ok; gofmt -l clean.

Broken by hand: findAll with the field check turned off. Both new tests
go red: the reporter's line masks {{SECRET_…}}:39117, and 17 of the
other cases fail (UI_TOKEN= after an empty field masked with its name,
UI_ADDR=127.0.0.1 then masked as known in the next case).

Not tried: the full gateway and gui packages (another session's suite
was on mote), the GUI, a real request through a running gateway.
UI_PASSWORD=hunter2 itself is not masked by a rule, before or after
this: the rule asks 8 characters of a value, hunter2 has 7.
2026-11-03 02:22:05 +08:00
yetone d577c184b3 redact: a user name's and an address's stand-ins come back in any case (yapechan on Discord)
yapechan (Discord #feedback): with masking on, a person's name sometimes
came back as letters that are no one's, with no {{…}} braces. A user name
in a home folder goes to the vendor as eight made-up lowercase letters
(standInOf). When the login name is the user's own name (yaobin), a model
takes those letters for the user's name and writes them as a name is
written, "作者:Tmhdfetm", "Hi Tmhdfetm,". restoreShapes put a stand-in
back only as written, so a capitalised or upper-case one reached the user
as garbage. An IP stand-in (public-ip-…), a host name that is the same in
any case, had the same gap.

Now a USERNAME or IP stand-in is put back in any ASCII case: in Restore,
RestoreJSON (hasShapes), a stream's held tail (shapeTail) and
outsideShapes. Matching uses an ASCII-lowered copy of the same length
(lowerASCII, which now returns s itself with no capital in it, so there
is no copy), and strings.Index runs once per stand-in as before. An IP
stand-in is still put back only as a whole name. A key's made-up form
(Options.Shape) is still put back only as written, because a key's case
is part of it.

The restart question: the placeholder-to-value map is in memory only.
But a placeholder is an HMAC of its value under a key kept on disk
(redact.key, 0600, SetKeyPath from the gateway), and an agent resends its
history with the values on every turn. So after a restart the same value
goes as the same placeholder and the reply comes back whole.
TestPlaceholdersOutliveARestart now guards that, using the reporter's
姚斌 as a user word. Nothing new is written to disk.

Not found in magpie: a homophone (姚斌 -> 姚兵). Nothing in redact, pii
or restore maps a name by sound. A value goes back only for its own
placeholder or stand-in. The test records that 姚兵 goes back as the
vendor wrote it. Most likely the vendor model wrote it from a
romanisation it saw (a login name, an address); this is not reproduced.

Run at 19e9f7a82 (rebased on 4fc34828e), on mote:
- go test ./internal/redact ./internal/masking ./plugins/redact: ok
- go test -run 'Redact|Mask|Placeholder|Restore' ./internal/gateway: ok
- before the rebase, the whole ./internal/gateway (-timeout 45m): one red,
  TestCodexPoolSaysTheClientsVersion, which is #4807 (another test's
  Codex identity reaches it in a full run). It passes alone -count=3 at
  this head, and it does not touch masking.
- GOOS=linux and GOOS=windows go vet ./internal/redact ./internal/gateway: ok
- gofmt -l: clean
Broken by hand: with the old shape.go, both InAnyCase tests are red
(Restore, RestoreJSON and the stream at every cut). With loadKey ignoring
the key file, TestPlaceholdersOutliveARestart is red (new placeholders,
reply left as {{TERM_…}}).
Not tried: a real vendor writing a capitalised stand-in. The reporter's
own session and records were not seen. The GUI was not run (no GUI
change).
2026-11-02 13:58:47 +08:00
yetone 3f393a4fae redact: a user name is not masked where code has the same word as a name (Tomyu_2034 on X)
Tomyu_2034 on X: "magpie 里面的 masking 很容易把参数变量名当成 user name
给 mask 掉". No sample was given, so the class was measured: with "User
name in home folders" and "User and computer names" on, two finders took
names in code for the user's.

- Known values (known.go). A user name the home rule found once
  (/Users/developer/…) is known from then on when it is 8 bytes or more,
  and standsAlone's default bound is a letter or a digit only, so it was
  masked wherever the word stood between anything else: def
  run(developer, developer_dir), developer_mode = True, const developer
  = 1, {"developer": true}, -    developer_count := 0 in a diff, a tool
  call's old_string. A user name such as developer or workspace1 is a
  word code has too.
- The "User:" line rule (more.go). Its unquoted value was any
  login-shaped word, so user = current_user, user: UserInfo, login =
  loginName, username = target_name, a Go struct's "\tUser  UserProfile"
  and a TS interface's "user: CurrentUser" went as made-up names.

nameAlone now decides a known USERNAME: it is the user's name as a word
of its own in text (a path's part, name@host, --author=name, ls -l's
owner, uid=501(name), prose, a quoted string, chown name:staff), and
code's where it is joined to another part (_ $ a letter or digit beside
it, or a . or - with one past it), declared (const/let/var/def/func/
class/return/import…), assigned or called (name =, name(, name[,
name :=, x = name), a JSON key ("name":), or a parameter ((name, ,name)
name: str, name string), but for id's 501(name)). Nothing is exempted
by a key's name: a tool call's arguments are read by the same rule as
any text, and a quoted value in them is masked as before. The "User:"
rule leaves an unquoted value made of two or more words (split at _ .
and camel humps) one of which says it holds a user (identParts: user,
name, login, current, target, info, obj, id…); a quoted one, and a
login of words of its own (deploy_bot, john_doe), are masked still.

The boundary costs this: prose that puts the name alone in a list
"(developer, alice)" or before "=" now goes as written; such text reads
as code to this rule. A name under 8 bytes was never matched as known,
so for those only the "User:" half changes anything.

Tests (identname_test.go), with "developer" (a common word) and
"rinakato" (a handle), known from a working directory first:
- TestUserNameInCodeIsNoUserName: a Python and a JS file read, a JSON
  file, Go code, a diff and an edit tool call's arguments go as written;
  a home path, --author=, ls -l, uid=501(), prose, a quoted string, a
  JSON value, chown and a bash tool call's ~name go as the made-up name.
- TestUserLineInCodeIsNoUserName: seven code lines unmasked; User:
  deploy_bot, USER=rinak, user: "current_user", ssh config's User and
  user = john_doe masked.

Broken by hand: with more.go and known.go as on main both tests are red
(12 and 7 failures); with standsAlone's USERNAME case returning true,
TestUserNameInCodeIsNoUserName alone is red.

Run at this head (on origin/main 89ffc58f5; nothing since touches
internal/redact or the doc), on mote:
- gofmt -l clean; go vet ./internal/redact ./internal/masking, and
  GOOS=linux -tags nogui and GOOS=windows go vet ./internal/redact: clean.
- go test ./internal/redact ./internal/masking ./internal/otlp
  ./internal/pii ./internal/sessions ./internal/settings: ok.
- go test ./internal/gateway -run '(?i)mask|redact|privacy|personal|
  standin|restore': ok.
- go test ./internal/gui: TestMainWindowCorners/macOS_26_SDK red, the
  AppKit title bar on mote's macOS 27 (#3949, open); nothing else.

Not tried: the full internal/gateway package and go test ./... (the
gateway takes ~45 min; pushed at once per the owner's ship rule); the
local model's PERSON finds, which already leave snake_case and
lower-case words (modelTakes, programWords); the home rule's
"/home/<segment>" in a web route ('/home/dashboard'), which reads as a
home folder and is unchanged; a real request with the reporter's code.
2026-11-02 04:49:42 +08:00
yetone b4d1c393c1 redact: a Chinese session's words before a missing module are read as cheaply (#4766)
The #4766 fix read the last 64 bytes before the quote, but fell back to
lowering the whole text before it when those bytes were not ASCII. A
session written in Chinese is not ASCII, so it kept the quadratic cost
the fix removed. Lowering is rune by rune with no context, so the last
bytes of the lowered window equal the last bytes of the lowered whole
text; the fallback is dropped. The spaces before the quote are now
trimmed before the window is taken, so more than 64 of them no longer
hide the words.

Run (mote-run, -tags nogui):
- go test ./internal/redact: ok.
- With ggbdpq's model.go: the new Chinese case is red (450560 bytes made,
  8 KiB at most). With main's: red (401408 bytes). With the window taken
  before the trim: the many-spaces case is red.
2026-11-01 22:23:51 +08:00
ggbdpq d3bf8f7394 fix(redact): an error's words for a missing module are read before the quote, not the whole body before it (#4766)
What changed

missingModuleAt said a quoted name is a module an error could not load by
lowering everything before the quote. A session's body holds a place a known
value turns up at for each turn it has been in the history, and knownSpans
asks packageAt at each of them, so every such place paid the body's whole
length again — a 555 KB turn held 1m54s in the masking, past the unrouted
budget, and was answered 504 (#4766). The words stand right before the
quote; what is read of what is before them is the last 64 bytes of it now,
as assignedSecret reads the 64 before the value it judges. A letter a lower
case folds wider than in those bytes reads the whole text before the quote,
as before. Nothing of what is masked changes.

Run

- RED (product file reverted, test kept): TestMissingModuleReadsOnlyTheWordsBeforeTheQuote
  fails with "judging the words made 401440 bytes, 8 KiB at most".
- GREEN: the test passes; go test -tags nogui ./internal/redact/ passes.
- A session that grows turn by turn, Personal on and config-dense as the
  report has it: a 925 KB turn went from 3.8s to 0.76s, a 560 KB turn
  masks in 0.2s; the rest of the cost is the rules' own linear scan.
- go vet on darwin, linux/amd64 and windows/amd64; builds on all three;
  gofmt clean; BenchmarkMaskLongSession unchanged on its shape.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:23:51 +08:00
yetone 1c3591b5d1 guard: the local masking model reads text a third faster on amd64 (mrwl666)
mrwl666 (Discord #help, v0.1.2554, Docker on a 2-core EPYC) saw one
core at 100% for 2-3 s on every request with masking and AstrLink Guard
on, and took it for every message of a ~66k-token conversation being
scanned again. It isn't. Probed on the Linux VM (GOMAXPROCS=2, taskset
-c 0,1) with a 50-60 turn Chat session of ~4 KB tool results, ~240-270 KB
a body:

- rules masking (MaskJSON without the model): 5-11 ms a turn;
- the history is cached by hash (LRU + found-<rev>.bin), and a turn
  hands the model only what it added. Bounded caps that at 4 KB;
- the request waits masking's 2 s defaultWait for the model on that
  text, and guard.Cores() is 1 on a 2-core box, so one core runs the
  int8 BERT at about 1 KB a second. That is the spike.

This change makes the model's CPU cheaper; it does not take the 2 s
wait away. AVX2 kernels for the int8 dot products (dot4, attention
scores), exp in softmax and the GELU epilogue, picked at start when
the CPU has AVX2, plus plain compares in place of the builtin float
min/max (a third of the non-matmul time, for their NaN/±0 rules).
Every float op is the same per lane and in the same order as the Go
code (release builds are GOAMD64=v1, no FMA), the int8 sums are exact,
mix32 and the softmax sum keep their order, so the model finds the
same spans with the same scores to the bit.

Numbers, Linux VM (AMD Ryzen AI MAX+ 395), one core of guard:
  guard.Find on 4,247 bytes: 4.05 s before, 2.75 s after (same 20 spans)
  turn 50-57 with the model: MaskJSON wall 2.0 s both (the wait), CPU
  after the wait 0.1-3.0 s before, 0.0-2.0 s after
mote (M5 Pro, arm64, rules path, unchanged by this):
  BenchmarkMaskLongSession chat 10.3-11.7 ms, responses 10.8-13.0 ms,
  messages 12.1-13.9 ms per turn of a ~260 KB body

Tests:
- TestKernelsSameBits: the AVX2 exp/GELU/scores give Float32bits equal
  to the Go code, edge values included. Broken by hand: swapping two
  adds in the asm exp made it red (0x175156d6 vs 0x175156d5).
- TestMaxAndRangeAsBuiltins: maxOf/rangeOf agree with the builtins on
  ±0 and NaN. Red with maxOf's NaN check taken out.
- TestModelSameWithoutAVX2 (needs MAGPIE_GUARD_DIR): the real model
  finds the same spans on ~6 KB of mixed text with AVX2 and with SSE2.
- TestSessionTurnReadsOnlyWhatItAdds (internal/pii): turn 61 of a
  275 KB session, after turn 60, has the model read only turn 61's text
  (5.2 KB for 4.6 KB added). It passes on the old code too: it guards
  the claim above, not this speedup. Red (10.5 KB, earlier turns read
  again) with the cache lookup in known() turned off by hand.
- BenchmarkMaskLongSession (internal/redact): Chat, Responses and
  Messages sessions with large tool results, turn 61 after turn 60.

Run at this tree (7b6b7492a + this):
- mote: go vet ./internal/pii/... ./internal/redact, GOOS=linux amd64
  (-tags nogui), GOOS=windows amd64, GOOS=linux arm64 guard: ok.
  go test -count=1 -timeout 45m ./internal/pii/... ./internal/redact: ok.
- WSL magpie-desktop (amd64, AVX2) with MAGPIE_GUARD_DIR: the same
  packages ok (guard 28.9 s, model tests included); the three kernel
  tests again under GOMAXPROCS=2 taskset: ok.
- Windows xiaomi-gpu: the same packages ok (no model dir there).

Not tried: the reporter's EPYC itself or Docker; AVX-VNNI or AVX-512
(would need the EPYC generation; VPDPWSSD is exact, so it could come
next); mix32 on AVX2 (more accumulators change its sum order, so not
byte-identical); the full ./... suite. For no spike at all, the model
can be turned off with rules masking kept on.
2026-11-01 15:51:18 +08:00
yetone b2145eac1b redact: what the rules found in a long text is remembered by its hash (#4353)
An agent sends its whole history on every turn, so with masking on every
turn ran each rule's regexp over every message before it again; on a long
session most of magpie's CPU went there (#4353). ruleSpans now keeps what
the rules found in a text of 256 bytes or more, keyed by a SHA-256 of the
text, the day (a date over a year old can be a birthday), Secrets,
Personal, the kinds turned on and off and the user's own rules. Only the
hash and the places found are kept, no value. Two generations of 65,536
entries, as sentMemo keeps.

Run on mote at this tree:
- gofmt, go vet (darwin, GOOS=windows, GOOS=linux): ok
- TestRulesRunOnceAText and TestRuleMemoKeysWhatTheRulesRead: ok 3 of 3
  alone; -race with TestMask*: ok
- go test ./internal/redact: ok; go test -timeout 45m ./internal/gateway:
  ok (662s; run before the counter moved into ruleSpans' find, which no
  gateway code reads)
- Broken by hand: memo bypassed -> "the rules ran over 41 texts for one
  new turn"; day left out of the key -> line 74 red; kinds left out ->
  line 69 red.
- BenchmarkMaskNextTurn (Codex history of 80 turns, then 81):
  99.6ms/op before, 6.6ms/op after.

Real use: sandbox HOME copied from the owner's, masking on, real DeepSeek
account, deepseek-flash, four turns of a 115-123KB history with mails and
phone numbers. Masking took 22-24ms a turn before; after, 24ms for the
first turn and 1.7-2.1ms for each next one. Every reply HTTP 200 "ok"
(one empty reply at finish_reason length on each binary, the model's
reasoning using max_tokens).

Not run: the full ./... suite; Windows and Linux runs of the tests.

Picked onto 54087aa43 (3 files changed, 199 insertions(+), 34 deletions(-), none in internal/redact); not run again there.
2026-11-01 09:44:31 +08:00
yetone 45385f0eed redact: a secret's field name masks only in a tool's arguments and result, with secrets on (#2946)
#2946's patch masked any JSON value whose field name looks like a
secret's (api_key, password, *_token) anywhere in a request body outside
tool definitions. That is an exemption, and a mask, keyed on a field's
name: it rewrote what the agent itself sends (mcp_servers'
authorization_token, a top-level api_key, metadata.session_token) as
well as the user's data. The name check now runs only where the user's
data sits in the protocol: a tool call's arguments (Anthropic tool_use
input, OpenAI arguments, Gemini functionCall args) and a tool's result
(Gemini functionResponse.response is added to the places scan reads),
and only with secrets masking on.

The Authorization/Cookie rule masked the word after the header name in
prose too ("Authorization: required for this route"). It now masks only
a value with a credential's shape: one token, or a scheme word and a
token, of 8 or more characters with a non-letter and not a ${VARIABLE};
or name=value cookie pairs.

Tests: TestMaskJSONNamedSecrets puts its values in tool_use input,
functionCall args and functionResponse response;
TestMaskJSONSecretNamesOnlyInToolArgs holds the agent's own fields as
written and nothing masked with secrets off; TestMaskAuthHeaders gains
prose rows (no mask) and a Cookie row.
docs/subsystems/gateway-routing.md says where the name check runs.

Landing record (yetone):
Run at the pushed batch head (tree a6b084d0b, on origin/main 616405061),
go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider and internal/plugin (this batch's
packages and those main changed since the full run): all ok. gofmt -l
clean; go vet ./... (darwin), GOOS=linux and GOOS=windows go vet -tags
nogui ./... clean. internal/gui on macOS (mote-run):
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners
(#3949), both red at main too.
- The full go test ./... -timeout 45m -count=1 ran one rebase earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2 (main then gained 5bfa9f076's
group stand-in, b19d08593, f856d381a and 616405061). It ran on Linux
(wsl-run): 82 packages ok. internal/agent has 4 reds, all red at
origin/main on that box as well: TestInstalledVersion,
TestGrokInstalled, TestOmpDetectedWithPiDir and
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, #3548). The root
package and internal/cli need gtk4 to build, so they ran on macOS
(mote-run): ok. TestColdTurnsTaken (#4510) was red there once. An
earlier full run at base d307aa648 was red once in
TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone at both
the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
Broken by hand: the name check's scope put back to everywhere but tool
definitions: TestMaskJSONSecretNamesOnlyInToolArgs goes red; headerValue
made to accept anything: TestMaskAuthHeaders' prose rows go red;
restored, green.
Not tried: a real agent's request through the gateway with masking on.

#2946's patch masked any JSON value whose field name looks like a
secret's (api_key, password, *_token) anywhere in a request body outside
tool definitions. That is an exemption, and a mask, keyed on a field's
name: it rewrote what the agent itself sends (mcp_servers'
authorization_token, a top-level api_key, metadata.session_token) as
well as the user's data. The name check now runs only where the user's
data sits in the protocol: a tool call's arguments (Anthropic tool_use
input, OpenAI arguments, Gemini functionCall args) and a tool's result
(Gemini functionResponse.response is added to the places scan reads),
and only with secrets masking on.

The Authorization/Cookie rule masked the word after the header name in
prose too ("Authorization: required for this route"). It now masks only
a value with a credential's shape: one token, or a scheme word and a
token, of 8 or more characters with a non-letter and not a ${VARIABLE};
or name=value cookie pairs.

Tests: TestMaskJSONNamedSecrets puts its values in tool_use input,
functionCall args and functionResponse response;
TestMaskJSONSecretNamesOnlyInToolArgs holds the agent's own fields as
written and nothing masked with secrets off; TestMaskAuthHeaders gains
prose rows (no mask) and a Cookie row.
docs/subsystems/gateway-routing.md says where the name check runs.

Landing record (yetone):
Run at tree 7d7955eb9 (this batch on origin/main 3cfba2e37), go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider, internal/agent and internal/usage
(this batch's packages, plus those main changed since the full run): all
ok except internal/agent's TestInstalledVersion, TestGrokInstalled and
TestOmpDetectedWithPiDir, red at origin/main on that box too (#4033,
#3548). gofmt -l clean; go vet ./... (darwin), GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean. On macOS (mote-run), the
root package and internal/cli ok; internal/gui red in
TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
(#3949) and TestColdTurnsTaken (#4510), the first two red at main too.
- The full go test ./... -timeout 45m -count=1 ran two rebases earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2, on Linux (wsl-run): 82
packages ok, internal/agent's 4 reds as above, plus
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, red at main). The
root package, internal/cli and internal/gui need gtk4 to build, so they
ran on macOS as above. An earlier full run at base d307aa648 was red
once in TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone
at both the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
- Rebased after these runs onto origin/main c1457f2ee. Its two commits
since 3cfba2e37 (3f2faef62 gui, c1457f2ee agent) touch neither
internal/gateway nor internal/redact, nor any file this batch changes,
and were not run again here.
Broken by hand: the name check's scope put back to everywhere but tool
definitions: TestMaskJSONSecretNamesOnlyInToolArgs goes red; headerValue
made to accept anything: TestMaskAuthHeaders' prose rows go red;
restored, green.
Not tried: a real agent's request through the gateway with masking on.
2026-11-01 06:38:01 +08:00
ggbdpq 9a05a7bcec redact: the mask covers ark- keys, _KEY/_PASS names, auth headers, and JSON field names (#2946)
What changed (one per gap the reporter reproduced on main):

- API_KEY gains the ark- value shape (#2946): Volcano Ark and the relays
  in front of it issue keys with an ark- prefix, and no value rule knew
  one. ARK_API_KEY=<ark key> was masked already (its name has api_key in
  it); ARK_KEY=<ark key>, a key in prose and one in a request body went
  as they were.
- A new SECRET rule takes an upper-case env var whose name only ends in
  KEY or PASS: SERVICE_X_KEY=…, FOO_KEY=…, DB_PASS=… — quoted or not.
  Upper case is the boundary: in the lower case a name that ends in key
  is code's (a sort_key:, a cache_key:, a public key =), so nothing of
  TestMaskGatewayKey's rows moves; notAPlainKey turns the upper-case
  SORT_KEY/PUBLIC_KEY/PROMPT_CACHE_KEY/CACHE_KEY away too.
- A new SECRET rule takes the value of an Authorization: or Cookie:
  header line, whatever it looks like — the opaque bearer tokens and
  session values the shape rules had no eye for (#2946).
- MaskJSON masks the value of a field named for a secret by its name,
  before the ids and names that would keep it: {"api_key": "…"} with a
  value no rule knows, {"db_pass": "…"}, an AKIA under access_key_id
  (its _id kept it from the value's own AKIA rule), {"Authorization":
  "Bearer …"} and {"Cookie": "…"} (#2946). signature,
  encrypted_content and data: values still go as written (#1911), and
  the tools' definitions are untouched. SecretName now says a name
  ending in pass is a secret's name too, so the archive (ScrubJSON) and
  MaskJSON judge a field by the same names.

Why: the reporter's five examples each leak a credential whose value has
no key's shape; the rules judged values by shape alone and field names
only ever kept a value. The boundary the reporter warned about —
sort_key, cache_key, prompt_cache_key, public_key must stay unmasked —
is held by case (lower-case names never enter the new rules) and by
notAPlainKey for the upper-case ones.

Run (rebased onto 9ae79122, upstream/main 10-27): the 18 upstream redact commits since
9b0f4861 (714ab8e8 CJK password rule .. 25341b4c address narrowing) add CJK-named
secret rules, made-up key forms and narrow emails and addresses — none covers
the five families here, so the rules take them side by side; the shared
secretNames rule carries upstream's new notCode boundary (511c4a76). The
_KEY/_PASS rule's boundary is notPlainKeyOrCode (plain key names and code
naming a secret both stay), the same resolution 2ea09ec3 on
codex/verify-2946-redact carried and the issue thread endorsed:
Refs #2946

Review: the ark- key, _KEY/_PASS assignment and Authorization/Cookie
rules land as written here. Two parts were narrowed in this batch's
redact follow-up ("a secret's field name masks only in a tool's
arguments"): a secret's JSON field name now masks only where the user's
data sits (a tool call's arguments and a tool's result, with secrets
on), never across the whole body by name, and an Authorization or Cookie
line masks only when what follows has a credential's shape. None of the
redact commits on main since 10-27 covered these five families.

Landing record (yetone):
Run at the pushed batch head (tree a6b084d0b, on origin/main 616405061),
go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider and internal/plugin (this batch's
packages and those main changed since the full run): all ok. gofmt -l
clean; go vet ./... (darwin), GOOS=linux and GOOS=windows go vet -tags
nogui ./... clean. internal/gui on macOS (mote-run):
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners
(#3949), both red at main too.
- The full go test ./... -timeout 45m -count=1 ran one rebase earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2 (main then gained 5bfa9f076's
group stand-in, b19d08593, f856d381a and 616405061). It ran on Linux
(wsl-run): 82 packages ok. internal/agent has 4 reds, all red at
origin/main on that box as well: TestInstalledVersion,
TestGrokInstalled, TestOmpDetectedWithPiDir and
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, #3548). The root
package and internal/cli need gtk4 to build, so they ran on macOS
(mote-run): ok. TestColdTurnsTaken (#4510) was red there once. An
earlier full run at base d307aa648 was red once in
TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone at both
the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
Broken by hand: gua's ablations, in the thread. The narrowing is broken
by hand in that follow-up.
Not tried: a real vendor request carrying these values through the
gateway; the rules were tested in internal/redact only.

Review: the ark- key, _KEY/_PASS assignment and Authorization/Cookie
rules land as written here. Two parts were narrowed in this batch's
redact follow-up ("a secret's field name masks only in a tool's
arguments"): a secret's JSON field name now masks only where the user's
data sits (a tool call's arguments and a tool's result, with secrets
on), never across the whole body by name, and an Authorization or Cookie
line masks only when what follows has a credential's shape. None of the
redact commits on main since 10-27 covered these five families.

Landing record (yetone):
Run at tree 7d7955eb9 (this batch on origin/main 3cfba2e37), go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider, internal/agent and internal/usage
(this batch's packages, plus those main changed since the full run): all
ok except internal/agent's TestInstalledVersion, TestGrokInstalled and
TestOmpDetectedWithPiDir, red at origin/main on that box too (#4033,
#3548). gofmt -l clean; go vet ./... (darwin), GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean. On macOS (mote-run), the
root package and internal/cli ok; internal/gui red in
TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
(#3949) and TestColdTurnsTaken (#4510), the first two red at main too.
- The full go test ./... -timeout 45m -count=1 ran two rebases earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2, on Linux (wsl-run): 82
packages ok, internal/agent's 4 reds as above, plus
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, red at main). The
root package, internal/cli and internal/gui need gtk4 to build, so they
ran on macOS as above. An earlier full run at base d307aa648 was red
once in TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone
at both the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
- Rebased after these runs onto origin/main c1457f2ee. Its two commits
since 3cfba2e37 (3f2faef62 gui, c1457f2ee agent) touch neither
internal/gateway nor internal/redact, nor any file this batch changes,
and were not run again here.
Broken by hand: gua's ablations, in the thread. The narrowing is broken
by hand in that follow-up.
Not tried: a real vendor request carrying these values through the
gateway; the rules were tested in internal/redact only.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 06:38:00 +08:00
yetone 03f609e3fd redact: a token count is not a secret (Discord, steven_4422; #3775)
steven_4422 in #feedback, with a screenshot of the Masking page: "total
number of tokens are masked as secret". Claude Code's system reminder
<total_tokens>1499872 tokens left</total_tokens> went upstream as
<total_tokens>{{SECRET_dkfgb3bf}} tokens left</total_tokens>, listed under
Secrets and found by the local model. #3775 had the same with AstrLink
Guard (<total_tokens>14902266).

Cause: the model labels the count `secret`; modelFits lets a hex run
(hexRe, which a run of decimal digits matches) through when secretCued
finds a key word right before it, and secretCued takes a cue anywhere in
the name before the value, with letters after it: the tag's name
total_tokens ends "token" + "s", so the count was "called a token". The
same held for "total_tokens": N, max_tokens: N and token_count=N.

Fix: a value of decimal digits alone that the model calls a secret is
masked only where the name right before it (then =, :, is, a tag's >,
quotes) ends with a key's, a token's, a password's or a PIN's word
(numberNamedSecret: api_key=, "token": , PIN:, user_pin=, 密码是,
<token>…). A name that runs on past the word counts what it names.
Rules are unchanged (numeric keys after key=/token: labels, phones,
ID numbers keep their own rules). The eval's token-count case now comes
out right for AstrLink Guard, so its #3775 marker is off.

Tests: TestTokenCountIsNoSecret uses the reporter's bytes in a Claude
Code user message's system reminder (the reporter's 7-digit counts, and
8-digit ones as Claude Code sends on a large window; the model's
len >= 8 secret check already let the 7-digit ones go, so the reporter's
exact values may have been 8 digits as read off the screenshot), plus a
usage object, max_tokens, token_count and "spin:". TestNamedNumber-
SecretStillMasked keeps api_key=, "token":, token is, PIN:, user_pin=,
password:, 密码是 and <token>…</token> masked.

Broken by hand: with model.go as on main, TestTokenCountIsNoSecret is
red for the 8-digit counts, total_tokens, max_tokens and token_count
(PIN:/user_pin= were not masked on main either; now they are).

Run (mote-run, base origin/main 93b31f5b7):
- gofmt -l clean; go vet ./internal/redact, GOOS=linux -tags nogui and
  GOOS=windows go vet ./internal/redact ./internal/masking ./internal/pii:
  clean.
- go test -timeout 45m ./internal/redact/... ./internal/masking
  ./internal/pii ./internal/otlp ./internal/sessions ./internal/settings
  ./internal/gui ./internal/gateway: all ok except
  - redact TestMaskEval: the token-count case's known issue was now
    fixed (marker removed, green after);
  - gui: TestCoreScriptBudget (green at 19594cc1c), TestSettingsSave-
    KeepsWhatItDoesNotSend (#4514, red on main, gui untouched here) and
    ten AppKit real-window tests killed at their deadlines on mote
    (#2645, #4125).
- Rebased on origin/main 19594cc1c: go test ./internal/redact/... ok,
  gofmt clean, TestCoreScriptBudget ok, #4514 still red there.

Not tried: the real local model (AstrLink Guard / Privacy Filter) on the
reporter's request; the gateway package was not run again after the
rebase (the commits in between touch usage, provider and the GUI).
2026-10-31 14:19:02 +08:00
yetone 79b4be4668 redact: a public IP goes as public-ip-<letters>, not a documentation address
akic404 on Discord (#feedback, 10-31): "ip的脱敏策略需要改进,会把公网ip直接
脱敏成内网ip,能不能沿用其他的方法用{ip:…}的代替". Since c2aad3db0 (10-28) a
masked public IP went as an address from RFC 5737's ranges (192.0.2.,
198.51.100., 203.0.113.). A 192.0.2. one reads as a LAN address to a
person, and every model knows the ranges: asked why ssh to the address
timed out, the models told the user they had an example address, not
their server's.

Now a public IPv4 or IPv6 address goes as public-ip- and eight lowercase
letters (public-ip-kvxqmrtz): visibly masked, still says it is public,
and a host name models ssh to. Same stand-in for an address every turn,
never shared, put back only as a whole name (no letter, digit, - or _
against it, no dot before it or before a name after it), in streamed
tool-call arguments too. A name with no dot reaches nobody if the vendor
tries it. A documentation address the user writes is no stand-in any
more, so it can't come back as someone's real address.

Run:
- Real models through the local gateway (deepseek-v4-pro, glm-5.3,
  kimi-k3, claude-sonnet-5-5, gpt-6-luna), two prompts each: "我的服务器
  是 X,帮我 ssh 上去看看磁盘" with a bash tool, and "阿里云服务器 X 从家里
  ssh 超时,是公网还是内网地址?最可能的原因?".
  - 203.0.113.147 / 198.51.100.147 / 192.0.2.183: ssh 5/5; diagnosis:
    4/5 (deepseek, kimi, gpt, glm) said "example address, use your real
    one", sonnet named it TEST-NET too.
  - {{IP_k3v9x2mq}}: ssh 0/5 (asked for the real IP, or grepped env);
    diagnosis fine.
  - public-ip-kvxqmrtz: ssh 5/5; diagnosis 5/5 security group or
    "public address", none said wrong/example address.
  - ip-kvxqmrtz (no "public"): ssh 4/5, but 4/5 called it an internal
    host name. Hence the public- head.
- On mote: gofmt -l, go vet ./internal/redact ./internal/gateway,
  go test -count=1 -tags nogui ./internal/redact ./internal/maskrec,
  and -run "Redact|Mask|Restore|IP|Privacy" ./internal/gateway: ok.
- Broken by hand: restoreAddr without its boundary check turns
  TestIPGoesAsAPublicIPName red; stand-ins made as 203.0.113.x again turn
  TestIPGoesAsAPublicIPName, TestIPv6GoesAsAPublicIPName,
  TestIPStandInsNeverShared and gateway TestRedactedKinds red.

Not tried:
- a real magpie build end to end with a real model (the gateway test runs
  the whole path against a fake upstream; the real models saw the
  stand-in text itself);
- the full suite, and Linux/Windows vet (no OS-specific code touched);
- an agent that resolves host names through a DNS search domain would
  look up public-ip-x.<domain> if a stand-in ever came back unrestored.
2026-10-31 11:48:21 +08:00
yetone 5218119456 redact: every reply gets its values back, a turn that masked nothing too
yapechan123 (Discord) saw a table the model wrote come back as
{{PERSON_kb32hzkg}}、{{PERSON_iye66366}} and {{PERSON_isyrz5ih}}、
{{PERSON_j5kluh3x}}, all four in canonical form. Every way a placeholder
could come back unrestored was probed with those literal bytes, on each
protocol's stream split at every byte and at 1..7 runes, and whole:

- The gateway put no restoring writer on a reply when the request in
  hand masked nothing (redactedHits, redactedPromptHits returned early
  on n == 0). A vendor that holds the conversation (Codex's compacted
  history, a server-side session) answers with placeholders of earlier
  turns while the request carries no value, so they went back as
  written. Most likely the reporter's path. Now every reply on a masked
  route is read.
- Responses streams: each event's random "obfuscation" string could end
  like a placeholder start and take the stream's one held tail from its
  delta, so the placeholder after 、 stayed (4 of 140 text runs, 6 of
  tool args runs). The writer now holds a tail per string path and
  never for obfuscation or kept keys.
- Kept keys (name, type, data, status...) were never restored in a
  stream, so a Gemini functionCall args object {"name":"{{PERSON_…}}"}
  kept it. Every string is restored now but signatures, data: URLs and
  opaque blobs (sealedText).
- A whole body skipped restoring unless it held "{{", so a model's
  PERSON_kb32hzkg or {PERSON_kb32hzkg} stayed; heldIn looks for any held
  placeholder's hash.
- makeRoom let a random half of 200k values go though its comment said
  the oldest; now the least recently used half (touch on every mask and
  hit), so a value just masked is never the one let go.
- A binary reply (audio/, image/, video/, octet-stream, pdf, zip) goes
  through as it comes instead of being held.

Not fixed by design: values are in memory only (README's privacy
promise, TestNoValueOnDisk), so a placeholder from before a restart that
only the vendor still holds can't be restored. Masking switched off
later also restores nothing.

Tests (all red on d159314e3's code, green now, run on mote):
TestReporterTableRestoredOnEveryStream (responses-text 4, responses-tool
6 fails before), TestPlaceholdersRestoredWhereverTheySit,
TestFullValuesKeepTheNewest (499 of 1000 newest lost before),
TestBinaryReplyIsNotHeld, TestReplyToAnUnmaskedTurnIsRestored (gateway,
real stack: first turn masks an email, second masks nothing and the
fake vendor answers with the first turn's placeholder).

Run: gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... on mote: clean. The full go test -tags nogui
-timeout 45m ./... on mote, one step before this head, found a nil
masker in redactedPromptHits with masking off (image drawing:
TestAntigravityDrawingOutOfQuotaInsideTheReplyGoesOn, internal/cli's
image MCP); fixed here (m == nil returns as before). At this head
internal/redact and internal/gateway pass on Linux (wsl-run, 594s).
That run's other reds are outside this change: internal/gui
TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll) and
TestColdTurnsTaken, internal/proc TestNoCommandBypassesProc
(internal/claudetui/child_unix.go uses os/exec). The full suite runs
again at the pushed head after the tag.
Not tried: a real Codex compaction round trip with a real account, and
the reporter's agent (unknown).
2026-10-31 11:23:53 +08:00
yetone e8d42c02db gateway: a masked request tells the model its placeholders are used as written (treeMan)
treeMan on Discord: with masking on, weaker models refuse to search
with a {{NAME_xxxxxxxx}} placeholder, ask to verify it, or rewrite it as
"an example name", which breaks long tasks. A request in which masking
swapped a value (maskHits.n > 0) now carries one short note, on each try:

  Values written like {{NAME_ab12cd34}} are placeholders for real values.
  Use them exactly as written, in replies and in tool calls alike: they
  are filled in with the real values before anything runs. Don't ask to
  verify them, and don't replace them with examples.

It names neither magpie nor a vendor or client (TestPlaceholderNoteIsNeutral
fails on magpie, Codex, Claude, a vendor's name, "provider", "gateway"...).
Its example uses a '1', outside the placeholder alphabet, so it is never
taken for a real placeholder or restored.

Where: where placeholders first appear, so it is new text the first time
and the same text on every later turn (the cached prefix holds). In the
instructions when they or the tools hold one (Anthropic system's last
block, Chat's first system/developer message, Gemini systemInstruction's
parts); otherwise on the earliest message that holds one, as a block or
part after its content (a string content becomes [text, note] blocks on
Anthropic, a paragraph on Chat), and on Responses as a developer message
after that item and the tool outputs following it. Responses
`instructions` (Codex's base_instructions) is never touched. A note
appended after text starts with a blank line, so a translator that joins
blocks (Anthropic to Chat) keeps it apart from the user's words.

Not added:
- a Claude subscription: the bridge puts the caller's instructions into
  the run's first message, which Anthropic classifies; text added there is
  risk for no gain;
- a ChatGPT/Codex sign-in (Account.Agent codex); Codex's own turns on
  codexUpstreamOn don't pass this loop either;
- a Responses turn with previous_response_id: the note would pile up in
  the stored conversation.
count_tokens counts without it.

A first version put the note in the system prompt. The full suite showed
TestMaskedConversationKeepsItsCachedPrefix red (a secret first found in a
tool output changed the system at turn 1 and rewrote the cache), hence
the first-appearance placement.

Run (mote, through mote-run):
- go test ./internal/gateway ./internal/redact -run
  'TestPlaceholderNote|TestMaskedRequestTold|TestMaskedConversation|
  TestUnredacted|TestRedacted|TestMask|TestMiddlewareThroughGateway': ok.
- Full suite at 46bdbad8f (-timeout 45m, log kept whole): red in
  internal/gateway TestMiddlewareThroughGateway (mine: its fake echoes the
  last message, which now holds the note; the fake strips it now), and
  five tests red alone on origin/main cc81ad4ea too, filed as #4362
  (TestAntigravityTurnsCodexsGPT5ThreadAwayOnce, TestAntigravityTurnedAway*,
  TestCodexSpentGrokFailingIsTold); internal/gui TestMainWindowCorners
  (#3949). Every other package ok.
- At 79c6a487c (this change on cc81ad4ea): go test -timeout 45m
  ./internal/gateway ./internal/redact ./internal/masking/...: redact and
  masking ok; gateway red only in the five #4362 tests.
- go vet ./internal/gateway ./internal/redact on macOS, CGO_ENABLED=0
  GOOS=windows go vet ./... on mote, go vet of both in WSL (Linux): ok.
  (CGO_ENABLED=0 GOOS=linux go vet ./... stops in wails' menu_linux.go on
  main too, so Linux was vetted natively.)

Broken by hand:
- note always in Anthropic's system (`if true ||`):
  TestMaskedConversationKeepsItsCachedPrefix, TestPlaceholderNotePlaces,
  TestMaskedRequestTold and the TestUnredacted* echo tests red.
- wiring off in serve: TestMaskedRequestTold red.
- the claude/previous_response_id skips removed:
  TestPlaceholderNoteNotOnClientPaths red.

Not tried: no real vendor or weak model was run with the note, so whether
it stops the refusals treeMan saw is not measured; no real Claude
subscription or Codex sign-in request (both skipped by design).
2026-10-30 14:08:22 +08:00
yetone 7632e1be1d redact: a text sent on a route goes on it as it went, the model's late finds too (vvrfxyz on X)
vvrfxyz on X: "脱敏功能是不是会降低缓存命中率 我开了脱敏后 dsh命中率暴跌".

Cause: the local model (AstrLink Guard, on by default) is waited for
2s a request (masking's defaultWait). A tool's output it hasn't read
by then goes with the rules' masking alone (pii.Partial). On the next
turn the model has read it, finds the names in it, and the same history
text now goes with {{PERSON_…}} in it. Everything from that message on
is a new prompt to the vendor, so its prefix cache misses. 50f52b540
(10-23) kept the known values of a text sent before as they went, but
not the model's finds.

Reproduced with real dsh 0.2.1-rc.2 (headless profile, sandbox HOME):
three turns in one session (read team.md, customers.csv and
notes/standup.md; check contracts.md; summarise the customers) through
a sandbox magpie with masking and the default model on, to a recording
Chat Completions upstream. dsh's own request bodies were recorded and
replayed in order, 3s apart, through a fresh sandbox magpie (found
cache cleared) on Linux (WSL2 magpie-desktop, -tags nogui).
- Old (origin/main without this change): "the local model read 5 of a request's
  7 texts in 2s". At request 7, message 6 (customers.csv's tool output)
  changed at byte 252: "1000,Fatima Rossi,Client 0 GmbH" became
  "1000,{{PERSON_2rmvxto6}},Client 0 GmbH". 4,793 of that request's
  18,380 history bytes were sent as before (26%). Over the whole
  conversation 97,815 of 111,402 resent bytes (87.8%) were the same.
  It happened on both runs.
- New: 108,378 of 108,378 (100%), the same Partial in the log.
- On mote (M5 Pro, CoreML) the model read everything inside 2s. Old
  code kept 100% of the prefix over the same 3 turns, and after a
  restart of magpie too (suspect 3, the key and the in-memory maps,
  was not the cause). Suspects 1 (known values) and 4 (re-encoding)
  were not the cause either: every other request kept its prefix byte
  for byte.

Fix:
- redact: sentKnownSpans becomes sentSpans. It remembers, per text and
  options, both the known values and the model's finds the text first
  went with (sentModel, sentKnown). The key now includes Options.Route,
  and for the model also the threshold, whether there is a model, and
  NamesByModel.
- learnLate: what the model finds in such a text since is made known
  (placeholder, scores) without being put in the text, so new text has
  it masked as before.
- The gateway gives masking each request's route (maskedFor,
  masking.WithRoute): the providers its model, the model's fallbacks or
  a group's members are served by, the same set unredactedRoute walks.
  Codex's own sign-in passes "codex", or the account's provider.
- A request with no route (search, embeddings, a text prompt) keeps
  the model's finds of now, and its known values as before.

Trade-off: a name the model reads late in a text sent before keeps
going as written on that route. That route's vendor was sent it as
written already. Within a route of several providers (fallbacks, a
group), a member that wasn't the first to get it may be sent it in
that form, as it could have been on the first turn's failover. In the
Linux replay, customers.csv's ~110 names stay as written on later
turns, where old code masked them from turn 2 on. The new turns'
masking is unchanged (the same placeholder counts in messages 9, 12
and 14). Another route, never sent the text, gets it masked with what
is known and found now. That is stricter than before for known values,
which were kept whatever the vendor. The alternative, waiting for the
model before any text goes, is what defaultWait was cut to 2s to stop
(shensmart, 10-28).

Tests:
- TestModelReadingLateKeepsTheSentPrefix (internal/masking): a model
  that reads a text only after its first request. Turn 2's history must
  be byte-identical, the name masked in new text, and masked on another
  route and with no route.
- TestMaskedPrefixKeptOnlyOnItsRoute (internal/gateway): a system
  prompt kept as written on its provider, masked on another.
- Broken by hand on mote, each red:
  - sentModel not remembered: "turn 2 rewrote message 2";
  - learnLate removed: "the new turn has the name the model found as
    written";
  - maskedFor returning ctx without a route: "another provider, never
    sent it, got the value as written".
  Each was green restored. TestMaskedConversationKeepsItsCachedPrefix
  and TestSentTextKeepsItsMasking stay green.

What was run, at this commit on origin/main 4b4c4a806, on mote
(after rebasing on e863f520c, which touches internal/gateway: gofmt, vet
of gateway/masking/redact, redact and masking whole, and gateway -run
"Mask|Redact|Sent|Effort|Route" ok again):
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.
- Targeted at this head: go test ./internal/redact ./internal/masking
  ./internal/gateway (ok), with the two new tests and
  TestMaskedConversationKeepsItsCachedPrefix, TestSentTextKeepsItsMasking.
- Full suite (go test -timeout 45m ./...) was still running on mote at
  push (load ~110, other sessions), pushed per the ship-at-once rule; its
  result goes on the release and any red gets its own issue.
- GUI suite not run: no GUI file, API or string changed.

Not tried: vvrfxyz's own machine and vendor (DeepSeek's real cache_hit
counts), and Windows.
2026-10-30 10:26:50 +08:00
yetone 95b40fb2f1 redact: a URL's password that is also its user, host or database goes as written (xuanwo on X)
xuanwo on X, 10-29: "我的很多项目名被识别成了 password,一天脱敏了 26M
次". The screenshot: a Codex summary where geodatafusion went as a
made-up word (bsssqojjdekwi) in every path, in rust/geodatafusion/,
geodatafusion.toml and cargo test -p geodatafusion; GEODATAFUSION in
capitals was left. Settings listed it under Passwords.

Cause, reproduced with the repo's own bytes: the geodatafusion repo's
PostGIS test (testing/postgis/README.md, rust/geodatafusion/tests/
postgis/README.md, .github/workflows/postgis-differential.yml) runs on
  postgresql://geodatafusion:geodatafusion@127.0.0.1:55432/geodatafusion
The URL PASSWORD rule (user:password@) took the password. Once masked a
value is known (knownSpans) and is masked wherever it is written, case
as written, so the project's name went as a password in every request
for the rest of the run. Neither the local model nor b9f1fcddd's
words-only check is involved: this is a rule's find, which is known
whatever its look. Other projects set up the same way (name:name@)
each made their name known.

The rule: masking a URL's password hides nothing when the same URL has
it written as its user, a label of its host or a part of its path
(postgres:postgres@, root:root@, guest:guest@, app:shopdb@…/shopdb,
geo:geo@db/geo). hiddenInURL leaves such a password as written, so it
is never known. Whole parts only: geo:geod@…/geodb is masked. A
password not written elsewhere in its URL is masked as before, whatever
it looks like, there and as known everywhere after
(postgresql://geo:opensesame@…: opensesame is masked in a later path
too). This is scoped by where the value is in the URL, not by how it
looks: a URL in a tool call's arguments is judged the same way, and a
random password there (Tr0ub4dor3) is masked.

What the user gets: after updating (a restart forgets every known
value, the store is in memory) the project's name goes as written. The
user's ask, choosing what is masked without one exception at a time,
is already in Settings › Privacy: each kind (Passwords among them) has
Mask / Warn / Block, and Warn sends that kind as written while still
recording it; Never mask takes values. Yayoi_no_yume asked under the
same tweet for a switch per kind; that row is it. No new control is added: an Off
that records nothing would be a fourth state beside Warn with little
more to it.

The 26M: maskrec counts every place masked in every request's whole
body, and an agent resends its history each turn, so one known word in
a long Codex history was counted hundreds of times a turn. Filed as
#4193 (with the unmeasured CPU question of MaskJSON having no memo).

Tests: url_password_test.go.
TestURLPasswordWrittenElsewhereGoesAsWritten: the repo's README and
workflow lines, then the screenshot's summary text, then a Codex body
with the URL in exec_command's arguments and "cargo test -p
geodatafusion", each unchanged with 0 masked; postgres:postgres@,
root:root@, guest:guest@, app:shopdb@…/shopdb, redis://:cachebox@cachebox,
geo:geo@db/geo unchanged. TestURLPasswordStillMasked: hunter2pass,
geo:opensesame@…/geodata, geo:geod@…/geodb and redis's r3disPass
masked; Tr0ub4dor3 in a tool call's arguments masked; opensesame
masked again as known in a later path.

Broken by hand: the rule without hiddenInURL: red, both URL lines
masked, the summary 9 places masked as the screenshot shows
(/f745/<made-up>, rust/<made-up>/tests, -p <made-up>), the body 4, and
each of the six same-word URLs masked; green with it.

Run (mote, at 033b17baf + this commit): go test -run
'URLPassword|URLUserinfo|Known' ./internal/redact ok; gofmt -l clean;
GOOS=linux and GOOS=windows go vet ./internal/redact ok. Full suite
go test -count=1 -timeout 45m ./... started on mote; at push time it was
still in internal/agent and internal/gateway (load 60 to 225 from four
suites of other sessions), internal/access ok so far. Shipped without
waiting on it, as the owner asks; any red it names gets its own issue.

Not tried: a real Codex session with the geodatafusion repo; no GUI
change, so no GUI run.
2026-10-29 15:53:04 +08:00
yetone 2eee5d6d1e redact: a folder or a program's word is no one's name or address (kekek711 on X)
kekek711 on X, 10-29: "node_modules给识别成姓名了". With the local
model on, node_modules went to the vendor as a placeholder of personal
data, and the agent couldn't read or list the folder.

Where it came from: the model's PERSON spans were already held to a
name's shape (personFits: no underscore, a capital; modelTakes: no
snake_case word), so a person's name can't take node_modules on main.
Its ADDRESS spans were not: modelFits only turned away an ASCII value
with a slash and no space, so node_modules, site-packages, __pycache__,
dist, vendor, "ls node_modules" and "node_modules 太" (the span running
on into the sentence) all went as {{ADDRESS_…}}, which Settings lists
under the same model as names ("姓名、地址"). A lone SECRET span over
"node_modules/" or "__pycache__" also went, as b9f1fcddd's wordsOnly
didn't read a folder's slash or Python's underscores.

- programWords: a value with an underscore, or Latin letters in lower
  case with no digit, is a program's words; an ADDRESS that is one goes
  as written. A real address has its number or capitals (42 Wallaby
  Way), a Chinese one its characters.
- wordsOnlyRe takes underscores around a word and a slash after it
  (node_modules/, __pycache__), so a secret the model alone found there
  goes as written unless assigned to a secret's name, as b9f1fcddd does.

Neither real model labels node_modules in what I could give it: AstrLink
Guard (MAGPIE_GUARD_DIR) and Privacy Filter (pf-serve pf-v2 with the q8
GGUF, on mote's GPU) were run on the literal texts below and on an
ls -la, a du, a .gitignore, a Cannot find module trace and four Chinese
sentences, and found only names (John Smith, Rina Kowalczyk, and kekek
in ls -la, which personFits drops). The reporter gave no screenshot, so
which label it had is not known; the tests drive each label over each
span with the fake model.

Tests: program_words_test.go.
TestModelLeavesProgramWords: a Claude Code body (Bash tool_use
"ls node_modules", a tool_result with node_modules/.bin/tsc, the user's
"node_modules 太大了"), each of PERSON/ADDRESS/SECRET over node_modules,
node_modules/, "node_modules 太" and "ls node_modules"; then
site-packages, __pycache__, dist, vendor, rm -rf node_modules and the
reporter's own sentence. TestModelStillMasksNamesBesideProgramWords:
Rina Kowalczyk, 42 Wallaby Way, Sydney and 建国路88号 beside the folder
are masked still (3 of 3).

Broken by hand: the tests run with model.go at a14f5c9c9 (the fix
stashed): red, 15 failures (ADDRESS over every span and word, SECRET
over node_modules/ and __pycache__); green with it.

Run (mote-run, this tree on a14f5c9c9): gofmt -l internal/redact
internal/pii clean; go vet ./internal/redact ./internal/pii/...; go test
./internal/redact ./internal/pii/... ./internal/masking ok.
Then go test -timeout 45m over the packages that use redact: gateway,
otlp, settings, sessions, redact, masking, pii/... ok; gui red on
TestCoreScriptBudget (#4133, 1531446 > 1530861, main's) and
TestMainWindowCorners/macOS_26_SDK (#3949, main's on macOS 27); this
change touches no gui file. GOOS=linux and GOOS=windows go vet
./internal/redact ./internal/pii ok. Not run: the full ./... suite (mote
was busy with another session's suite).

Not changed: a SECRET span with other words in it ("ls node_modules",
"node_modules 太") still goes as a secret: a passphrase is lower-case
words with spaces too, and the shape doesn't tell the two apart.
2026-10-29 09:20:38 +08:00
yetone b9f1fcddde redact: words in lower case the model took for a secret go as written unless assigned to a secret's name (dniray on Discord)
dniray, on v0.1.1976 after 300b7eee0: drizzle-orm still went out as
{{SECRET_o2tu7vej}}, now in a tsup config in a Markdown fence:
  external: [/@nestjs/, 'reflect-metadata', 'rxjs', 'mysql2', 'drizzle-orm'],
v0.1.1932 and v0.1.1976 each let a package's name go in more places
(import lines, manifests, errors, installs, pins); a list in a build
config was none of them, and the places can't all be listed.

Cause, reproduced with the real model on mote: AstrLink Guard finds
drizzle-orm as a secret on that line alone at 0.515 (and pieces of it,
"zzle-orm" 0.755, "-orm", which modelFits already drops, elsewhere in
the block). Under Guard's default slider (0.8) it isn't masked; with the
slider at or below 0.515 origin/main masks it ('{{SECRET_…}}'), and once
masked it is known and masked in the whole block and every later
request. Privacy Filter finds nothing in it.

The rule, by shape instead of place:
- modelFits: a secret the model found that is lower-case letters only,
  words joined by - . or _ (wordsOnly: drizzle-orm, reflect-metadata,
  lodash.merge) is masked only where it is assigned to a secret's name
  (assignedSecret: a name holding password/pass/pwd/key/token/secret/
  credential or 密码/密钥/令牌, then =, :, is/was, 是/为, right before
  it). A list's comma is no assignment: 'jsonwebtoken', 'drizzle-orm'
  is not cued, where secretCued would take the token in it.
- knownSpans: a known SECRET of that shape whose score is the model's
  alone (scores < ruleFound) is masked again only where assigned. A
  rule's find, the user's rules' and a value with a digit, a capital or
  a symbol are matched as before. magpie's own SECRET rules already ask a
  digit of a value after password= (secretValue).
- Old data: the known store is in memory only, so updating (a restart)
  forgets a remembered drizzle-orm anyway; in a magpie still running,
  the knownSpans check lets one the model remembered go on the next
  request with no action from the user.
- Cost: a lower-case-letters-only password the model alone found under a
  password's name stays masked there, but where it comes back with no
  name before it (an echo in prose) it now goes as written.

Tests: package_words_test.go. TestModelWordsArentSecrets: the literal
block in a user message as Markdown, in a Read tool_result with Claude
Code's line numbers, prose and the name alone, with a fake model at
0.93; red on origin/main ({{SECRET_…}} in all). TestKnownModelWordsGoAsWritten:
drizzle-orm and reflect-metadata remembered as the model's, then the
block with no model and in a body; red on origin/main; and
"DB_PASSWORD: drizzle-orm" still masked. TestWordSecretsStillMasked:
PASSWORD=opensesame, {"password": "letmeinplease"}, "the wifi password
is purplemonkey", api_key: correct-horse-battery, hunter2pass,
Zq8vR2mT6wLp, Tr0ub4dor&3xq still masked by the model; a rule's
"token 是 bluewhalesinging" masked again as known in prose.

Run, at 926ef769f + this change, on mote:
- go test -count=1 -timeout 45m ./internal/redact/... ./internal/masking/...
  ./internal/otlp/... ./internal/pii/... ./internal/sessions/...
  ./internal/settings/... ./internal/gwmw/... ./plugins/redact/...: ok
  (TestMaskEval's recordings pass unchanged, no Known entry flipped)
- go test -run "Redact|Mask|Privacy|Unredact|Known|Restore"
  ./internal/gateway ./internal/gui: ok
- gofmt -l internal/redact: clean; go vet, GOOS=linux -tags nogui and
  GOOS=windows go vet on ./internal/redact/ ./internal/masking/: ok
- the real AstrLink Guard and Privacy Filter (zzcache) over the literal
  block, a fragment, the lone line, the block in a Markdown doc and a
  .env, each also with Read line numbers, slider at 0.3: origin/main
  masks drizzle-orm in the lone line (Guard); with this change nothing
  masks it, and PASSWORD=opensesame (Guard 0.908/0.962), hunter2pass and
  the JWT secret are masked still.

Broken by hand, each red: the modelFits check off
(TestModelWordsArentSecrets, all five); the knownSpans check off
(TestKnownModelWordsGoAsWritten, both); assignedSecret always false
(TestWordSecretsStillMasked, four cued cases, and the assigned case).

Not tried: dniray's own text and slider setting (the screenshot's block
is cut off at the top); the full go test ./... and the whole gateway
and gui suites; Windows and Linux runs (vet only). No eval case added
(recordings not re-recorded).
2026-10-29 08:45:58 +08:00
yetone 300b7eee08 redact: a package's name goes as written where it was masked before, and in manifests and errors (dniray on Discord)
dniray, on v0.1.1965 after v0.1.1932's fix: "问题还在", with
import { and, eq } from ' drizzle-orm ' still going out as
from ' {{SECRET_o2tu7vej}} '.

v0.1.1932 let the module an import loads go as written only where the
local model found it on that line (moduleAt in modelFits). A value
masked once is known (knownSpans) and masked wherever it is, with no
look at what is around it. So once the model took drizzle-orm for a
secret anywhere in a request (package.json's dependencies, a tsc
error, a sentence: none of those was exempt), the import line was
masked as known: in the same request (MaskJSON walks the texts in
order) and in every later one.

- knownSpans skips a known value where packageAt says it is a
  package's name.
- packageAt: moduleAt, plus a manifest's dependency pinned at a version
  ("drizzle-orm": "^0.36.4", workspace:*, TOML x = "9";
  dependencyAt), a folder under node_modules or site-packages, the
  module an error could not find (Cannot find module 'x', No module
  named 'x', Can't resolve 'x'; missingModuleAt), a package an install
  names (pnpm add x, npm i -D x, pip install x, cargo add x;
  installedAt, not after a --token-like flag), one pinned with @
  (x@0.36.4, lower case, not an IPv4 address; pinnedAt). A piece of a
  name (drizzle-orm of drizzle-orm/pg-core, of @acme/drizzle-orm) is
  judged as the whole name.
- moduleAt reads past an editor's line number and a diff's mark
  (codeHead): Claude Code's Read gives "     1→import drizzle from
  'drizzle-orm'", and a default import there wasn't an import line.

Tests: package_known_test.go.
TestKnownPackageNameGoesAsWrittenWhereCodeLoadsIt has the reporter's
literal line in a Claude Code tool_result after a sentence with the
name, in one Anthropic body, then alone (Mask, no model) and in a
second body: red on the old code at all three
(from ' {{SECRET_…}} '). TestModelPackageNamesInManifestsAndOutput: 22
shapes, red on the old code. TestPackageShapesKeepSecrets: a JSON key
with a non-version value, a password before @ip, a quoted secret on a
numbered line, prose with "install", a known secret in prose and on a
numbered line are masked still.

Run, at 936bdccfa + this change, on mote:
- go test -count=1 -timeout 45m ./internal/redact/... ./internal/masking/...
  ./internal/otlp/... ./internal/pii/... ./internal/sessions/...
  ./internal/settings/... ./internal/gwmw/...: ok (TestMaskEval's
  recordings pass unchanged)
- go test -run "Redact|Mask|Privacy|Unredact|Known|Restore"
  ./internal/gateway ./internal/gui: ok
- go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
  ./internal/redact/... ./internal/masking/...: ok; gofmt -l: clean
- the real AstrLink Guard and Privacy Filter on mote (zzcache), at
  their default thresholds, over 12 texts: the literal line, a
  numbered Read of a drizzle file, package.json, pnpm add, a tsc
  error, node_modules path, prose, a .env: neither model found
  drizzle-orm anywhere, and the .env's password and JWT secret were
  still masked with the change.

Broken by hand, each red: the packageAt check in knownSpans off
(TestKnownPackageNameGoesAsWrittenWhereCodeLoadsIt, all three);
codeHead off and missingModuleAt/installedAt/pinnedAt off
(TestModelPackageNamesInManifestsAndOutput, 11 cases).

Not tried: what made the model take drizzle-orm for a secret on
dniray's machine. Neither real model does on any text tried, so the
fix is held by the fake model; the known path is the one way found
that v0.1.1932's check is passed by. No eval case added (recordings not
re-recorded); the full ./internal/gateway and ./internal/gui suites;
Windows and Linux runs (vet only).
2026-10-29 08:00:53 +08:00
yetone 5a85a9836c redact: a value at the end of a tool call's arguments keeps its closing quote (xiaojiang091499 on X)
xiaojiang091499 on X (v0.1.1808): "隐私脱敏误把 Codex 工具参数结尾的引号和
花括号一起替换了,破坏了参数格式,导致会话一直报错重连". Still the case on
main before this commit.

Cause, outbound: a tool call's arguments are masked as JSON text
(MaskJSON, escaped). A span is kept out of escapes (#3022) but not inside
its JSON string, so a span that runs past the string's end took the
closing quote with it. The local model does this: Privacy Filter's
tokenizer merges a punctuation run, so in {"cmd":"export
DB_PASSWORD=Hunt3r!"} the real model's SECRET span is `Hunt3r!"`, and a
secret's edges are kept by design (#3591). Same with "the api key is
AbC…!?\"", "ship to 221B Baker Street, London.\"", "pwd=Qq123456@#\"".
A user rule like `tok-\S+` does the same. The vendor got
{"cmd":"export DB_PASSWORD={{SECRET_…}}}: arguments no longer JSON, so
Codex's turn failed and reconnected. The model is on by default since
v0.1.1858, so this hits every user from then.

Fix: inStrings (redact.go) moves each span in escaped text onto the JSON
string it starts in and ends it where that string ends. A span that is a
whole bare value (a number a rule finds, "acct": 12345678901) is kept and
its placeholder goes in quoted (span.bare); any other span outside a
string is dropped. Text that isn't valid JSON is left as before. This is the
path for Responses function_call and Chat tool_calls arguments (JSON
text); Anthropic tool_use input and Gemini functionCall args are
objects, masked string by string, so a span there never leaves its
string.

Sibling, inbound: Writer.event and restoreJSON read an event's "type" as
the walk reached it, so a Responses function_call_arguments.delta whose
"delta" key comes before "type" (as a Go map or any key-sorting proxy
writes it) had its value put back unescaped: a password with a quote in
it ended the arguments' string. typeOf now reads the type first, and the
Writer falls back to the SSE event name. Chat tool_calls and Anthropic
input_json_delta were already right (key "arguments"/"partial_json").

Tests (internal/redact/argstail_test.go):
- TestArgumentsValueAtEndKeepsQuote: the real model's four spans
  (captured from Privacy Filter on mote) and a \S+ rule, in Responses and
  Chat bodies; arguments stay JSON, the value is gone, Restore gives the
  original back.
- TestArgumentsBareValueQuoted: a bare number is masked as a string.
- TestWriterStreamArgumentsValueAtEnd: a value with a quote and a
  backslash, at the end of the arguments, split at every byte after its
  placeholder starts, through Responses deltas (delta before type),
  Chat tool_calls and Anthropic input_json_delta.
- TestRestoreJSONDeltaBeforeType: the whole-body path.

Broken by hand: without inStrings, the first two fail; with the type
read in the walk again in writer.go, the stream test fails at cuts 28-43
({"cmd":"export DB_PASSWORD=Hunt3r!"\x"}); the same in json.go fails
TestRestoreJSONDeltaBeforeType.

Real model: a probe (not committed) ran Privacy Filter on mote over 36
argument texts through MaskJSON as the gateway does; before, the
arguments were broken for each case above; after, all 36 are valid JSON
with the value masked.

Run on mote (mote-run): go test ./... -timeout 45m -count=1 at this
change on 655f8dbd1: every package ok except two reds already filed and
outside redact: internal/gui TestMainWindowCorners/macOS_26_SDK (#3949)
and internal/provider TestClaudeAccountServesModelsListedSinceItsFetch
(#3174). Rebased on 362774210/e5e2aa58e (gateway and routes only), then
internal/redact, internal/pii and internal/masking again at the pushed
head: ok. go vet ./..., GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go build
-tags nogui, GOOS=windows go build: ok. gofmt -l: nothing.

Not tried: a real Codex session through the gateway with a masked
password; Gemini's functionCall with the real model (its args are an
object, masked string by string, never as JSON text). No docs/subsystems
page describes where spans are placed, so none changed.
2026-10-29 01:17:04 +08:00
yetone 7a79318337 redact: a package's name goes as written, an import's module first (dniray on Discord)
dniray (v0.1.1917): "脱敏会把包名给替换了", with the case
import { and, eq } from ' drizzle-orm ' going out as
from ' {{SECRET_…}} '. The SECRET came from the local model; the rules
left it. AstrLink Guard reproduces the class on mote with
require( ' jsonwebtoken ' ) -> {{SECRET_…}} and a requirements.txt
django-rest-passwordreset==1.4.0 -> {{SECRET_…}}==1.4.0; Privacy Filter
took a pnpm-lock integrity hash (sha512-…==}) for one, eating the }.

A probe of ~60 package shapes (npm scoped and pinned, Java/Android ids,
Go module paths, Python modules, purls, Debian, Cargo, Gradle, Maven,
CocoaPods, lock files) through Preview, rules alone and with both real
models, default kinds and all kinds, found these and fixed each class:

- model, any kind: the module a line of code loads is never PII
  (moduleAt): a quoted specifier after from on an import/export line or
  after } or *, import 'x', require('x'), import('x'), and unquoted
  from x import / import x / use x:: / extern crate x at a line's start.
  A from in prose ("the token from 'Zq8v…'", "copy it from Zq8v…") is
  judged as before.
- model SECRET: a name a version is pinned after (==, >=, ~=, !=, <=,
  ===; pinnedAfter); @ is left out so s3cretPass@10.0.0.5 still masks.
- model SECRET: an SRI hash (sriRe in namesThing).
- secret-named field rule (fieldAt, keyAt, modelTakes): a version or a
  range is no secret value: "js-tokens": "^4.0.0-beta.1",
  jsonwebtoken = "9.2.0-beta1", secretVersion = '2.1.0-alpha03'
  (versionValue).
- user@host (off by default): js-tokens@4.0.0: in pnpm-lock.yaml went
  as a user and a host (notPackagePin); alice@10.0.0.5 still masks.

Left as is: SECRET_PACKAGE=@acme/secret-store-v2 and
PASSWORD_LIB=passlib-1.7.4 (a value under a secret's name, not told
apart from a password), and Privacy Filter's "Dagger Hilt" as a person.

Tests: package_names_test.go. TestPackageNamesGoAsWritten (rules,
default and all kinds), TestPackagePinIsNoLogin,
TestModelPackageNamesNotMasked (dniray's literal bytes first, through
fakeModel), TestPackageNameChecksKeepRealValues (emails, an ssh host,
password=, API_KEY=, a secret-named field with a real value, alice@ip,
a model secret in prose after from, before ==, before @ip).

Run, at b692de9c8 + this change, on mote:
- go test -count=1 -timeout 45m ./internal/redact/... ./internal/masking/...: ok
- go test ./internal/otlp/... ./internal/pii/... ./internal/sessions/...
  ./internal/settings/...: ok; -run "Redact|Mask|Privacy|Unredact"
  ./internal/gateway ./internal/gui: ok
- go vet ./internal/redact/... darwin, GOOS=linux -tags nogui, GOOS=windows: ok
- gofmt -l internal/redact: clean
- probe with real AstrLink Guard and Privacy Filter (MAGPIE_EVAL_CACHE):
  every shape above as written; emails, ssh host and the author's email
  still masked.

Broken by hand, each red: moduleAt off (TestModelPackageNamesNotMasked:
drizzle-orm, reflect-metadata, jsonwebtoken), notPackagePin always true
(TestPackagePinIsNoLogin), versionValue false
(TestPackageNamesGoAsWritten), pinnedAfter off and sriRe off
(TestModelPackageNamesNotMasked).

Not tried: dniray's own text didn't make either model fire alone on
mote (the model reads context), so the fix is held by the fake-model
test and the jsonwebtoken case the real model does fire on; the eval
recordings were not re-recorded (no eval case added); the full
./internal/gateway and ./internal/gui suites.
2026-10-29 00:45:18 +08:00
yetone c2aad3db02 redact: a wallet address goes as written, and an IP as a documentation address the agent can use
0x0_air on X (10-28): with masking on, the agent stopped and asked again.
Their EVM address (0x89dfBD9b…, public) went as a secret placeholder and
the vendor's model told them to rotate it in case it was a private key;
the server IP they typed went as {{IP_…}} and the model refused to ssh
to it and asked for the real host.

- model.go: the local model's SECRET/ACCOUNT span on 0x and 40 hex
  digits (evmRe) is left as written; no rule matched it, the model's
  label did (the 0x prefix and mixed case got past hexRe). A 64-hex
  private key is masked still, and so is a 40-hex value called a key
  (secretCued).
- shape.go: an IP the IP rule masks goes as an address from the
  documentation ranges (192.0.2/198.51.100/203.0.113 .101-.254, IPv6
  2001:db8::/32), stable for the value, never shared by two values
  (falls back to {{IP_…}} past 462 IPv4 ones), and put back only as a
  whole address in replies and streamed tool calls (restoreAddr).
  Preview shows the same stand-in.
- docs: gateway-routing.md, and masking.html in en/zh/ja.

Run:
- Real models through the local gateway, the screenshot's ssh prompt
  with the placeholder vs a documentation address: with
  {{IP_k3v9x2mq}}, deepseek-v4-pro, glm-5.3, kimi-k3 and
  claude-sonnet-5-5 mostly searched ~/.ssh or asked for the real IP;
  with 203.0.113.147 or 192.0.2.183 all 20 runs over 5 models ran ssh
  at once.
- New tests (internal/redact/standin_ip_test.go): the screenshot's
  message, the tool call restored whole and streamed cut at every byte,
  boundary cases, IPv6, 472 addresses never sharing, the screenshot's
  address under labels secret and account_number with every category
  on, and a 64-hex key still masked. gateway TestRedactedKinds now
  wants a documentation address upstream.
- Broken by hand: without the evmRe check TestEVMAddressGoesAsWritten
  is red for every text and label; without restoreAddr the boundary
  cases are red; without the IP stand-in all three IP tests and
  gateway TestRedactedKinds are red.
- On mote at this head (rebased on 27bf14790): gofmt -l, go vet
  ./... for darwin, linux (-tags nogui) and windows, go test -count=1 -timeout 45m
  -tags nogui ./... (and go build for
  darwin, linux -tags nogui and windows): every package ok, exit 0.
  The run before at 56602426d had TestMoreKinds red, which wanted
  {{IP_…}}; it now wants the documentation address.
- Rebased again on 56d26f0bb (two gateway commits, #4004): go vet
  and go test -tags nogui of internal/redact, internal/gateway and
  internal/maskrec on mote at this head: ok.

Not tried:
- the real AstrLink model on an EVM address (the fake model gives it
  the labels it can give);
- a host name (user@host) still goes as {{HOSTNAME_…}};
- a documentation address the user writes themselves can match a
  stand-in in a reply and be put back as the real one;
- stand-ins are not kept across a restart or once their slot is
  evicted, like every placeholder.
2026-10-28 20:23:38 +08:00
yetone a5315c70d5 redact: the local model doesn't read an agent's tool definitions (niuniu_8964 on X)
码妞 on X: the official container on a 4-core, 8 GB server, AstrLink Guard
on, Claude Code's requests sat at 脱敏中 for minutes and timed out, load
1.78, a short conversation. aca0f0d8a made Guard read a text's windows
at once; this takes away most of what it reads.

MaskJSON asked the model about every text it masks, the tools'
descriptions and their schemas' too. On Claude Code 2.1.296's own request
(internal/gateway/testdata/workdir) that was 67,532 bytes, 52,577 of them
definitions: the agent's or a tool server's text, the same in every
request. The per-text cache only helps after the first request has been
read whole, so a fresh install (or new tools, or a Claude Code update)
paid for all of it at once, past the gateway's 2 minutes on a slow CPU.

Now what is under the request's definitions (defKeys, defItems) is never
sent to the model; it is masked as with the model off, by the rules
alone (emails, phones, keys, the user's words still are). It is masked
after the rest of the request, so a value the model found in a message
is masked in a definition too, as known. The system prompt and messages
are read as before.

Measured on magpie-desktop (WSL, Ryzen AI Max+ 395, taskset to the CPUs
named), real Guard model (rev 7216b6a3, sha256s checked), that request
through redact.MaskJSON with guardBackend, cold cache:
  4 CPUs: 129 texts, 67,532 bytes, 11.5s before; 7 texts, 14,955 bytes, 2.6s now
  2 CPUs: 20.9s before, 4.9s now
  rules alone 13-15ms; the same body warm 13ms, the next turn 36-44ms,
  before and after.
On three real Claude Code requests (claude-code-2.1.296.json,
context/claude-code.json, dsh-gateway messages-turn.json), masked with
the model at 0.8 and with the rules alone, every top-level key came out
the same: the model masked nothing in their definitions that the rules
didn't.

No time cap was added. The reporter turned the model on (the default-on
model is from today, ae0327945), so a request there is held for the
model and never falls back to the rules; a cap would only turn the wait
into an error. Less to read is the fix.

Tests:
- TestModelNotAskedAboutDefinitions (new): on Claude Code 2.1.296's and
  Codex 0.162.1's own requests no definition's text is asked about, and
  every long text said is.
- TestDefinitionMaskedAsWithoutModel (new): a tool's description and a
  schema property's come out as with no model; the email, the key and
  the phone in them are masked.
- TestModelAskedOnceForRequest: now asks about the message only, and the
  description's name is still masked (as known).

Run:
- mote-run: go vet ./internal/redact ./internal/masking, GOOS=linux and
  GOOS=windows go vet of them: ok. go test ./internal/redact/...
  ./internal/masking/... ./internal/pii/... ./internal/gwmw/...: ok.
  go test -run "Mask|Redact|Privacy|Unmasked|Masked|Placeholder"
  ./internal/gateway ./internal/middleware ./internal/gui: ok.
- wsl-run: go test ./internal/redact ./internal/masking: ok; the stage
  timings above (a scratch test, not committed).
- gofmt -l: clean.
- The vet and the test lines above ran again after rebasing onto
  d6df72a2b (its own redact change), and redact, masking and the
  gateway masking tests again on 25fc92d59: ok.

Broken by hand:
- Definitions sent to the model again: TestModelNotAskedAboutDefinitions
  red ("the model was asked about a definition's "Launch a new agent…""),
  and TestModelAskedOnceForRequest red.
- Definitions masked in the first pass, before the messages:
  TestModelAskedOnceForRequest red ("description":"find Rina Kowalczyk"
  went as written).

Not tried: the reporter's server, the Docker image itself, or a real
Claude Code session through it; a Chinese full name only in a tool's
description is no longer masked (the model was what found one; the rules
mask Chinese names only beside the model). The full go test ./... wasn't
run: mote had another session's full suite on it at load ~216, and only
internal/redact changed.
2026-10-28 17:36:40 +08:00
yetone d6df72a2ba redact: a disassembly's symbols (system@plt, foo@@GLIBC_2.2.5, system@got) are no email
ch35tnut_ on X: reversing, symbols like system@plt were masked as
emails, so masking had to be turned off for reverse engineering.

The rule's regexp already needs a dot and a mail TLD (mailTLD), so
system@plt, puts@got.plt and memcpy@GLIBC_2.14 went as written by it at
origin/main. The local model's EMAIL spans pass realEmail too, which
never asked for a dot: .got is an ICANN top-level domain, so a model
span on system@got (IDA's "; system@got") was masked. And a
foo@plt.got ends in .got with a dot, so the rule masked that too.

realEmail now asks mailHost first, for the rule and the model alike: the
host has a dot, every label is letters, digits and hyphens (or non-ASCII,
an IDN's), no label empty, the local part does not end in @ (foo@@VER),
and the host is not made of linker table words alone (plt, got, sec,
iplt, igot: free@plt.got, memcpy@plt.sec). A version with an underscore
(@GLIBC_2_2_5) or no dot (@Base, @GLIBC_PRIVATE) is no host.

TestSymbolIsNoEmail has objdump, readelf, nm, gdb and IDA lines as they
print them, for the rule and for a fake model flagging each symbol as
private_email, and checks that rina.k@fastmail.com in code and
ops@build01.acme.io beside a symbol are still masked by both.

Run at this head (origin/main aca0f0d8a), through mote-run:
- go test ./internal/redact ./internal/pii ./internal/masking
  -count=1 -timeout 45m: ok, ok, ok.
- gofmt -l clean; go vet of the three on darwin, GOOS=linux -tags nogui
  and GOOS=windows: clean.

Broken by hand:
- mailHost's call made `false &&`: TestSymbolIsNoEmail red, the model
  masked "; system@got" as {{EMAIL_…}}.
- linker check made `return true || !linker`: red, rule and model both
  masked <free@plt.got>.

Not tried: the real local model (AstrLink / Privacy Filter) on a
disassembly; the fake model stands in for its spans. Full go test ./...
not run; this touches internal/redact and its doc only.
2026-10-28 17:23:59 +08:00
yetone eb6d1d8d97 redact: a colour or an ordinary word is no personal name (黄绿色, 关键词)
hh05928822 on X after v0.1.1850: names were found in ordinary Chinese,
"黄绿色" the worst, with 边••, 应••, 关••, 尚• in the screenshot.
wangjunxiao128: "关键词" taken for a name.

Both ways a Chinese name is found (the model's PERSON spans in
modelSpans, and the cue rules in zhNameSpans) now go through one check,
zhWordNotName: a span that is an ordinary word is no name, unless a role
before it or a title after it says a person is meant (客户方圆, 江山老师).
A word is (zhWordShaped):
- a colour: Han colour characters alone, or anything ending in 色
  (黄绿色, 红色, 金黄色, 浅蓝色);
- a two-character word starting with a surname, from zhWords or the new
  zhDict (边界, 应该, 尚可, 关心);
- such a word with a noun ending after it (关键词, 关键字, 应用层,
  毛利率, 时间戳, 文件名).
zhDict is zhdict.txt, embedded: ~1,550 two-character words from jieba
v0.42.1's dict.txt (MIT, in THIRD_PARTY_NOTICES), the first character a
surname, frequency >= 100, tag not nr/nrt/nrfg, and a list left out by
hand (陆游, 关露, 欧阳, 司徒...) in its header. The surname list keeps
黄, 关, 边: they are real surnames, so 黄晓明, 关羽 and 毛利兰 are still
masked. modelTakes' own zhWords check moved into the shared one.

Run on mote at 761e0e010 + this change:
- go test -timeout 45m ./internal/redact/... ./internal/pii/...
  ./internal/masking/... ./internal/maskrec/...: all ok
- go test -run TestNotices . : ok
- go test -run "Mask|Redact|Privacy|Person|Name|Known" ./internal/gateway: ok
- gofmt -l internal/redact: clean
- GOOS=linux and GOOS=windows go vet of redact, pii, masking: ok

Broken by hand, each red:
- zhWordNotName returning false (at 761e0e010 too):
  TestChineseWordsAreNoNames, TestModelWordsAreNoNames,
  TestModelNamesBesideWords.
- The colour rule, zhDict and the noun-ending rule each turned off:
  TestModelWordsAreNoNames and TestModelNamesBesideWords.
- The role/title exception removed: TestModelNamesBesideWords.
- The old model.go and zhname.go with the new tests: both new tests red
  (the cue rules alone masked 请黄绿, 发给黄绿, 张伟和黄绿).

The real AstrLink Guard model on mote (MAGPIE_GUARD_DIR) found 黄晓明,
关羽, 张飞, 毛利兰 and 工藤新一 with this change, and flagged none of
long agent-style prompts with 黄绿色, 关键词, 边界线, 边距, 应用层, 尚可,
on the old code or the new.

Not tried: the reporters' own texts (not in the reports), so their
exact false positive was not reproduced with the real model; Privacy
Filter; the GUI. 高峰期 is still masked: jieba tags 高峰 as a name.
2026-10-28 17:01:49 +08:00
yetone ae03279458 masking: the local model is on by default; the rules mask alone until it is downloaded
The owner's plan (10-28, after the xuanwo/_kaichen reports under the
masking demo): with AstrLink Guard picked, the Chinese-name heuristic
is off and only nicknames like 小王/老李 stay a rule; with Privacy Filter
it is as before; every format rule stays; the model is on by default,
masks with the rules alone until its download finishes, and no longer
answers 503 for it.

- masking.ModelWanted(st): on when the user turned it on, off when the
  user turned it off (new RedactModelOff, set by SetRedactModel(false),
  remove, and cancelling the default's own download), on when the
  default's download finished (RedactModelAuto). A settings file from
  before this, with a model name picked or files on disk and the model
  off, reads as the user's off: magpie's default doesn't override it.
- Until the picked model is installed, requests are masked by the rules
  alone and fetch starts its download (one try per model per hour,
  never under testing.Testing(), nothing where the model can't run).
  When it finishes, settings.UseDefaultRedactModel records the default
  (it refuses when the user has set anything) and the model warms.
- model(..., strict): a model that fails holds requests back (503)
  only when the user turned it on; under the default the rules mask
  alone. The Privacy page says which ("…the rules mask requests alone"
  in en, zh, zh-TW, ja, de; /api/privacy-model has `chosen`).
- redact.Options.NamesByModel (AstrLink Guard picked): zhNameSpans
  keeps only zhNick candidates (小/老 + a surname).
- KeepOwn and POST /api/settings keep both new fields.
- Docs: gateway-routing.md, site masking docs (en, zh, ja).

Run (mote, Go 1.26.8):
- gofmt clean; go vet of masking, settings, redact, gui; GOOS=linux go
  vet of masking, settings, redact; GOOS=windows go vet of the four.
  (GOOS=linux vet of internal/gui needs cgo, as on main.)
- go test -count=1 -timeout 45m ./... at base 7fd77a944: every package
  ok except internal/gui. Its reds: TestCoreScriptBudget (+64 bytes,
  fixed by dropping a comment, budget not raised), TestPrivacyModelPick
  and TestSettingsSaveKeepsWhatItDoesNotSend (updated for the new
  default and fields), TestMainWindowCorners (#3949, red on origin/main
  e8c7dddcb too), and three AppKit tests killed at 20-30s under load
  just before mote rebooted, which pass in the rerun.
- Rerun at base 6bec526f7: internal/gui (only #3949 red), masking,
  settings, redact ok. GUI node tests privacy-model, masking-records,
  masking-demo, routing-masking, i18n-keys, gui-zh-tw, gui-ja, gui-de:
  Chromium 199/199, WebKit 106/106.
- At the pushed base 9e33962c0: TestCoreScriptBudget, TestSettingsSave*,
  TestPrivacyModel* ok; i18n-keys and privacy-model 68/68 in both
  engines.
- At the pushed base 7fcf642ee (masking in the request archive):
  -run 'Mask|Redact|Archive|Privacy' in masking, gateway, redact ok.

Broken by hand, each red: the nick filter off
(TestChineseNamesByModelOnlyNicks), ModelWanted needing RedactModel
(TestModelOnByDefault), strict ignored (TestDefaultModelFailingIsTheRules,
TestNoModelYetMasksByTheRules).

Not tried: a real default download in a sandbox HOME (the tests fake the
model). Known limit: a user who turned the model on before model picks
existed and then deleted it has no name or files left, so reads as new
and gets the default on.
2026-10-28 16:55:24 +08:00
yetone 189db9ba5b redact: ids, digests and 毛利 go as written; the slider reaches known values; a user name goes as a made-up name
Reports on X under the masking demo (10-28):

_kaichen: "hash类型也会被过滤…长int,假如以1为开头的…会被当作电话被mask;
"毛利低"也会被当作人名被mask。即使把匹配拉到 0.95,也是一样行为".

- Hex digests: 16 to 31 hex digits in one case, with letters and digits
  both (a cache key, a short commit), are ids now (digestShaped in
  ids.go), like UUIDs and 32+ hex. The rules' SECRET keeps one only under
  a credential's field or a CJK/prose key with no field word (密钥为…);
  the model's SECRET is dropped under a field named for something else
  (cache_key, commit, object, blob, file, content, revision, partition,
  shard, bucket, dedup, lookup, row, sort) and on a JSON object's key
  (nameOfField). A bare `key` after api/access/secret/private/signing/
  license is still a credential (keyPhrase). The IBAN case kept its mask
  through the letter/digit minimums.
- 11-digit 1x numbers (phone.go, phoneAt): a phone with +86/86, as the
  value of a field whose name says phone (phone, mobile, tel, cell,
  contact, 手机, 电话, `number`), or in prose with no id word right
  before it (order, id, no., #, 订单号, 编号, 单号, 流水号…). Under
  order_id/uid, after 订单号, or with a letter or digit against it, it
  goes as written. PHONE and BANK_CARD are bounded by alnum, not digits,
  in the rule and in known values.
- 毛利: zhWords gained 毛利, 毛重, 毛坯, 毛巾, 毛衣, so 毛利低 (a margin)
  is no surname+name. The model still finds 毛利兰 (Guard). 毛利小五郎
  (indekkusu141209) is masked by neither model nor the rules now.
- The slider: a value masked once was masked again as known whatever the
  threshold. Each value now remembers the highest score it was found
  with (rules count as sure, ruleFound), and knownSpans skips one under
  Options.MinScore, which masking sets from pii.Threshold.

eerttreeeert: with mimo-v2.6-flash the home folder went as
C:\Users\{{USERNAME_…}}; the model took it for a temp folder and set out
to delete it. With the user name switch on, it now goes as a made-up name
of 8 lowercase letters (HMAC of the name, same every turn, standIn in
shape.go), restored in replies and tool calls like any placeholder;
Preview shows the same name.

Docs: docs/subsystems/gateway-routing.md masking bullets, and the site's
masking page (en, zh, ja) on mobile ids and the user name.

Run (mote, at this tree on base 6af83172d; rebased onto b01193ef9, which
changes nothing in redact, masking or pii, and redact, masking and
pii/... run again ok at the pushed head):
- gofmt -l clean; go vet ./... and GOOS=darwin/linux/windows go vet of
  redact, masking, pii: ok.
- go test -count=1 -timeout 45m redact, masking, pii/..., gateway, otlp,
  sessions, settings: all ok but internal/gateway's
  TestPluginStreamsPastTheBudgetWait (connection reset by peer, 183 of
  192), red the same alone at fresh origin/main b01193ef9 (169 of 192);
  #3946, commented.
- Real models on mote (AstrLink Guard and Privacy Filter, cached): the
  reporter's hashes, ids and every 毛利低 sentence kept; a prose phone
  masked; 毛利兰是谁 masked by Guard; 毛利小五郎姓什么 kept by both.

Broken by hand, each red: phoneAt off; the phone bound back to digits;
digestShaped off; "cache" out of the field list; nameOfField off; the
model's field check off; 毛利 out of zhWords; the slider check out of
knownSpans; standIn off.

Not tried: a real mimo-v2.6-flash session with the made-up name; the
Windows box; the GUI suite (no GUI file changed). 毛利小五郎 stays
unmasked by rules and both models, said in the doc.
2026-10-28 16:05:19 +08:00
yetone f02d92c7be redact: a file's lines, a path, a skill and a name in code after token: are no secret
Three reports on X (10-28), each a value the SECRET rule took (Insights >
Masking: 机密, 规则). The rule takes a name with token, secret, password
or api_key in it, then : or =, then 8 characters or more with a letter and
a digit. Prompts and code have that shape where nothing is secret:

- AlpsNowX: L643-669. was masked, in two requests. A file whose name has
  one of those words, then :L643-669. (internal/auth/token.go:L643-669.)
  read as a field token.go and its value, and once masked the lines went
  as {{SECRET_…}} wherever they came again (by known). Now a name that is
  a source file's (.go, .ts, .py, .md, .json …, not .txt/.env/.key) or a
  path's last part is no field, and a line or range (L643, L643-669,
  L12-L40, 643:12) is no value. Siblings: token.go:643-669 and #L643-L669
  were never masked (no letter / no colon); file.go:L12-40 was, and isn't.
- binary4cat: function names masked. access_token = get_access_token_v2,
  max_tokens=max_tokens_v3, secret: env.SECRET_V2, refreshToken2;,
  fn(token=token_v2), secretKey:=base64Encode(raw) all masked the name.
  A value written as code writes a name (lower-case start, or _ or .
  between words) of two words or more, one of them token/secret/password/
  key/credential, is a name now; a value starting with = is Go's :=.
- AkinoNya: folders and skills with a random string replaced. Found two
  routes: a path after such a name (PRIVATE_KEY_PATH=~/.ssh/id_ed25519,
  token_dir=/private/tmp/claude-501/x7k2p9q1-skill,
  GOOGLE_APPLICATION_CREDENTIALS=/Users/…/legacy_credentials/x7k2p9q1/…,
  私钥 ~/.ssh/…), and Claude Code's plugin:skill when the plugin's name
  has one of the words (design-tokens:generate-v2, secret-scan:
  audit-x7k2p9q1). A path from ~/, ./, ../ or a root folder (/Users,
  /tmp, /private …) with no + or = goes as written, in the CJK key rules
  too; slug:slug with no space is a skill. The ~1100 real folder and skill
  names on this machine (~/.claude, ~/.codex, $TMPDIR, Claude's
  claude-501 dirs) in five contexts masked nothing before or after, so
  the reporter's exact names are not reproduced.

Still masked (TestSecretsBesideLinesAndNames): password=hunter2pass9,
API_KEY=AbC123dEf456GhI789, token=t0k3nValue2, Passw0rd123, password123,
SuperSecret2024 (PascalCase stays a password), token: Lk8x9QmP2vR4,
secret.txt:hunter2pass9, x-api-key:k9x2mp4qr7st1vw3 and :ab12cd34ef56,
Password=Abc12345; in a connection string, 密钥为12231241, 私钥 ab12…,
django-insecure-…; vendorchecks and the existing code tests unchanged.

Run (mote): go vet ./internal/redact for darwin, linux, windows; go test
-count=1 ./internal/redact ./internal/masking ./internal/pii/...
./internal/otlp ./internal/sessions ./internal/settings ./internal/gateway
at base ea53eb126: all ok (gateway 551s). After the rebase onto
bc3ddc661 (zhname): vet (3 OSes) and redact, masking ok. gofmt -l clean.
Broken by hand: the two SECRET rules back on notCode and keyAt without
the path check: 28 of the new tests' cases red (every reported shape),
the still-masked test green.

Not tried: the full ./... suite (mote at load ~50 with two other full
suites); the reporters' own prompts; the local-model path, unchanged.
Tradeoff: a password written as code writes a name (myPassword1,
MY_SECRET_2) now goes as written.
2026-10-28 15:16:59 +08:00
yetone bc3ddc661a redact: 文案 and words like it are no Chinese names (zeewell on X)
zeewell on X: tasks kept going wrong because 文案 was masked as a name,
so they turned names (and birthdays) off. 文 is a surname, and zhName
took a cue around 文案 that says nothing about a person. Probing words
that start with a surname (文档, 方案, 关键, 项目, 成本, 段落, 颜色, 查询,
时区, 简历, 林间, …, ~130 of them) in the places a prompt has 文案, about
110 were masked, through two cues:

- 一下 before it (改一下文案, 检查一下文案,) counted as "a person comes
  next". 一下 follows any verb, so it now counts only after one that asks
  a person (zhAskVerbs: 问, 找, 联系, 通知, 提醒, 回复, …): 问一下张伟
  still is one, 改一下文案 is not.
- At a sentence's start, a word after it that any subject takes (已经,
  明天, 今天, 昨天, 他, 她, 提交, 负责, 回复) counted alone: 文案已经改好了,
  文案明天给你, 文案他们说. Those (zhAnyAfter) now count only with a
  person's cue before (客户张伟已经到了). 说明, 说法, 讲解, 讲座, 讲义, 讲究
  are words, not 说 (文案说明), but for 说明天 (张伟说明天来).
- zhWords gets ~150 more common words (文案, 文风, 关键, 项目, 段落, 林间,
  …) for where a real cue is before a word (发给文案, 请文案), and is a
  set looked up by a candidate's first two characters rather than a scan.
- The model's own PERSON span that is such a word whole (文案) is
  dropped too (modelTakes), the other route a word reaches a name.

Old data: masked values are remembered in memory only, and 文案 (6
bytes) is under minKnown, so nothing stays masked after the update.

Fixtures are prompts with 文案 where the report gives no sentence (帮我
改一下这段文案, 文案:…, 把首页文案换成英文, ### 文案, 文案和图片, 文案已经改好了,
文案说明要简短, 这张图发给文案。), beside names in the same places that
still mask (问一下张伟,, 张伟说明天来, 客户张伟已经到了, 发给张伟。);
TestChineseWordsAreNoNames runs 25 listed words in 10 shapes plus the
model's label, and 5 unlisted ones (文创, 方位, 高铁, 安防, 林荫) through the
cue shapes alone. Every TestChineseNames case stays green.

Run (mote, mote-run, at this tree): go vet ./internal/redact for darwin,
linux and windows ok; gofmt clean; go test -timeout 45m of
internal/redact, masking, pii/..., otlp, sessions, settings, gateway
ok; internal/gui red on TestMainWindowCorners/macOS_26_SDK only, the
macOS 27 red filed as #3949 (no redact in it).
After rebasing onto 8edb9dbb7 (gateway, provider only): redact and
masking again ok at the pushed head.
Broken by hand, each red: the 一下 rule always true (改一下文创), the
zhAnyAfter check off (文创已经好了, 文创明天给你, 文创他们定), the 说明 words
off (文创说明), the model's word check off (the model's 文案, 文档, …), 文案
out of zhWords (发给文案, 请文案).
Not tried: the real model on zeewell's prompts (they gave none). Now
left: a two-character name at a sentence's start before only 已经/明天/
他 (张伟已经到了。), and an unlisted word after a person's verb at a
clause's end (发给文创。). Birthdays: the report names no birthday that
was masked wrongly, so they are unchanged.
2026-10-28 15:15:31 +08:00
yetone 58fb3a7786 redact: 关键发现, 易触发 and 和边界 are words, not Chinese names
xuanwo on X: with the model on, a report's words were masked as names,
关键 in "### 关键发现", 易触 in "`gh pr view` 易触发" and 边界 in
"判断和边界,". Each starts with a surname (关, 易, 边), and zhName took
a cue around it that was too weak alone:

- 发 and 打 after it counted as the verb a person does. They now count
  only when no Han character follows, or one of 了个给过一 (发了个消息,
  打给他); 发现, 打开 begin a word.
- 和 and 与 before it counted as "a person comes next". They join like
  to like, so they now count only when a pronoun or what may be a name
  (a surname and 1-3 characters, no zhWords word) is before them:
  吴敏和郑浩, 我和张伟, not 判断和边界.
- A sentence started after any space or symbol. A space after a word or
  code is inside a sentence, so the start is now after punctuation (with
  spaces after it or none) or at the text's start; a backtick no longer
  counts.

The fixtures are the reporter's literal lines, beside names around the
same cues that still mask (### 张伟发了个消息, 我和张伟,, 这件事。 李娜说过).

Run (mote, mote-run): go test ./internal/redact (TestChineseNames,
TestMaskEval and the rest) ok; gofmt clean. Broken by hand, each red on
its own case: the 和/与 rule off (边界), wordAfter off (关键发现),
sentenceStart always true (易触发).
Running as this is pushed: vet (darwin, windows, linux) of
internal/redact and go test of redact, masking, pii, otlp, sessions,
settings, gui and gateway.
Not tried: the real model on the reporter's whole session; a name that
starts after a space following a Chinese word (这件事 李娜说过) is now
left, as one inside a sentence.
2026-10-28 14:27:17 +08:00
yetone bad05e1b79 redact: sk- and a UUID in lower case is a key again
3e96197da left an sk- value unmasked when it had no capital and no run
of 16 between hyphens, so an SK hynix article's address is not a key.
A key that is sk- and a UUID in lower case (groups of 8, 4, 4, 4 and 12
hex digits) met both and went to the vendor as written. A value that is
hex digits alone after sk- is masked again; no slug of words is.

Run on mote at this tree: go test ./internal/redact ok. TestSlugIsNoKey
with the UUID case is red on 3e96197da's rule ("0 masked"). The SK hynix
addresses stay unmasked.
Not run: the full suite.
2026-10-28 11:23:46 +08:00
yetone 3e96197da3 redact: an address's words joined by hyphens are no sk- key (sk-hynix-…)
innerpeacebuild on X: search results naming articles about SK hynix,
cnbc.com/…/sk-hynix-third-quarter-profit.html and the like, went to the
model with each slug as {{API_KEY_…}}. The sk- rule took any 20
characters of letters, digits, - and _.

A key's characters are random, so it now needs a capital or a run of 16
or more with no hyphen. DeepSeek's sk- and 32 hex digits and
OpenRouter's sk-or-v1- and 64 are lower case and still masked.

Run on mote at this tree: go test ./internal/redact ok;
TestSlugIsNoKey (the reporter's four addresses beside four keys) is red
on the old rule (each slug masked) and green on the new. go vet for
darwin, linux and windows ok, gofmt clean. Not run: the full suite;
only internal/redact changed.
2026-10-28 11:11:45 +08:00
yetone df8e9de3f1 redact: a masked word that is a date matches that date however it is written
JackyCcao on X turned birthday masking off (old dates in logs and tasks
after a birthday's word were still taken) and put their own birthday in
Masked words instead. A word matched only as typed, so 1990-05-12 let
1990/5/12, 1990.05.12, 1990年5月12日 and 19900512 go as written.

A masked word that is all of a date (dateword.go: year-month-day with
- / . 、 or a space, 年月日 or 년월일, a month's English name, or
day/month/year where only one reading is a date) now matches that
calendar date in each of those forms, with or without leading zeros,
as eight digits, and day-first or month-first only where the day is
over 12 or equals the month: for 1990-05-12 neither 05/12/1990 nor
12/05/1990, which reads as December 5th too. A word like 05/12/1990
is no date and matches only as written. Eight digits alone are not
taken for a date word (as likely an id) and match as before. A date
match never has a digit, or a dot and a digit, beside it, whatever
Whole words only says, so 1990.5.12.1, 3.1990.5.12 and 11990-05-12
are no match; this is a change for a date word without Whole words,
which matched inside such numbers before.

The birthday rule is not changed. It takes a date only right after a
birthday's word (生日, DOB, born...), so a log line's, a file name's
or a task's own date is never one, however old. What is left (生日:
2019-03-02 in a task log about a party) has the same shape as a real
date of birth, and a time beside the date doesn't tell them apart: a
date of birth stored as a time (1990-05-11T16:00:00.000Z, midnight in
UTC+8, as JavaScript writes it) is the commonest way one reaches an
agent in JSON. TestBirthdayLogDates pins both sides; #3878 tracks
fixed-shape false alarms.

Tests: TestDateWordEveryForm (22 forms x 5 words x 6 contexts, each
restored as written), TestDateWordDayMonthOrder, TestDateWordNotAnotherDate
(another date, 1990.5.12.1, longer numbers), TestDateWordOnlyADate.
Broken by hand: with the dateSpans hook in mask turned off, EveryForm,
DayMonthOrder and NotAnotherDate fail; OnlyADate and BirthdayLogDates
pin behaviour that was already right and pass on both.

Docs: gateway-routing.md, masking.html en/zh/ja.

Run on origin/main 94c2aaecb, sandbox HOME and GOCACHE, then rebased
onto 841bcf8da (its changes are in usage and gateway/history.go, none
in redact) and the vet and the four packages run again there; on e056779a6
(a GUI change, nothing in redact) redact, masking and settings again:
- gofmt -l clean; go vet clean on macOS, GOOS=linux -tags nogui and
  GOOS=windows (internal/redact).
- go test -count=1 ./internal/redact/... ./internal/masking/...
  ./internal/pii/... ./internal/settings/...: ok. The date tests also
  with TZ=UTC and TZ=Pacific/Kiritimati: ok.
- go test -count=1 -timeout 100m ./internal/gateway (at 94c2aaecb):
  every test ok
  but TestPluginToldWhereTheAgentWorks, which failed only because the
  run's TMPDIR was inside this git worktree (its "not in a repo"
  folder was in one, git "yes"). Run alone with TMPDIR outside the
  repo it is ok; with TMPDIR inside it fails at this head too.
Not run: the full ./... suite (another session's full suite holds the
machine, load ~100-140). No GUI asset changed, so no GUI run.
2026-10-27 22:44:52 +08:00
yetone e7ba8a3892 redact: an email that ends a sentence is masked
The EMAIL rule's bound characters held "." on both sides, so an
address followed by a full stop was no match: "The user's email
address is jo@quill.dev." (Claude Code's own userEmail line) and
"write to me at li.wei@qq.com." went to the vendor as written with
the rules on. Found measuring the local model's threshold for
Yayoi_no_yume on X: in 2000 segments of real Codex and Claude Code
traffic, two real addresses were masked only because a model found
them, at 0.70 and 0.95.

emailAt now judges a dot beside the match: one before it still turns
it away, and one after it only when a letter, digit, - or _ follows
(a@b.io.12 stays unmasked, as before). The rest of the bound
(letters, digits, _ % + -) is unchanged.

TestEmailBeforeAFullStop: its five sentence-end cases fail on the old
rule (5 of 5 unmasked), pass now; its two longer-name cases are
unmasked on both.
2026-10-27 17:10:20 +08:00
JoeyWu-tech 1cbdda25be redact: cua-driver's element tokens go as written (#3782)
Hu9956 (#3782): with masking on, DeepSeek Harness's computer use
(cua-driver: a window's state, then a click on one of its elements) went
to the vendor with element_token values as {{SECRET_...}}, found by the
rules. cua-driver hands the model a token for each element of a window:
s, the snapshot's counter in 8 hex digits, a colon and the element's
index (s0000002a:14). The model clicks by it. The SECRET rule takes a
value of 8 or more letters and digits after a field whose name holds
"token", and element_token is one, so each token in a window's state, in
a click's arguments and in a shell command's JSON went as a placeholder
and its index ({{SECRET_...}}:74). Two of the report's places show the
token with no index ("element_token": "s00000001"), so that is taken as
it is written too.

noIDs, which lets a backend's id (a UUID, 32 hex digits or more) go as
written unless its field is named for a credential, now takes an element
token for one too (elementToken): s and 8 lowercase hex digits, then a
colon and the index, with no letter, digit or _ on either side. Without
the index, s and 8 hex digits is one only as the value of a field named
for an element: alone in a text it may be a student's number
(s12345678), which the local model may call an account. A field named
for an element is no credential's, as one named for a page, a cursor or
a request isn't (credentialField, whose field name reading is now
fieldWords). So element_token's value goes as written, while the same
value after password=, token:, "refresh_token": or "api_key": is
masked, and so is a value of any other shape in element_token. A token
the local model takes for a secret, or anything else, goes as written,
as a UUID does. The user's own words still mask one.
docs/subsystems/gateway-routing.md says so.

A UUID in a field named for an element (element_token) goes as written
now too, as one in next_page_token does.

What was run (tree bb52fa4d, on origin/main 5215108e, go1.26.8,
linux/amd64):
- TestElementTokensGoAsWritten, new. Five tokens (s00000001,
  s00000003:74, s0000002a:14, s00007a3f:42, s00010001:3) in seven
  places, as the report has them (JSON laid out and compact, a space
  after the colon, a shell command's JSON, element_token=, inside a JSON
  string, elementToken), go as written. MaskJSON of a window's state and
  a click, DB_PASSWORD=hunter2abc9 beside them, masks the password
  alone. The local model's every label goes as written on s0000002a:14
  in a text and on s00000001 in element_token. s12345678, in a sentence
  or under student_no, labelled an account number or a secret by the
  model, is masked. s00000001 and s00000003:74 after password=, token:,
  "refresh_token": and "api_key" are masked, and so is element_token
  holding abc123def456, s0000000g1, S0000002A, s000000012, s00000001x or
  s00000001:x9. The user's own word masks one.
- It and TestIDsGoAsWritten -count=50: ok. internal/redact,
  internal/maskrec, internal/gwmw, internal/masking and plugins/redact:
  ok.
- Broken by hand, each red in TestElementTokensGoAsWritten:
  - idAround not taking an element token: every kept place, the
    MaskJSON body, the model's every label on s00000001 in
    element_token (the rule masks it there), and its address and secret
    labels on s0000002a:14.
  - "element" not among credentialField's words: every kept place, the
    MaskJSON body and the model's every label on s00000001 in
    element_token (the rule, again).
  - the model's secret kept on a token: its secret label on both.
  - s and 8 hex digits a token anywhere: s12345678's four cases.
  - a token only with its index: s00000001 in its seven places and the
    model's labels on it.
- A real run: magpie built at 5215108e and at this tree (go build -tags
  nogui -buildvcs=false), in a sandbox HOME with masking on
  (settings.json "redact": true), a local server standing in for the
  vendor that keeps each body it is sent. One request on
  /v1/chat/completions with the report's three places: a window's state
  as compact JSON with "element_token": "s00000003:74", one laid out
  with "element_token": "s00000001", a shell command's cua-driver click
  with "element_token": "s0000002a", a click by s00000003:74, and a user
  message with DB_PASSWORD=hunter2abc9. 5215108e: the vendor got each
  token as a {{SECRET_...}} placeholder (s00000003's with its :74), four
  places. This tree: each as written, the password still a placeholder.
- gofmt -l; go vet -tags nogui and go build -tags nogui for linux,
  windows and darwin, and go vet and go build for windows without the
  tag: exit 0 each. go vet and go build without the tag on linux: exit
  1 (this box has no GTK or WebKitGTK dev packages).
- go test -tags nogui -count=1 -timeout 45m ./..., Bun 1.4.2 on PATH:
  68 ok, and 7 red, none in what this changes: agent
  TestCodexDriftReached and TestCodexBehindReverseProxy (#3398);
  TestHowInstalled, TestCursorFolderFromTheEditorIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141);
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (#3640);
  gateway TestPluginToldWhereTheAgentWorks (#3675); gui
  TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
  (#3649); proc TestProbeTimeoutEndsWhatItStarted (#3848, passes 40 of
  40 alone); provider's "close of synctest channel from outside bubble"
  from TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so the
  package's tests after it didn't run: go test ./internal/provider
  -skip '^TestUnreadLoginsWriteErrorsKeepCredentials$', Bun 1.4.2 on
  PATH: ok.

Not tried: DeepSeek Harness and cua-driver themselves (no macOS here);
the request was written by hand from the report's places.

Review, applied on origin/main 8e2ba36de (git am, sha256 of the patch
matches the issue's 1db65568…), with two changes to the patch:
- The patch made any field with "element" among its name's words no
  credential's (credentialField) and the field an index-less token may
  sit in. That widened a key-name exemption: a UUID in element_api_key or
  elementSecret went as written. Now only cua-driver's own name,
  element_token (elementToken, element-token), is that field
  (elementField); any other name is a credential's as before.
- A token known from before (ByKnown) was still masked as a credential.
  One the local model labelled in prose ("I will click s00000001 now")
  was then masked in every element_token after it, a click on nothing.
  An element token is no longer masked by a value known from before;
  the user's own words and rules, and the password, API key and token
  rules, still mask one.
Not scoped to tool calls and results by place: the exemption is held to
the token's shape (s, 8 hex digits, :index; index-less only as
element_token's value), so a value of any other shape under that key is
masked, and every route masks through redact.mask (masking.Masker's
MaskJSON and Text), so each route gets it.

What was run in review (darwin/arm64, go1.26.8, sandbox HOME):
- TestElementTokensGoAsWritten red with origin/main's ids.go (the
  report's laid-out "element_token": "s00000001" went as
  {{SECRET_…}}), green with this.
- Broken by hand: elementField back to "any word element": red, a UUID
  and s00000001 in element_api_key and elementSecret went out; ByKnown
  masking a token again: red, the click's element_token masked after
  the prose turn.
- go test -tags nogui ./internal/redact/... ./internal/masking/...
  ./internal/maskrec/... ./internal/gwmw/... ./plugins/redact/... and
  internal/gateway -run 'Redact|Mask|Masked': ok. gofmt -l: nothing;
  GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  internal/redact: ok.
- Real run: magpie built at 8e2ba36de and at this tree, `magpie serve`
  in a sandbox HOME with "redact": true, a local fake vendor recording
  bodies; one /v1/chat/completions request with the report's three
  places (a laid-out window state with s00000001, a compact one with
  s00000003:74, a Bash call's cua-driver click with s0000002a) and
  DB_PASSWORD=hunter2abc9. Base: all three tokens went as {{SECRET_…}}
  (the second with its :74). This: all three as written, the password
  still a placeholder.
Not run: the full suite (one suite per machine; other sessions' runs
are on this box). Not tried: DeepSeek Harness and cua-driver
themselves.
2026-10-27 15:42:08 +08:00
yetone 7aeae59670 privacy: masked words can match as whole words only, by a switch under Masked words (acmilan_)
Settings › Privacy's masked words (脱敏词) were found anywhere: ABC masked
the ABC inside XABCD, and 123456 the middle of 91234567 or 0.123456. A
new row under "Masked words in any case", "Whole words only" (仅完整单词
匹配), makes each word match only where no letter, digit or _ is beside
it, and for a number no "." and digit either, so a decimal counts as one
value: ABC masks "ABC IS xxx" and name='ABC' but not XABCD or ABCDEF;
123456 masks a 123456 of its own but not 91234567, 0.123456 or 123456.78
("the code is 123456." still is). Chinese and Japanese letters count as
no letter there, since those scripts put no spaces between words: 张三
is still found in 我的同事张三今天来了, and ABC in 用ABC做. It is
independent of any case and works with it (xabc then Abc! masks only
Abc). A match inside a longer word is passed over one letter at a time,
so a whole one after it is still found. Off by default and for every
existing user: settings.json without redactWordsWhole reads false, and a
page from before it that saves without the field keeps what was set
(api.go, as redactWordsAnyCase). Each match goes as {{TERM_…}} and comes
back as written. Translated in zh, zh-TW, ja, de.

redact.Options.WordsWhole (wholeWord, wordRune); settings.RedactWordsWhole
(redactWordsWhole) reaches it through internal/masking; prefsKeep sends it
on every Settings save. docs/subsystems/gateway-routing.md has a bullet
for the user's own words, any case and whole words.

Tests, each red when its part is broken by hand:
- TestWordsWhole (internal/redact), the reporter's literal examples plus
  CJK and any case: with the whole-word check skipped, 10 cases FAIL
  "1 masked, want 0"; with the decimal check off, FAIL on 0.123456 and
  123456.78; with Han/kana counted as letters, FAIL on 张三, 用ABC做 and
  これはABCです. Every case round-trips through Restore.
- TestWordsWholeJSON: a request body and a tool call's escaped
  arguments; with the check skipped, FAIL "XABCD not kept as written".
- TestCountTokensRedacted/words_whole (internal/gateway): with
  masking.go not passing the setting, FAIL "redaction off changed
  content: …X{{TERM_…}}D…"; words_inside holds the default unchanged.
- TestSettingsRedactWordsWholeKept (internal/gui): with the not-sent
  guard removed, FAIL "…redactWordsAnyCase…: whole words false".
- redact-words-whole.test.cjs: 20 of 20 (Chromium and WebKit, en, zh,
  zh-TW, ja, de, 1100 and 640px); with prefsKeep's field removed,
  WebKit fails "a later save keeps it".

Run, in worktree magpie-wt/redact-wholeword at base 353519f55, sandbox HOME,
pinned caches, pipefail, tee'd:
- go test -tags nogui ./internal/redact ./internal/masking
  ./internal/settings ./internal/gui (TestCoreScriptBudget, i18n)
  ./internal/gateway ./plugins/redact: all ok.
- GUI: redact-words-whole, redact-words-any-case, i18n-keys 44/44;
  gui-zh-tw, gui-ja, gui-de 9/9.
- gofmt -l clean; go vet (darwin), GOOS=linux -tags nogui and
  GOOS=windows vet of the changed packages clean; go build,
  GOOS=linux go build -tags nogui, GOOS=windows go build ok.

Not run: the full go test ./... and the whole GUI suite (machine load
over 200 with other sessions' runs); the change reaches only the
packages above. Not tried: a real vendor request with the switch on;
the gateway test checks the body that goes out. A letter written as a
\u escape inside a tool call's arguments reads as no letter beside a
word (unescapedView), so it doesn't stop a match there.

Rebased onto origin/main 83368d994 (usage, signin, agent, gateway stream,
web page port, guard; app.js and gateway-routing.md touched elsewhere):
go test -tags nogui ./internal/redact ./internal/masking ./internal/gui
(budget, i18n) ok; redact-words-whole and i18n-keys 24/24.

Then onto 83368d994 (Codex thread descriptions; settings.go, app.js, i18n.js):
gofmt clean; go test ./internal/settings ./internal/masking ./internal/redact
and ./internal/gui -run 'Budget|I18n|Settings' ok.
2026-10-27 15:34:38 +08:00
yetone ea7c0067e0 privacy: each local model's confidence threshold is the user's to set
Yayoi_no_yume on X asked for the privacy model's threshold to be
adjustable: they read it as fixed at 0.5, and from their own use find
0.85-0.95 right for AstrLink. The 0.5 is Privacy Filter's (pf-serve's
argv default); AstrLink Guard already masked at its publisher's 0.8.

Both models now find at a floor of 0.5 (pii.Floor) and give each span
its score: Guard's least token probability (rounded through float32,
so a span read back from the cache file sits on the same side of a
threshold), pf-serve's own. masking.model keeps the spans at
pii.Threshold or over: settings.RedactModelScore[model] when it is in
[0.5, 1), else the model's MinScore (Privacy Filter 0.5, AstrLink
Guard 0.8). Settings -> Privacy shows a Confidence threshold row under
the model (app menu, 0.5 to 0.95 and Default), /api/privacy-model
takes do:"score". The setting is this computer's own, like the model.

The defaults stay. TestMaskEval's cases, rules + model + magpie's
checks, by threshold:

  Privacy Filter 0.5-0.8   masked 41/42  kept 112/113
  Privacy Filter 0.85-0.95 masked 40/42  (a Chinese name lost)
  AstrLink Guard 0.5-0.7   masked 42/42  kept 112/113
  AstrLink Guard 0.8-0.85  masked 41/42  (a phone in a tool result)
  AstrLink Guard 0.9       masked 40/42
  AstrLink Guard 0.95      masked 40/42  kept 113/113

The model alone does raise fewer false alarms higher up (Privacy
Filter's found-in-keep falls from 47 at 0.5 to 27 at 0.95, Guard's
from 8 to 2), but the checks after it drop most of those already, so
a higher threshold mostly costs values that should be masked.

Cache file: found-<model>.bin is now "pfound02" with a float32 score
per span. A "pfound01" file is still read, each span with score 1, so
texts cached before mask as they did and aren't asked again. For those
texts a higher threshold drops nothing and a lower one doesn't add a
Guard span scored 0.5-0.8 until the cache turns over (20000 answers).
merge() keeps the surer score of spans it joins. The eval recordings
(eval-model.json, eval-astrlink.json) were made again with scores,
from a scratch cache, the live found files untouched.

Run in the worktree at 11dcc743f + this change:
- go vet / gofmt -l on the touched packages: clean
- go test -count=1 -timeout 45m ./internal/pii/... ./internal/masking
  ./internal/redact ./internal/settings ./internal/gui ./internal/gateway: all ok (gateway 546s, rerun
  after an earlier run hit "no space left on device" on this machine;
  every failure in that run was a TempDir mkdir). This run caught
  TestSettingsSaveKeepsWhatItDoesNotSend wanting RedactModelScore set;
  it is now
- GUI: privacy-model.test.cjs 64/64 (chromium + webkit, 5 languages,
  1100 and 640px; the new threshold menu test among them),
  i18n-keys 4/4, redact-kinds, redact-rule-edit,
  redact-rule-row, redact-shape, redact-words-any-case all pass.
  masking-records 82/82, routing-masking 10/10, privacy-usage-stats 4/4,
  mask-actions 22/22. privacy-hides-accounts was 3/4 once (webkit en,
  page.goto's 5s at load ~290, the class of #3525, commented there),
  then 4/4 three times. Not run: the rest of the GUI suite.
Rebased on 508911e43 (which touched internal/pii fetch and mirror): at
that head, go build ./..., Linux and Windows go vet of pii, masking,
settings and redact, gofmt -l, and go test of pii/..., masking, redact,
settings and gui all ok; gateway not run again after the rebase.
Broken by hand: masking.model keeping every span (TestModelThreshold
  red); Threshold taking any value (TestModelThreshold red); the cache
  writing 1 for every score (TestRestartReadsWhatWasFound red); merge
  not keeping the surer score (TestMergeAcrossPieces red, after its
  joined span was made surer than the one it joins).
Not tried: the real app's window, Windows, Privacy Filter on a GPU
with the new score read (pf-serve itself is unchanged; it always sent
the score).
2026-10-27 14:10:33 +08:00
yetone 79c8667c92 gateway: Codex gives Claude its signed thinking back through encrypted_content
Codex calling a Claude model through magpie (mysterious_dove_96933 on
Discord): a reply's reasoning items carried only the summary, so Claude's
thinking signature and a redacted_thinking block's data were gone. On
the next request of a tool loop magpie sent Anthropic the turn as
[tool_use] alone, with thinking on, which Anthropic documents as a 400
("final assistant message must start with a thinking block"), and the
model lost its reasoning across calls either way.

Now the Anthropic decoders name a signature as Claude's (KSig with
sealAnthropic, Part.SignedBy). The Responses encoder and renderResponses
give each thinking block a reasoning item whose encrypted_content is
"magpie-claude1:" and the block's JSON in base64 (internal/claudeseal):
its summary beside it, an empty summary for a block signed with no
text, and redacted_thinking as an item of its own. parseResponses reads
it back into the block as Claude wrote it, in order, so anthropicBody
sends it as before for an Anthropic client. A Gemini thought's
signature isn't named and isn't sealed.

The envelope never reaches a Responses API: withoutClaudeSeals in
passthrough and forwardOnce (the item keeps its summary, one with none
goes), codexInputAs leaves such an item out for Codex's own models, and
codexUpstreamOn takes it out before the ChatGPT backend. OpenAI's own
encrypted_content is untouched. sessions.PortCodexRollouts writes such
an item as its summary, so a thread resumed against OpenAI itself isn't
refused. redact.MaskJSON already keeps a reasoning item's seal whole
(no change); TestMaskJSONKeepsClaudeBlocks holds that.

Run, at 5e3dd1d52 plus this change:
- go test -count=1 -timeout 45m ./internal/gateway/ ./internal/sessions/
  ./internal/redact/ ./internal/claudeseal/: sessions, redact,
  claudeseal ok; gateway ok but for TestResponsesStreamToolThenHiddenThinking
  (#1786), whose hidden cases wanted no reasoning item, the loss this
  fixes. They now want one item carrying the sealed block with an empty
  summary, and its guarantee (a whole stream, no panic) is unchanged;
  re-run green.
- gofmt -l clean; go vet (darwin) on the touched packages, GOOS=linux
  go vet -tags nogui ./internal/..., GOOS=windows go vet on the touched
  packages: clean.
- TestCodexToolLoopGivesClaudeItsThinkingBack (a fake Anthropic: signed
  thinking, redacted_thinking, a text-less signed block, tool_use; a
  Codex-shaped request with store false and the encrypted_content
  include; then the follow-up) fails on 5e3dd1d52: "stream=true:
  Anthropic was sent 1 assistant blocks, want 4". Passes now, streamed
  and not.
- Real: a sandbox HOME with only OpenRouter's key (Anthropic endpoint,
  anthropic/claude-opus-5.5, served by Claude Platform on AWS), magpie
  serve on its own port, a Codex-shaped two-turn tool loop at effort
  high, streamed and not: turn 1 gave a reasoning item with
  magpie-claude1: (3.1KB), turn 2 was 200 through /v1/responses →
  /v1/messages and answered from the tool output.

Broken by hand:
- withoutClaudeSeals a no-op: TestClaudeBlocksNeverGoToAResponsesAPI
  red, the relay sent magpie-claude1: items.
- codexInputAs not leaving them out: red, "ChatGPT backend would be
  sent …".
- sealing any signature (no sealAnthropic check):
  TestGeminiSignatureIsNotSealedAsClaudes red.
- portValue's reasoning branch off: TestPortLineDropsClaudeBlocks red.

Not tried: the 400 itself. Through OpenRouter, Opus 5.5 answered turn 2
with the envelope stripped too (the old shape), so this route shows
only the lost reasoning, not the refusal. Not tried on api.anthropic.com
directly, Bedrock or Vertex keys, or Claude's subscription (whose tool
loop stays inside Claude Code's run). Codex resuming a ported thread
against OpenAI with such items wasn't run.
2026-10-27 11:26:54 +08:00
yetone 89a9ded2cc redact: the masking eval scores each local model (#3578)
TestMaskEval runs once per model in pii.Models, each against its own
recording (testdata/eval-model.json for Privacy Filter, the new
eval-astrlink.json for AstrLink Guard, recorded through pii with the
publisher's files), and MAGPIE_EVAL_CACHE records every model found
there. A value known to come out wrong with AstrLink Guard says so in
GuardKnown: a token count taken for a secret (#3775) and a +81 phone
neither the rules nor it find (#3776).

Rules + model: Privacy Filter 41/42 masked, 1/113 wrongly; AstrLink
Guard 41/42, 1/113. Model alone: 40/42, 47/113 and 38/42, 3/113.

Run: go test ./internal/redact at the pushed head; removing either
GuardKnown makes it red.
2026-10-27 02:01:17 +08:00
yetone b3729b8d56 redact: a model's or a toolchain's name the local model takes for a secret goes as written
The owner's 脱敏 page showed groqAPIModel = "llama3-70b-8192" masked as
a secret by the local model. The real model, asked again, also takes
claude-3-5-sonnet-20241022 beside it for one. namesThing now holds
modelName: lower-case words joined by dashes with a size part (70b,
8x7b, 32k), an eight-digit date part (20241022) or a yyyy-mm-dd date
(nightly-2026-09-01). A diceware passphrase (correct-horse-battery-
staple) or maple-4-river-77 has neither and is still masked.

The page's other value, nightly-2026-09-01 as a name, was recorded by
the running v0.1.1370 (10-24). The model labels it private_person, and
main already drops it (a name with a digit, a word in lower case, since
611b9e173); the new rust-toolchain eval case holds that.

Run:
- MAGPIE_EVAL_CACHE=$HOME/.cache go test -run TestMaskEval ./internal/redact
  with the real model: re-recorded, both new cases ok in "both", the
  model's column WRONG for all three values.
- go test ./internal/redact ./internal/pii: ok. gofmt clean; go vet for
  darwin, linux and windows.
- Broken by hand: modelName taken out of namesThing → settings-model red
  (both values) and the four new TestModelMisreadsNotMasked cases. The
  digit check in personFits alone taken out stays green on
  rust-toolchain, since the lower-case-word check also drops it.

Not run: the packages that import redact (gateway and others) before
the push; the change only narrows what the model's secrets mask.
2026-10-26 22:16:02 +08:00