ac4af582301a4e8a29245dbba767eba31334ddf9
31
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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
|
||
|
|
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 |
||
|
|
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
|
||
|
|
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>
|
||
|
|
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. |
||
|
|
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) |
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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
|
||
|
|
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.
|
||
|
|
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.
|
||
|
|
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.
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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.
|
||
|
|
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. |