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

Moderation takes typed subjects and events, and reports come to the group

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:proposal/moderation

What changes

Subjects are typed. Wherever a moderation subject is sent or answered, it is fyi.opensocial.defs#accountSubject (a did) or #recordSubject (a uri, optionally a cid), in place of a bare URI. subjectView is the proposal's: subject, status (the new subjectStatus), createdAt, updatedAt and reportCount, all required; lastReportedAt is gone.

Events are typed. getSubjectHistory answers moderationEvents (id, createdAt, createdBy, event), each event one of reportEvent (reasonType, reason, rule), statusEvent (status, note), labelEvent (uri, val, deleted) or ejectEvent, in place of eventView. It pages (limit, cursor), oldest first, takes a cid to narrow a record to one version, and no longer answers the subject's view. A subject nothing has happened to has no events. A subject that is no DID or record in the group is InvalidSubject.

Resolving sets a status. resolveSubject takes status (resolved or escalated) and an optional note of 2,000 graphemes / 20,000 bytes, in place of action (resolve, escalate, note). Setting the current status adds a note. It answers the subject's view. A migration turns kept resolve, escalate and note events into status events, a note taking the status before it.

The queue lists one status. listSubjects' status is open unless asked (it listed everything before), with limit from 1.

Reports come to the group. fyi.opensocial.createReport replaces com.atproto.moderation.createReport. It names the group, a typed subject, a reasonType, and optionally a reason and rule, and answers id (a string now) and createdAt. An account can now be reported if it is a member. The reporter must be able to read the subject's space: a record's own, or the members space for an account. A reporter who cannot is refused. The group's labeler now limits what is taken: reasonTypes, subjectTypes and subjectCollections, where present. A new group's labeler takes accounts and records. Refusals are GroupNotFound, InvalidSubject, or InvalidRequest for a reason it does not take or a rule outside the meta space.

The labeler is the proposal's. policies refers to fyi.opensocial.defs#labelerPolicies (moved there), and subjectCollections is an array of NSIDs.

The console and the tools follow. The moderation page shows one status at a time and reads typed events. A note goes with Resolve or Escalate. MCP tool schemas now carry a lexicon's enum.

Why

The host follows the opensocial proposal's moderation methods and shapes, so that apps written to it work here, under fyi.opensocial.*. Where the proposal says nothing, the host keeps its behaviour: labels through applyLabel and negateLabel, the roles' mod.read and mod.resolve, and reopening a resolved subject on a report. The proposal's closed enum statuses and its id fields are let through harness/lexicons.mjs by name. The retyped and removed fields are in its retracted set, and the upstream createReport is retired.

How it was checked

tests/moderation.rs was rewritten for the new shapes. It covers reports from readers and refusals of non-readers, non-members, other groups' spaces, unhosted spaces, unknown kinds and bad rules. It covers the labeler's limits, label and negation events, status events with notes, history paging and cid narrowing, the queue by status, an ejection's event, and the migration of kept events. The members, groups, lexicons and MCP tests pass. cargo fmt, clippy, node harness/lexicons.mjs, node harness/docs.mjs and the console's npm run check pass. CI is left the coverage gate and e2e. The e2e flow now escalates with a note, then reads the escalated queue.

Shortcomings

  • Labels are still fyi.opensocial.label records written by applyLabel, and taken back by negateLabel, not label records written through CRUD as the proposal expects. A negation is answered as a labelEvent with deleted: true and the negating record's URI.
  • ejectEvent is empty, as the proposal's. The host still stores ejectMember's reason but does not answer it.
  • Label events kept before this have no uri, which labelEvent requires.
  • createdBy is always given; the host does not withhold it.

🤖 Generated with Claude Code

Approved

This pull moves moderation onto the proposal's typed subjects and events, adds fyi.opensocial.createReport, makes resolveSubject set a status, and updates the console, MCP tools, docs and tests to match. I read the Rust core (moderation.rs, store.rs, group.rs, lib.rs) closely and found nothing that must change. I did not read the other 21 changed files (lexicon JSON, tests, docs, web, harness, MCP). I relied on the passing lexicons, docs, web and e2e checks and on the PR's own description for those.

  • test check fails. The 100% line gate reports moderation.rs lines 262 and 396 as never run. That is the account branch of subject_ref and the retain in present. A test that queues, reads or resolves an account subject would cover the first. Check the second with --show-missing-lines, since your AGENTS.md says a ? or closure line can be miscounted. The gate enforces this, so it is not a reason to withhold approval.
  • Migration edge case, minor. A migrated note takes the status of the last earlier status event. A report that reopened a resolved subject wrote no status event, so a note after such a report is stored as resolved while the subject was open. This only affects old history. It is worth a line in the shortcomings or a fix.
  • createReport does not check the cited rule. It only checks that the URI is in the meta space. This is not a problem, but a missing record is accepted.
Approved

Round 2. The new commit answers the coverage failure I noted. A test now reads the queue for an account subject, which covers the account branch of subject_ref. present now unwraps an object instead of branching, so it has no uncovered line. Both callers (moderation.rs:432 and :436) pass json! objects, so the expect can't fire. The CI checks for this head were still queued or running when I looked, so I haven't seen the coverage gate pass. I read only this incremental diff; I read the rest of the pull last round.

Two small items from last round are still open. Neither blocks the merge:

  • A migrated note after a reopening report is stored as resolved while the subject was open. Add a line to the shortcomings or fix it.
  • createReport accepts a rule URI in the meta space even if no such record exists.
Approved

Round 3. The only new commit is a merge of main into the branch, which resolved conflicts in tests/moderation.rs, harness/lexicons.mjs and lexicons/fyi/opensocial/defs.json. I did not re-read the merge resolution line by line. I relied on the checks instead: for this head, test (including the coverage gate), e2e, lexicons, docs, web and check (fmt and clippy) all pass. That answers my earlier coverage concern.

Two small items from earlier rounds are still open, and neither blocks the merge:

  • A migrated note after a reopening report is stored as resolved while the subject was open. Add a line to the shortcomings or fix it.
  • createReport accepts a rule URI in the meta space even if no such record exists.
Merged as fd78027