ac4af582301a4e8a29245dbba767eba31334ddf9
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5637cca141 |
settings: a notification when masking swaps a value for the first time (Must2333 on X)
Must2333 on X: "我还希望能即时的知道发生了替换,但不是通过随时监控网关的方式".
They want to know when magpie masks something without watching the
gateway or the 脱敏 page.
Settings › Usage has a new row, "Masking alert" (zh 脱敏提醒), after the
task done alert. Off/On, off by default. When on, a value masked for the
first time gives a system notification through the same notifier as the
other alerts. It says only how many new values, each kind and its count,
and the agents that sent them (two named, "+N" for more). It never says
the value, any piece of it, or the Head hint the 脱敏 page keeps. A click
opens the 脱敏 page on the latest record (clickView, "masking&key=<key>").
Why off by default: every other notification in this group is off until
turned on; turning one on asks macOS for notification permission; for
most users a notice each time masking works is noise, since masking's
expected behaviour is quiet protection. It is one row, in the group that
already holds the alerts, hidden while masking is switched off
(data-feature="redact") and in gateway mode.
Staying quiet:
- First time only: maskrec.Fresh says which values a record has that no
record before it had. A conversation sends its whole history each turn,
so a value is masked again every turn after its first. The index is by
placeholder (HMAC-stable across restarts), filled from memory and from
the days kept on disk, so a restart doesn't make a history new again.
The days are read off the lock, since Hold takes it on the request's
way. Values sent as written (Action "warn") are left out.
- A burst is one notification: records gather for 3s (maskGather).
- At most one every minute (maskGap); what comes in between is said
together after it. At most 5000 records wait.
- With the setting off, nothing is kept.
The gateway tells the app through gateway.OnMasked, after maskrec.Hold,
with Snips and Back taken out; nil under `magpie serve`.
Strings: en, zh, zh-TW, ja, de, in i18n.js (the row) and in
mask_alert.go (the notification's title and kind names, the 脱敏 page's
own words for the kinds). docs/subsystems/gateway-routing.md has the
bullet. The core script budget isn't raised: main's 10-29 budget leaves
room for the row's 287 bytes.
Tests, each broken by hand and seen red:
- TestMaskAlertFirstTimeOnly: masks through redact.Mask as the gateway
does; the history masked again says nothing, a new email in turn 4 is
said alone. Red when flush counts r.Values instead of the fresh ones.
- TestMaskAlertNeverSaysTheValue: no 4-character piece of the key, email
or phone, and no Head, in any of the 5 languages. Red with the Head
added to the kind's name.
- TestMaskAlertCoalesces: a burst of 5 from 3 agents is one wait of
maskGather and one notification ("+1"); two more 10s later wait
maskGap-10s and are said as one; off keeps nothing. Red without the
waiting check (5 waits) and without the maskGap wait ("waits 3s want
50s").
- TestFreshOnlyTheFirstTime, TestFreshHeldWhileReading (maskrec). Red
with loadFirst skipping the disk read (the history new after a
restart), and with the index broken (both).
- TestDismissedAlertOpensNothing covers the mask notice's click.
- mask-alert.test.cjs: every language at 900 and 380px, both engines:
the row after the task done alert, Off at first, On saves maskAlert,
another save keeps it, Off saves false, no click moves the page, no
left border, gone with masking switched off. Red with maskAlert taken
out of prefsKeep, and with data-feature taken off the row.
Run:
- This change on main
|
||
|
|
b904cc22bf |
maskrec: the latest requests' bodies are kept zstd in memory, in 32 MiB (#2278)
The 脱敏 page shows a recent request as the vendor got it, so memory kept the latest 100 bodies whole, up to 64 MiB. apple-ouyang's heap profile on #2278 had gateway.sentOf holding 64 MB of them, a sixth of the live heap, kept for a page that is rarely open. Each body is now compressed (zstd, fastest, outside the store's lock) as Hold takes it, held apart from the record, and decoded only when SentOf asks. The budget counts stored bytes and is halved to 32 MiB: a request carrying a screenshot's base64 hardly compresses. On real local session files zstd -1 makes Claude Code's text 4 to 5 times smaller, and a Codex rollout with screenshots 1.4 times. Records in memory no longer hold a body at all, so Get has nothing to clear. Run at this tree (rebased on origin/main |
||
|
|
f76e4d1f5c |
gateway: a chat body is copied for its masked record only when the record keeps it (#4004)
Every route that masks a body passed string(body) to noteMasked, which
copied the whole request though noteMasked keeps nothing when nothing
was masked, and only the first 4 MiB-or-less body otherwise
(maskrec's sentMax). A 44 MiB Codex turn with nothing to mask was
copied whole on every request for nothing.
sentOf copies only for a record that keeps it. maskrec.SentMax exports
the bound it checks.
TestMaskedBodyCopiedOnlyWhenKept: with nothing masked, and over
SentMax, nothing is allocated; under it the body is kept. Red with
sentOf returning string(body) always (2,097,152 bytes allocated for a
2 MiB body).
Run (mote-run at aa8ded04e, both commits, on
|
||
|
|
630fd1d691 |
masking: Clear records… deletes what masking kept, after a confirm (maxyou2090)
maxyou2090 (#feedback) turned on strict masking and it recorded many
requests, with no way to delete them short of finding
~/.config/magpie/masking by hand.
Insights › Masking's list now ends in "Clear records…" (beside "Kept on
this computer for 30 days", shown while anything is kept). It asks first
with the app's confirm dialog (Cancel / Clear, red), then posts
/api/masking/clear and reads the page again: an empty list and card. A
clear that fails says why in the status pill and the list stays.
maskrec.Clear removes each day's file whole under the store's lock (a
day is removed, never rewritten, so there is no half-written file to
guard against), forgets each day's cached summary, and drops the text
around placeholders and the bodies kept in memory. A day it can't
remove stays, is still listed, and is named in the error. Keys keep
rising, so a record after the clear never takes an old key. What the
masker holds for each placeholder stays: a placeholder still in an
agent's context is put back in its answers. GET on the route does
nothing. Strings in zh, zh-TW, ja and de. gateway-routing.md says it.
Tests:
- internal/maskrec TestClear (three days and a stray file: the days go,
the stray stays, List/Sum/Get/SentOf are empty, keys keep rising, a
new Add counts) and TestClearSaysWhatStays (a directory it can't
write: the error names 2026-10-26.jsonl and the record is still
listed). With Clear stubbed to return nil both go red
(maskrec_test.go:220 "left in ...", :260 "err <nil>").
- internal/gui TestMaskingRecordsAPI: GET clears nothing, POST clears,
records/summary empty, record/sent 404. Red with Clear stubbed
(masking_test.go:127).
- GUI masking-records.test.cjs: "Clear records asks first, then
empties the page" in Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and
640px (Cancel sends nothing; Clear posts once; nothing wider than the
window; the click scrolls nothing; nothing left in English), and "a
clear that fails says why and keeps the list". Red on the old page.js
(the button never appears).
Run, at this commit (on origin/main 44a626bed; vet, maskrec, the gui Masking tests and the 22 new GUI cases again after that rebase):
- gofmt -l internal/maskrec internal/gui: clean. go vet on darwin,
GOOS=linux -tags nogui and GOOS=windows for both packages: ok.
- go test ./internal/maskrec: ok. go test -run 'Masking|Budget|Script'
./internal/gui: ok.
- GUI: masking-records.test.cjs whole and i18n-keys.test.cjs, both
engines: 86 pass, 0 fail (before the rebase onto
|
||
|
|
49f15d1244 |
masking: a record names the provider the request went to, not the group's first member (Max You and Linka on Discord)
Linka on Discord: Insights › Masking's records said WorkBuddy AI, the
first member of their auto group, for requests that Codex in the same
group had answered. Max You: providers no route sends to show up under
Privacy all the same.
Cause: serve() recorded the masking (noteMasked) as the route began,
with p.ID, the first planned provider, before any try. A request the
first member failed, or a member resting or unable to serve, went on
to the next, and the record (on disk, and counted into the flow and
the provider filter) kept the first. Embeddings recorded tries[0] and
video the same way.
Fix: maskrec.Hold keeps a record in memory at once (the route's badge
and the answer's Restored need its key) and writes it to disk only
when done is told the provider and model of the last try.
noteMaskedUntil wraps it, and serve, embeddings and video call done
in a defer with call.Provider and the model tried last. A request
that never reached a try keeps the planned one, as before. Since a
long request's line is now written after later ones, List sorts each
day's lines by key, so paging with before skips nothing.
Old records keep the name they were written with; there is no record
of which member had them. They leave with the 30 days.
Tests:
- TestMaskedRecordNamesTheProviderThatHadIt (gateway): a group a/m,
b/m, a answers 500, b 200, with Mask secrets on; chat and
embeddings. On the old code both subtests fail:
masked_sent_test.go:96: recorded on "a", the request went to b
- TestHoldNamesWhoHadIt (maskrec): the held record goes on disk with
done's provider and model, done's second call counts for nothing,
Sum counts that provider, and List pages a late-written record in
key order. With the sort taken out it fails on the first page.
Run at this tree (base
|
||
|
|
51667a34c6 |
maskrec: records narrow by several kinds, by who found them, and to held-back requests
The Masking page's facets ask for a set of kinds (Secrets is API keys, passwords, private keys...), for what found the values (rules or the local model), and for the requests held back. Filter.Kind takes a comma list, Filter.By and Filter.Blocked are new, and /api/masking/records passes by= and blocked=1 through. Run: go test ./internal/maskrec ./internal/gui -run 'Filter|Records|Masking|MainView|ShowMain' ok. |
||
|
|
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. |
||
|
|
b00c82acfa |
masking: each kind is masked, sent with a warning or held back; a Never mask list and Try it (#1977)
Settings › Privacy gets two sections under What to mask:
- When a value is found: Mask, Warn or Block per kind (redactActions;
a kind left out is masked). Warn sends the value as written and records
it with a placeholder nobody remembers, not counted as masked. Block
masks it as before and the gateway answers 400 naming the kind and the
value's hint, never the value, with nothing sent (maskBlocked); the
record is kept as Blocked. The secret kinds come first, the personal
ones behind Show all kinds. A Never mask list (redactAllow) lets a whole
value go as written in any case; a longer value it is part of is masked.
- Try it: POST /api/masking/preview masks a text as a request would
(redact.Preview) and remembers nothing: no placeholder stands for it
afterwards and its values aren't masked later as seen before. The page
shows the vendor's text, what was found and what would be done, and
keeps the text in no storage.
The masking card counts requests held back and values sent as written; a
call whose values only went as written gets an amber badge on Recent calls
and the Routing log. zh, zh-TW, ja and de throughout. Docs: gateway-routing
and gui-shell.
Broken by hand: the new GUI badge assertion fails on the old maskedBadge
(no .warn badge drawn); TestSettingsSaveKeepsWhatItDoesNotSend went red
until the two settings were in its fixture; "{n} held back" turned
i18n-keys red against the routing plugin's "{n} held" and was renamed.
Run at this tree (base origin/main
|
||
|
|
f21dd99f5a |
privacy: every masking is recorded, and Settings › Privacy shows it
What was masked is now kept, so the user can see it. Settings › Privacy opens on a summary card: how many values were kept from vendors over 1, 7 or 30 days, by kind, by finder (rules, your words, the local model, known values) and by where they went, with a day strip. The page is grouped into What to mask, How it's found (rules and the local model are layers, not a toggle: the model adds names and addresses rules can't see) and Sharing. A records view lists each masked request: its kinds, finders, placeholders and, while magpie runs, the line around each value. Gateway › Recent calls and the Routing log carry a masked-N badge that opens the record. Originals never go to disk. internal/maskrec writes day files under ~/.config/magpie/masking (0600, 30 days, 100MB at most) holding kinds, finders, placeholders, a first character or key prefix and a length. The lines around values are kept in memory for the last 400 records only, and /api/masking/value answers only while the masker remembers a placeholder. Nothing is written under MAGPIE_TEST_SANDBOX. A masker says what it masked through gwmw.Teller (JSONHits, TextHits, Value); a plugin masker that doesn't is counted only, so older redact plugins keep working. Every route that masks notes it: chat, Responses, Codex backend and search, embeddings, images, video, transcription, decide and the search MCP query. Masking still fails closed: a masker that panics on any path refuses the request (TestMaskingOnAndOff's fake now panics on JSONHits and TextHits too, since the gateway asks a Teller through those). app.js grows to 1,314,432 bytes, so its budget rises to 1,335,000 and the core's to 1,528,800 (+1.5%): Settings is the core's own page. Run at this head (rebased on origin/main |