Merge branch 'worktree-agent-afad54f12aef2cccf'

# Conflicts:
#	app/storage/schema.py
#	app/storage/store.py
#	tests/test_storage.py
This commit is contained in:
Wolf committed 2026-09-29 14:32:28 +02:00
commit 706b127bc0
10 files changed
+459 -37

No files matched your search

+44 -3
View File
@@ -66,7 +66,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 == 10
assert LATEST == 11
# A second open finds it current and applies nothing.
assert Store(path).migrations_applied == []
@@ -123,7 +123,7 @@ def test_a_v8_file_gains_ats_slug_and_keeps_its_companies(tmp_path: Path) -> Non
migrated = Store(path)
assert migrated.migrations_applied == [9, 10]
assert migrated.migrations_applied == list(range(9, LATEST + 1))
acme = migrated.company("acme")
assert acme is not None
assert (acme.ats, acme.country, acme.ats_slug) == ("teamtailor", "DK", "")
@@ -249,7 +249,7 @@ def test_v10_backfills_posted_at_by_the_same_rule_upsert_uses(
migrated = Store(path)
assert migrated.migrations_applied == [10]
assert migrated.migrations_applied == list(range(10, LATEST + 1))
after_trusted, after_untrusted = migrated.role(trusted.uid), migrated.role(untrusted.uid)
assert after_trusted is not None and after_untrusted is not None
# The backfill reproduces exactly what upsert_role would have written.
@@ -375,6 +375,47 @@ def test_upsert_without_a_trusted_host_keeps_posted_at_at_first_seen(store: Stor
assert role.posted_at == role.first_seen
def test_function_is_the_classifiers_guess_not_a_board_field(store: Store) -> None:
"""`function` behaves the opposite of every other raw field: a pull may
only set it before extract has run, and once extract has answered — even
with a different function than the pull's guess — no later pull may put
the guess back. The no-flip property across pull, extract, pull."""
store.upsert_role(posting(function="engineering"))
uid = posting().uid
assert store.role(uid).function == "engineering" # type: ignore[union-attr]
store.set_extracted(uid, {"function": "sales"})
assert store.role(uid).function == "sales" # type: ignore[union-attr]
# A later pull with the classifier's old (now wrong) guess must not flip
# it back — the "board wins" COALESCE that every other raw field gets
# would otherwise put "engineering" straight back on every pull.
store.upsert_role(posting(function="engineering"))
assert store.role(uid).function == "sales" # type: ignore[union-attr]
def test_function_is_frozen_once_extracted_even_with_no_answer(store: Store) -> None:
store.upsert_role(posting(function="engineering"))
uid = posting().uid
store.set_extracted(uid, {}) # extract answered this role, but not function
assert store.role(uid).extracted_at is not None # type: ignore[union-attr]
# extracted_at alone freezes it, whatever a later pull's guess says.
store.upsert_role(posting(function="sales"))
assert store.role(uid).function == "engineering" # type: ignore[union-attr]
def test_function_is_set_from_raw_before_extract_like_any_other_field(store: Store) -> None:
store.upsert_role(posting(function="engineering"))
role = store.role(posting().uid)
assert role is not None and role.function == "engineering"
# Before extract, a fresh guess still overwrites the old one, the same
# "board wins" behaviour as place, country and the rest.
store.upsert_role(posting(function="sales"))
role = store.role(posting().uid)
assert role is not None and role.function == "sales"
def test_company_falls_back_to_the_subscription(store: Store) -> None:
sub = store.add_subscription("ats", "greenhouse:acme", company="Acme", board="Greenhouse")
store.upsert_role(posting(), sub)