Files
Joel Hooks e357bcc609 feat(memory): Phase 1 slice — embed priority lanes (ADR-0243 Rule 9a)
Validates ADR-0243 Rule 9a with a decisive contention test. Priority-lane
embed scheduling measured at 338ms query latency with 98 ingest-bulk embeds
queued — a ~25x improvement over the 8-10s observed in the spike without
priority discipline.

@joelclaw/inference-router
  - new src/embeddings.ts — PriorityEmbedClient with single-writer queue
    honoring query > ingest-realtime > ingest-bulk; embed() returns queued_ms,
    compute_ms, total_ms for observability
  - new __tests__/embeddings-priority.test.ts — drives 100 ingest-bulk embeds
    then submits one query-priority embed mid-stream; asserts query < 3s
    (observed 338ms); skips gracefully when Ollama is unreachable
  - vitest added as devDependency; tests pass under vitest 4

@joelclaw/memory
  - new __tests__/chunking.test.ts — 12 tests locking in the tool_result
    role detection fix that landed during the spike, format detection
    (claude-code vs pi), meta-entry filtering, thinking-content handling,
    oversized-turn sub-chunk splitting, and malformed-JSON tolerance

packages/system-bus
  - memory/embed.requested + memory/embed.completed event contracts added
    to Events map
  - new functions/memory/embed.ts — Inngest durable wrapper, concurrency:1
    (matches Ollama internal serialization), priority.run expression mapping
    the three lanes to numeric scheduling scores, OTEL emission + fanout
    completed event; calls @joelclaw/inference-router under the hood

Query path bypasses Inngest and calls the router directly (fast, no
durability needed). Only ingest paths fire memory/embed.requested. Both
converge on the same priority queue — that's where the contention is
resolved.

ADR-0243 status: accepted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 18:15:21 -07:00
..