Give an agent a CV, languages, avoid and must texts, and read a posting's languages with a level and its deadline (migration 28)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-10-03 21:54:16 +02:00
1 parent ed6d641373
commit 4fc474c437
15 files changed
+716 -79

No files matched your search

+100 -7
View File
@@ -19,7 +19,8 @@ from collections.abc import Callable
from app import places
from app.models import (
SENIORITIES, company_fold, company_key, country_of, host_word, posted_at, posted_host,
SENIORITIES, company_fold, company_key, country_of, host_word, iso_day, posted_at,
posted_host,
)
from app.seniority import from_title
from app.storage import gazetteer
@@ -120,7 +121,11 @@ CREATE TABLE IF NOT EXISTS roles (
employment TEXT NOT NULL DEFAULT '',
prep_due INTEGER NOT NULL DEFAULT 0,
remote_model TEXT NOT NULL DEFAULT '',
remote_where_model TEXT
remote_where_model TEXT,
languages_required TEXT,
deadline_host TEXT NOT NULL DEFAULT '',
deadline_model TEXT NOT NULL DEFAULT '',
deadline TEXT
);
-- The *_host columns hold the host's own words as a reader handed them on
-- (app.models.host_word: a bool is 'true' or 'false'), and app.prep maps
@@ -134,9 +139,14 @@ CREATE TABLE IF NOT EXISTS roles (
-- word mapped to app.seniority's vocabulary, and the title's. remote_model is
-- extract's remote, which wins over the host's word and the place line, and
-- remote_where_model the names it read for where a remote hire may live (a
-- JSON list, NULL never asked, [] not stated). No comment sits among the last
-- columns: SQLite cannot drop a column a comment precedes, which the
-- migration tests do.
-- JSON list, NULL never asked, [] not stated). languages_required is every
-- language extract read in the posting, a JSON list of {language, level,
-- kind}, NULL never asked; languages keeps the required codes for the
-- languages gate. deadline_host is the host's own last day to apply, as a
-- pull hands it on, deadline_model the one extract read, both YYYY-MM-DD or
-- '', and deadline the first of them, NULL for none, written by prep. No
-- comment sits among the last columns: SQLite cannot drop a column a comment
-- precedes, which the migration tests do.
-- The gazetteer: a place is a continent, a country (key the ISO code), a
-- region or a city, in the place parent_id names. key is unique per kind:
@@ -317,7 +327,10 @@ END;
-- limits is how deep into this agent's ranking extract and summarise read,
-- as JSON: a key it lacks means the `Limits` default. fetch_terms is a JSON
-- list of words that narrow what big boards send (app/jobs/reach.py); empty
-- means no narrowing.
-- means no narrowing. cv_text, cv_languages (a JSON list of {language,
-- level}), avoid_text (what drains) and must_text (must-haves and
-- deal-breakers) are what judge reads a role against; an agent with no CV
-- is not judged.
CREATE TABLE IF NOT EXISTS agents (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
@@ -326,7 +339,11 @@ CREATE TABLE IF NOT EXISTS agents (
enabled INTEGER NOT NULL DEFAULT 1,
created_at TEXT NOT NULL,
limits TEXT NOT NULL DEFAULT '{}',
fetch_terms TEXT NOT NULL DEFAULT '[]'
fetch_terms TEXT NOT NULL DEFAULT '[]',
cv_text TEXT NOT NULL DEFAULT '',
cv_languages TEXT NOT NULL DEFAULT '[]',
avoid_text TEXT NOT NULL DEFAULT '',
must_text TEXT NOT NULL DEFAULT ''
);
-- What an agent looks for, as several named texts in order; a role's fit is
@@ -378,6 +395,29 @@ CREATE TABLE IF NOT EXISTS scores (
PRIMARY KEY (uid, agent_id)
);
-- One agent's judge reading of a role against its CV. Its own table, since
-- replace_scores rewrites scores every run and a judgement outlives that
-- and the role closing. skills, experience and career are 0 to 100,
-- cv_score their weighted total, strengths and gaps JSON lists. input_key
-- is a hash of the CV, prompts, avoid text and the role's text it read: a
-- different one is read again. tries counts replies that left the role
-- without one since; at 3 it is given up until the agent is saved again. A
-- row with judged_at NULL holds only tries.
CREATE TABLE IF NOT EXISTS role_judgements (
uid TEXT NOT NULL REFERENCES roles(uid) ON DELETE CASCADE,
agent_id INTEGER NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
skills INTEGER,
experience INTEGER,
career INTEGER,
cv_score REAL,
strengths TEXT NOT NULL DEFAULT '[]',
gaps TEXT NOT NULL DEFAULT '[]',
input_key TEXT NOT NULL DEFAULT '',
tries INTEGER NOT NULL DEFAULT 0,
judged_at TEXT,
PRIMARY KEY (uid, agent_id)
);
-- One vector per role, little-endian float32. Only comparable to another from
-- the same model, so every read is scoped by it.
CREATE TABLE IF NOT EXISTS vectors (
@@ -442,6 +482,10 @@ CREATE INDEX IF NOT EXISTS idx_places_parent ON places(parent_id);
CREATE INDEX IF NOT EXISTS idx_role_remote_place ON role_remote(place_id, uid);
-- The roles the next prep maps. Partial: after a prep there are none.
CREATE INDEX IF NOT EXISTS idx_roles_prep_due ON roles(prep_due) WHERE prep_due > 0;
-- The feed's Closing soon filter. Partial: most roles state no deadline.
CREATE INDEX IF NOT EXISTS idx_roles_deadline ON roles(deadline) WHERE deadline IS NOT NULL;
-- An agent's judgements, for its feed under Best CV match.
CREATE INDEX IF NOT EXISTS idx_role_judgements_agent ON role_judgements(agent_id, cv_score DESC);
"""
#: The table whose absence marks a file that has never been a roledesk
@@ -649,6 +693,11 @@ UPDATE roles SET seniority = COALESCE(NULLIF(seniority_model, ''),
# Anywhere. The areas are written by the next prep (app.prep.stage.VERSION 3).
(27, "roles.remote_model and roles.remote_where_model, role_remote and the Anywhere "
"place: where a remote hire may live", lambda conn: _add_remote_area(conn)),
# A Python step: it adds the columns only where they are missing. The
# deadline is composed by the next prep (app.prep.stage.VERSION 4).
(28, "agents.cv_text, cv_languages, avoid_text and must_text, roles.languages_required and the "
"deadline columns, and role_judgements: the CV match, the language flag and the "
"deadline", lambda conn: _add_cv_match(conn)),
)
#: What a file created from `SCHEMA` today is already at.
@@ -932,6 +981,50 @@ def _add_remote_area(conn: sqlite3.Connection) -> None:
gazetteer.seed(conn)
def _add_cv_match(conn: sqlite3.Connection) -> None:
"""Migration 28's step: an agent's CV, languages, avoid text and
must-haves, all empty; `roles.languages_required` NULL for every role, so `extract`
reads the roles it has read once more for the languages and the
deadline; `roles.deadline_host` from the date a reader already keeps in
`raw` (`applicationDeadline`, Jobnet and Jobbank), `deadline_model`
empty and `deadline` NULL until the next prep; and `role_judgements`,
empty. Runs twice without harm."""
agents = {r[1] for r in conn.execute("PRAGMA table_info(agents)")}
for column, ddl in (("cv_text", "TEXT NOT NULL DEFAULT ''"),
("cv_languages", "TEXT NOT NULL DEFAULT '[]'"),
("avoid_text", "TEXT NOT NULL DEFAULT ''"),
("must_text", "TEXT NOT NULL DEFAULT ''")):
if column not in agents:
conn.execute(f"ALTER TABLE agents ADD COLUMN {column} {ddl}")
roles = {r[1] for r in conn.execute("PRAGMA table_info(roles)")}
for column, ddl in (("languages_required", "TEXT"),
("deadline_host", "TEXT NOT NULL DEFAULT ''"),
("deadline_model", "TEXT NOT NULL DEFAULT ''"),
("deadline", "TEXT")):
if column not in roles:
conn.execute(f"ALTER TABLE roles ADD COLUMN {column} {ddl}")
dated = conn.execute(
"SELECT uid, json_extract(raw, '$.applicationDeadline') FROM roles "
"WHERE deadline_host = '' AND json_extract(raw, '$.applicationDeadline') IS NOT NULL"
).fetchall()
found = [(day, uid) for uid, value in dated if (day := iso_day(value))]
conn.executemany("UPDATE roles SET deadline_host = ? WHERE uid = ?", found)
log.info("migration 28: a host deadline on %d roles", len(found))
conn.execute("""CREATE TABLE IF NOT EXISTS role_judgements (
uid TEXT NOT NULL REFERENCES roles(uid) ON DELETE CASCADE,
agent_id INTEGER NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
skills INTEGER,
experience INTEGER,
career INTEGER,
cv_score REAL,
strengths TEXT NOT NULL DEFAULT '[]',
gaps TEXT NOT NULL DEFAULT '[]',
input_key TEXT NOT NULL DEFAULT '',
tries INTEGER NOT NULL DEFAULT 0,
judged_at TEXT,
PRIMARY KEY (uid, agent_id))""")
def _add_all_roles(conn: sqlite3.Connection) -> None:
"""Migration 21's step. The column; the tag for every company that is a
favourite of any agent, since favourite no longer widens what a pull