Skip to content

docs(adr): add ADR 031 — ContentBlacklist appeal-contract surface - #556

Merged
alpergundogdu merged 2 commits into
mainfrom
adr-031-blacklist-appeals-contract
May 14, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
adr-031-blacklist-appeals-contract

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Closes #544.

New file: adr/031-content-blacklist-appeals-contract.md.

Fills the implementation gap deferred at ADR 011 § Contract surface. Companion ADR to #524 (ADR 030), which performs the same job for SafetyReserve slash appeals.

What this ADR pins

  • Storage layout. BlacklistAppeal struct with explicit slot packing (5 slots / 160 bytes including padding), appeals[appealId] mapping, monotonic appealCounter, plus four auxiliary mappings carrying the ADR 011 frequency caps: lastRatifiedSuccessUs (90-day per-filer success cap), filerRejections (3-rejection rolling cooldown packed into one slot), perjuryDenylistUntilUs (365-day denylist), regionActiveReliefCount (BODY_CONCURRENT_APPEAL_CAP enforcement).
  • Function signatures with full revert tables and state transitions for the seven entry points: openBlacklistAppeal, fastTrackAppeal, unFastTrackAppeal, rejectAppeal, rejectAppealAsPerjury (new sibling for the perjury path called out in ADR 011 § Evidence), ratifyAppealRemoval, reverseAppeal, cleanupExpiredAppeal.
  • Canonical event topic ordering. Eight events (one new — BlacklistAppealPerjuryRecorded) with indexed vs non-indexed fields pinned. LapseReason indexed sub-field on BlacklistAppealLapsed lets off-chain consumers distinguish refund vs burn cases without parsing follow-on Transfer events.
  • State machine diagram (mermaid) covering all transitions including the one-shot UnFastTracked re-entry path.
  • Integration with ContentBlacklist core. Where each path writes entry.suspended / entry.suspendedAtUs, how the ADR 014 § Evidence Staleness clock consumes entry.suspendedAtUs preservation, the internal _removeHashRegional reuse from ratifyAppealRemoval, the four cleanupExpiredAppeal admissibility conditions.
  • Multisig capability scope. Sub-mode of ADR 009 § Emergency Multisig's existing suspendRegionalBody capability — not a new multisig power.

What this ADR does not do

Semantic decisions remain owned by ADR 011: bond size, filing windows, standing paths and synthetic-standing clawback, evidence rules, regional-only scope, interaction with SlashJudge. Where this ADR's text appears to restate them it is for self-containedness of the contract spec; the canonical authority is ADR 011.

Sites touched

Coordination with #524

#524 reserves ADR 030 for the SafetyReserve appeals contract. This PR takes ADR 031 for the ContentBlacklist appeals contract. The two ADRs follow the same shape (storage layout → entry points with revert tables → events → state machine → integration → multisig scope). CLAUDE.md's "Next ADR number" note isn't updated in this PR to avoid conflict with #524's potential same edit; a follow-up should update it to 032 once both land.

New file: adr/031-content-blacklist-appeals-contract.md.

Fills the implementation gap deferred at ADR 011 § Contract surface:
the per-appeal storage layout (BlacklistAppeal struct with explicit
slot packing), the four auxiliary mappings carrying frequency / cooldown
/ perjury / per-region concurrent-relief state, the function signatures
with full revert tables and state transitions, the canonical event topic
ordering (including a new BlacklistAppealPerjuryRecorded event), the
state-machine diagram across Open → FastTracked → terminal, the
integration points on the parent ContentBlacklist (entry.suspended,
entry.suspendedAtUs preservation rules, internal _removeHashRegional
call), and the multisig capability scope (sub-mode of ADR 009's
existing suspendRegionalBody capability, not a new power).

Companion ADR to #524 (ADR 030), which performs the same job for
SafetyReserve slash appeals. ADR 011 § Contract surface "deferred to a
future contract-implementation ADR" clause updated to point at this
ADR.

Semantic decisions remain owned by ADR 011 (bond size, filing windows,
standing paths, evidence rules, synthetic-standing clawback,
interaction with SlashJudge). This ADR is purely contract-shape.

