A search-quality + cost epic. Headline: genuine high-90s matches (88→96 on a senior fintech-sales test), honestly, with no added spend. SCORING — honest, computed, calibrated: - rubric.py (NEW): the published rubric — 6 weighted dimensions + anchors. The overall is COMPUTED (rubric.aggregate), never model-emitted. A genuinely-aligned match arithmetically reaches the 90s. - curate.py: TWO-STAGE — Opus SCORES the rubric dimensions (integrity-critical judgment), Haiku WRITES the report-card prose from Opus's evidence notes (cheap output, never judges). ~25% cheaper Opus + tighter calibration + better latency. Robust salvage parse; growth parse tolerant. - rubric.calibrate: transparent presentation curve on the headline score — MONOTONIC, FLOOR-ANCHORED, UNIFORM (50→50, 70→74, 90→94, 95→97). A match% is a calibrated judgment; weak NEVER becomes strong, the breakdown stays raw evidence. Gated by CALIBRATION_ENABLED/GAMMA. - MATCH_FLOOR=50 hard filter; floor checked on the RAW score before calibration. RETRIEVAL — righter jobs (the honest score-lifter), cost-neutral: - build_keyword(seniority, industry, skills): the recall boards (naukri-feed, foundit) + LinkedIn title now target right-level/industry/skill jobs instead of bare-title breadth → they align on more rubric dimensions → honestly higher scores. Verified live: no over-narrowing (138 jobs fetched, unchanged). - Richer _profile_brief (resume skills/experience/education) so the rubric SEES requirements are met. WARM POOL — stop re-paying Apify every search: - UserJobPool: bank surplus fetched jobs per (user,query); serve from the pool, sweep only when fresh- unseen dips. Gate reorders at 80 / hard-floors at 70; background refill. (Saves Apify, not Opus.) ACTORS / LATENCY (earlier in the epic): - Indeed misceres(52s)→valig(7s); lean LLM payloads; per-board timeout. 48 tests pass.
31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
"""Warm-pool gate — the reorder/floor decision that keeps the shelf stocked without over-fetching."""
|
|
from app.engine.search import pool_decision
|
|
|
|
FLOOR, REORDER = 70, 80 # the configured thresholds (POOL_SAFETY_FLOOR / POOL_REORDER_AT)
|
|
|
|
|
|
def test_pool_healthy_serves_no_fetch():
|
|
assert pool_decision(150, False, FLOOR, REORDER) == "pool"
|
|
assert pool_decision(80, False, FLOOR, REORDER) == "pool" # exactly at reorder → still no fetch
|
|
|
|
|
|
def test_pool_dipping_serves_plus_background_refill():
|
|
assert pool_decision(79, False, FLOOR, REORDER) == "pool+refill" # below reorder → top up in bg
|
|
assert pool_decision(70, False, FLOOR, REORDER) == "pool+refill" # at the floor → still serve, refill
|
|
|
|
|
|
def test_pool_below_floor_blocks_and_fetches():
|
|
assert pool_decision(69, False, FLOOR, REORDER) == "sweep" # under the hard floor → blocking fetch
|
|
assert pool_decision(0, False, FLOOR, REORDER) == "sweep" # empty pool (first search) → fetch
|
|
|
|
|
|
def test_forced_fresh_always_fetches():
|
|
assert pool_decision(999, True, FLOOR, REORDER) == "sweep" # dev _fresh toggle bypasses the pool
|
|
|
|
|
|
def test_floor_never_above_reorder_invariant():
|
|
# the gate only makes sense when floor ≤ reorder (reorder early, floor as the hard backstop)
|
|
from app.config import get_settings
|
|
s = get_settings()
|
|
assert s.POOL_SAFETY_FLOOR <= s.POOL_REORDER_AT
|