Files
seaweedfs/sw-block/engine/replication/doc.go
T
pingqiuandClaude Opus 4.6 20d70f9fb6 feat: add V2 engine replication core (Phase 05 Slice 1)
Creates sw-block/engine/replication/ — the real V2 engine ownership core,
promoted from sw-block/prototype/enginev2/ with all accepted invariants.

Files:
- types.go: Endpoint, ReplicaState, SessionKind, SessionPhase, FSM transitions
- sender.go: per-replica Sender with full execution + rebuild APIs
- session.go: Session with identity, phases, frozen target, truncation, budget
- registry.go: Registry with reconcile + assignment intent + epoch invalidation
- budget.go: CatchUpBudget (duration, entries, stall detection)
- rebuild.go: RebuildState FSM (snapshot+tail vs full base)
- outcome.go: HandshakeResult + ClassifyRecoveryOutcome

Tests (ownership_test.go, 13 tests):
- Changed-address invalidation (A10)
- Stale session ID rejected at all APIs (A3)
- Stale completion after supersede (A3)
- Epoch bump invalidates all sessions (A3)
- Stale assignment epoch rejected
- Rebuild exclusivity (catch-up APIs rejected)
- Rebuild full lifecycle
- Frozen target rejects chase (A5)
- Budget violation escalates (A5)
- E2E: 3 replicas, 3 outcomes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:51:01 -07:00

25 lines
1.2 KiB
Go

// Package replication implements V2 per-replica sender/session ownership.
//
// This is the real V2 engine core, promoted from the prototype at
// sw-block/prototype/enginev2/. It preserves all accepted invariants:
//
// - One stable Sender per replica, identified by ReplicaID
// - One active Session per replica per epoch
// - Session identity fencing: stale sessionID rejected at every execution API
// - Endpoint change invalidates active session
// - Epoch bump invalidates all stale-epoch sessions
// - Catch-up is bounded (frozen target, budget enforcement)
// - Rebuild is a separate, exclusive sender-owned execution path
// - Completion requires convergence (catch-up) or ReadyToComplete (rebuild)
//
// File layout (Slice 1):
//
// types.go — Endpoint, ReplicaState, SessionKind, SessionPhase
// sender.go — Sender: per-replica owner with execution APIs
// session.go — Session: recovery lifecycle with FSM phases
// registry.go — Registry: sender group with reconcile + assignment intent
// budget.go — CatchUpBudget: bounded catch-up enforcement
// rebuild.go — RebuildState: rebuild execution FSM
// outcome.go — HandshakeResult, RecoveryOutcome classification
package replication