feat: index reasoning, and close the two-minute freshness gap #18

Closed
opened 2026-11-05 03:38:53 +00:00 by david · 0 comments
Owner

Two gaps that make the index lag behind the work.

1. Reasoning was discarded

loadOCTranscripts indexed user text and assistant text parts only. The model's reasoning — where a decision is actually justified — was explicitly excluded, so "why did you do that" was unsearchable.

It is also large: individual reasoning parts reach 175 KB. Each part is truncated to 1.2 KB and each session is budgeted 4 KB. It goes into content (searchable) but not into summary, which is what search results and MCP output display.

Bug this exposed: the session sweep skipped a session when created_at and summary matched. Content that gained reasoning behind unchanged prose was therefore never recorded. IngestResult now carries a content hash and the sweep compares it — the observation layer already used that signal internally, only the pre-check bypassed it.

2. Finished turns were stale for up to two minutes

The watcher polls opencode.db every 2 minutes. A turn was not searchable until the next tick.

  • IngestSessionsNow shares the watcher's logic (no duplication).
  • Sweeps only sessions newer than a stored watermark (opencode_sync_max_updated).
  • ~45 ms steady state vs ~21 s for a full sweep of 59k messages.
  • The plugin calls it at prompt admission, fire-and-forget, so it never delays the turn that triggers it.

Side effect: the watcher's own 2-minute sweep drops from ~20 s to ~45 ms.

Two gaps that make the index lag behind the work. ## 1. Reasoning was discarded `loadOCTranscripts` indexed user text and assistant *text* parts only. The model's reasoning — where a decision is actually justified — was explicitly excluded, so "why did you do that" was unsearchable. It is also large: individual reasoning parts reach **175 KB**. Each part is truncated to 1.2 KB and each session is budgeted 4 KB. It goes into `content` (searchable) but not into `summary`, which is what search results and MCP output display. **Bug this exposed:** the session sweep skipped a session when `created_at` and `summary` matched. Content that gained reasoning behind unchanged prose was therefore never recorded. `IngestResult` now carries a content hash and the sweep compares it — the observation layer already used that signal internally, only the pre-check bypassed it. ## 2. Finished turns were stale for up to two minutes The watcher polls `opencode.db` every 2 minutes. A turn was not searchable until the next tick. - `IngestSessionsNow` shares the watcher's logic (no duplication). - Sweeps only sessions newer than a stored watermark (`opencode_sync_max_updated`). - **~45 ms** steady state vs **~21 s** for a full sweep of 59k messages. - The plugin calls it at prompt admission, fire-and-forget, so it never delays the turn that triggers it. Side effect: the watcher's own 2-minute sweep drops from ~20 s to ~45 ms.
david closed this issue 2026-11-05 03:39:17 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#18