Skip to content

fix(swarm-mail): stop status default corrupting new memories - #206

Open
srmcguirt wants to merge 3 commits into
joelhooks:mainfrom
srmcguirt:fix/memory-status-default-quotes
Open

srmcguirt wants to merge 3 commits into
joelhooks:mainfrom
srmcguirt:fix/memory-status-default-quotes

Conversation

@srmcguirt

@srmcguirt srmcguirt commented Aug 6, 2026 •

Copy link
Copy Markdown

Summary

Fixes a silent data-corruption bug in swarm-mail's memory store: every stored memory got status = "'active'" (8 chars, literal embedded quotes) instead of status = "active" (6 chars). search() and ftsSearch() filter on status = 'active', so every write silently became permanently unsearchable while getStats() kept reporting a healthy corpus. Store succeeds, search returns empty, stats lies — indistinguishable from a legitimately empty index.

Found in the wild: this silently disabled semantic memory across a full multi-agent session. Every agent's "no prior results" query looked exactly like a correctly-empty index — there was no error, no warning, nothing to notice. Only caught by manually inspecting the raw status column against getStats()'s reported count.

Related issue

Addresses #176 (not using a closing keyword — see why below).

#176 documents the same root-cause class of bug — .default() receiving a SQL-literal string instead of a JS value — across eight .default() calls in memory.ts. This PR fixes exactly one of them: status (line 86 in the issue, the one causing the reported symptom of hivemind_find returning 0 results). The other six the issue's own table lists as broken — metadata, collection, tags, created_at, updated_at, last_accessed — are not touched by this PR and are still broken on this branch as of this commit (access_count was already fine per the issue). Merging this with a Fixes #176 keyword would auto-close an issue that isn't fully resolved.

I deliberately didn't fold the other six into this PR — this fix is narrowly scoped, tested, and has a fails-without/passes-with demonstration for exactly the status bug. Widening it would mix an easy, well-understood, already-verified fix with five more schema changes (including two that need sql template literals for the datetime('now') defaults, a different fix shape) that haven't been through the same rigor. Suggest either: keep #176 open and re-scope its title/checklist to the remaining six, or I'm happy to open a narrowly-scoped follow-up PR for them once this one lands — your call.

Bug flow

 WRITE PATH                                    READ PATH
 ══════════                                    ═════════

 store(memory)                                 search(query) / ftsSearch(query)
      │                                              │
      ▼                                              ▼
 status omitted from .values()                WHERE (m.status IS NULL
      │                                              OR m.status = 'active')
      ▼                                              │
 Drizzle client-side default kicks in                │
 (memory.ts schema):                                 │
   .default("'active'")                              │
      │                                              │
      ▼                                              │
 INSERT binds status = "'active'"                    │
 (8 chars, quotes included as data) ──────────X───────┘
      │                                     never matches
      ▼                                   ("'active'" != "active")
 Row committed successfully                          │
      │                                              ▼
      ▼                                       0 results returned
 getStats() counts the row:                          │
 "13/13 memories, healthy" ◄──────────────────────────┘
      │                                    (stats and search disagree —
      ▼                                     stats has no idea search is
 Silent, total, invisible corruption        filtering everything out)

Root cause

packages/swarm-mail/src/db/schema/memory.ts:

status: text("status").default("'active'"), // BUG: literal quote chars

This looks like a copy-paste artifact from a raw-SQL default string, and it's easy to miss on review because the table's raw CREATE TABLE DDL (libsql-schema.ts) already has the correct DEFAULT 'active'. Reading just the DDL, everything looks fine.

But Drizzle's SQLite dialect doesn't route through the DDL default at all when a column is omitted from .values(). It binds .default() as a client-side insert parameter instead — confirmed in node_modules/drizzle-orm/sqlite-core/dialect.js:

defaultValue = is(col.default, SQL) ? col.default : sql.param(col.default, col);

Whatever string the JS-level .default() was given gets bound literally as the parameter value. The correct raw-SQL DDL default is never consulted for this path — it's dead code as far as Drizzle-issued inserts are concerned. store() never sets status explicitly, so every INSERT bound the 8-character string 'active' (with the quote characters as literal data) instead of the 6-character active.