Closes #544.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces ADR 031, which specifies the contract-level implementation details for the content blacklist appeal process, including storage layout, function signatures, and state transitions. The review feedback identifies several internal inconsistencies within the document: the fastTrackAppeal revert logic contradicts the state machine's re-entry path, the Lapsed status description fails to account for bond burns during standing clawbacks, and the cleanupExpiredAppeal transition narrative is contradictory. Additionally, the feedback suggests adding a boolean flag to the BlacklistAppeal struct to properly enforce the 'one-shot' requirement for un-fast-tracking and points out a redundant revert condition in unFastTrackAppeal.

| Revert | Trigger |
| --- | --- |
| `AppealNotFound()` | `appeals[appealId].status == None` |
| `AppealNotOpen()` | `appeals[appealId].status != Open` (also rejects `UnFastTracked` — that path uses re-entry via separate call sequence; see § State machine) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The revert condition AppealNotOpen incorrectly restricts fastTrackAppeal to only Open appeals. According to the state machine diagram (line 256), fastTrackAppeal is also the valid transition from the UnFastTracked state. This revert condition should be updated to allow both Open and UnFastTracked statuses.

Suggested change
| `AppealNotOpen()` | `appeals[appealId].status != Open` (also rejects `UnFastTracked` — that path uses re-entry via separate call sequence; see § State machine) |
| `AppealNotOpenOrUnFastTracked()` | `appeals[appealId].status != Open && appeals[appealId].status != UnFastTracked` (re-entry path; see § State machine) |
References
  1. Ensure protocol documentation is internally consistent by verifying that function descriptions, field lists, and edge-case logic are aligned across all sections of the document.

Ratified, // 3 — terminal: _removeHashRegional executed; bond refunded
Reversed, // 4 — terminal: entry.suspended cleared; bond burned
Rejected, // 5 — terminal: rejected at intake or after un-fast-track; bond burned
Lapsed, // 6 — terminal: review/ratification window expired or global override fired; bond refunded

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment for the Lapsed status states that the bond is refunded. However, according to the cleanupExpiredAppeal logic for condition (c) (StandingClawback), the bond is burned. This comment should be updated to reflect that the bond is refunded except in the case of a synthetic-standing clawback.

Suggested change
Lapsed, // 6 — terminal: review/ratification window expired or global override fired; bond refunded
Lapsed, // 6 — terminal: review/ratification window expired or global override fired; bond refunded (except for StandingClawback)
References
  1. Ensure protocol documentation is internally consistent by verifying that function descriptions, field lists, and edge-case logic are aligned across all sections of the document.

uint64 fastTrackedAtUs; // 8 bytes — non-zero iff entered FastTracked; refreshed on UnFastTracked → FastTracked re-entry
uint64 reviewWindowEndsUs; // 8 bytes — running deadline for the active review window (multisig pre-fast-track, ve-Governor post-fast-track)
bytes2 region; // 2 bytes — ISO 3166-1 alpha-2 per ADR 011's bytes2 gas-optimization
bytes14 _pad1; // 14 bytes — explicit padding for slot completion

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To enforce the 'one-shot' requirement for unFastTrackAppeal as specified in ADR 011, the BlacklistAppeal struct needs a way to track if an appeal has already been un-fast-tracked. Since there are 14 bytes of padding in Slot 4, adding a boolean flag is a gas-efficient way to track this state.

Suggested change
bytes14 _pad1; // 14 bytes — explicit padding for slot completion
bool alreadyUnFastTracked; // 1 byte — true if unFastTrackAppeal was ever called
bytes13 _pad1; // 13 bytes — explicit padding for slot completion

| --- | --- |
| `AppealNotFound()` | `appeals[appealId].status == None` |
| `AppealNotFastTracked()` | `status != FastTracked` |
| `RatificationAlreadyFired()` | The post-fast-track ratification window has been closed by a `ratifyAppealRemoval` / `reverseAppeal` call (i.e., the appeal is already terminal) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The RatificationAlreadyFired revert condition appears redundant. The function already requires status == FastTracked (line 156). Since Ratified and Reversed are terminal statuses (as defined in the AppealStatus enum), an appeal that has been ratified or reversed will no longer have the FastTracked status, making the AppealNotFastTracked check sufficient.

References
  1. Ensure protocol documentation is internally consistent by verifying that function descriptions, field lists, and edge-case logic are aligned across all sections of the document.

