fix(test): route contacts-write trust-store writes to test workspace#24884
Merged
Conversation
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
GATEWAY_SECURITY_DIRto the per-test workspace'sprotected/dir before importing../permissions/trust-store.jsincontacts-write.test.ts.~/.vellum/protected/trust.json.Context
PR #24879 added a regression test that imports
clearAllRulesandgetAllRulesfrom../permissions/trust-store.jsand calls them inbeforeEach/test bodies. Both functions write to disk viafileClearAllRules→saveToDisk(seetrust-store.ts:597-609). The file path is resolved fromgetGatewaySecurityDir(), which falls back to~/.vellum/protectedwhenGATEWAY_SECURITY_DIRis unset.Because PR #24879 did not set the env var before the import, running
bun test src/__tests__/contacts-write.test.tswas writing to the developer's real~/.vellum/protected/trust.json. After the test runs, the file contains staledefault:allow-file_{read,write,edit}-guardian-personarules pointing at/private/var/folders/.../vellum-test-workspace-XXX/users/carol.md— a temp directory that no longer exists. This breaks permission matching on the real assistant: everyfile_edit users/<slug>.mdwould prompt for approval because the auto-allow rule points at a dead path.Verified the blast radius on my machine:
trust.jsonmtime updated after each test run, and stale guardian-persona entries withvellum-test-workspace-XXXpaths appeared.trust.jsonmtime unchanged across test runs (4 pass, 0 fail).This follows the same
GATEWAY_SECURITY_DIRoverride pattern used by every other trust-store-touching test file (checker.test.ts:27-30,trust-store.test.ts,inline-skill-load-permissions.test.ts,ephemeral-permissions.test.ts,starter-bundle.test.ts,config-watcher-feature-flags.test.ts).Follow-up suggestion
The
test-preload.tsmodule could setGATEWAY_SECURITY_DIR = join(testDir, "protected")unconditionally so individual test files don't need to remember this. That would prevent the same class of bug for any future test that imports trust-store. Out of scope for this fix.