Why this survives casual review: the DDL is correct, the column name is correct, the intent (// active, superseded) is stated right there in the comment — the only thing wrong is two stray characters buried in a .default() call, and the failure mode (silent, 100% reproducible, but invisible in stats) gives no signal to go looking for it.

Why a swarm-mail-only fix doesn't reach the shipped binary

opencode-swarm-plugin's build (packages/opencode-swarm-plugin/scripts/build.ts) has three targets:

  • Library (dist/index.js, dist/plugin.js) — swarm-mail is external, resolved from node_modules at runtime.
  • CLI (dist/bin/swarm.js — what the hivemind_* MCP tools actually shell out to) — swarm-mail is explicitly not external. Build script's own comment: "swarm-mail is bundled into CLI to avoid version mismatch issues with global install."
  • Marketplace bundle (dist/marketplace/index.js) — same story, bundled because that distribution ships with no node_modules.

So the CLI binary is a frozen snapshot of swarm-mail source at last build time. Patching only the standalone swarm-mail package (e.g. a local bun add swarm-tools@patched) changes nothing the CLI executes — the fix has to land in swarm-mail source and get rebuilt through opencode-swarm-plugin for dist/bin/swarm.js / dist/marketplace/index.js to pick it up. Verified directly against a from-source rebuild: grep -c 'default("active")' against dist/bin/swarm.js and dist/marketplace/index.js shows the fix present in both after rebuild, dist/index.js / dist/plugin.js show 0 (expected — external there).

This is also why the changeset (below) bumps both packages, not just swarm-mail — a swarm-mail-only version bump wouldn't trigger changesets/action to republish opencode-swarm-plugin, so the CLI/marketplace tarballs on npm would stay frozen at the pre-fix source forever.

The fix

(a) Schema default — the actual bug, one line:

-  status: text("status").default("'active'"), // active, superseded
+  status: text("status").default("active"), // active, superseded

(b) Status filter widening — already present in main (search() and ftsSearch() in store.ts, both already carry):

sql`AND (m.status IS NULL OR m.status = 'active' OR m.status = '''active''')`

This is a compat shim so memories already written by unpatched installs (with the corrupted 'active' literal already sitting in their status column) stay searchable instead of being silently orphaned by (a). This half was already correct on main and required no change — this PR only needed (a). Both halves together: (a) stops new corruption, (b) keeps old corrupted rows reachable. (b) can be dropped in a future major version once corrupted rows have aged out / been backfilled, since it's pure legacy-compat surface.

Test

Added to store.drizzle.test.ts, a new describe("Memory Store (Drizzle) - Status Corruption Regression") block. The key test asserts the raw status column value after store(), not just search behavior:

const rows = await db.all<{ status: string }>(
  sql`SELECT status FROM memories WHERE id = ${memory.id}`,
);
expect(rows[0]?.status).toBe("active");

This distinction matters: a naive store() → find()/search() round-trip test does not catch this bug, because the filter widening in (b) already masks it — a corrupted row is still findable through the widened OR m.status = '''active''' clause. The only way to catch the write-side bug is to inspect the column directly. That's exactly why it survived undetected — every "does search still work" sanity check passes even with the schema bug present.

Plus:

  • End-to-end store() → search() round trip
  • End-to-end store() → ftsSearch() round trip
  • Regression guard: search() still finds a row with the legacy-corrupted status value (protects against (b) being narrowed again later)

Demonstrated fails-without-fix / passes-with-fix

Reverted the schema line locally, reran:

$ bun test src/memory/store.drizzle.test.ts
error: expect(received).toBe(expected)
Expected: "active"
Received: "'active'"
(fail) Memory Store (Drizzle) - Status Corruption Regression > store() writes a clean 'active' status, not a quoted literal [0.66ms]
 17 pass
 1 fail

Restored the fix, reran:

$ bun test src/memory/store.drizzle.test.ts
 18 pass
 0 fail
 39 expect() calls

Maintainers can rerun this yourselves: revert the one-line diff in memory.ts above, run the targeted test, confirm the Expected: "active", Received: "'active'" failure, then restore it and confirm green.

Verification

$ bun test src/memory/store.drizzle.test.ts     # targeted
 18 pass
 0 fail

$ bun test src/                                  # full swarm-mail suite
 1300 pass
 50 skip
 0 fail
 3318 expect() calls
Ran 1350 tests across 92 files.

$ bunx tsc --noEmit                              # clean, no output

One flaky, unrelated failure (session-handoff.test.ts, an ordering assertion — Expected: 8, Received: 9) appeared on the first full-suite run and was gone on rerun. Reproduced independently against this branch's unmodified tip by stashing this PR's changes and rerunning in isolation — same intermittent failure, confirming it's a pre-existing timing flake in that test's own setup, unrelated to this change. Flagging so it isn't mistaken for something this PR introduced.

For the maintainer — release housekeeping

A few things that make this land cleanly with minimal back-and-forth:

Changeset — added .changeset/fix-memory-status-default-quotes.md, patch-level for both opencode-swarm-plugin and swarm-mail, following the "lore" convention documented in AGENTS.md (epigraph, before/after, ASCII art). Bumps both packages for the vendoring reason described above — matches the precedent set by .changeset/fix-memory-database-path.md, an earlier memory-layer fix that did the same for the same reason.

Data migration — not needed. The existing statusFilter widening in search()/ftsSearch() (unchanged by this PR, already on main) keeps rows with the corrupted 'active' literal permanently searchable. Installs running the buggy version don't need any backfill; they just stop accumulating new corruption once this ships. A normalization migration to actually clean up the corrupted rows would be a nicer end state but is out of scope here — flagging it as a possible future cleanup, not blocking.

Vouch — already satisfied, no action needed on your end. srmcguirt is already in .github/VOUCHED.td, which is presumably why this PR wasn't auto-closed by vouch-check-pr.yml.

CI status — as of this update, Vercel shows failure, but that's an expected team-authorization gate on preview deploys for external contributors (unrelated to this change — it needs a team member to click "authorize" in the Vercel dashboard, not a code fix). CodeRabbit and both Socket Security checks pass. CI and Eval Gate haven't run at all yet — no workflow runs exist for this commit — because GitHub requires a maintainer to approve workflow runs for a first-time contributor. Whenever you get a moment: "Approve and run workflows" on this PR.

Issue linking — see the "Related issue" section above; used Addresses #176 rather than a closing keyword since #176 documents more than this PR fixes.


Test summary

Suite Result
Targeted regression tests 18 pass / 0 fail
Full swarm-mail suite 1300 pass / 50 skip / 0 fail
Typecheck (tsc --noEmit) clean
Fails-without-fix demonstration confirmed (Expected: "active", Received: "'active'")
Changeset added, patch × 2 packages (swarm-mail, opencode-swarm-plugin)

Credits

Bug found the hard way, in production, by a multi-agent swarm quietly losing all its memory for an entire session while reporting itself perfectly healthy. Root-caused down to the Drizzle dialect source. No AI agents were harmed in the making of this fix, though several were mildly confused about why nothing they remembered was coming back.

   ___
  /___\   status: "'active'"  ➜  status: "active"
 |     |
 | o o |   the extra quotes are gone now.
 |  ∪  |   ship it.
  \___/

Summary by CodeRabbit

  • Bug Fixes
    • New memories now receive the correct active status automatically.
    • Improved memory search reliability for both newly created memories and existing records.
    • Added support for finding memories through vector and full-text search, including legacy records.

db/schema/memory.ts's Drizzle column default for status contained
literal quote characters: .default("'active'"). Drizzle's SQLite
dialect binds .default() as a client-side insert parameter whenever
a column is omitted from .values() (confirmed in
node_modules/drizzle-orm/sqlite-core/dialect.js), independent of
whatever the table's raw-SQL DDL default says. store() never sets
status explicitly, so every memory was written with the 8-char
literal '\''active'\'' instead of the 6-char active.

search() and ftsSearch() already carry a widened statusFilter
(m.status = '\''active'\'' OR m.status = '\'''\'''\''active'\'''\'''\''\'') added in an
earlier unpublished fix, so legacy rows written by unpatched installs
remain searchable. That half was correct; this commit fixes the other
half so new writes stop being corrupted in the first place. Both
halves are required together.

Adds a regression suite (store.drizzle.test.ts) that asserts the raw
status column value after store(), plus end-to-end store->search()/
ftsSearch() round-trips, plus a case simulating a legacy-corrupted
row to prove the search-side widening still covers old installs.

Verified: rebuilt opencode-swarm-plugin and confirmed the fix reaches
dist/bin/swarm.js and dist/marketplace/index.js, which bundle
swarm-mail's source directly (CLI/marketplace builds mark swarm-mail
non-external specifically to avoid global-install version skew) -
patching the swarm-mail npm package alone does not affect the CLI
binary that hivemind_* tools actually invoke.
@srmcguirt
srmcguirt requested a review from joelhooks as a code owner August 6, 2026 19:50
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

