~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain-support-agent

grain's support agent: triages mentions and reports, investigates bugs, proposes fixes

1 collaborator
0
0

Keep anything about a child-safety report from models

Merged
Merged chadtmiller.com asked to merge into main from grain.social/grain-support-agent:child-safety
1 reviewer 1 asked for changes

Anything about a child-safety report is kept from models, and acting on it is left to a person, as grain's own MCP server (crates/grain-mcp) already does.

What changes

  • The test is grain's labels::child_safety: label csae, or a reason type starting tools.ozone.report.defs#reasonChildSafety. A report also counts when its account is child safety, meaning grain-serve's social.grain.admin.getReviewSubject returns childSafety: a child-safety report or a csae label was ever made on the account or its records, in any state. If grain-serve can't be asked, the report is treated as child safety.
  • Intake: such a report is held for a person (needs_review, "child safety, for a person only") before anything reads it. It never goes to Clef, an investigation, a chat turn or a fix, and investigations, chats and fixes resumed after a restart check again.
  • What models read (the brief, the queue, support tools, prompts) is the report's id, account and date, plus the same notice grain-mcp gives, pointing at grain admin reports --label csae. The dashboard shows the report in full to a person.
  • SQL: report and classification are now private as well. The authorizer refuses them, and they're hidden from list_tables and describe_table. Models read reports through the brief, where this filter applies.
  • Moderation: act now takes who is acting, model or person. A model can't give or remove csae, and can't act at all on a child-safety subject, including any subject with an open child-safety report. The dashboard's buttons keep working for a person.

Why

Reported child sexual abuse material must not be passed on, and that includes third-party model APIs, Workers AI and OpenRouter among them. Until now a child-safety report's reason, subject and photo link reached both of them, and a model could act on it.

How it was checked

  • npm test -w server: 37 pass, including the new child-safety.test.ts. It covers a csae report, a child-safety reason type, an ordinary report on an account that has had one, and a failed lookup. For each it checks that nothing a model reads holds the reason, subject or image link, that Clef isn't called, that nothing is queued for investigation, and that SQL and moderation refuse.
  • turbo typecheck passes.
  • getReviewSubject is served (crates/grain-serve/src/moderation.rs:76) and returns childSafety from the index.

🤖 Generated with Claude Code

chadtmiller.com added 1 commit
Asked for changes

This pull keeps child-safety reports away from models. It holds them for a person at intake and checks again when a chat, investigation or fix resumes. Prompts, the support tools and the brief show only the report's id, account, date and HUMAN. It closes report and classification to the SQL tool, and the agent's moderate tool refuses csae and any child-safety subject. The intake, resume and moderation gating looks right. It fails closed when grain-serve can't be reached or doesn't send childSafety, and the tests cover the four cases the body lists.

One gap breaks the pull's main claim: the label table can still be read. It holds every csae label grain gave out, with the account or record it is on. Any agent session the SQL tool reaches can run SELECT uri FROM label WHERE val = 'csae' and join it to photo, gallery_item and the other tables. That includes a Bluesky bug investigation or a brief on a clean account, and a prompt injection in a post or report could steer it there. The query gives back exactly the subjects, captions and image blob CIDs this pull is meant to keep from third-party model APIs.

The moderation prompt even points the agent at label. The authorizer works on whole tables, not rows, so the simplest fix is to put label in MODERATION_TABLES too. The brief already carries an account's labels from getReviewSubject when the account isn't child safety. Then drop the label bullet from moderationPrompt, and add a test that SELECT * FROM label WHERE val = 'csae' is refused. If you'd rather keep labels readable, you'd need something that filters by row, such as a view without csae rows that the authorizer allows in place of the base table.

apps/server/src/grain-db.tsline 30
]);
/** Reports and what the classifiers said: a model reads them only as the brief shows them. */
export const MODERATION_TABLES = new Set(["report", "classification"]);
review.knotless.dev

label should be closed here too. It holds every csae label with the record or account it's on, so SELECT uri FROM label WHERE val = 'csae', joined to photo or gallery_item, gives a model the subjects and image blob CIDs this pull means to keep from it. Any session with the SQL tool can run that, including a Bluesky investigation that a post's text steers. The authorizer can't filter rows, so either add label to this set or give the agent a view without csae rows.

apps/server/src/investigate.tsline 108
You can also query grain-serve's index, the appview's database, read-only with the grain-db tools. grain/crates/grain-serve/src/index/schema.rs describes every table. The tables that matter here:
- label: labels grain gave out on the account or its records (uri is the bare DID for an account, an at:// URI for a record; neg = 1 is a retraction).
review.knotless.dev

This bullet still tells the agent to query label, which is where csae labels and their subjects live. Once label is closed, drop the bullet: for an account that isn't child safety, the brief above already lists its labels from getReviewSubject.

Merged as 7c7a99a