Add the trust and safety subsystem and the App Store compliance work

Implements the moderation and consent obligations a social platform carries,
so the web version and any client that speaks to it enforce the same rules.

Moderation core (services/moderation/, database/moderation.py): a reportable
target registry, the content filter and its choke points, the report queue with
atomic resolution, enforcement actions, consent tracking, maturity gating, and
account deletion with a grace window.

Surfaces: POST /reports plus the member report list, /admin/moderation and the
per-report admin view, /workspaces, terms acceptance at /auth/terms, consent and
account deletion under /profile, the report button and dialog partials, the
maturity gate, and the moderation stylesheet and ReportDialog client.

Every user-generated surface stays reportable by construction: new content tables
are registered in REPORTABLE_TARGETS or listed in UNREPORTABLE_TABLES with a
reason, and the registry test fails the suite on anything left unclassified.

Docs: community guidelines, content moderation, intellectual property, privacy,
terms, contact, and the admin-only moderation operations page, plus the
moderation API group and the Devii moderation actions.

Compliance record: applecomp.md is the requirement register, applechanges.md the
gap analysis against this codebase, and appleimpl.md the implementation design
they resolve to.

Tests cover the report flow, admin moderation, consent, account deletion, terms
acceptance, workspaces, and the registry invariant across the unit, api, and e2e
tiers.
This commit is contained in:
2026-08-09 00:18:20 +02:00
parent 68c2bbe387
commit 8e9d3fad98
348 changed files with 10633 additions and 238 deletions
+1
View File
@@ -46,6 +46,7 @@ def _seed_owner():
{
"uid": uid,
"username": f"seo_{uid[:8]}",
"terms_version": "1",
"email": f"{uid[:8]}@seo.test",
"password_hash": "x",
"role": "Member",
+8
View File
@@ -15,6 +15,8 @@ def test_login_success(page, app_server):
page.fill("#email", "login@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
@@ -34,6 +36,8 @@ def test_login_wrong_password(page, app_server):
page.fill("#email", "wrongpw@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
@@ -52,6 +56,8 @@ def test_login_remember_me(page, app_server):
page.fill("#email", "remember@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
@@ -72,6 +78,8 @@ def test_logout(page, app_server):
page.fill("#email", "logout@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
+1
View File
@@ -35,6 +35,7 @@ def test_reset_password_full_flow(page, app_server):
{
"uid": uid,
"username": uname,
"terms_version": "1",
"email": email,
"password_hash": hash_password("oldpass123"),
"bio": "",
+31
View File
@@ -69,6 +69,7 @@ def _seed_owner():
{
"uid": uid,
"username": f"seo_{uid[:8]}",
"terms_version": "1",
"email": f"{uid[:8]}@seo.test",
"password_hash": "x",
"role": "Member",
@@ -211,6 +212,8 @@ def test_signup_success(page, app_server):
page.fill("#email", "fresh@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
assert page.is_visible("text=fresh_user")
@@ -222,6 +225,8 @@ def test_signup_existing_username(page, app_server):
page.fill("#email", "dup1@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
@@ -231,6 +236,8 @@ def test_signup_existing_username(page, app_server):
page.fill("#email", "dup2@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
expect(page.locator("text=Username already taken")).to_be_visible()
@@ -241,6 +248,8 @@ def test_signup_existing_email(page, app_server):
page.fill("#email", "sameemail@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
@@ -250,6 +259,8 @@ def test_signup_existing_email(page, app_server):
page.fill("#email", "sameemail@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
expect(page.locator("text=Email already registered")).to_be_visible()
@@ -260,6 +271,8 @@ def test_signup_password_mismatch(page, app_server):
page.fill("#email", "mismatch@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "different456")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
expect(page.locator("text=Passwords do not match")).to_be_visible()
@@ -270,6 +283,8 @@ def test_signup_short_password(page, app_server):
page.fill("#email", "shortpw@test.devplace")
page.fill("#password", "ab")
page.fill("#confirm_password", "ab")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
expect(page.locator("text=Password must be at least 6 characters")).to_be_visible()
@@ -280,6 +295,8 @@ def test_signup_invalid_username(page, app_server):
page.fill("#email", "shortname@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
expect(
page.locator("text=Username must be between 3 and 32 characters")
@@ -316,6 +333,8 @@ def test_landing_authenticated_shows_dashboard(page, app_server):
page.fill("#email", "home@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
with page.expect_navigation(timeout=10000):
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
@@ -346,6 +365,8 @@ def test_registration_closed_blocks_signup(alice):
"email": "closed_signup@test.devplace",
"password": "secret123",
"confirm_password": "secret123",
"birth_date": "1990-01-01",
"accept_terms": "1",
},
)
assert "Registration is currently closed" in attempt.text
@@ -379,6 +400,8 @@ def test_session_length_setting_applies(alice, browser):
guest.fill("#email", f"{username}@test.devplace")
guest.fill("#password", "secret123")
guest.fill("#confirm_password", "secret123")
guest.fill("#birth_date", "1990-01-01")
guest.check("#accept_terms")
guest.click("button:has-text('Create account')")
guest.wait_for_url("**/feed", wait_until="domcontentloaded")
@@ -397,6 +420,8 @@ def test_feed_page_has_unique_title(page, app_server):
page.fill("#email", "seo_title@test.dev")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
title = page.title()
@@ -416,6 +441,8 @@ def test_feed_page_has_canonical(page, app_server):
page.fill("#email", "seo_canon@test.dev")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
link = page.locator('link[rel="canonical"]')
@@ -429,6 +456,8 @@ def test_feed_page_has_og_tags(page, app_server):
page.fill("#email", "seo_og@test.dev")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
og = page.locator('meta[property="og:title"]')
@@ -442,6 +471,8 @@ def test_feed_page_has_twitter_card(page, app_server):
page.fill("#email", "seo_twit@test.dev")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.fill("#birth_date", "1990-01-01")
page.check("#accept_terms")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
card = page.locator('meta[name="twitter:card"]')