@srmcguirt is attempting to deploy a commit to the joelhooks' projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The memory status default now stores active without SQL quoting. Integration tests verify new memory storage, vector and FTS retrieval, and compatibility with legacy rows containing quoted status values.

Changes

Memory status handling

Layer / File(s) Summary
Correct and document the status default
packages/swarm-mail/src/db/schema/memory.ts, .changeset/fix-memory-status-default-quotes.md
The memories.status column now uses the plain active default. The changeset documents the fix and compatibility with existing rows.
Validate status storage and search
packages/swarm-mail/src/memory/store.drizzle.integration.test.ts
Integration tests verify unquoted status writes, vector and FTS retrieval, and searchability of legacy quoted status values. Test setup imports and insertion formatting were updated.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related issues

  • Issue 176 — Addresses the same memories.status Drizzle default bug and its search failures.

Suggested reviewers: joelhooks

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the fix to the swarm-mail memory status default that corrupts new memory records.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/swarm-mail/src/memory/store.drizzle.test.ts (1)

364-364: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the integration-test file suffix.

This suite creates and queries a libSQL database. Rename packages/swarm-mail/src/memory/store.drizzle.test.ts to packages/swarm-mail/src/memory/store.drizzle.integration.test.ts.

As per coding guidelines, “.integration.test.ts” is required for integration tests that use libSQL or the filesystem.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/swarm-mail/src/memory/store.drizzle.test.ts` at line 364, Rename the
test file containing the “Memory Store (Drizzle) - Status Corruption Regression”
suite to use the .drizzle.integration.test.ts suffix, preserving all test
contents and behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/swarm-mail/src/memory/store.drizzle.test.ts`:
- Around line 378-410: Replace the per-test client setup in the test suite’s
beforeEach with a shared createInMemorySwarmMail() instance initialized in
beforeAll and closed in afterAll. Build the Drizzle client and memory store from
that shared database, and preserve test isolation by clearing records between
tests or using unique memory IDs.
- Around line 467-486: Add a dedicated test alongside the existing legacy-status
search test that stores a memory, updates its status to the literal legacy value
'''active''', and calls ftsSearch() with a matching query. Assert that the
returned results include the legacy memory, covering the separate ftsSearch
status-filter path.

