포스트

Operating a Personal RAG System: Storage, Recovery, and Observability

Part 3: avoiding repeated full-index construction, fixing FTS cleanup, resuming interrupted workers, and making dashboard metrics honest.

Operating a Personal RAG System: Storage, Recovery, and Observability

Personal Session Memory · Part 3 of 4

1. Archive · 2. Retrieval · 3. Operations · 4. Recall

A Working Query Is Not the Same as a Working System

My local retrieval stack uses Ollama for embeddings, LanceDB for vectors, and SQLite for text and keyword search. Getting its first useful result did not settle the operational questions.

How much disk would repeated updates consume? Could a long build survive the coding-agent session that launched it? Was a dashboard reporting useful progress, or merely repeating an old running flag?

This part covers the problems I encountered after retrieval worked: storage growth, slow cleanup, interrupted work, and metrics that required more interpretation than a green status badge could provide.

Stop Rebuilding the World for a Small Change

An early update path recreated the search acceleration index over the whole corpus even for a small change. With roughly 530,000 chunks, an index could be on the order of 2 GiB. Old versions and other generated copies added to the footprint.

That was not an unavoidable property of RAG. The update path needed to distinguish three operations:

  1. Incorporating changed data into an existing index.
  2. Constructing an index when one does not yet exist.
  3. Reclaiming data no longer needed by retained versions.

I switched existing-index updates to incremental optimization, kept garbage collection separate from index construction, and made unchanged checkpoints reuse the serving generation. Cleanup itself must not invoke an optimization routine that can commit another physical index version.

I also separated the schedules. Archival capture runs roughly hourly; automatic search updates run at 04:00 KST, after a successfully published archive capture that satisfies the daily gate. Preserving new records and paying the cost of refreshing search do not need the same frequency.

“One Generation” Is a Retention Policy

A search generation is a coherent published set: a source checkpoint, text catalog, configuration, and pinned vector-table version. It is not one conversation or one day’s messages.

The publication sequence is:

1
2
3
4
5
Keep serving the old generation
  -> build or resume a candidate
  -> validate vector/catalog agreement
  -> publish the candidate
  -> retire obsolete derived data under locks

A failed candidate cannot replace the serving index. Readers stay pinned to a completed generation while a writer prepares the next one.

Latest-only retention reduces storage at rest, but it is not a promise that only one generation’s data exists at every instant. Old and new data coexist during construction, and explicitly retained model-test candidates are intentional exceptions. After the old serving generation is retired, immediate rollback is no longer available; recovery may require rebuilding from the archive.

For scale, the September 28 corpus had 630,057 vectors. At 1,024 dimensions and four bytes per float, the values alone represent about 2.4 GiB, before catalogs, metadata, search indexes, caches, and temporary versions. Moving everything to a NAS would not remove those working-set and consistency questions.

The Keyword Cleanup Was the Bottleneck Before Embedding

Another slow path appeared during preparation. The cleanup loop deleted old FTS entries one session at a time. Its chunk_id column was UNINDEXED, so each lookup could scan the keyword table again.

The fix was to collect the retiring session IDs once, skip deletion for genuinely new sessions, and perform the FTS cleanup in one batch. Ordinary tables could use their normal indexes. A savepoint preserved rollback behavior without taking transaction ownership away from the caller.

The September 13 validation was intentionally narrower than an end-to-end RAG benchmark:

TestBeforeAfterWhat was checked
Synthetic 50,000-chunk corpus; 45 existing and 123 new sessions0.7041 s0.0203 sSame remaining records and keyword scores
Disposable copy of the 536,176-chunk catalogNot measured in this comparison25.461 sOne cleanup scan; 30,873 chunks retired; 505,303 retained

The second row is cleanup-only time, not embedding throughput. The synthetic result supports this specific optimization, not a claim that the entire pipeline became 35 times faster.

It also changed what I wanted from progress reporting. A long preparation phase should say whether it is comparing sessions, cleaning old chunks, or exporting text. Showing no progress until embedding begins hides useful information about where time is actually going.

A Background Command Was Not an Independent Worker

A manual update stopped during embedding. At 00:34:25 KST on September 14, its Python worker disappeared at almost the same time as the Codex execution process. The checkpoint still said running, because the worker had not recorded normal completion or a handled failure.

The exact reason for the Codex process exit was not established. The operational weakness was clear: the long update had been launched inside the agent’s command session rather than through an independent job manager.

I added a managed manual command:

1
2
# From my Session Search checkout.
./search.command sync --background

It submits a one-shot macOS launchd job, resumes a compatible saved candidate, respects the indexing lock, and writes separate logs. Repeated requests do not restart an already running worker. The existing 04:00 schedule remains unchanged.

This is not an infinite failure-retry service, and it does not guarantee survival across logout or reboot. Its useful guarantee is narrower: closing Codex or the launching terminal no longer owns the worker’s lifetime. Persisted checkpoints allow a later resume.

