Skip to content

FTS5 session search and skill curator lifecycle - #77

Merged
ApiliumDevTeam merged 3 commits into
devfrom
chore/tier2-curator-fts5
Jul 14, 2026
Merged

ApiliumDevTeam merged 3 commits into
devfrom
chore/tier2-curator-fts5

Conversation

@ApiliumDevTeam

Copy link
Copy Markdown
Collaborator

Summary

Two Tier 2 features: fast full-text session search and automatic skill lifecycle management.

FTS5 session search

  • Dedicated SQLite FTS5 index (~/.mayros/agents/<agentId>/sessions/search.sqlite) with BM25 ranking, multi-word query support, role/timestamp/session filters, and snippet generation.
  • Incremental indexing: lazy sync on each query, skipping unchanged files by mtime+size. No background watchers needed.
  • The public searchSessions API is unchanged — tries FTS5 first, falls back to the linear substring scan when node:sqlite is unavailable.

Skill curator lifecycle

  • Activity tracking: JSON sidecar (~/.mayros/skills/skill-activity.json) records lastInvokedAt, invocationCount, firstInvokedAt per skill.
  • Lifecycle metadata: MayrosSkillMetadata extended with state, pinned, created, updated frontmatter fields.
  • Auto-transition sweep: active → stale (30 days inactive), stale → archived (90 days). Pinned skills are never transitioned. Only agent-created skills are eligible for archival. Archived skills move to ~/.mayros/skills.archived/.

Test plan

  • pnpm tsgo — 0 errors
  • pnpm lint — 0 errors, 358 warnings
  • pnpm exec vitest run src/infra/ src/agents/skills/ — 57 passed, 0 failed
  • FTS5 tests: schema, indexing, BM25 search, role/time filters, incremental sync
  • Activity store tests: read/write, invocation recording, day calculation
  • Existing session-search and skills tests pass unchanged

Follow-up

The LLM consolidation pass (Commit 3 of the plan) is deferred to a separate session — it requires an isolated agent turn and clustering logic that benefits from focused implementation.

Replace the linear substring scan with a dedicated SQLite FTS5 index for
session message search. The index lives at
~/.mayros/agents/<agentId>/sessions/search.sqlite and uses an
external-content virtual table with triggers for automatic sync.

The search now supports multi-word queries with BM25 relevance ranking,
role/timestamp/session filters, and snippet generation via the FTS5
snippet() function. Indexing is incremental (lazy sync on each query,
skipping unchanged files by mtime+size), so no background watchers are
needed.

The public searchSessions API is unchanged — it tries FTS5 first and
falls back to the original linear scan when node:sqlite is unavailable,
so search always works regardless of the runtime.
Replace the linear substring scan with a dedicated SQLite FTS5 index for
session message search. The index lives at
~/.mayros/agents/<agentId>/sessions/search.sqlite and uses an
external-content virtual table with triggers for automatic sync.

The search now supports multi-word queries with BM25 relevance ranking,
role/timestamp/session filters, and snippet generation via the FTS5
snippet() function. Indexing is incremental (lazy sync on each query,
skipping unchanged files by mtime+size), so no background watchers are
needed.

The public searchSessions API is unchanged — it tries FTS5 first and
falls back to the original linear scan when node:sqlite is unavailable,
so search always works regardless of the runtime. Results are sorted by
timestamp descending and sessionsSearched counts files scanned, matching
the original contract.
Add a skill lifecycle manager that automatically transitions skills
through active → stale → archived states based on invocation activity.

Activity tracking (activity-store.ts): a JSON sidecar at
~/.mayros/skills/skill-activity.json records lastInvokedAt,
invocationCount, and firstInvokedAt per skill. Updated on every skill
invocation.

Lifecycle metadata: extend MayrosSkillMetadata with state, pinned,
created, and updated fields. Parsed from SKILL.md frontmatter.

Curator sweep (skill-curator.ts): a self-throttled background sweep
(mirroring session-reaper.ts) that transitions active skills to stale
after 30 days of inactivity and stale skills to archived after 90 days.
Pinned skills are never transitioned. Only agent-created skills
(source: mayros-managed) are eligible for archival — user skills can
go stale but are never auto-archived. Archived skills are moved to
~/.mayros/skills.archived/.
@ApiliumDevTeam
ApiliumDevTeam merged commit 410223f into dev Jul 14, 2026
7 of 8 checks passed
@ApiliumDevTeam
ApiliumDevTeam deleted the chore/tier2-curator-fts5 branch July 14, 2026 17:08
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