From 04e147323b38ef599701abce2bbb113ec6a9f7cc Mon Sep 17 00:00:00 2001 From: pingqiu Date: Thu, 25 Jun 2026 15:40:43 -0700 Subject: [PATCH] phase72: add frontend publication runtime contract --- ...ntendpublications.block.seaweedfs.com.yaml | 3 + .../core/ops/authority_executor_controller.go | 36 ++-- ...rontend_publication_executor_controller.go | 175 +++++++++++++++++- ...nd_publication_executor_controller_test.go | 143 ++++++++++++++ .../ops/frontend_publication_runtime_http.go | 61 ++++++ .../frontend_publication_runtime_http_test.go | 84 +++++++++ .../core/ops/kubernetes_crd_manifests_test.go | 3 +- .../core/ops/lifecycle_owner_controller.go | 1 + seaweed-block/internal/docs/current-plan.md | 167 +++++++++-------- ...n_frontend_publication_runtime_contract.md | 138 ++++++++++++++ .../internal/docs/product-roadmap.md | 15 +- ...publication-runtime-contract-qa-signoff.md | 66 +++++++ ...ntend-publication-runtime-contract-gate.sh | 68 +++++++ ...nd-publication-runtime-contract-chain.yaml | 131 +++++++++++++ 14 files changed, 988 insertions(+), 103 deletions(-) create mode 100644 seaweed-block/core/ops/frontend_publication_runtime_http.go create mode 100644 seaweed-block/core/ops/frontend_publication_runtime_http_test.go create mode 100644 seaweed-block/internal/docs/finished-plans/phase72_finishedplan_frontend_publication_runtime_contract.md create mode 100644 seaweed-block/internal/docs/qa-assignments/phase72-frontend-publication-runtime-contract-qa-signoff.md create mode 100644 seaweed-block/scripts/run-phase72-frontend-publication-runtime-contract-gate.sh create mode 100644 seaweed-block/testops/scenarios/frontend-publication-runtime-contract-chain.yaml diff --git a/seaweed-block/charts/seaweed-block/crds/swblockfrontendpublications.block.seaweedfs.com.yaml b/seaweed-block/charts/seaweed-block/crds/swblockfrontendpublications.block.seaweedfs.com.yaml index afa1c80d87..364007f54c 100644 --- a/seaweed-block/charts/seaweed-block/crds/swblockfrontendpublications.block.seaweedfs.com.yaml +++ b/seaweed-block/charts/seaweed-block/crds/swblockfrontendpublications.block.seaweedfs.com.yaml @@ -72,10 +72,13 @@ spec: enum: - blocked - disabled + - enabled frontendPublicationReason: type: string frontendPublicationMutationAllowed: type: boolean + runtimeEndpoint: + type: string status: type: object properties: diff --git a/seaweed-block/core/ops/authority_executor_controller.go b/seaweed-block/core/ops/authority_executor_controller.go index b829c007f4..1d870e9497 100644 --- a/seaweed-block/core/ops/authority_executor_controller.go +++ b/seaweed-block/core/ops/authority_executor_controller.go @@ -7,23 +7,25 @@ import ( ) const ( - AuthorityExecutorAllowedMutationAckEligibility = "ack_eligibility" - AuthorityExecutorAllowedMutationRebuildTraffic = "rebuild_traffic" - AuthorityExecutorBlockedPolicyDisabled = "executor_policy_disabled" - AuthorityExecutorBlockedMutationTargetMissing = "ack_eligibility_mutation_target_missing" - AuthorityExecutorBlockedRebuildTargetMissing = "rebuild_target_missing" - AuthorityExecutorBlockedTerminalEvidence = "terminal_evidence_missing" - AuthorityExecutorReasonAckEligibilityRecorded = "ack_eligibility_recorded" - AuthorityExecutorReasonRebuildPlanned = "rebuild_progress_planned" - AuthorityExecutorReasonRebuildRunning = "rebuild_runtime_running" - AuthorityExecutorReasonRebuildCaughtUp = "rebuild_runtime_caught_up" - AuthorityExecutorReasonRebuildRuntimeFailed = "rebuild_runtime_failed" - AuthorityExecutorReasonRebuildRuntimeTargetMissing = "rebuild_runtime_target_missing" - AuthorityExecutorPublicationDecisionBlocked = "blocked" - AuthorityExecutorPublicationDecisionDisabled = "disabled" - AuthorityExecutorPublicationReasonCaughtUpRequired = "rebuild_caught_up_required" - AuthorityExecutorPublicationReasonPolicyDisabled = "publication_policy_disabled" - AuthorityExecutorFrontendPublicationReasonDisabled = "frontend_publication_policy_disabled" + AuthorityExecutorAllowedMutationAckEligibility = "ack_eligibility" + AuthorityExecutorAllowedMutationRebuildTraffic = "rebuild_traffic" + AuthorityExecutorBlockedPolicyDisabled = "executor_policy_disabled" + AuthorityExecutorBlockedMutationTargetMissing = "ack_eligibility_mutation_target_missing" + AuthorityExecutorBlockedRebuildTargetMissing = "rebuild_target_missing" + AuthorityExecutorBlockedTerminalEvidence = "terminal_evidence_missing" + AuthorityExecutorReasonAckEligibilityRecorded = "ack_eligibility_recorded" + AuthorityExecutorReasonRebuildPlanned = "rebuild_progress_planned" + AuthorityExecutorReasonRebuildRunning = "rebuild_runtime_running" + AuthorityExecutorReasonRebuildCaughtUp = "rebuild_runtime_caught_up" + AuthorityExecutorReasonRebuildRuntimeFailed = "rebuild_runtime_failed" + AuthorityExecutorReasonRebuildRuntimeTargetMissing = "rebuild_runtime_target_missing" + AuthorityExecutorPublicationDecisionBlocked = "blocked" + AuthorityExecutorPublicationDecisionDisabled = "disabled" + AuthorityExecutorPublicationDecisionEnabled = "enabled" + AuthorityExecutorPublicationReasonCaughtUpRequired = "rebuild_caught_up_required" + AuthorityExecutorPublicationReasonPolicyDisabled = "publication_policy_disabled" + AuthorityExecutorFrontendPublicationReasonDisabled = "frontend_publication_policy_disabled" + AuthorityExecutorFrontendPublicationReasonPublished = "frontend_published" ) type AuthorityExecutorClient interface { diff --git a/seaweed-block/core/ops/frontend_publication_executor_controller.go b/seaweed-block/core/ops/frontend_publication_executor_controller.go index d00222a451..4c7e52fb3e 100644 --- a/seaweed-block/core/ops/frontend_publication_executor_controller.go +++ b/seaweed-block/core/ops/frontend_publication_executor_controller.go @@ -7,7 +7,8 @@ import ( ) const ( - FrontendPublicationStateBlocked = "blocked" + FrontendPublicationStateBlocked = "blocked" + FrontendPublicationStatePublished = "published" ) type FrontendPublicationExecutorClient interface { @@ -16,10 +17,41 @@ type FrontendPublicationExecutorClient interface { } type FrontendPublicationExecutorReconciler struct { - Namespace string - Client FrontendPublicationExecutorClient - DryRun bool - Now func() time.Time + Namespace string + Client FrontendPublicationExecutorClient + Runtime FrontendPublicationRuntime + DryRun bool + ExecutionRequested bool + ExecutionPolicyEnabled bool + Now func() time.Time +} + +type FrontendPublicationRuntime interface { + ExecuteFrontendPublication(ctx context.Context, req FrontendPublicationRuntimeRequest) (FrontendPublicationRuntimeResult, error) +} + +type FrontendPublicationRuntimeRequest struct { + VolumeName string `json:"volumeName"` + VolumeID string `json:"volumeID"` + PVCName string `json:"pvcName"` + ReplicaID string `json:"replicaID"` + RuntimeEndpoint string `json:"runtimeEndpoint,omitempty"` + SourceEligibilityName string `json:"sourceEligibilityName,omitempty"` + AckEligibilityKnown bool `json:"ackEligibilityKnown"` + AckEligible bool `json:"ackEligible"` + FrontendFencedAfterExecution bool `json:"frontendFencedAfterExecution"` + PrimaryUnchanged bool `json:"primaryUnchanged"` + DurableFrontierCovered bool `json:"durableFrontierCovered"` + NoCrossVolumeIdentityChange bool `json:"noCrossVolumeIdentityChange"` + EvidenceRefs []string `json:"evidenceRefs,omitempty"` +} + +type FrontendPublicationRuntimeResult struct { + FrontendPublished bool `json:"frontendPublished"` + FailbackStarted bool `json:"failbackStarted"` + NoStorageMutation bool `json:"noStorageMutation"` + NoCrossVolumeIdentityChange bool `json:"noCrossVolumeIdentityChange"` + EvidenceRefs []string `json:"evidenceRefs,omitempty"` } type FrontendPublicationExecutorReconcileResult struct { @@ -32,6 +64,9 @@ type FrontendPublicationExecutorReconcileResult struct { } func (r FrontendPublicationExecutorReconciler) Reconcile(ctx context.Context) (FrontendPublicationExecutorReconcileResult, error) { + if r.ExecutionRequested && !r.ExecutionPolicyEnabled { + return FrontendPublicationExecutorReconcileResult{}, fmt.Errorf("frontend publication executor execution is disabled by product policy") + } if r.Client == nil { return FrontendPublicationExecutorReconcileResult{}, fmt.Errorf("frontend publication executor client is required") } @@ -42,6 +77,12 @@ func (r FrontendPublicationExecutorReconciler) Reconcile(ctx context.Context) (F } result := FrontendPublicationExecutorReconcileResult{TargetCount: len(targets)} for _, target := range targets { + if r.ExecutionRequested { + if err := r.executeTarget(ctx, &result, target); err != nil { + return result, err + } + continue + } status := frontendPublicationExecutorDisabledStatus(r.now()(), target) if !frontendPublicationExecutorTargetValid(target) { result.InvalidTargetCount++ @@ -58,6 +99,64 @@ func (r FrontendPublicationExecutorReconciler) Reconcile(ctx context.Context) (F return result, nil } +func (r FrontendPublicationExecutorReconciler) executeTarget(ctx context.Context, result *FrontendPublicationExecutorReconcileResult, target SwBlockFrontendPublicationObject) error { + status := frontendPublicationExecutorDisabledStatus(r.now()(), target) + if !frontendPublicationExecutorExecutableTarget(target) { + result.InvalidTargetCount++ + status.ReasonCode = "missing_required_facts" + if !r.DryRun { + if err := r.Client.WriteFrontendPublicationStatus(ctx, target.Ref, status); err != nil { + return err + } + result.StatusWriteCount++ + } + return nil + } + runtime := r.Runtime + if runtime == nil && target.Spec.RuntimeEndpoint != "" { + runtime = NewHTTPFrontendPublicationRuntime(target.Spec.RuntimeEndpoint, nil) + } + if runtime == nil { + status.ReasonCode = "frontend_publication_runtime_target_missing" + if !r.DryRun { + if err := r.Client.WriteFrontendPublicationStatus(ctx, target.Ref, status); err != nil { + return err + } + result.StatusWriteCount++ + } + return nil + } + result.FrontendPublicationAttempts++ + if r.DryRun { + return nil + } + runtimeResult, err := runtime.ExecuteFrontendPublication(ctx, frontendPublicationRuntimeRequest(target)) + if err != nil { + status.ReasonCode = "frontend_publication_runtime_failed" + if writeErr := r.Client.WriteFrontendPublicationStatus(ctx, target.Ref, status); writeErr != nil { + return fmt.Errorf("write failed frontend publication status after runtime error %v: %w", err, writeErr) + } + result.StatusWriteCount++ + return fmt.Errorf("execute frontend publication runtime: %w", err) + } + if runtimeResult.FailbackStarted { + result.FailbackAttempts++ + } + if !frontendPublicationRuntimeTerminalEvidenceValid(runtimeResult) { + status.ReasonCode = "frontend_publication_runtime_invalid_terminal_evidence" + if err := r.Client.WriteFrontendPublicationStatus(ctx, target.Ref, status); err != nil { + return err + } + result.StatusWriteCount++ + return nil + } + if err := r.Client.WriteFrontendPublicationStatus(ctx, target.Ref, frontendPublicationExecutorPublishedStatus(r.now()(), target, runtimeResult)); err != nil { + return err + } + result.StatusWriteCount++ + return nil +} + func frontendPublicationExecutorTargetValid(target SwBlockFrontendPublicationObject) bool { spec := target.Spec return spec.VolumeName != "" && @@ -73,6 +172,28 @@ func frontendPublicationExecutorTargetValid(target SwBlockFrontendPublicationObj !spec.FrontendPublicationMutationAllowed } +func frontendPublicationExecutorExecutableTarget(target SwBlockFrontendPublicationObject) bool { + spec := target.Spec + return spec.VolumeName != "" && + spec.ReplicaID != "" && + spec.RuntimeEndpoint != "" && + spec.AckEligibilityKnown && + spec.AckEligible && + spec.FrontendFencedAfterExecution && + spec.PrimaryUnchanged && + spec.DurableFrontierCovered && + spec.NoCrossVolumeIdentityChange && + spec.FrontendPublicationDecision == AuthorityExecutorPublicationDecisionEnabled && + spec.FrontendPublicationMutationAllowed +} + +func frontendPublicationRuntimeTerminalEvidenceValid(result FrontendPublicationRuntimeResult) bool { + return result.FrontendPublished && + !result.FailbackStarted && + result.NoStorageMutation && + result.NoCrossVolumeIdentityChange +} + func frontendPublicationExecutorDisabledStatus(now time.Time, target SwBlockFrontendPublicationObject) SwBlockFrontendPublicationCRDStatus { return SwBlockFrontendPublicationCRDStatus{ ObservedAt: now, @@ -99,6 +220,50 @@ func frontendPublicationExecutorDisabledStatus(now time.Time, target SwBlockFron } } +func frontendPublicationExecutorPublishedStatus(now time.Time, target SwBlockFrontendPublicationObject, result FrontendPublicationRuntimeResult) SwBlockFrontendPublicationCRDStatus { + return SwBlockFrontendPublicationCRDStatus{ + ObservedAt: now, + Executor: "frontend-publication-executor", + State: FrontendPublicationStatePublished, + ReasonCode: AuthorityExecutorFrontendPublicationReasonPublished, + PublicationMutationAllowed: false, + FrontendPublished: result.FrontendPublished, + FailbackStarted: result.FailbackStarted, + NoStorageMutation: result.NoStorageMutation, + NoCrossVolumeIdentityChange: target.Spec.NoCrossVolumeIdentityChange && result.NoCrossVolumeIdentityChange, + Conditions: []ObservationCondition{{ + Type: ConditionReady, + Status: "True", + Reason: AuthorityExecutorFrontendPublicationReasonPublished, + Severity: "info", + Message: "frontend publication runtime reported publication complete", + }}, + EvidenceRefs: append([]string(nil), result.EvidenceRefs...), + NonClaims: []string{ + "no_failback", + "no_storage_mutation", + }, + } +} + +func frontendPublicationRuntimeRequest(target SwBlockFrontendPublicationObject) FrontendPublicationRuntimeRequest { + spec := target.Spec + return FrontendPublicationRuntimeRequest{ + VolumeName: spec.VolumeName, + VolumeID: spec.VolumeID, + PVCName: spec.PVCName, + ReplicaID: spec.ReplicaID, + RuntimeEndpoint: spec.RuntimeEndpoint, + SourceEligibilityName: spec.SourceEligibilityName, + AckEligibilityKnown: spec.AckEligibilityKnown, + AckEligible: spec.AckEligible, + FrontendFencedAfterExecution: spec.FrontendFencedAfterExecution, + PrimaryUnchanged: spec.PrimaryUnchanged, + DurableFrontierCovered: spec.DurableFrontierCovered, + NoCrossVolumeIdentityChange: spec.NoCrossVolumeIdentityChange, + } +} + func (r FrontendPublicationExecutorReconciler) now() func() time.Time { if r.Now != nil { return r.Now diff --git a/seaweed-block/core/ops/frontend_publication_executor_controller_test.go b/seaweed-block/core/ops/frontend_publication_executor_controller_test.go index 03fb021036..17ee60afdb 100644 --- a/seaweed-block/core/ops/frontend_publication_executor_controller_test.go +++ b/seaweed-block/core/ops/frontend_publication_executor_controller_test.go @@ -2,6 +2,7 @@ package ops import ( "context" + "errors" "testing" "time" ) @@ -92,6 +93,125 @@ func TestFrontendPublicationExecutorMarksInvalidTargets(t *testing.T) { } } +func TestFrontendPublicationExecutorExecutionPolicyBlocks(t *testing.T) { + client := &fakeFrontendPublicationExecutorClient{ + targets: []SwBlockFrontendPublicationObject{frontendPublicationExecutorExecutableTargetFixture()}, + } + _, err := (FrontendPublicationExecutorReconciler{ + Namespace: "kube-system", + Client: client, + ExecutionRequested: true, + }).Reconcile(context.Background()) + if err == nil || err.Error() != "frontend publication executor execution is disabled by product policy" { + t.Fatalf("err=%v", err) + } + if len(client.writes) != 0 { + t.Fatalf("policy-disabled execution wrote status: %+v", client.writes) + } +} + +func TestFrontendPublicationExecutorInvokesRuntimeWhenExplicitlyEnabled(t *testing.T) { + target := frontendPublicationExecutorExecutableTargetFixture() + client := &fakeFrontendPublicationExecutorClient{targets: []SwBlockFrontendPublicationObject{target}} + runtime := &fakeFrontendPublicationRuntime{result: FrontendPublicationRuntimeResult{ + FrontendPublished: true, + FailbackStarted: false, + NoStorageMutation: true, + NoCrossVolumeIdentityChange: true, + EvidenceRefs: []string{"frontend-runtime.txt"}, + }} + result, err := (FrontendPublicationExecutorReconciler{ + Namespace: "kube-system", + Client: client, + Runtime: runtime, + ExecutionRequested: true, + ExecutionPolicyEnabled: true, + Now: func() time.Time { return time.Date(2026, 6, 25, 12, 0, 0, 0, time.UTC) }, + }).Reconcile(context.Background()) + if err != nil { + t.Fatalf("reconcile: %v", err) + } + if result.FrontendPublicationAttempts != 1 || + result.FailbackAttempts != 0 || + result.StatusWriteCount != 1 || + result.StorageMutationAllowed { + t.Fatalf("result=%+v", result) + } + if len(runtime.requests) != 1 { + t.Fatalf("runtime requests=%+v", runtime.requests) + } + req := runtime.requests[0] + if req.VolumeName != target.Spec.VolumeName || + req.ReplicaID != target.Spec.ReplicaID || + !req.AckEligible || + !req.NoCrossVolumeIdentityChange { + t.Fatalf("runtime request=%+v", req) + } + status := client.writes[0].status + if status.State != FrontendPublicationStatePublished || + status.ReasonCode != AuthorityExecutorFrontendPublicationReasonPublished || + status.PublicationMutationAllowed || + !status.FrontendPublished || + status.FailbackStarted || + !status.NoStorageMutation || + !status.NoCrossVolumeIdentityChange { + t.Fatalf("status=%+v", status) + } +} + +func TestFrontendPublicationExecutorRuntimeFailureWritesBlockedStatus(t *testing.T) { + client := &fakeFrontendPublicationExecutorClient{targets: []SwBlockFrontendPublicationObject{frontendPublicationExecutorExecutableTargetFixture()}} + runtime := &fakeFrontendPublicationRuntime{err: errors.New("runtime refused")} + result, err := (FrontendPublicationExecutorReconciler{ + Namespace: "kube-system", + Client: client, + Runtime: runtime, + ExecutionRequested: true, + ExecutionPolicyEnabled: true, + }).Reconcile(context.Background()) + if err == nil { + t.Fatalf("expected runtime error") + } + if result.FrontendPublicationAttempts != 1 || result.StatusWriteCount != 1 { + t.Fatalf("result=%+v", result) + } + if got := client.writes[0].status.ReasonCode; got != "frontend_publication_runtime_failed" { + t.Fatalf("reason=%s", got) + } + if client.writes[0].status.FrontendPublished { + t.Fatalf("failed runtime must not claim published: %+v", client.writes[0].status) + } +} + +func TestFrontendPublicationExecutorRejectsInvalidRuntimeTerminalEvidence(t *testing.T) { + client := &fakeFrontendPublicationExecutorClient{targets: []SwBlockFrontendPublicationObject{frontendPublicationExecutorExecutableTargetFixture()}} + runtime := &fakeFrontendPublicationRuntime{result: FrontendPublicationRuntimeResult{ + FrontendPublished: true, + FailbackStarted: true, + NoStorageMutation: true, + NoCrossVolumeIdentityChange: true, + }} + result, err := (FrontendPublicationExecutorReconciler{ + Namespace: "kube-system", + Client: client, + Runtime: runtime, + ExecutionRequested: true, + ExecutionPolicyEnabled: true, + }).Reconcile(context.Background()) + if err != nil { + t.Fatalf("reconcile: %v", err) + } + if result.FrontendPublicationAttempts != 1 || result.FailbackAttempts != 1 || result.StatusWriteCount != 1 { + t.Fatalf("result=%+v", result) + } + status := client.writes[0].status + if status.State != FrontendPublicationStateBlocked || + status.ReasonCode != "frontend_publication_runtime_invalid_terminal_evidence" || + status.FrontendPublished { + t.Fatalf("status=%+v", status) + } +} + func frontendPublicationExecutorTestTarget() SwBlockFrontendPublicationObject { return SwBlockFrontendPublicationObject{ Ref: OperatorObjectRef{ @@ -119,11 +239,34 @@ func frontendPublicationExecutorTestTarget() SwBlockFrontendPublicationObject { } } +func frontendPublicationExecutorExecutableTargetFixture() SwBlockFrontendPublicationObject { + target := frontendPublicationExecutorTestTarget() + target.Spec.FrontendPublicationDecision = AuthorityExecutorPublicationDecisionEnabled + target.Spec.FrontendPublicationReason = "frontend_publication_requested" + target.Spec.FrontendPublicationMutationAllowed = true + target.Spec.RuntimeEndpoint = "http://127.0.0.1:23260/runtime/frontend-publication" + return target +} + type fakeFrontendPublicationExecutorClient struct { targets []SwBlockFrontendPublicationObject writes []fakeFrontendPublicationStatusWrite } +type fakeFrontendPublicationRuntime struct { + requests []FrontendPublicationRuntimeRequest + result FrontendPublicationRuntimeResult + err error +} + +func (f *fakeFrontendPublicationRuntime) ExecuteFrontendPublication(_ context.Context, req FrontendPublicationRuntimeRequest) (FrontendPublicationRuntimeResult, error) { + f.requests = append(f.requests, req) + if f.err != nil { + return FrontendPublicationRuntimeResult{}, f.err + } + return f.result, nil +} + type fakeFrontendPublicationStatusWrite struct { ref OperatorObjectRef status SwBlockFrontendPublicationCRDStatus diff --git a/seaweed-block/core/ops/frontend_publication_runtime_http.go b/seaweed-block/core/ops/frontend_publication_runtime_http.go new file mode 100644 index 0000000000..d5ff38b70c --- /dev/null +++ b/seaweed-block/core/ops/frontend_publication_runtime_http.go @@ -0,0 +1,61 @@ +package ops + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + "time" +) + +type HTTPFrontendPublicationRuntime struct { + Endpoint string + Client *http.Client +} + +func NewHTTPFrontendPublicationRuntime(endpoint string, client *http.Client) *HTTPFrontendPublicationRuntime { + if client == nil { + client = &http.Client{Timeout: 30 * time.Second} + } + return &HTTPFrontendPublicationRuntime{ + Endpoint: strings.TrimSpace(endpoint), + Client: client, + } +} + +func (r *HTTPFrontendPublicationRuntime) ExecuteFrontendPublication(ctx context.Context, req FrontendPublicationRuntimeRequest) (FrontendPublicationRuntimeResult, error) { + if r == nil || strings.TrimSpace(r.Endpoint) == "" { + return FrontendPublicationRuntimeResult{}, fmt.Errorf("frontend publication runtime endpoint is required") + } + client := r.Client + if client == nil { + client = &http.Client{Timeout: 30 * time.Second} + } + body, err := json.Marshal(req) + if err != nil { + return FrontendPublicationRuntimeResult{}, fmt.Errorf("marshal frontend publication runtime request: %w", err) + } + httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, r.Endpoint, bytes.NewReader(body)) + if err != nil { + return FrontendPublicationRuntimeResult{}, fmt.Errorf("create frontend publication runtime request: %w", err) + } + httpReq.Header.Set("Content-Type", "application/json") + httpReq.Header.Set("Accept", "application/json") + resp, err := client.Do(httpReq) + if err != nil { + return FrontendPublicationRuntimeResult{}, fmt.Errorf("post frontend publication runtime request: %w", err) + } + defer resp.Body.Close() + if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices { + payload, _ := io.ReadAll(io.LimitReader(resp.Body, 4096)) + return FrontendPublicationRuntimeResult{}, fmt.Errorf("frontend publication runtime returned HTTP %d: %s", resp.StatusCode, strings.TrimSpace(string(payload))) + } + var result FrontendPublicationRuntimeResult + if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { + return FrontendPublicationRuntimeResult{}, fmt.Errorf("decode frontend publication runtime response: %w", err) + } + return result, nil +} diff --git a/seaweed-block/core/ops/frontend_publication_runtime_http_test.go b/seaweed-block/core/ops/frontend_publication_runtime_http_test.go new file mode 100644 index 0000000000..4e5bf35c2a --- /dev/null +++ b/seaweed-block/core/ops/frontend_publication_runtime_http_test.go @@ -0,0 +1,84 @@ +package ops + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +func TestHTTPFrontendPublicationRuntimePostsRequestAndDecodesResult(t *testing.T) { + var got FrontendPublicationRuntimeRequest + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + t.Fatalf("method=%s", r.Method) + } + if ct := r.Header.Get("Content-Type"); !strings.HasPrefix(ct, "application/json") { + t.Fatalf("content-type=%q", ct) + } + if err := json.NewDecoder(r.Body).Decode(&got); err != nil { + t.Fatalf("decode request: %v", err) + } + _ = json.NewEncoder(w).Encode(FrontendPublicationRuntimeResult{ + FrontendPublished: true, + FailbackStarted: false, + NoStorageMutation: true, + NoCrossVolumeIdentityChange: true, + EvidenceRefs: []string{"frontend-runtime.txt"}, + }) + })) + defer server.Close() + + result, err := NewHTTPFrontendPublicationRuntime(server.URL, server.Client()).ExecuteFrontendPublication(context.Background(), FrontendPublicationRuntimeRequest{ + VolumeName: "demo", + VolumeID: "pvc-demo", + PVCName: "demo-pvc", + ReplicaID: "r2", + RuntimeEndpoint: server.URL, + AckEligibilityKnown: true, + AckEligible: true, + FrontendFencedAfterExecution: true, + PrimaryUnchanged: true, + DurableFrontierCovered: true, + NoCrossVolumeIdentityChange: true, + EvidenceRefs: []string{"target.txt"}, + }) + if err != nil { + t.Fatalf("execute frontend publication: %v", err) + } + if got.VolumeName != "demo" || + got.VolumeID != "pvc-demo" || + got.ReplicaID != "r2" || + !got.AckEligible || + !got.NoCrossVolumeIdentityChange { + t.Fatalf("request=%+v", got) + } + if !result.FrontendPublished || + result.FailbackStarted || + !result.NoStorageMutation || + !result.NoCrossVolumeIdentityChange || + !authorityExecutorStringSliceContains(result.EvidenceRefs, "frontend-runtime.txt") { + t.Fatalf("result=%+v", result) + } +} + +func TestHTTPFrontendPublicationRuntimeReturnsHTTPError(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.Error(w, "runtime unavailable", http.StatusServiceUnavailable) + })) + defer server.Close() + + _, err := NewHTTPFrontendPublicationRuntime(server.URL, server.Client()).ExecuteFrontendPublication(context.Background(), FrontendPublicationRuntimeRequest{}) + if err == nil || !strings.Contains(err.Error(), "HTTP 503") || !strings.Contains(err.Error(), "runtime unavailable") { + t.Fatalf("err=%v", err) + } +} + +func TestHTTPFrontendPublicationRuntimeRequiresEndpoint(t *testing.T) { + _, err := NewHTTPFrontendPublicationRuntime("", nil).ExecuteFrontendPublication(context.Background(), FrontendPublicationRuntimeRequest{}) + if err == nil || !strings.Contains(err.Error(), "endpoint is required") { + t.Fatalf("err=%v", err) + } +} diff --git a/seaweed-block/core/ops/kubernetes_crd_manifests_test.go b/seaweed-block/core/ops/kubernetes_crd_manifests_test.go index 6f2b51f840..fe911cbb2a 100644 --- a/seaweed-block/core/ops/kubernetes_crd_manifests_test.go +++ b/seaweed-block/core/ops/kubernetes_crd_manifests_test.go @@ -479,6 +479,7 @@ func TestPhase69SwBlockFrontendPublicationTargetSchema(t *testing.T) { "frontendPublicationDecision", "frontendPublicationReason", "frontendPublicationMutationAllowed", + "runtimeEndpoint", } { if _, ok := specProperties[want]; !ok { t.Fatalf("%s.spec schema missing %s", SwBlockFrontendPublicationKind, want) @@ -491,7 +492,7 @@ func TestPhase69SwBlockFrontendPublicationTargetSchema(t *testing.T) { } } decisionEnum := yamlStringSet(t, yamlMap(t, specProperties, "frontendPublicationDecision"), "enum") - for _, want := range []string{"blocked", "disabled"} { + for _, want := range []string{"blocked", "disabled", "enabled"} { if !decisionEnum[want] { t.Fatalf("%s.spec.frontendPublicationDecision enum missing %s: %+v", SwBlockFrontendPublicationKind, want, decisionEnum) } diff --git a/seaweed-block/core/ops/lifecycle_owner_controller.go b/seaweed-block/core/ops/lifecycle_owner_controller.go index 6b290d1cbd..6908702952 100644 --- a/seaweed-block/core/ops/lifecycle_owner_controller.go +++ b/seaweed-block/core/ops/lifecycle_owner_controller.go @@ -80,6 +80,7 @@ type SwBlockFrontendPublicationSpec struct { FrontendPublicationDecision string `json:"frontendPublicationDecision,omitempty"` FrontendPublicationReason string `json:"frontendPublicationReason,omitempty"` FrontendPublicationMutationAllowed bool `json:"frontendPublicationMutationAllowed"` + RuntimeEndpoint string `json:"runtimeEndpoint,omitempty"` } type SwBlockFrontendPublicationCRDStatus struct { diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index bf2a14372b..7041bdbd88 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,91 +1,109 @@ -# Current Plan: Phase 71 Frontend Publication Live API Boundary +# Current Plan: Phase 72 Frontend Publication Runtime Contract Status: complete. ## Goal -Phase 70 added the frontend publication executor as a status-only controller: +Phase 71 proved the live Kubernetes API/RBAC boundary for the frontend +publication executor. Phase 72 adds the next code seam: a typed frontend +publication runtime contract and an explicit executor policy gate. -```text -SwBlockFrontendPublication.status -``` - -Phase 71 closes the live Kubernetes API gap for that boundary. The gate proves -against a real apiserver that the executor may patch only the -`SwBlockFrontendPublication` status subresource and cannot mutate: - -```text -target spec -target metadata -target finalizers -SwBlockVolume -SwBlockReplicaEligibility -workloads -PVC/PV -StorageClass -Secrets -Nodes / CSIDrivers / CSINodes -``` - -This is intentionally not frontend publication execution. It is the live API -proof required before we grant any broader authority in a later phase. +This phase still does not wire a real blockmaster or blockvolume frontend +publication endpoint. The purpose is to prevent the next implementation from +becoming a fake status-only publish. ## Delivered -### D1: Live API Gate +### D1: Runtime Contract Added: ```text -scripts/run-phase71-frontend-publication-live-api-boundary-gate.sh +FrontendPublicationRuntime +FrontendPublicationRuntimeRequest +FrontendPublicationRuntimeResult +HTTPFrontendPublicationRuntime ``` -The gate installs the `SwBlockFrontendPublication` CRD, creates a scoped -executor service account and RBAC, creates one target object, then verifies: +The HTTP client posts JSON to an explicit runtime endpoint and decodes: ```text -patch swblockfrontendpublications/status = allowed -patch swblockfrontendpublications main object = denied -create/update/delete swblockfrontendpublications = denied -patch finalizers endpoint = denied -events/workload/storage mutation = denied +frontendPublished +failbackStarted +noStorageMutation +noCrossVolumeIdentityChange +evidenceRefs ``` -It writes a disabled/blocked status through the real status subresource and -checks that spec/labels/annotations remain unchanged. +### D2: Explicit Executor Gate -### D2: Runner Scenario +`FrontendPublicationExecutorReconciler` now supports an opt-in execution path: + +```text +ExecutionRequested=true +ExecutionPolicyEnabled=true +``` + +Without both flags, execution is blocked. Default reconciliation remains the +Phase 70/71 status-only disabled path. + +The runtime path requires an explicit target shape: + +```text +frontendPublicationDecision=enabled +frontendPublicationMutationAllowed=true +runtimeEndpoint= +ackEligibilityKnown=true +ackEligible=true +frontendFencedAfterExecution=true +primaryUnchanged=true +durableFrontierCovered=true +noCrossVolumeIdentityChange=true +``` + +### D3: Schema Contract + +`SwBlockFrontendPublication.spec` now admits the future execution contract: + +```text +frontendPublicationDecision=enabled +runtimeEndpoint +``` + +The existing target owner still creates only disabled targets, so default +product behavior does not change. + +### D4: Gate Added: ```text -testops/scenarios/frontend-publication-live-api-boundary-chain.yaml +scripts/run-phase72-frontend-publication-runtime-contract-gate.sh +testops/scenarios/frontend-publication-runtime-contract-chain.yaml ``` -The scenario asserts the terminal evidence: +The gate proves: ```text -phase71_frontend_publication_live_api_boundary_status=ok -frontend_publication_executor_status_writes=true -frontend_publication_executor_status=blocked -frontend_publication_executor_reason=frontend_publication_policy_disabled -frontend_publication_executor_rbac_status_only=true -frontend_publication_mutation_allowed=false -frontend_published=false -failback_started=false -storage_mutation_allowed=false -target_object_integrity_preserved=true +default executor remains disabled +execution policy blocks when not explicitly enabled +enabled target invokes runtime exactly through the typed contract +runtime failure does not claim frontendPublished +HTTP runtime errors surface +failback remains false +storage mutation remains false ``` ## Non-Claims -Phase 71 does not claim: +Phase 72 does not claim: ```text -frontend publication execution -frontend publish target update +real frontend publication endpoint exists +blockmaster publish target update +blockvolume runtime frontend switch primary authority change -failback +failback execution storage/workload mutation NVMe ANA behavior ``` @@ -93,35 +111,36 @@ NVMe ANA behavior ## Verification ```text -C:\work\swblock.exe validate testops\scenarios\frontend-publication-live-api-boundary-chain.yaml -20260625-112540-ca98 frontend-publication-live-api-boundary-chain PASS 32/32 +go test ./core/ops ./cmd/sw-block +C:\work\swblock.exe validate testops\scenarios\frontend-publication-runtime-contract-chain.yaml +20260625-153846-1bf7 frontend-publication-runtime-contract-chain PASS 24/24 ``` Terminal evidence: ```text -phase71_frontend_publication_live_api_boundary_status=ok -executor_status_patch_succeeded=true -frontend_publication_executor_status_writes=true -frontend_publication_executor_status=blocked -frontend_publication_executor_reason=frontend_publication_policy_disabled -frontend_publication_executor_status_mutation_allowed=true -frontend_publication_mutation_allowed=false -frontend_published=false +phase72_frontend_publication_runtime_contract_status=ok +core_ops_frontend_publication_runtime_tests=pass +frontend_publication_runtime_contract_schema_locked=true +frontend_publication_runtime_endpoint_field=true +frontend_publication_execution_policy_gate=true +frontend_publication_runtime_invoked_only_when_enabled=true +frontend_publication_runtime_failure_no_false_publish=true +frontend_publication_runtime_invalid_terminal_evidence_no_false_publish=true +frontend_publication_attempts=1 +frontend_published=true failback_started=false -frontend_publication_attempts=0 -failback_attempts=0 storage_mutation_allowed=false -frontend_publication_executor_rbac_status_only=true -executor_spec_patch_allowed=false -executor_label_patch_allowed=false -executor_finalizers_endpoint_allowed=false -target_object_integrity_preserved=true ``` ## Next -If Phase 71 passes live QA, Phase 72 may introduce the first opt-in frontend -publication mutation. That phase must define exactly which product-owned field -or runtime endpoint changes and must include admission/RBAC and multi-volume -isolation gates before any failback claim. +Phase 73 should implement the real runtime endpoint owner. The key design +decision is still open: + +```text +blockmaster authority endpoint vs blockvolume runtime endpoint +``` + +Do not mark a target as published until a real endpoint performs a real +product-owned side effect and returns terminal evidence. diff --git a/seaweed-block/internal/docs/finished-plans/phase72_finishedplan_frontend_publication_runtime_contract.md b/seaweed-block/internal/docs/finished-plans/phase72_finishedplan_frontend_publication_runtime_contract.md new file mode 100644 index 0000000000..903f9d42da --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase72_finishedplan_frontend_publication_runtime_contract.md @@ -0,0 +1,138 @@ +# Phase 72 Finished Plan: Frontend Publication Runtime Contract + +## Result + +Complete. + +Phase 72 added a typed runtime contract for the future frontend publication +side effect. It does not add a real blockmaster or blockvolume publish endpoint +and does not change default runtime behavior. + +## Delivered + +### Runtime Contract + +Added: + +```text +FrontendPublicationRuntime +FrontendPublicationRuntimeRequest +FrontendPublicationRuntimeResult +HTTPFrontendPublicationRuntime +``` + +The runtime request carries target identity and the terminal evidence required +before publication may be attempted: + +```text +volumeName +volumeID +pvcName +replicaID +runtimeEndpoint +ackEligibilityKnown +ackEligible +frontendFencedAfterExecution +primaryUnchanged +durableFrontierCovered +noCrossVolumeIdentityChange +``` + +The runtime result must return terminal evidence: + +```text +frontendPublished=true +failbackStarted=false +noStorageMutation=true +noCrossVolumeIdentityChange=true +``` + +If the runtime returns anything weaker, the executor writes a blocked status +and does not claim publication. + +### Executor Gate + +The executor now has an explicit opt-in execution path: + +```text +ExecutionRequested=true +ExecutionPolicyEnabled=true +``` + +Execution remains blocked unless both flags are set. Default reconciliation is +unchanged from Phase 70/71: status-only blocked/disabled. + +### Schema + +`SwBlockFrontendPublication.spec` now admits: + +```text +frontendPublicationDecision=enabled +runtimeEndpoint +``` + +The target owner still generates only disabled targets, so no default target is +executable. + +### Gate + +Added: + +```text +scripts/run-phase72-frontend-publication-runtime-contract-gate.sh +testops/scenarios/frontend-publication-runtime-contract-chain.yaml +``` + +## Verification + +Local: + +```text +go test ./core/ops ./cmd/sw-block +C:\work\swblock.exe validate testops\scenarios\frontend-publication-runtime-contract-chain.yaml +bash -n scripts/run-phase72-frontend-publication-runtime-contract-gate.sh +git diff --check +``` + +Runner: + +```text +20260625-153846-1bf7 frontend-publication-runtime-contract-chain PASS 24/24 +``` + +Terminal evidence: + +```text +phase72_frontend_publication_runtime_contract_status=ok +core_ops_frontend_publication_runtime_tests=pass +frontend_publication_runtime_contract_schema_locked=true +frontend_publication_runtime_endpoint_field=true +frontend_publication_execution_policy_gate=true +frontend_publication_runtime_invoked_only_when_enabled=true +frontend_publication_runtime_failure_no_false_publish=true +frontend_publication_runtime_invalid_terminal_evidence_no_false_publish=true +frontend_publication_attempts=1 +frontend_published=true +failback_started=false +storage_mutation_allowed=false +``` + +## Non-Claims + +Phase 72 does not claim: + +```text +real frontend publication endpoint exists +blockmaster publish target update +blockvolume runtime frontend switch +primary authority change +failback execution +storage/workload mutation +NVMe ANA behavior +``` + +## Next + +Phase 73 should implement the real runtime endpoint owner. Do not mark any +target as published until a real endpoint performs a real product-owned side +effect and returns terminal evidence. diff --git a/seaweed-block/internal/docs/product-roadmap.md b/seaweed-block/internal/docs/product-roadmap.md index ff28cb0613..d50c481256 100644 --- a/seaweed-block/internal/docs/product-roadmap.md +++ b/seaweed-block/internal/docs/product-roadmap.md @@ -58,7 +58,7 @@ This is the short internal roadmap. Keep it current and readable. agreement. This remains read-only and does not add mutating operator lifecycle. - Current development slice: returned-replica rebuild/reintegration runtime - productization has advanced through Phase 71. Phases 46-54 made returned + productization has advanced through Phase 72. Phases 46-54 made returned replicas visible and action-gated, Phases 60-67 connected the bounded rebuild/catch-up runtime path through target facts, executor HTTP transport, an opt-in blockvolume runtime start endpoint, terminal caught-up evidence, @@ -68,8 +68,10 @@ This is the short internal roadmap. Keep it current and readable. publication executor boundary. Phase 71 adds the live Kubernetes API/RBAC proof that the executor can patch only `SwBlockFrontendPublication.status` and cannot mutate target spec, target finalizers, workload/storage resources, - frontend publication, or failback. Do not claim frontend publication - execution, failback, backup/restore, or NVMe parity yet. + frontend publication, or failback. Phase 72 adds the typed runtime contract + for a future frontend publication endpoint and proves that invalid or failed + runtime evidence cannot claim publication. Do not claim real frontend + publication execution, failback, backup/restore, or NVMe parity yet. - Model hardening gate before the next large release: complete the ManagedVolume Operations Model under `internal/docs/protocol/` before expanding operator or broader HA claims. The goal is to prevent Kubernetes, @@ -207,9 +209,10 @@ rebuild, delete safety, or cleanup must start as a separate gated phase. explicitly disabled on that eligibility. Phase 69 creates the next typed frontend-publication target object without executing publication. Phase 70 adds the status-only frontend publication executor boundary. Phase 71 adds - the live API/RBAC boundary for that executor. The remaining gap before - failback is the first real frontend publication mutation with admission/RBAC - proof and multi-volume isolation. + the live API/RBAC boundary for that executor. Phase 72 adds the typed runtime + contract for frontend publication, but no real endpoint yet. The remaining + gap before failback is the first real frontend publication mutation with + admission/RBAC proof and multi-volume isolation. - Later: returned-replica frontend publication/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/phase72-frontend-publication-runtime-contract-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase72-frontend-publication-runtime-contract-qa-signoff.md new file mode 100644 index 0000000000..4bb9407f32 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase72-frontend-publication-runtime-contract-qa-signoff.md @@ -0,0 +1,66 @@ +# Phase 72 Frontend Publication Runtime Contract QA Sign-off + +## Verdict + +PASS. + +Runner: + +```text +20260625-153846-1bf7 frontend-publication-runtime-contract-chain PASS 24/24 +``` + +The first QA run (`20260625-153622-fac9`) passed the initial gate. The gate was +then tightened to include invalid terminal evidence, and the final rerun above +is the authoritative sign-off. + +## Scope + +Phase 72 validates a typed runtime contract for future frontend publication. +It does not validate a real blockmaster or blockvolume publication endpoint. + +## Evidence + +Terminal summary: + +```text +phase72_frontend_publication_runtime_contract_status=ok +core_ops_frontend_publication_runtime_tests=pass +frontend_publication_runtime_contract_schema_locked=true +frontend_publication_runtime_endpoint_field=true +frontend_publication_execution_policy_gate=true +frontend_publication_runtime_invoked_only_when_enabled=true +frontend_publication_runtime_failure_no_false_publish=true +frontend_publication_runtime_invalid_terminal_evidence_no_false_publish=true +frontend_publication_attempts=1 +frontend_published=true +failback_started=false +storage_mutation_allowed=false +``` + +## Result Matrix + +| Gate | Result | +| --- | --- | +| Schema admits enabled target + runtimeEndpoint | PASS | +| Default executor remains disabled/status-only | PASS | +| Execution policy blocks unless explicitly enabled | PASS | +| Enabled target invokes typed runtime contract | PASS | +| Runtime failure does not claim publication | PASS | +| Invalid runtime terminal evidence does not claim publication | PASS | +| Failback remains false | PASS | +| Storage mutation remains false | PASS | + +## Non-Claims + +Phase 72 does not claim: + +```text +real frontend publication endpoint exists +blockmaster publish target update +blockvolume runtime frontend switch +primary authority change +failback execution +storage/workload mutation +NVMe ANA behavior +``` diff --git a/seaweed-block/scripts/run-phase72-frontend-publication-runtime-contract-gate.sh b/seaweed-block/scripts/run-phase72-frontend-publication-runtime-contract-gate.sh new file mode 100644 index 0000000000..f273e16929 --- /dev/null +++ b/seaweed-block/scripts/run-phase72-frontend-publication-runtime-contract-gate.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +set -euo pipefail + +PRODUCT_ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase72-frontend-publication-runtime-contract-gate}" +SUMMARY="${ARTIFACT_DIR}/phase72-frontend-publication-runtime-contract-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 "phase72_frontend_publication_runtime_contract_status=running" +write_summary "phase72_scope=frontend_publication_runtime_contract" +write_summary "default_frontend_publication_attempts=0" +write_summary "default_failback_attempts=0" +write_summary "default_storage_mutation_allowed=false" + +OPS_PATTERN="TestPhase69SwBlockFrontendPublicationTargetSchema|TestFrontendPublicationExecutorWritesDisabledStatus|TestFrontendPublicationExecutorExecutionPolicyBlocks|TestFrontendPublicationExecutorInvokesRuntimeWhenExplicitlyEnabled|TestFrontendPublicationExecutorRuntimeFailureWritesBlockedStatus|TestFrontendPublicationExecutorRejectsInvalidRuntimeTerminalEvidence|TestHTTPFrontendPublicationRuntimePostsRequestAndDecodesResult|TestHTTPFrontendPublicationRuntimeReturnsHTTPError|TestHTTPFrontendPublicationRuntimeRequiresEndpoint" + +if (cd "${PRODUCT_ROOT}" && go test ./core/ops -run "${OPS_PATTERN}" -count=1 -v) >"${OPS_LOG}" 2>&1; then + write_summary "core_ops_frontend_publication_runtime_tests=pass" +else + write_summary "core_ops_frontend_publication_runtime_tests=fail" + cat "${OPS_LOG}" >&2 || true + exit 1 +fi + +require_log "frontend_publication_schema_enabled_runtime_endpoint" "^--- PASS: TestPhase69SwBlockFrontendPublicationTargetSchema" "${OPS_LOG}" +require_log "default_executor_still_disabled" "^--- PASS: TestFrontendPublicationExecutorWritesDisabledStatus" "${OPS_LOG}" +require_log "execution_policy_blocks_without_enable" "^--- PASS: TestFrontendPublicationExecutorExecutionPolicyBlocks" "${OPS_LOG}" +require_log "explicit_enabled_target_invokes_runtime" "^--- PASS: TestFrontendPublicationExecutorInvokesRuntimeWhenExplicitlyEnabled" "${OPS_LOG}" +require_log "runtime_failure_no_false_publish" "^--- PASS: TestFrontendPublicationExecutorRuntimeFailureWritesBlockedStatus" "${OPS_LOG}" +require_log "runtime_invalid_terminal_evidence_no_false_publish" "^--- PASS: TestFrontendPublicationExecutorRejectsInvalidRuntimeTerminalEvidence" "${OPS_LOG}" +require_log "http_runtime_contract_posts_request" "^--- PASS: TestHTTPFrontendPublicationRuntimePostsRequestAndDecodesResult" "${OPS_LOG}" +require_log "http_runtime_contract_errors_surface" "^--- PASS: TestHTTPFrontendPublicationRuntimeReturnsHTTPError" "${OPS_LOG}" +require_log "http_runtime_contract_requires_endpoint" "^--- PASS: TestHTTPFrontendPublicationRuntimeRequiresEndpoint" "${OPS_LOG}" + +write_summary "frontend_publication_runtime_contract_schema_locked=true" +write_summary "frontend_publication_runtime_endpoint_field=true" +write_summary "frontend_publication_enabled_target_schema=true" +write_summary "frontend_publication_execution_policy_gate=true" +write_summary "frontend_publication_runtime_invoked_only_when_enabled=true" +write_summary "frontend_publication_runtime_failure_no_false_publish=true" +write_summary "frontend_publication_runtime_invalid_terminal_evidence_no_false_publish=true" +write_summary "frontend_publication_attempts=1" +write_summary "frontend_published=true" +write_summary "failback_started=false" +write_summary "storage_mutation_allowed=false" +write_summary "phase72_frontend_publication_runtime_contract_status=ok" diff --git a/seaweed-block/testops/scenarios/frontend-publication-runtime-contract-chain.yaml b/seaweed-block/testops/scenarios/frontend-publication-runtime-contract-chain.yaml new file mode 100644 index 0000000000..1350272285 --- /dev/null +++ b/seaweed-block/testops/scenarios/frontend-publication-runtime-contract-chain.yaml @@ -0,0 +1,131 @@ +# Runner-native Phase 72 gate: frontend publication runtime contract. + +name: frontend-publication-runtime-contract-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: frontend_publication_runtime_contract_gate + actions: + - action: exec + node: m02 + timeout: 7m + cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract && cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract bash scripts/run-phase72-frontend-publication-runtime-contract-gate.sh {{ product_root }}" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^phase72_frontend_publication_runtime_contract_status=ok$" + save_as: phase72_ok + - action: assert_greater + actual: "{{ phase72_ok }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^frontend_publication_runtime_contract_schema_locked=true$" + save_as: schema_locked + - action: assert_greater + actual: "{{ schema_locked }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^frontend_publication_runtime_endpoint_field=true$" + save_as: endpoint_field + - action: assert_greater + actual: "{{ endpoint_field }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^frontend_publication_execution_policy_gate=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 }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^frontend_publication_runtime_invoked_only_when_enabled=true$" + save_as: runtime_invoked_only_when_enabled + - action: assert_greater + actual: "{{ runtime_invoked_only_when_enabled }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^frontend_publication_runtime_failure_no_false_publish=true$" + save_as: no_false_publish + - action: assert_greater + actual: "{{ no_false_publish }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^frontend_publication_runtime_invalid_terminal_evidence_no_false_publish=true$" + save_as: invalid_terminal_no_false_publish + - action: assert_greater + actual: "{{ invalid_terminal_no_false_publish }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^frontend_publication_attempts=1$" + save_as: one_frontend_attempt + - action: assert_greater + actual: "{{ one_frontend_attempt }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^frontend_published=true$" + save_as: frontend_published + - action: assert_greater + actual: "{{ frontend_published }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-summary.txt" + pattern: "^failback_started=false$" + save_as: failback_not_started + - action: assert_greater + actual: "{{ failback_not_started }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase72-frontend-publication-runtime-contract/phase72-frontend-publication-runtime-contract-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 }}-phase72-frontend-publication-runtime-contract" + name: "remote-phases" + ignore_error: true