f2eb56c6bbde1300dddc402861b59cd4e45e0215
7
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 |
||
|
|
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.
|
||
|
|
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). |
||
|
|
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, |
||
|
|
62390fe92e |
redact: a masked word is never masked inside tool definitions or schemas, so Codex's apply_patch grammar reaches OpenAI intact (#1911, loveNangua)
What changed: MaskJSON masked custom words as raw substrings in every
string of the request, tool definitions included. A word "pd" turned
apply_patch's Lark rule name update_hunk into u{{TERM_..}}ate_hunk and
OpenAI refused the request with 400 "Invalid lark grammar". Definitions
are now kept by where they sit in the protocol, not by a key's name:
the request's top-level tools, tool_choice, functions, function_call,
toolConfig/tool_config, response_format, text (an object), reasoning,
include, output_format, output_config and generationConfig, and the
tools of a Responses input item of type additional_tools or
tool_search_output. Inside them only "description" strings are still
masked. A "tools" or "text" key in tool-call arguments, a message, a
Gemini part or a Responses message item is masked as before.
Run: go test ./internal/redact/ ./internal/provider/ (ok). The new
tests use Codex 0.162.1's real request (copied from the gateway's
testdata) with the top-level tools and as a Responses Lite
additional_tools item, plus Anthropic/Chat/Responses/Gemini schema
cases and negative cases. With the old json.go both tests fail
(update_hunk masked, every schema case changed). gofmt -l clean; go vet
-tags nogui on darwin, linux and windows. Not tried: a real request to
OpenAI with the word set.
|