Cario0x on X asked to route by the project being worked on. A group's rule now has a
"folders" condition: it matches when the request's working folder is one of the listed
folders or inside one. It combines (AND) with the existing conditions: tokens, images,
intent, time, agents and quota.
- gateway/workdir.go reads the folder each agent states in its own request:
- Claude Code: "Primary working directory", including "(was …)" after a move.
- Codex: <environment_context><cwd>.
- Pi: <cwd>.
- OpenCode: <env> "Working directory".
The last one stated wins. Assistant text and tool results are ignored. A request
that states no folder matches no folder rule: unknown, never empty.
- provider/rulefolder.go matches a folder only at a path boundary.
- ~ is the home folder.
- C:\x is the same folder as /mnt/c/x, and \\wsl$\Distro\x as /x.
- Case is ignored on macOS and Windows, and always for a drive.
- A rule's folder must be a whole path. Pause rules can't have folders.
- The trace's RuleHit.Folder makes the Routing page say "The agent works in …".
- GUI: an "in folder" condition in the group editor, hidden on pause rules. Strings in
zh, zh-TW, ja and de.
- CLI: `magpie group rule add … folders=~/oss,"~/My Project"`. The TUI shows the
condition.
- Docs: docs/subsystems/gateway-routing.md and site start.html (en, zh, ja).
Fixtures are real requests from Claude Code 2.1.296, Codex 0.162.0 and Pi 1.1.0, run in
a sandbox from a folder named "a&b <c> 中文" or "My Proj", with the sandbox path
replaced.
Run at this head:
- go test ./... green.
- gofmt -l clean.
- go vet green for darwin, GOOS=linux -tags nogui and GOOS=windows.
- GUI routing-folder.test.cjs: chromium and webkit, en, zh, zh-TW, ja and de, 1100px
and 390px (no horizontal scroll). It fails on the old routing.js.
- Related routing, group and i18n GUI tests: 85/85.
- Full GUI suite: 5611/5631 under --test-concurrency=6. Rerun alone, every failure
passes except:
- skill-install-agents-all (chromium, 420px), which is red on origin/main too: #1554.
- The menu-scroll track flake, which flakes on main as well: #1550.
- e2e: a sandbox HOME, a dev build and fake upstreams, with real Claude Code 2.1.296
(`claude -p --model group/fd`).
- From proj/acme/web, rule 1 matched and the request went to kb.
- From proj/acme-old, no rule matched and the request went to ka. The trace and UI
showed the folder.
John asked for a pause in a group's Rules, e.g. a model paused in its
vendor's peak hours. A time rule could only send those turns to another
member first: the paused-for model stayed behind it for failover, went
first when the other was unready, and was kept by affinity mid-turn.
What changed:
- provider: Rule.Pause (`"pause": true`, typed `pause=<model>`). It holds
by time/days and agents only; cleanRules and ParseRule refuse any other
condition, and refuse a pause with none. Pause rules are not send-to rules:
MatchesBesidesIntent, ruledEntry and Ruled() leave them out.
PausedOut(g, ms, agent, at) drops members a pause holds for, from the
group's own rules and each nested group's (a group named = all its
models; a model named = wherever a nested group has it, #625).
- gateway: serve and embeddings run PausedOut on ruleClock before planning,
on every request. Every member paused -> 503 naming each rule
(pausedError). The trace's GroupRef carries Paused.
- GUI: the rule editor's "send to" is now an app-menu action button (send
to / pause); a pause hides the request conditions (clearing them),
keeps hours, days and agents, and isn't saved without one. The group
card's rule reads "→ pause <model>", and the Routing trace says which
model was paused by which rule. Strings in zh, zh-TW, ja, de.
- CLI/TUI: `magpie group rule add <g> pause=<model> time=… days=…`.
- docs: gateway-routing.md step 2; start.html en/zh/ja "Hours and days".
Run:
- gofmt -l clean; go vet -tags nogui ./...; GOOS=linux and GOOS=windows
go vet -tags nogui on gateway, provider, tui, root; go build ./...
- go test -tags nogui ./... under a temp HOME with pinned caches: all ok.
- rules_pause_test.go (3 tests) fails with the PausedOut call in serve
removed (the paused model answers mid-turn, as a fallback, and the
all-paused case returns 200). grouprule_pause_test.go covers clean,
parse/Line, Ruled, Pauses and nested PausedOut.
- GUI: routing-pause.test.cjs in Chromium and WebKit, en/zh at 1100px
and en/zh/zh-TW/ja/de at 420px: 14/14; all 7 Chromium cases fail on
the old routing.js. routing-*, group-*, i18n-keys, gui-ja, gui-de,
click-scroll: 618 pass, 4 fail under --test-concurrency=4
(routing-blocked, -idle-frame, -side-calls, -wb-refused), all of which
pass run alone; routing-side-calls failed 1 of 6 alone and passes
with the old routing.js too, so it is a load flake not touched here.