f2eb56c6bbde1300dddc402861b59cd4e45e0215
76
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e8d42c02db |
gateway: a masked request tells the model its placeholders are used as written (treeMan)
treeMan on Discord: with masking on, weaker models refuse to search
with a {{NAME_xxxxxxxx}} placeholder, ask to verify it, or rewrite it as
"an example name", which breaks long tasks. A request in which masking
swapped a value (maskHits.n > 0) now carries one short note, on each try:
Values written like {{NAME_ab12cd34}} are placeholders for real values.
Use them exactly as written, in replies and in tool calls alike: they
are filled in with the real values before anything runs. Don't ask to
verify them, and don't replace them with examples.
It names neither magpie nor a vendor or client (TestPlaceholderNoteIsNeutral
fails on magpie, Codex, Claude, a vendor's name, "provider", "gateway"...).
Its example uses a '1', outside the placeholder alphabet, so it is never
taken for a real placeholder or restored.
Where: where placeholders first appear, so it is new text the first time
and the same text on every later turn (the cached prefix holds). In the
instructions when they or the tools hold one (Anthropic system's last
block, Chat's first system/developer message, Gemini systemInstruction's
parts); otherwise on the earliest message that holds one, as a block or
part after its content (a string content becomes [text, note] blocks on
Anthropic, a paragraph on Chat), and on Responses as a developer message
after that item and the tool outputs following it. Responses
`instructions` (Codex's base_instructions) is never touched. A note
appended after text starts with a blank line, so a translator that joins
blocks (Anthropic to Chat) keeps it apart from the user's words.
Not added:
- a Claude subscription: the bridge puts the caller's instructions into
the run's first message, which Anthropic classifies; text added there is
risk for no gain;
- a ChatGPT/Codex sign-in (Account.Agent codex); Codex's own turns on
codexUpstreamOn don't pass this loop either;
- a Responses turn with previous_response_id: the note would pile up in
the stored conversation.
count_tokens counts without it.
A first version put the note in the system prompt. The full suite showed
TestMaskedConversationKeepsItsCachedPrefix red (a secret first found in a
tool output changed the system at turn 1 and rewrote the cache), hence
the first-appearance placement.
Run (mote, through mote-run):
- go test ./internal/gateway ./internal/redact -run
'TestPlaceholderNote|TestMaskedRequestTold|TestMaskedConversation|
TestUnredacted|TestRedacted|TestMask|TestMiddlewareThroughGateway': ok.
- Full suite at 46bdbad8f (-timeout 45m, log kept whole): red in
internal/gateway TestMiddlewareThroughGateway (mine: its fake echoes the
last message, which now holds the note; the fake strips it now), and
five tests red alone on origin/main
|
||
|
|
7632e1be1d |
redact: a text sent on a route goes on it as it went, the model's late finds too (vvrfxyz on X)
vvrfxyz on X: "脱敏功能是不是会降低缓存命中率 我开了脱敏后 dsh命中率暴跌".
Cause: the local model (AstrLink Guard, on by default) is waited for
2s a request (masking's defaultWait). A tool's output it hasn't read
by then goes with the rules' masking alone (pii.Partial). On the next
turn the model has read it, finds the names in it, and the same history
text now goes with {{PERSON_…}} in it. Everything from that message on
is a new prompt to the vendor, so its prefix cache misses.
|
||
|
|
95b40fb2f1 |
redact: a URL's password that is also its user, host or database goes as written (xuanwo on X)
xuanwo on X, 10-29: "我的很多项目名被识别成了 password,一天脱敏了 26M
次". The screenshot: a Codex summary where geodatafusion went as a
made-up word (bsssqojjdekwi) in every path, in rust/geodatafusion/,
geodatafusion.toml and cargo test -p geodatafusion; GEODATAFUSION in
capitals was left. Settings listed it under Passwords.
Cause, reproduced with the repo's own bytes: the geodatafusion repo's
PostGIS test (testing/postgis/README.md, rust/geodatafusion/tests/
postgis/README.md, .github/workflows/postgis-differential.yml) runs on
postgresql://geodatafusion:geodatafusion@127.0.0.1:55432/geodatafusion
The URL PASSWORD rule (user:password@) took the password. Once masked a
value is known (knownSpans) and is masked wherever it is written, case
as written, so the project's name went as a password in every request
for the rest of the run. Neither the local model nor b9f1fcddd's
words-only check is involved: this is a rule's find, which is known
whatever its look. Other projects set up the same way (name:name@)
each made their name known.
The rule: masking a URL's password hides nothing when the same URL has
it written as its user, a label of its host or a part of its path
(postgres:postgres@, root:root@, guest:guest@, app:shopdb@…/shopdb,
geo:geo@db/geo). hiddenInURL leaves such a password as written, so it
is never known. Whole parts only: geo:geod@…/geodb is masked. A
password not written elsewhere in its URL is masked as before, whatever
it looks like, there and as known everywhere after
(postgresql://geo:opensesame@…: opensesame is masked in a later path
too). This is scoped by where the value is in the URL, not by how it
looks: a URL in a tool call's arguments is judged the same way, and a
random password there (Tr0ub4dor3) is masked.
What the user gets: after updating (a restart forgets every known
value, the store is in memory) the project's name goes as written. The
user's ask, choosing what is masked without one exception at a time,
is already in Settings › Privacy: each kind (Passwords among them) has
Mask / Warn / Block, and Warn sends that kind as written while still
recording it; Never mask takes values. Yayoi_no_yume asked under the
same tweet for a switch per kind; that row is it. No new control is added: an Off
that records nothing would be a fourth state beside Warn with little
more to it.
The 26M: maskrec counts every place masked in every request's whole
body, and an agent resends its history each turn, so one known word in
a long Codex history was counted hundreds of times a turn. Filed as
#4193 (with the unmeasured CPU question of MaskJSON having no memo).
Tests: url_password_test.go.
TestURLPasswordWrittenElsewhereGoesAsWritten: the repo's README and
workflow lines, then the screenshot's summary text, then a Codex body
with the URL in exec_command's arguments and "cargo test -p
geodatafusion", each unchanged with 0 masked; postgres:postgres@,
root:root@, guest:guest@, app:shopdb@…/shopdb, redis://:cachebox@cachebox,
geo:geo@db/geo unchanged. TestURLPasswordStillMasked: hunter2pass,
geo:opensesame@…/geodata, geo:geod@…/geodb and redis's r3disPass
masked; Tr0ub4dor3 in a tool call's arguments masked; opensesame
masked again as known in a later path.
Broken by hand: the rule without hiddenInURL: red, both URL lines
masked, the summary 9 places masked as the screenshot shows
(/f745/<made-up>, rust/<made-up>/tests, -p <made-up>), the body 4, and
each of the six same-word URLs masked; green with it.
Run (mote, at
|
||
|
|
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
|
||
|
|
a5315c70d5 |
redact: the local model doesn't read an agent's tool definitions (niuniu_8964 on X)
码妞 on X: the official container on a 4-core, 8 GB server, AstrLink Guard on, Claude Code's requests sat at 脱敏中 for minutes and timed out, load 1.78, a short conversation. |
||
|
|
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
|
||
|
|
f02d92c7be |
redact: a file's lines, a path, a skill and a name in code after token: are no secret
Three reports on X (10-28), each a value the SECRET rule took (Insights >
Masking: 机密, 规则). The rule takes a name with token, secret, password
or api_key in it, then : or =, then 8 characters or more with a letter and
a digit. Prompts and code have that shape where nothing is secret:
- AlpsNowX: L643-669. was masked, in two requests. A file whose name has
one of those words, then :L643-669. (internal/auth/token.go:L643-669.)
read as a field token.go and its value, and once masked the lines went
as {{SECRET_…}} wherever they came again (by known). Now a name that is
a source file's (.go, .ts, .py, .md, .json …, not .txt/.env/.key) or a
path's last part is no field, and a line or range (L643, L643-669,
L12-L40, 643:12) is no value. Siblings: token.go:643-669 and #L643-L669
were never masked (no letter / no colon); file.go:L12-40 was, and isn't.
- binary4cat: function names masked. access_token = get_access_token_v2,
max_tokens=max_tokens_v3, secret: env.SECRET_V2, refreshToken2;,
fn(token=token_v2), secretKey:=base64Encode(raw) all masked the name.
A value written as code writes a name (lower-case start, or _ or .
between words) of two words or more, one of them token/secret/password/
key/credential, is a name now; a value starting with = is Go's :=.
- AkinoNya: folders and skills with a random string replaced. Found two
routes: a path after such a name (PRIVATE_KEY_PATH=~/.ssh/id_ed25519,
token_dir=/private/tmp/claude-501/x7k2p9q1-skill,
GOOGLE_APPLICATION_CREDENTIALS=/Users/…/legacy_credentials/x7k2p9q1/…,
私钥 ~/.ssh/…), and Claude Code's plugin:skill when the plugin's name
has one of the words (design-tokens:generate-v2, secret-scan:
audit-x7k2p9q1). A path from ~/, ./, ../ or a root folder (/Users,
/tmp, /private …) with no + or = goes as written, in the CJK key rules
too; slug:slug with no space is a skill. The ~1100 real folder and skill
names on this machine (~/.claude, ~/.codex, $TMPDIR, Claude's
claude-501 dirs) in five contexts masked nothing before or after, so
the reporter's exact names are not reproduced.
Still masked (TestSecretsBesideLinesAndNames): password=hunter2pass9,
API_KEY=AbC123dEf456GhI789, token=t0k3nValue2, Passw0rd123, password123,
SuperSecret2024 (PascalCase stays a password), token: Lk8x9QmP2vR4,
secret.txt:hunter2pass9, x-api-key:k9x2mp4qr7st1vw3 and :ab12cd34ef56,
Password=Abc12345; in a connection string, 密钥为12231241, 私钥 ab12…,
django-insecure-…; vendorchecks and the existing code tests unchanged.
Run (mote): go vet ./internal/redact for darwin, linux, windows; go test
-count=1 ./internal/redact ./internal/masking ./internal/pii/...
./internal/otlp ./internal/sessions ./internal/settings ./internal/gateway
at base
|
||
|
|
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
|
||
|
|
58fb3a7786 |
redact: 关键发现, 易触发 and 和边界 are words, not Chinese names
xuanwo on X: with the model on, a report's words were masked as names, 关键 in "### 关键发现", 易触 in "`gh pr view` 易触发" and 边界 in "判断和边界,". Each starts with a surname (关, 易, 边), and zhName took a cue around it that was too weak alone: - 发 and 打 after it counted as the verb a person does. They now count only when no Han character follows, or one of 了个给过一 (发了个消息, 打给他); 发现, 打开 begin a word. - 和 and 与 before it counted as "a person comes next". They join like to like, so they now count only when a pronoun or what may be a name (a surname and 1-3 characters, no zhWords word) is before them: 吴敏和郑浩, 我和张伟, not 判断和边界. - A sentence started after any space or symbol. A space after a word or code is inside a sentence, so the start is now after punctuation (with spaces after it or none) or at the text's start; a backtick no longer counts. The fixtures are the reporter's literal lines, beside names around the same cues that still mask (### 张伟发了个消息, 我和张伟,, 这件事。 李娜说过). Run (mote, mote-run): go test ./internal/redact (TestChineseNames, TestMaskEval and the rest) ok; gofmt clean. Broken by hand, each red on its own case: the 和/与 rule off (边界), wordAfter off (关键发现), sentenceStart always true (易触发). Running as this is pushed: vet (darwin, windows, linux) of internal/redact and go test of redact, masking, pii, otlp, sessions, settings, gui and gateway. Not tried: the real model on the reporter's whole session; a name that starts after a space following a Chinese word (这件事 李娜说过) is now left, as one inside a sentence. |
||
|
|
bad05e1b79 |
redact: sk- and a UUID in lower case is a key again
|
||
|
|
3e96197da3 |
redact: an address's words joined by hyphens are no sk- key (sk-hynix-…)
innerpeacebuild on X: search results naming articles about SK hynix,
cnbc.com/…/sk-hynix-third-quarter-profit.html and the like, went to the
model with each slug as {{API_KEY_…}}. The sk- rule took any 20
characters of letters, digits, - and _.
A key's characters are random, so it now needs a capital or a run of 16
or more with no hyphen. DeepSeek's sk- and 32 hex digits and
OpenRouter's sk-or-v1- and 64 are lower case and still masked.
Run on mote at this tree: go test ./internal/redact ok;
TestSlugIsNoKey (the reporter's four addresses beside four keys) is red
on the old rule (each slug masked) and green on the new. go vet for
darwin, linux and windows ok, gofmt clean. Not run: the full suite;
only internal/redact changed.
|
||
|
|
df8e9de3f1 |
redact: a masked word that is a date matches that date however it is written
JackyCcao on X turned birthday masking off (old dates in logs and tasks after a birthday's word were still taken) and put their own birthday in Masked words instead. A word matched only as typed, so 1990-05-12 let 1990/5/12, 1990.05.12, 1990年5月12日 and 19900512 go as written. A masked word that is all of a date (dateword.go: year-month-day with - / . 、 or a space, 年月日 or 년월일, a month's English name, or day/month/year where only one reading is a date) now matches that calendar date in each of those forms, with or without leading zeros, as eight digits, and day-first or month-first only where the day is over 12 or equals the month: for 1990-05-12 neither 05/12/1990 nor 12/05/1990, which reads as December 5th too. A word like 05/12/1990 is no date and matches only as written. Eight digits alone are not taken for a date word (as likely an id) and match as before. A date match never has a digit, or a dot and a digit, beside it, whatever Whole words only says, so 1990.5.12.1, 3.1990.5.12 and 11990-05-12 are no match; this is a change for a date word without Whole words, which matched inside such numbers before. The birthday rule is not changed. It takes a date only right after a birthday's word (生日, DOB, born...), so a log line's, a file name's or a task's own date is never one, however old. What is left (生日: 2019-03-02 in a task log about a party) has the same shape as a real date of birth, and a time beside the date doesn't tell them apart: a date of birth stored as a time (1990-05-11T16:00:00.000Z, midnight in UTC+8, as JavaScript writes it) is the commonest way one reaches an agent in JSON. TestBirthdayLogDates pins both sides; #3878 tracks fixed-shape false alarms. Tests: TestDateWordEveryForm (22 forms x 5 words x 6 contexts, each restored as written), TestDateWordDayMonthOrder, TestDateWordNotAnotherDate (another date, 1990.5.12.1, longer numbers), TestDateWordOnlyADate. Broken by hand: with the dateSpans hook in mask turned off, EveryForm, DayMonthOrder and NotAnotherDate fail; OnlyADate and BirthdayLogDates pin behaviour that was already right and pass on both. Docs: gateway-routing.md, masking.html en/zh/ja. Run on origin/main |
||
|
|
e7ba8a3892 |
redact: an email that ends a sentence is masked
The EMAIL rule's bound characters held "." on both sides, so an address followed by a full stop was no match: "The user's email address is jo@quill.dev." (Claude Code's own userEmail line) and "write to me at li.wei@qq.com." went to the vendor as written with the rules on. Found measuring the local model's threshold for Yayoi_no_yume on X: in 2000 segments of real Codex and Claude Code traffic, two real addresses were masked only because a model found them, at 0.70 and 0.95. emailAt now judges a dot beside the match: one before it still turns it away, and one after it only when a letter, digit, - or _ follows (a@b.io.12 stays unmasked, as before). The rest of the bound (letters, digits, _ % + -) is unchanged. TestEmailBeforeAFullStop: its five sentence-end cases fail on the old rule (5 of 5 unmasked), pass now; its two longer-name cases are unmasked on both. |
||
|
|
1cbdda25be |
redact: cua-driver's element tokens go as written (#3782)
Hu9956 (#3782): with masking on, DeepSeek Harness's computer use (cua-driver: a window's state, then a click on one of its elements) went to the vendor with element_token values as {{SECRET_...}}, found by the rules. cua-driver hands the model a token for each element of a window: s, the snapshot's counter in 8 hex digits, a colon and the element's index (s0000002a:14). The model clicks by it. The SECRET rule takes a value of 8 or more letters and digits after a field whose name holds "token", and element_token is one, so each token in a window's state, in a click's arguments and in a shell command's JSON went as a placeholder and its index ({{SECRET_...}}:74). Two of the report's places show the token with no index ("element_token": "s00000001"), so that is taken as it is written too. noIDs, which lets a backend's id (a UUID, 32 hex digits or more) go as written unless its field is named for a credential, now takes an element token for one too (elementToken): s and 8 lowercase hex digits, then a colon and the index, with no letter, digit or _ on either side. Without the index, s and 8 hex digits is one only as the value of a field named for an element: alone in a text it may be a student's number (s12345678), which the local model may call an account. A field named for an element is no credential's, as one named for a page, a cursor or a request isn't (credentialField, whose field name reading is now fieldWords). So element_token's value goes as written, while the same value after password=, token:, "refresh_token": or "api_key": is masked, and so is a value of any other shape in element_token. A token the local model takes for a secret, or anything else, goes as written, as a UUID does. The user's own words still mask one. docs/subsystems/gateway-routing.md says so. A UUID in a field named for an element (element_token) goes as written now too, as one in next_page_token does. What was run (tree bb52fa4d, on origin/main |
||
|
|
7aeae59670 |
privacy: masked words can match as whole words only, by a switch under Masked words (acmilan_)
Settings › Privacy's masked words (脱敏词) were found anywhere: ABC masked
the ABC inside XABCD, and 123456 the middle of 91234567 or 0.123456. A
new row under "Masked words in any case", "Whole words only" (仅完整单词
匹配), makes each word match only where no letter, digit or _ is beside
it, and for a number no "." and digit either, so a decimal counts as one
value: ABC masks "ABC IS xxx" and name='ABC' but not XABCD or ABCDEF;
123456 masks a 123456 of its own but not 91234567, 0.123456 or 123456.78
("the code is 123456." still is). Chinese and Japanese letters count as
no letter there, since those scripts put no spaces between words: 张三
is still found in 我的同事张三今天来了, and ABC in 用ABC做. It is
independent of any case and works with it (xabc then Abc! masks only
Abc). A match inside a longer word is passed over one letter at a time,
so a whole one after it is still found. Off by default and for every
existing user: settings.json without redactWordsWhole reads false, and a
page from before it that saves without the field keeps what was set
(api.go, as redactWordsAnyCase). Each match goes as {{TERM_…}} and comes
back as written. Translated in zh, zh-TW, ja, de.
redact.Options.WordsWhole (wholeWord, wordRune); settings.RedactWordsWhole
(redactWordsWhole) reaches it through internal/masking; prefsKeep sends it
on every Settings save. docs/subsystems/gateway-routing.md has a bullet
for the user's own words, any case and whole words.
Tests, each red when its part is broken by hand:
- TestWordsWhole (internal/redact), the reporter's literal examples plus
CJK and any case: with the whole-word check skipped, 10 cases FAIL
"1 masked, want 0"; with the decimal check off, FAIL on 0.123456 and
123456.78; with Han/kana counted as letters, FAIL on 张三, 用ABC做 and
これはABCです. Every case round-trips through Restore.
- TestWordsWholeJSON: a request body and a tool call's escaped
arguments; with the check skipped, FAIL "XABCD not kept as written".
- TestCountTokensRedacted/words_whole (internal/gateway): with
masking.go not passing the setting, FAIL "redaction off changed
content: …X{{TERM_…}}D…"; words_inside holds the default unchanged.
- TestSettingsRedactWordsWholeKept (internal/gui): with the not-sent
guard removed, FAIL "…redactWordsAnyCase…: whole words false".
- redact-words-whole.test.cjs: 20 of 20 (Chromium and WebKit, en, zh,
zh-TW, ja, de, 1100 and 640px); with prefsKeep's field removed,
WebKit fails "a later save keeps it".
Run, in worktree magpie-wt/redact-wholeword at base
|
||
|
|
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 |
||
|
|
79c8667c92 |
gateway: Codex gives Claude its signed thinking back through encrypted_content
Codex calling a Claude model through magpie (mysterious_dove_96933 on
Discord): a reply's reasoning items carried only the summary, so Claude's
thinking signature and a redacted_thinking block's data were gone. On
the next request of a tool loop magpie sent Anthropic the turn as
[tool_use] alone, with thinking on, which Anthropic documents as a 400
("final assistant message must start with a thinking block"), and the
model lost its reasoning across calls either way.
Now the Anthropic decoders name a signature as Claude's (KSig with
sealAnthropic, Part.SignedBy). The Responses encoder and renderResponses
give each thinking block a reasoning item whose encrypted_content is
"magpie-claude1:" and the block's JSON in base64 (internal/claudeseal):
its summary beside it, an empty summary for a block signed with no
text, and redacted_thinking as an item of its own. parseResponses reads
it back into the block as Claude wrote it, in order, so anthropicBody
sends it as before for an Anthropic client. A Gemini thought's
signature isn't named and isn't sealed.
The envelope never reaches a Responses API: withoutClaudeSeals in
passthrough and forwardOnce (the item keeps its summary, one with none
goes), codexInputAs leaves such an item out for Codex's own models, and
codexUpstreamOn takes it out before the ChatGPT backend. OpenAI's own
encrypted_content is untouched. sessions.PortCodexRollouts writes such
an item as its summary, so a thread resumed against OpenAI itself isn't
refused. redact.MaskJSON already keeps a reasoning item's seal whole
(no change); TestMaskJSONKeepsClaudeBlocks holds that.
Run, at
|
||
|
|
89a9ded2cc |
redact: the masking eval scores each local model (#3578)
TestMaskEval runs once per model in pii.Models, each against its own recording (testdata/eval-model.json for Privacy Filter, the new eval-astrlink.json for AstrLink Guard, recorded through pii with the publisher's files), and MAGPIE_EVAL_CACHE records every model found there. A value known to come out wrong with AstrLink Guard says so in GuardKnown: a token count taken for a secret (#3775) and a +81 phone neither the rules nor it find (#3776). Rules + model: Privacy Filter 41/42 masked, 1/113 wrongly; AstrLink Guard 41/42, 1/113. Model alone: 40/42, 47/113 and 38/42, 3/113. Run: go test ./internal/redact at the pushed head; removing either GuardKnown makes it red. |
||
|
|
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.
|
||
|
|
25341b4ca5 |
redact: an address needs a mail domain (xxx@Agents.md, x@pytest.fixture)
ydzh on Discord: masking took xxx@Agents.md and xxx@pytest.xxx for email addresses. realEmail now also refuses a host that is a known agent doc file (agents.md, claude.md, readme.md, ...) or whose last label is not an ICANN TLD (publicsuffix) nor a local mail suffix (local, internal, lan, corp, home, intranet, localdomain). So decorator and module paths like pytest.fixture or dataclasses.dataclass go as written, while me@notes.md, j@Gmail.COM, admin@build.local and ops@mail.corp are still masked. Run: go test ./internal/redact (all, evals included) ok; go test ./internal/gateway -run 'Redact|Mask|Email|Privacy' ok; gofmt -l clean; GOOS=linux and windows go vet ./internal/redact ok. Broken by hand: with the new checks removed, TestEmailNeedsAMailDomain fails 10 cases. Not tried: the real app; full suite (other sessions' suites on the machine). |
||
|
|
dce7fe6096 |
redact: git@host, a git remote's SSH user, is not masked as an email (jumy on Discord)
jumy: "脱敏的邮箱, 会把git地址也算进去, 比如 git@xxxx". The EMAIL rule took git@github.com out of git@github.com:o/r.git, so a remote reached the model as {{EMAIL_…}}:o/r.git. git is the user every git host is reached by over SSH (GitHub, GitLab, Gitee, a company's own), no one's mailbox. realEmail, which the rule and the local model's EMAIL both ask, now says no to a local part of git, any case. userhost already left git out (notUsers). An address whose name only starts with git (gitte@, git.lee@, github@) is still masked. Run: - TestGitRemoteIsNoEmail: 7 failures with the check pointed at another name by hand, green with it. - go test ./internal/redact (whole package, ok), the gateway's Redact/Mask/Email/PII tests, gofmt -l. |
||
|
|
c2c88e85e9 |
redact: a date in the last year or ahead is not a birthday
JackyCcao on X: under Mask personal data the birthday rule took the day
the agent ran on, 2026-10-24, for a birthday in 122 requests. dateOK now
takes a date after 生日/DOB/born for a birthday only when it is over a
year before today (dateClock, held in the test). A date in the last year
or ahead is a run date, a deadline or a log's; a baby's birthday in a
prompt is far rarer than those. Older dates are masked as before.
Run: go test ./internal/redact (also TZ=UTC and TZ=Pacific/Kiritimati),
go vet for darwin, linux and windows, gofmt -l. TestBirthdayNotRecent
holds today at 2026-10-24 (today, yesterday, a year less a day, ahead,
each format) and then reads the real clock; with the year check taken
out by hand it is red ("生日:2026-10-27" masked). The GUI's
redact-kinds test only toggles the category and is unchanged.
Docs: gateway-routing.md and masking.html (en, zh, ja).
Not tried: the reporter's own request text (the screenshot shows only
the masked date), so which words were before it is not known.
|
||
|
|
db6d1540ef |
redact: eval cases that reach more of modelTakes/modelFits
TestMaskEval's cases reached 5 of the 36 checks on model spans: breaking any other one by hand left it green. This adds 21 cases (39 to 60), most of them texts from modelfits_test.go and vendorchecks_test.go, the places the model was seen misreading, and records the real model's spans on them (testdata/eval-model.json). Breaking each check by hand (breaks.py: one replacement in model.go, TestMaskEval run, file restored) now turns 13 red (5 before): secret-madeID, person-2runes, email-realEmail, person-zhTrim, person-assistant, account-numberLike, account-cue, address-letter, secret-wordstart, secret-uuid, secret-hexwords, secret-hexcue, edge-delimiter. Still green, because the real model gives no such span on any text tried (24 more probed) or another check catches the same span first: secret-namesThing, secret-len8, person-snakeWord, account-madeID, cut-from-word, person-chars, person-filedot, person-pathpart, person-colon, person-lowerword (person-chars keeps the same lower-case word), account-hex, account-version, the four phone checks, secret-pattern, secret-json, secret-link, secret-base64, email-wordstart, email-modcache, email-userinfo. Their unit tests in modelfits_test.go still cover them with recorded spans. A new real miss: "hex40 ok? 1 <sha1>" is one secret span "1 <sha1>" to the model, and the hex-words check only looks at the first field. Filed as #3597 and marked Known. Totals at this head (rules / model / both, masked and wrongly): 16/40 0/89, 38/40 28/89, 39/40 1/89. Run: MAGPIE_EVAL_CACHE=$HOME/.cache go test -run TestMaskEval -v ./internal/redact (recorded, then replayed green); go test -count=1 ./internal/redact ./internal/pii ok; go vet ./internal/redact for darwin, linux and windows; gofmt -l clean; breaks.py over all 36 checks. Not tried: the full suite (only test files changed in internal/redact). |
||
|
|
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.
|
||
|
|
033990e642 |
redact: the masking evaluation starts with nothing known
A value Mask masks is known from then on, and masked wherever it is again (known.go), Preview's too. TestMaskEval ran after the tests that masked hunter2pass, rina.k@fastmail.com and the like, so in the package's full run what they masked was masked in its cases too, and the rules' column was not the rules': with one test before it that masked the eval's phones, rules read 19/34 for 16/34. Forget (export_test.go) lets every value go before the cases. 180cfb565's body says 38 cases; there are 39. Run: go test ./internal/redact (TestMaskEval in the full run and alone: 16/34 rules either way) and ./internal/pii ok; go vet darwin, linux, windows; gofmt -l clean. Broken by hand: without Forget and with a test before it that masks the eval's phones, rules read 19/34. |
||
|
|
180cfb565e |
redact: an evaluation of the masking, with the rules, the model and both
TestMaskEval scores 38 made-up texts of the kinds agents send (prose, code, logs, tool results, JSON, CSV, Chinese) with 34 values to mask and 40 to keep. The cases start from what users reported masked wrongly (#3144, #3143, #3029, #3538, #3577, |
||
|
|
e4809a150a |
redact: a key of digits only after 密钥为, token 是, apikey:… is masked; PIN码, 安全码, 授权码 join the names (CyberCaius on Discord)
"密钥为12231241" in Settings → Masking's 试一试 came back "这里没有需要脱敏的
内容". ee715c2e0's key rules (a CJK name for a key or token, or an English
one before 为/為/是/:) asked for letters in the value, so that
"RSA 密钥为 2048 位" stays; an all-digit key went as written. 密码/口令 took
digits already (
|
||
|
|
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.
|
||
|
|
fc91e58ba4 |
redact: a bare JSON number ("timestamp": 17929036837) is not masked as a phone (id.null on Discord)
The 脱敏 before/after view showed a tool result holding a session file's
JSONL line, and its "timestamp": 17929036837 went as {{PHONE_…}}. The
PHONE rule is 1[3-9]\d{9} bounded by digits, so any 11-digit number
starting 13-19 is a CN mobile wherever it sits. A phone, a card or an ID
number in JSON is a string; a bare number there is a count, an id or a
time.
Now a personal kind's value that is all of a bare JSON number is left,
judged by where it sits and its form, not by the key's name: digits only,
after "key": (an object's value) or inside an array of numbers, with only
, } ] or the text's end after it. It sits beside the decimal check
(noDecimals, now noNumbers), so it holds for what the rules, the model
and values known before find alike. A BANK_CARD (Luhn-valid snowflake)
and an ID_CARD's digits as JSON numbers are left the same way.
Still masked (tested): "phone": "13800138000", ["13800138000"],
phone:13800138000, "call 13800138000, thanks", 我的号码 13800138000,谢谢,
"numbers 13900139000, 13800138000]" (no [ before), a phone inside a JSON
string's text, "card": "4111111111111111", and every case of
TestStandaloneNumbersStillMasked. "phone": 13800138000 as a number is
left too; that is the cost of not going by the key's name.
Run at this head:
- go test ./internal/redact ./internal/pii ./internal/settings
./internal/masking ./internal/otlp ./internal/sessions ./internal/gui
-count=1: ok
- go test ./internal/gateway -run 'CJK|Mask|Redact|Privacy|PII|Secret': ok
- gofmt -l, go vet, GOOS=windows go vet, GOOS=linux go vet -tags nogui
./internal/redact: clean
- Broken by hand: with origin/main's redact.go, TestBareJSONNumberNotMasked
fails 7 cases (the reporter's line, {"n": 13800138000}, a spread-out
object, two arrays, the card and the ID number). The 10- and 13-digit
epochs were not masked before either; they are in the test to stay so.
Not tried: the GUI before/after view in a running magpie, and the full suite.
|
||
|
|
359da679db |
redact: 试一试 shows the made-up key when "keep key form" is on, short keys and named keys too
A user turned on 保留密钥格式 (v0.1.1497) and 试一试 still showed
{{SECRET_…}} for "用密钥 sk_abcdefg 部署可以吗". Three gaps:
- Preview wrote every value with tag, which never looked at Shape: a
sibling v0.1.1497 missed. It now makes the same key shapeOf gives a
real request, without storing it.
- shapeOf made up nothing under 16 characters, so sk_abcdefg stayed a
placeholder even on a real request. Now 8 or more, with at least 6
characters made up after the prefix.
- 密钥 OPENAI_API_KEY=sk_… is found with its name (the CJK key rule
takes NAME=value as the value), and '=' isn't a key character, so it
fell back to a placeholder. The name now stays as written and only
the key after it is made up and remembered, so a reply naming the key
alone is put back too.
Run: go test ./internal/redact ./internal/settings, -tags nogui
./internal/gui, ./internal/gateway -run 'Redact|Mask|Shape|Privacy' all
ok; go vet darwin, linux and windows (nogui); gofmt clean.
Broken by hand: Preview back to tag, minShape 16, the minRandom check
removed and splitName turned off each turn TestShapeShortAndPreview,
TestShapeKeepsAName or TestMaskingPreviewKeepsKeyForm red; storing the
whole NAME=value turns TestShapeKeepsAName's Restore red.
Not tried: the GUI suite (no front-end change) and a real model's reply
naming the made-up key; the full Go suite.
|
||
|
|
bea9f905d0 |
redact: a key can go as a made-up key of its own form, not a placeholder (Charles Cao on X)
Charles Cao on X (2114238140835844575) asked for a format-preserving
swap: sk_w3axCByTQgK1PxqPhfKTrJOLBqz6sbZv sent as another sk_ key of the
same shape and put back on the way home. With Mask secrets on, a key went
as {{API_KEY_xxxxxxxx}}, which a tool's check of the key's form fails
and a model may remark on.
Settings › Privacy has "Keep a key's form" under Mask secrets (shown only
while secrets are masked; off by default, so nothing changes for anyone
who doesn't turn it on). settings.RedactShape → redact.Options.Shape;
api.go keeps it when a page from before doesn't send it.
How (internal/redact/shape.go):
- Only a secret's kind, 16+ characters, all of [A-Za-z0-9-_.]. Personal
data, the user's words and anything else still go as placeholders. A
made-up key needs no JSON escaping.
- Prefix kept (sk-proj-, sk-ant-api03-, github_pat_, AKIA/ASIA, or up to
4 letters plus - or _), same length, separators in place, and each
other character a random one of the same class. A hex key stays hex
of its case. Random from HMAC(placeholder key, kind+value), so it is
the same every turn and a vendor's prompt cache still matches.
- Kept in values like a placeholder (makeRoom shared with placeholder),
so masking records, Value(), signed-thinking re-masking (the put
closure) and known-value re-masking work unchanged; kindOf reads it.
- restore() puts made-up keys back first, then placeholders.
RestoreJSON no longer returns early when one is in the body;
hasShapes copies nothing while none was made.
- A stream holds an event's end that may start a made-up key
(partialTail → shapeTail), but never one inside a key that has come
whole: a key ending in "s" is also the start of every sk_ key, and
without that its end was held and the key went out unrestored (found
as 1 in ~40 fresh processes; 0 of 150 after).
- apply() leaves a made-up key that came back unrestored alone
(outsideShapes), as it does a placeholder.
Tests: shape_test.go — form kept (the reporter's key, hex, ghp_,
sk-proj-), same fake twice, Restore; off is placeholders; email/short/
odd values not shaped; MaskJSON then RestoreJSON with escaped tool
args; signed thinking re-masked to the same fake; no re-mask of a fake;
a stream split mid-key, after one character, and a key ending as one
starts. GUI: redact-shape.test.cjs (both engines, 5 languages, 1100 and
640px; row under Mask secrets, Off by default, one save with the rest
kept, no scroll, a later save keeps it; no row while secrets are off).
redact-words-any-case now finds Mask personal data by place after the
new row, not by index.
Broken by hand, each red: no restoreShapes (KeepsForm, JSON, Stream),
no shapeTail (Stream), no outsideShapes (JSON), no hasShapes (JSON),
put ignoring Shape (all three), shapeTail without the whole-key bound
(Stream).
Budgets: app.js 1,321,994 → 1,322,289 and the core 1,529,542 →
1,529,837, the row's 295 bytes, Settings' own row, no room added.
Doc: docs/subsystems/gateway-routing.md, a bullet beside the other
masking options.
Run at
|
||
|
|
ee715c2e0e |
redact: a key or token after 密钥, 令牌, 金鑰…, or apikey/token before 为/是/:, is masked (CyberCaius on Discord)
|
||
|
|
714ab8e8bf |
redact: a password after 密码, 密碼, 口令, パスワード or 비밀번호 is masked (CyberCaius on Discord)
"密码:786kih" in Settings → Masking's try box came back "nothing to mask", and so
went to the vendor as written. The password rules only knew English field names
(password = …, as configs have them) and asked for 8+ characters of letters and
digits both, since code calls many things a password. Nothing in code is called
密码, so after a CJK name for a password any value of 4 or more is taken, digits
only too, after :, :, =, 是, は or 는, quoted or not. A sentence's closing stop
stays outside the value.
Left as they were: "请输入密码:", 密码:${DB_PASS}, 密码:****, 忘记密码了怎么办,
修改密码功能, and a value of 3 (密码:abc). English "password: abc12" with a short
value is unchanged; issue filed for it.
Run at this head:
- go test ./internal/redact ./internal/masking ./internal/otlp ./internal/pii
./internal/settings ./internal/sessions -count=1: ok (every package that
imports redact but gateway and gui)
- go test ./internal/gateway -run 'CJK|Mask|Redact|Privacy': ok
- gofmt -l, go vet ./internal/redact: clean
- Broken by hand: with origin/main's redact.go, TestCJKPasswordMasked fails 7
of 7 masked cases; green with the rule.
Not tried: the GUI try box in a running magpie, and the full 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
|
||
|
|
511c4a765e |
redact: code naming a secret (secretKey: Uint8Array, toBase64Url(…)) is not masked as one
Kieran Zhang on X (10-25) showed TypeScript masked as secrets:
`secretKey: Uint8Array;`, `details.2`, `toBase64Url(...)`. The SECRET
rules took any letters-and-digits value after a secret's name, and an
identifier like Uint8Array or a call like toBase64Url has both.
Both SECRET rules (the named-secret one and the bare "key" one) now ask
notCode: a value that is an identifier path (a.b.c) is code, not a
secret, when a "(" follows it (a call), or when it sits unquoted after a
":" and code punctuation (; , ) } ] | ? & < >) or the end follows (a
type or an object member). A quoted value, an `=` assignment, or a YAML
style `password: Passw0rd123` line is masked as before.
Run at this head:
- internal/redact TestCodeIsNoSecret: the reporter's four literal lines,
a union type, an object member and a spaced call go as written; seven
real secrets (quoted, escaped JSON, env, YAML, query-like) still mask.
Red on the old code (6 of them masked), green after.
- go test -timeout 45m ./internal/gateway ./internal/gui ./internal/otlp
./internal/pii ./internal/redact ./internal/sessions ./internal/settings:
all ok except internal/gui TestMainWindowCorners, an AppKit window
killed at its 40s deadline at load ~146; it is red alone too, filed as
#1936 and #2645, and this change doesn't reach it.
- go vet on darwin, linux and windows; gofmt -l clean.
Not tried: the reporter's own file in a live session; an unquoted
`apiKey: SomeIdent,` in YAML now goes as written, which reads as code.
|
||
|
|
2dfaf75539 |
redact: a masked body is held at its size, not in a buffer grown by doubling (#3383)
With masking on, the masked body is what a request holds while it
streams (MaskJSON, 285 MB live in the report's heap). walk built it in a
bytes.Buffer grown by doubling, up to twice the body. It now makes room
for the body and a sixteenth at the first value it masks, and copies the
result to its size when placeholders grew it past an eighth spare.
Run:
- the heap probe, 8 requests of 9.7 MB held mid-stream with Privacy
masking on: 138 MB before, 86 MB after (Anthropic to Anthropic);
translated to Chat 235 MB before, 183 MB after.
- TestMaskedBodyHeldAtItsSize: green; red with both changes off
("the masked body of 4356589 bytes is held in 7077888").
- go test ./internal/redact/ ./internal/masking/ ok; gateway -run
'Mask|Redact|…' ok (see the commit before).
|
||
|
|
9b57261b62 |
masking: a record keeps its request as sent, how long masking took and what the answer put back
For the 观测 › 脱敏 page's request view. In memory only: the masked body of the latest 100 requests (each up to 4MB, 64MB in all), and by placeholder how many places of the answer had the value put back (redact.Writer.Put, counted once per place even when a stream splits the placeholder). Took (µs) is written to disk too; it holds nothing of the request. GET /api/masking/sent?key= gives the body, POST /api/masking/values the values the masker still remembers, both no-store. Run: go test ./internal/maskrec ./internal/redact ./internal/gui -run TestMaskingRecordsAPI and ./internal/gateway -run TestMasked; ok. Broken by hand: without toldBack, TestMaskedRecordKeepsSentAndBack is red. |
||
|
|
50f52b540b |
redact: a text masked for a vendor before is masked as it was then, so a cached prompt stays cached
With Privacy masking on, a value masked once is "known" and masked
wherever a later request has it (redact/known.go). When a rule first
finds a value in a later turn (a tool printing DB_PASSWORD=...), that
value was masked from then on in the system prompt and the turns already
sent with it as written. The prefix the vendor had cached changed, so
the whole prompt was written to the cache again and none of it was read.
Reported by audie on Discord: DeepSeek Harness on a routing group served
by a custom Anthropic-compatible provider. Adjacent turns 10s apart had
cache_read 0 and cache_write 412K to 427K.
Fix: Mask and MaskJSON (the vendor-bound paths, via masking.Masker) now
use sentKnownSpans. A text masked before gets the known values it had
the first time, keyed by a sha256 of the text and the options. Only
hashes and spans are kept, never a value, in two generations of 65536.
New text still gets every known value masked. Scrub (archives, sessions,
OTel; local only) keeps the latest known set.
Unchanged: if magpie restarts, or a text falls out of both generations,
the text is masked under the current known set once, as before.
What was run:
- internal/redact TestSentTextKeepsItsMasking and internal/gateway
TestMaskedConversationKeepsItsCachedPrefix. The gateway test sends a
dsh-shaped Chat Completions conversation to a group with an Anthropic
member, and a Claude Code-shaped /v1/messages one. It checks that each
turn's system, tools and earlier messages reach the fake upstream byte
for byte. Both tests are red with sentKnownSpans forced back to
knownSpans: the system prompt became "{{SECRET_...}}" on turn 3. Both
are green with the fix.
- With masking off, a probe of the same dsh shape had the system, tools
and earlier turns byte-identical on every turn.
- gofmt -l: clean. go vet: darwin, GOOS=linux -tags nogui ./...,
GOOS=windows ./...: clean.
- Full suite at 8187919d7 (this tree, on origin/main
|
||
|
|
243594410d |
redact: a tool call's arguments stay JSON when a value follows an escape (#3022)
A history tool call's function.arguments is JSON text inside a string.
MaskJSON masked it as plain text, so the n of a \n started a match:
"\n@mcp.tool()" became "\{{EMAIL_…}}()", the arguments were no longer
JSON, and Ollama Cloud refused every turn that replayed the call with
400 "invalid tool call arguments". Reported by xiaobaifly7 and reproduced
independently by Shane-Meng (\n\n\n@pytest.mark…).
Where a string holds JSON text (asJSON), mask now reads it the way the
vendor reads it once it is unescaped:
- unescapedView: a same-length view in which \n, \r, \t, \b and \f read
as control characters and a \u escape reads as line breaks, so no word
starts or ends on an escape's letter. \" \\ \/ stay as written, so the
SECRET rule's \"-aware quote and Windows paths read as before.
- outsideEscapes: any span (rule, word, model, known) that starts or
ends inside an escape is cut back to the escape's edges, so the JSON
holds and what the span held is still masked. A span left empty is
dropped.
- unescapedPut: the value kept for Restore is the unescaped one, so
Restore (which escapes it again in arguments) gives the agent exactly
what it wrote. Before this, a private key's \n came back as \\n.
Ported from ggbdpq's hunt53-f-redact-json-escape. Their test
TestMaskJSONKeepsArgumentsJSON is kept verbatim. Their guard alone let
"\njo@quill.dev" through unmasked, so this port also adds the view, the
trimming and the restore.
Run at base
|
||
|
|
ec7e50b828 |
redact: a decimal's digits are not masked as a number of their own (willz, Discord)
willz on Discord: a tool's JSON with "height": 5.13393848347348 went to
the vendor with part of the number as a placeholder. A run of digits
right after the point of a decimal, or right before it, was judged on
its own: 0.13800138000 went as 0.{{PHONE_…}}, 6.4111111111111111e-3 as
6.{{BANK_CARD_…}}e-3, 1.110105194912310038 as 1.{{ID_CARD_…}}, and
13800138000.5 as {{PHONE_…}}.5. The rules' bound only kept digits off
either side, not a point with a digit beyond it.
mask now drops, after noIDs, any span of a personal-data kind (kindCats:
PHONE, BANK_CARD, ID_CARD, SSN, IP, the model's ACCOUNT and PHONE, …)
that starts with a digit after "<digit>." or ends with a digit before
".<digit>" (noDecimals, inDecimal). It is one choke point for every
finder: the rules, the local model's spans and values known from
before. Not changed: secrets (a key or password masked once is masked
wherever it is, a decimal's digits too), the user's words and rules,
and the signed-thinking path, which re-masks only secrets. A phone
number or card standing alone, in text, after a colon, in a JSON
string, or at a sentence's end ("13800138000.") is masked as before.
A number list written "1.13800138000" with no space now goes as
written; a comma decimal (5,13800138000) is not treated as one.
Reporter's literal: at
|