Repository navigation
fix(cli): squad memory opens the same governed store as squad_state - #2317
Conversation
🟡 Impact Analysis — PR #2317Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affecteddocs (1 file)
root (1 file)
squad-cli (1 file)
tests (1 file)
This report is generated automatically for every PR. See #733 for details. |
🛫 PR Readiness Check
PR Scope: 📦🔧 Mixed (product + infrastructure)
|
| Status | Check | Details |
|---|---|---|
| ❌ | Single commit | 2 commits — consider squashing before review |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | No Copilot review threads |
| ❌ | CI passing | 15 check(s) still running |
Files Changed (4 files, +145 −20)
| File | +/− |
|---|---|
.changeset/memory-cli-same-store.md |
+5 −0 |
docs/src/content/docs/features/memory.md |
+5 −1 |
packages/squad-cli/src/cli/commands/memory.ts |
+44 −19 |
test/memory-store-resolution.test.ts |
+91 −0 |
Total: +145 −20
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
c3fd643 to
438bf81
Compare
`squad memory` built its LocalMemoryStore over plain files at <cwd>/.squad, while the memory.* tools in squad_state resolve the team with resolveSquadState and go through the configured state backend. On orphan and two-layer backends, in linked teams, in worktrees without their own .squad and from subfolders the two read and wrote different stores, and running the CLI from a subfolder created a stray .squad. The CLI now resolves the squad the same way and opens the same store. Outside a squad it fails with a clear message; `squad memory help` still works anywhere. Closes github#2316
438bf81 to
ae2a1b7
Compare
|
Thanks Jose! I confirmed the split store bug in packages/squad-cli/src/cli/commands/memory.ts:164 ( |
What
squad memorynow opens the same governed memory store as the agents'memory.*tools insquad_state. It resolves the squad withresolveSquadState(walking up from the current folder, following worktrees and linked teams) and goes through the configured state backend. Onorphanandtwo-layerthat means thesquad-statebranch, not working-tree files. Outside a squad it now fails with a clear message instead of creating a stray.squad/.Why
Closes #2316
The CLI built
new LocalMemoryStore(new FSStorageProvider(), projectRoot), whilesquad state-mcpusesresolveSquadState(startDir)and the backend's storage. So on git backends, in linked teams, in worktrees without their own.squadand from subfolders, what an agent remembered was invisible tosquad memory, and the other way round.How
packages/squad-cli/src/cli/commands/memory.ts: a small exportedopenGovernedMemoryStore(context, startDir)buildsnew LocalMemoryStore(context.storage, context.paths.teamSquadDir, { rootKind: 'squad' }), the same constructioncreateStateMcpToolRegistryhands toToolRegistry.squad memory helpstill works outside a squad.config.json.startDir, the resolvedprojectRoot, the squad dir and the backend name.docs/src/content/docs/features/memory.md: the CLI paragraph now says it opens the same store as thememory.*tools.test/memory-store-resolution.test.tsbuilds the agents' side with the realcreateStateMcpToolRegistry, so the test fails if the two ever drift apart again. Three cases:memory.writeis found by the CLI, and a CLI write is found bymemory.search. The CLI doesn't create.squad/memory/in the working tree.packages/app/.squad.Not in this PR:
orphanortwo-layer. They still fail, becausesquad_stateitself can't handle that combination yet (squad_state fails on every call in a linked team with the orphan or two-layer backend #2320). Since the CLI now opens the same store, it fails the same way there.index.json. That was already possible: twosquad_stateservers race (for examplesquad watchwithmaxConcurrent > 1), and so do the CLI and a session on the local backend from the repo root. This PR makes the CLI share the store in the setups that used to be split, so the race becomes reachable there too. A lock key on thesquad-statebranch roughly doubled the time per write in my tests on Windows, so I'd rather agree on the locking approach separately..changeset/memory-cli-same-store.md)PR Readiness Checklist
Branch & Commit
dev(notmain)dev(rebased on 9d7dff8)Build & Test
npm run buildpassesnpm testpasses (all tests green). On my Windows machine the full suite shows the same pre-existing failures on this branch as on plaindev(gh-aw compiler, terminal and path-related suites). The few tests that differ between runs are timing-sensitive, including two memory-provider concurrency tests, and they pass when rerun alone. The memory, tools and state-mcp suites are green, and the new tests fail without the fix (3 of 3). CI is the real check here.npm run lintpasses (type check clean)npm run lint:eslintpasses on the changed files (no new warnings inmemory.ts)Changeset
@bradygaster/squad-clipatch)Docs
features/memory.md)Exports
openGovernedMemoryStoreis a new named export of the existing@bradygaster/squad-cli/commands/memoryentry point.Breaking Changes
squad memoryrun outside a squad now fails instead of silently creating<cwd>/.squad/. That includessquad memory classify, which does no storage I/O but now needs a squad to open.orphanandtwo-layer, the CLI now reads and writes thesquad-statebranch. Entries that older CLIs wrote into working-tree.squad/memory/files on those backends won't show up until they're moved over.Waivers
None.