Files
magpie/internal/redact
yetone eb6d1d8d97 redact: a colour or an ordinary word is no personal name (黄绿色, 关键词)
hh05928822 on X after v0.1.1850: names were found in ordinary Chinese,
"黄绿色" the worst, with 边••, 应••, 关••, 尚• in the screenshot.
wangjunxiao128: "关键词" taken for a name.

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

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

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

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

Not tried: the reporters' own texts (not in the reports), so their
exact false positive was not reproduced with the real model; Privacy
Filter; the GUI. 高峰期 is still masked: jieba tags 高峰 as a name.
2026-10-28 17:01:49 +08:00
..
gateway: a request archive, off unless turned on, keeps each call's headers and bodies in the user's own S3 bucket and a recent call reads its own back (Jorben on Discord: 请求存档) — the Gateway page's recent calls only ever held the last bodies in memory, the first 256 KB of each, with no headers, gone at a restart. A switch over Recent calls ("Request archive", POST /api/settings/archive, settings' requestArchive) turns it on, refused with a reason while sync isn't set up with an s3:// bucket; with it on, each call the gateway serves gets an id (UTC HHMMSS-<16 hex>, said back in X-Magpie-Archive-Id) and, once it is recorded, its method, path and query, request headers and body and response status, headers and body go as one JSON file to <prefix>/magpie/archive/<YYYY-MM-DD>/<id>.json in the bucket sync keeps its backup in, signed with the same client (davsync.Bucket, no new SDK). Before anything leaves, Authorization, x-api-key, Cookie, Set-Cookie, any header or JSON field or query parameter named for a key, token, secret or password, and anything that looks like a key or token anywhere in the text (the redaction rules' patterns, in a stream's data lines too) become [REDACTED] — gone, no placeholder kept; the archive is plain JSON, readable in the bucket, not sealed with the passphrase. Uploads go one at a time on their own goroutine from a queue of 16 calls, each body capped at the 256 KB the call already keeps and marked truncated; a full queue drops the call with a log line, a failed upload is logged and shown under the switch until the next one goes, and no request waits on any of it. A recent call the archive kept shows its date and id under its bodies, and "Fetch from archive" (GET /api/archive?date=&id=, only a date and an id of that shape) shows the request's and response's headers and bodies as the bucket has them, or says it isn't there yet. The hook is in record() and the Call literal, so PR #239's request log lines are not touched; the archived call carries its usage, and with #239 its vendor request id. Only calls through serve() are archived, not Codex's backend, image or video calls. TestArchiveOn, TestArchiveOff, TestArchiveName, TestRequestArchiveToS3 (a real gateway request through the signature-checking fake S3), TestScrub and request-archive.test.cjs fail without the change; TestSettingsSaveKeepsWhatItDoesNotSend now sets requestArchive. A sandbox magpie web with a fake vendor and a fake S3 server uploaded nothing while off; on, it uploaded a signed archive with none of eight planted secrets in it, read it back through /api/archive and in the page, and with the S3 server down served the call in 0.1 s and said why the upload failed. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (Claude account tests and TestClaudeRunEndsWhenTheClientLeaves pass alone); request-archive, click-scroll, old-webkit, sse-body, gateway-fold pass.
2026-10-01 17:13:34 +08:00