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>
3.5 KiB
V2 Second Migration Batch
Date: 2026-04-04 Status: delivered
Purpose
This note defines the second migration batch for the sw-block separation
work.
The first batch established contract ownership and canonical translation in
sw-block. The second batch starts the next frontier: backend-binding
extraction.
Batch Goal
Separate reusable execution-muscle logic from concrete BlockVol bindings so
that more code can physically move toward sw-block without importing
weed/storage/blockvol.
Batch Scope
In scope
- reader backend-binding extraction
- pinner backend-binding extraction
- executor backend capability extraction
- recovery-side shim reduction where those bindings are still copied manually
Out of scope
- moving raw
BlockVolbackend code intosw-block - moving
weed/server/block_recovery.gowhole - redesigning the rebuild TCP protocol
- changing engine semantics or recovery policy
Current Boundary Problem
After the first batch, the ownership split is better, but the reusable logic is
still physically stuck next to BlockVol because:
weed/storage/blockvol/v2bridge/reader.goreadsBlockVoldirectlyweed/storage/blockvol/v2bridge/pinner.gomixes hold bookkeeping with concrete retention-floor wiringweed/storage/blockvol/v2bridge/executor.gomixes reusable recovery steps with concrete backend callsweed/server/block_recovery.gostill contains reader/pinner shims that copy contract shapes manually
Target Package Shape
Recommended landing zone inside sw-block:
- keep pure contracts in
sw-block/bridge/blockvol - allow a new execution-oriented package for reusable muscle logic:
sw-block/bridge/blockvol/runtime
Weed-side code should shrink toward:
- thin
BlockVolbinding - runtime hosting
- network/wire adaptation
Concrete Batch Steps
- extract reader logic so
weed/only fetches backend snapshot data - extract pinner hold bookkeeping so
weed/only performs concrete retention binding and state checks - extract executor-facing backend capabilities so reusable orchestration no
longer depends on direct
BlockVolimports - remove redundant reader/pinner contract-shape shims from
weed/server/block_recovery.gowhere the new extracted layer makes them unnecessary
Execution Form
This batch is executed through the validate-able tasks in:
sw-block/design/v2-second-migration-task-pack.md
Why This Batch Is Second
This batch comes second because the first batch had to finish first:
- backend-binding extraction is unsafe until contracts and canonical rules are stable
- after Batch 1, the remaining coupling is mostly physical implementation coupling, not semantic drift
- shrinking
weed/serveronly becomes meaningful onceweed/storage/...stops owning reusable muscle logic
Exit Condition
This batch is complete when:
- reusable reader/pinner/executor logic can live in
sw-blockwithout directweed/storage/blockvolimports - weed-side files are reduced to thin backend bindings and runtime hosting
- recovery-side manual shims are either removed or reduced to trivial wiring
Delivery Note
This batch is now delivered:
- Task E removed reader contract-shape shimming and made
v2bridge.Readerreturn the bridge contract directly - Task F removed the pinner shim from
weed/server/block_recovery.go - Task G was reviewed and confirmed already clean because
v2bridge.Executoralready satisfies the engine IO interfaces directly