Merge branch 'worktree-agent-a3bd292551395dda0'
# Conflicts: # app/storage/schema.py
This commit is contained in:
commit
43773efc53
8 files changed
+338
-34
No files matched your search
+21
-4
@@ -80,9 +80,10 @@ def config(tmp_path: Path) -> Config:
|
||||
|
||||
|
||||
def role(store: Store, source_id: str, title: str = "Backend Engineer", *,
|
||||
company: str = "Acme", body: str = "", **raw: Any) -> str:
|
||||
company: str = "Acme", body: str = "",
|
||||
published_at: datetime = datetime(2026, 9, 20, tzinfo=UTC), **raw: Any) -> str:
|
||||
item = Item(source_id=source_id, location=f"https://boards.example/{source_id}",
|
||||
title=title, body=body, published_at=datetime(2026, 9, 20, tzinfo=UTC),
|
||||
title=title, body=body, published_at=published_at,
|
||||
raw={"company": company, **raw})
|
||||
item.source = "ats"
|
||||
store.upsert_role(item)
|
||||
@@ -274,7 +275,7 @@ def test_recency_halves_every_fourteen_days() -> None:
|
||||
|
||||
|
||||
def test_a_role_without_a_vector_is_scored_without_fit_unless_fit_is_all() -> None:
|
||||
candidate = Candidate(uid="u", first_seen=NOW.isoformat(), affinity=0)
|
||||
candidate = Candidate(uid="u", posted_at=NOW.isoformat(), affinity=0)
|
||||
value, reason = score.score_one(candidate, [], Weights(), None, NOW)
|
||||
assert reason == "" and value == pytest.approx((0.2 * 1.0 + 0.2 / 3) / 0.4)
|
||||
|
||||
@@ -334,7 +335,7 @@ def test_failed_gates_reads_evidence_only() -> None:
|
||||
Gate(field="seniority", values=["senior"], mode="any"),
|
||||
Gate(field="function", values=["engineering"], mode="prefer")]
|
||||
def cand(*states: int) -> Candidate:
|
||||
return Candidate(uid="u", first_seen=NOW.isoformat(), affinity=0, gates=list(states))
|
||||
return Candidate(uid="u", posted_at=NOW.isoformat(), affinity=0, gates=list(states))
|
||||
assert score.failed_gates(cand(1, 1, 0, 0), gates) == []
|
||||
assert score.failed_gates(cand(-1, -1, -1, 0), gates) == []
|
||||
assert score.failed_gates(cand(0, 0, -1, 1), gates) == [
|
||||
@@ -402,6 +403,22 @@ def test_an_older_role_scores_lower(
|
||||
assert scores[new][0] > scores[old][0]
|
||||
|
||||
|
||||
def test_recency_counts_from_posted_at_not_first_seen(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
"""A trusted board's backlog, first seen today, must not score as fresh:
|
||||
recency has to read the board's own (trusted) posted date, not the
|
||||
moment the app happened to pull it in."""
|
||||
stale = role(store, "1", board="greenhouse",
|
||||
published_at=NOW - timedelta(days=28))
|
||||
fresh = role(store, "2") # untrusted host: posted_at falls back to first_seen (NOW)
|
||||
agent = store.save_agent("Any")
|
||||
|
||||
run(config, store, score.run_score)
|
||||
|
||||
scores = store.scores(agent.id)
|
||||
assert scores[fresh][0] > scores[stale][0]
|
||||
|
||||
|
||||
def test_two_agents_rank_the_same_roles_the_other_way_round(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
back = role(store, "1", "Backend Engineer", body="Python services")
|
||||
|
||||
Reference in new issue
Block a user