Commit Graph
31 Commits
Author SHA1 Message Date
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 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
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 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 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 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 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 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 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 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
yetone 720e491d2b redact: the local model's ids, decimals, model names and products in agent sessions go as written
A reporter on X (tearicerice, 10-26) had Claude Code check what the
local model masked and found "大概95%以上都是误判". Run over the last
120 turns of 22 real Claude Code sessions, rules-only against
rules-plus-model, the model alone found 69 distinct values, ~55 of them
wrongly. modelFits and modelTakes now leave these as written:

- PHONE: a decimal (a metric's 104.21875033916251, 23 such values) and
  a value starting with a letter ("run 48213097715").
- SECRET: a value right after an id's name (Claude Code's "with ID:
  kq3m8zx2t", "(ID: …)", <task-id>…, "backgroundTaskId":"…"); a
  lower-case slug with a slash (qwen/qwen3-14b); a lower-case file name
  (make-icons.sh); a grep regexp with \| or \b; words with a time of day
  in them (release about 17:05Z); a hex or digit run whose key cue is
  further back than "key:" / "token is" (GH_TOKEN in "env -u GH_TOKEN
  gh run view 48213097716" made the run id a secret).
- SECRET spans that took in a JSON key (ledgerId":"gl_…) start after
  the key's `":"`.
- madeID takes ids with more words and a nanoid's - and _
  (req_gateway_<hex>, tb_Ra4K…-ZqT2…), except under sk/rk/pk/whsec/
  shpat/shpss/xoxb/xoxp, whose keys have that shape.
- ADDRESS: an ASCII value with no space and a slash (a transcript's
  path). A Chinese address has no spaces and is unchanged; "3/12 Smith
  Street, Sydney" still masks.
- EMAIL: a value with no @ (eu.stg.acme.io, a host).
- PERSON, one word: an acronym (CI), a camel-case product with a
  capital after 3+ lower-case letters (CodeRabbit; McDonald, MacKenzie
  still mask), and a word the same text has as a host's name (Greptile
  beside app.greptile.com; not an address's local part, matt.lee@…).

Measured again on the same 22 sessions: 20 distinct model-only values,
12 of them real (people's names, the user's emails, an AWS account). The
8 left wrong are single dictionary or product words (Alma, Greptile
where no host is in the same text, Harness, Reds, Todo, Zhipu), 查询,
and an org id seen bare in a grep. The sessions' values were read in a
scratch test that isn't committed, and its logs are deleted; every
value in the tests and here is made up in the sessions' shapes.

Tests: 19 TestModelMisreadsNotMasked cases and 6 TestModelFindsStillMasked
cases (a Stripe-shaped sk_test_ key, a hex after "token is", McDonald,
Rina beside rina.lee@…, +1 415.555.0132, an address with a slash). 9
evaluation cases (metric-decimals, run-ids, background-tasks,
model-names, ls-files, gateway-ids, transcript-path, pr-checks,
team-notes), recorded with the real model.

Broken by hand, one at a time (each red): the decimal and leading-letter
phone checks, the path address check, regexpLike, idAfter and its camel
and > forms, the clock check, secretCued (back to cued), the slug and
file name checks, the JSON key trim, EMAIL needing an @, the acronym,
camel and hostIn name checks, madeID's longer ids and its keyHeads.
A decimal check for ACCOUNT was green when broken (versionRe already
covers it) and was dropped.

Run: go test -count=1 ./internal/redact ./internal/pii (ok),
MAGPIE_EVAL_CACHE TestMaskEval (re-recorded, ok). gofmt -l clean; go vet
./internal/redact for linux, windows and darwin. The packages that
import redact (gateway, gui, masking, otlp, sessions, settings) were
still running at push, beside another session's gateway run; not a
record of a pass.

Not tried: the reporter's own sessions, the WorkBuddy AI group/flash
traffic in their screenshot (~160 values a request), or their version.
Not looked at in the GUI's Masking page; the change is in what is
found, not in how it is shown.
2026-10-26 16:11:11 +08:00
yetone 552cdf8071 redact: a value the model spans from the delimiter before it is masked (#3591)
The model's span may start at the token before a value: the `":"` of
a JSON field, a CSV row's comma. A phone number in
{"phone":"+86 139 1234 5678"} came as `":"+86 139 1234 5678`, and in a
CSV row as `,+81 90-1234-5678`, which the PHONE check took for no
number, and it went as written. A name came as `"Wei Zhang"` and was
masked with its quotes, so the JSON lost them. modelSpans now trims
spaces and `"',;:` from both ends of a name's, a phone's, an
address's, an account's and an email's span; a secret's only spaces,
since a password may start or end with a quote.

Found by TestMaskEval: its 3 #3591 phones are no longer Known, and
"both" reads 33/34 masked, 0/40 wrongly (from 30/34).

Run: go test ./internal/redact and ./internal/pii ok; -run
'Mask|Redact|Privacy' ./internal/gui ./internal/gateway ok; go vet
darwin, linux, windows; gofmt -l clean.
Broken by hand: edge = isSpace for every kind: TestModelSpanLeavesDelimiters
red (both phones as written, the name's quotes gone) and TestMaskEval
red on the 3 phones.
Not tried: the full suite (internal/proc's #3567 is red on main), a
real request through the gateway with the model on.
2026-10-25 17:44:52 +08:00
yetone faa79ea2f5 redact: a Unix time the local model takes for a phone is not masked (#3577)
id.null (v0.1.1483) saw a tool result's "timestamp": 1792903687 go as
"timestamp": {{PHONE_c2ukh7gk}}. The PHONE rule needs eleven digits, so
the local model found it; v0.1.1457's check leaves a bare number alone
unless a cue is before it, but cues match inside words, and a log's
"tool_call" (or "telemetry") is "call" (or "tel").

A ten-digit time, or a thirteen-digit one in milliseconds, starting with
1 and nothing else, is now never a phone, cued or not: a North American
area code starts with 2 to 9, and a Chinese mobile is eleven digits.
The loose cues themselves are #3585.

Run: go test ./internal/redact ok; go vet darwin, linux, windows; gofmt
clean. Broken by hand: without the epochNumber check
TestModelPhoneKeepsUnixTime is red with the reporter's line masked.
Not tried: the real model on the reporter's whole tool result (their
screenshot only has the one line); the full Go suite.
2026-10-25 16:48:07 +08:00
yetone 641b1217f2 redact: a URL's user:password@host is a PASSWORD and a host, not one EMAIL (#3538)
With Mask personal data on, postgres://app:hunter2pass@db.acme-corp.cn:5432/x
went as app:{{EMAIL_…}}:5432/x: the EMAIL rule took hunter2pass@db.acme-corp.cn,
which starts where the PASSWORD rule's value does and is longer, so it won
the overlap. The kind was wrong and the host the model may need was hidden.

Now an EMAIL match whose start is inside a URL's authority (after
scheme:// with no /, ?, #, space, quote or @ between) is turned away
(notUserinfo, the rule's `at`), and the local model's EMAIL the same way
(modelFits). The password is the PASSWORD rule's and the host goes as
written. An address in a URL's path or query, in mailto: and in prose is
an EMAIL still.

Sibling found on the way: the PASSWORD rule asked for a user before the
colon, so redis://:pass@host (Redis has a password and no user) was not
masked with Mask secrets alone, and was only covered by the EMAIL accident
with personal data on. The user part may now be empty; without that the
email fix would have sent a Redis password as written.

Behaviour change to note: a userinfo with no password
(https://yetone@github.com/..., ssh://git@gitlab...) was an EMAIL and now
goes as written; it is a user name in a URL, not an address. With Mask
personal data on and Mask secrets off, a URL's password now goes as
written, as Mask secrets off says (it went as an EMAIL by accident).

#3029's file names (…@2x.jpg) are untouched: realEmail is unchanged and
TestFileNameIsNoEmail/TestMoreFileNamesAreNoEmail pass. #3365 (rule SECRETs
and known values) is a different rule; this changes nothing it reports.

Test: TestURLUserinfoIsNoEmail (internal/redact/userinfo_test.go) with the
report's literal string, mysql://, amqp://, mongodb+srv://, https://user:pass@,
redis://:pass@, a user with no password, ssh://git@, and emails in prose,
mailto:, a URL path, a query, and a query after a userinfo; a request via
MaskJSON; and the local model's EMAIL.

Broken by hand:
- redact.go and model.go reverted: red, 9 table cases plus the request and
  model checks (the literal went as postgres://app:{{EMAIL_…}}:5432/x).
- model.go alone reverted: red on the model check only.
- the PASSWORD regex's user back to +: red on both Redis cases (with
  personal on it went fully unmasked).

Run at this head (rebased on origin/main d153f0259):
- go test -count=1 ./internal/redact/... ./internal/masking/... ./plugins/redact/...: ok
- go test -count=1 ./internal/gateway/ -run 'Mask|Redact|Privacy|Masked': ok
- gofmt -l internal/redact internal/masking plugins/redact: empty
- GOOS=linux, windows, darwin go vet on the three packages: ok
Not run: the full suite (no suite lock on this machine; owner: don't hold
the push for it). Not tried in the GUI's Try it preview by hand; it calls
the same redact.Preview path the tests exercise.
2026-10-25 09:57:21 +08:00
yetone 611b9e1731 redact: what the local model misreads in agent requests is not masked
With "Use a local model" on, the model masked far more than the rules
did. Over 3 MB of real Claude Code requests (19,258 texts, the fields
MaskJSON leaves as sent skipped) the model alone masked about 1,800
pieces before this change, almost all wrong; the rules masked 17. It
took the turn's <total_tokens> count, run ids, commit hashes and
versions for accounts; Claude, Opus and other model names, a user name
inside a path and skill names for people; pieces of toolu_/srvtoolu_
ids, of base64 images, bare hashes, grep alternations, session file
names, links and Go module-cache names for secrets.

modelFits now judges each span the model reports against the text
around it: a span cut out of a longer word is no finding; a person's
name has no digits, path signs or lowercase words (bar van, de, bin and
the like) and no assistant's name; an account or phone number is
number-like and not a hash, version or size, and a bare run of digits
needs a cue before it ("account", "卡号", "phone", "手机"); a secret
starts with a letter or digit, is not a link, a UUID, a pattern of
words or a piece of a base64 run, and a bare hex run needs "key",
"token", "password" or 密钥/密码/令牌 before it. madeID takes prefixes
up to 8 letters (srvtoolu_).

After: the model masks 32 pieces on the same texts, 13 of them real
email addresses; what's left wrong is mostly a lone capitalised word
(Rerun, Relay, Xferd, Alma). On the synthetic set rules+model miss 1 of
20 secrets (rules alone 4) and flag 0 of 15 clean texts. The default
stays off.

Run at this head (rebased on 5d2260d3e):
- go test ./internal/redact: ok. TestModelMisreadsNotMasked holds the
  real bytes of 23 misreads, TestModelFindsStillMasked 9 real finds
  (an account with its cue, Rina Kowalczyk, Ludwig van Beethoven, a
  mobile and a London number, an address, a secret, a cued hex key,
  an email). With modelFits taken out of modelSpans by hand, 17 of the
  first 18 misreads went red.
- The corpus and synthetic measurement with the real privacy-filter
  q8 model (a scratch test, not committed; the corpus stays local).
- go vet (darwin, linux, windows) and gofmt on internal/redact: clean.
- Full suite (-timeout 45m, behind other sessions' runs): queued, not
  finished at push.

Not tried: the GUI, since nothing in it changed; a request through a
running gateway with the model on.
2026-10-25 06:05:06 +08:00
yetone d3db461bbb redact: the local model's secrets leave UUIDs, digests and paths, and client_metadata goes as written
The owner's masking records showed Codex's turn metadata with every id as
{{SECRET_…}}: installation_id, session_id, turn_id, window_id,
context_window_id, root_turn_id, and a skill's file path in the
instructions. The local model (OpenAI's Privacy Filter) labels a UUID a
secret: run on Codex's x-codex-turn-metadata it took each id, and on a
log it took a request id and "sha256 9b74…". The vendor and magpie's own
sessions match a turn by those ids, so masking them can break what
depends on them, and hides nothing worth hiding.

- modelTakes: a secret the model finds is not taken when it names a
  thing (namesThing): a UUID, with window_id's ":0" after it too; a
  digest with its algorithm's name; a file's path. A password or a key
  it finds is still masked, and the rules' secrets (sk-…, password=…,
  API_KEY: …) are unchanged.
- client_metadata is in defKeys: the client's ids, which no model
  reads, go as written, as tools and stream_options do.

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

TestModelSecretIsNoID uses what the real model labelled "secret" on these
texts (pf-serve with the q8 model, run here): the UUIDs, the request id,
the sha256 digest, plus the reporter's path; the password and the
32-hex key beside them are still masked. Broken by hand: without
namesThing 5 values are masked, without client_metadata in defKeys a
user word in it is.

Run:
- At 3fff6c011 (on origin/main e65688886): gofmt -l clean; go vet clean
  on macOS, GOOS=linux -tags nogui and GOOS=windows; go test ./...
  -timeout 100m: 66 packages ok, and internal/agent and internal/library
  printed PASS but were marked FAIL when the disk briefly filled ("can't
  write testlog.txt: no space left on device"); run again alone, both ok
  (993s, 596s).
- Rebased on origin/main 141470515 (its 12 commits touch agent, cli,
  gateway, gui, provider, sessions, settings, tui, not redact): at this
  head gofmt and vet three ways clean, go test ./internal/redact
  ./internal/gwmw ./plugins/redact ok. The rest runs on CI before the
  tag.
2026-10-21 19:13:49 +08:00
yetone b855cfee9e redact: a file named like an address (…@2x.jpg) is not masked as an email (#3029)
vdxz on Pi with personal data masked: /Users/…/Pictures/261020_14-16-11@2x.jpg
went to the model as /Users/…/Pictures/{{EMAIL_…}}, and Pi could no longer
read the file. A Mac saves an image at twice its size with @2x before its
extension, which the EMAIL rule reads as user@2x.jpg.

realEmail leaves an address whose last label is a file extension no
top-level domain has (fileExt: jpg, png, gif, webp, svg, heic, pdf and
the like; py, md, sh, zip and mov are domains and stay out of it). The
local model's EMAIL spans pass the same check now (modelTakes), so it
can't mask the name the rule leaves. An address beside the file's name
is still masked.

TestFileNameIsNoEmail uses the reporter's path. Broken by hand: with
redact.go as on main the rule's half fails, with model.go as on main the
model's half fails.

Run at this head (on the #3143/#3144 commit, origin/main ba319a758):
- gofmt -l clean; go vet clean on macOS, GOOS=linux -tags nogui and
  GOOS=windows.
- go test ./internal/redact ./internal/masking ./internal/gateway
  -timeout 100m: ok (gateway 2742s at load ~25).
- The commit below this one ran go test ./... -timeout 100m: 68
  packages ok; this one touches internal/redact and its doc only.
2026-10-21 17:20:42 +08:00
yetone 88119d4f67 redact: Codex's tool server names, stream_options and snake_case words go as written (#3143, #3144)
Two reports from hibaliqya-yonma (v0.1.1306, Codex Desktop through
/backend-api/codex), each a 400 on every request until masking was
turned down:

- #3143: a user's word that is part of an MCP server's name went into a
  Responses function_call's namespace as mcp__{{TERM_…}}. Codex checks a
  namespace against ^[a-zA-Z0-9_-]+$, and the call is replayed every
  turn. namespace is kept as name is, and so are the server's name in
  its siblings: a Responses mcp_call's server_label, Anthropic's
  mcp_tool_use server_name.
- #3144: the local model took stream_options.reasoning_summary_delivery,
  "sequential_cutoff", for a name. stream_options is a request setting
  now (defKeys, with reasoning and text), and the model's name is never
  a snake_case word (snakeWord), wherever it is, so an enum or an
  identifier in a tool's arguments or in code is not taken either.

The same word in the user's own message is still masked, and a name
beside it still is. docs/subsystems/gateway-routing.md says both.

Tests from the reporter's bodies: TestMaskJSONKeepsReasoningSummaryDelivery,
TestMaskJSONKeepsToolServerNames (namespace, server_label, server_name),
TestModelTakesNoSnakeWord. Broken by hand: with json.go and model.go as
on main, all three fail; with the change they pass.

Run at this head (origin/main ba319a758):
- gofmt -l clean; go vet clean on macOS, GOOS=linux -tags nogui and
  GOOS=windows.
- go test ./... -timeout 100m: 68 packages ok, exit 0.
- With #3029's commit stacked on it: go test ./internal/redact
  ./internal/gateway ok (gateway 2742s at load ~25), vet the three ways
  clean.
2026-10-21 17:20:37 +08:00
yetone f21dd99f5a privacy: every masking is recorded, and Settings › Privacy shows it
What was masked is now kept, so the user can see it. Settings › Privacy
opens on a summary card: how many values were kept from vendors over 1,
7 or 30 days, by kind, by finder (rules, your words, the local model,
known values) and by where they went, with a day strip. The page is
grouped into What to mask, How it's found (rules and the local model are
layers, not a toggle: the model adds names and addresses rules can't
see) and Sharing. A records view lists each masked request: its kinds,
finders, placeholders and, while magpie runs, the line around each
value. Gateway › Recent calls and the Routing log carry a masked-N badge
that opens the record.

Originals never go to disk. internal/maskrec writes day files under
~/.config/magpie/masking (0600, 30 days, 100MB at most) holding kinds,
finders, placeholders, a first character or key prefix and a length.
The lines around values are kept in memory for the last 400 records
only, and /api/masking/value answers only while the masker remembers a
placeholder. Nothing is written under MAGPIE_TEST_SANDBOX.

A masker says what it masked through gwmw.Teller (JSONHits, TextHits,
Value); a plugin masker that doesn't is counted only, so older redact
plugins keep working. Every route that masks notes it: chat, Responses,
Codex backend and search, embeddings, images, video, transcription,
decide and the search MCP query. Masking still fails closed: a masker
that panics on any path refuses the request (TestMaskingOnAndOff's fake
now panics on JSONHits and TextHits too, since the gateway asks a Teller
through those).

app.js grows to 1,314,432 bytes, so its budget rises to 1,335,000 and
the core's to 1,528,800 (+1.5%): Settings is the core's own page.

Run at this head (rebased on origin/main a3ebed202):
- go vet clean on macOS, GOOS=linux -tags nogui and GOOS=windows;
  go test ./internal/gateway ok (561s).
- On origin/main c922225f1 (one commit back, the packages either side
  touches): agent, gateway, gui, gwmw, maskrec, provider, redact ok.
- On origin/main 592899467: go test ./... -timeout 45m, 65 packages ok;
  agent and gateway hit the 45m timeout under load ~26 (each mid-way
  through a short test, not a hang) and pass alone with -timeout 100m
  (1133s, 890s).
- GUI, on 592899467, the 42 files this change or main's new commits reach (privacy-*,
  redact-*, masking-records, settings-*, gateway-*, routing-bodies,
  routing-request-metrics, routing-log-icons, account-discovery,
  click-scroll, i18n-keys, old-webkit), both engines, every language:
  475 tests, 475 pass. routing-bodies is green here since 2543fb2c1.

Run on the previous base, origin/main c84864ffc (the whole suites):
- go test ./... -timeout 45m: every package ok (66), exit 0. An earlier
  run found TestMaskingOnAndOff/panics (its fake, above) and
  TestCoreScriptBudget (the budget, above); both fixed.
- gofmt -l clean; go vet on macOS, GOOS=linux -tags nogui and
  GOOS=windows clean; node --check on the changed scripts.
- GUI suite, both engines, every language, --test-concurrency=6:
  11533 tests, 11483 pass, 50 fail. Each failing file rerun alone here
  and on origin/main:
  - red the same on main, filed: codex-predictions (#2624),
    usage-checkin (#2549), usage-agents-hide (#2276), usage-fold
    (#2163), s3-sync (#2448), quota-count-wrap and
    quota-name-translated (#2228), routing-request-metrics (#2571),
    routing-bodies (#2559: red at its "second request pressed" step;
    this change's badge checks before and after it pass),
    routing-rule-remove (#3096, filed now: 0 2 1 alone here, 0 0 2 on
    c84864ffc).
  - load, pass alone: group-member-weight (#2387), routing-model-rest,
    context-tune (Chromium didn't launch in 180s at load average ~45;
    0 0 0 alone on both). An earlier whole run's library-chip-fan red is
    #3072 (filed), plugin-card-update #3079, lightweight #2638,
    segs-glide #2683.
  - mine, fixed: old-webkit, three ":hover, :focus-visible" lists
    Safari before 15.4 drops; split, 6/6.
- Broken by hand, each went red: masked values kept on disk
  (TestNoValueOnDisk), a snip that runs past an escaped quote
  (TestSnipStaysInItsString), the shared-line dedup in the records view
  (masking-records, 10 of 12).
- Real app in a sandbox HOME with the local model on: the summary card,
  flow, chips and records view in light and dark; persons and
  addresses, Chinese names among them, recorded by=model; a grep of the
  masking folder and the sandbox config for the masked values found
  none.
2026-10-21 06:12:37 +08:00
yetone 3806014ac8 redact: Chinese personal names are masked, where the model misses or overreaches them (#1977)
OpenAI's Privacy Filter gives common Chinese names (张伟, 李娜, 陈建国,
黄晓明) almost no PERSON weight. Lowering the O label's emission by 2 or
4 in a patched pf-serve didn't bring them back. It also returns spans
that run past the name (「王芳,她下周一」, 「张伟先生」).

zhname.go adds a rule layer behind the model, only when personal data
is covered:
- a surname (single, compound, or 小/老 + surname) with a 1–2
  character given name is masked when something around it says it is
  a person:
  - a role before it (客户, 联系人:, 我叫, 作者:, @);
  - a verb before it (给, 告诉, 抄送) or after it (说, 反馈, 先生);
  - a title or 总 (孙经理, 邓总);
- a name joined by 和/与/跟/及/、 to a name already found counts too;
- words that start with a surname (张量, 高度, 王国, 周五, 总是) are
  never taken;
- the model's PERSON spans with Han in them are cut at punctuation or a
  title, and only when at least two characters remain.

Run:
- Real model, end to end through MaskJSON (pf-serve q8, Metal):
  - masked 张伟, 王芳 (cut), 李娜, 刘洋, 陈建国, 赵丽颖, 欧阳娜娜, 司马光,
    黄晓明, 周杰伦, 小王, 老李, 马云, 王老板, 邓总, 孙经理, 刘总监,
    吴敏, 郑浩, 何静, 唐宁, 许文强, 罗志祥, 林老师 and 郭靖;
  - Japanese, Korean and English names are unchanged.
- Missed, with nothing around them that says person: 「模块是谢磊写的」
  and 「和黄蓉团队」.
- False positives: none over 2237 lines of the repo's Chinese docs and
  i18n, or 61 developer sentences.
- Cost: ~19ms CPU over 880KB.
- Broken by hand:
  - with the layer off, TestChineseNames has 8 names unmasked;
  - with the two-character guard off before a title, 感谢李老师 goes red.
- Checks:
  - gofmt -l is clean;
  - go vet is clean on darwin, GOOS=linux -tags nogui and GOOS=windows.
- go test ./... -timeout 45m at load ~750: 63 packages ok, redact
  among them. internal/agent (TestReconnectKeepsTheLastPick) and
  internal/gateway (TestLargeRequestEndpoints) hit the 45m timeout with
  no failed assertion, and are being rerun alone.
2026-10-20 05:15:19 +08:00
yetone c0dad80da1 redact, pii: a local model finds what the masking rules can't (#1977)
WIP on pf/serve, recovered after the scratchpad holding it was wiped.
internal/pii downloads OpenAI's Privacy Filter (q8 GGUF, sha256 pinned)
and pf-serve, runs it on the GPU first, and answers redact's Model;
settings.RedactModel turns it on, per computer. Off by default.

Run: go vet and go test -race on internal/redact, pii, source,
settings (all ok). Not yet released: pf-serve's serveSHA is empty
until pf-v1 is tagged.
2026-10-18 23:12:41 +08:00