Per-agent ranking: votes, affinity and a taste term; settings are three sub-tabs
Votes on roles and company affinity move to role_votes and agent_companies, one row per search agent, so two agents rank the same roles differently. The score gains taste, the cosine to mean(liked) - mean(passed) of the agent's votes, as newsdesk ranks articles. The API takes agent on roles, votes and companies and falls back to the default agent, the enabled one with the lowest id. Settings become Search agents (a list again, with New and Delete), Sources (job boards, company boards and runs with the message log, one section per plugin) and Account. Old paths answer 301 to their section. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
515d2250fc
commit
a0772519b3
28 files changed
+1461
-668
No files matched your search
+60
-6
@@ -67,10 +67,6 @@ CREATE TABLE IF NOT EXISTS roles (
|
||||
-- Replies from extract that left this role unanswered. At GIVE_UP_AFTER it
|
||||
-- is no longer offered. A column, not raw, because every upsert rewrites raw.
|
||||
extract_tries INTEGER NOT NULL DEFAULT 0,
|
||||
-- The owner's judgement of the role: NULL unjudged, else -1 pass, 0
|
||||
-- neutral, 1 like. It moves the rank at read time and never hides a role.
|
||||
vote INTEGER CHECK (vote IN (-1, 0, 1)),
|
||||
voted_at TEXT,
|
||||
-- About 60 words from summarise, and when it wrote them.
|
||||
summary TEXT NOT NULL DEFAULT '',
|
||||
summarised_at TEXT,
|
||||
@@ -87,8 +83,6 @@ CREATE TABLE IF NOT EXISTS companies (
|
||||
key TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
domain TEXT NOT NULL DEFAULT '',
|
||||
-- -1 mute, 0 neutral, 1 interested, 2 favourite.
|
||||
affinity INTEGER NOT NULL DEFAULT 0 CHECK (affinity BETWEEN -1 AND 2),
|
||||
status TEXT NOT NULL DEFAULT 'researching',
|
||||
careers_url TEXT NOT NULL DEFAULT '',
|
||||
notes TEXT NOT NULL DEFAULT '',
|
||||
@@ -167,6 +161,29 @@ CREATE TABLE IF NOT EXISTS agents (
|
||||
intent_vec BLOB
|
||||
);
|
||||
|
||||
-- One agent's stance on a company: -1 hidden, 0 neutral, 1 liked, 2
|
||||
-- favourite. No row is 0, so the table holds only what somebody set. Per
|
||||
-- agent, because a company that is noise for one search is the target of
|
||||
-- another.
|
||||
CREATE TABLE IF NOT EXISTS agent_companies (
|
||||
agent_id INTEGER NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
|
||||
company_key TEXT NOT NULL,
|
||||
affinity INTEGER NOT NULL CHECK (affinity BETWEEN -1 AND 2),
|
||||
updated_at TEXT NOT NULL,
|
||||
PRIMARY KEY (agent_id, company_key)
|
||||
);
|
||||
|
||||
-- One agent's judgement of a role: -1 pass, 0 neutral, 1 like. No row is
|
||||
-- unjudged. A vote moves the rank at read time, never hides a role, and its
|
||||
-- vectors shape the agent's taste direction in `score`.
|
||||
CREATE TABLE IF NOT EXISTS role_votes (
|
||||
agent_id INTEGER NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
|
||||
uid TEXT NOT NULL REFERENCES roles(uid) ON DELETE CASCADE,
|
||||
vote INTEGER NOT NULL CHECK (vote IN (-1, 0, 1)),
|
||||
voted_at TEXT NOT NULL,
|
||||
PRIMARY KEY (agent_id, uid)
|
||||
);
|
||||
|
||||
-- A role is scored per agent. A gated role keeps its row, with the reason.
|
||||
CREATE TABLE IF NOT EXISTS scores (
|
||||
uid TEXT NOT NULL REFERENCES roles(uid) ON DELETE CASCADE,
|
||||
@@ -207,6 +224,7 @@ CREATE INDEX IF NOT EXISTS idx_roles_board ON roles(source, subscription_id
|
||||
CREATE INDEX IF NOT EXISTS idx_application_events
|
||||
ON application_events(application_id, at);
|
||||
CREATE INDEX IF NOT EXISTS idx_scores_agent ON scores(agent_id, score DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_role_votes_agent ON role_votes(agent_id, vote);
|
||||
CREATE INDEX IF NOT EXISTS idx_vectors_model ON vectors(model);
|
||||
"""
|
||||
|
||||
@@ -244,6 +262,42 @@ ALTER TABLE roles ADD COLUMN summary TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE roles ADD COLUMN summarised_at TEXT;
|
||||
ALTER TABLE roles ADD COLUMN article_text TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE roles ADD COLUMN article_at TEXT;
|
||||
"""),
|
||||
# Votes and affinities move from the role and company rows to one row per
|
||||
# agent. What was global goes to the default agent, the enabled one with
|
||||
# the lowest id (`Store.default_agent`); a file with something to move and
|
||||
# no agent gets one first, so nothing is lost. The columns are then
|
||||
# dropped, which SQLite has allowed since 3.35.
|
||||
(5, "agent_companies and role_votes: affinity and vote become per agent", """
|
||||
CREATE TABLE agent_companies (
|
||||
agent_id INTEGER NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
|
||||
company_key TEXT NOT NULL,
|
||||
affinity INTEGER NOT NULL CHECK (affinity BETWEEN -1 AND 2),
|
||||
updated_at TEXT NOT NULL,
|
||||
PRIMARY KEY (agent_id, company_key)
|
||||
);
|
||||
CREATE TABLE role_votes (
|
||||
agent_id INTEGER NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
|
||||
uid TEXT NOT NULL REFERENCES roles(uid) ON DELETE CASCADE,
|
||||
vote INTEGER NOT NULL CHECK (vote IN (-1, 0, 1)),
|
||||
voted_at TEXT NOT NULL,
|
||||
PRIMARY KEY (agent_id, uid)
|
||||
);
|
||||
INSERT INTO agents (name, intent, gates, weights, enabled, created_at)
|
||||
SELECT 'My ranking', '', '[]', '{}', 1, strftime('%Y-%m-%dT%H:%M:%S+00:00', 'now')
|
||||
WHERE NOT EXISTS (SELECT 1 FROM agents)
|
||||
AND (EXISTS (SELECT 1 FROM roles WHERE vote IS NOT NULL)
|
||||
OR EXISTS (SELECT 1 FROM companies WHERE affinity <> 0));
|
||||
INSERT INTO role_votes (agent_id, uid, vote, voted_at)
|
||||
SELECT (SELECT id FROM agents ORDER BY enabled DESC, id LIMIT 1), uid, vote,
|
||||
COALESCE(voted_at, strftime('%Y-%m-%dT%H:%M:%S+00:00', 'now'))
|
||||
FROM roles WHERE vote IS NOT NULL;
|
||||
INSERT INTO agent_companies (agent_id, company_key, affinity, updated_at)
|
||||
SELECT (SELECT id FROM agents ORDER BY enabled DESC, id LIMIT 1), key, affinity, updated_at
|
||||
FROM companies WHERE affinity <> 0;
|
||||
ALTER TABLE roles DROP COLUMN vote;
|
||||
ALTER TABLE roles DROP COLUMN voted_at;
|
||||
ALTER TABLE companies DROP COLUMN affinity;
|
||||
"""),
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user