Commit Graph
1 Commits
Author SHA1 Message Date
yetone 0db804999e pii: AstrLink Guard as a second local model (#3578)
pii.Model is a local model (ID, Supported, Installed, Size, Find, Now,
Download, Cancel, Warm, Stop, Remove); pii.Models lists Privacy Filter
and AstrLink Guard, pii.Of finds one by id. pii.Choose decides which
one runs: the user's pick; else Privacy Filter for a user who has it on
or downloaded, so no one's model changes under them; else AstrLink
Guard, the default for everyone who turns the model on from now on.

Why AstrLink Guard as the default. On 234 segments of real code and
config (131 KB: Go, TS, lockfiles, go.sum, CI and agent configs),
Privacy Filter found 100 spans in 26 segments, 39 after redact's checks
(38 go.sum hashes and "Zed"); AstrLink Guard found 2, 1 after the
checks. On the masking eval (42 values to mask, 113 to keep), the
model alone: Privacy Filter 40/42 and 47/113 wrongly, AstrLink Guard
38/42 and 3/113; with the rules and checks both are 41/42 and 1/113.
It is 39 MB, not 1.6 GB, runs on any CPU in magpie's process, and
needs no native helper.

Its three files come from Hugging Face at revision 7216b6a3 (v0.1.3),
each checked against the sha256 in the publisher's SHA256SUMS:
int8/model_int8.onnx 0a070d31…, int8/model_int8.onnx_data 0ba34216…,
int8/tokenizer.json 0cf3b235…; from hf-mirror first in China, as
Privacy Filter's are. It is loaded on the first request and let go
after 10 minutes with none; a failure holds requests back with the
same backoff as Privacy Filter's. Its labels are named as Privacy
Filter's, so redact's checks read both alike.

TestGuardFilesAreThePublishers holds each pinned path and sha256 to
the publisher's SHA256SUMS lines (testdata); it is red with the
tokenizer at the repo root, which is a 404 (found by a real download).

Run: go test -race -count=2 ./internal/pii ./internal/source; a real
download from huggingface.co into a sandbox HOME through
Of(Choose("", false)).Download (8.7s), then Find: 张伟, 13800138000,
zhangwei@example.cn, 北京市朝阳区建国路88号 and an sk-proj key found,
nothing in a go.sum line or "gpt-5.1-codex, go 1.26.8, README.md";
load 104 ms, three texts in 177 ms. All at the pushed head.
Not tried: a real download on Windows or Linux.
2026-10-27 02:01:16 +08:00