test(project): regression coverage for #312 — HOME-like config does not leak#335
Open
ricardoarz-dev wants to merge 1 commit intoGentleman-Programming:mainfrom
Conversation
…ME-like config does not leak Adds two regression tests covering the multi-agent scenario reported in Gentleman-Programming#312, where each agent's MCP server runs from its own cwd under a shared $HOME that contains `~/.engram/config.json`. Existing TestDetectProjectFull_DoesNotInheritParentConfigOutsideGitRepo covers the immediate parent + plain-child case. These tests extend that coverage to the two shapes that match real multi-agent deployments: 1. HomeLikeConfigDoesNotLeakIntoNestedGitRepo — config at HOME-like ancestor, cwd inside a git repo several levels below (e.g. $HOME/repos/agent-b/src/pkg). Asserts SourceGitRoot wins over the ancestor config; project resolves to the repo basename, not the HOME-level project_name. 2. HomeLikeConfigDoesNotLeakIntoDeeplyNestedNonGitCwd — config at HOME-like ancestor, cwd several levels below outside any git tree. Asserts SourceDirBasename of the leaf cwd, not the ancestor's project_name. Both shapes are mentioned in Gentleman-Programming#312's reproduction. Together with the existing test, they pin the contract that `.engram/config.json` is a project/repo lock — never inherited from arbitrary ancestors — and should make any future regression of that behavior fail loudly. Refs Gentleman-Programming#312
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.
Summary
Adds two regression tests in `internal/project/detect_test.go` that pin the contract `.engram/config.json` is a project/repo lock — never inherited from arbitrary ancestors. They cover the multi-agent shape reported in #312, where each agent's MCP server runs from its own cwd under a shared `$HOME` that contains `~/.engram/config.json`.
Tests-only PR — no behavior change. The actual fix that prevents `~/.engram/config.json` from contaminating arbitrary cwds is already in main (`detectFromConfig` only reads at the git-root or the input dir, never walking to ancestors). These tests blind-side regressions of that behavior.
Closes #312 if maintainers agree the issue is resolved by the existing fix + this regression coverage. Otherwise happy to keep iterating.
Why these specific tests
`TestDetectProjectFull_DoesNotInheritParentConfigOutsideGitRepo` already covers the immediate-parent + plain-child case. The two shapes added here match what #312 actually reproduces in real multi-agent deployments:
`TestDetectProjectFull_HomeLikeConfigDoesNotLeakIntoNestedGitRepo` — config at a HOME-like ancestor, cwd inside a git repo several levels below (e.g. `$HOME/repos/agent-b/src/pkg`). Asserts `SourceGitRoot` wins over the ancestor config; project resolves to the repo basename, not the HOME-level `project_name`.
`TestDetectProjectFull_HomeLikeConfigDoesNotLeakIntoDeeplyNestedNonGitCwd` — config at a HOME-like ancestor, cwd several levels below outside any git tree. Asserts `SourceDirBasename` of the leaf cwd, not the ancestor's `project_name`.
Both shapes are described in #312's reproduction ("3 agents (`agent-a`, `agent-b`, `agent-c`) each with own engram MCP" sharing `/root/.engram/config.json`).
Test plan
Files changed
Notes