Companies as symbols: company_aliases, merge, duplicates, empty enrichment columns (migration 20)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 09:45:43 +02:00
1 parent 3adafd8950
commit 9172b2da72
8 files changed
+347 -17

No files matched your search

+16 -6
View File
@@ -69,7 +69,7 @@ def test_schema_creates_on_an_empty_file(tmp_path: Path) -> None:
"application_events", "agents", "scores", "state"} <= tables
assert "idx_roles_cluster" in indexes
assert store.migrations_applied == []
assert LATEST == 19
assert LATEST == 20
# A second open finds it current and applies nothing.
assert Store(path).migrations_applied == []
@@ -88,9 +88,19 @@ def _columns(path: Path, table: str) -> list[tuple[str, str, int, str]]:
return [(r[1], r[2], r[3], r[4]) for r in conn.execute(f"PRAGMA table_info({table})")]
def _undo_v20(conn: sqlite3.Connection) -> None:
"""A fresh file put back to the v19 shape: no company aliases, no
enrichment columns."""
conn.execute("DROP TABLE company_aliases")
for column in ("sector", "stage", "size_band", "founded", "last_funding",
"last_funding_currency", "facts_source", "facts_at"):
conn.execute(f"ALTER TABLE companies DROP COLUMN {column}")
def _undo_v19(conn: sqlite3.Connection) -> None:
"""A fresh file put back to the v18 shape: no gazetteer, no role places,
no teaser, one level."""
_undo_v20(conn)
for table in ("role_places", "place_includes", "place_aliases", "places"):
conn.execute(f"DROP TABLE {table}")
for column in ("teaser", "seniority_model", "seniority_stated", "seniority_title"):
@@ -176,7 +186,7 @@ def test_a_v14_file_gains_the_watchlist_columns_and_leaves_companies_unrated(
migrated = Store(path)
assert migrated.migrations_applied == [15, 16, 17, 18, 19]
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20]
acme = migrated.company("acme")
assert acme is not None
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
@@ -381,7 +391,7 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P
migrated = Store(path)
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19]
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20]
assert migrated.agent(backend.id).prompts == [ # type: ignore[union-attr]
Prompt(name="Backend", text="python backend")]
assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr]
@@ -405,7 +415,7 @@ def test_v16_gives_a_company_no_reason_and_keeps_its_row(tmp_path: Path) -> None
migrated = Store(path)
assert migrated.migrations_applied == [16, 17, 18, 19]
assert migrated.migrations_applied == [16, 17, 18, 19, 20]
acme = migrated.company("acme")
assert acme is not None
assert (acme.careers_url, acme.notes, acme.hand_reason) == (
@@ -434,7 +444,7 @@ def test_v17_folds_every_place_and_levels_the_titles_extract_has_not_read(
migrated = Store(path)
assert migrated.migrations_applied == [17, 18, 19]
assert migrated.migrations_applied == [17, 18, 19, 20]
with sqlite3.connect(path) as conn:
rows = {uid: (fold, level) for uid, fold, level in conn.execute(
"SELECT uid, place_fold, seniority FROM roles")}
@@ -676,7 +686,7 @@ def test_v19_gives_every_role_its_places_and_splits_its_level(tmp_path: Path) ->
migrated = Store(path)
assert migrated.migrations_applied == [19]
assert migrated.migrations_applied == [19, 20]
assert [p.name for p in migrated.role_places(joined.uid)] == ["Copenhagen", "Malmö"]
assert [p.name for p in migrated.role_places(detailed.uid)] == ["Aarhus"]
assert migrated.role_places(stated.uid) == []