A moderation backend with exact authority and bounded review
This design extends the forum's useful content, private messaging and graph
features with explicit staff authority, grouped reports, reasoned actions,
member appeals and an external-worker workflow. Source snapshot:
aa56efd90c8474c560f6241ca57be4934e623945. Qualification and complete endpoint
costs belong to the measurement owner's separate evidence; this write-up adds
no benchmark result. The application guide
describes the actual Wire API.
State ownership and collection choices
| Owner | Representation and reason |
|---|---|
| Accounts | Dense native user rows and exact principal/username maps; role and automated bytes fit the 96-byte row. A sparse native map stores restrictions only for affected accounts. Authority lookup does not copy the stable biography. |
| Board | Dense native 64-byte Post rows preserve stable IDs; each has one byte-sized canonical visibility enum. Native topic/user post-ID indexes support bounded navigation. Public contribution/like counters are maintained locally. Topic rows are 88 bytes after adding an independent lock revision. |
| Texts | Each consumer owns a private Hylix Map/String child for authoritative long text. Post bodies, biographies, report evidence, action notes and appeals do not become per-entry Store modules or duplicate native payload caches. |
| Moderation | Dense native Vecs hold reports, cases, appeals and immutable audit IDs. Exact maps deduplicate reports, actions, votes and appeals. Ordered sets index pending cases, lease expiry and private owner/case pages. Grouped decision-prefix records avoid rewriting every report in a case action. |
| Abuse | A fixed rule array, sparse native action windows and ordered expiry index implement exact quotas with bounded cleanup. Native domain-policy maps and caller/block sets implement exact configurable policy. Capacity rejection does not evict a live window. |
| Advisory analytics | Existing Minima Count-Min/HLL/distribution structures provide report-frequency and resolution assistance. They never grant authority or automatically hide/suspend content. Exact records determine acceptance and action state. |
See the complete private schemas for Accounts, Board, Texts, Moderation and Abuse. The existing native Nyxus Network and Minima PagedGraph Taxonomy/Conversations remain ordinary separate owners. Forum composes their read-only selectors in one synchronous scope; no owner opens another owner's private record or carries a guard across await.
Visibility, authority and private records
Public content participates in discovery, public profile statistics, feeds and graph projections. Unlisted content is directly readable, including children of a known topic, but does not enter those discovery surfaces. Hidden post bodies require the post's authenticated author or staff. Deleted post text is removed from the authoritative Texts map and retired; a stable ID/tombstone remains and cannot be edited/restored. This is logical record erasure/reclamation, not a secure-overwrite claim for freed storage or separate reporter evidence.
The existing DTO hidden flag is derived as visibility != Public; Unlisted direct
responses can therefore carry both hidden=true and a body. Topic visibility
caches the starter. At this source snapshot, a Hidden/Deleted starter additionally
gates get_topic; this does not change the visibility or erase Public replies,
which retain their own direct-ID policy. ProfileStats includes Public posts and
their likes; User.post_count is historical, and global Stats counts retained
records including tombstones. The facade
and profile composition
make those distinctions explicit.
Ordinary accounts start Member. The saved installer can bootstrap its own registered Administrator account and explicitly grant roles; numeric user IDs confer no privilege. Reviewer grants private reading/claim authority, Moderator adds permitted decisions, and Administrator manages broader authority/policy. The automated flag identifies an actor in receipts without granting power. Restrictions are sparse, timed and scoped to write categories; own reads, read tracking and appeal access remain available. Staff reporter identity/evidence never appears in redacted community cases or another member's own records. Action notes are visible to the affected author, so they must not copy private reporter evidence. Account-only action reasons have their own private page.
Plans, revisions and the external worker
Forum authenticates, checks roles/restrictions/quotas and prepares all ordinary business rejection before committing owners. Body/visibility revisions use max(sequence, old.updated +1), rejecting overflow before a text write. Topic lock has its own similarly monotonic revision: two cases against different posts in one topic cannot silently overwrite a newer lock decision. Case revisions and lease tokens independently protect review state. No-op effects retain their revision; stale expected tokens still reject.
An external operator registers a worker, explicitly grants the needed role and
sets automated=true. The worker pages moderation_cases, claims a bounded lease,
reads moderation_case evidence and moderation_content metadata/body, then
submits act_on_case with the case/content revisions and, for lock/unlock, topic
revision. The worker persists the exact request and actor-scoped client_action_id
before sending. Exact retries return the immutable successful receipt without
duplicating business effects or audit. Unknown outcomes do not authorize replacing
that identity; rejected stale facts require refresh and reassessment.
The worker treats posts and evidence as untrusted data, not instructions. Its operator's allowed actions remain outside that content. AI/vendor calls run outside the actor; a human client uses the same bounded routes. Review reads scan at most 128 logical IDs and return at most 50 metadata entries or 20 bodies. Last-scanned logical cursors progress through filtered empty pages. The recent-change ring reports gaps rather than claiming complete history; workers can fall back to the bounded content scan.
Successful action composition updates Board/Accounts, exact indexes, audit and recipient notices synchronously. Unexpected persistent failures trap and rely on IC rollback. There is no application undo journal or retained remote AI job inside the canister. See review composition and case contracts.
Choices deliberately avoided
- Implicit “first users are staff,” a second mutable hidden flag, advisory-score bans and probabilistic permission checks were replaced by exact authority and one canonical post state.
- Visibility/deletion targets the selected post; it does not cascade-delete other authors' replies. The topic-page guard is a separate current policy.
- Per-entry modules, long native body copies, whole-user scans and unbounded per-report resolution writes do not belong in normal request paths.
- Reusing a post revision for topic locking was insufficient for different cases sharing a topic. A real persisted topic revision is checked and included in exact request/audit identity for lock actions.
- A frontend and vendor integration are outside this backend. Content-action appeals exist; account-only appeal workflows remain deferred. An upheld deletion appeal can offer guidance, never resurrect the removed body.
Wire allowance footgun without an SDK change
A twenty-body review response carries at most 20×4,096 =81,920 UTF-8 body bytes, but fitting the encoded-byte cap does not prove decode admission. The unchanged native visitor starts its accounting at allocation - bytes and conservatively debits 8× byte length plus typed visitor/seed/record geometry. Text length is not a per-character node count; encode and decode do different work.
With the former 768 KiB allocation and 192 KiB byte cap, only 589,824 accounting bytes remain. The body debit alone is 655,360, already 65,536 too large before metadata. Increasing nodes cannot repair this. The app's current response limit is finite: 192 KiB bytes, 1 MiB allocation, 65,536 nodes and depth 32. The allocation allowance is a validation ceiling, not a 1 MiB buffer allocated at entry. The maximal full-response encode/decode regression remains in the route tests.
The mechanism is in the unchanged native budget and decode visitors. The saved source review tied the original refusal to decode allocation; it did not require weakening SDK visitors, increasing business body/count bounds or changing the wire representation. This is separate from whole-call instruction, page, capacity and latency qualification.
Moderation changed app code/dependencies only. A read-only tracked-tree comparison from pre-feature 7dab54db to this snapshot has no changes in ver1/ or rrt/rrts/hrrt. The saved source/control inventory identifies reusable prior controls and compiled policy proof; its initial status is not relabeled as a new integrated gate. Raw SDK archives remain local. The qualification owner will attach exact current artifact/source/control receipts and any measured results separately.
See the detailed visitor-budget finding.
Qualification scope
The integrated app passed all 185 native tests in both its default and
rollback-probe configurations at d9fa3d6d. The full-body Wire round trip passes
with the bounded allocation fix. Earlier failing fixtures were corrected for
explicit grants, bounded real time windows and the new privacy contract;
borrow enforcement was retained when a test nested an actor query in a write.
Actual IC KEEP/rollback and populated endpoint results are recorded separately.
The operation report and scoped acceptance record the actual Small, Large and separate wide-ID recovery evidence. The Large fixture collision remains an incomplete original protocol, rather than a full PASS.