Skip to content

fix(state): narrow FTS UPDATE triggers to payload-bearing columns - #73113

Closed
smfworks wants to merge 1 commit into
NousResearch:mainfrom
smfworks:main
Closed

fix(state): narrow FTS UPDATE triggers to payload-bearing columns#73113
smfworks wants to merge 1 commit into
NousResearch:mainfrom
smfworks:main

Conversation

@smfworks

Copy link
Copy Markdown
Contributor

Narrow the messages_fts_update and messages_fts_trigram_update triggers to only fire when content, tool_name, or tool_calls actually change, instead of on every UPDATE (including status-only writes like the active flag). On a ~447k-message DB this eliminates multi-GB of redundant FTS churn per SessionDB open.

Migration contract (per review of the FTS trigger narrowing PR):

  • Inspect sqlite_master.sql; only migrate when an existing UPDATE trigger is broad (no WHEN clause).
  • Drop only the two UPDATE triggers, recreate with individual cursor.execute() calls (not executescript).
  • Keep INSERT/DELETE triggers present throughout.
  • Do NOT rebuild FTS: broad triggers may have over-indexed unchanged payload, but have not missed content updates.
  • Idempotent: reopening an already-converged DB performs reads only.

Fixes #68891

Narrow the messages_fts_update and messages_fts_trigram_update triggers
to only fire when content, tool_name, or tool_calls actually change,
instead of on every UPDATE (including status-only writes like the active
flag). On a ~447k-message DB this eliminates multi-GB of redundant FTS
churn per SessionDB open.

Migration contract (per review of the FTS trigger narrowing PR):
- Inspect sqlite_master.sql; only migrate when an existing UPDATE
  trigger is broad (no WHEN clause).
- Drop only the two UPDATE triggers, recreate with individual
  cursor.execute() calls (not executescript).
- Keep INSERT/DELETE triggers present throughout.
- Do NOT rebuild FTS: broad triggers may have over-indexed unchanged
  payload, but have not missed content updates.
- Idempotent: reopening an already-converged DB performs reads only.

Fixes NousResearch#68891
@alt-glitch alt-glitch added type/perf Performance improvement or optimization P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state duplicate This issue or pull request already exists labels Jul 28, 2026
@smfworks

Copy link
Copy Markdown
Contributor Author

Superseded by #73639 — same 13 FTS commits cherry-picked onto current upstream/main with zero conflicts. This PR was conflicting due to fork divergence between smfworks:main and upstream.

@smfworks smfworks closed this Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants