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/main5215108e, go1.26.8, linux/amd64): - TestElementTokensGoAsWritten, new. Five tokens (s00000001, s00000003:74, s0000002a:14, s00007a3f:42, s00010001:3) in seven places, as the report has them (JSON laid out and compact, a space after the colon, a shell command's JSON, element_token=, inside a JSON string, elementToken), go as written. MaskJSON of a window's state and a click, DB_PASSWORD=hunter2abc9 beside them, masks the password alone. The local model's every label goes as written on s0000002a:14 in a text and on s00000001 in element_token. s12345678, in a sentence or under student_no, labelled an account number or a secret by the model, is masked. s00000001 and s00000003:74 after password=, token:, "refresh_token": and "api_key" are masked, and so is element_token holding abc123def456, s0000000g1, S0000002A, s000000012, s00000001x or s00000001:x9. The user's own word masks one. - It and TestIDsGoAsWritten -count=50: ok. internal/redact, internal/maskrec, internal/gwmw, internal/masking and plugins/redact: ok. - Broken by hand, each red in TestElementTokensGoAsWritten: - idAround not taking an element token: every kept place, the MaskJSON body, the model's every label on s00000001 in element_token (the rule masks it there), and its address and secret labels on s0000002a:14. - "element" not among credentialField's words: every kept place, the MaskJSON body and the model's every label on s00000001 in element_token (the rule, again). - the model's secret kept on a token: its secret label on both. - s and 8 hex digits a token anywhere: s12345678's four cases. - a token only with its index: s00000001 in its seven places and the model's labels on it. - A real run: magpie built at5215108eand at this tree (go build -tags nogui -buildvcs=false), in a sandbox HOME with masking on (settings.json "redact": true), a local server standing in for the vendor that keeps each body it is sent. One request on /v1/chat/completions with the report's three places: a window's state as compact JSON with "element_token": "s00000003:74", one laid out with "element_token": "s00000001", a shell command's cua-driver click with "element_token": "s0000002a", a click by s00000003:74, and a user message with DB_PASSWORD=hunter2abc9.5215108e: the vendor got each token as a {{SECRET_...}} placeholder (s00000003's with its :74), four places. This tree: each as written, the password still a placeholder. - gofmt -l; go vet -tags nogui and go build -tags nogui for linux, windows and darwin, and go vet and go build for windows without the tag: exit 0 each. go vet and go build without the tag on linux: exit 1 (this box has no GTK or WebKitGTK dev packages). - go test -tags nogui -count=1 -timeout 45m ./..., Bun 1.4.2 on PATH: 68 ok, and 7 red, none in what this changes: agent TestCodexDriftReached and TestCodexBehindReverseProxy (#3398); TestHowInstalled, TestCursorFolderFromTheEditorIsNotTheCLI, TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir and TestZedAppPath (#3141); TestReasonixCLIRequiresSupportedNativeVersion and TestReasonixCLIRecoversAfterProbeTimeout (#3641); edit TestWriteAtomicReadOnlyHardLink and testenv TestProgram (#3640); gateway TestPluginToldWhereTheAgentWorks (#3675); gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie (#3649); proc TestProbeTimeoutEndsWhatItStarted (#3848, passes 40 of 40 alone); provider's "close of synctest channel from outside bubble" from TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so the package's tests after it didn't run: go test ./internal/provider -skip '^TestUnreadLoginsWriteErrorsKeepCredentials$', Bun 1.4.2 on PATH: ok. Not tried: DeepSeek Harness and cua-driver themselves (no macOS here); the request was written by hand from the report's places. Review, applied on origin/main8e2ba36de(git am, sha256 of the patch matches the issue's 1db65568…), with two changes to the patch: - The patch made any field with "element" among its name's words no credential's (credentialField) and the field an index-less token may sit in. That widened a key-name exemption: a UUID in element_api_key or elementSecret went as written. Now only cua-driver's own name, element_token (elementToken, element-token), is that field (elementField); any other name is a credential's as before. - A token known from before (ByKnown) was still masked as a credential. One the local model labelled in prose ("I will click s00000001 now") was then masked in every element_token after it, a click on nothing. An element token is no longer masked by a value known from before; the user's own words and rules, and the password, API key and token rules, still mask one. Not scoped to tool calls and results by place: the exemption is held to the token's shape (s, 8 hex digits, :index; index-less only as element_token's value), so a value of any other shape under that key is masked, and every route masks through redact.mask (masking.Masker's MaskJSON and Text), so each route gets it. What was run in review (darwin/arm64, go1.26.8, sandbox HOME): - TestElementTokensGoAsWritten red with origin/main's ids.go (the report's laid-out "element_token": "s00000001" went as {{SECRET_…}}), green with this. - Broken by hand: elementField back to "any word element": red, a UUID and s00000001 in element_api_key and elementSecret went out; ByKnown masking a token again: red, the click's element_token masked after the prose turn. - go test -tags nogui ./internal/redact/... ./internal/masking/... ./internal/maskrec/... ./internal/gwmw/... ./plugins/redact/... and internal/gateway -run 'Redact|Mask|Masked': ok. gofmt -l: nothing; GOOS=linux go vet -tags nogui and GOOS=windows go vet of internal/redact: ok. - Real run: magpie built at8e2ba36deand at this tree, `magpie serve` in a sandbox HOME with "redact": true, a local fake vendor recording bodies; one /v1/chat/completions request with the report's three places (a laid-out window state with s00000001, a compact one with s00000003:74, a Bash call's cua-driver click with s0000002a) and DB_PASSWORD=hunter2abc9. Base: all three tokens went as {{SECRET_…}} (the second with its :74). This: all three as written, the password still a placeholder. Not run: the full suite (one suite per machine; other sessions' runs are on this box). Not tried: DeepSeek Harness and cua-driver themselves.
Subsystem design references
These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.
| Subsystem | Reference |
|---|---|
| Built-in subscriptions moving to plugins | Provider and plugin ownership |
| Built-in plugins: registry, lifecycle, plugins.yml, presets, settings schemas, the window's kernel (slots, error boundary, kit) | Plugin runtime |
| Plugins that run on the gateway's requests and replies | Gateway middleware |
| Tools that plugins give, offered to every agent as an MCP server | Plugin tools |
| Plugins that await context recall and observe completed replies | Asynchronous gateway request hooks |
| Claude subscription turns across Claude Code runs | Claude subscription bridge |
| How the gateway picks a provider, key or account, and falls back | Gateway routing and fallback |
| Gateway Session Aggregation | Gateway Session Aggregation |
| Connecting an agent's config to the gateway, drift, disconnect, WSL twins | Agent wiring |
| Providers, keys, subscription accounts, refresh and allowance | Providers and accounts |
| Instructions, MCP servers, skills and RTK written into agents | Library |
Tray, panel, window, magpie web and the page's JSON API |
GUI app shell |
| Encrypted backups and setup synchronization over WebDAV, S3 or GitHub | Sync and backup |
A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.
Maintain a reference
Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.
Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.
For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.
Describe a PR's semantic changes
For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.
For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.
This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.
Review a change
- Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
- Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
- Check that changed contracts appear in the owning reference and that source links still resolve.
- Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.
A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.