Why
In etl/manager_similarity_flow.py:27-47, the function ensure_manager_similarity_table(conn) executes table creation DDL only when isinstance(conn, sqlite3.Connection).
When executed against a PostgreSQL connection, ensure_manager_similarity_table(conn) executes no statements and provides no fallback or table verification. This inconsistency contrasts with all other table ensure functions across the codebase (such as etl/conviction_flow.py, alerts/db.py, and etl/activism_detection.py), which provide PostgreSQL DDL branches.
Scope
- Implement PostgreSQL DDL execution in
ensure_manager_similarity_table() in etl/manager_similarity_flow.py:27-47 matching dialect patterns used across etl/.
- Add test coverage in
tests/test_manager_similarity_flow.py verifying table creation DDL execution on PostgreSQL connections.
Implementation Notes
- Mirror the PostgreSQL table creation schema in
etl/conviction_flow.py using BIGINT, TIMESTAMPTZ, and FLOAT types.
- Ensure idempotent execution using
CREATE TABLE IF NOT EXISTS manager_similarity (...).
Non-Goals
- Modifying similarity computation algorithms or vector embedding distance metrics.
- Adding scaffold-only stubs, mocks, or empty bypass functions without wiring up the real implementation does NOT count as done and constitutes a failure of this issue.
Tasks
Acceptance Criteria
- Running
pytest tests/test_manager_similarity_flow.py executes without errors.
- Calling
ensure_manager_similarity_table(pg_conn) on a PostgreSQL mock connection executes DDL creating table manager_similarity.
- Verification gate: deliberately break the implementation by omitting PostgreSQL handling in
etl/manager_similarity_flow.py and verify pytest tests/test_manager_similarity_flow.py fails.
Why
In
etl/manager_similarity_flow.py:27-47, the functionensure_manager_similarity_table(conn)executes table creation DDL only whenisinstance(conn, sqlite3.Connection).When executed against a PostgreSQL connection,
ensure_manager_similarity_table(conn)executes no statements and provides no fallback or table verification. This inconsistency contrasts with all other table ensure functions across the codebase (such asetl/conviction_flow.py,alerts/db.py, andetl/activism_detection.py), which provide PostgreSQL DDL branches.Scope
ensure_manager_similarity_table()inetl/manager_similarity_flow.py:27-47matching dialect patterns used acrossetl/.tests/test_manager_similarity_flow.pyverifying table creation DDL execution on PostgreSQL connections.Implementation Notes
etl/conviction_flow.pyusingBIGINT,TIMESTAMPTZ, andFLOATtypes.CREATE TABLE IF NOT EXISTS manager_similarity (...).Non-Goals
Tasks
ensure_manager_similarity_table()inetl/manager_similarity_flow.py.tests/test_manager_similarity_flow.pyasserting PostgreSQL DDL executes on non-SQLite connection instances.Acceptance Criteria
pytest tests/test_manager_similarity_flow.pyexecutes without errors.ensure_manager_similarity_table(pg_conn)on a PostgreSQL mock connection executes DDL creating tablemanager_similarity.etl/manager_similarity_flow.pyand verifypytest tests/test_manager_similarity_flow.pyfails.