Test coverage for memory + scratchpad subsystem#104
Open
mlund01 wants to merge 1 commit into
Open
Conversation
Follow-up to #102 — fills the test gaps the post-ship audit flagged at the tool-implementation, agent auto-attach, prompt-formatter, and wsbridge file-browser layers. All new tests use Ginkgo + Gomega to match the project's BDD pattern. aitools/memory_tools_test.go (28 specs, package aitools_test) - schema: every file_* tool advertises `slot`, not legacy `folder` - schema: legacy {"folder": ...} payloads are rejected at unmarshal - file_list: flat, recursive, pagination, empty, unknown slot - file_read: contents verbatim, max_lines, max_bytes, missing path, directory rejected, path traversal rejected - file_create: new, fail-if-exists, overwrite, append (success + fail-if-missing), creates parent dirs - file_delete: file removed, directories rejected - file_search: regex match, no-match summary, bad regex - file_grep: flat match, recursive descent, no-recursion-by-default agent/internal/prompts/prompts_test.go (7 specs, new suite) - FormatMemoryContext nil/empty → empty string - "memory" slot gets the persistent-mission label - "scratchpad" slot gets the ephemeral label - Shared slots get no reserved-name label - Output advertises `slot` param + names all six file_* tools - Iteration order is preserved (sort lives in mission/memory_store.go) wsbridge/memory_browser_test.go (17 specs, package wsbridge, joins the existing Wsbridge HumanInput Suite) - collectMemoryInfos: shared + per-mission memory both emitted with correct paths under SquadronHome - collectMemoryInfos: Editable=true for every entry (no read-only mode) - collectMemoryInfos: missions without memory{} skipped, scratchpads not exposed (preserved behavior, pinned) - resolveMemoryPath: shared, mission, collision priority (shared wins — pinned so a future priority swap is loud), unknown name, mission without memory{}, end-to-end real file read - resolveSafePath: rejects ../, mid-path ../, absolute paths; accepts valid relative + empty (root) agent/memory_tools_attach_test.go (3 specs, new suite, package agent_test) - All six file_* tools attached when MemoryStore is non-nil - All six omitted when MemoryStore is nil (negative case) - Attached tools wired to the exact store passed in What's still uncovered (low ROI): - cmd/engage.go runScratchpadCleanupLoop — tiny shim around mission.SweepExpiredScratchpads - Full end-to-end mission with memory + scratchpad — covered by the manual smoke test in #102; a true integration test would need an LLM call
5a1a26a to
4f30aa7
Compare
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
Follow-up to #102. The post-ship audit flagged that the memory + scratchpad rework had solid coverage at the config-parse and store-build layers (~90%) but the tool surface, the agent auto-attach branch, the prompt formatter, and the wsbridge file browser were untested (~20-30%). This PR closes those gaps.
50 new tests, ~960 lines, no production-code changes.
What's covered
aitools/memory_tools_test.go(27 tests)Direct unit tests for all six
file_*tools against a fakeMemoryStorethat backs slots with real temp dirs (so syscalls exercise actual on-disk behavior):slot(not legacyfolder){\"folder\": ...}JSON payloads are rejected at unmarshalfile_list: flat, recursive, pagination, empty, unknown slotfile_read: max_lines, max_bytes, missing path, directory rejected,../escapefile_create: create-new, fail-if-exists, overwrite, append (+ missing target), parent-dir creationfile_delete: happy path, directory rejectedfile_search: regex match, no match, bad regexfile_grep: flat, recursive, no-recursion-by-defaultagent/internal/prompts/prompts_test.go(7 tests)FormatMemoryContextbehavior:memoryslot gets the persistent-mission labelscratchpadslot gets the ephemeral labelslotparam and all six file_* toolsmission/memory_store.go, not prompts)wsbridge/memory_browser_test.go(13 tests)File-browser RPC layer that was previously fully untested:
collectMemoryInfos: shared + per-mission memory both emitted with correct paths under SquadronHome,Editable: truefor allmemory { }are skipped; scratchpads aren't exposed (preserved behavior, now pinned by test)resolveMemoryPath: shared memory, mission memory, unknown name, collision (shared wins — pinned so a future priority swap is loud), mission withoutmemory{}not resolvableresolveSafePath: rejects../, mid-path../, absolute paths; accepts valid relative and empty (root)agent/memory_tools_attach_test.go(3 tests)The auto-attach contract — that file_* tools appear iff a
MemoryStoreis wired:MemoryStore != nilMemoryStore == nilWhat's still uncovered
Low ROI, deliberately skipped:
cmd/engage.go runScratchpadCleanupLoop— three-line shim aroundmission.SweepExpiredScratchpadsTest plan
go build ./...go test ./...— all 19 packages pass🤖 Generated with Claude Code