Skip to content

docs(adr): trim PoC framing where it doesn't pull weight - #388

Merged
alpergundogdu merged 1 commit into
mainfrom
docs/adr-trim-poc-framing
May 1, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
docs/adr-trim-poc-framing

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Across the ADR set, PoC vs Production carve-outs accreted in three shapes:

  • top-level diff-table sections,
  • paired `PoC: / Production:` inline callouts,
  • one half-designed Production sketch (in 014).

This pass walks each one and either keeps it (dual framing carries real explanatory weight), reframes it (structure is right but labels overspecify), or drops it (PoC side is implementation-status disguised as design). One commit, 11 files, ~100 LOC off.

Top-level scope sections

File Change
`007-watchtower.md` Top-of-doc scope note frames the ADR as the production design; § 8 collapses to a 3-item PoC forward-compat checklist. Watchtower fee model + gas-economics drop their PoC carve-outs. Sequencer-censorship reframed as layered defence (48 h baseline + forced-inclusion deadline extension on top).
`008-reputation.md` § 14 PoC Scope diff table → `### 14a. PoC Scope` (action items + invariants) + `### 14b. Deferred to Production` (bullets cross-ref'ing each deferred feature's main section in this ADR).
`019-node-onboarding.md` § PoC Simplifications table dropped. Real differences (multiaddr cooldown, NTP) were already in body sections; wallet/gas/keys folded into one forward-ref to ADR 024 + the operator key-rotation runbook in Phase-1 Step-4.
`024-account-abstraction.md` § 6 PoC vs Production Scope dropped — § 1 (`SignatureChecker` rollout) and § 3 (Session Keys — Deferred to Production) already own the surface; § 6 was an executive-summary recap with three "Yes | Yes" rows that survived the earlier "drop Same rows" pass. Client-side voucher-signing PoC/Production callouts merged.
`appendix-encrypted-content-publishing.md` § PoC Scope dropped — this appendix is an app-developer reference pattern, not a protocol ADR; every row was N/A on the PoC side.
`appendix-observability.md` § 5 dropped (operational maturity, not PoC vs Prod). § 2.7 "(production only)" tag dropped, replaced with one-line gating note. Two passing PoC mentions in intro / OpenMetrics-migration bullet rephrased. Sections renumbered.

Inline **PoC:** / **Production:** paired callouts

File Change
`001-network.md` Multiaddr Update Policy collapsed to one paragraph; region-hint verification dropped over-specific PoC/Production labels.
`012-client.md` Eclipse-attack mitigation collapsed to one paragraph. Three "PoC simplification" lines (`--max-channels capped at 1`, `single-channel mode only`, `single-chunk manifests only`) dropped — multi-channel downloads are supported in PoC. Also fixed a stale-spec contradiction where state-flush cadence was claimed as 256 MiB while line 334 already documented it as 64 MiB.
`013-schema-evolution.md` § Deprecation Timeline PoC paragraph dropped; the timeline applies to released versions.
`024-account-abstraction.md` Client voucher-signing PoC/Production pair merged (node-side hot-signing pair kept — see below).

Half-designed Production path

File Change
`014-on-chain-verification.md` § 2 BLAKE3 Content Corruption no longer carries the production sketch. Single-round optimistic challenge becomes the canonical current design. Interactive keccak256 Merkle path becomes a Future Evolution pointer to #387. The prior sketch left the BLAKE3↔keccak256 root binding as "subject of a future ADR" that was never written; half-designed sketches shouldn't sit in protocol spec.

Other

  • `architecture.md`: a passing "PoC payments use USDC only…" note under the system diagram dropped — multi-token support is in ADR 010 already.

Kept on purpose (dual framing earns its keep)

  • `001-network.md` `adminReclaimNodeId` PoC safety valve.
  • `009-governance.md` PoC: Admin Key vs Production: ve-Weighted Governance — two genuinely different governance systems.
  • `011-content-takedown.md` regional bodies (none vs EU/US 3-of-5).
  • `016-contract-interactions.md` § 8 PoC vs Production Contract Topology — only place the cross-contract mode delta lives.
  • `024-account-abstraction.md` § 2 node-side Owners + Hot signing — the technical justification (`SignatureChecker` → Safe's `checkSignatures` can't reach multi-owner threshold at wire speed) motivates the entire § 3 session-key design and shouldn't be elided.
  • `appendix-poc-production-seams.md` — the whole appendix is the canonical home for managing PoC/Prod seams; out of scope.

