Skip to content

docs(adr): add ADR 032 — SafetyReserve appeal-surface contract surface - #566

Merged
alpergundogdu merged 6 commits into
mainfrom
adr-030-safety-reserve-appeals-contract
May 15, 2026
Merged

alpergundogdu merged 6 commits into
mainfrom
adr-030-safety-reserve-appeals-contract

Conversation

@thiras

@thiras thiras commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #524 (Risk 2 of #453). Pins the contract-implementation surface for ADR 028 — the slashing-side analogue of ADR 031 for the blacklist side. Unblocks #452 (slashing/appeals contract implementation).

Note: originally drafted as ADR 030; renumbered to ADR 032 to avoid a file/numbering collision with in-flight PR #565, which independently assigns 030 to 030-node-region-self-attestation.md. The head branch name still references 030.

  • New file: adr/032-safety-reserve-appeals-contract.md — six numbered Decision subsections matching issue ADR 030: SafetyReserve appeal-surface contract-implementation #524's outline (storage / escrow accounting / events / state machine / cross-category hook / multisig capability scope), each using ADR 031's presentation patterns (slot-aligned Solidity struct, event-topic table, Mermaid stateDiagram-v2).
  • Six events pinned (the resolving change vs ADR 026 §5). The stub at ADR 026 §5 previously carried five event-name stubs without parameter lists; SlashAppealLapsed was named in ADR 028 Forward references but absent. ADR 032 §3 pins all six full signatures, and the §5 stub is updated to match. SlashAppealReversed carries a bondSplitRecipient field to surface the ADR 028 §4 dispatch (counter-bundle filer vs challenger-incentive pool).
  • Sixth permissionless entry point. ADR 032 introduces cleanupExpiredAppeal(appealId) to settle the two ADR 028 §4 lapse cases (multisig silent past MULTISIG_REVIEW_WINDOW; governance silent past RATIFICATION_WINDOW). Parallel to ADR 031's cleanupExpiredAppeal. This expands ADR 028 §6's enumerated five entry points to six; ADR 028 §6 / Negative bullet / Forward-references "SafetyReserve future split" item are editorially expanded in this PR.
  • Cross-category queue. Per-appeal records live in ADR 032; the pending-claim queue ((accrualEpoch asc, claimId asc)) is canonical in ADR 026 §5 Cross-category payout ordering (merged in #522). ADR 032 §5 defers to it. Note: the issue body's (accrualEpoch, IncidentReason, recipient) key is stale relative to the merged ADR 026 §5 — this PR mirrors the canonical merged form, not the issue body.
  • Frequency cap mechanics. ADR 032 §1 / §4 pin lastAcceptedAppealUs[appellant] (microsecond timestamp at ratification) for ADR 028 §5's "1 accepted appeal per 365 days" cap. Stored as ratification timestamp (not appeal-opened timestamp) so "Resets on the date the previous successful appeal was ratified" is exact.
  • Cross-doc edits to match issue ADR 030: SafetyReserve appeal-surface contract-implementation #524's acceptance checklist:
    • adr/026-gauge-boost-tokenomics.md §5 interface stub — six full event signatures (adding the missing SlashAppealLapsed), cleanupExpiredAppeal added to function stubs, comment block pointing at ADR 032 as authority.
    • adr/028-slashing-appeals.md — Forward references bullet replaced with back-reference to ADR 032; §6 intro / Solidity block / Negative bullet / "SafetyReserve future split" item updated to reflect the six-entry-point surface.
    • adr/architecture.md — Chapter 5 reading order and Architectural Decisions list both include ADR 032 (and ADR 031, which was missing).
    • decdn/CLAUDE.md next-ADR counter bumped 030 → 033; this ADR is numbered 032 (030 is claimed by in-flight PR docs(adr): add ADR 030 — node region self-attestation #565; 031 already consumed by ADR 031).

Acceptance checklist (#524)

  • adr/032-safety-reserve-appeals-contract.md created
  • All six event signatures pinned (including SlashAppealLapsed)
  • adr/026-gauge-boost-tokenomics.md §5 interface stub updated to add SlashAppealLapsed (and the rest of the six, with parameter lists matching ADR 032 §3)
  • adr/028-slashing-appeals.md Forward references bullet "future contract-implementation ADR will pin…" replaced with a back-reference to ADR 032
  • adr/architecture.md updated: ADR 032 in Chapter 5 reading order + Architectural Decisions list (also added the missing ADR 031 entry)
  • decdn/CLAUDE.md next-ADR counter bumped (030 → 033; this ADR renumbered to 032 to avoid collision with in-flight PR docs(adr): add ADR 030 — node region self-attestation #565)

Test plan

This is docs-only; no code changes. Verification:

  • pre-commit run --files adr/032-safety-reserve-appeals-contract.md adr/026-gauge-boost-tokenomics.md adr/028-slashing-appeals.md adr/architecture.md CLAUDE.md — markdownlint, EOF, trailing whitespace all pass.
  • Cross-consistency: grep -n SlashAppeal adr/026-gauge-boost-tokenomics.md adr/028-slashing-appeals.md adr/032-safety-reserve-appeals-contract.md — all six events present in ADR 026 §5 and ADR 032 §3 with identical parameter lists; ADR 028 §6 prose mentions all six event names without parameter lists (canonical signatures live in ADR 032 §3, by design).
  • All anchor links manually spot-checked against target headings: #cross-category-payout-ordering, #5-safety-and-insurance-reserve-3-bucket, #interface-stability, #spending-controls, #epoch-mechanics, #contract-safetyreserve, #6-contract-surface, #forward-references-follow-up-adrs, #bond-handling, #slashed-event-and-slashid-allocation, #emergency-multisig, #chapter-5--verification--enforcement, #architectural-decisions.
  • Reviewer to sanity-check the §2 "bond-routing dispatch" rationale (reading gate-3 state at reverseAppeal to choose between counter-bundle filer and challenger-incentive pool, surfaced via SlashAppealReversed.bondSplitRecipient) — there is room to debate whether a per-appeal counterBundleFiler storage field would be clearer; my reading of ADR 028 §4 + §6 says "no" but worth a second opinion.
  • Reviewer to confirm the editorial expansion in ADR 028 (five → six entry points) is acceptable here vs. a separate follow-up PR. The current PR includes it because the new entry point is a direct consequence of ADR 032.
  • GitHub PR preview to confirm the §4 Mermaid stateDiagram-v2 renders.

🤖 Generated with Claude Code

#524)

Pins the contract-implementation surface deferred by ADR 028 §6: per-appeal
storage layout, the per-appeal escrow accounting from §2, all six canonical
Solidity event signatures (resolving the `SlashAppealLapsed` gap between
ADR 028 Forward references and ADR 026 §5's stub), the state machine, and
the integration with ADR 026 §5's cross-category pending-claim queue.

Adds a sixth permissionless entry point `cleanupExpiredAppeal` for the two
lapse cases (multisig timeout, ratification timeout), mirroring ADR 031's
pattern. ADR 028 §6's enumerated five entry points expands to six;
editorial follow-through in this commit.

Closes #453 Risk 2. Unblocks #452 (slashing/appeals contract implementation).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 14, 2026 20:27

@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 030, which defines the technical specification for the slash-appeal contract surface within the SafetyReserve. The changes include detailed storage layouts, event signatures, and a state machine for managing appeals, alongside updates to existing ADRs to ensure consistency. Feedback provided suggests enhancing the specification by including incident identifiers in events for better off-chain reconciliation, standardizing microsecond variable naming with the '_US' suffix, and optimizing the frequency-cap check to occur at the fast-track stage to prevent unnecessary multisig review effort.

Comment thread adr/026-gauge-boost-tokenomics.md Resolved

Copilot AI 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.

Pull request overview

Adds ADR 030 as the canonical SafetyReserve slashing-appeal contract surface, aligning ADR 026/028 and architecture references so the downstream Solidity implementation has a pinned storage/event/state-machine spec.

Changes:

  • Adds adr/030-safety-reserve-appeals-contract.md with storage layout, escrow accounting, events, state machine, queue integration, and multisig scope.
  • Updates ADR 026 and ADR 028 to include the sixth cleanupExpiredAppeal entry point and full appeal event signatures.
  • Updates architecture reading order/index and bumps the next ADR note in CLAUDE.md.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
CLAUDE.md Updates the next available ADR number to 032.
adr/architecture.md Adds ADR 030 and ADR 031 to the verification/enforcement reading order and ADR index.
adr/030-safety-reserve-appeals-contract.md Introduces the new SafetyReserve slashing-appeal contract-surface ADR.
adr/028-slashing-appeals.md Cross-references ADR 030 and expands the appeal surface from five to six entry points.
adr/026-gauge-boost-tokenomics.md Updates the ISafetyReserve appeal stubs and event signatures to match ADR 030.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

thiras and others added 2 commits May 15, 2026 00:19
…rmula cleanup

Responds to Copilot and Gemini review on PR #566:

- §2 escrow model clarified: per-appeal escrow is a lien on general balance,
  not a separate USDC sub-account. `totalEscrowLien` aggregate added to
  storage; solvency invariant rewritten as `totalEscrowLien + Σ pendingClaim
  ≤ generalBalance`. Resolves the ratifyAppeal→payout double-debit ambiguity
  raised by Copilot (#3244100352).
- §3 / §5 / ADR 026 §5 stub: `SlashAppealRatified` now emits `incidentId`
  (indexed) so off-chain consumers join directly against `SafetyReserve.Paid.id`
  without `evidenceBundleHash`/`recipient` joins. Per Gemini (#3244098475 /
  #3244098480).
- §4 reviewWindowEndsUs lifecycle: pinned to one formula
  `nowUs + SafetyReserve.appealWindow() + RATIFICATION_WINDOW`, referencing the
  governable parameter rather than hardcoding "48h". Resolves Copilot
  (#3244100324) and the appealWindow part of Gemini (#3244098488).
- Negative consequence about ADR 028's "five entry points" prose rewritten
  to describe the actual ABI-widening cost (Copilot #3244100374).
- Risk note about "coarse-grained epochs" replaced with a mixed-time-units
  risk that matches the post-fix storage (microsecond timestamps for cap;
  epoch index for queue alignment) — Copilot #3244100280.
- §1 storage description: `escrowAmount` comment updated to reflect the
  lien semantics; struct count clarified in Negative consequence.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…Ts + invariant tests (PR #566 review)

Addresses /pr-review-toolkit:review-pr findings on PR #566.

Critical fixes (lien-vs-sub-account drift flagged by three reviewers):
- §1 AppealStatus enum lines 26-30: enum value comments updated from
  "moved from general balance" / "returned to general balance" to lien-released
  language, matching §2's "Escrow is a lien, not a sub-account" framing.
- §4 cleanupExpiredAppeal admissibility table (b): "return escrowAmount to
  general balance" → "release lien on escrowAmount (funds remain in general
  balance)" — funds never moved under the lien model.

§2 additions:
- Checks-Effects-Interactions ordering pinned at ratifyAppeal /
  reverseAppeal / cleanupExpiredAppeal so the re-entrant-appellant
  case is unambiguous: status update + lien decrement + bond transfer
  (effects) BEFORE the payout() / bond-split (interactions).

§1 type-design upgrades (per type-design-analyzer):
- Introduce `type EpochIndex is uint64;` and `type MicroTimestamp is uint64;`
  user-defined value types. Solidity refuses implicit conversion between
  them, so the storage layer cannot silently mix epoch indices with
  microsecond timestamps. Zero gas cost. ADR 031 retains raw uint64 — a
  future editorial pass may retrofit cross-ADR.

§Risks expansion:
- Named Foundry invariant tests (invariant_lienEqualsSumOfFastTracked,
  invariant_fastTrackedImpliesEscrow, invariant_terminalIsSticky,
  invariant_bondAccounting) become a MUST for #452's implementation.
- "Mixed time units" risk rewritten as the residual hazard surface that
  UDVTs do not cover (unwrap casts, raw-uint64 setters, unit-ambiguous
  literals) with concrete enforcement obligations.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu

Copy link
Copy Markdown
Contributor

ADR-number coordination — please renumber to ADR 032

Maintainer decision: #565 (ADR 030 — Node Region Self-Attestation, closes #400) keeps ADR number 030. This PR currently adds adr/030-safety-reserve-appeals-contract.md, which would collide — two canonical ADR 030s plus merge conflicts on CLAUDE.md, architecture.md, the README pandoc list, and ADR 031's cross-refs.

Please renumber this PR to ADR 032:

Flagging #565 as the merge-order dependency (it should land first).

@alpergundogdu

Copy link
Copy Markdown
Contributor

Code review

Found 2 issues (the ADR-030 numbering collision with #565 is omitted here — already raised separately):

  1. Reading-order book build will drift. ADR 030 and 031 were added to architecture.md Chapter 5, but the README.md reading-order pandoc command was not updated in lockstep. architecture.md says: "Edits to the chapters below — adding, removing, or reordering ADRs — must update that pandoc command in lockstep, or the rendered book will drift from this index." The Chapter 5 line of the command still ends at 028-slashing-appeals.md with no 030-/031- entry:

decdn/adr/README.md

Lines 149 to 151 in b119711

026-gauge-boost-tokenomics.md 018-liquidity-strategy.md \
014-on-chain-verification.md 008-reputation.md 011-content-takedown.md 028-slashing-appeals.md \
009-governance.md 016-contract-interactions.md \

Maintenance note being violated:

> **Maintenance note:** the reading-order book PDF in [`README.md` § Reading-order build (book layout)](README.md#reading-order-build-book-layout) lists every ADR explicitly in the same order. Edits to the chapters below — adding, removing, or reordering ADRs — must update that pandoc command in lockstep, or the rendered book will drift from this index.

  1. Contradictory cross-reference for cleanupExpiredAppeal. The Forward references bullet links the "two lapse cases" to ADR 030 §6 (Multisig capability scope), but the two-lapse-case admissibility table lives in ADR 030 §4 (State machine) — which the inline comment in this same file's §6 contract block correctly cites. "the two lapse cases below" is also dangling: no cases follow it in ADR 028.

Wrong link (§6 — should be §4):

- Storage layout, per-appeal escrow accounting from §2, and the six Solidity event signatures (`SlashAppealOpened` / `SlashAppealFastTracked` / `SlashAppealRejected` / `SlashAppealRatified` / `SlashAppealReversed` / `SlashAppealLapsed`) are pinned in [ADR 030 — SafetyReserve appeal-surface contract surface](030-safety-reserve-appeals-contract.md). ADR 030 also introduces a sixth external entry point `cleanupExpiredAppeal(appealId)` (permissionless) for the two lapse cases below; see [ADR 030 §6](030-safety-reserve-appeals-contract.md#6-multisig-capability-scope).
- **`SafetyReserve` future split.** If the reserve is ever decomposed into separate per-category contracts (e.g. distinct reserves for slash-restitution vs. SLA-breach vs. payment-channel downtime), the following state and entry points must migrate alongside the slash-restitution payout category:

Same file's inline comment, correctly pointing at §4:

function reverseAppeal(uint256 appealId) external onlyGovernor;
// Permissionless lapse handler — see [ADR 030 §4](030-safety-reserve-appeals-contract.md#4-state-machine).
function cleanupExpiredAppeal(uint256 appealId) external;

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

alpergundogdu added a commit that referenced this pull request May 15, 2026
Resolves the six findings from the PR #565 security/compliance review:

- #1 §4: replace the inverted "misdeclaration expands slashing
  surface" argument with the honest reactive-vs-pre-positioned
  decomposition; reconcile Negative bullet 1 and the same claim
  mirrored in ADR 011 § Regional Scope.
- #2: gate blacklist scope/slash eligibility on the stability window,
  not just appeals standing. Add `regionPrev`, make `updateRegion`
  revert within `REGION_STABILITY_WINDOW` (cooldown = window), and
  amend the ADR 011 § Regional Scope / § Slashing predicate so the
  previous region's entries and slash exposure persist until a change
  ripens — closing the reactive blacklist-evasion flip.
- #3: migration fallback `max(firstRegisteredAt, regionGateActivatedAt)`
  instead of bare `firstRegisteredAt`; add migration-cohort Risks bullet.
- #4: §2 states the residual control is consciously accepted
  unparameterized; log the `validation.rs` vs ADR 001 spec divergence
  as a Forward reference.
- #5: raise `REGION_STABILITY_WINDOW` floor [1d,30d] -> [3d,30d]
  (default 7d unchanged) across §3, threshold rationale, Risks,
  and ADR 011 § Standing.
- #6: this PR keeps ADR 030 (no change here; #566 renumber requested
  separately).

§3 renamed "Appeals-standing hardening" -> "Region-stability window";
anchor references updated in ADR 011, ADR 019, architecture.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu and others added 2 commits May 15, 2026 12:57
…ild (PR #566 review)

ADR 028 Forward references pointed cleanupExpiredAppeal's two lapse
cases at ADR 030 §6 (Multisig capability scope) with a dangling
"below"; the lapse-case admissibility table lives in ADR 030 §4
(State machine), which the §6 contract-block inline comment already
cites correctly. Repoint to §4 and drop the dangling phrase.

architecture.md Chapter 5 gained ADR 030/031 but README.md's
reading-order pandoc command was not updated in lockstep, per the
architecture.md maintenance note. Add both files after
028-slashing-appeals.md, matching Chapter 5 order.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
PR #565 (also open) independently assigns ADR 030 to
030-node-region-self-attestation.md. To prevent a file collision and
conflicting CLAUDE.md canonical claims on merge, move this PR's ADR to
the free slot 032.

- git mv 030-safety-reserve-appeals-contract.md -> 032-...
- Update self-references, title, and ADRs-Affected in the renamed file
- Repoint cross-refs in 026, 028, 031, architecture.md, README.md
  (section anchors unchanged)
- architecture.md: move the per-ADR numeric-index entry after 031;
  Chapter 5 thematic order (028 -> 032 -> 031) and README reading-order
  build kept in lockstep
- CLAUDE.md: next ADR number 032 -> 033; provenance note records 032
  canonical, 030 assigned by in-flight PR #565

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request May 15, 2026
* docs(adr): add ADR 030 — node region self-attestation

Closes #400 with a self-claim production posture: regions in NodeAnnounce
and StakingRegistry are accepted at face value; the IP-geolocation oracle
/ third-party attestation path is considered and rejected. Misdeclaration
is the operator's legal exposure under the declared jurisdiction and
*expands* the operator's slashing surface under ADR 011 § Regional Scope
(the operator opts into the declared region's blacklist while remaining
legally reachable through their physical operations). The latency-vs.-
claim reputation penalty from ADR 001 § Risks is the canonical soft
mitigation; this ADR does not respecify it.

The only gaming surface the soft loop does not close is appeals-standing
flipping (ADR 011 § Standing path 2). ADR 030 § 3 closes it: adds a
`regionLastChanged: uint64` field on the StakingRegistry operator record
and a new operator-facing `updateRegion(string)` mutator alongside the
existing `updateMultiaddrs`. Operator standing under path 2 requires
`block.timestamp - regionLastChanged >= REGION_STABILITY_WINDOW` (default
7 days; governable [1d, 30d] per the ADR 009 safety-bound pattern).
Sub-window filings are not auto-rejected — they remain admissible at
multisig discretion, preserving heightened-scrutiny intake as the
soft-norm fallback for legitimate post-relocation filers.

Supersedes the "production mitigation: oracle/attestation" passages in
ADRs 001, 011, and 019. Cross-refs updated in ADRs 001 (§ Risks), 008
(§ Regional coverage caveat), 011 (§ Standing + § Regional Scope), 019
(Phase 1 step 5 + Future Work), architecture.md (Chapter 5 Verification
& Enforcement + numeric ADR index). CLAUDE.md next-ADR counter bumped
030 → 032 (031 already used by 031-content-blacklist-appeals-contract).

Closes #400

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): address review findings on ADR 030 (#400)

Cross-ADR consistency cleanup raised by the comprehensive review on the
ADR 030 branch:

- **Broken anchors fixed.** ADR 030 referenced `[ADR 019 § Step 5.2]`
  and `[ADR 019 § Re-registration]` — neither section exists. The real
  `updateMultiaddrs` precedent lives in [ADR 019 § NAT and Multiaddr
  Handling]; `firstRegisteredAt` is defined under [ADR 019 § Re-Onboarding
  after Deregistration or Auto-Ejection]. Cross-refs in § 3 (Decision —
  StakingRegistry interface delta) and § Consequences/Positive updated.

- **`firstRegisteredAt` precedent overclaim corrected.** The Positive
  bullet had claimed `regionLastChanged` "mirrors the precedent."
  `firstRegisteredAt` is write-once-on-first-registration; `regionLastChanged`
  updates on every successful `updateRegion`. Bullet now: parallel storage
  shape with opposite mutability, called out explicitly.

- **`updateMultiaddrs` "no governance gate" wording corrected.**
  `updateMultiaddrs` has a governable cooldown ([ADR 001 § Multiaddr
  Update Policy], default 0). Reframed as: operator-callable, no-bond;
  no analogous per-call cooldown specified for `updateRegion`; the 7-day
  `REGION_STABILITY_WINDOW` is the only timing gate.

- **`[ADR 001 § Risks]` references corrected to `§ Consequences`.**
  ADR 001 has no `### Risks` section — the regional-attestation
  consequence lives in `## Consequences`. Five references updated (ADR
  030 lines 16/28/72/98, architecture.md line 160, ADR 011 line 548).

- **Self-referential anchor in ADR 011 § Regional Scope edit fixed.**
  Was `[§ Regional Scope](#regional-scope)` — a self-loop. Now
  `[§ Slashing](#slashing)` (the actual target of the "expands slashing
  surface" claim).

- **Section order aligned with ADR 028 / 026 / 031 precedent.**
  Consequences now precedes Alternatives Considered.

- **`Touches:` front-matter expanded.** Added ADRs 008 (regional-coverage
  caveat), 009 (governable-parameter bounds pattern), 026 (minimum-stake
  cost bullet) — all referenced in the body.

- **Terminology mix-up fixed.** Context paragraph had conflated the
  StakingRegistry `regionHint` field with the `NodeAnnounce` `region`
  field. Reworded to name both surfaces explicitly.

- **ADR 030 added to the book-PDF reading-order build list** at
  `adr/README.md:150` (Chapter 5 — Verification & Enforcement).

- **Tightened ADR 028 § 5 alignment claim** (the 30d upper bound) and
  added a sentence on the 7d-stability-window-vs.-3d-filing-window-lower-bound
  interaction in the threshold-rationale paragraph.

Refs #400

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): address PR #565 review feedback on ADR 030 (#400)

Acts on inline review comments from Copilot + Gemini Code Assist:

- **Drop "known ISO code set" overclaim** in the gossip-layer-validation
  paragraph. `crates/gossip/src/validation.rs:127-130` is shape-only
  (length-2 ASCII uppercase). ADR 001 § Gossip validation describes the
  stricter check; tightening `validation.rs` to enforce it is orthogonal
  to this ADR and not a precondition for the self-attestation posture.

- **Clarify migration semantics** for `regionLastChanged`. No storage
  migration required — Solidity zero-initializes the field for pre-upgrade
  records, and the standing-eligibility check reads it with a read-time
  fallback to `firstRegisteredAt`:
  `effective = regionLastChanged != 0 ? regionLastChanged : firstRegisteredAt`.
  Previous "defaults to firstRegisteredAt" wording was ambiguous between
  migration sweep and read-time fallback.

- **`regionLastChanged: uint256`** (was `uint64`) to match
  `firstRegisteredAt`, `registeredAt`, and `lastMultiaddrUpdate` in
  ADR 001 § Data Structure.

- **`RegionUpdated` event signature corrected.** Index `nodeId` to match
  every other `StakingRegistry` event in ADR 001; drop the redundant
  `timestamp` parameter (block timestamp is implicit in the event log
  header).

- **Note ADR 011 § Contract: ContentBlacklist's `bytes2` recommendation**
  for the region field, and explain why ADR 030 retains `string` here
  (consistency with the existing `StakingRegistry.NodeInfo.regionHint`
  shape per ADR 001 § Data Structure; `bytes2` migration is a separate
  `StakingRegistry` storage-shape change orthogonal to this ADR).

- **Rename §3 heading** from "Appeals-standing hardening: regionLastChanged
  + 7-day window" to "Appeals-standing hardening" so the GFM slug is
  predictable and short. Update cross-references in ADR 011:197 and
  ADR 019:259 to use the `#3-appeals-standing-hardening` anchor.

Refs #400 #565

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): address third-pass review on PR #565 (#400)

Two findings from the post-fce0fc2 internal review pass:

- **ADR 030 §3 strict-rule fenced block now uses the read-time fallback.**
  Bullet 1 of §3 introduced
  `effective = regionLastChanged != 0 ? regionLastChanged : firstRegisteredAt`
  to avoid a storage migration, but the canonical fenced rule still read
  `block.timestamp - operator.regionLastChanged >= REGION_STABILITY_WINDOW`,
  which a contract-impl reader could copy verbatim and silently skip the
  fallback for legacy records. The fenced block is now self-contained:

      effective = operator.regionLastChanged != 0 ? operator.regionLastChanged : operator.firstRegisteredAt
      block.timestamp - effective >= REGION_STABILITY_WINDOW

  Runtime semantics unchanged (legacy records with `regionLastChanged == 0`
  already trivially passed `block.timestamp - 0`), but the spec is now
  unambiguous to a code-generation reader.

- **Stale "(ADR 030)" cross-references in ADR 031 corrected.** ADR 031
  was written when "ADR 030" was the informal placeholder for the
  SafetyReserve slash-appeal contract-implementation ADR (the blacklist-
  side analogue of which is ADR 031). With #400 now claiming the 030
  slot for Node Region Self-Attestation, ADR 031's three "(ADR 030)"
  pointers (lines 14, 291, 314) became factually wrong on merge.
  Reworded to refer to #524 alone (the GitHub issue tracking the
  SafetyReserve slash-appeal contract ADR), with parenthetical pointers
  to ADR 030's new occupant for cross-reference. The natural claimant
  of the next-free 032 slot is now #524.

Refs #400 #565

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): address security/compliance review on ADR 030 (#400)

Resolves the six findings from the PR #565 security/compliance review:

- #1 §4: replace the inverted "misdeclaration expands slashing
  surface" argument with the honest reactive-vs-pre-positioned
  decomposition; reconcile Negative bullet 1 and the same claim
  mirrored in ADR 011 § Regional Scope.
- #2: gate blacklist scope/slash eligibility on the stability window,
  not just appeals standing. Add `regionPrev`, make `updateRegion`
  revert within `REGION_STABILITY_WINDOW` (cooldown = window), and
  amend the ADR 011 § Regional Scope / § Slashing predicate so the
  previous region's entries and slash exposure persist until a change
  ripens — closing the reactive blacklist-evasion flip.
- #3: migration fallback `max(firstRegisteredAt, regionGateActivatedAt)`
  instead of bare `firstRegisteredAt`; add migration-cohort Risks bullet.
- #4: §2 states the residual control is consciously accepted
  unparameterized; log the `validation.rs` vs ADR 001 spec divergence
  as a Forward reference.
- #5: raise `REGION_STABILITY_WINDOW` floor [1d,30d] -> [3d,30d]
  (default 7d unchanged) across §3, threshold rationale, Risks,
  and ADR 011 § Standing.
- #6: this PR keeps ADR 030 (no change here; #566 renumber requested
  separately).

§3 renamed "Appeals-standing hardening" -> "Region-stability window";
anchor references updated in ADR 011, ADR 019, architecture.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): exempt first region change from cooldown (#400)

Follow-up to the security/compliance review fixes. The cooldown =
window rule, combined with regionLastChanged being stamped at
registerNode, locked a freshly registered operator out of correcting
a mis-entered region for a full window.

Fix uses regionLastChanged itself as the "has changed region yet"
discriminator rather than overloading regionPrev emptiness (which is
only a clean sentinel if registration forbids an empty region):

- registerNode no longer stamps regionLastChanged (stays 0 until the
  first updateRegion); the effective fallback already covers fresh
  nodes for appeals-standing / blacklist-scope.
- Cooldown reverts iff regionLastChanged != 0 AND
  block.timestamp - regionLastChanged < REGION_STABILITY_WINDOW, so
  the first change is exempt and every subsequent change is gated.

Safe: reactive evasion is foreclosed by the scope predicate (prev
region keeps applying via regionPrev for the window) regardless of
the cooldown; the cooldown only blocks a second flip, still gated
once regionLastChanged != 0. Migration-cohort Risks bullet updated
to note the first post-activation change is cooldown-exempt but
still does not ripen / grant standing until the window passes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Co-authored-by: Alper Gundogdu <[email protected]>
@alpergundogdu alpergundogdu changed the title docs(adr): add ADR 030 — SafetyReserve appeal-surface contract surface docs(adr): add ADR 032 — SafetyReserve appeal-surface contract surface May 15, 2026
…e-appeals-contract

# Conflicts:
#	CLAUDE.md
#	adr/031-content-blacklist-appeals-contract.md
#	adr/README.md
#	adr/architecture.md
@alpergundogdu
alpergundogdu merged commit a0b901d into main May 15, 2026
11 checks passed
@alpergundogdu
alpergundogdu deleted the adr-030-safety-reserve-appeals-contract branch May 15, 2026 12:18
alpergundogdu added a commit that referenced this pull request May 15, 2026
* docs(adr): fix and enrich the ADR book PDF build

- Fix mermaid-filter build failure: the ADR 011 and ADR 028 appeal
  sequence diagrams used `;` in message text, which Mermaid parses as a
  statement separator. Replace with `—` / `,`. This broke both the
  adrs.pdf and adrs-book.pdf builds.
- Make the reading-order book exhaustive: add appendix-binaries.md and
  appendix-bundles.md to architecture.md's Appendices index and the
  README adrs-book command (they were never wired in — hand-maintained
  list drift, same class as the ADR 031 omission #566 fixed).
- Reading-order book only: add full-page chapter/appendix divider pages
  (_build/part-*.md) with a title and 2–3 sentence intro derived from
  architecture.md's Reading Order. The numeric adrs.pdf is unchanged.
- Drop the redundant `cd adr` from both README build commands —
  README.md lives in adr/, so the reader is already there.
- Exclude adr/_build/ from markdownlint (pandoc concatenation
  fragments, not standalone documents).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ci: exclude adr/_build/ from markdownlint-cli2

The CI markdownlint job uses DavidAnson/markdownlint-cli2-action, which
does not read .markdownlintignore (that is a markdownlint-cli v1 feature,
used by the local pre-commit hook). Add !adr/_build/** to the workflow
glob negation list so the pandoc build fragments are excluded in CI too,
matching the existing !.github/agents/** pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): drop stale fraud-detection line from architecture.md Ch5

The Permissionless Fraud-Detection Layer was demoted from an ADR to an
appendix (#422), but architecture.md's Chapter 5 reading order still
listed it as item 8 — a stale leftover. It already appears in the
Appendices section, and the adrs-book build groups appendices at the
end (not interspersed in chapters), so the Chapter 5 entry contradicted
both the Appendices section and the README command. Remove the line.

Resolves the inconsistency flagged in PR review; the suggested
alternative (also listing it in the README Chapter 5 block) would have
compiled appendix-fraud-detection.md twice into the PDF.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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 030: SafetyReserve appeal-surface contract-implementation

3 participants