At interruption, 32,256 of 89,342 new/changed chunks had been committed. Most of that workload came from a one-time Antigravity import, with Codex and OpenClaw changes included too. The approximately 505,000 inherited chunks were not new embedding work.

That difference matters when interpreting a progress bar: counting inherited chunks in the denominator and numerator would make a new update look mostly finished before much of its actual work had happened.

Build the Dashboard Around Questions, Not Process Names

Collection, publication, indexing, and retrieval have different states. I built a compact English-language dashboard to make those distinctions visible.

ViewQuestion it answers
Overview / SourcesWhat has been collected, from where, and when?
Imports / Recent RunsWas an export imported and backed up, or merely encountered?
RAG: serving indexWhich completed corpus is available to Recall now?
RAG: current updateWhat is being prepared, embedded, or finalized?
UsageWhat token usage can be supported by recorded evidence?

The dashboard is read-only: no transcript browser, upload flow, deletion button, or index-switch control. Its underlying web service binds to loopback and is reached through private Tailscale access with a server-side owner allowlist. The search API credential remains on the server.

Archive overview showing session coverage, local database size, verified exports, and backup status Archive overview, captured September 29, 2026. Only aggregate operating metrics are shown; private addresses and conversation contents are outside the capture.

RAG dashboard separating the serving index from update progress, embedding cache reuse, and search storage RAG view from the same day. The search catalog uses its own published checkpoint, so its session count is not the archive’s main-view session count.

The RAG view separates serving state from candidate progress and excludes inherited unchanged chunks from the update denominator. Processing speed and completion estimates require recent samples. When progress becomes stale, an old estimate stops being presented as reliable.

Monitoring itself does not run searches or generate embeddings. It reads operational metadata and cached metrics. “The API responded” is still not proof that semantic retrieval works, and a stored running state is not proof of a live worker.

Token Usage Needed Its Own Normalization

The Usage view covers Codex, Claude Code, and OpenClaw. ChatGPT exports and the Antigravity import are outside this report’s usage-accounting scope.

Blindly adding token fields would have produced plausible but wrong totals:

  • Codex records can include per-response usage and cumulative mirrors.
  • Claude transcripts can repeat usage for the same message across content blocks.
  • OpenClaw can summarize work also represented by its internal Codex runtime.

I derive small usage tables during collection instead of reparsing every transcript on each dashboard refresh. Response identities remove supported duplicates. Cumulative records are reconciled rather than summed line by line. Engine usage is not added to its transcript rollup again, and unresolved overlaps are conservatively excluded and counted as exclusions.

Input Already Includes Cache

Provider field names do not mean the same thing everywhere. OpenAI documents cached input as part of total input and reasoning as part of output. Claude documents cache-read and cache-creation input separately from its input_tokens field. My adapters normalize them into one dashboard convention. See OpenAI’s usage explanation and Claude’s cache accounting.

1
2
Input = Uncached input + Cache read + Cache write
Total = Input + Output

The table says Input (incl. cache), percentage columns say Cache read %, and the calculation is visible beside the table—not only inside folded help text. Cache tokens are not another amount to add to Input.

Missing or conflicting usage is Unknown, not zero. A cumulative remainder with no reliable per-response timing contributes to supported all-time totals, not an invented daily allocation or response count. Cache ratios disclose the input coverage on which they are based.

Large Totals Need Careful Labels

On September 28, the recorded aggregate was about 13.7 billion tokens, with a 91.3% input cache-read ratio. Those are partial historical usage measurements for the supported sources—not unique corpus tokens, a count of text I typed, a complete account-wide total, or a bill. Repeated context can appear on many model calls, even when cached.

Session counts have a similar ambiguity. The September 29, 2026 captures above show:

MeasurementObserved snapshotInterpretation
Archive dashboard session entries13,459Excludes internal Codex runtime entries; includes automation and subagents
Internal runtime entries shown separately8,146Not another 8,146 independent human conversations
Session entries in the serving search catalog21,593Includes internal representations and has its own checkpoint
Text chunks in the serving index630,057Searchable fragments, not conversation count
Serving archive checkpointSeptember 28, 04:02 KSTSuccessful source publication consumed by the build

The archive dashboard was observed later in the day than the search checkpoint, so those counts are not expected to add up perfectly. “Sessions” is not one universal unit across applications, archive views, and search catalogs.

What I Would Keep

The operational lessons were not specific to one embedding model:

  • Separate frequent preservation from more expensive index refreshes.
  • Distinguish a validated serving generation from work in progress.
  • Preserve resumable work, but do not mistake a checkpoint for a live process.
  • Label partial coverage, unknown values, and measured quantities explicitly.
  • Keep cleanup from creating the data it is supposed to reclaim.

A dashboard cannot repair a pipeline on its own. Its value is making the next question clear enough that I can tell whether to investigate ingestion, indexing, retrieval, or merely a misleading metric.

Previous: Replaceable Local RAG · Next: A Recall Skill for Codex—using this evidence in real decisions without treating history as authority.

이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.