Merge main: read state and tags meet per-agent votes and affinity

The per-agent migration becomes v6 behind main's v5. A vote still stamps
the role's read_at, tag counts hide the agent's hidden companies, and
/api/filters takes the agent like /api/roles.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-28 12:59:41 +02:00
commit c69fb0b6c4
23 files changed
+2270 -717

No files matched your search

+22 -1
View File
@@ -67,6 +67,9 @@ 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,
-- NULL unread, else when the feed first opened it or judged it: a vote
-- stamps this too, see Store.set_vote, because voting is reading.
read_at TEXT,
-- About 60 words from summarise, and when it wrote them.
summary TEXT NOT NULL DEFAULT '',
summarised_at TEXT,
@@ -77,6 +80,15 @@ CREATE TABLE IF NOT EXISTS roles (
created_at TEXT NOT NULL
);
-- The open vocabulary summarise reads off a posting: the role family, the
-- technologies and skills it names, and the domain. What the feed's filter
-- row is built from; see Store.set_tags and Store.tag_counts.
CREATE TABLE IF NOT EXISTS role_tags (
uid TEXT NOT NULL REFERENCES roles(uid) ON DELETE CASCADE,
tag TEXT NOT NULL,
PRIMARY KEY (uid, tag)
);
-- A company as a target, whether or not any board of it is read. key is
-- models.company_key(name), the slug roles.company_key holds.
CREATE TABLE IF NOT EXISTS companies (
@@ -226,6 +238,7 @@ CREATE INDEX IF NOT EXISTS idx_application_events
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);
CREATE INDEX IF NOT EXISTS idx_role_tags_tag ON role_tags(tag);
"""
#: The table whose absence marks a file that has never been a roledesk
@@ -262,13 +275,21 @@ 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;
"""),
(5, "roles.read_at and role_tags, for the feed's read state and tags", """
ALTER TABLE roles ADD COLUMN read_at TEXT;
CREATE TABLE role_tags (
uid TEXT NOT NULL REFERENCES roles(uid) ON DELETE CASCADE,
tag TEXT NOT NULL,
PRIMARY KEY (uid, tag)
);
"""),
# 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", """
(6, "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,