diff --git a/seaweed-block/charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml b/seaweed-block/charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml index 67bd98acd6..7367b198af 100644 --- a/seaweed-block/charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml +++ b/seaweed-block/charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml @@ -259,6 +259,55 @@ spec: type: array items: type: string + executorContracts: + type: array + items: + type: object + required: + - actionType + - decision + - reason + - ownerExecutor + - executionEnabled + - mutationAllowed + properties: + actionType: + type: string + replicaID: + type: string + decision: + type: string + enum: + - blocked + - disabled + reason: + type: string + ownerExecutor: + type: string + executionEnabled: + type: boolean + mutationAllowed: + type: boolean + preflightDecision: + type: string + preflightReason: + type: string + allowedMutationClass: + type: array + items: + type: string + forbiddenMutationClass: + type: array + items: + type: string + terminalEvidenceRequired: + type: array + items: + type: string + evidenceRefs: + type: array + items: + type: string nonClaims: type: array items: diff --git a/seaweed-block/cmd/sw-block/main_test.go b/seaweed-block/cmd/sw-block/main_test.go index 537b8e6335..dffd904cd1 100644 --- a/seaweed-block/cmd/sw-block/main_test.go +++ b/seaweed-block/cmd/sw-block/main_test.go @@ -1167,6 +1167,7 @@ func TestOpsReturnedReplicaFromBundleSurfacesAcrossReportExplainDashboard(t *tes for _, want := range []string{ "managed_volume_returned_replica=pvc-returned replica=r1 state=fenced reason=returned_replica_frontend_fenced", "managed_volume_executor_preflight=authority.reintegrate_returned_replica target=r1 decision=ready reason=preconditions_satisfied mode=dry_run executor=authority_recovery_executor mutation_allowed=false ack_eligibility_known=true required_lsn=4241 durable_lsn=4241", + "managed_volume_executor_contract=authority.reintegrate_returned_replica target=r1 decision=disabled reason=executor_policy_disabled executor=authority_recovery_executor execution_enabled=false mutation_allowed=false allowed_mutation=ack_eligibility terminal_evidence=ack_eligibility_known,ack_eligible_true,frontend_fenced_after_execution,primary_unchanged,durable_frontier_covered,no_cross_volume_identity_change", "managed_volume_action=authority.reintegrate_returned_replica mode=dry_run side_effect=authority_mutating executor=authority_recovery_executor decision=allowed", } { if !strings.Contains(string(summary), want) { @@ -1180,8 +1181,11 @@ func TestOpsReturnedReplicaFromBundleSurfacesAcrossReportExplainDashboard(t *tes for _, want := range []string{ `"replica_reintegrations": [`, `"executor_preflights": [`, + `"executor_contracts": [`, `"state": "fenced"`, `"reason_code": "returned_replica_frontend_fenced"`, + `"reason": "executor_policy_disabled"`, + `"execution_enabled": false`, `"reason": "preconditions_satisfied"`, `"type": "authority.reintegrate_returned_replica"`, } { @@ -1209,6 +1213,13 @@ func TestOpsReturnedReplicaFromBundleSurfacesAcrossReportExplainDashboard(t *tes if len(returned) != 1 || returned[0].ReplicaID != "r1" || returned[0].State != ops.ReturnedReplicaStateFenced { t.Fatalf("CRD returned replicas=%+v", returned) } + contracts := writer.volumes[0].status.ExecutorContracts + if len(contracts) != 1 || + contracts[0].Decision != ops.ReturnedReplicaExecutorContractDisabled || + contracts[0].ExecutionEnabled || + contracts[0].MutationAllowed { + t.Fatalf("CRD executor contracts=%+v", contracts) + } foundReintegrate := false for _, action := range writer.volumes[0].status.AllowedActions { if action.Type == ops.ManagedVolumeActionReintegrateReturned { @@ -1228,6 +1239,7 @@ func TestOpsReturnedReplicaFromBundleSurfacesAcrossReportExplainDashboard(t *tes for _, want := range []string{ "managed_volume_returned_replica=pvc-returned replica=r1 state=fenced reason=returned_replica_frontend_fenced", "managed_volume_executor_preflight authority.reintegrate_returned_replica target=r1 decision=ready reason=preconditions_satisfied mode=dry_run executor=authority_recovery_executor mutation_allowed=false ack_eligibility_known=true required_lsn=4241 durable_lsn=4241", + "managed_volume_executor_contract authority.reintegrate_returned_replica target=r1 decision=disabled reason=executor_policy_disabled executor=authority_recovery_executor execution_enabled=false mutation_allowed=false allowed_mutation=ack_eligibility terminal_evidence=ack_eligibility_known,ack_eligible_true,frontend_fenced_after_execution,primary_unchanged,durable_frontier_covered,no_cross_volume_identity_change", "managed_volume_action authority.reintegrate_returned_replica mode=dry_run", } { if !strings.Contains(stdout.String(), want) { @@ -1251,7 +1263,10 @@ func TestOpsReturnedReplicaFromBundleSurfacesAcrossReportExplainDashboard(t *tes for _, want := range []string{ `"reason_code": "returned_replica_frontend_fenced"`, `"executor_preflights": [`, + `"executor_contracts": [`, `"reason": "preconditions_satisfied"`, + `"reason": "executor_policy_disabled"`, + `"execution_enabled": false`, `"type": "authority.reintegrate_returned_replica"`, } { if !strings.Contains(body, want) { diff --git a/seaweed-block/core/ops/kubernetes_crd_manifests_test.go b/seaweed-block/core/ops/kubernetes_crd_manifests_test.go index 0d34ed1f80..653dc7f40d 100644 --- a/seaweed-block/core/ops/kubernetes_crd_manifests_test.go +++ b/seaweed-block/core/ops/kubernetes_crd_manifests_test.go @@ -240,6 +240,28 @@ func TestPhase50SwBlockVolumeExecutorPreflightSchema(t *testing.T) { } } +func TestPhase52SwBlockVolumeExecutorContractSchema(t *testing.T) { + doc := readYAMLMap(t, "charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml") + statusProperties := crdStatusProperties(t, doc) + contractProperties := yamlMap(t, yamlMap(t, yamlMap(t, statusProperties, "executorContracts"), "items"), "properties") + for _, want := range []string{"actionType", "replicaID", "decision", "reason", "ownerExecutor", "executionEnabled", "mutationAllowed", "preflightDecision", "preflightReason", "allowedMutationClass", "forbiddenMutationClass", "terminalEvidenceRequired", "evidenceRefs"} { + if _, ok := contractProperties[want]; !ok { + t.Fatalf("SwBlockVolume.status.executorContracts[] schema missing %s", want) + } + } + decisionEnum := yamlStringSet(t, yamlMap(t, contractProperties, "decision"), "enum") + for _, want := range []string{ReturnedReplicaExecutorContractBlocked, ReturnedReplicaExecutorContractDisabled} { + if !decisionEnum[want] { + t.Fatalf("SwBlockVolume.status.executorContracts[].decision enum missing %s: %+v", want, decisionEnum) + } + } + for _, forbidden := range []string{"action_type", "owner_executor", "execution_enabled", "mutation_allowed", "preflight_decision", "allowed_mutation_class", "terminal_evidence_required"} { + if _, ok := contractProperties[forbidden]; ok { + t.Fatalf("SwBlockVolume.status.executorContracts[] leaked snake_case %s", forbidden) + } + } +} + func TestOperatorStatusRBACIsStatusEventsOnly(t *testing.T) { raw := readRepoFile(t, "charts/seaweed-block/templates/operator-status-rbac.yaml") required := []string{ diff --git a/seaweed-block/core/ops/kubernetes_status_conformance_test.go b/seaweed-block/core/ops/kubernetes_status_conformance_test.go index 2c69b066b7..e16c19a072 100644 --- a/seaweed-block/core/ops/kubernetes_status_conformance_test.go +++ b/seaweed-block/core/ops/kubernetes_status_conformance_test.go @@ -129,6 +129,21 @@ func TestPhase40D1KubernetesStatusClientConformsToCRDSchemaAndRBAC(t *testing.T) EvidenceRefs: []string{"returned-replica-summary.txt"}, ForbiddenMutationClass: []string{"ack_eligibility"}, }}, + ExecutorContracts: []SwBlockVolumeCRDExecutorContract{{ + ActionType: ManagedVolumeActionReintegrateReturned, + ReplicaID: "r1", + Decision: ReturnedReplicaExecutorContractDisabled, + Reason: ReturnedReplicaExecutorContractReasonExecutorDisabled, + OwnerExecutor: "authority_recovery_executor", + ExecutionEnabled: false, + MutationAllowed: false, + PreflightDecision: ReturnedReplicaExecutorPreflightReady, + PreflightReason: ReturnedReplicaExecutorPreflightReasonSatisfied, + AllowedMutationClass: []string{"ack_eligibility"}, + ForbiddenMutationClass: []string{"frontend_publication", "rebuild_traffic", "failback"}, + TerminalEvidenceRequired: []string{"ack_eligibility_known", "ack_eligible_true", "frontend_fenced_after_execution", "primary_unchanged", "durable_frontier_covered", "no_cross_volume_identity_change"}, + EvidenceRefs: []string{"returned-replica-summary.txt"}, + }}, DeleteSafety: &SwBlockVolumeCRDDeleteSafety{ ActionType: SwBlockVolumeDeleteActionReleaseFinalizer, Decision: ManagedVolumeActionDecisionRejected, diff --git a/seaweed-block/core/ops/kubernetes_status_writer_test.go b/seaweed-block/core/ops/kubernetes_status_writer_test.go index fa95407a43..74c0e3b25f 100644 --- a/seaweed-block/core/ops/kubernetes_status_writer_test.go +++ b/seaweed-block/core/ops/kubernetes_status_writer_test.go @@ -99,6 +99,21 @@ func TestKubernetesStatusClientPatchesOnlyStatusSubresources(t *testing.T) { EvidenceRefs: []string{"returned-replica-summary.txt"}, ForbiddenMutationClass: []string{"ack_eligibility"}, }}, + ExecutorContracts: []SwBlockVolumeCRDExecutorContract{{ + ActionType: ManagedVolumeActionReintegrateReturned, + ReplicaID: "r1", + Decision: ReturnedReplicaExecutorContractDisabled, + Reason: ReturnedReplicaExecutorContractReasonExecutorDisabled, + OwnerExecutor: "authority_recovery_executor", + ExecutionEnabled: false, + MutationAllowed: false, + PreflightDecision: ReturnedReplicaExecutorPreflightReady, + PreflightReason: ReturnedReplicaExecutorPreflightReasonSatisfied, + AllowedMutationClass: []string{"ack_eligibility"}, + ForbiddenMutationClass: []string{"frontend_publication", "rebuild_traffic", "failback"}, + TerminalEvidenceRequired: []string{"ack_eligibility_known", "ack_eligible_true", "frontend_fenced_after_execution", "primary_unchanged", "durable_frontier_covered", "no_cross_volume_identity_change"}, + EvidenceRefs: []string{"returned-replica-summary.txt"}, + }}, AllowedActions: []SwBlockVolumeCRDAction{{ Type: "observe.collect_bundle", Mode: "read_only", @@ -192,6 +207,17 @@ func TestKubernetesStatusClientPatchesOnlyStatusSubresources(t *testing.T) { t.Fatalf("executor preflight leaked snake_case %s: %+v", forbidden, preflight) } } + executorContract := volumeStatus["executorContracts"].([]any)[0].(map[string]any) + for _, want := range []string{"actionType", "replicaID", "ownerExecutor", "executionEnabled", "mutationAllowed", "preflightDecision", "allowedMutationClass", "forbiddenMutationClass", "terminalEvidenceRequired"} { + if _, ok := executorContract[want]; !ok { + t.Fatalf("executor contract missing camelCase %s: %+v", want, executorContract) + } + } + for _, forbidden := range []string{"action_type", "owner_executor", "execution_enabled", "mutation_allowed", "preflight_decision", "allowed_mutation_class", "terminal_evidence_required"} { + if _, ok := executorContract[forbidden]; ok { + t.Fatalf("executor contract leaked snake_case %s: %+v", forbidden, executorContract) + } + } } func TestKubernetesStatusClientCreatesCoreEvents(t *testing.T) { diff --git a/seaweed-block/core/ops/managed_volume_model.go b/seaweed-block/core/ops/managed_volume_model.go index 2c8d5df792..1ff3060642 100644 --- a/seaweed-block/core/ops/managed_volume_model.go +++ b/seaweed-block/core/ops/managed_volume_model.go @@ -334,6 +334,18 @@ func RenderManagedVolumeProjectionText(projection ManagedVolumeProjection) strin preflight.RequiredFrontierLSN, preflight.DurableFrontierLSN) } + for _, contract := range ReturnedReplicaExecutorContracts(projection) { + fmt.Fprintf(&b, "managed_volume_executor_contract %s target=%s decision=%s reason=%s executor=%s execution_enabled=%t mutation_allowed=%t allowed_mutation=%s terminal_evidence=%s\n", + emptyAsDash(contract.ActionType), + emptyAsDash(contract.ReplicaID), + emptyAsDash(contract.Decision), + emptyAsDash(contract.Reason), + emptyAsDash(contract.OwnerExecutor), + contract.ExecutionEnabled, + contract.MutationAllowed, + emptyAsDash(strings.Join(contract.AllowedMutationClass, ",")), + emptyAsDash(strings.Join(contract.TerminalEvidenceRequired, ","))) + } for _, condition := range projection.Conditions { fmt.Fprintf(&b, "managed_volume_condition %s status=%s reason=%s severity=%s", emptyAsDash(condition.Type), diff --git a/seaweed-block/core/ops/managed_volume_operator_contract.go b/seaweed-block/core/ops/managed_volume_operator_contract.go index df275db6d7..0d07065648 100644 --- a/seaweed-block/core/ops/managed_volume_operator_contract.go +++ b/seaweed-block/core/ops/managed_volume_operator_contract.go @@ -17,6 +17,7 @@ type ManagedVolumeOperatorStatus struct { DeleteSafety *SwBlockVolumeDeleteSafetyDecision `json:"delete_safety,omitempty"` ReplicaReintegrations []ReturnedReplicaProjection `json:"replica_reintegrations,omitempty"` ExecutorPreflights []ReturnedReplicaExecutorPreflight `json:"executor_preflights,omitempty"` + ExecutorContracts []ReturnedReplicaExecutorContract `json:"executor_contracts,omitempty"` NonClaims []string `json:"non_claims,omitempty"` EvidenceRefs []string `json:"evidence_refs,omitempty"` } @@ -56,6 +57,7 @@ func ManagedVolumeOperatorContractFromProjection(projection ManagedVolumeProject DeleteSafety: cloneSwBlockVolumeDeleteSafetyDecision(projection.DeleteSafety), ReplicaReintegrations: cloneReturnedReplicaProjections(projection.ReplicaReintegrations), ExecutorPreflights: cloneReturnedReplicaExecutorPreflights(ReturnedReplicaExecutorPreflights(projection)), + ExecutorContracts: cloneReturnedReplicaExecutorContracts(ReturnedReplicaExecutorContracts(projection)), NonClaims: append([]string(nil), projection.NonClaims...), EvidenceRefs: append([]string(nil), projection.EvidenceRefs...), }, @@ -97,6 +99,20 @@ func cloneReturnedReplicaExecutorPreflights(in []ReturnedReplicaExecutorPrefligh return out } +func cloneReturnedReplicaExecutorContracts(in []ReturnedReplicaExecutorContract) []ReturnedReplicaExecutorContract { + if len(in) == 0 { + return nil + } + out := append([]ReturnedReplicaExecutorContract(nil), in...) + for i := range out { + out[i].AllowedMutationClass = append([]string(nil), in[i].AllowedMutationClass...) + out[i].ForbiddenMutationClass = append([]string(nil), in[i].ForbiddenMutationClass...) + out[i].TerminalEvidenceRequired = append([]string(nil), in[i].TerminalEvidenceRequired...) + out[i].EvidenceRefs = append([]string(nil), in[i].EvidenceRefs...) + } + return out +} + func cloneReturnedReplicaProjections(in []ReturnedReplicaProjection) []ReturnedReplicaProjection { if len(in) == 0 { return nil diff --git a/seaweed-block/core/ops/managed_volume_operator_contract_test.go b/seaweed-block/core/ops/managed_volume_operator_contract_test.go index c92a47eef1..b9317cf93d 100644 --- a/seaweed-block/core/ops/managed_volume_operator_contract_test.go +++ b/seaweed-block/core/ops/managed_volume_operator_contract_test.go @@ -128,4 +128,14 @@ func TestManagedVolumeOperatorContract_ReturnedReplicaProjection(t *testing.T) { preflight.MutationAllowed { t.Fatalf("executor preflight=%+v", preflight) } + if len(contract.Status.ExecutorContracts) != 1 { + t.Fatalf("executor contracts=%+v", contract.Status.ExecutorContracts) + } + executorContract := contract.Status.ExecutorContracts[0] + if executorContract.Decision != ReturnedReplicaExecutorContractDisabled || + executorContract.Reason != ReturnedReplicaExecutorContractReasonExecutorDisabled || + executorContract.ExecutionEnabled || + executorContract.MutationAllowed { + t.Fatalf("executor contract=%+v", executorContract) + } } diff --git a/seaweed-block/core/ops/observation_report.go b/seaweed-block/core/ops/observation_report.go index 90825c5548..d5d5eb3504 100644 --- a/seaweed-block/core/ops/observation_report.go +++ b/seaweed-block/core/ops/observation_report.go @@ -186,6 +186,18 @@ func renderManagedProjectionSummary(b *strings.Builder, managed ManagedVolumePro preflight.RequiredFrontierLSN, preflight.DurableFrontierLSN) } + for _, contract := range ReturnedReplicaExecutorContracts(managed) { + fmt.Fprintf(b, "managed_volume_executor_contract=%s target=%s decision=%s reason=%s executor=%s execution_enabled=%t mutation_allowed=%t allowed_mutation=%s terminal_evidence=%s\n", + emptyAsDash(contract.ActionType), + emptyAsDash(contract.ReplicaID), + emptyAsDash(contract.Decision), + emptyAsDash(contract.Reason), + emptyAsDash(contract.OwnerExecutor), + contract.ExecutionEnabled, + contract.MutationAllowed, + emptyAsDash(strings.Join(contract.AllowedMutationClass, ",")), + emptyAsDash(strings.Join(contract.TerminalEvidenceRequired, ","))) + } for _, action := range managed.Actions { fmt.Fprintf(b, "managed_volume_action=%s mode=%s side_effect=%s executor=%s decision=%s", emptyAsDash(action.Type), diff --git a/seaweed-block/core/ops/observation_report_test.go b/seaweed-block/core/ops/observation_report_test.go index 37d71a635c..3f448c1d0a 100644 --- a/seaweed-block/core/ops/observation_report_test.go +++ b/seaweed-block/core/ops/observation_report_test.go @@ -121,6 +121,7 @@ func TestObservationReportSummary_IncludesReturnedReplicaProjection(t *testing.T "managed_volume_returned_replica=pvc-returned replica=r1 state=fenced reason=returned_replica_frontend_fenced", "frontend_fenced=true ack_eligibility_known=true ack_eligible=false durable_frontier_known=true durable_lsn=52", "managed_volume_executor_preflight=authority.reintegrate_returned_replica target=r1 decision=ready reason=preconditions_satisfied mode=dry_run executor=authority_recovery_executor mutation_allowed=false ack_eligibility_known=true required_lsn=52 durable_lsn=52", + "managed_volume_executor_contract=authority.reintegrate_returned_replica target=r1 decision=disabled reason=executor_policy_disabled executor=authority_recovery_executor execution_enabled=false mutation_allowed=false allowed_mutation=ack_eligibility terminal_evidence=ack_eligibility_known,ack_eligible_true,frontend_fenced_after_execution,primary_unchanged,durable_frontier_covered,no_cross_volume_identity_change", "managed_volume_action=authority.reintegrate_returned_replica mode=dry_run side_effect=authority_mutating executor=authority_recovery_executor decision=allowed", } { if !strings.Contains(summary, want) { diff --git a/seaweed-block/core/ops/operator_status_controller.go b/seaweed-block/core/ops/operator_status_controller.go index 794f7e0ec4..a251f58719 100644 --- a/seaweed-block/core/ops/operator_status_controller.go +++ b/seaweed-block/core/ops/operator_status_controller.go @@ -272,6 +272,7 @@ type SwBlockVolumeCRDStatus struct { DeleteSafety *SwBlockVolumeCRDDeleteSafety `json:"deleteSafety"` ReplicaReintegrations []SwBlockVolumeCRDReturnedReplica `json:"replicaReintegrations,omitempty"` ExecutorPreflights []SwBlockVolumeCRDExecutorPreflight `json:"executorPreflights,omitempty"` + ExecutorContracts []SwBlockVolumeCRDExecutorContract `json:"executorContracts,omitempty"` NonClaims []string `json:"nonClaims,omitempty"` EvidenceRefs []string `json:"evidenceRefs,omitempty"` AllowedActions []SwBlockVolumeCRDAction `json:"allowedActions,omitempty"` @@ -313,6 +314,22 @@ type SwBlockVolumeCRDExecutorPreflight struct { ForbiddenMutationClass []string `json:"forbiddenMutationClass,omitempty"` } +type SwBlockVolumeCRDExecutorContract struct { + ActionType string `json:"actionType"` + ReplicaID string `json:"replicaID,omitempty"` + Decision string `json:"decision"` + Reason string `json:"reason"` + OwnerExecutor string `json:"ownerExecutor"` + ExecutionEnabled bool `json:"executionEnabled"` + MutationAllowed bool `json:"mutationAllowed"` + PreflightDecision string `json:"preflightDecision,omitempty"` + PreflightReason string `json:"preflightReason,omitempty"` + AllowedMutationClass []string `json:"allowedMutationClass,omitempty"` + ForbiddenMutationClass []string `json:"forbiddenMutationClass,omitempty"` + TerminalEvidenceRequired []string `json:"terminalEvidenceRequired,omitempty"` + EvidenceRefs []string `json:"evidenceRefs,omitempty"` +} + type SwBlockVolumeCRDDeleteSafety struct { ActionType string `json:"actionType,omitempty"` Decision string `json:"decision,omitempty"` @@ -440,6 +457,7 @@ func (r OperatorStatusReconciler) Reconcile(ctx context.Context) (OperatorStatus DeleteSafety: swBlockVolumeCRDDeleteSafety(volume.Status.DeleteSafety), ReplicaReintegrations: swBlockVolumeCRDReturnedReplicas(volume.Status.ReplicaReintegrations), ExecutorPreflights: swBlockVolumeCRDExecutorPreflights(volume.Status.ExecutorPreflights), + ExecutorContracts: swBlockVolumeCRDExecutorContracts(volume.Status.ExecutorContracts), NonClaims: append([]string(nil), volume.Status.NonClaims...), EvidenceRefs: append([]string(nil), volume.Status.EvidenceRefs...), AllowedActions: swBlockVolumeCRDActions(volume.AllowedActions), @@ -543,6 +561,31 @@ func swBlockVolumeCRDExecutorPreflights(preflights []ReturnedReplicaExecutorPref return out } +func swBlockVolumeCRDExecutorContracts(contracts []ReturnedReplicaExecutorContract) []SwBlockVolumeCRDExecutorContract { + if len(contracts) == 0 { + return nil + } + out := make([]SwBlockVolumeCRDExecutorContract, 0, len(contracts)) + for _, contract := range contracts { + out = append(out, SwBlockVolumeCRDExecutorContract{ + ActionType: contract.ActionType, + ReplicaID: contract.ReplicaID, + Decision: contract.Decision, + Reason: contract.Reason, + OwnerExecutor: contract.OwnerExecutor, + ExecutionEnabled: contract.ExecutionEnabled, + MutationAllowed: contract.MutationAllowed, + PreflightDecision: contract.PreflightDecision, + PreflightReason: contract.PreflightReason, + AllowedMutationClass: append([]string(nil), contract.AllowedMutationClass...), + ForbiddenMutationClass: append([]string(nil), contract.ForbiddenMutationClass...), + TerminalEvidenceRequired: append([]string(nil), contract.TerminalEvidenceRequired...), + EvidenceRefs: append([]string(nil), contract.EvidenceRefs...), + }) + } + return out +} + func swBlockVolumeCRDDeleteSafety(decision *SwBlockVolumeDeleteSafetyDecision) *SwBlockVolumeCRDDeleteSafety { if decision == nil { return nil diff --git a/seaweed-block/core/ops/operator_status_controller_test.go b/seaweed-block/core/ops/operator_status_controller_test.go index 65417984a8..54a5283200 100644 --- a/seaweed-block/core/ops/operator_status_controller_test.go +++ b/seaweed-block/core/ops/operator_status_controller_test.go @@ -192,16 +192,29 @@ func TestOperatorStatusReconcilerWritesReturnedReplicaExecutorPreflight(t *testi preflight.MutationAllowed { t.Fatalf("executor preflight=%+v", preflight) } + if len(status.ExecutorContracts) != 1 { + t.Fatalf("executor contracts=%+v", status.ExecutorContracts) + } + contract := status.ExecutorContracts[0] + if contract.ActionType != ManagedVolumeActionReintegrateReturned || + contract.Decision != ReturnedReplicaExecutorContractDisabled || + contract.Reason != ReturnedReplicaExecutorContractReasonExecutorDisabled || + contract.ExecutionEnabled || + contract.MutationAllowed || + !containsActionFact(contract.AllowedMutationClass, "ack_eligibility") || + !containsActionFact(contract.TerminalEvidenceRequired, "frontend_fenced_after_execution") { + t.Fatalf("executor contract=%+v", contract) + } raw, err := json.Marshal(status) if err != nil { t.Fatalf("marshal status: %v", err) } - for _, want := range []string{`"executorPreflights"`, `"actionType"`, `"mutationAllowed"`, `"durableFrontierLsn"`, `"forbiddenMutationClass"`} { + for _, want := range []string{`"executorPreflights"`, `"executorContracts"`, `"actionType"`, `"mutationAllowed"`, `"executionEnabled"`, `"durableFrontierLsn"`, `"forbiddenMutationClass"`, `"terminalEvidenceRequired"`} { if !strings.Contains(string(raw), want) { t.Fatalf("CRD status missing %s: %s", want, string(raw)) } } - for _, forbidden := range []string{"executor_preflights", "action_type", "mutation_allowed", "durable_frontier_lsn"} { + for _, forbidden := range []string{"executor_preflights", "executor_contracts", "action_type", "mutation_allowed", "execution_enabled", "durable_frontier_lsn", "terminal_evidence_required"} { if strings.Contains(string(raw), forbidden) { t.Fatalf("CRD status leaked snake_case %s: %s", forbidden, string(raw)) } diff --git a/seaweed-block/core/ops/returned_replica_executor_contract.go b/seaweed-block/core/ops/returned_replica_executor_contract.go new file mode 100644 index 0000000000..1ece492ea7 --- /dev/null +++ b/seaweed-block/core/ops/returned_replica_executor_contract.go @@ -0,0 +1,73 @@ +package ops + +const ( + ReturnedReplicaExecutorContractBlocked = "blocked" + ReturnedReplicaExecutorContractDisabled = "disabled" + + ReturnedReplicaExecutorContractReasonPreflightNotReady = "preflight_not_ready" + ReturnedReplicaExecutorContractReasonExecutorDisabled = "executor_policy_disabled" +) + +// ReturnedReplicaExecutorContract is the still-non-mutating execution boundary +// for returned-replica reintegration. It names the future mutation envelope and +// terminal evidence while keeping execution disabled in the current product. +type ReturnedReplicaExecutorContract struct { + ActionType string `json:"action_type"` + VolumeID string `json:"volume_id,omitempty"` + ReplicaID string `json:"replica_id,omitempty"` + Decision string `json:"decision"` + Reason string `json:"reason"` + OwnerExecutor string `json:"owner_executor"` + ExecutionEnabled bool `json:"execution_enabled"` + MutationAllowed bool `json:"mutation_allowed"` + PreflightDecision string `json:"preflight_decision,omitempty"` + PreflightReason string `json:"preflight_reason,omitempty"` + AllowedMutationClass []string `json:"allowed_mutation_class,omitempty"` + ForbiddenMutationClass []string `json:"forbidden_mutation_class,omitempty"` + TerminalEvidenceRequired []string `json:"terminal_evidence_required,omitempty"` + EvidenceRefs []string `json:"evidence_refs,omitempty"` +} + +func ReturnedReplicaExecutorContracts(projection ManagedVolumeProjection) []ReturnedReplicaExecutorContract { + preflights := ReturnedReplicaExecutorPreflights(projection) + if len(preflights) == 0 { + return nil + } + out := make([]ReturnedReplicaExecutorContract, 0, len(preflights)) + for _, preflight := range preflights { + contract := ReturnedReplicaExecutorContract{ + ActionType: preflight.ActionType, + VolumeID: preflight.VolumeID, + ReplicaID: preflight.ReplicaID, + Decision: ReturnedReplicaExecutorContractBlocked, + Reason: ReturnedReplicaExecutorContractReasonPreflightNotReady, + OwnerExecutor: preflight.OwnerExecutor, + ExecutionEnabled: false, + MutationAllowed: false, + PreflightDecision: preflight.Decision, + PreflightReason: preflight.Reason, + ForbiddenMutationClass: append([]string(nil), preflight.ForbiddenMutationClass...), + TerminalEvidenceRequired: returnedReplicaTerminalEvidenceRequired(), + EvidenceRefs: append([]string(nil), preflight.EvidenceRefs...), + } + if preflight.Decision == ReturnedReplicaExecutorPreflightReady { + contract.Decision = ReturnedReplicaExecutorContractDisabled + contract.Reason = ReturnedReplicaExecutorContractReasonExecutorDisabled + contract.AllowedMutationClass = []string{"ack_eligibility"} + contract.ForbiddenMutationClass = []string{"frontend_publication", "rebuild_traffic", "failback"} + } + out = append(out, contract) + } + return out +} + +func returnedReplicaTerminalEvidenceRequired() []string { + return []string{ + "ack_eligibility_known", + "ack_eligible_true", + "frontend_fenced_after_execution", + "primary_unchanged", + "durable_frontier_covered", + "no_cross_volume_identity_change", + } +} diff --git a/seaweed-block/core/ops/returned_replica_executor_contract_test.go b/seaweed-block/core/ops/returned_replica_executor_contract_test.go new file mode 100644 index 0000000000..fcdbb92d7e --- /dev/null +++ b/seaweed-block/core/ops/returned_replica_executor_contract_test.go @@ -0,0 +1,69 @@ +package ops + +import "testing" + +func TestReturnedReplicaExecutorContract_DisabledWhenPreflightReady(t *testing.T) { + projection := returnedReplicaPreflightProjection(t, func(*ManagedVolumeFacts) {}) + + contract := onlyReturnedReplicaExecutorContract(t, projection) + if contract.Decision != ReturnedReplicaExecutorContractDisabled || + contract.Reason != ReturnedReplicaExecutorContractReasonExecutorDisabled || + contract.ExecutionEnabled || + contract.MutationAllowed { + t.Fatalf("executor contract=%+v", contract) + } + if contract.PreflightDecision != ReturnedReplicaExecutorPreflightReady || + contract.PreflightReason != ReturnedReplicaExecutorPreflightReasonSatisfied { + t.Fatalf("preflight handoff=%+v", contract) + } + if !containsActionFact(contract.AllowedMutationClass, "ack_eligibility") { + t.Fatalf("allowed mutation classes=%+v", contract.AllowedMutationClass) + } + for _, want := range []string{"frontend_publication", "rebuild_traffic", "failback"} { + if !containsActionFact(contract.ForbiddenMutationClass, want) { + t.Fatalf("forbidden mutation classes missing %s: %+v", want, contract.ForbiddenMutationClass) + } + } + for _, want := range []string{ + "ack_eligibility_known", + "ack_eligible_true", + "frontend_fenced_after_execution", + "primary_unchanged", + "durable_frontier_covered", + "no_cross_volume_identity_change", + } { + if !containsActionFact(contract.TerminalEvidenceRequired, want) { + t.Fatalf("terminal evidence missing %s: %+v", want, contract.TerminalEvidenceRequired) + } + } +} + +func TestReturnedReplicaExecutorContract_BlockedWhenPreflightHolds(t *testing.T) { + projection := returnedReplicaPreflightProjection(t, func(facts *ManagedVolumeFacts) { + facts.Replicas[0].AckEligibilityKnown = false + }) + + contract := onlyReturnedReplicaExecutorContract(t, projection) + if contract.Decision != ReturnedReplicaExecutorContractBlocked || + contract.Reason != ReturnedReplicaExecutorContractReasonPreflightNotReady || + contract.PreflightReason != ReturnedReplicaExecutorPreflightReasonAckEligibilityUnknown || + contract.ExecutionEnabled || + contract.MutationAllowed { + t.Fatalf("executor contract=%+v", contract) + } + if len(contract.AllowedMutationClass) != 0 { + t.Fatalf("blocked contract must not allow mutation classes: %+v", contract.AllowedMutationClass) + } + if !containsActionFact(contract.ForbiddenMutationClass, "ack_eligibility") { + t.Fatalf("blocked contract should carry preflight forbidden facts: %+v", contract.ForbiddenMutationClass) + } +} + +func onlyReturnedReplicaExecutorContract(t *testing.T, projection ManagedVolumeProjection) ReturnedReplicaExecutorContract { + t.Helper() + contracts := ReturnedReplicaExecutorContracts(projection) + if len(contracts) != 1 { + t.Fatalf("executor contracts=%+v", contracts) + } + return contracts[0] +} diff --git a/seaweed-block/docs/roadmap.md b/seaweed-block/docs/roadmap.md index 30b90f35df..66075ca518 100644 --- a/seaweed-block/docs/roadmap.md +++ b/seaweed-block/docs/roadmap.md @@ -163,7 +163,14 @@ Recommended order from here: missing ACK evidence. A future executor may not treat default `ack_eligible=false` as proof; preflight readiness requires `ack_eligibility_known=true` and `ack_eligible=false`. -9. Add backup/restore and NVMe ANA parity after they can reuse the same action +9. Phase 52: returned-replica executor contract. **Closed 2026-06-21, QA PASS** + (`internal/docs/finished-plans/phase52_finishedplan_returned_replica_executor_contract.md`). + The future executor boundary is published as a non-mutating contract: + execution remains disabled, only ACK eligibility is named as the future + allowed mutation class, frontend publication/rebuild traffic/failback remain + forbidden, and terminal evidence is required before any later executor can + claim completion. +10. 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. @@ -172,8 +179,8 @@ The internal release-train contract is the operation-layer loop for a bounded `SwBlockVolume` protection finalizer. Phase 46 reused this same fact -> judgment -> action -> evidence pattern for returned-replica reintegration before any larger storage feature is enabled. -Phases 47-51 closed the executor-admission, preflight, status-schema, and ACK -evidence bridge without allowing mutation. +Phases 47-52 close the executor-admission, preflight, status-schema, ACK +evidence, and executor-contract bridge without allowing mutation. The practical rule is: diff --git a/seaweed-block/docs/wiki/deep-dives/returned-replica-rebuild.md b/seaweed-block/docs/wiki/deep-dives/returned-replica-rebuild.md index 3fd1c010bf..8086f32ad9 100644 --- a/seaweed-block/docs/wiki/deep-dives/returned-replica-rebuild.md +++ b/seaweed-block/docs/wiki/deep-dives/returned-replica-rebuild.md @@ -116,8 +116,9 @@ stateDiagram-v2 ## Executor Preflight Boundary -The current product exposes a dry-run returned-replica reintegration action and -an executor preflight. The distinction matters: +The current product exposes a dry-run returned-replica reintegration action, an +executor preflight, and a still-disabled executor contract. The distinction +matters: ```text dry-run action visible @@ -125,6 +126,9 @@ dry-run action visible executor preflight ready means: a future bounded executor has enough typed evidence to consider work + +executor contract disabled + means: the future executor boundary is named, but execution is still off ``` Phase 51 added an explicit ACK eligibility gate to avoid a common control-plane @@ -153,6 +157,30 @@ This is still not rebuild execution. It is a machine-readable contract that a future executor can consume without parsing report text or inferring safety from absence. +Phase 52 adds the next non-mutating boundary: + +```text +executor_contracts[].decision=disabled +execution_enabled=false +mutation_allowed=false +allowed_mutation_class=ack_eligibility +forbidden_mutation_class=frontend_publication,rebuild_traffic,failback +``` + +The terminal evidence required by that contract is: + +```text +ack_eligibility_known +ack_eligible_true +frontend_fenced_after_execution +primary_unchanged +durable_frontier_covered +no_cross_volume_identity_change +``` + +This prevents the next implementation from silently turning "mark replica +eligible for ACKs" into a broad rebuild, failback, or frontend-publication path. + ## QA Gate Shape Needed A real returned-replica gate should prove: @@ -174,6 +202,8 @@ cleanup verifier remains clean - No automated returned-replica rebuild is currently claimed. - No failback policy is claimed. - No backup/restore is implied. +- The executor contract is visible, but `execution_enabled=false` and + `mutation_allowed=false`. - No broad HA production claim follows from lower-level recovery code alone. ## Why This Is Next After Operation Layer diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index 97d4adb0ff..d6ab2ea8d9 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,136 +1,126 @@ -# Current Plan: Phase 51 Returned-Replica ACK Evidence Gate +# Current Plan: Phase 52 Returned-Replica Executor Contract -Status: complete; local validation PASS; live gate PASS. +Status: complete. Finished record: +`internal/docs/finished-plans/phase52_finishedplan_returned_replica_executor_contract.md`. -Working branch: `phase51-returned-replica-ack-evidence-gate` +Branch: `phase52-returned-replica-executor-contract` -Decision note: Phase 51 keeps returned-replica reintegration non-mutating. It -tightens the executor preflight so a missing ACK-eligibility fact is not treated -as `ack_eligible=false`. +Decision note: Phase 52 still does not execute returned-replica reintegration, +rebuild, failback, frontend publication, or storage traffic. It adds the +machine-readable contract for the future executor boundary so the product can +say exactly what would be allowed, what remains forbidden, and what terminal +evidence must exist before any later mutating executor is enabled. -Previous product phase: Phase 50 is closed in -`internal/docs/finished-plans/phase50_finishedplan_returned_replica_preflight_status_schema.md`. +## Why This Phase Exists -## Product Goal +Phases 46-51 made returned-replica state visible and progressively safer: -Prevent the next executor phase from confusing "no evidence of ACK eligibility" -with "known not ACK eligible": +- Phase 46 exposed returned-replica facts and dry-run actions. +- Phase 47 admitted the dry-run reintegration action only with fenced/frontier + evidence. +- Phase 48 connected the live iSCSI returned-replica scenario to the same + managed-volume evidence path. +- Phase 49 added a typed executor preflight. +- Phase 50 published that preflight into SwBlockVolume status. +- Phase 51 required explicit ACK eligibility evidence rather than treating a + default false as proof. -```text -returned replica observed --> frontend fenced --> durable frontier covers required frontier --> ACK eligibility explicitly known false --> executor preflight may be ready -``` +The remaining gap before a real executor is not code that mutates state. The +gap is a contract: which mutation class would a future executor own, which +mutation classes are still forbidden, and which terminal evidence proves it did +not accidentally publish an old frontend, change primary authority, or mix +volume identity. -If ACK eligibility is unknown, the human-facing dry-run action can still be -shown, but the executor preflight must hold with a stable reason: +## Scope -```text -returned_replica_ack_eligibility_unknown -``` +In scope: -## Why This Is Next +- Add a returned-replica executor contract derived from the existing preflight. +- Publish the contract in: + - report summary + - explain text + - operator-snapshot JSON + - dashboard JSON + - SwBlockVolume `.status.executorContracts[]` +- Keep `executionEnabled=false` and `mutationAllowed=false`. +- Name the only future allowed mutation class as `ack_eligibility`. +- Keep these mutation classes explicitly forbidden: + - `frontend_publication` + - `rebuild_traffic` + - `failback` +- Require terminal evidence: + - `ack_eligibility_known` + - `ack_eligible_true` + - `frontend_fenced_after_execution` + - `primary_unchanged` + - `durable_frontier_covered` + - `no_cross_volume_identity_change` +- Extend the live returned-replica CRD/RBAC gate so the contract validates + against the real Kubernetes status subresource schema. -Phases 46-50 made returned-replica state, action, preflight, and CRD status -visible. While reviewing the next mutating executor step, one gap remained: -`ack_eligible=false` was projected from absence, not from a live ACK-admission -fact. That is safe for a read-only status surface, but not enough for an -executor handoff. +Out of scope: -Phase 51 closes that semantic gap before adding any mutation. - -## Scope Contract - -| In | Out | -|---|---| -| `ack_eligibility_known` model field | ACK eligibility mutation | -| executor preflight holds on unknown ACK evidence | frontend publication | -| CRD/operator-snapshot/report expose the known bit | rebuild traffic | -| schema and writer tests | automatic failback | -| live status/RBAC gate payload update | lifecycle-owner/RBAC expansion | - -## D1: Model Gate - -Goal: make ACK eligibility evidence explicit in returned-replica facts and -projection. - -Acceptance: - -```text -[x] ReplicaFact carries ack_eligibility_known and ack_eligible -[x] ReturnedReplicaProjection carries ack_eligibility_known -[x] missing ACK evidence does not become a known false value -``` - -## D2: Executor Preflight Gate - -Goal: require explicit ACK non-eligibility before preflight `ready`. - -Acceptance: - -```text -[x] known false ACK eligibility can produce ready -[x] unknown ACK eligibility produces hold -[x] hold reason is returned_replica_ack_eligibility_unknown -[x] existing dry-run action remains visible and non-mutating -``` - -## D3: Status / Schema Contract - -Goal: carry ACK evidence through every machine-readable status surface. - -Acceptance: - -```text -[x] report/explain text includes ack_eligibility_known -[x] operator-snapshot uses ack_eligibility_known -[x] SwBlockVolume.status uses ackEligibilityKnown -[x] CRD schema requires camelCase ackEligibilityKnown -[x] snake_case ack_eligibility_known remains rejected in CRD payloads -``` - -Finished plan: -`internal/docs/finished-plans/phase51_finishedplan_returned_replica_ack_evidence_gate.md`. - -## D4: Validation - -Required before close: - -```text -[x] go test -count=1 ./core/ops -[x] go test -count=1 ./cmd/sw-block -[x] bash -n scripts/run-phase47-returned-replica-status-schema-rbac-gate.sh -[x] swblock validate testops/scenarios/returned-replica-status-schema-rbac-chain.yaml -[x] swblock run testops/scenarios/returned-replica-status-schema-rbac-chain.yaml - run: 20260621-003502-a3ce, 18/18 PASS -``` - -## QA Assignment - -QA/live validation re-ran the returned-replica status schema/RBAC chain and -verified: - -```text -valid status payload includes ackEligibilityKnown=true -missing/snake_case ack_eligibility_known is rejected by the CRD schema -executorPreflights[].decision remains ready only for known ACK non-eligible evidence -operator-status RBAC remains status/events-only -server_dry_run_status_mutated=false -``` - -## Non-Claims - -- No ACK eligibility mutation. +- No returned-replica rebuild execution. +- No automatic reintegration or failback. - No frontend publication. -- No rebuild traffic. -- No automatic failback. -- No lifecycle-owner/operator-status RBAC expansion. -- No release-image claim. +- No authority mutation. +- No storage write or rebuild traffic. +- No RBAC expansion beyond existing status/events. -## Next Phase Candidate +## Success Criteria -Only after Phase 51 is validated should the project design the real returned -replica executor boundary: exact mutation set, admission/RBAC, terminal -evidence, failure handling, and multi-volume isolation. +1. A ready preflight creates exactly one executor contract with: + - `decision=disabled` + - `reason=executor_policy_disabled` + - `execution_enabled=false` + - `mutation_allowed=false` + - `allowed_mutation=ack_eligibility` + - terminal evidence listed above + +2. A held preflight creates a blocked executor contract with: + - `decision=blocked` + - `reason=preflight_not_ready` + - copied preflight reason + - no allowed mutation class + - copied forbidden mutation class + +3. SwBlockVolume CRD status uses camelCase: + - `executorContracts` + - `executionEnabled` + - `allowedMutationClass` + - `terminalEvidenceRequired` + +4. The live server-dry-run gate accepts the valid `executorContracts[]` + payload and rejects snake-case drift. + +5. Existing non-claims stay true: + - no executor command + - no lifecycle-owner involvement + - no finalizer/spec/storage/workload mutation + - no broad rebuild/failback claim + +## Validation + +Run before close: + +```text +go test -count=1 ./core/ops ./cmd/sw-block +bash -n scripts/run-phase47-returned-replica-status-schema-rbac-gate.sh +swblock validate testops/scenarios/returned-replica-status-schema-rbac-chain.yaml +swblock run testops/scenarios/returned-replica-status-schema-rbac-chain.yaml +``` + +The live run must show: + +```text +valid_executor_contract_status_server_dry_run=true +executor_contract_execution_disabled_projected=true +executor_contract_terminal_evidence_projected=true +``` + +## Expected Close + +Close Phase 52 only if the executor contract is visible and schema-valid while +execution remains disabled. The next phase may decide whether to start an +executor implementation, but it must reuse this contract rather than inventing +a separate mutation path. diff --git a/seaweed-block/internal/docs/finished-plans/phase52_finishedplan_returned_replica_executor_contract.md b/seaweed-block/internal/docs/finished-plans/phase52_finishedplan_returned_replica_executor_contract.md new file mode 100644 index 0000000000..6766500ef2 --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase52_finishedplan_returned_replica_executor_contract.md @@ -0,0 +1,95 @@ +# Phase 52 Finished Plan: Returned-Replica Executor Contract + +Status: complete. + +Branch: `phase52-returned-replica-executor-contract` + +## Summary + +Phase 52 publishes the future returned-replica executor boundary as a +machine-readable, non-mutating contract. + +The phase does not execute returned-replica reintegration. It names what the +future executor is allowed to own, what remains forbidden, and what terminal +evidence must exist before any later phase can enable mutation. + +## What Changed + +- Added `ReturnedReplicaExecutorContract`. +- Derived executor contracts from the existing returned-replica executor + preflight. +- Published the contract through: + - report summary, + - explain text, + - operator-snapshot/dashboard JSON, + - SwBlockVolume `.status.executorContracts[]`. +- Added the SwBlockVolume OpenAPI schema for `executorContracts[]` using + camelCase fields. +- Extended the live returned-replica status/RBAC gate so Kubernetes + server-side dry-run accepts the valid contract and rejects schema drift. +- Kept `executionEnabled=false` and `mutationAllowed=false`. + +## Closed Acceptance + +```text +ready preflight -> executor contract decision=disabled +held preflight -> executor contract decision=blocked +execution_enabled=false +mutation_allowed=false +allowed mutation class is ack_eligibility only +frontend_publication/rebuild_traffic/failback remain forbidden +terminal evidence is projected +SwBlockVolume.status.executorContracts[] validates against real CRD schema +snake_case drift is rejected +operator-status RBAC remains status/events-only +``` + +## Validation + +```text +go test -count=1 ./core/ops ./cmd/sw-block +bash -n scripts/run-phase47-returned-replica-status-schema-rbac-gate.sh +swblock validate testops/scenarios/returned-replica-status-schema-rbac-chain.yaml +swblock run testops/scenarios/returned-replica-status-schema-rbac-chain.yaml +``` + +All passed. Live run: + +```text +run: 20260621-171227-5362 +actions: 24/24 PASS +``` + +Key live summary: + +```text +valid_returned_replica_status_server_dry_run=true +valid_executor_preflight_status_server_dry_run=true +executor_preflight_ack_eligibility_known_projected=true +executor_preflight_forbidden_mutation_class_projected=true +valid_executor_contract_status_server_dry_run=true +executor_contract_execution_disabled_projected=true +executor_contract_terminal_evidence_projected=true +snake_case_action_rejected=true +unsupported_action_mode_rejected=true +main_object_patch_rejected=true +server_dry_run_status_mutated=false +phase47_returned_replica_status_schema_rbac_status=ok +``` + +## Non-Claims + +- No returned-replica rebuild execution. +- No automatic reintegration or failback. +- No frontend publication. +- No authority mutation. +- No storage write or rebuild traffic. +- No lifecycle-owner/operator-status RBAC expansion. +- No release-image claim. + +## Next Step + +The next returned-replica phase may decide whether to implement an executor, +but it must reuse this contract. A mutating implementation must prove +admission/RBAC confinement, terminal evidence, failure handling, and +multi-volume isolation before any execution is enabled. diff --git a/seaweed-block/internal/docs/product-roadmap.md b/seaweed-block/internal/docs/product-roadmap.md index d7160acf51..ca740d11ca 100644 --- a/seaweed-block/internal/docs/product-roadmap.md +++ b/seaweed-block/internal/docs/product-roadmap.md @@ -191,9 +191,12 @@ rebuild, delete safety, or cleanup must start as a separate gated phase. documented mechanism, and support-bundle proof of fencing and data integrity. - Current returned-replica status: observed returned replicas are productized through the ManagedVolume surface. A dry-run reintegration action and - executor preflight can become ready only with fencing and frontier evidence, - and that preflight is now available through machine-readable status. The - actual authority/storage mutation is still deferred. + executor preflight can become ready only with fencing, frontier, and explicit + ACK eligibility evidence, and that preflight is now available through + machine-readable status. Phase 52 adds a still-disabled executor contract: + only ACK eligibility is named as the future allowed mutation class, while + frontend publication, rebuild traffic, and failback stay forbidden. The actual + authority/storage mutation is still deferred. - Later: returned-replica rebuild/reintegration/failback execution, NVMe ANA Kubernetes multipath parity, stronger committed-frontier reporting, broad distro/host compatibility, and longer soak under failure. NVMe ANA parity diff --git a/seaweed-block/internal/docs/qa-assignments/phase52-returned-replica-executor-contract-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase52-returned-replica-executor-contract-qa-signoff.md new file mode 100644 index 0000000000..943f978ef9 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase52-returned-replica-executor-contract-qa-signoff.md @@ -0,0 +1,76 @@ +# Phase 52 Returned-Replica Executor Contract QA Sign-off + +Verdict: PASS. + +Live QA run: `20260621-171227-5362`, 24/24 actions PASS. + +## Gates + +| Gate | Result | Evidence | +|---|---|---| +| Local tests | PASS | `go test -count=1 ./core/ops ./cmd/sw-block` | +| Script syntax | PASS | `bash -n scripts/run-phase47-returned-replica-status-schema-rbac-gate.sh` | +| Scenario validation | PASS | `swblock validate testops/scenarios/returned-replica-status-schema-rbac-chain.yaml` | +| Live CRD schema/RBAC | PASS | `swblock run ...`, 24/24 actions | +| Executor contract projection | PASS | `valid_executor_contract_status_server_dry_run=true` | +| Execution disabled | PASS | `executor_contract_execution_disabled_projected=true` | +| Terminal evidence projected | PASS | `executor_contract_terminal_evidence_projected=true` | +| Status subresource boundary | PASS | status/events yes; main/finalizers/pods/pvc/storageclass no | +| Server dry-run non-mutation | PASS | `server_dry_run_status_mutated=false` | + +## Live Evidence + +```text +operator_status_patch_status_allowed=yes +operator_status_update_status_allowed=yes +operator_status_create_events_allowed=yes +operator_status_main_patch_allowed=no +operator_status_finalizers_patch_allowed=no +operator_status_pods_patch_allowed=no +operator_status_pvc_patch_allowed=no +operator_status_storageclass_update_allowed=no +valid_returned_replica_status_server_dry_run=true +valid_executor_preflight_status_server_dry_run=true +executor_preflight_ack_eligibility_known_projected=true +executor_preflight_forbidden_mutation_class_projected=true +valid_executor_contract_status_server_dry_run=true +executor_contract_execution_disabled_projected=true +executor_contract_terminal_evidence_projected=true +snake_case_action_rejected=true +unsupported_action_mode_rejected=true +main_object_patch_rejected=true +server_dry_run_status_mutated=false +phase47_returned_replica_status_schema_rbac_status=ok +``` + +## Boundary + +No executor ran. No RBAC expanded. No CRD spec/finalizer/storage/workload +mutation was added. + +The product now publishes the future executor envelope while keeping it +disabled: + +```text +decision=disabled +reason=executor_policy_disabled +execution_enabled=false +mutation_allowed=false +allowed_mutation_class=ack_eligibility +forbidden_mutation_class=frontend_publication,rebuild_traffic,failback +``` + +The terminal evidence required before any future executor can claim completion +is: + +```text +ack_eligibility_known +ack_eligible_true +frontend_fenced_after_execution +primary_unchanged +durable_frontier_covered +no_cross_volume_identity_change +``` + +This closes the executor-boundary design gap without claiming returned-replica +rebuild, failback, frontend publication, or storage mutation. diff --git a/seaweed-block/scripts/run-phase47-returned-replica-status-schema-rbac-gate.sh b/seaweed-block/scripts/run-phase47-returned-replica-status-schema-rbac-gate.sh index c7ceb57074..2a1571d871 100644 --- a/seaweed-block/scripts/run-phase47-returned-replica-status-schema-rbac-gate.sh +++ b/seaweed-block/scripts/run-phase47-returned-replica-status-schema-rbac-gate.sh @@ -205,6 +205,30 @@ cat >"${ARTIFACT_DIR}/valid-status-patch.json" <<'JSON' "forbiddenMutationClass": ["ack_eligibility", "frontend_publication", "rebuild_traffic", "failback"] } ], + "executorContracts": [ + { + "actionType": "authority.reintegrate_returned_replica", + "replicaID": "r1", + "decision": "disabled", + "reason": "executor_policy_disabled", + "ownerExecutor": "authority_recovery_executor", + "executionEnabled": false, + "mutationAllowed": false, + "preflightDecision": "ready", + "preflightReason": "preconditions_satisfied", + "allowedMutationClass": ["ack_eligibility"], + "forbiddenMutationClass": ["frontend_publication", "rebuild_traffic", "failback"], + "terminalEvidenceRequired": [ + "ack_eligibility_known", + "ack_eligible_true", + "frontend_fenced_after_execution", + "primary_unchanged", + "durable_frontier_covered", + "no_cross_volume_identity_change" + ], + "evidenceRefs": ["returned-replica-summary.txt"] + } + ], "allowedActions": [ { "type": "authority.reintegrate_returned_replica", @@ -243,6 +267,16 @@ cat >"${ARTIFACT_DIR}/snake-status-patch.json" <<'JSON' "ack_eligibility_known": true, "mutation_allowed": false } + ], + "executorContracts": [ + { + "action_type": "authority.reintegrate_returned_replica", + "decision": "disabled", + "reason": "executor_policy_disabled", + "owner_executor": "authority_recovery_executor", + "execution_enabled": false, + "mutation_allowed": false + } ] } } @@ -290,6 +324,12 @@ grep -q "ackEligibilityKnown: true" "${ARTIFACT_DIR}/valid-status-server-dry-run write_summary "executor_preflight_ack_eligibility_known_projected=true" grep -q "forbiddenMutationClass:" "${ARTIFACT_DIR}/valid-status-server-dry-run.stdout.txt" write_summary "executor_preflight_forbidden_mutation_class_projected=true" +grep -q "executorContracts:" "${ARTIFACT_DIR}/valid-status-server-dry-run.stdout.txt" +write_summary "valid_executor_contract_status_server_dry_run=true" +grep -q "executionEnabled: false" "${ARTIFACT_DIR}/valid-status-server-dry-run.stdout.txt" +write_summary "executor_contract_execution_disabled_projected=true" +grep -q "terminalEvidenceRequired:" "${ARTIFACT_DIR}/valid-status-server-dry-run.stdout.txt" +write_summary "executor_contract_terminal_evidence_projected=true" run_expect_failure snake-status-server-dry-run \ "${KUBECTL}" patch swblockvolume phase47-returned -n "${NAMESPACE}" \ diff --git a/seaweed-block/testops/scenarios/returned-replica-status-schema-rbac-chain.yaml b/seaweed-block/testops/scenarios/returned-replica-status-schema-rbac-chain.yaml index 584853d7fb..94ee5a3b74 100644 --- a/seaweed-block/testops/scenarios/returned-replica-status-schema-rbac-chain.yaml +++ b/seaweed-block/testops/scenarios/returned-replica-status-schema-rbac-chain.yaml @@ -61,6 +61,30 @@ phases: - action: assert_greater actual: "{{ phase51_ack_known_projected_count }}" threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase47-status-schema-rbac/phase47-returned-replica-status-schema-rbac-summary.txt" + pattern: "^valid_executor_contract_status_server_dry_run=true$" + save_as: phase52_valid_contract_count + - action: assert_greater + actual: "{{ phase52_valid_contract_count }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase47-status-schema-rbac/phase47-returned-replica-status-schema-rbac-summary.txt" + pattern: "^executor_contract_execution_disabled_projected=true$" + save_as: phase52_execution_disabled_count + - action: assert_greater + actual: "{{ phase52_execution_disabled_count }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase47-status-schema-rbac/phase47-returned-replica-status-schema-rbac-summary.txt" + pattern: "^executor_contract_terminal_evidence_projected=true$" + save_as: phase52_terminal_evidence_count + - action: assert_greater + actual: "{{ phase52_terminal_evidence_count }}" + threshold: "0" - action: grep_log node: m02 path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase47-status-schema-rbac/phase47-returned-replica-status-schema-rbac-summary.txt"