---

Nitpick comments:
In `@packages/swarm-mail/src/memory/store.drizzle.test.ts`:
- Line 364: Rename the test file containing the “Memory Store (Drizzle) - Status
Corruption Regression” suite to use the .drizzle.integration.test.ts suffix,
preserving all test contents and behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b14e868-effc-408b-a3fb-03bef95f7599

📥 Commits

Reviewing files that changed from the base of the PR and between b685253 and 26e355f.

📒 Files selected for processing (2)
  • packages/swarm-mail/src/db/schema/memory.ts
  • packages/swarm-mail/src/memory/store.drizzle.test.ts

Comment on lines +378 to +410
beforeEach(async () => {
const client = createClient({ url: ":memory:" });

await client.execute(`
CREATE TABLE memories (
id TEXT PRIMARY KEY,
content TEXT NOT NULL,
metadata TEXT DEFAULT '{}',
collection TEXT DEFAULT 'default',
tags TEXT DEFAULT '[]',
created_at TEXT DEFAULT (datetime('now')),
updated_at TEXT DEFAULT (datetime('now')),
decay_factor REAL DEFAULT 1.0,
embedding F32_BLOB(1024),
valid_from TEXT,
valid_until TEXT,
superseded_by TEXT REFERENCES memories(id),
auto_tags TEXT,
keywords TEXT,
access_count TEXT DEFAULT '0',
last_accessed TEXT DEFAULT (datetime('now')),
category TEXT,
status TEXT DEFAULT 'active'
)
`);
await client.execute(`
CREATE INDEX idx_memories_embedding
ON memories(libsql_vector_idx(embedding))
`);

db = createDrizzleClient(client);
store = createMemoryStore(db);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use the shared in-memory test database helper.

Line 379 creates a libSQL client directly for every test. Create the test database through createInMemorySwarmMail() in beforeAll, and close it in afterAll. Keep test records isolated by ID or clean them between tests.

As per coding guidelines, use createInMemorySwarmMail() for tests and prefer shared database instances through beforeAll and afterAll.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/swarm-mail/src/memory/store.drizzle.test.ts` around lines 378 - 410,
Replace the per-test client setup in the test suite’s beforeEach with a shared
createInMemorySwarmMail() instance initialized in beforeAll and closed in
afterAll. Build the Drizzle client and memory store from that shared database,
and preserve test isolation by clearing records between tests or using unique
memory IDs.

Source: Coding guidelines

- Use shared createInMemorySwarmMailLibSQL() + toSwarmDb() harness in
  beforeAll/afterAll instead of a per-test raw libSQL client, per the
  libSQL testing pattern documented in AGENTS.md. Drops the hand-rolled
  CREATE TABLE / CREATE VIRTUAL TABLE DDL in favor of the real
  createLibSQLMemorySchema() migration path (FTS5 table + triggers
  included), so inserts now hit the same schema production does.
- Rename store.drizzle.test.ts -> store.drizzle.integration.test.ts to
  match the documented suffix convention for tests touching libSQL.
- Add a legacy-status ftsSearch() regression test mirroring the
  existing search() legacy-status case; ftsSearch() has its own status
  filter and was untested for the corrupted-status scenario.

The raw-column assertion in the original regression test is preserved
unchanged: it reads status directly via db.all(sql`SELECT status ...`),
which is what actually catches the write-side bug. A store->find
round-trip would not, since the widened statusFilter already masks
corrupted rows on the read path.
@srmcguirt

Copy link
Copy Markdown
Author

Thanks for the review — all three points are valid and match the AGENTS.md testing conventions:

  • Switched to createInMemorySwarmMailLibSQL() + toSwarmDb() in beforeAll/afterAll. This also drops the duplicated schema DDL in favour of the real migration path (including FTS5 setup), so it's a net simplification rather than just a style change.
  • Renamed to .drizzle.integration.test.ts per the documented suffix convention.
  • Added the legacy-status ftsSearch() case to mirror the existing search() coverage — that was a genuine gap.

The raw-column assertion is kept deliberately: a store→find round-trip doesn't detect this bug, because the widened statusFilter masks the corrupted value. Asserting the stored status directly is what makes the test fail without the schema fix.

Verified the regression test still catches the bug after the refactor — reverted the one-line schema default back to .default("'active'") and reran: Expected: "active", Received: "'active'" (1 fail, as expected). Restored the fix: 19/19 pass. Full swarm-mail suite: 1300 pass / 50 skip / 1 fail (pre-existing session-handoff.test.ts ordering flake, unrelated to this change and reproducible on the unpatched base commit too). tsc --noEmit clean.

Note CI hasn't run yet — CI / Eval Gate are at action_required pending maintainer approval for a first-time contributor, so the suite results above are local only.

Adds a patch-level changeset for both swarm-mail and opencode-swarm-plugin.
Both need bumping: opencode-swarm-plugin's CLI/marketplace build bundles
swarm-mail's source directly (non-external, per build.ts comment - avoids
global-install version skew), so a swarm-mail-only version bump would not
by itself trigger a republish of the CLI binary that actually contains the
fix. This mirrors the precedent in .changeset/fix-memory-database-path.md,
an earlier memory-layer fix that bumped both packages together for the
same reason.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.changeset/fix-memory-status-default-quotes.md:
- Line 23: Update the fenced code block in fix-memory-status-default-quotes.md
to specify the text language by changing its opening fence to use text, while
preserving the ASCII-art content and closing fence.
- Around line 19-21: Update the changeset’s migration guidance for the
memories.status default fix: remove the claim that no migration is needed and
document the required deployment/manual database update step, or add the
corresponding ALTER/fix migration. Ensure it addresses both existing SQLite
column defaults and rows containing the corrupted '''active''' value.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 866605fc-b7ff-4b8f-ba3e-a4792b0586dd

📥 Commits

Reviewing files that changed from the base of the PR and between ab5b192 and 498e38c.

📒 Files selected for processing (1)
  • .changeset/fix-memory-status-default-quotes.md

Comment on lines +19 to +21
**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.

Copy link
Copy Markdown

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:

#!/bin/bash
set -euo pipefail

fd -t f . packages/swarm-mail | sort | while IFS= read -r file; do
  if rg -q 'drizzle|migrat|CREATE TABLE|memories|status' "$file"; then
    printf '\n### %s\n' "$file"
    rg -n -C 4 'drizzle|migrat|CREATE TABLE|memories|status' "$file"
  fi
done

Repository: joelhooks/swarm-tools

Length of output: 50379


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Find relevant schema/migration/store files\n'
fd -t f 'memory.ts|migrations.ts|store.ts$|migrations' packages/swamp-mail packages/swarm-mail 2>/dev/null || true

printf '\nMemory schema around statusFilter/default\n'
sed -n '70,95p' packages/swarm-mail/src/db/schema/memory.ts 2>/dev/null || true

printf '\nMemory store read filter around statusFilter\n'
sed -n '220,240p' packages/swarm-mail/src/memory/store.ts 2>/dev/null || true

printf '\nMemory migrations definitions\n'
sed -n '1,220p' packages/swarm-mail/src/memory/migrations.ts 2>/dev/null || true

printf '\nMemory schema exports and imports\n'
rg -n "memory|create.*memory|schema_|schemaVersion|version.*memory|statusFilter" packages/swarm-mail/src -g '*.{ts,tsx,js,jsx}' | head -n 200

Repository: joelhooks/swarm-tools

Length of output: 31806


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Memory migrations remaining definitions\n'
sed -n '220,420p' packages/swarm-mail/src/memory/migrations.ts

printf '\nMemory migrations array exports\n'
rg -n "memoryMigrations|memorySchemaOverhaulLibSQL|memoryMigrationsLibSQL|version.*1[0-2][0-9]?|status" packages/swarm-mail/src/memory/migrations.ts packages/swarm-mail/src/memory -g '*.ts' | head -n 200

printf '\nMemory store write/insert status usages\n'
rg -n -C 4 "status|statusFilter|status.*active|new\(|insert|storeMemory|MemoryAdapter|default" packages/swarm-mail/src/memory/store.ts packages/swarm-mail/src/memory/adapter.ts packages/swarm-mail/src/memory -g '*.ts' | head -n 260

Repository: joelhooks/swarm-tools

Length of output: 35382


Require migration guidance for the memories.status default fix.

default("active") does not change the default in existing SQLite memories columns or update rows where status already 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
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.changeset/fix-memory-status-default-quotes.md around lines 19 - 21, Update
the changeset’s migration guidance for the memories.status default fix: remove
the claim that no migration is needed and document the required
deployment/manual database update step, or add the corresponding ALTER/fix
migration. Ensure it addresses both existing SQLite column defaults and rows
containing the corrupted '''active''' value.


**Backward compatible:** yes — no data is lost or requires backfill; previously-corrupted rows stay reachable through the existing filter, they just stop multiplying.

```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

markdownlint-cli2 reports MD040 for this fence. Use text for the ASCII-art block.

Proposed fix
-```
+```text
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

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 Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.changeset/fix-memory-status-default-quotes.md at line 23, Update the fenced
code block in fix-memory-status-default-quotes.md to specify the text language
by changing its opening fence to use text, while preserving the ASCII-art
content and closing fence.

Source: Linters/SAST tools

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant