Files
magpie/docs/subsystems
yetone d9459a5371 pii: pf-serve loads a model under a user folder named outside ASCII (Windows)
AIMetaPhD on X (Windows, Chinese user name): Settings → Privacy's
Privacy Filter said "the local masking model didn't start:
pf-serve-vulkan.exe: failed to read GGUF: C:\Users\<mojibake>\.cache\
magpie\privacy-filter\privacy-filter-q8-80efc1803eda.gguf", the same for
pf-serve.exe. pf-serve's main takes a narrow argv, which on Windows is
in the ANSI code page (936 on a Chinese system); ggml_fopen reads the
name as UTF-8 and the GPU's weights are reopened through a narrow
ifstream, so no device could open it, and its error came back in
GBK, which magpie read as UTF-8.

startOne now runs pf-serve in the model's folder and gives it the
model's file name (modelName, ASCII), never the path. That works with
the pf-v2 binaries users already have. A pf-serve error that names the
file is shown with the whole path, in UTF-8. The stand-in pf-serve in
the tests now refuses a model path with a byte outside ASCII and opens
the file from where it runs, as the real one does. TestModelInFolder-
NotASCIILoads and TestModelErrorNamesWholePath put the model under
"用户 Ünïcode". The native side (wide argv, and ggml_fopen in
weights-once.patch) is #4342. pf-serve is the only native helper magpie
starts. AstrLink Guard's CoreML paths are darwin cgo, which is UTF-8.

Run:
- Real use on xiaomi-gpu (Windows 11, zh-CN, ACP 936): the real pf-v2
  pf-serve zip and the real 1.6 GB model (both sha256 match the pins)
  under C:\Users\yeton\runs\pf-测试用户\.cache\magpie\privacy-filter.
  A temporary test (not committed) pointed dir there and called Find
  through win-run. Vulkan (AMD Radeon 8060S) loaded in 3.7s and found
  the person and the email. Forced onto the CPU, it loaded in 7.0s with
  the same finds. Broken by hand (the old full-path argv), it gave the
  reporter's exact error, the folder in mojibake, on both programs.
- Broken by hand on mote: with the old argv, both new tests are red.
- win-run go test ./internal/pii/...: ok (the real test included).
  wsl-run go test ./internal/pii/: ok.
- mote: gofmt ok; GOOS=darwin/linux/windows go vet -tags nogui ./...
  ok; GOOS=windows go vet ./internal/pii/... ok.
- mote: go test -count=1 -timeout 45m ./... at base e863f520c: every
  package ok except internal/gui's TestMainWindowCorners/macOS_26_SDK.
  That is #3949 (macOS 27 on mote), and gui is untouched here.
- After rebasing onto 9e8c22dad (7632e1be1 changed internal/redact and
  internal/masking): pii, redact and masking were run 4 times.
  redact's TestMoreKinds was red once with its output lost, then
  passed 3 runs, -count=8 alone and -count=3 of the package. Filed as
  #4345. pii and masking were ok every time.

Not tried: the GUI on the reporter's real machine. No GUI file changed:
the GUI shows the error text the Go code sends, which is now UTF-8.
2026-10-30 10:53:28 +08:00
..

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
One MCP server, magpie, given to every agent in place of the Library's servers MCP hub
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

  1. Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
  2. Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
  3. Check that changed contracts appear in the owning reference and that source links still resolve.
  4. 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.