tidaldb/tidal/docs/planning/milestone-5/phase-4/task-02-creator-vector-index.md
jx12n 3bcfb3c576 feat: Bazel build, crate docs/ai-lookup, docker images, and engine hardening
- Add BUILD.bazel across tidal, tidal-net, tidal-server, tidalctl for bzlmod build
- Add tidal/ crate docs (README, CHANGELOG, CONTRIBUTING, AGENTS, CLAUDE, API, ARCHITECTURE) and ai-lookup reference
- Add docker standalone/cluster/deploy images, compose, and prometheus config
- Harden WAL (batch format, writer, dedup, diagnostics), text syncer/collectors, and vector registry
- Expand tidalctl CLI and tests; restructure WAL/visibility integration test suites
- Refine tidal-net transport/client/server and tidal-server cluster/scatter-gather
2026-06-07 18:29:38 -06:00

1.4 KiB

Task 02: Creator Vector Index

Goal

Add write_creator_embedding() and read_creator_embedding() to TidalDb. These register and populate the (EntityKind::Creator, "content") slot in the existing EmbeddingSlotRegistry.

Files to Modify

  • tidal/src/db/mod.rs — add write_creator_embedding() and read_creator_embedding()

Implementation

pub fn write_creator_embedding(&self, id: EntityId, embedding: &[f32]) -> crate::Result<()> {
    let mut registry = self.embedding_registry.write()...;
    if registry.get(EntityKind::Creator, "content").is_none() {
        // auto-register slot
        let state = EmbeddingSlotState::new(embedding.len(), QuantizationLevel::F32, EmbeddingSource::External);
        registry.register(EntityKind::Creator, "content".to_string(), state)?;
    }
    let slot = registry.get_mut(EntityKind::Creator, "content")...;
    slot.index.add(id.as_u64(), embedding)?;
    Ok(())
}

pub fn read_creator_embedding(&self, id: EntityId) -> crate::Result<Option<Vec<f32>>> {
    let registry = self.embedding_registry.read()...;
    let slot = match registry.get(EntityKind::Creator, "content") { None => return Ok(None), Some(s) => s };
    Ok(slot.index.get(id.as_u64()))
}

Acceptance Criteria

  • write_creator_embedding(id, &vec) succeeds and auto-registers the slot
  • read_creator_embedding(id) returns the stored vector
  • ANN search on (EntityKind::Creator, "content") returns results