Phase 11, part 3: approvals for what agents send out

Agents can now ask to publish or schedule a post, send an email, add
someone to a mailing list, or apply an SEO change. Each waits on the
Approvals page (with a count in the sidebar) for an admin or a member with
edit on its module, who can edit it first, approve or refuse it, and let
the agent take that class of action on its own with a cap per day. A
rotation after a leak revokes the old keys and withdraws everything
allowed. All of it is in the audit log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 10:54:53 -07:00
co-authored by Claude Opus 5.5
parent bfb74e7700
commit 311d2e815b
17 changed files with 1396 additions and 13 deletions
+32
View File
@@ -185,6 +185,38 @@ CREATE TABLE agent_keys (
);
CREATE INDEX agent_keys_user ON agent_keys(user_id);
ALTER TABLE users ADD COLUMN description TEXT NOT NULL DEFAULT '';
`,
},
// 38
{
Note: "approvals: what agents ask to send out, and what they may do on their own",
SQLite: `
CREATE TABLE approvals (
id INTEGER PRIMARY KEY,
agent_id INTEGER NOT NULL,
class TEXT NOT NULL, -- post:<account>, email-first, email-reply, list:<id>, seo-change:<site>
module TEXT NOT NULL, -- whose members decide: content, prospects, seo
target_id INTEGER NOT NULL, -- the draft, message, contact or change
params TEXT NOT NULL DEFAULT '{}', -- what else it needs: when, which list…
summary TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'waiting', -- waiting, done, refused, failed
created_at TEXT NOT NULL,
decided_at TEXT NOT NULL DEFAULT '',
decided_by INTEGER NOT NULL DEFAULT 0, -- 0 with done: the agent did it on its own
result TEXT NOT NULL DEFAULT ''
);
CREATE INDEX approvals_status ON approvals(status, created_at);
CREATE INDEX approvals_agent ON approvals(agent_id, class, decided_at);
CREATE TABLE agent_autonomy (
agent_id INTEGER NOT NULL,
class TEXT NOT NULL,
label TEXT NOT NULL, -- what it is, in words
module TEXT NOT NULL,
daily_cap INTEGER NOT NULL DEFAULT 0, -- 0: no cap
granted_by INTEGER NOT NULL,
granted_at TEXT NOT NULL,
PRIMARY KEY (agent_id, class)
);
`,
},
}