fix(server): refuse memory writes for a workspace that does not exist (UF-039)

POST /api/memory/frames, /api/quick-capture and the Memory Center's
POST /api/memory saved a memory meant for an unknown workspace into
personal memory, which every workspace reads. They now answer 404
workspace_not_found and write nothing; a request without a workspace
still goes to personal memory.
This commit is contained in:
shumeiko.it
2026-10-24 18:09:43 +02:00
parent 4dbab2cb8b
commit 8a9ba09ad9
6 changed files with 61 additions and 10 deletions

View File

@@ -67,6 +67,7 @@ Baseline: commit `b20b138` of `git.os-dev.tech/oleg.m/waggle-os`.
| UF-036 | The web client reads "important" and "temporary" memories as normal importance | Fixed | Web UI, memory |
| UF-037 | Restore overwrites database files the running sidecar holds open | Open | Sidecar, backup |
| UF-038 | Marketplace installs never notify the running sidecar | Open | Marketplace, sidecar |
| UF-039 | A memory saved to an unknown workspace lands in personal memory | Fixed | Sidecar, memory, privacy |
## Entries
@@ -384,3 +385,12 @@ Entries UF-010 to UF-019 come from the UI audit `anti-slop/audit-001-2026-10-14.
- Cause: the installer posts to port 3000, while the sidecar listens on 3333 by default and nothing sets `WAGGLE_API_URL`; the request also carries no session token, which the sidecar requires. The error is swallowed (`// Server not running`).
- What we did: nothing yet.
- Recommendation: when the installer runs inside the sidecar (the Marketplace routes), call the reload logic directly instead of over HTTP; for the standalone CLI, take the port and token from the running sidecar.
### UF-039. A memory saved to an unknown workspace lands in personal memory
- Status: Fixed
- Found: 2026-10-24
- Where: at commit `b20b138`, `packages/server/src/local/routes/memory.ts:417-427` (`POST /api/memory/frames`: `getWorkspaceMindDb(workspace)` returns null for an unknown id, and the frame goes to `server.multiMind.personal`); the same fallback in `POST /api/quick-capture` and `POST /api/memory` (Memory Center)
- Symptom: a memory sent for a workspace that does not exist, for example one deleted in another window or a mistyped id, is saved without an error into personal memory, which every workspace reads. Searching from any other workspace then returns it. The e2e isolation tests (`competitive-benchmarks` B2.4, `user-behavior` U2.4) passed only because the legacy full-text search rejected their hyphenated queries with HTTP 400.
- Cause: the routes treat an unknown workspace the same as no workspace.
- What we did: the three write routes save to personal memory only when no workspace is named and answer 404 `workspace_not_found` for a workspace that does not exist (`writeScopeForWorkspace` in `memory-records.ts`).
- Recommendation: refuse writes for unknown workspaces in the main project as well.