Workers and maintenance
The daemon runs a small set of non-semantic background workers. They ingest documents, purge expired data, check and repair storage health, and keep embeddings current. Dreaming owns every automatic semantic write; see Extraction and decisions.
Worker model
Section titled “Worker model”When memory.pipelineV2 is enabled and not paused, the daemon starts the retention, maintenance, document, and synthesis workers, plus the hints worker when hints.enabled is set and mutations are not frozen. When the pipeline is disabled or paused, the retention worker still starts on its own. The embedding tracker starts separately when an embedding provider is configured, embeddingTracker.enabled is true, and the pipeline is not paused.
GET /api/pipeline/status reports which workers are running. For the document worker it also reports inFlight and maxInFlight, so a full ingest budget is distinguishable from queue depth.
Retired extraction
Section titled “Retired extraction”The legacy extraction, decision, and escalation workers are retired, and no runtime creates or leases extract jobs in memory_jobs. When the pipeline is not paused, startup marks any unfinished historical extract job dead and sets its memory’s extraction_status to retired. It does not change the memory’s provenance or memory_kind. The dependency-synthesis worker is retired too; Dreaming’s audited create_link path is the only semantic dependency writer.
Document ingest
Section titled “Document ingest”The document worker processes document_ingest jobs from memory_jobs, oldest first. It ticks every documents.workerIntervalMs (default 10,000 ms) and skips a tick under high system pressure.
At most two documents are processed at once across every document worker in the daemon. The worker takes an admission slot before it leases a job, so URL fetch, chunking, embedding, and indexing cannot exceed that budget. The slot is held through processing, completion or failure handling, and terminal telemetry, and is released in the tick’s finally block.
Processing moves the documents row through extracting, chunking, embedding, indexing, and done:
- URL sources are fetched with SSRF protection, a 30-second timeout, and a
documents.maxContentByteslimit (default 10 MB). The fetcher acceptstext/*,application/json, andapplication/xml. For HTML it extracts the<title>and strips<script>and<style>before chunking. A fetched title fills an empty document title. Other sources use the stored raw content. - Content is split into windows of
documents.chunkSizecharacters (default 2,000) that overlap bydocuments.chunkOverlap(default 200). Content shorter than one window stays one chunk. - Each chunk is embedded outside any transaction, then written in its own transaction as a memory with
type = 'document_chunk',importance = 0.3, and the tagdocument:<title>when a title exists. A chunk whose content hash is already linked to the document is skipped. An identical chunk memory in the same agent and project scope is reused instead of duplicated. document_memoriesrecords each chunk’s index, so a document’s chunks can be listed or removed as a unit.
If the document is deleted mid-run, the job completes without further writes.
On an error, the document row is set to failed with the error text, even when the job itself returns to pending for another attempt. Leasing only picks jobs whose attempt count is below worker.maxRetries (default 3, range 1 to 10). Failure handling compares attempts with the job’s stored max_attempts, which enqueue sets to 3. With worker.maxRetries below 3, a failed job stays pending but is never leased again (#2356).
Retention
Section titled “Retention”The retention worker purges expired data. Its first sweep runs one minute after start, then every six hours. A sweep is skipped under high system pressure or while the database owner’s maintenance queue is unhealthy.
Each sweep selects up to 500 soft-deleted memories whose tombstone window has expired. In one write transaction it then:
- Deletes their
memory_entity_mentionsrows and decrements the mention count of each affected entity. Entities, relations, and ontology content are kept even at zero mentions. Each affected entity is decremented once, even when several deleted memories mention it (#2355). - Deletes their embeddings and the matching
vec_embeddingsrows. - Copies the memory rows to
memories_cold, removes their temporal edges, and hard-deletes them. Thememories_adtrigger cleans up full-text search.
The 500 limit counts memories, not rows, so the linked mention and embedding rows can exceed 500.
After that transaction, five cleanup steps run as separate yielding transactions, each limited to 500 rows: old memory_history rows, completed and dead memory_jobs, and completed and dead transcript_capture_jobs. Dead memory jobs age from failed_at; dead transcript capture jobs age from updated_at. Rows beyond any limit are picked up by later sweeps.
Retention windows and limits are compiled in. See Retention config for the defaults.
Maintenance
Section titled “Maintenance”The maintenance worker runs diagnostics and, by default, repairs. It runs every autonomous.maintenanceIntervalMs (default 30 minutes) when autonomous.enabled is true and autonomous.frozen is false. A cycle defers under high system pressure or while the owner maintenance queue is unhealthy. A new cycle does not start while the previous one is running.
Each cycle builds a diagnostics report covering queue health, full-text index consistency, storage, duplicates, and graph health, summarized as a composite score from 0 to 1. It then recommends repairs:
| Repair | Recommended when |
|---|---|
repairEmbeddingIndex |
Embeddings are missing, orphaned, or on an old model |
requeueDeadJobs |
More than 1% of jobs are dead |
releaseStaleLeases |
Stale leases exist |
checkFtsConsistency |
The full-text index count does not match canonical memory rows, including retained tombstones |
triggerRetentionSweep |
Tombstones exceed 30% of memories |
deduplicateMemories |
The duplicate ratio exceeds 5% |
With autonomous.maintenanceMode: observe, the cycle logs the recommendations and stops. With execute (the default), it runs each one through its repair action, subject to that action’s cooldown and hourly budget, then re-reads diagnostics. An action that fails to raise the score three runs in a row is halted until a cycle produces no recommendations.
The cycle also does housekeeping. When the graph and feedback are enabled, it propagates memory status into graph attributes and, if decay is enabled, decays aspect weights. In execute mode, after it runs repairs, it also logs a warning when more than 100 low-value memories look dead and reclaims incremental-vacuum space when at least 20% of database pages are free. A cycle with no recommendations, or in observe mode, skips these two checks.
Embedding tracker
Section titled “Embedding tracker”The embedding tracker keeps memory embeddings current in small batches. Each cycle:
- Finds up to
batchSizememories with no embedding, an embedding whose hash differs from the memory’s content hash, or anembedding_modelthat differs from the configured model, most recently updated first. Rows in a persisted failure backoff are excluded until their retry time. - Checks that the embedding provider is available, and skips the cycle if it is not.
- Claims a singleton repair lease. Memories that have never been embedded go first and skip the re-embed cooldown and hourly budget. Re-embedding stale rows is limited by
repair.reembedCooldownMsandrepair.reembedHourlyBudget. - Embeds each row one at a time outside a transaction. A failure is counted and gets a persisted backoff keyed by memory, content hash, and model.
- Writes all results in one transaction: removes the memory’s vectors for other hashes, upserts the embedding, syncs
vec_embeddings, and updatesembedding_model.
After a cycle whose candidate list filled the batch, included at least one never-embedded memory, and saved its results, the next cycle starts immediately, so a backlog from a Dreaming run drains at provider speed. Other cycles wait pollMs. getStats() returns running, processed, failed, skippedCycles, lastCycleAt, and queueDepth.
| Field | Default | Range | Description |
|---|---|---|---|
embeddingTracker.enabled |
true |
Master switch | |
embeddingTracker.pollMs |
5000 |
1000–60000 ms | Delay between cycles unless the last cycle qualified for an immediate next cycle (see above) |
embeddingTracker.batchSize |
8 |
1–20 | Maximum embeddings per cycle |
At startup, if vec_embeddings was created with different dimensions than the configured model, the daemon recreates it at the configured size and backfills stored embeddings that match.
Queue health and repair
Section titled “Queue health and repair”memory_jobs is the live job queue. The retired summary_jobs queue is no longer a work surface.
GET /api/diagnostics/queue (admin) returns per-queue counts, bounded at 1,000 rows per status. queues.memory describes live work. queues.summary is a retired compatibility entry, and oldestDeadSummaryJob is always null.
{ "timestamp": "2026-12-03T00:00:00.000Z", "queues": { "memory": { "pending": 0, "leased": 0, "completed": 12, "failed": 0, "dead": 1, "oldestAgeSec": 0, "oldestDeadAgeSec": 86400, "lastError": "timeout", "completeness": "exact" }, "summary": { "pending": 0, "leased": 0, "completed": 0, "failed": 0, "dead": 0, "oldestAgeSec": 0, "oldestDeadAgeSec": 0, "lastError": null, "completeness": "exact" } }, "oldestDeadSummaryJob": null, "oldestDeadMemoryJob": { "id": "job-id", "harness": null, "sessionKey": null, "createdAt": "2026-12-02T00:00:00.000Z", "attempts": 3, "error": "timeout" }, "thresholds": { "memoryDeadWarn": 50, "memoryDeadFail": 500, "memoryOldestPendingWarnSec": 300, "memoryOldestPendingFailSec": 1800 }}The real thresholds object also carries retired summary* keys. See Health and status for the full reference.
signet status shows a Memory job queue block. The heading adds (dead work present) when dead jobs exist, and failed and dead counts are colored when nonzero.
Three repair commands act on memory_jobs:
| CLI | Behavior |
|---|---|
signet repair queue requeue |
Resets dead jobs to pending, 50 per call by default. Limited by repair.requeueCooldownMs and repair.requeueHourlyBudget. Skips retired extract jobs. |
signet repair queue cancel |
Copies dead or completed jobs older than 30 days (default) to job_cancellations and marks them cancelled. |
signet repair queue prune |
Copies dead, cancelled, or completed jobs older than 90 days (default) to job_archive, then deletes them. At most 1,000 rows per call. |
All three are dry runs unless you pass --apply. A preview lists up to 100 selected job IDs and the total match count; the selected batch can be smaller than the match count. Targeting the retired summary table is rejected. The HTTP equivalent is POST /api/diagnostics/queue/repair.
Inference providers
Section titled “Inference providers”Workers that need a model go through inference routing. Targets use Pi-backed model providers (Anthropic, OpenRouter, Ollama, llama.cpp, OpenAI-compatible) or ACPX harness adapters for Claude Code, Codex, OpenCode, and Kimi. The local defaults are http://127.0.0.1:8080/v1 for llama.cpp and http://127.0.0.1:11434/v1 for Ollama, both using the OpenAI-compatible API. Catalog default models are qwen3:4b for llama.cpp and Ollama, haiku for Claude Code, gpt-6-luna for Codex, opencode/gemini-3.8-flash for OpenCode, claude-haiku-5-5 for Anthropic, ~openai/gpt-luna-latest for OpenRouter, and gpt-4o-mini for OpenAI-compatible endpoints. See Inference and routing.
Predictor schema placeholders
Section titled “Predictor schema placeholders”The schema still has nullable session_memories.predictor_score and predictor_rank columns and a predictor_comparisons table. The daemon does not ship a predictive scorer. Session start ranks candidates with hybrid search, graph traversal, and baseline scoring, and leaves the predictor fields null. The dashboard has no predictor view. Entity health reads predictor_comparisons only when that table exists.

