All three were test fixtures, not magpie writing a bad file.
TestHooksCodexTrustMovesWithTheGroups wrote Codex's [hooks.state."<path>"]
keys itself as basic strings, so on Windows "C:\Users\..." held \U, and
toml read the test's own file as broken ("toml: non-hex character").
Codex doesn't write that. Driving the real `codex app-server`
(0.162.1, config/batchWrite on hooks.state, as its /hooks does) under a
sandbox CODEX_HOME shows its toml_writer spelling: a basic string when
nothing needs escaping, a literal string ('C:\Users\x\...') when a
backslash does, and an escaped basic string ("C:\\Users\\O'Brien\\...")
when the key has an apostrophe too, under a bare [hooks.state] header.
codexKey in the test now spells keys that way, and the test runs for
the default home, a CODEX_HOME with a backslash in it and one with an
apostrophe as well, so macOS and Linux exercise both quoted forms too.
codexRekey already reads both and rewrites only the key's tail, so the
spelling is kept.
Every place magpie writes a path into TOML was checked: edit.tomlString
(every edit.KV string value, model_catalog_json among them),
library/mcp.go tomlString/tomlKey, provider/devin.go tomlString all
escape backslashes; the strconv.Quote writers (grok/kimi/atomcode/jcode/
reasonix/codex reasoning efforts, Grok hook blocks) write model ids,
efforts and commands, where a backslash comes out as \\ too. None writes
an unescaped path, so no writer changes.
TestAgentsSkillsFolders and TestTargetsLeaveGoneAgentsOut wrote Hermes's
config.yaml into ~/.hermes, but Hermes's folder on Windows is
%LOCALAPPDATA%\hermes (appdir.HermesHome). There Hermes wasn't there at
all: its skills folder was the Windows one, and Takes for an agent with
no folder says yes rather than "isn't installed". Both now write into
appdir.HermesHome(), and TestTargetsLeaveGoneAgentsOut first checks
Hermes is detected by that config, so a fixture in the wrong place fails
as that rather than as a Takes result.
Run:
- Windows 11 box, test binaries cross-built (GOOS=windows -tags nogui),
fresh USERPROFILE/HOME/APPDATA/LOCALAPPDATA/TEMP each run, cwd with
internal/library/testdata:
- origin/main 2b0037f41: the three fail as in the issue.
- this change: the whole internal/library package PASS.
- this change with codexRekey's literal-key branch disabled by hand:
TestHooksCodexTrustMovesWithTheGroups/default and /backslash FAIL
("keeps Codex's trust of ... in a way magpie can't move").
- macOS: the same break fails /backslash; restored, all pass.
- real codex 0.162.1 app-server in a sandbox HOME/CODEX_HOME for the
three key spellings above.
- macOS, rebased on origin/main 9d97fd073: gofmt -l prints
nothing; go vet -tags nogui ./internal/library for GOOS=darwin, linux
and windows ok; go test -p 1 -count=1 ./internal/library ok (132s)
in a sandbox HOME/TMPDIR with Go's caches pinned.
- Full suite: SUITE_LINE