Skip to content

Persistence: vector params built via ','.join(str(f)) bypass the pgvector codec #72

Description

@JumpTechCode

Summary

Embedding vectors are hand-serialized into a string literal ("[" + ",".join(str(f) ...) + "]") and bound as text with CAST(:vec AS vector), bypassing the native pgvector codec. The ORM column already uses pgvector.sqlalchemy.Vector, but no asyncpg codec is registered, which is why the manual path exists.

Evidence

  • sentinel/persistence/repositories.py:819 (set_embedding) and :897 (similar_resolved_incidents) — manual ",".join(str(f) for f in ...) literal.
  • sentinel/persistence/models.py:70 — column typed Vector, but no register_vector / set_type_codec anywhere.

(str(float) round-trips, so this isn't numerically lossy — but it bypasses the codec the project otherwise depends on and duplicates serialization logic across two call sites.)

Fix

Register the pgvector asyncpg codec (pgvector.asyncpg.register_vector) at connection setup and bind list[float] directly, removing the manual literal construction.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtCode-quality cleanup deferred from a prior PR

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions