Skip to content

docs(adr): add ADR 030 — node region self-attestation - #565

Merged
alpergundogdu merged 6 commits into
mainfrom
feat/issue-400-region-self-attestation
May 15, 2026
Merged

alpergundogdu merged 6 commits into
mainfrom
feat/issue-400-region-self-attestation

Conversation

@thiras

@thiras thiras commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds ADR 030 — Node Region Self-Attestation closing ADR gap: node region / geolocation verification #400 (prod-blocking / missing-decision).
  • Decision: self-attested regions are accepted at face value as the production posture; the IP-geolocation oracle / third-party attestation path named in ADRs 001/011/019 is considered and rejected. Misdeclaration is operator legal exposure (and expands their slashing surface under ADR 011 § Slashing); the latency-vs.-claim reputation penalty from ADR 001 § Consequences is the canonical soft mitigation.
  • One protocol-level hardening: the appeals-standing flip surface in ADR 011 § Standing path 2 is closed by a regionLastChanged: uint64 field on StakingRegistry + new updateRegion(string) mutator. Operator standing under path 2 requires block.timestamp - regionLastChanged >= REGION_STABILITY_WINDOW (default 7 days; governable [1d, 30d]). Sub-window filings remain admissible at multisig discretion only.
  • Supersedes the "production mitigation: oracle / attestation" passages in ADRs 001, 011, 019. Cross-refs updated in ADRs 001, 008, 011, 019, architecture.md, and the book-PDF build list. CLAUDE.md next-ADR counter bumped 030 → 032.
  • Two commits: the ADR itself (203fa34) and review-driven cross-ref cleanups (27a41e8) addressing anchor corrections, section-order alignment with ADR 028/026/031, terminology disambiguation, and the updateMultiaddrs/firstRegisteredAt precedent claims.

Test plan

  • Skim ADR 030 end-to-end — does the decision rationale and the 7-day stability-window threshold rationale read cleanly?
  • Spot-check the cross-ref edits in ADRs 001 (§ Consequences line 248), 008 (line 333 caveat), 011 (§ Standing line 197 + § Regional Scope line 548), 019 (Phase 1 Step 5 line 48 + Future Work line 259), architecture.md (Chapter 5 + numeric index).
  • Verify next-ADR counter in decdn/CLAUDE.md reads 032 (031 already taken by 031-content-blacklist-appeals-contract.md).
  • Confirm pre-commit run --all-files is green locally — pass on both commits in CI.
  • On merge: issue ADR gap: node region / geolocation verification #400 closes via Closes #400 in the first commit body.

🤖 Generated with Claude Code

thiras and others added 2 commits May 14, 2026 22:24
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]>
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]>
Copilot AI review requested due to automatic review settings May 14, 2026 19:37

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 to formally decide that node regions remain self-attested in production (rejecting IP-geolocation/oracle attestation), and updates existing ADRs/docs to reflect the new posture and the new regionLastChanged / stability-window hardening for appeals standing.

Changes:

  • Added ADR 030 — Node Region Self-Attestation (decision + rationale + contract-interface delta for regionLastChanged and updateRegion).
  • Updated cross-references across ADRs (001/008/011/019) and adr/architecture.md to supersede prior “future work: oracle/attestation” language.
  • Updated ADR build/book lists and the “next ADR number” note.

Reviewed changes

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

Show a summary per file
File Description
CLAUDE.md Bumps next ADR number note to 032 and documents 030/031 as canonical.
adr/README.md Adds ADR 030 to the reading-order (book) PDF build list.
adr/architecture.md Adds ADR 030 to Chapter 5 reading order and numeric index.
adr/030-node-region-self-attestation.md New ADR specifying self-attestation posture + regionLastChanged stability window + updateRegion interface.
adr/019-node-onboarding.md Updates onboarding guidance and marks geolocation verification future work as resolved by ADR 030.
adr/011-content-takedown.md Updates standing + regional-scope language to reference ADR 030 and the stability-window mitigation.
adr/008-reputation.md Updates region-attestation caveat to reflect ADR 030 production posture.
adr/001-network.md Updates consequences text to note oracle/attestation was considered and rejected (ADR 030).

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

Comment thread adr/030-node-region-self-attestation.md Resolved
Comment thread adr/030-node-region-self-attestation.md Resolved
Comment thread adr/011-content-takedown.md Resolved
Comment thread adr/019-node-onboarding.md Resolved

@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 establishes self-attestation as the production posture for node regions, explicitly rejecting the use of external oracles or attestation services. The changes include adding a regionLastChanged timestamp and an updateRegion function to the StakingRegistry, along with a 7-day stability window required for operators to gain standing in regional blacklist appeals. Feedback focuses on improving documentation navigability via GFM anchor links and ensuring consistency in data types and event definitions within the smart contract interfaces.

Comment thread adr/011-content-takedown.md Resolved
Comment thread adr/019-node-onboarding.md Resolved
Comment thread adr/030-node-region-self-attestation.md Resolved
Comment thread adr/030-node-region-self-attestation.md Resolved
thiras and others added 2 commits May 14, 2026 22:49
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]>
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]>
@thiras
thiras requested a review from alpergundogdu May 14, 2026 19:57
@thiras thiras linked an issue May 14, 2026 that may be closed by this pull request
@alpergundogdu

Copy link
Copy Markdown
Contributor

Security & compliance review (design-level)

Reviewed ADR 030 for security/compliance gaps only. The oracle-rejection rationale and the appeals-standing hardening are solid, and the oracle-language supersession across ADRs 001/008/011/019 is complete with all cross-ref anchors resolving. Six gaps below, each with a simple fix. Three need a maintainer decision — flagged [maintainer call].

1. §4 "misdeclaration expands slashing surface" is backwards for the main evasion case

§4's only worked example declares into a stricter region (US-physical → EU). The real evasion is declaring out of the takedown's region: per ADR 011 § Slashing — "a node is only slashable for serving a hash it was in-scope to remove ... a node that declared region US is not slashable for [an EU-only entry]" — an in-region operator hit by a region-scoped takedown can self-declare a clean region and shed protocol slash exposure for that entry. §4 claims "more slashing surface, not less"; Negative bullet 1 admits the opposite ("slash eligibility under the declared region"). They contradict; the Negative bullet is correct.

Fix: Rewrite §4 to state plainly that for region-scoped entries served by an in-region operator, misdeclaration reduces protocol slash exposure, with off-protocol legal action + the latency penalty as the only backstops. Reconcile with Negative bullet 1. Doc-only, no behavior change.

2. updateRegion has no cooldown/bond — reactive blacklist-evasion flip is ungated

The 7-day REGION_STABILITY_WINDOW gates only appeals-standing path 2. Blacklist applicability is governed by declared region (ADR 011 § Regional Scope: a node applies only entries matching its declared region), and §3 explicitly adds no cooldown/bond to updateRegion. An operator can flip region the instant a regional entry lands on content they serve, dodge it, and flip back — gas only. The ADR closes the governance-gaming flip but leaves the content-compliance flip (the reason regional scoping exists) open, with no stated rationale for the asymmetry.

Fix: Reuse the regionLastChanged timestamp already introduced — make a region change take effect for blacklist-scope purposes only after it has been stable for REGION_STABILITY_WINDOW, so a freshly-changed region grants no blacklist exemption until it ripens. [maintainer call] — this adds a protocol invariant; the alternative is to accept the risk and document it explicitly in Negative/Risks. Simple solution exists; adopt-vs-accept is your decision.

3. Migration fallback is the least conservative for the cohort that matters

§3: pre-upgrade records have regionLastChanged == 0 → effective = firstRegisteredAt (ancient) → instant pass of the 7-day check. The ADR calls this "most conservative," but it is the opposite for operators who changed region just before/at upgrade — they get path-2 standing immediately, defeating the new invariant for exactly the mid-flip cohort during rollout.

Fix: effective = max(firstRegisteredAt, upgradeTimestamp) (or a one-time backfill of regionLastChanged at upgrade). Add the trade-off to Risks either way. Clear implementation choice, no decision needed.

4. Canonical soft mitigation is unparameterized; gossip validation diverges from spec

§2 defers the latency-penalty threshold/sample/decay entirely to a future ADR 008 follow-up and marks it "not a precondition" — so a prod-blocking issue closes with its only concrete control unquantified. crates/gossip/src/validation.rs:128 is shape-only ("ZZ"/"XX" pass), diverging from the ADR 001 spec ("known ISO 3166-1 alpha-2 code set"); §1 notes but defers it.

Fix: Add one sentence to §2 stating the residual control is consciously accepted unquantified pending the ADR 008 follow-up, and reference a tracking issue for the validation.rs known-code-set tightening so the spec divergence is logged rather than silent. Doc fix; optionally open the tracking issue.

5. Governance floor [1d] nullifies the control the ADR designed

REGION_STABILITY_WINDOW is governable [1d, 30d]. The ADR's own rationale needs ~7d to make flipping uneconomic; at the 1d floor (plus the uncooled updateRegion from #2) the appeals-standing protection is near-void. Framed as merely "above-the-line."

Fix: Raise the lower bound to a value consistent with the ADR's own rationale (suggest 3d–7d). [maintainer call] — governance-policy parameter; the alternative is to keep 1d and explicitly document that at the floor the protection is void and that is an accepted governance risk.

6. ADR-030 number collides with PR #566

On main, ADR 031 binds "ADR 030" to the #524 SafetyReserve slash-appeals contract. This PR reassigns 030 to region self-attestation; PR #566 still adds adr/030-safety-reserve-appeals-contract.md. Whichever merges second yields two canonical ADR 030s plus merge conflicts on CLAUDE.md, architecture.md, the README pandoc list, and ADR 031 prose. This PR's CLAUDE.md sets next-free = 032, leaving no slot for #566.

Fix (mechanical): one PR keeps 030, the other renumbers to 032. [maintainer call] — which PR keeps 030 is cross-PR coordination only the team can decide; the renumber itself is mechanical once decided.


Simple solutions found for all six. Maintainer decision needed on three: #2 (adopt new invariant vs accept-and-document), #5 (raise floor vs document acceptance), #6 (which PR keeps 030).

@alpergundogdu

Copy link
Copy Markdown
Contributor

Maintainer decisions on the three [maintainer call] items

Resolving the three open calls from the review above. #1, #3, #4 stand as previously described — clean doc/impl fixes, no decision needed.

#2 — Adopted: reuse regionLastChanged to gate blacklist-scope

A region change must not take effect for blacklist scope / slash eligibility until it has been stable for REGION_STABILITY_WINDOW. Minimal spec to fold into §3 and the ADR 011 § Regional Scope / § Slashing edits:

  1. New operator-record field regionPrev: string. On updateRegion(newRegion): set regionPrev = <prior regionHint>, then regionHint = newRegion, regionLastChanged = block.timestamp. On registerNode: regionPrev = "".
  2. updateRegion reverts if block.timestamp - regionLastChanged < REGION_STABILITY_WINDOW. This is the per-call cooldown the review flagged as missing; it also guarantees at most one in-flight change, so regionPrev is unambiguous (no chained-flip escape).
  3. Amended scope predicate (ADR 011 § Regional Scope, and identically § Slashing eligibility): a node is in scope for an entry iff the entry is global, OR entry.region == regionHint, OR (block.timestamp - regionLastChanged < REGION_STABILITY_WINDOW AND entry.region == regionPrev). A region change adds the new region immediately but does not drop the previous region's entries or its slash exposure until the change has ripened.

Net: flipping region the instant a regional entry lands buys nothing — the old region's entries and slash exposure persist for the full window, and you cannot flip again until it ripens.

#5 — Adopted: raise the floor to 3 days

REGION_STABILITY_WINDOW: default unchanged at 7 days; governable hard bounds change from [1d, 30d] to [3d, 30d]. Concretely update: (a) the §3 interface delta and the bracketed bound in the ADR 011 § Standing edit (governable [1d, 30d] → [3d, 30d]), and (b) the §3 "Threshold rationale" sentence "the 1-day lower bound prevents governance from defanging the invariant entirely" → "the 3-day lower bound …".

(Reading "raise the window to 3d" as raising the lower bound; the 7-day default is unchanged.)