Test plan

  • `cd adr && pandoc … -o adrs.pdf` (numeric) — renders without warnings; § 14 in 008 now reads as Scope/Deferred-to-Production split with working anchor links.
  • `cd adr && pandoc … --lua-filter=_build/strip-meta-sections.lua _build/preface.md … -o adrs-book.pdf` — renders without typst label-not-found errors.
  • Spot-check 014 § 2: optimistic-challenge subsection now stands as the current design; ADR: production BLAKE3 corruption verification (interactive keccak256 Merkle proof + root-binding) #387 link works.
  • Spot-check 007: top-of-doc scope note flags the ADR as production-only; § 8 is the 3-item PoC checklist.

Notes

🤖 Generated with Claude Code

Across the ADR set, PoC vs Production carve-outs accreted in three shapes: top-level diff-table sections, paired bold inline callouts, and one half-designed Production sketch. This pass walks each one and either keeps it (when the dual framing carries real explanatory weight), reframes it (when the structure is right but the labels overspecify), or drops it (when the PoC side is implementation-status disguised as design). Net: ~100 lines off across 11 files.

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

@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 refactors several Architecture Decision Records (ADRs) to remove explicit distinctions between Proof of Concept (PoC) and production implementations. It merges PoC-specific simplifications into unified protocol descriptions, updates sections on watchtower economics, reputation scoring, and account abstraction to reflect a more cohesive design, and moves certain production-only features to deferred or future work sections. I have no feedback to provide.

