Repository navigation
fix(harness): let adapters own their global context path - #3
Merged
Merged
Conversation
`mom doctor` read pi's global context from ~/.pi/AGENTS.md while the pi adapter writes ~/.pi/agent/AGENTS.md, the path pi's own docs name for global instructions. A working Pi-only install therefore failed the harness context check, and anyone who followed doctor's path instead of the adapter's put the MOM block somewhere pi never reads. The mismatch came from doctor keeping its own copy of the home-file list rather than asking the code that wrote the block. GlobalAdapter now requires GlobalContextPath, each adapter returns the path it writes to, and GenerateGlobalContextFile goes through that same accessor — so the two cannot drift apart again. Registry.GlobalContextPaths collects those paths per harness, and doctor and uninstall both read it. That fixes two more symptoms of the duplicated list: uninstall omitted pi entirely and left the managed block behind in ~/.pi/agent/AGENTS.md, and doctor hardcoded ~/.codex/AGENTS.md where the codex adapter honours CODEX_HOME. The new test writes the block through each adapter and asserts it lands at the path that adapter advertises, which is the assertion the old hardcoded list was missing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
mom doctorlooked for pi's global context at~/.pi/AGENTS.md, but the pi adapter writes~/.pi/agent/AGENTS.md— which is the path pi's own docs name for global instructions (docs/usage.md:~/.pi/agent/AGENTS.mdfor global instructions).So a working Pi-only install failed the harness context check, and anyone who trusted doctor's path over the adapter's put the MOM block somewhere pi never reads.
Root cause
Doctor kept its own hand-maintained copy of the per-harness home-file list instead of asking the code that wrote the block. Removing that list surfaced two more symptoms of the same duplication:
ingress/cli/uninstall.go:127omitted pi entirely, somom uninstallleft the managed block behind in~/.pi/agent/AGENTS.md.~/.codex/AGENTS.mdwhile the codex adapter honoursCODEX_HOME, so a relocated Codex home read as absent.The fix
GlobalAdapternow requiresGlobalContextPath() (string, error). Each adapter returns the path it writes to, and its ownGenerateGlobalContextFileresolves through that accessor — the write and the read cannot diverge.Registry.GlobalContextPaths()collects those paths keyed by harness name, and both doctor and uninstall consume it. One definition per harness, held by the adapter.Verification
go test ./...passes.ingress/harness/global_context_path_test.gopins the invariant the old list was missing: write the block through each adapter, then assert it lands at the path that adapter advertises. Reintroducing the original bug (pointing pi'sGlobalContextPathback at.pi/AGENTS.md) fails the test at the pi subtest.Against a real install, doctor now reports all four harnesses instead of silently dropping pi:
Not included
~/.agents/AGENTS.mdcame up as a possible shared location for pi, codex, and droid. Pi does not read it as global instructions —~/.agents/is the skills.sh directory, and pi only reads~/.agents/skills/from it (docs/sdk.md). Consolidating onto one file would mean MOM writing there and symlinking each harness path to it, which is a feature rather than a fix and needs codex/droid behaviour confirmed first.