Merge branch 'main' into isolate-batches

This commit is contained in:
Wolf committed 2026-09-28 19:42:51 +02:00
commit 074a41c6cf
10 files changed
+143 -28

No files matched your search

+27 -8
View File
@@ -4,8 +4,16 @@ A role is scored per agent, `(uid, agent) -> score`, because a role is only
good for a given search. For each agent:
require gates a role that fails one keeps its row, with score 0 and the
reason ("place unknown", "remote not remote")
reason ("remote not remote")
any gates one group: a role that matches none of them, and has the
column filled for at least one, is gated ("none of
country DK / remote remote")
prefer gates `weight` when the role matches, 0 when it does not
A gate rejects on evidence, never on absence: a role whose column is empty
is not gated by it. `extract` is what fills an empty column, and it reads
only the roles that rank, so gating on an empty column would keep those
roles out of extract's reach for good.
fit cos(role vector, intent vector), min-max scaled across
the roles this agent scores in this run: the closest is 1,
the farthest 0, a lone role 1
@@ -117,21 +125,32 @@ def scale(cosines: dict[str, float]) -> dict[str, float]:
return {uid: (value - low) / (high - low) for uid, value in cosines.items()}
def _reason(gate: Gate, state: int) -> str:
if state < 0:
return f"{gate.field} unknown"
def _wanted(gate: Gate) -> str:
if gate.field == "salary_min":
return f"salary_min {min(gate.values, key=lambda v: float(v))}"
return f"{gate.field} {' / '.join(str(v) for v in gate.values)}"
def _reason(gate: Gate) -> str:
if gate.field == "salary_min":
return f"salary_min under {min(gate.values, key=lambda v: float(v))}"
return f"{gate.field} not {' / '.join(str(v) for v in gate.values)}"
def failed_gates(candidate: Candidate, gates: Sequence[Gate]) -> list[str]:
"""Every require gate this role fails, as reasons. None for a favourite,
which skips the gates."""
"""Why this role is gated, as reasons: every require gate it fails, and
the `any` group when it matches none of them. A gate with an empty column
(state -1) neither passes nor fails, so the group fails only when some
member had evidence. None for a favourite, which skips the gates."""
if candidate.affinity == 2:
return []
return [_reason(g, state) for g, state in zip(gates, candidate.gates, strict=True)
if g.mode == "require" and state != 1]
states = list(zip(gates, candidate.gates, strict=True))
reasons = [_reason(g) for g, state in states if g.mode == "require" and state == 0]
group = [(g, state) for g, state in states if g.mode == "any"]
if group and not any(state == 1 for _, state in group) \
and any(state == 0 for _, state in group):
reasons.append("none of " + ", ".join(_wanted(g) for g, _ in group))
return reasons
def score_one(candidate: Candidate, gates: Sequence[Gate], weights: Weights,