phase42: add operation layer gate contracts

This commit is contained in:
pingqiu committed 2026-06-14 11:03:07 -07:00
1 parent c95947ab1a
commit fe606bb400
3 files changed
+304 -1

No files matched your search

@@ -605,12 +605,18 @@ Approximate engineering effort if scope remains tight:
- Phase 39 Delete-Safety Status Boundary is closed.
- Phase 40 Operator Production Hardening is closed and is the v0.4 beta release
boundary.
- Active work is Phase 41 Lifecycle Owner Foundation. It is non-mutating:
- Phase 41 Lifecycle Owner Foundation is closed. It is non-mutating:
finalizer add/remove is deferred, while lifecycle-owner dry-run decisions and
delete-safety preconditions are made visible.
- Active work is Phase 42 Lifecycle Owner API / Admission Gate. It must prove
the future lifecycle-owner main-object patch boundary against a real
Kubernetes API/admission surface before Phase 43 can ship finalizer mutation.
- Phase 41-44 are the Operation Layer v0.5 release train: lifecycle-owner
foundation, real API/admission proof, first bounded finalizer mutation, and
delete lifecycle close gate/release.
- The release-train contract is
`internal/docs/ref/operation-layer-v0.5-release-train.md`; the Phase 42 gate
draft is `internal/docs/ref/phase42-lifecycle-owner-api-admission-gate.md`.
- Do not start NVMe ANA parity, rebuild/failback, backup/restore, or mutating
recovery workflows by extending Phase 41. Pick those as separate gated phases
after the Operation Layer v0.5 train closes.
@@ -0,0 +1,119 @@
# Operation Layer v0.5 Release Train
Status: planning contract.
## Purpose
Phase 41-44 are one product train: finish the Kubernetes operation layer before
starting new storage features such as productized returned-replica rebuild,
NVMe ANA parity, or backup/restore.
This train is not an open-ended ops cleanup loop. It has one exit condition:
```text
Seaweed Block can explain and safely gate Kubernetes lifecycle actions through
facts, judgment, action ownership, CRD status, Events, reports, dashboard, QA
evidence, and cleanup verification.
```
## Phase Boundaries
| Phase | Goal | Mutation allowed |
|---|---|---|
| 41 | Lifecycle owner foundation | none |
| 42 | Real API/admission proof for lifecycle-owner patches | test-only |
| 43 | First bounded finalizer mutation | SwBlockVolume finalizer only |
| 44 | Delete lifecycle close gate and release | finalizer only |
## Phase 41: Lifecycle Owner Foundation
Phase 41 defines the control model:
- observer/status writer,
- lifecycle owner,
- executor.
It keeps `operator-status` status/events-only and exposes delete-safety as
status plus dry-run lifecycle-owner action decisions.
Non-claim:
```text
No SwBlockVolume finalizer add/remove.
Delete-safety is guidance, not Kubernetes deletion protection.
```
## Phase 42: Real API / Admission Gate
Phase 42 proves the future lifecycle owner can receive main-object
`patch swblockvolumes` without opening a broad mutation surface.
The hard claim is:
```text
Only finalizer-shaped main-object patches are admitted for the lifecycle-owner
identity. Spec, labels, annotations, ownerReferences, status-through-main,
storage, workload, and host mutations are rejected.
```
Phase 42 may use envtest, a live throwaway cluster, or an equivalent real
apiserver/admission harness. Mock-only tests are not sufficient.
Phase 42 does not ship finalizer mutation in the product controller.
## Phase 43: First Bounded Lifecycle Mutation
Phase 43 can enable the first real mutation if Phase 42 passes:
```text
add/remove block.seaweedfs.com/swblockvolume-protection finalizer
```
Allowed:
- add finalizer on owned `SwBlockVolume`,
- hold deletion when delete-safety is blocked or unknown,
- remove finalizer when delete-safety is clean and fresh,
- emit Events and status for hold/release decisions.
Forbidden:
- cleanup execution,
- data deletion,
- PVC/PV mutation,
- workload mutation,
- storageclass mutation,
- rebuild/failback/promotion/backup/restore.
## Phase 44: Delete Lifecycle Close Gate And Release
Phase 44 validates the release path:
```text
install -> PVC -> status -> delete requested -> blocked/releasable finalizer
behavior -> cleanup evidence -> support bundle -> uninstall zero residue
```
Release claim should stay narrow:
- Kubernetes-native status/events operator foundation.
- Lifecycle-owner finalizer boundary proven.
- Delete-safety and finalizer lifecycle visible and gated.
- No automatic cleanup.
- No productized returned-replica rebuild/failback.
- No backup/restore.
- No NVMe ANA parity.
## After v0.5
After Phase 44, the next feature train can productize one larger data-plane
capability. The recommended first candidate is returned-replica
rebuild/reintegration/failback because the low-level rebuild and returned
replica safety pieces already exist.
That later train must still use the same five-layer standard:
```text
live facts -> judgment -> action owner -> user-visible status/action -> QA gate
```
@@ -0,0 +1,178 @@
# Phase 42 Draft: Lifecycle Owner API / Admission Gate
Status: draft entry plan. Start only after Phase 41 QA sign-off.
## Product Goal
Prove the Kubernetes API boundary required before Seaweed Block ships any
`SwBlockVolume` finalizer mutation.
Phase 39 proved that CRD finalizers cannot be safely bounded with
`swblockvolumes/finalizers` RBAC alone. Phase 41 defined the lifecycle-owner
role and dry-run action contract. Phase 42 must turn that into a real API
proof.
Hard exit statement:
```text
The lifecycle-owner identity can patch exactly the approved finalizer shape on
SwBlockVolume main objects, and cannot patch spec, unrelated metadata, status
through the main object, or any storage/workload resource.
```
## Scope Contract
| In | Out |
|---|---|
| real apiserver/envtest/admission harness | production finalizer controller |
| lifecycle-owner RBAC proof | cleanup executor |
| finalizer-only admission rule or equivalent enforcement | rebuild/failback |
| negative patch matrix | backup/restore |
| audit evidence for accepted/rejected patches | NVMe ANA parity |
Phase 42 should not mutate real user data or ship product finalizer add/remove.
It is a gate phase.
## D1: Harness Choice And Baseline
Goal: choose the enforcement shape before writing the product mutation.
Acceptance:
```text
[ ] choose one harness: envtest, live throwaway cluster, or equivalent
[ ] load real SwBlockVolume CRD schema
[ ] install lifecycle-owner RBAC separate from operator-status
[ ] install admission policy/webhook or equivalent finalizer-only enforcement
[ ] prove operator-status RBAC remains status/events-only
```
Fail if:
```text
mock-only tests are used as the primary proof
operator-status receives main patch on swblockvolumes
```
## D2: Allowed Finalizer Patch
Goal: prove the one intended mutation works.
Allowed patch shape:
```json
{"metadata":{"finalizers":["block.seaweedfs.com/swblockvolume-protection"]}}
```
Acceptance:
```text
[ ] lifecycle-owner can add the Seaweed Block finalizer
[ ] lifecycle-owner can remove the Seaweed Block finalizer
[ ] repeated add/remove is idempotent
[ ] patch preserves spec, labels, annotations, ownerReferences, and status
[ ] audit evidence records request, decision, reason, and observed object diff
```
## D3: Forbidden Main-Object Patches
Goal: prove broad main-object patch permission is effectively confined.
Forbidden patches:
```text
spec changes
status through main object
labels/annotations changes
ownerReferences changes
deletionTimestamp manipulation
foreign finalizer add/remove
mixed finalizer + spec patch
mixed finalizer + unrelated metadata patch
```
Acceptance:
```text
[ ] every forbidden patch is rejected by the real API/admission layer
[ ] rejection reason is stable enough for QA evidence
[ ] the object is unchanged after every rejected patch
```
## D4: Forbidden Resource Mutations
Goal: prove lifecycle-owner does not become a storage/workload mutator.
Forbidden resources:
```text
pods
deployments
persistentvolumeclaims
persistentvolumes
storageclasses
secrets
nodes
csidrivers
csinodes
```
Acceptance:
```text
[ ] kubectl auth can-i or client requests deny create/update/patch/delete
[ ] no product action attempts these mutations
[ ] operator-status permissions are unchanged
```
## D5: Delete-Safety Preconditions Stay External
Goal: prove Phase 42 does not bypass the Phase 41 decision model.
Acceptance:
```text
[ ] clean delete-safety evidence permits finalizer-release intent
[ ] blocked residue rejects finalizer-release intent
[ ] missing/stale cleanup evidence returns unknown
[ ] allowed/rejected/unknown decisions are visible through CRD status/actions
[ ] Phase 42 does not execute cleanup to make the decision pass
```
## D6: Multi-Volume Isolation
Goal: prove admission and action decisions are per object.
Scenario:
```text
A: finalizer patch allowed
B: spec patch rejected
C: blocked delete-safety rejected
D: stale evidence unknown
```
Acceptance:
```text
[ ] A's allowed patch does not affect B/C/D
[ ] B's rejected patch leaves B unchanged
[ ] C/D status decisions do not block A's API proof
[ ] all Events/audit evidence use the correct volume identity
```
## D7: Close Gate
Phase 42 can close only if:
```text
[ ] real API/admission proof is used
[ ] finalizer-shaped add/remove works
[ ] forbidden main-object patches fail
[ ] forbidden resource mutations fail
[ ] operator-status remains status/events-only
[ ] delete-safety decisions remain status/action facts, not cleanup execution
[ ] QA sign-off records that Phase 43 is now eligible to implement the first
real finalizer mutation
```