mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-04 02:57:44 +01:00
Batch 7: Command dispatch binding extraction - New weed/server/blockcmd package: CommandHandler interface + DispatchCommands - volume_server_block.go applyCoreCommandsWithAssignment delegates to dispatcher - weed/server still owns RecordCommand, EmitCoreEvent, PublishProjection - v2bridge NOT given command-switch or event-emission semantics Phase 16C: Rebuilding assignment enters core command path Phase 16D: Rebuild recovery-task startup is command-driven Phase 16E: Catch-up recovery-task startup is command-driven Engine refinements: - RecoveryTarget on AssignmentDelivered event - shouldStartRecoveryTask / shouldStartReceiver guards - bootstrapReason: awaiting_rebuild_start Bridge/contract updates: - control_adapter.go: refined translation helpers - contract.go: executor port alignment Migration design docs (Batch 1-3 delivered, design artifacts): - v2-first/second/third-migration-batch.md + task-pack.md - v2-assignment-translation-unification.md - v2-execution-muscles-inventory.md - v2-separation-port-layer-audit.md - v2-legacy-runtime-exit-criteria.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2.6 KiB
2.6 KiB
V2 Assignment Translation Unification
Date: 2026-04-04 Status: active
Purpose
This note defines how assignment translation should be unified so that:
weed/storage/blockvol/v2bridge/control.goweed/server/volume_server_block.go
do not drift on identity, role, or recovery-target meaning.
Current Drift Risk
Today there are two live translation sites:
ControlBridge.ConvertAssignment()producesengine.AssignmentIntentBlockService.coreAssignmentEvent()producesengine.AssignmentDelivered
They do not translate the same source type, but they do share semantic rules:
- how to build stable
ReplicaID - how to map role-shaped inputs to recovery target
- how to represent one local replica endpoint in engine types
If those rules stay duplicated, later migration batches will reintroduce split truth.
Canonical Rule Placement
The canonical reusable rules belong in:
sw-block/bridge/blockvol
Why:
- the rules are semantic translation, not product integration
- both
weed/storage/blockvol/v2bridgeandweed/servercan import this package sw-blockremains weed-free
Rules That Must Be Canonical
1. Stable identity
Canonical helper:
MakeReplicaID()ReplicaAssignmentForServer()
Rule:
ReplicaID = <volume>/<server-id>- never derive identity from transport address
2. Recovery-target mapping
Canonical helper:
RecoveryTargetForRole()
Rule:
replica -> catchuprebuilding -> rebuild- all other roles -> no recovery target
3. Endpoint packaging
Canonical helper:
ReplicaAssignmentForServer()
Rule:
- adapter code may still source endpoint fields from different wire/runtime inputs
- but once packaged into
engine.ReplicaAssignment, the shape must be uniform
What Still Stays Local
These parts remain adapter-local and should NOT be forced into one helper yet:
- reading
blockvol.BlockVolumeAssignment - deciding whether the local VS is primary/replica/rebuilding in a given runtime context
- multi-replica traversal over heartbeat/master wire structures
Those are source-format adaptation concerns, not canonical translation rules.
Implemented First Step
The first unification step is already applied:
sw-block/bridge/blockvol/control_adapter.go- now exports the canonical helpers
weed/server/volume_server_block.go- now consumes the same helper layer for local assignment rebinding
Next Step
The next step after this document is:
- reduce
weed/storage/blockvol/v2bridge/control.goto source-format extraction only - keep all shared semantic mapping rules in
sw-block/bridge/blockvol