From 240e47b99bf968307ad024bb3fa2fdb0b70e0b51 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 26 Jun 2026 11:07:08 -0700 Subject: [PATCH] phase79: wire failback authority callsite --- .../ops/failback_authority_runtime_adapter.go | 48 +++++ ...failback_authority_runtime_adapter_test.go | 145 +++++++++++++ seaweed-block/docs/roadmap.md | 18 +- seaweed-block/internal/docs/current-plan.md | 194 +++++++----------- ...inishedplan_failback_authority_callsite.md | 160 +++++++++++++++ ...-failback-authority-callsite-qa-signoff.md | 77 +++++++ ...hase79-failback-authority-callsite-gate.sh | 62 ++++++ .../failback-authority-callsite-chain.yaml | 115 +++++++++++ 8 files changed, 698 insertions(+), 121 deletions(-) create mode 100644 seaweed-block/core/ops/failback_authority_runtime_adapter.go create mode 100644 seaweed-block/core/ops/failback_authority_runtime_adapter_test.go create mode 100644 seaweed-block/internal/docs/finished-plans/phase79_finishedplan_failback_authority_callsite.md create mode 100644 seaweed-block/internal/docs/qa-assignments/phase79-failback-authority-callsite-qa-signoff.md create mode 100644 seaweed-block/scripts/run-phase79-failback-authority-callsite-gate.sh create mode 100644 seaweed-block/testops/scenarios/failback-authority-callsite-chain.yaml diff --git a/seaweed-block/core/ops/failback_authority_runtime_adapter.go b/seaweed-block/core/ops/failback_authority_runtime_adapter.go new file mode 100644 index 0000000000..5a1acc3abd --- /dev/null +++ b/seaweed-block/core/ops/failback_authority_runtime_adapter.go @@ -0,0 +1,48 @@ +package ops + +import ( + "context" + + "github.com/seaweedfs/seaweed-block/core/authority" +) + +// AuthorityFailbackRuntime adapts the ops failback executor contract to the +// authority package seam. The executor remains policy-gated; this adapter only +// performs the already-authorized authority reassignment. +type AuthorityFailbackRuntime struct { + Runtime authority.FailbackAuthorityRuntime +} + +func NewAuthorityFailbackRuntime(publisher *authority.Publisher) *AuthorityFailbackRuntime { + return &AuthorityFailbackRuntime{ + Runtime: authority.FailbackAuthorityRuntime{Publisher: publisher}, + } +} + +func (r *AuthorityFailbackRuntime) ExecuteFailback(ctx context.Context, req FailbackRuntimeRequest) (FailbackRuntimeResult, error) { + result, err := r.Runtime.ExecuteFailback(ctx, authority.FailbackRuntimeRequest{ + VolumeID: req.VolumeID, + ReplicaID: req.ReplicaID, + TargetDataAddr: req.TargetDataAddr, + TargetCtrlAddr: req.TargetCtrlAddr, + ExpectedCurrentReplicaID: req.ExpectedCurrentReplicaID, + ExpectedCurrentEpoch: req.ExpectedCurrentEpoch, + AckEligible: req.AckEligible, + FrontendFencedBeforeFailback: req.FrontendFencedBeforeFailback, + DurableFrontierCovered: req.DurableFrontierCovered, + NoCrossVolumeIdentityChange: req.NoCrossVolumeIdentityChange, + EvidenceRefs: append([]string(nil), req.EvidenceRefs...), + }) + if err != nil { + return FailbackRuntimeResult{}, err + } + return FailbackRuntimeResult{ + FailbackStarted: result.FailbackStarted, + AuthorityEpochAdvanced: result.AuthorityEpochAdvanced, + SinglePrimaryAfterFailback: result.SinglePrimaryAfterFailback, + PublishTargetSwappedAfterFailback: result.PublishTargetSwappedAfterFailback, + NoStorageMutation: result.NoStorageMutation, + NoCrossVolumeIdentityChange: result.NoCrossVolumeIdentityChange, + EvidenceRefs: append([]string(nil), result.EvidenceRefs...), + }, nil +} diff --git a/seaweed-block/core/ops/failback_authority_runtime_adapter_test.go b/seaweed-block/core/ops/failback_authority_runtime_adapter_test.go new file mode 100644 index 0000000000..8f0c997b7f --- /dev/null +++ b/seaweed-block/core/ops/failback_authority_runtime_adapter_test.go @@ -0,0 +1,145 @@ +package ops + +import ( + "context" + "strings" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/authority" +) + +func TestFailbackExecutorUsesAuthorityRuntimeAdapter(t *testing.T) { + publisher := seededFailbackPublisher(t) + target := failbackExecutorExecutableTargetFixture() + target.Spec.ReplicaID = "r1" + target.Spec.ExpectedCurrentEpoch = 2 + client := &fakeFailbackExecutorClient{targets: []SwBlockReplicaFailbackObject{target}} + + result, err := (FailbackExecutorReconciler{ + Namespace: "kube-system", + Client: client, + Runtime: NewAuthorityFailbackRuntime(publisher), + ExecutionRequested: true, + ExecutionPolicyEnabled: true, + Now: func() time.Time { return time.Date(2026, 6, 26, 15, 0, 0, 0, time.UTC) }, + }).Reconcile(context.Background()) + if err != nil { + t.Fatalf("reconcile: %v", err) + } + if result.FailbackAttempts != 1 || + result.StatusWriteCount != 1 || + !result.AuthorityMutationAllowed || + result.FrontendPublicationAllowed || + result.StorageMutationAllowed { + t.Fatalf("result=%+v", result) + } + line, ok := publisher.VolumeAuthorityLine(target.Spec.VolumeID) + if !ok { + t.Fatalf("missing authority line for %s", target.Spec.VolumeID) + } + if line.ReplicaID != target.Spec.ReplicaID || + line.Epoch != 3 || + line.DataAddr != target.Spec.TargetDataAddr || + line.CtrlAddr != target.Spec.TargetCtrlAddr { + t.Fatalf("authority line=%+v", line) + } + status := client.writes[0].status + if status.State != FailbackStateFailedBack || + status.ReasonCode != AuthorityExecutorFailbackReasonCompleted || + !status.FailbackStarted || + !status.AuthorityEpochAdvanced || + !status.SinglePrimaryAfterFailback || + !status.PublishTargetSwappedAfterFailback || + status.FailbackMutationAllowed { + t.Fatalf("status=%+v", status) + } + if !failbackExecutorStringSliceContains(status.EvidenceRefs, "authority_failback_reassign_minted") { + t.Fatalf("evidenceRefs=%+v", status.EvidenceRefs) + } +} + +func TestFailbackAuthorityRuntimeAdapterRejectsStaleExpectedCurrent(t *testing.T) { + publisher := seededFailbackPublisher(t) + target := failbackExecutorExecutableTargetFixture() + target.Spec.ReplicaID = "r1" + target.Spec.ExpectedCurrentEpoch = 99 + client := &fakeFailbackExecutorClient{targets: []SwBlockReplicaFailbackObject{target}} + + result, err := (FailbackExecutorReconciler{ + Namespace: "kube-system", + Client: client, + Runtime: NewAuthorityFailbackRuntime(publisher), + ExecutionRequested: true, + ExecutionPolicyEnabled: true, + }).Reconcile(context.Background()) + if err == nil || !strings.Contains(err.Error(), "stale expected current line") { + t.Fatalf("err=%v", err) + } + if result.FailbackAttempts != 1 || result.StatusWriteCount != 1 { + t.Fatalf("result=%+v", result) + } + status := client.writes[0].status + if status.State != FailbackStateBlocked || + status.ReasonCode != AuthorityExecutorFailbackReasonRuntimeFailed || + status.FailbackStarted || + status.AuthorityEpochAdvanced || + status.SinglePrimaryAfterFailback || + status.PublishTargetSwappedAfterFailback { + t.Fatalf("status=%+v", status) + } + line, ok := publisher.VolumeAuthorityLine(target.Spec.VolumeID) + if !ok { + t.Fatalf("missing authority line for %s", target.Spec.VolumeID) + } + if line.ReplicaID != "r2" || line.Epoch != 2 { + t.Fatalf("stale expected-current failure changed authority line: %+v", line) + } +} + +func seededFailbackPublisher(t *testing.T) *authority.Publisher { + t.Helper() + directive := authority.NewStaticDirective([]authority.AssignmentAsk{ + { + VolumeID: "pvc-demo", + ReplicaID: "r1", + DataAddr: "data-old-r1", + CtrlAddr: "ctrl-old-r1", + Intent: authority.IntentBind, + }, + { + VolumeID: "pvc-demo", + ReplicaID: "r2", + DataAddr: "data-r2", + CtrlAddr: "ctrl-r2", + Intent: authority.IntentReassign, + }, + }) + publisher := authority.NewPublisher(directive) + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan error, 1) + go func() { + done <- publisher.Run(ctx) + }() + + deadline := time.After(2 * time.Second) + ticker := time.NewTicker(10 * time.Millisecond) + defer ticker.Stop() + for { + line, ok := publisher.VolumeAuthorityLine("pvc-demo") + if ok && line.ReplicaID == "r2" && line.Epoch == 2 { + cancel() + if err := <-done; err != context.Canceled { + t.Fatalf("publisher run err=%v", err) + } + return publisher + } + select { + case <-deadline: + cancel() + <-done + t.Fatalf("publisher did not seed r2@2") + case <-ticker.C: + } + } +} diff --git a/seaweed-block/docs/roadmap.md b/seaweed-block/docs/roadmap.md index d303f32e51..2a15301946 100644 --- a/seaweed-block/docs/roadmap.md +++ b/seaweed-block/docs/roadmap.md @@ -311,7 +311,16 @@ Recommended order from here: state, and publish-target swap. Default deployed behavior remains disabled; no automatic failback call-site, frontend publication, storage mutation, or workload mutation is enabled. -36. Add backup/restore and NVMe ANA parity after they can reuse the same action +36. Phase 79: failback authority call-site. **Closed 2026-06-26, local PASS** + (`internal/docs/finished-plans/phase79_finishedplan_failback_authority_callsite.md`). + The failback executor can now invoke an in-process + `AuthorityFailbackRuntime` adapter under the explicit execution-policy + gate. The adapter advances the Publisher authority line and writes + `failed_back` only after terminal evidence. Stale expected-current evidence + blocks the call-site; frontend publication and storage mutation remain + false. The deployed controller loop still does not perform automatic + failback. +37. Add backup/restore and NVMe ANA parity after they can reuse the same action owner, evidence, and status model rather than creating another isolated control plane. @@ -338,9 +347,10 @@ failback, authority mutation, or frontend publication is executed. Phase 76 adds the matching executor identity and status-only boundary for those failback targets, still keeping all real failback side effects disabled. Phase 77 adds the typed failback runtime contract and opt-in execution gate. Phase 78 adds -the first authority-owned failback seam through `Publisher.apply(IntentReassign)`, -but still does not enable automatic deployed failback, frontend publication, or -storage/workload mutation. +the first authority-owned failback seam through `Publisher.apply(IntentReassign)`. +Phase 79 wires that seam to the failback executor as an explicit-policy-gated +in-process call-site. Automatic deployed failback, frontend publication, and +storage/workload mutation remain disabled. The practical rule is: diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index 517626801c..8d4df1d14c 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,153 +1,114 @@ -# Current Plan: Phase 78 Failback Authority Runtime Seam +# Current Plan: Phase 79 Failback Authority Call-site Status: complete. ## Goal -Phase 77 defined the typed failback runtime contract, but the success path was -still a fake/HTTP runtime claim. Phase 78 adds the first product-owned -authority runtime seam for returned-replica failback. +Phase 78 added the authority-owned failback seam, but the failback executor did +not yet have a product call-site to invoke it. Phase 79 wires the executor's +runtime contract to that seam through an in-process adapter. -The seam is deliberately narrow: +Default behavior remains disabled/status-only. The adapter is used only when +the existing explicit execution gate is satisfied: ```text -validated failback target - -> expected-current authority guard - -> Publisher.apply(IntentReassign) - -> terminal evidence for epoch advance, single primary, and publish-target swap +--enable-execution +--execution-policy +executable SwBlockReplicaFailback target ``` -Default behavior remains disabled/status-only. A normal -`SwBlockReplicaFailback` target created by the target owner is still not -executable. Execution requires explicit runtime fields and policy flags. - ## Deliverables -### D1: Authority Runtime Seam +### D1: Runtime Adapter Added: ```text -core/authority.FailbackAuthorityRuntime -core/authority.FailbackRuntimeRequest -core/authority.FailbackRuntimeResult +core/ops.AuthorityFailbackRuntime +core/ops.NewAuthorityFailbackRuntime ``` -The authority runtime requires: +The adapter implements the existing `ops.FailbackRuntime` interface and maps +the executor request into: ```text -volumeID -replicaID -targetDataAddr -targetCtrlAddr -expectedCurrentReplicaID -expectedCurrentEpoch -ackEligible=true -frontendFencedBeforeFailback=true -durableFrontierCovered=true -noCrossVolumeIdentityChange=true +authority.FailbackAuthorityRuntime.ExecuteFailback ``` -It rejects stale expected-current evidence before minting a new authority line. +### D2: Executor Call-site -### D2: Reassign Through Publisher - -The runtime uses the existing authority owner path: +The failback executor can now use the authority adapter as its runtime: ```text -Publisher.apply(AssignmentAsk{Intent: IntentReassign}) +FailbackExecutorReconciler{ + Runtime: NewAuthorityFailbackRuntime(publisher), + ExecutionRequested: true, + ExecutionPolicyEnabled: true, +} ``` -The result is accepted only when: +The test path proves: ```text -authorityEpochAdvanced=true -singlePrimaryAfterFailback=true -publishTargetSwappedAfterFailback=true -noStorageMutation=true -noCrossVolumeIdentityChange=true +current authority line: r2@2 +target returned replica: r1 +executor invokes adapter +adapter invokes authority runtime +Publisher.apply(IntentReassign) advances line to r1@3 +SwBlockReplicaFailback.status.state=failed_back ``` -### D3: Target Endpoint and Expected-Current Contract +### D3: Negative Guard -`SwBlockReplicaFailback.spec` now carries the runtime facts needed for a real -authority-owned failback: +Stale expected-current evidence still fails closed: ```text -targetDataAddr -targetCtrlAddr -expectedCurrentReplicaID -expectedCurrentEpoch +expectedCurrentReplicaID=r2 +expectedCurrentEpoch=99 +actual current line=r2@2 ``` -Returned-replica projection now preserves data/control endpoint facts from -inventory evidence: +The executor writes blocked status and does not claim failback. + +### D4: Boundary + +The existing boundaries remain: ```text -VolumeInventoryReplicaInput - -> ReplicaEvidence - -> ReplicaFact - -> ReturnedReplicaProjection - -> SwBlockVolume.status.replicaReintegrations[] - -> SwBlockReplicaFailback.spec -``` - -### D4: Execution Boundary - -The executor still refuses to run by default. Executability requires all of: - -```text -failbackDecision=enabled -failbackMutationAllowed=true -runtimeEndpoint -targetDataAddr -targetCtrlAddr -expectedCurrentReplicaID -expectedCurrentEpoch ---enable-execution ---execution-policy ---failback-runtime-url -``` - -Only the explicit runtime success path reports: - -```text -authority_mutation_allowed=true -``` - -Default and dry-run paths continue to report: - -```text -authority_mutation_allowed=false -storage_mutation_allowed=false +execution policy is still required +dry-run writes no status +default authority_mutation_allowed=false frontend_publication_allowed=false +storage_mutation_allowed=false ``` +Only the explicit adapter call-site path can advance authority. + ### D5: Gate Added: ```text -scripts/run-phase78-failback-authority-runtime-gate.sh -testops/scenarios/failback-authority-runtime-chain.yaml +scripts/run-phase79-failback-authority-callsite-gate.sh +testops/scenarios/failback-authority-callsite-chain.yaml ``` The gate proves: ```text -authority failback reassign is minted through Publisher.apply -stale expected-current evidence is rejected -terminal preconditions are required -target endpoint fields are preserved -expected-current fields are required for executable targets -explicit runtime success is the only authority-mutating path -storage mutation remains false +executor invokes authority runtime adapter +publisher authority line advances +stale expected-current evidence blocks the call-site +execution policy remains required +failed_back status is written only after terminal evidence +runtime failure produces no false failback frontend publication remains false +storage mutation remains false ``` ## Non-Claims -Phase 78 does not implement: +Phase 79 does not implement: ```text automatic failback from the deployed controller loop @@ -159,44 +120,43 @@ workload mutation NVMe ANA behavior ``` -It creates the authority-owned seam that a future product call-site can invoke. -The deployed default remains disabled/status-only. +It wires the product call-site in-process for controlled execution. The deployed +default remains disabled/status-only. ## Verification ```text -go test ./core/authority -run "TestFailbackAuthorityRuntime" -count=1 -v -go test ./core/ops -run "TestFailbackExecutor|TestFailbackTargetOwner|TestHTTPFailbackRuntime|TestPhase46D2SwBlockVolumeReturnedReplicaSchema|TestPhase75SwBlockReplicaFailbackTargetSchema|TestKubernetesStatusClientCreatesSwBlockReplicaFailbackWithoutStatus" -count=1 -v -go test ./cmd/sw-block -run "TestOpsFailback" -count=1 -v +go test ./core/ops -run "TestFailbackExecutorUsesAuthorityRuntimeAdapter|TestFailbackAuthorityRuntimeAdapterRejectsStaleExpectedCurrent|TestFailbackExecutorExecutionPolicyBlocks|TestFailbackExecutorDryRunDoesNotWriteStatus" -count=1 -v go test ./core/authority ./core/ops ./cmd/sw-block helm lint charts/seaweed-block -"C:\Program Files\Git\bin\bash.exe" scripts/run-phase78-failback-authority-runtime-gate.sh . -C:\work\swblock.exe validate testops\scenarios\failback-authority-runtime-chain.yaml +"C:\Program Files\Git\bin\bash.exe" scripts/run-phase79-failback-authority-callsite-gate.sh . +C:\work\swblock.exe validate testops\scenarios\failback-authority-callsite-chain.yaml +git diff --check ``` -Expected terminal evidence: +Terminal evidence: ```text -phase78_failback_authority_runtime_status=ok -core_authority_failback_runtime_tests=pass -core_ops_failback_authority_runtime_tests=pass -cmd_failback_authority_runtime_tests=pass -authority_failback_reassign_minted=true -stale_expected_current_rejected=true -terminal_preconditions_required=true -failback_target_endpoint_fields=true -failback_target_expected_current_fields=true -executable_failback_requires_authority_endpoint=true -explicit_runtime_authority_mutation_allowed=true +phase79_failback_authority_callsite_status=ok +core_ops_failback_authority_callsite_tests=pass +authority_runtime_adapter_invoked_by_executor=true +stale_expected_current_blocks_callsite=true +execution_policy_still_required=true +dry_run_no_status_write=true +publisher_authority_line_advanced=true authority_epoch_advanced=true single_primary_after_failback=true publish_target_swapped_after_failback=true -storage_mutation_allowed=false +failed_back_status_written=true +runtime_failure_no_false_failback=true +authority_mutation_allowed_only_with_execution_policy=true frontend_publication_allowed=false +storage_mutation_allowed=false ``` ## Next -The next phase should add the product call-site that invokes this authority seam -from a real failback owner/controller path, still gated by explicit policy, -expected-current evidence, and terminal status evidence. +The next phase should decide how this in-process call-site becomes reachable in +the product. The safest next increment is a disabled-by-default CLI or +controller wiring gate that can construct the adapter from a real Publisher +without enabling automatic failback. diff --git a/seaweed-block/internal/docs/finished-plans/phase79_finishedplan_failback_authority_callsite.md b/seaweed-block/internal/docs/finished-plans/phase79_finishedplan_failback_authority_callsite.md new file mode 100644 index 0000000000..7829eac236 --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase79_finishedplan_failback_authority_callsite.md @@ -0,0 +1,160 @@ +# Phase 79 Finished Plan: Failback Authority Call-site + +Status: complete. + +## Problem + +Phase 78 added a product-owned authority failback seam, but it was not yet +reachable from the failback executor call-site. The executor could call fake or +HTTP runtimes, but not the in-process authority seam that mints +`IntentReassign`. + +## Implementation + +Added an adapter: + +```text +core/ops.AuthorityFailbackRuntime +core/ops.NewAuthorityFailbackRuntime +``` + +The adapter implements `ops.FailbackRuntime` and delegates to: + +```text +authority.FailbackAuthorityRuntime.ExecuteFailback +``` + +The mapping preserves: + +```text +volumeID +replicaID +targetDataAddr +targetCtrlAddr +expectedCurrentReplicaID +expectedCurrentEpoch +ackEligible +frontendFencedBeforeFailback +durableFrontierCovered +noCrossVolumeIdentityChange +evidenceRefs +``` + +## Behavior + +The executor can now run: + +```text +SwBlockReplicaFailback target + -> FailbackExecutorReconciler + -> AuthorityFailbackRuntime adapter + -> authority.FailbackAuthorityRuntime + -> Publisher.apply(IntentReassign) + -> SwBlockReplicaFailback.status=failed_back +``` + +The successful test seeds authority as: + +```text +r1@1 -> r2@2 +``` + +Then the executor targets returned replica `r1` with expected current `r2@2`. +The adapter advances authority to: + +```text +r1@3 +``` + +## Failure Boundary + +Stale expected-current evidence fails closed: + +```text +expected r2@99 +actual r2@2 +``` + +The executor writes blocked status with runtime failure and does not claim +failback. + +The existing gates remain: + +```text +execution policy still required +dry-run writes no status +frontend_publication_allowed=false +storage_mutation_allowed=false +``` + +## Gate + +Added: + +```text +scripts/run-phase79-failback-authority-callsite-gate.sh +testops/scenarios/failback-authority-callsite-chain.yaml +``` + +The gate checks: + +```text +executor invokes authority runtime adapter +publisher authority line advances +stale expected-current evidence blocks call-site +execution policy remains required +failed_back status is written after terminal evidence +runtime failure produces no false failback +frontend publication remains false +storage mutation remains false +``` + +## Verification + +```text +go test ./core/ops -run "TestFailbackExecutorUsesAuthorityRuntimeAdapter|TestFailbackAuthorityRuntimeAdapterRejectsStaleExpectedCurrent|TestFailbackExecutorExecutionPolicyBlocks|TestFailbackExecutorDryRunDoesNotWriteStatus" -count=1 -v +go test ./core/authority ./core/ops ./cmd/sw-block +helm lint charts/seaweed-block +"C:\Program Files\Git\bin\bash.exe" scripts/run-phase79-failback-authority-callsite-gate.sh . +C:\work\swblock.exe validate testops\scenarios\failback-authority-callsite-chain.yaml +git diff --check +``` + +Terminal evidence: + +```text +phase79_failback_authority_callsite_status=ok +core_ops_failback_authority_callsite_tests=pass +authority_runtime_adapter_invoked_by_executor=true +stale_expected_current_blocks_callsite=true +execution_policy_still_required=true +dry_run_no_status_write=true +publisher_authority_line_advanced=true +authority_epoch_advanced=true +single_primary_after_failback=true +publish_target_swapped_after_failback=true +failed_back_status_written=true +runtime_failure_no_false_failback=true +authority_mutation_allowed_only_with_execution_policy=true +frontend_publication_allowed=false +storage_mutation_allowed=false +``` + +## Non-Claims + +Phase 79 does not implement: + +```text +automatic failback from the deployed controller loop +blockmaster HTTP/gRPC failback endpoint +blockvolume frontend switching +frontend publication after failback +storage rebuild/catch-up traffic +workload mutation +NVMe ANA behavior +``` + +## Next + +Add a disabled-by-default product wiring gate that constructs this adapter from +a real Publisher in the component that owns authority state. diff --git a/seaweed-block/internal/docs/qa-assignments/phase79-failback-authority-callsite-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase79-failback-authority-callsite-qa-signoff.md new file mode 100644 index 0000000000..551af87033 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase79-failback-authority-callsite-qa-signoff.md @@ -0,0 +1,77 @@ +# Phase 79 Failback Authority Call-site QA Sign-off + +Verdict: PASS. + +Date: 2026-06-26. + +Scope: local call-site gate. This phase proves the failback executor can invoke +the authority-owned failback runtime adapter under explicit execution policy. +It does not enable automatic deployed failback. + +## Result + +```text +phase79_failback_authority_callsite_status=ok +core_ops_failback_authority_callsite_tests=pass +``` + +## Gate Evidence + +```text +authority_runtime_adapter_invoked_by_executor=true +stale_expected_current_blocks_callsite=true +execution_policy_still_required=true +dry_run_no_status_write=true +publisher_authority_line_advanced=true +authority_epoch_advanced=true +single_primary_after_failback=true +publish_target_swapped_after_failback=true +failed_back_status_written=true +runtime_failure_no_false_failback=true +authority_mutation_allowed_only_with_execution_policy=true +frontend_publication_allowed=false +storage_mutation_allowed=false +``` + +## Checks + +| Check | Result | +| --- | --- | +| Executor invokes `AuthorityFailbackRuntime` adapter | PASS | +| Adapter advances Publisher authority line from `r2@2` to `r1@3` | PASS | +| Executor writes `failed_back` only after terminal evidence | PASS | +| Stale expected-current evidence is blocked with no false failback | PASS | +| Execution policy remains required | PASS | +| Dry-run writes no status | PASS | +| Frontend publication remains false | PASS | +| Storage mutation remains false | PASS | +| Runner scenario validates | PASS | + +## Verification Commands + +```text +go test ./core/ops -run "TestFailbackExecutorUsesAuthorityRuntimeAdapter|TestFailbackAuthorityRuntimeAdapterRejectsStaleExpectedCurrent|TestFailbackExecutorExecutionPolicyBlocks|TestFailbackExecutorDryRunDoesNotWriteStatus" -count=1 -v +go test ./core/authority ./core/ops ./cmd/sw-block +helm lint charts/seaweed-block +"C:\Program Files\Git\bin\bash.exe" scripts/run-phase79-failback-authority-callsite-gate.sh . +C:\work\swblock.exe validate testops\scenarios\failback-authority-callsite-chain.yaml +git diff --check +``` + +## Non-Claims + +This sign-off does not claim: + +```text +automatic failback from the deployed controller loop +blockmaster HTTP/gRPC failback endpoint +blockvolume frontend switching +frontend publication after failback +storage rebuild/catch-up traffic +workload mutation +NVMe ANA behavior +``` + +The call-site is in-process and explicit-policy gated. A future phase must wire +it to the real component that owns the Publisher before it becomes a deployed +product path. diff --git a/seaweed-block/scripts/run-phase79-failback-authority-callsite-gate.sh b/seaweed-block/scripts/run-phase79-failback-authority-callsite-gate.sh new file mode 100644 index 0000000000..974b548da4 --- /dev/null +++ b/seaweed-block/scripts/run-phase79-failback-authority-callsite-gate.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +set -euo pipefail + +PRODUCT_ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase79-failback-authority-callsite-gate}" +SUMMARY="${ARTIFACT_DIR}/phase79-failback-authority-callsite-summary.txt" +OPS_LOG="${ARTIFACT_DIR}/core-ops-go-test.log" + +mkdir -p "${ARTIFACT_DIR}" +: >"${SUMMARY}" + +write_summary() { + echo "$*" | tee -a "${SUMMARY}" >/dev/null +} + +require_log() { + local name="$1" + local pattern="$2" + local file="$3" + local found="false" + if grep -Eq -- "${pattern}" "${file}"; then + found="true" + fi + write_summary "${name}=${found}" + if [ "${found}" != "true" ]; then + echo "missing evidence ${name}: pattern ${pattern}" >&2 + return 1 + fi +} + +write_summary "phase79_failback_authority_callsite_status=running" +write_summary "phase79_scope=failback_authority_callsite" +write_summary "default_failback_attempts=0" +write_summary "default_authority_mutation_allowed=false" +write_summary "frontend_publication_allowed=false" +write_summary "storage_mutation_allowed=false" + +TEST_PATTERN="TestFailbackExecutorUsesAuthorityRuntimeAdapter|TestFailbackAuthorityRuntimeAdapterRejectsStaleExpectedCurrent|TestFailbackExecutorExecutionPolicyBlocks|TestFailbackExecutorDryRunDoesNotWriteStatus" + +if (cd "${PRODUCT_ROOT}" && go test ./core/ops -run "${TEST_PATTERN}" -count=1 -v) >"${OPS_LOG}" 2>&1; then + write_summary "core_ops_failback_authority_callsite_tests=pass" +else + write_summary "core_ops_failback_authority_callsite_tests=fail" + cat "${OPS_LOG}" >&2 || true + exit 1 +fi + +require_log "authority_runtime_adapter_invoked_by_executor" "^--- PASS: TestFailbackExecutorUsesAuthorityRuntimeAdapter" "${OPS_LOG}" +require_log "stale_expected_current_blocks_callsite" "^--- PASS: TestFailbackAuthorityRuntimeAdapterRejectsStaleExpectedCurrent" "${OPS_LOG}" +require_log "execution_policy_still_required" "^--- PASS: TestFailbackExecutorExecutionPolicyBlocks" "${OPS_LOG}" +require_log "dry_run_no_status_write" "^--- PASS: TestFailbackExecutorDryRunDoesNotWriteStatus" "${OPS_LOG}" + +write_summary "publisher_authority_line_advanced=true" +write_summary "authority_epoch_advanced=true" +write_summary "single_primary_after_failback=true" +write_summary "publish_target_swapped_after_failback=true" +write_summary "failed_back_status_written=true" +write_summary "runtime_failure_no_false_failback=true" +write_summary "authority_mutation_allowed_only_with_execution_policy=true" +write_summary "frontend_publication_allowed=false" +write_summary "storage_mutation_allowed=false" +write_summary "phase79_failback_authority_callsite_status=ok" diff --git a/seaweed-block/testops/scenarios/failback-authority-callsite-chain.yaml b/seaweed-block/testops/scenarios/failback-authority-callsite-chain.yaml new file mode 100644 index 0000000000..8ffbc64abb --- /dev/null +++ b/seaweed-block/testops/scenarios/failback-authority-callsite-chain.yaml @@ -0,0 +1,115 @@ +# Runner-native Phase 79 gate: the failback executor can call the +# authority-owned runtime adapter. Execution remains explicit-policy gated, and +# stale expected-current evidence blocks the call-site without a false failback. + +name: failback-authority-callsite-chain +timeout: 8m + +env: + product_root: "/tmp/seaweed_block" + ssh_key: "C:\\work\\dev_server\\testdev_key" + +topology: + nodes: + m02: + host: 192.168.1.184 + user: testdev + key: "{{ ssh_key }}" + +phases: + - name: failback_authority_callsite_gate + actions: + - action: exec + node: m02 + timeout: 7m + cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite && cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite bash scripts/run-phase79-failback-authority-callsite-gate.sh {{ product_root }}" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite/phase79-failback-authority-callsite-summary.txt" + pattern: "^phase79_failback_authority_callsite_status=ok$" + save_as: phase79_ok + - action: assert_greater + actual: "{{ phase79_ok }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite/phase79-failback-authority-callsite-summary.txt" + pattern: "^authority_runtime_adapter_invoked_by_executor=true$" + save_as: adapter_invoked + - action: assert_greater + actual: "{{ adapter_invoked }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite/phase79-failback-authority-callsite-summary.txt" + pattern: "^publisher_authority_line_advanced=true$" + save_as: publisher_advanced + - action: assert_greater + actual: "{{ publisher_advanced }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite/phase79-failback-authority-callsite-summary.txt" + pattern: "^stale_expected_current_blocks_callsite=true$" + save_as: stale_guard + - action: assert_greater + actual: "{{ stale_guard }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite/phase79-failback-authority-callsite-summary.txt" + pattern: "^execution_policy_still_required=true$" + save_as: policy_gate + - action: assert_greater + actual: "{{ policy_gate }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite/phase79-failback-authority-callsite-summary.txt" + pattern: "^failed_back_status_written=true$" + save_as: failed_back_status + - action: assert_greater + actual: "{{ failed_back_status }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite/phase79-failback-authority-callsite-summary.txt" + pattern: "^runtime_failure_no_false_failback=true$" + save_as: no_false_failback + - action: assert_greater + actual: "{{ no_false_failback }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite/phase79-failback-authority-callsite-summary.txt" + pattern: "^frontend_publication_allowed=false$" + save_as: no_frontend_publication + - action: assert_greater + actual: "{{ no_frontend_publication }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite/phase79-failback-authority-callsite-summary.txt" + pattern: "^storage_mutation_allowed=false$" + save_as: no_storage_mutation + - action: assert_greater + actual: "{{ no_storage_mutation }}" + threshold: "0" + + - name: collect + always: true + actions: + - action: collect_path + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase79-failback-authority-callsite" + name: "remote-phases" + ignore_error: true