Repository navigation
fix(swarm-mail): stop status default corrupting new memories #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||
| --- | ||||
| "opencode-swarm-plugin": patch | ||||
| "swarm-mail": patch | ||||
| --- | ||||
|
|
||||
| ## 🐝 Memories Were Whispering Into a Room With No Door | ||||
|
|
||||
| > "Program testing can be used to show the presence of bugs, but never to show their absence." — Edsger W. Dijkstra | ||||
|
|
||||
| **What changed:** | ||||
| - `packages/swarm-mail/src/db/schema/memory.ts`: the Drizzle column default for `status` carried literal quote characters — `.default("'active'")` instead of `.default("active")`. `store()` never sets `status` explicitly, so every memory was written with the 8-character string `'active'` (quotes included, as data) instead of the correct 6-character `active`. | ||||
| - `search()` and `ftsSearch()` filter on `status = 'active'`, so every corrupted row silently became permanently unsearchable — while `getStats()` kept counting the rows and reporting a perfectly healthy corpus. Store succeeds, search returns nothing, stats lies. Indistinguishable from an empty index. | ||||
| - Added a regression test that reads the *raw* `status` column value straight off `store()`'s output, not just round-trip search behavior — the existing widened `statusFilter` (`m.status = 'active' OR m.status = '''active'''`) already masks this bug on the read side, so only a direct column read catches the write-side corruption. | ||||
|
|
||||
| **Why it matters:** | ||||
|
|
||||
| Found in the wild: this silently disabled semantic memory across a full multi-agent session. Every agent's "no prior results" looked exactly like a legitimately empty index — no error, no warning, nothing to notice, right up until someone checked the raw column against the stats count by hand. | ||||
|
|
||||
| **Migration:** none needed. The existing `statusFilter` widening (already on `main`, unchanged by this patch) keeps pre-existing corrupted rows searchable — this fix only stops *new* writes from being corrupted going forward. The widening can be dropped in a future major version once old installs have aged out. | ||||
|
|
||||
| **Backward compatible:** yes — no data is lost or requires backfill; previously-corrupted rows stay reachable through the existing filter, they just stop multiplying. | ||||
|
|
||||
| ``` | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Specify a language for the fenced block.
Proposed fix-```
+```text📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.23.2)[warning] 23-23: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||
| ,-.__,-. | ||||
| ( o o ) "getStats() says I'm fine." | ||||
| \ ^ / "search() says I don't exist." | ||||
| `-----' turns out: I was written with my own name in quotes. | ||||
| ``` | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: joelhooks/swarm-tools
Length of output: 50379
🏁 Script executed:
Repository: joelhooks/swarm-tools
Length of output: 31806
🏁 Script executed:
Repository: joelhooks/swarm-tools
Length of output: 35382
Require migration guidance for the
memories.statusdefault fix.default("active")does not change the default in existing SQLitememoriescolumns or update rows wherestatusalready stores'''active'''. Either add an ALTER/fix migration or update this changeset to document the required deployment/manual update step instead of saying “Migration: none needed.”🤖 Prompt for AI Agents