| status | done | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| depends |
|
||||||||||||
| specs |
|
||||||||||||
| pr | 262 |
Chris (2026-11-11), replying to the ops bot's flag of a spam sign-up: "let's build a tool where you can apply 'spam' and 'not spam' votes as our screen in /admin/members enables. Those rulings stage for 3 days so you can freely set them as you see evidence."
Chris (2026-11-12), the policy this plan implements: "When someone actually posts spam, purge immediately. For signups that are obviously spam but haven't posted anything spammy, log a spam vote to put them in the 3-day purge queue pending doing anything that makes them not look like spam."
Read as two cases:
- Posted spam: the account itself put spam content on the site — a promotional bio or link in it, a spam project, update, buzz item or help-wanted role. The agent purges at once.
- Looks like spam, nothing posted: a business or site name as the member name, a throwaway GitHub account. The agent casts a spam vote; the member is hidden and sits in the three-day queue, purged at the end unless something makes them not look like spam.
Two recent cases the design is tested against (described generically):
- An account signed up under a business name and, 90 seconds later, set a promotional bio with a link. Staff purged it. Nine hours later the same GitHub account signed up again, got the same slug, and posted the same bio within 80 seconds.
- An account signed up under a site name, self-joined an existing project as a plain member, and within 70 seconds set a bio advertising a streaming site, with a link.
Today only a staff session can vote or purge, the only way into a session is a
browser GitHub sign-in, every vote is recorded as human-<slug>, and a purged
GitHub account signs straight back in (case 1). This plan gives an automated
moderator its own narrow way in and its own label, a fenced purge for posted
spam, a public log of spam purges that also blocks the purged GitHub account
from signing up again, and fixes votes from a purged account attaching to a
new account with the same slug.
In:
- Agent accounts and agent grants: a public
agent-grantssheet (contractcodeforphilly.org/agent-grants/v1), token hashes in the private store, and the admin endpoints inapi/agents.md(create agent, mint, revoke, list, withdraw staged votes). Three scopes:moderation:read,moderation:vote,moderation:purge(purge needs read; never implied). - Session middleware:
Authorization: Bearer cfpa_…resolves to an agent principal that satisfies onlyagent:<scope>markers;401 grant_invalidotherwise; header redacted from logs. - Votes (the "looks like spam" case):
staff | agent:…on the member endpoints;DELETE …/votefor agents;agent-<slug>evaluator; the agent vote rules (humans final,useronly, 30-day member age forspam, 20 spam votes / 24h, required reasoning, flags); agent-caller redaction (emailnull,emailDomain, domain-onlyq);stagedVote,emailDomain,vote=staged,kindon detail votes. - Agent purge (the "posted spam" case):
POST /api/admin/members/:slug/purgewithreason(no URL),flags, 1–5evidenceitems the API verifies, anddryRun; the eight agent purge rules (signed-upuseronly, joined ≤ 7 days, no human vote, no standinglegitvote, no Slack sign-in, no shared project, evidence goes with the purge, 5 / 24h); one commit per purge withPurge-IdandEvidencetrailers; the agent's vote record written as the "why". spam-purgessheet (contractcodeforphilly.org/spam-purges/v1): written by agent purges, by the scheduled sweep, and by a staff purge marked as spam ({ spam: true, reason }onPOST /api/people/:slug/purge; a checkbox in the Danger Zone dialog).GET /api/admin/spam-purgesandPOST /api/admin/spam-purges/:id/unblock.- Re-registration block (case 1): the GitHub callback refuses
signup_blockedfor a GitHub id an activespam-purgesrecord blocks, and link-GitHub refusesgithub_blocked;/loginshows the message. - Votes belong to one account (a fix): votes with
evaluatedAtearlier than the person'screatedAtare an earlier account's and count for nothing — in the roster fields, deciding votes, the reversal rule, agent rules, the sweep and the offline prune. Newslug-purged-beforesignal; detailearlierVotes/earlierPurges. - Lifecycle: "deciding votes" (humans if any, else agents with an active
grant) in the reversal rule,
spamPurgeDueAtand the sweep; agent accounts excluded from the sweep, votes and purges;Agent-Stagedtrailer and(staged by …)lines on the sweep commit; sweep writesspam-purges. - Commit metadata:
Actor-Kind: agent+Grant-Idtrailers. account-levelrefuses to raise an agent account.prune-spam:agent-*legitprotects;agent-*spamignored; votes older than the person ignored./admin/members: staged badge with reasoning and flags, buttons kept on staged rows, "staged by an agent" filter, "Hidden by {agent} (AI)", history labels,Slug purged beforebadge and Earlier account block, the recent agent purges banner, the Agents panel (show staged, purge counts, withdraw, mint/revoke/new agent, second confirm for a purge grant) and its purge log (reason, evidence links, commit link, unblock).docs/operations/runbook.md: "Agents" (create, mint, rotate, revoke, withdraw) and "Restore a purged member".
Out:
- The bot-side command and loop policy — the
grittybotrepo, described below, its own plan there after this ships. - Creating the production agent account and minting its grants — operator steps after deploy (Rollout below), not code.
- A staff "Restore" button. Restores follow the runbook (git revert, unblock,
Not spam); a
POST /api/admin/spam-purges/:id/restoreis a follow-up if restores become routine. - A public "AI agent" chip on
/members/<slug>— follow-up; the agent's bio says it for now. - Email or Slack notification from the site to staff on an agent purge — the bot posts each one to its operators' channel, and the roster banner shows them for seven days.
- Clearing a human vote; bulk staff actions; scopes beyond moderation.
- Recording who added a project membership (
addedBySlug): would let the API tell a maintainer-added member from a self-joiner; the bot reads it from the commit author for now. - The existing gap that a spam-hidden member can self-reactivate from
/accountand so leave the purge queue — true of staff votes today; worth its own spec decision, not this plan's. - The existing gap that the purge cascade leaves help-wanted roles a purged person posted on a project the purge keeps. Agent purges cannot reach it (posting a role needs a maintainer, and maintaining a shared project blocks the purge); a staff purge can.
- The private store's missing versioning in production (see Risks): the
private-storage.mdclaim that production buckets are versioned does not hold for the filesystem PVC in use. Not this plan's to fix; it limits what a restore recovers.
- api/agents.md — every endpoint (list now staff);
the agent account rules (no sign-in identity, never staff, never voted on,
purged or swept); the three scopes and purge-needs-read; token format,
hashing, expiry, revocation,
lastUsedAt;purgescounts on the list. - api/moderation.md — auth column; Votes belong
to one account;
slug-purged-before;vote=staged,emailDomain,stagedVote,purgeAfteron deciding votes;kind,earlierVotes,earlierPurgeson detail; agent vote fields,DELETE …/vote; Agent callers; Agent votes (rules 1–5);POST …/purgeand Agent purges (rules 1–8, effects, commit);GET /api/admin/spam-purges;POST …/unblock. - api/people.md — purge body
{ spam, reason };agent_accountrefusal on account-level. - api/auth.md — callback "Purged as spam" check,
signup_blocked; link-GitHubgithub_blocked. - behaviors/authorization.md —
agent:<scope>marker; Agent grants; purge is its own scope. - behaviors/person-lifecycle.md —
deciding votes (this account only), reversal rule, staged purge, Agent
purge, spam or not on staff purge, sweep writes
spam-purges, Restoring a purged member, authorization summary. - behaviors/spam-exclusion.md — evaluator kinds; agent votes never prune; agent purge records; earlier account's votes ignored.
- behaviors/storage.md — agent commit trailers, agent purge trailers.
- behaviors/private-storage.md —
agent-grant-secrets.jsonl. - data-model.md —
AgentGrant(three scopes);PersonEvaluationaccount rule;SpamPurge. - screens/admin-members.md — staged rows,
filter, history labels,
Slug purged before, Earlier account, recent agent purges banner, Agents panel, purge log. - screens/login.md —
signup_blockedmessage.
- Votes belong to one account (a fix that stands alone; land first if
split). One helper,
votesOnAccount(state, person), filteringevaluationsByPersontoevaluatedAt >= person.createdAt; use it inspamPurgeDueAt,latestHumanVerdict, the roster's vote fields and the vote filter.prune-spamapplies the same filter. Tests: a re-registered slug with an old staff spam vote shows nolatestVote, is not queued when deactivated, and lists the vote underearlierVotes. - Schema + sheets.
AgentGrantSchemaandSpamPurgeSchemainpackages/shared(Zod;references('people.slug')onAgentGrant.personSlug, no reference onSpamPurge.personSlug),AGENT_EVALUATOR_PREFIX,agentEvaluatorFor,isAgentEvaluator, and anevaluatorKind()that returnshuman | agent | machine. Generate theagent-grants/v1andspam-purges/v1contracts the waysheet-contractsdoes; addapps/api/gitsheets/agent-grants.tomlandspam-purges.toml. Data repo: prepare both sheet configs onempty,fixture,legacy-import,publishedbefore the API deploy that reads them (asperson-evaluations-contractdid). - State. Load
agent-grants(agentGrants,agentGrantsByPerson) andspam-purges(spamPurges,spamPurgesByGithubUserId,spamPurgesBySlug) in the loader, incremental reload andStateApply; addagent-grantsto the slug-rename reference cascade (notspam-purges) and the purge cascade (a purged agent loses its grants and secrets). Private store:agent-grant-secrets.jsonlwithgetGrantSecretByHash,putGrantSecret,deleteGrantSecretsFor(personId); build aMap<hash, grantId>at boot. - Auth. In
auth/middleware.ts, before the cookie: aBearer cfpa_header → hash → grant → checks →SessionContextwithperson= agent,accountLevel: 'user', andagent: { grantId, scopes }. Grant + cookie together → 401.requireAuth/requireAuthMarkergainagent:<scope>; every existing marker treats a session withagentset as anonymous (one guard at the top, so no route can forget). Redactauthorizationin the Fastify logger config. ThrottlelastUsedAtwrites to one an hour. Inauth/github-oauth.ts,completeCallbackchecksspamPurgesByGithubUserIdafterresolveIdentityreturns anything butexisting→signup_blocked;completeLinkCallback→github_blocked. - Moderation service: votes.
decidingVotes(state, slug, now)(on top of step 1) used bycastVote's reversal check,spamPurgeDueAt,stagedVoteand the vote filter, so there is one definition.castVotetakes the caller kind; the agent path runs rules 1–4 inside the mutex (rate count from the agent's own records), writesagent-<slug>with["agent", …flags]and required reasoning.withdrawVoteforDELETE(409 once a human has voted). Agent read redaction in#rowand the detail route.spamPurgeDueAtneeds grant state (active grant per agent) — pass it in withstate.slug-purged-beforesignal fromspamPurgesBySlug. - Moderation service: agent purge.
agentPurge(tx, session, slug, body)inservices/moderation.ts: validate body (reason without URL — a plainhttps?://orwww.test plus bare-domain-with-path), resolve each evidence item to its record and data-repo path, check ownership and non-empty field; then rules 1–8 inside the mutex. ReusepurgePeoplefromservices/person-purge.tsfor the cascade and a dry-run variant ofpurgePreviewfor rule 7 ("goes with the purge") and thedeletedcounts. Write the agent's evaluation and thespam-purgesrecord in the same transaction;beforeCommitis the data repo HEAD read under the lock (verify gitsheets exposes it — see Risks). Route inroutes/moderation.ts. - Staff purge + sweep.
POST /api/people/:slug/purgeaccepts{ spam, reason }and writes aspam-purgesrecord whenspam; the sweep writes one per purged person (by = "scheduled", reason naming the deciding voters). - Spam-purges routes.
GET /api/admin/spam-purges(filters,urls built from the configured data repo GitHub URL +beforeCommit+ path,commitUrlto the record path's history) andPOST …/unblock. - Commit meta.
buildTransactionOptionsaddsActor-Kind: agentandGrant-Idwhensession.agentis set, plusPurge-IdandEvidencetrailers for an agent purge, reason as body. Sweep message lists(staged by agent-<slug>)and theAgent-Stagedtrailer. - Agents routes.
routes/agents.ts+services/agents.tsperapi/agents.md; create-agent writes person + empty private profile + grant + secret in one dual-store transaction;withdraw-votesdeletes and reactivates in one commit, skipping purged slugs; mint refusesmoderation:purgewithoutmoderation:read. - people.account-level refuses agent accounts.
- prune-spam
foldEvaluation:agent-*legit →hasAnyLegit; agent spam skipped; earlier-account votes skipped; test all three. - Web.
AdminMembers.tsx: staged badge, reasoning line, flag chips, buttons on staged rows, filter option, history labels,Slug purged beforebadge and Earlier account block, recent agent purges banner, Agents panel with the once-only token dialog and the purge-grant second confirm, purge log with Unblock. Danger Zone purge dialog: the "This was spam" checkbox./login:signup_blockedmessage. - Docs.
docs/operations/runbook.md— "Agents" (create the agent, mint, hand the token to its host, rotate, add or drop the purge scope, revoke, withdraw) and "Restore a purged member" (the steps inperson-lifecycle.md).
The work fits one PR but splits cleanly: (a) step 1 alone (a bug fix today); (b) steps 2–5, 9–12 and the vote half of 13 (agents can vote); (c) steps 6–8 and the rest of 13–14 (agent purge, the purge log, the sign-up block). Don't ship (b) to production without its UI — the review window is only real once staff can see staged votes — and don't mint a purge grant before (c)'s purge log is live.
-
npm run type-check && npm run lint && npm testclean. - Auth tests: a valid grant reaches
GET /api/admin/membersandPOST …/vote; the same token is refused (401) onuser-marked routes (e.g.PATCH /api/people/:slug),POST /api/auth/refreshmints nothing from it, and public reads see it as anonymous; revoked, expired, deactivated-agent and grant+cookie all 401grant_invalid; a grant withoutmoderation:votegets 404 on vote; withoutmoderation:purge, 404 on purge; minting purge without read → 422. - The token never appears in the commit, the private store (only its hash), or a captured request log line.
- Vote rules: agent vote on a human-voted member → 409
human_verdict_exists; on staff/agent/self → 409/422; spam on a member older than 30 days → 409member_too_old; 21st spam vote in 24h → 429 withRetry-After; missing reasoning → 422;DELETEafter a human vote → 409. - Side effects: agent spam hides; agent legit /
DELETEun-hides only when the agent's spam hid them; a stafflegiton a staged member un-hides and stops the purge; a staffspamconfirms and movespurgeAfterto its own date. - Case 1 fixture: a member created 2 minutes ago with a business name
and a bio with a link; agent purge citing
person#bio→ 200, one commit, person and avatar gone,spam-purgesrecord withgithubUserId,blocksSignIn; the reason's URL check rejects a reason containing the link. A GitHub callback for the samegh.id→ redirect/login?error=signup_blocked, nothing written. Afterunblock, the callback creates a fresh person; the roster showsslug-purged-before, nolatestVote, and the old votes underearlierVotes. The same flow with a staff Danger Zone purge (spam: true) blocks the same way; withspam: false, no record and no block. - Case 2 fixture: a 1-minute-old member who self-joined another person's project (not maintainer) and set a promotional bio → agent purge 200; their membership is gone; the project, its other members and their records are unchanged.
- Agent purge refusals: member 8 days old →
member_too_old; any human vote (spam or legit) →human_verdict_exists; an agentlegit→legit_vote_exists;lastSlackSsoAtset →established_member; created a project someone else joined, or maintains a project with another member →shared_project; evidence on a record not theirs or empty →evidence_invalid; evidence on a project the purge keeps →evidence_survives; imported member →protected_account; 6th purge in 24h → 429. Each refusal writes nothing.dryRun: truepasses or fails the same and writes nothing. - Agent purge commit: author the agent's pseudonymous identity; subject
<agent>: POST /api/admin/members/<slug>/purge; body the reason; trailersAction: person.purge,Actor-Kind: agent,Grant-Id,Purge-Id, oneEvidence:per item;git show <sha>^:<evidence path>shows the spam. - Sweep: an agent-only spam member ≥ 3 days with an active grant is
purged, listed
(staged by agent-<slug>),Agent-Staged: 1, with aspam-purgesrecordby = "scheduled"; with the grant revoked, not queued andstagedVote.counts = false; agent accounts never queued; a re-registered slug with only an earlier account's spam vote is never queued. - Commit for an agent vote: author is the agent's pseudonymous identity,
subject
<agent>: POST /api/admin/members/<slug>/vote, trailers includeActor-Kind: agent,Grant-Id,Actor-Account-Level: user. -
withdraw-votes: one commit; counts right; votes on human-voted and on purged members untouched. - account-level refuses to raise an agent (
409 agent_account). - prune-spam: agent legit protects; agent spam does not prune; an earlier account's human spam vote does not prune the new account.
- Contract:
gitsheets contracts verifyclean on every data-repo branch with theagent-grantsandspam-purgesconfigs; boot fails loudly without them. - Restore runbook rehearsed on the devbox: agent-purge a fixture member,
unblock,
git revert --no-commitkeepingspam-purges/, push, hot reload, vote Not spam, sign in as that GitHub user. - Browser (devbox): create an agent, mint (token shown once; purge grant
asks twice), vote and purge with
curlas the agent, see the staged badge with reasoning in the default roster view, overrule with Not spam, see the banner and the purge log with evidence and commit links, unblock, withdraw, revoke; see/login?error=signup_blocked.
- A wrong purge. Unlike a vote, it acts before anyone looks. Bounded by
the API rules (new, unestablished, unvoted, nothing shared, evidence the
member authored), the 5-a-day cap, a public log with the reason and the
spam as it stood, the banner, and the bot posting every purge to its
operators. Recovery is the runbook: public records come back exactly; the
private profile does not (no versioning or backup of the production
PVC —
docs/operations/deploy.md), so the person's email, newsletter choice and Slack link are lost and rebuilt on their next GitHub sign-in. - A leaked token. With read + vote it can hide up to 20 new members a day; with purge, also delete up to 5 a day of members under 7 days old who authored something. Recovery: revoke (purges and staged purges stop at once), withdraw (hidden members return), restore any wrong purges by hand. The purge scope is why the first grant leaves it out (Rollout).
- The API cannot judge content. It checks that the cited record is the member's and non-empty, not that it is spam. A purge citing an innocent bio passes the API; the reason, evidence links and operator channel are what catch it. The narrow population (≤ 7 days, nothing shared, no Slack) keeps the cost of that small.
- Nobody looks during the three days. The window is only a safeguard if someone reviews. The bot side reports each vote to the operators' channel and the members nearing purge (below); the roster's default view includes staged rows.
- An agent arguing with staff. The rules make that impossible on the site; the bot's own policy must still not re-vote or purge someone a human cleared (it can't — 409 — but it should not retry).
- Blocking a GitHub id is permanent until someone unblocks. A person whose account was purged as spam by mistake can't sign up again and is told to email; staff unblock from the log.
beforeCommit. The purge record wants the data repo commit it was applied on. If gitsheets' transaction does not expose its parent, readHEADof the data branch under the write lock before transacting; verify in step 6.- Data-repo ordering. The API must not boot against a branch without the
agent-grantsandspam-purgesconfigs; land the data-repo commits first (asperson-evaluations-contractdid). lastUsedAtwrites to the private store on a polling agent; throttled to one an hour per grant.
Each with a recommended answer. (The 2026-11-11 question "purge a bot-only spam vote after three days with no person looking?" is answered by the policy: yes.)
Resolved 2026-11-12: the operator said to build with the recommended answers, so every question below (1–17) was resolved with its recommended answer, as written. The reasoning stays as the record of why.
- Daily caps and age windows. 20 spam votes / 24h on members under 30 days; 5 purges / 24h on members under 7 days. Recommend as written: both real cases posted within two minutes of signing up.
- Should the agent see full emails? No, the domain only.
- Create the agent as a site record, with no GitHub sign-in? Yes.
- Should staff voting Spam on a staged row restart the three days? Yes, the existing rule.
- Grant lifetime? 90 days, renewed by an administrator.
- Is purge a separate scope, and does the first grant carry it?
Separate (
moderation:purge, never implied). First grant: read + vote only. Mint a read + vote + purge grant (and revoke the old one) once the purge log is live and the bot's rules change is merged. - Does any human vote block an agent purge, or only "not spam"? Any. A staff "not spam" must win; a staff "spam" already hid the member and set a clock the agent should not shorten.
- Does a project membership block an agent purge? Only a shared one: creating a project someone else touched, or maintaining a project with another member. A plain self-join (case 2) does not block — joining is self-service and carries no maintainer's judgment; the membership goes and the project stays.
- Does a Slack sign-in block an agent purge? Yes — the person got far enough to use the community; a human decides.
- Is the re-registration block in scope, and where does it live? In
scope, as a public
spam-purgesrecord checked at the GitHub callback, with a staff unblock.githubUserIdis already public on every person record and in the purged record's history, so a public block list exposes nothing new and keeps the block auditable; the private store has no history in production. Not adopted: treating "slug or GitHub id purged before" as posted-spam evidence on its own — with the block, the same GitHub id cannot return, and a new GitHub account gets a new slug, so the rule would only matter after an unblock, which is exactly when it should not fire. The bot usesslug-purged-beforeas a strong vote signal. - Should the scheduled sweep's purges also block sign-up? Yes: three days unopposed is a spam verdict. A mistaken one is one Unblock click.
- Staff Danger Zone purge: "This was spam" checkbox default? Checked when the person has a spam vote on their current account, else unchecked, so an erase-me request never lands on the block list by default.
- Restore: endpoint or runbook? Runbook now; an endpoint if restores pass about one a month.
- Forbid URLs in a purge reason? Yes, so the spam link is never republished in a permanent public commit; the evidence path points at it.
- Should the member's name or avatar count as posted-spam evidence? No. A business name is the "looks like spam" case (a vote). Avatars are rarely the spam and are hard to review from a log; revisit if they become the vector.
- Ship the "votes belong to one account" fix with this plan or first? First, as its own small PR (step 1): it is a bug for staff votes today (case 1's re-registration showed the earlier account's staff vote as its own).
- Should the site itself notify staff of an agent purge? Not yet: the bot posts each purge to its operators' channel and the roster banner shows it for seven days. Revisit if purges go unseen.
Kept from before, not addressed here: a member hidden by a spam vote can still sign in and reactivate themselves, which takes them out of the purge queue. That is true of staff votes today.
A small command, bin/member-vote, the bot's only way to vote or purge:
bin/member-vote show <slug> # roster row + votes, JSON
bin/member-vote <slug> spam|not-spam --reason "…" [--flag <tag>]… [--dry-run]
bin/member-vote <slug> clear # DELETE its own vote
bin/member-vote <slug> purge --evidence <path or url>… --reason "…" [--flag <tag>]… [--dry-run]
bin/member-vote staged # its staged votes and purge dates
bin/member-vote purges [--since <date>] # its purge log
purgerequires at least one--evidence(a data-repo path such aspeople/<slug>.toml#bioorproject-updates/<project>/<n>.toml, or the site URL of the record, which the command maps to one) and--reason(the command refuses a reason with a URL before calling the API).--dry-runsendsdryRun: trueand prints what would go.- Credential:
~/.config/grittybot/cfp-agent-token, mode 0600, beside the Slack app token, never in the repo, read by the command only; the site base URL inopsbot.json(site.base_url). The operator mints the grant and places the file; the bot never sees a person's credential and holds no site session. - Output: the API's result plus the purge date or purge record, one JSON line appended to the cycle log; a refusal (409/422/429) is reported as such, never retried around.
- Visibility: every vote and every purge it makes is posted to
#grittybot-hqin the same cycle (member slug, verdict or purge, reason, evidence paths, purge date or commit link, roster or purge-log link); once a day, a list of its staged votes that purge within 24 hours. - Decision rule (loop policy, in the bot's specs), in the operator's
words: "When someone actually posts spam, purge immediately. For signups
that are obviously spam but haven't posted anything spammy, log a spam vote
to put them in the 3-day purge queue pending doing anything that makes them
not look like spam." From the
30-data-commitsstream'snew-memberandprofile-edititems:- Purge when the member has posted spam: a bio (or a project, update,
buzz item or role they authored) that promotes a business, product or
site unrelated to civic tech, typically with a link, and it is that
record the bot cites. If the API refuses (too old, shared project, Slack,
a human vote), it votes
spaminstead when allowed and flags the member to the operators. - Vote
spamwhen nothing spammy is posted but at least two independent signals agree and none contradicts: a business or site name as the member name; a GitHub account hours old (author-account-<n>h-old) or the roster'sgithub-new-account/github-no-activity; a throwawayemailDomain;slug-purged-before. - Never vote or purge anyone it is talking to, anyone a maintainer added to a project (the membership commit's author is not the member), or anyone with a project footprint shared with other people; those it flags to the operators.
- Clear its vote (or vote
not-spam) at once when a member it staged stops looking like spam. What counts: a staffnot-spam(the site already overrules; the bot just stops tracking); a maintainer adding them to a project or making them a maintainer; a real profile — a bio that describes a person and their interests, with no promotional link; a non-promotional update or comment on a project with other members; a Slack sign-in; a reply to the bot or an operator. What does not count on its own: a self-join to a project, an RSVP, an avatar, or a renamed account that still reads as a business.not-spamwhen it has positive evidence;clearwhen the signal is only that the spam case no longer holds.
- Purge when the member has posted spam: a bio (or a project, update,
buzz item or role they authored) that promotes a business, product or
site unrelated to civic tech, typically with a link, and it is that
record the bot cites. If the API refuses (too old, shared project, Slack,
a human vote), it votes
- Rules change in the bot repo: the bot's own rule card makes every delete
wait for an operator's gate word, given in the operator's own words for
that one action. A staged vote is not a delete (the site's three days and
human overrule are the gate), but a purge is. A standing authorization for
posted-spam purges under this policy is a change to the bot's rules, being
proposed separately as a reviewed PR to the bot's protocols; a person
merges it. Until it merges, the bot votes
spamon posted-spam accounts (which hides the spam at once) and asks the operator, even if its grant carries the purge scope.
- Data repo:
agent-grantsandspam-purgessheet configs on every branch. - Release + deploy (sandbox first; sandbox shares
publishedbut does not sweep). - An administrator creates the agent account on production with a bio
saying it is an AI run by Code for Philly, mints a
moderation:read, moderation:votegrant (90 days), and places the token on the bot's host. - The bot ships
bin/member-vote(vote verbs) and its policy; first week, it posts every vote and the operator reviews the lot. - Once the purge log is live in production and the bot's rules change is
merged, an administrator mints a
moderation:read, moderation:vote, moderation:purgegrant (90 days), revokes the read + vote one, and replaces the token file. The bot turns on thepurgeverb; first week, the operator reviews every purge in the log.
An independent review (2026-11-12) of the first build found ten gaps; the specs were corrected first, then each was fixed with a test:
- votes dated at or before a
spam-purgesrecord for the slug that names another person do not count (a long-standing member could otherwise take a freed slug and inherit a spammer's votes), and a rename onto a slug with moderation history is refused (slug_retired); - an agent purge or vote is checked, committed and applied to the in-memory
state under one lock (
Store.transact'sonCommit), so concurrent purges cannot pass the daily allowance or purge one slug twice; the dry run reads the member under that lock; - agent accounts are never claim candidates and staff cannot approve a claim on one;
grantis required when an agent is created (an agent is "has any grant record", active or not);- agent accounts cannot be renamed;
- revoke takes
withdrawVotes: truefor a compromised token; the spec now says staged votes count again when a new grant is minted unless withdrawn; - the URL check catches bare domains and defanged forms, and applies to agent
vote
reasoningtoo; control characters are refused in both; - evidence identifiers are pattern-checked before lookup;
- writes of
agent-grant-secrets.jsonlare serialized.
Built as specified, with three spec edits made along the way: an agent
account has no private profile; the purge log carries byRef (who purged,
resolved to kind, slug and name) beside the stored by; and the data scrub
pseudonymizes the new slug fields (agent-grants, spam-purges).
- Repeated
Evidence:trailers are written inline in the commit message, because gitsheets trailers are a single-value map;git interpret-trailers --parsestill reads oneEvidence:line per item. - The 20-a-day spam-vote cap counts the agent's current vote records, so a re-vote on the same member within 24 hours replaces its record rather than adding to the count.
- The
Contractbox stays unchecked.gitsheets contracts verifyis clean onempty,fixtureandlegacy-importwith both configs added, in codeforphilly-data PRs 21, 22 and 23, merged on 2026-11-12;publishedis adopted at release time perdocs/operations/releases.md→ "Releases that change a schema contract". The box closes when the release adoptspublished. Without the configs the store refuses to open ("Store opens with validators.agent-grants, but .gitsheets/agent-grants.toml is not declared"), checked againstfixtureas it stood before the configs; no test covers that missing-sheet case specifically. - Validation boxes ticked on tests: auth and scopes
(
apps/api/tests/agents-auth.test.ts,agent-votes.test.ts,agent-purge.test.ts); token nowhere (agents-auth.test.ts"keeps only the hash" and "request logs",agent-votes.test.tscommit test); vote rules, side effects, the vote commit,withdraw-votesand the sweep (agent-votes.test.ts, with the human-decided sweep record inspam-purge-block.test.ts); case 1 (agent-purge.test.ts,spam-purge-block.test.ts,votes-one-account.test.ts); case 2, every purge refusal with its dry run, and the purge commit (agent-purge.test.ts);agent_account(agents-auth.test.ts); prune-spam (prune-spam.test.ts). At closeout two assertions were missing and were added toagent-votes.test.ts: a vote on a member purged since is left alone bywithdraw-votes, and the sweep writes aby = "scheduled"record for an agent-staged purge. The full gate passed at8f4ce58; the closeout re-ranagent-votes.test.ts, type-check and lint. - Restore and browser rehearsal (2026-11-12, devbox, invented personas only):
the dev API served a throwaway bare clone of
fixture(configs added), whoseoriginwas a second local bare repo standing in for GitHub; pushes from the API's clone to it stood in for the push daemon (noCFP_DATA_REMOTE). GitHub OAuth was not real: the API process loaded an msw interceptor for GitHub's token,/userand/user/emailsendpoints, so the site's own/api/auth/github/startand/callbackran end to end. An invented sign-up set a promotional bio and self-joined a project; an agent created in the New agent form (which refuses to submit without the first grant's label), with a purge grant minted through the second confirm, purged it withcurl; sign-in as its GitHub id went to/login?error=signup_blockedwith nothing written; Unblock from the purge log; the runbook's revert in a working clone, pushed to the stand-in origin, thenPOST /api/_internal/reload-data(fast-forwarded, rebuilt); Not spam from the roster; sign-in as the same GitHub id signed in as the restored person (same id), rebuilding the private profile's email. Also in the browser: staged badge with reasoning and flags in the default view, overrule with Not spam (history reads "overruled"), the banner, the purge log's evidence and commit links, withdraw, and revoke with the "may be compromised" box (token then401 grant_invalid). Dialogs checked at desktop and 390px; no console errors. - The rehearsal corrected the restore steps
(
docs/operations/runbook.md, and the command inspecs/behaviors/person-lifecycle.md): after an unblock,git revert --no-commitstops with a modify/delete conflict on thespam-purgesrecord and exits non-zero, so the spec'srevert && checkoutnever ran the checkout; the working clone must be pulled after the unblock; the Commit link opens the record's history, whose oldest entry is the purge; a purge leaves votes in place, so a member restored from the sweep comes back hidden and past due, and Not spam must land before the next sweep.
No planned plan owns any of these, so none is Deferred to. Entries marked
(file an issue) should become Issue [#N] entries once filed.
- Tracked as: (file an issue)
castVotestill replaces an evaluator's record on an earlier account under the same slug (person-evaluations/<slug>/<evaluator>has one slot per evaluator per slug). Keeping both needs a path change (a new contract version), so it is left; thespam-purgesrecord still names the purge's reason, and git history keeps the old vote. - Tracked as: (file an issue)
scripts/prune-spam.tsapplies only thecreatedAtrule for earlier accounts, not the newerspam-purgescutoff. - Tracked as: (file an issue) routes outside moderation and agents still
apply their state after
store.transactreturns; moving them toonCommitwould close the same gap for every write. - Tracked as: (file an issue)
POST /api/admin/private-data/purge-orphansdoes not count or delete orphaned agent grant secrets. - Tracked as: (file an issue) the staff purge's "This was spam" reason gets the URL check but not the control-character check that agent reasons get.
- Tracked as: (file an issue) a restored member keeps the
slug-purged-beforesignal and shows their own purge under Earlier account, since the rule is "aspam-purgesrecord names this slug"; whether a record naming the same person should count is a spec decision. - Tracked as: the general 30-writes-a-minute per-account cap also applies to agents, purge dry runs included; revisit if the bot's dry-run-then-purge pattern hits it.
- Tracked as: a public "AI agent" chip on
/members/<slug>(the agent's bio says it for now); revisit after the bot's first weeks. - Tracked as: a
POST /api/admin/spam-purges/:id/restoreendpoint if restores pass about one a month (Open question 13); the runbook covers them until then. - Tracked as: the Revoke confirm's unchecked text says staged votes stop counting "while it holds no active grant", which reads as if they stop even when the agent keeps another active grant (the rotation case, where they keep counting); a wording tweak.
- Issue CodeForPhilly/grittybot#22
— the bot-side
bin/member-votecommand and loop policy (Bot side above).