@alpergundogdu
alpergundogdu merged commit 7ba0a88 into main May 1, 2026
8 of 10 checks passed
@alpergundogdu
alpergundogdu deleted the docs/adr-trim-poc-framing branch May 1, 2026 16:46
alpergundogdu added a commit that referenced this pull request May 5, 2026
The PoC/production split in §12 was decorative rather than load-bearing
— this PR's selection module ships the full 4-tier tie-breaker that §12
listed as production-only, which is the cleanest evidence the framing
isn't predicting what gets implemented. Following the trim pattern from
PRs #388 and the architecture intro, drop the section so §9's tie-break
spec stands as the single source of truth. What's wired vs. what's
deferred remains visible in code and issue tracking.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request May 5, 2026
The PoC/production split in §12 was decorative rather than load-bearing
— this PR's selection module ships the full 4-tier tie-breaker that §12
listed as production-only, which is the cleanest evidence the framing
isn't predicting what gets implemented. Following the trim pattern from
PRs #388 and the architecture intro, drop the section so §9's tie-break
spec stands as the single source of truth. What's wired vs. what's
deferred remains visible in code and issue tracking.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request May 11, 2026
* docs(plan): node selection algorithm (issue #322)

Bite-sized TDD plan to implement ADR 001 §Node Selection Algorithm
plus ADR 008 §9 four-tier tie-break (load → geo → stake → random),
landing as a pure ranking module at crates/node/src/selection.rs.
Stake stays Option<u64> until on-chain lookup is wired; reputation
is taken as f32 per Candidate so ReputationEngine can ship later.

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

* feat(selection): add Candidate / RankedCandidate types + module skeleton

Skeleton for the node-selection algorithm specified in ADR 001 and
ADR 008. Issue #322.

* feat(selection): compute_score with reputation floor clamp

Implements ADR 001's unified score formula. Reputation is clamped to a
0.1 floor so a node at 0.0 reputation scores identically to one at 0.1
(100x multiplier vs perfect reputation). Issue #322.

* feat(selection): rank_candidates basic score-ascending sort

No tie-breaking yet — that lands in tasks 4-7. Uses f64::total_cmp so
the comparator is total even though score values are always finite.
Issue #322.

* feat(selection): tie-break tier 1 (lower load wins within 1% score)

Adds tie-group detection on the 1% score-equivalence threshold from
ADR 001 and orders tied candidates by LoadHint (bandwidth_utilization
first, then active_streams). Tiers 2-4 follow. Issue #322.

* feat(selection): tie-break tier 2 (geographic diversity)

Refactors apply_tiebreaker into a stateful per-pick loop that prefers
candidates in regions not yet emitted. Tier-1 load winners across
multiple regions are now distributed before duplicates of the same
region. Issue #322.

* feat(selection): tie-break tier 3 (higher stake wins)

Stake is Option<u64> because on-chain stake lookup is deferred (not in
NodeAnnounce). When all pool candidates have stake = None the tier is
a no-op and the next tier decides. Issue #322.

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

* feat(selection): tie-break tier 4 (random) and complete ADR 008 §9

When all four tiers tie, picks uniformly at random from the remaining
pool. The internal rank_candidates_with_rng entry point keeps tests
deterministic via a seeded StdRng. Issue #322.

* fix(selection): pin random seed in geo-diversity test

geo_diversity_prefers_unseen_region was flaky: with three candidates
fully tied by score and load, the tier-4 random tier could pick DE
first, breaking the [US, DE, US] assertion ~1 in 3 runs. Switching to
rank_candidates_with_rng with a fixed seed makes the path
deterministic. Issue #322.

* test(selection): make geo-diversity test invariant-based

Replaces the seed-2 golden-output check with a loop over 32 seeds that
asserts the actual invariant — WHEN the first pick is US, the second
pick MUST be DE (the only unseen region). Robust to rand RNG changes
and input ordering. Also adds a comment explaining why the random
tier's pool.get(idx).copied().unwrap_or(0) is unreachable-None.
Issue #322.

* feat(selection): add top_n helper and MAX_PROVIDER_ATTEMPTS = 3

top_n(candidates, MAX_PROVIDER_ATTEMPTS) is the canonical entry point
for the future cache-miss-pull caller — issue #322's 'max 3 provider
attempts before returning error to caller' requirement.

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

* fix(selection): scope geo tie-break tracker per tie group

The emitted_regions HashSet was declared outside the outer while loop
in apply_tiebreaker, so a region picked in one score tie group biased
the geo tier of subsequent unrelated tie groups. ADR 008 §9 scopes
tie-breaking to a single group; resetting the tracker per group fixes
the leak and matches the function's doc comment. Adds a regression
test using two distinct-score tie groups with overlapping regions.
Issue #322.

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

* fix(selection): drop intra-doc link to private rank_candidates_with_rng

CI's rustdoc lint denies private_intra_doc_links: a public doc comment
on rank_candidates can't link to the private rank_candidates_with_rng
helper. Replace the [`...`] link with plain code formatting; the test
module already uses the helper directly so no functional reference is
lost.

Issue #322.

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

* docs(adr): drop ADR 008 §12 PoC Scope

The PoC/production split in §12 was decorative rather than load-bearing
— this PR's selection module ships the full 4-tier tie-breaker that §12
listed as production-only, which is the cleanest evidence the framing
isn't predicting what gets implemented. Following the trim pattern from
PRs #388 and the architecture intro, drop the section so §9's tie-break
spec stands as the single source of truth. What's wired vs. what's
deferred remains visible in code and issue tracking.

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

* perf(selection): use swap_remove for tie-group pick removal

`pick_best_in_group` rescans the group from scratch on every iteration,
so the order inside the Vec doesn't matter. swap_remove is O(1) where
remove is O(K). Negligible at PoC scale but mechanical to fix.

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

* perf(selection): collapse pick_best_in_group to a single pool buffer

Replace the load_tied / geo_pool / stake_pool intermediates with a
single Vec<usize> filtered in place across the four tiers. Allocates
one Vec per call regardless of group size, instead of three per call
plus a clone in the geo-empty branch.

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

* fix(selection): correctly group zero-score candidates in tie_group_end

The previous denom <= 0.0 guard treated zero-score candidates as
ungroupable: each became its own singleton tie group, so the load /
geo / stake / random tiers were silently skipped between them. Replace
with: a zero pivot ends the group only when the next score is strictly
positive (zero is strictly better than any positive score), and zero
scores tie with each other.

Adds two regression tests:
- zero_score_candidates_group_together_for_tie_break — two zero scores
  go through the load tier
- zero_score_beats_positive_score — zero is not tied with positive

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

* refactor(selection): apply review fixes — debug_asserts, non_exhaustive, ADR refs

- Add `#[non_exhaustive]` to `Candidate` and `RankedCandidate` so future
  tie-break fields don't break downstream extractors.
- Pair the unreachable safe fallbacks (slice bounds, pick_idx, empty group,
  random tier) with `debug_assert!` so invariant breaks surface in tests
  while release keeps the clippy-required indexing guard.
- Fix Tier 3 comment: ADR 023 doesn't exist; stake-lookup wiring lives in
  ADR 001 §Node Registry / ADR 019.
- Document why `compare_load` orders by `bandwidth_utilization` first
  (utilization is the primary saturation signal; `active_streams` is a
  coarser proxy).
- Soften the ADR 008 §9 citation in `apply_tiebreaker` — §9 lists the four
  tiers but doesn't prescribe per-group scoping; that's this module's
  interpretation.
- Add `some_zero_stake_beats_none_stake` test pinning the `Some(0)` vs
  `None` boundary (Some(0) wins because `max_stake = Some(0)` then retain
  drops `None` entries).

Findings from /pr-review-toolkit:review-pr (5 specialist agents).

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

* chore(docs): remove node-selection implementation plan

Plan completed; implementation lives in crates/node/src/selection.rs.

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

* refactor(selection): drop f32→f64 cast in compute_score, drain in apply_tiebreaker

Addresses two open review threads on PR #380:

- gemini: REPUTATION_FLOOR was f32 but compute_score works in f64; declaring
  the floor as f64 lets us promote-then-clamp in one expression and drop the
  intermediate `rep_clamped`.
- Copilot: apply_tiebreaker cloned each tie group via `to_vec()`, copying every
  RankedCandidate (including its String region). Switching to `Vec::drain`
  moves elements out of `ranked` instead, eliminating K String clones per
  K-sized tie group. Also lets us drop the `start: usize` walk variable and
  the `.get(start..end)` ceremony required by clippy::indexing_slicing.

Side effect of the f64 floor: `0.1f32` promotes to ~0.10000000149f64, slightly
above the floor, so an exact-floor input no longer aliases the clamp output.
The two clamp tests now compare two sub-floor inputs (0.0 and 0.01, or -0.5
and 0.01), which both clamp identically — preserves the original "clamping
happens" semantic without depending on the f32→f64 promotion artifact.

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

* test(selection): add boundary + invariant tests, tighten doc-comments

Round-2 review pass on PR #380 surfaced four polish items and four missing
boundary tests. None block correctness; all are cheap quality wins.

Doc nits:
- tie_group_end: state the termination contract ("returns > start whenever
  start < ranked.len()") so the drain-the-front loop's progress invariant
  is local-to-read.
- pick_best_in_group: state the order-independence INVARIANT that
  apply_tiebreaker's swap_remove relies on, and document the pool-index
  validity invariant (only shrinks via retain → every entry is a valid
  group index).
- Tier 3 ADR ref: cite ADR 001's actual heading "Contract Interface: Node
  Registry" for greppability.

New tests:
- score_floor_value_is_zero_point_one — pins REPUTATION_FLOOR=0.1 by value
  (existing tests pin clamping behavior but not the floor value).
- at_1_percent_boundary_counts_as_tied — covers the exact 1.0% boundary;
  tie_group_end uses `> TIE_THRESHOLD` so 1.0% is *inclusive*. Guards
  against a future change to `>=`.
- three_way_zero_stake_falls_through_to_random_tier — two `Some(0)` plus
  one `None`; verifies tier 3 retains both `Some(0)` survivors and tier 4
  picks fairly between them. Guards the `Some(0)` semantic from
  some_zero_stake_beats_none_stake against a one-winner short-circuit.
- top_n_with_zero_returns_empty — locks the n=0 contract against a future
  truncate(n.max(1)).

Drop #[non_exhaustive] from Candidate and RankedCandidate — the `node`
crate doesn't expose a stable downstream API surface yet, and the markers
were forward-looking insurance with no current consumer to protect.

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

* refactor(selection): clamp reputation in f32 before promoting to f64

Revert aaf9e42's REPUTATION_FLOOR f32→f64 change. The cleaner resolution to
gemini's original concern is to inline the cast rather than change the
constant's type:

  // before aaf9e42 (had intermediate var)
  let rep_clamped = reputation.max(REPUTATION_FLOOR);
  let rep = f64::from(rep_clamped);

  // aaf9e42 (f64 floor — promote then clamp)
  let rep = f64::from(reputation).max(REPUTATION_FLOOR);

  // now (f32 floor — clamp then promote, single line)
  let rep = f64::from(reputation.max(REPUTATION_FLOOR));

The aaf9e42 form had a subtle boundary surprise: f32(0.1) is not exactly
representable in f32 (its true value is ~0.10000000149), and promotes to a
value slightly above the f64 floor — so an exact-0.1 reputation input
slipped past the clamp. That forced the two clamp-tests to compare two
sub-floor inputs instead of the natural "clamped-zero == compute_score(_,
_, 0.1)" assertion.

Clamping in f32 (the input's domain) and promoting once at the end keeps
the floor's type matching the input's, restores the natural test, and
applies gemini's actual cleanup intent (one conversion, no intermediate
variable). Rule of thumb: convert at the latest sensible point.

Tests:
- score_reputation_0_0_clamps_to_floor / score_negative_reputation_clamps_to_floor:
  reverted the sub-floor-vs-sub-floor workaround.
- score_floor_value_is_zero_point_one: tolerance loosened from 1e-3 to 1e-2
  to absorb the f32(0.1) → f64 promotion artifact (~3e-3 in score). Still
  catches a floor drift to 0.05 or 0.2.

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.

1 participant