-
Notifications
You must be signed in to change notification settings - Fork 1
Session Query
Edge adaptation of the upstream session search and query system.
Upstream reference: Session Query documentation
The Session Query provides full-text search across the session corpus. It consists of two packages:
-
dsh-session-query — service definition: query vocabulary, search document extraction (
buildSessionEventSearchDocuments), session/event filtering, and relationship tracking. - dsh-session-query-sqlite — SQLite FTS provider: maintains a full-text index updated on each event, supports ranked cross-session search with opaque cursor pagination.
The ctx.sessionQuery service is consumed by session.search in the apiproxy layer, which handles result deduplication, stale-generation restarts, and per-provider page-size probing.
Edge does not install the upstream SessionQueryEngine or the SQLite FTS provider. Instead, searchApiSessions() in session-store.ts implements a bounded linear scan:
- Scans the most recent 32 sessions (
MAX_SEARCH_SESSIONS) - For each session, loads up to 512 events (
MAX_SEARCH_EVENTS_PER_SESSION) or 256 KB (MAX_SEARCH_STORED_BYTES_PER_SESSION) - Extracts search documents using upstream's
buildSessionEventSearchDocuments() - Matches against a normalized query string
This reuses the upstream text extraction logic but bypasses the FTS index entirely.
- Search document extraction via
buildSessionEventSearchDocuments()— upstream logic, reused as-is - Search result schema (
SessionSearchItemwith snippets) — upstream format - The
session.searchAPI contract exposed to the client
Each search scans up to 32 sessions × 512 events = 16,384 events in the worst case. Events are loaded from DO SQL (live sessions) or persistence (cold sessions). The linear scan has no index — latency scales with the number of sessions and their size. For a typical deployment with a few dozen sessions, this completes in tens of milliseconds.
Sessions with more than 512 events are skipped entirely (marked as hasMore). Only the 32 most recent sessions are searched. There is no cross-session ranking — results are returned in session recency order, not relevance order.
| Component | Category | Edge Code |
|---|---|---|
| Text extraction | Reuse | buildSessionEventSearchDocuments() from upstream |
| Search engine | Replace | Linear scan in searchApiSessions() |
| FTS index | Not installed | — |
Key observation: Edge trades search quality for simplicity. The FTS index and its SQLite dependency are avoided; the search is "good enough" for personal single-user deployments with limited session counts. The text extraction is upstream code, so upgrading to full FTS later would only require installing the provider plugin.
Evaluate DO SQL FTS. Durable Objects support SQLite, which includes FTS5. The upstream dsh-session-query-sqlite provider could potentially be installed directly if its SQLite access pattern is compatible with DO's SQL API. This would replace the linear scan with indexed search, lifting the 32-session and 512-event limits.
- Home
- Architecture
- Core & Scope
- Session & Persistence
- Model & Context
-
Execution & Tools
- Tools
- Bash
- Subprocess 🚫
- PTY Session 🚫
- Background Jobs 🚫
- Filesystem
- LSP Navigation 🚫
- Code Runtime 🚫
-
Web Access
⚠️ -
Skills
⚠️ - Workflow 🚫
- Subagent 🚫
-
Policy & Interaction
- Goal
- Approval 🚫
- Permission Presets 🚫
-
Sandbox
⚠️ - Plan Mode 🚫
- User Interaction 🚫
- Commands 🚫
- Schedule 🚫
- Message Feedback 🚫
- Platform & Access
- Development
- 首页
- 架构
- 核心与作用域
- 会话与持久化
- 模型与上下文
- 执行与工具
- 策略与交互
- 平台与接入
- 开发