| (c) synthetic-standing clawback fired | `status == Open && standingPath == TokenHolder && nowUs ≥ openedAtUs + STANDING_LOOKBACK_SECONDS * 1_000_000 && TOKEN.balanceOf(filer) < APPEAL_FILER_TOKEN_THRESHOLD` | **burn** (100%) |
| (d) global override fired | `status ∈ {Open, FastTracked} && _entryExists(appeal.blake3Hash, appeal.region) == false` | refund (per ADR 011 § Global Override — treats as lapse, not reversal) |

**State transitions:** `status = Lapsed` (conditions a, b, d) or `status = Rejected` with `perjuryFlagged = 0` (condition c — handled as a forfeiture, not a lapse, but the structural outcome is similar; the contract uses `Lapsed` for c as well to keep the terminal-status set minimal and emits a distinct event for telemetry). If `status` was `FastTracked` when cleanup fires: `regionActiveReliefCount[appeal.region]--`; `entry.suspended = false`; `entry.suspendedAtUs` preserved. Bond handled per the table above. `totalBondsEscrowed -= appeal.bond`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description of the state transition for condition (c) is contradictory. It first suggests status = Rejected but then states the contract uses Lapsed to keep the terminal-status set minimal. Given the state machine diagram and the event table, it should consistently state that condition (c) results in the Lapsed status with a specific reason that triggers a bond burn.

Suggested change
**State transitions:** `status = Lapsed` (conditions a, b, d) or `status = Rejected` with `perjuryFlagged = 0` (condition c — handled as a forfeiture, not a lapse, but the structural outcome is similar; the contract uses `Lapsed` for c as well to keep the terminal-status set minimal and emits a distinct event for telemetry). If `status` was `FastTracked` when cleanup fires: `regionActiveReliefCount[appeal.region]--`; `entry.suspended = false`; `entry.suspendedAtUs` preserved. Bond handled per the table above. `totalBondsEscrowed -= appeal.bond`.
**State transitions:** `status = Lapsed` (all conditions). If `status` was `FastTracked` when cleanup fires: `regionActiveReliefCount[appeal.region]--`; `entry.suspended = false`; `entry.suspendedAtUs` preserved. Bond handled per the table above (refunded for a, b, d; burned for c). `totalBondsEscrowed -= appeal.bond`.
References
  1. Ensure protocol documentation is internally consistent by verifying that function descriptions, field lists, and edge-case logic are aligned across all sections of the document.
  2. When a protocol-enforced state is resumed after a temporary suspension, the original effective timestamp must be preserved to prevent granting a fresh compliance window.

Five real findings addressed:

1. fastTrackAppeal revert table excluded UnFastTracked, contradicting
   the state-machine diagram (UnFastTracked → FastTracked re-entry).
   Renamed revert to AppealNotEligibleForFastTrack covering both Open
   and UnFastTracked.

2. AppealStatus.Lapsed enum doc comment claimed "bond refunded" but
   cleanupExpiredAppeal condition (c) StandingClawback burns. Updated
   to call out the clawback exception.

3. No storage to enforce the unFastTrackAppeal one-shot per ADR 011.
   Added uint8 alreadyUnFastTracked flag to the BlacklistAppeal struct
   (1 byte from Slot 4 padding; _pad1 → bytes13). unFastTrackAppeal
   now sets it on entry and reverts when already set.

4. unFastTrackAppeal RatificationAlreadyFired revert was redundant
   with the AppealNotFastTracked check (Ratified / Reversed are
   terminal so status != FastTracked already catches them). Dropped.

5. cleanupExpiredAppeal state-transition prose said both
   status = Lapsed (a/b/d) and status = Rejected (c). Consistent now:
   always status = Lapsed; bond outcome (refund / burn) determined by
   the matched condition, surfaced via the LapseReason indexed field
   on BlacklistAppealLapsed. Emits paragraph tightened to remove the
   resulting redundancy.
@alpergundogdu
alpergundogdu merged commit bc5f737 into main May 14, 2026
10 checks passed
@alpergundogdu
alpergundogdu deleted the adr-031-blacklist-appeals-contract branch May 14, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADR 031: ContentBlacklist appeal-contract surface (mirror of ADR 030 for ADR 011)

1 participant