#6 — Resolved: this PR keeps ADR 030

#565 keeps ADR number 030. PR #566 will renumber to ADR 032 — commented there. No change needed here; the CLAUDE.md / ADR 031 reassignment already in this PR is correct as-is.

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

alpergundogdu commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

All six review findings addressed — 9b2b822

Pushed fixes for the security/compliance review:

  • 1 — §4 rewritten: the inverted "misdeclaration expands slashing surface" claim replaced with the honest reactive-vs-pre-positioned decomposition; Negative bullet 1 and the mirrored claim in ADR 011 § Regional Scope reconciled.
  • 2 — blacklist scope/slash eligibility now gated on the stability window, not just appeals standing: new regionPrev, updateRegion reverts within REGION_STABILITY_WINDOW (cooldown = window), amended ADR 011 § Regional Scope / § Slashing predicate so the previous region's entries and slash exposure persist until a change ripens. Closes the reactive blacklist-evasion flip and chained-flip variant.
  • 3 — migration fallback is now max(firstRegisteredAt, regionGateActivatedAt); migration-cohort Risks bullet added.
  • 4 — §2 states the residual control is consciously accepted unparameterized; the validation.rs vs ADR 001 spec divergence is logged as a Forward reference.
  • 5 — REGION_STABILITY_WINDOW floor raised [1d,30d] → [3d,30d] (default 7d unchanged) across §3, threshold rationale, Risks, and ADR 011 § Standing.
  • 6 — this PR keeps ADR 030; renumber requested on docs(adr): add ADR 032 — SafetyReserve appeal-surface contract surface #566.

§3 renamed "Appeals-standing hardening" → "Region-stability window"; anchor refs updated in ADR 011 / 019 / architecture.md. pre-commit run (markdownlint, etc.) green. 4 files, +36/-29.

One implementation note for the contract work: with cooldown = window and regionLastChanged set at registerNode, a newly registered operator cannot updateRegion for one window. That is the faithful consequence of the approved cooldown=window decision; flagging it in case the StakingRegistry implementation wants a first-change carve-out (out of scope for this ADR).

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]>
@alpergundogdu

Copy link
Copy Markdown
Contributor

Follow-up — 11fb7f0: first region change is cooldown-exempt

Correcting the implementation note in my previous comment. That note flagged that with cooldown = window and regionLastChanged stamped at registerNode, a freshly registered operator could not updateRegion to fix a mis-entered region for a full window. 11fb7f0 removes that limitation:

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

regionLastChanged != 0 is used as the "has the operator ever changed region" discriminator rather than regionPrev == "". The latter is only a clean sentinel if registration forbids an empty region (otherwise the first updateRegion copies the empty prior regionHint into regionPrev and it stays empty through the second change too); regionLastChanged != 0 is unconditionally correct.

Safety unchanged: reactive evasion is foreclosed by the §3 blacklist-scope predicate (regionPrev keeps the prior region's entries applying for the window) regardless of the cooldown; the cooldown only blocks a second flip, which is still gated once regionLastChanged != 0. So the original "no first-change lockout" UX concern is resolved with no weakening of the anti-flip invariant.

No remaining open items from the review on this PR. pre-commit green.

alpergundogdu added a commit that referenced this pull request May 15, 2026
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
alpergundogdu merged commit 82a3492 into main May 15, 2026
10 checks passed
@alpergundogdu
alpergundogdu deleted the feat/issue-400-region-self-attestation branch May 15, 2026 12:09
alpergundogdu added a commit that referenced this pull request May 15, 2026
#566)

* docs(adr): add ADR 030 — SafetyReserve appeal-surface contract surface (#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]>

* docs(adr): address PR #566 review — escrow lien model, incidentId, formula 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]>

* docs(adr): align ADR 030 enum/table comments with lien model; add UDVTs + 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]>

* docs(adr): fix ADR 030 §4 cross-ref + add 030/031 to reading-order build (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]>

* docs(adr): renumber ADR 030 -> 032 to avoid collision with PR #565

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]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Co-authored-by: Alper Gundogdu <[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 gap: node region / geolocation verification

3 participants