Fetch terms narrow what big boards read with the wide reach send (WP F2)

An agent has fetch_terms (migration 23, API, a chip field in the agent
editor). The terms of a pull are the union over the enabled agents, none
when one of them has none. They go only to wide reads: a company tagged All
roles, or a reach ask_for drops as too many countries for a one host; a
board's {"terms": false} switches them off. SmartRecruiters q,
SuccessFactors q, Workday searchText, Phenom keywords, Eightfold query and
Oracle keyword declare query="one"; the runner makes one series per term
times the country series, drops the places first over MAX_SERIES, then the
terms. A term read is narrowed: it writes no ats:size, closes nothing and
prunes no per-role state, and the 10% guard holds it to its own
fingerprint. The Companies reach line counts the terms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 11:59:27 +02:00
1 parent 3917b31209
commit 0fd45b333a
28 files changed
+839 -113

No files matched your search

+17 -2
View File
@@ -295,7 +295,9 @@ END;
-- A search agent: a named saved search with its own prompts, gates and
-- weights. gates is a list of {field, values, mode: require|prefer, weight}.
-- limits is how deep into this agent's ranking extract and summarise read,
-- as JSON: a key it lacks means the `Limits` default.
-- 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.
CREATE TABLE IF NOT EXISTS agents (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
@@ -303,7 +305,8 @@ CREATE TABLE IF NOT EXISTS agents (
weights TEXT NOT NULL DEFAULT '{}',
enabled INTEGER NOT NULL DEFAULT 1,
created_at TEXT NOT NULL,
limits TEXT NOT NULL DEFAULT '{}'
limits TEXT NOT NULL DEFAULT '{}',
fetch_terms TEXT NOT NULL DEFAULT '[]'
);
-- What an agent looks for, as several named texts in order; a role's fit is
@@ -598,6 +601,9 @@ ALTER TABLE companies ADD COLUMN hand_reason TEXT NOT NULL DEFAULT '';
# A Python step: the host words are read out of raw's JSON.
(22, "roles.*_host, roles.employment, roles.prep_due and unmapped: the host's own "
"words are stored and app.prep maps them", lambda conn: _add_host_words(conn)),
# A Python step: it adds the column only where it is missing.
(23, "agents.fetch_terms: words that narrow what big boards read with the wide reach "
"send", lambda conn: _add_fetch_terms(conn)),
)
#: What a file created from `SCHEMA` today is already at.
@@ -830,6 +836,15 @@ def _add_company_aliases(conn: sqlite3.Connection) -> None:
log.info("migration 20: %d companies folded, %d folds shared", len(rows), len(clashes))
def _add_fetch_terms(conn: sqlite3.Connection) -> None:
"""Migration 23's step: `agents.fetch_terms`, empty for every agent, so
no board is narrowed by words until an agent is given some. Runs twice
without harm."""
columns = {r[1] for r in conn.execute("PRAGMA table_info(agents)")}
if "fetch_terms" not in columns:
conn.execute("ALTER TABLE agents ADD COLUMN fetch_terms TEXT NOT NULL DEFAULT '[]'")
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
+13 -6
View File
@@ -26,7 +26,7 @@ from app.models import (
ApplicationEvent, Candidate, Company, Gate, Limits, Prompt, Role, RoleCopy, RolePlace,
RoleRow, ScoredRole,
Subscription, Weights, check_prompts, company_fold, company_key, country_of, excerpt, place_key,
host_word, posted_at, posted_host, remote_of, title_key,
fetch_terms as normal_terms, host_word, posted_at, posted_host, remote_of, title_key,
)
from app.storage import gazetteer, schema
@@ -1712,10 +1712,13 @@ class Store:
def save_agent(self, name: str, intent: str = "", gates: Sequence[Gate] = (),
weights: Weights | None = None, enabled: bool = True,
agent_id: int | None = None, limits: Limits | None = None,
prompts: Sequence[Prompt] | None = None) -> Agent:
prompts: Sequence[Prompt] | None = None,
fetch_terms: Sequence[str] | None = None) -> Agent:
"""Create an agent, or with `agent_id` replace that one's fields and
prompts. Without `prompts`, a non-empty `intent` is its one prompt,
named after the agent. A prompt whose text is unchanged keeps its
named after the agent. Without `fetch_terms` an update keeps the
stored ones and a new agent has none, so a caller that does not know
them (the CLI's prompt edit) loses none. A prompt whose text is unchanged keeps its
cached vector, whatever its name or place, so an edit re-embeds only
the prompts it changed. Raises ValueError on an empty or taken name,
or two prompts of one name, KeyError on an unknown id."""
@@ -1725,18 +1728,22 @@ class Store:
if prompts is None:
prompts = [Prompt(name=name, text=intent)] if intent.strip() else []
prompts = check_prompts(list(prompts))
terms = None if fetch_terms is None else json.dumps(
normal_terms(list(fetch_terms)), ensure_ascii=False)
fields = (name, json.dumps([g.model_dump() for g in gates]),
(weights or Weights()).model_dump_json(),
(limits or Limits()).model_dump_json(), int(enabled))
(limits or Limits()).model_dump_json(), int(enabled), terms)
try:
with self.transaction() as conn:
if agent_id is None:
agent_id = conn.execute(
"""INSERT INTO agents (name, gates, weights, limits, enabled,
created_at) VALUES (?,?,?,?,?,?)""",
fetch_terms, created_at)
VALUES (?,?,?,?,?,COALESCE(?, '[]'),?)""",
(*fields, self.now())).lastrowid
elif not conn.execute(
"""UPDATE agents SET name=?, gates=?, weights=?, limits=?, enabled=?
"""UPDATE agents SET name=?, gates=?, weights=?, limits=?, enabled=?,
fetch_terms=COALESCE(?, fetch_terms)
WHERE id=?""",
(*fields, agent_id)).rowcount:
raise KeyError(agent_id)