Files
devvm/internal/msg/agentstore_test.go
w3cjandClaude Opus 5.5 d939d1d870 fix(agents): agent import and save never write through a linked store, nor copy a link to what they leave out
devvm agent import copied a link inside an agent's folder as the file it
led to wherever that was in the folder, so a link in ~/.claude/skills or
~/.claude/plugins/cache could put the history, .credentials.json or a
plugin's data into the store. Such a link is now copied only when its
target is one of the agent's settings (listedPath, MachineOwn included),
and any other is left out, naming where it leads
(agent_import_link_not_setting). Each file the import listed is read
through the agent's folder opened one folder at a time without
following a link (readListed), and must be the file it listed, so a VM
whose project folder is in the agent's folder can't swap a link or a
folder between the listing and the read; a file it can't read so is a
message (agent_import_read_failed), as is one whose details can't be read
while listing, which was dropped without a word. One file is read up to
128 MiB.

pruneStore and clearKind opened the store by path, so a store that was a
link (to ~, say) let import and save delete the files of the folder it led
to. They now open it from devvm's config folder, refusing a link on the
path (openStoreDir, sharing one walk, walkStore, with cleanSeed and the
guard), and import and save check every path they'll write, for every
agent they handle, before the first write (storeGuard, checkStore,
checkPlan, saver.applyAll): a link fails the command, naming it, before
the store changes (agent_store_link).

Tests: TestAgentImportLinksInsideToSettingsOnly,
TestAgentImportSwappedAfterListing, TestAgentImportLinkedStore,
TestAgentImportLinkedStoreOfAnother, TestAgentSaveLinkedStore,
TestAgentSaveLinkedStoreOfAnother, TestStoreOpsRefuseLinks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 23:07:04 -07:00

22 lines
703 B
Go

package msg
import (
"strings"
"testing"
)
// devvm agent import's and save's messages about links and the agent store, which their own
// package's tests check by name: each renders whole, its values in place, and links to its page.
func TestAgentStoreMessages(t *testing.T) {
for _, m := range []M{
AgentImportLinkNotSetting("/h/.claude/skills/x", "/h/.claude/projects/p"),
AgentImportReadFailed("/h/.claude/settings.json", "changed"),
AgentStoreLink("/c/agents/claude"),
} {
text := m.Text()
if strings.Contains(text, "{{") || strings.Contains(text, "<no value>") || !strings.Contains(text, "/") || m.DocURL() == "" {
t.Errorf("%s: %q, link %q", m.ID(), text, m.DocURL())
}
}
}