feat(plugin): add governance release gates
Some checks failed
Go / build (.exe, 386, windows, windows-386) (push) Has been cancelled
Go / build (.exe, amd64, windows, windows-amd64) (push) Has been cancelled
Go / build (.exe, arm64, windows, windows-arm64) (push) Has been cancelled
Go / build (386, freebsd, freebsd-386) (push) Has been cancelled
Go / build (386, linux, linux-386) (push) Has been cancelled
Go / build (386, netbsd, netbsd-386) (push) Has been cancelled
Go / build (386, openbsd, openbsd-386) (push) Has been cancelled
Go / build (386, plan9, plan9-386) (push) Has been cancelled
Go / build (amd64, darwin, darwin-amd64) (push) Has been cancelled
Go / build (amd64, dragonfly, dragonfly-amd64) (push) Has been cancelled
Go / build (amd64, freebsd, freebsd-amd64) (push) Has been cancelled
Go / build (amd64, illumos, illumos-amd64) (push) Has been cancelled
Go / build (amd64, linux, linux-amd64) (push) Has been cancelled
Go / build (amd64, netbsd, netbsd-amd64) (push) Has been cancelled
Go / build (amd64, openbsd, openbsd-amd64) (push) Has been cancelled
Go / build (amd64, plan9, plan9-amd64) (push) Has been cancelled
Go / build (amd64, solaris, solaris-amd64) (push) Has been cancelled
Go / build (arm, 6, linux, linux-armv6) (push) Has been cancelled
Go / build (arm, 7, linux, linux-armv7) (push) Has been cancelled
Go / build (arm, freebsd, freebsd-arm) (push) Has been cancelled
Go / build (arm, netbsd, netbsd-arm) (push) Has been cancelled
Go / build (arm, openbsd, openbsd-arm) (push) Has been cancelled
Go / build (arm, plan9, plan9-arm) (push) Has been cancelled
Go / build (arm64, darwin, darwin-arm64) (push) Has been cancelled
Go / build (arm64, freebsd, freebsd-arm64) (push) Has been cancelled
Go / build (arm64, linux, linux-arm64) (push) Has been cancelled
Go / build (arm64, netbsd, netbsd-arm64) (push) Has been cancelled
Go / build (arm64, openbsd, openbsd-arm64) (push) Has been cancelled
Go / build (loong64, linux, linux-loong64) (push) Has been cancelled
Go / build (mips, linux, linux-mips) (push) Has been cancelled
Go / build (mips64, linux, linux-mips64) (push) Has been cancelled
Go / build (mips64le, linux, linux-mips64le) (push) Has been cancelled
Go / build (mipsle, linux, linux-mipsle) (push) Has been cancelled
Go / build (ppc64, aix, aix-ppc64) (push) Has been cancelled
Go / build (ppc64, linux, linux-ppc64) (push) Has been cancelled
Go / build (ppc64, openbsd, openbsd-ppc64) (push) Has been cancelled
Go / build (ppc64le, linux, linux-ppc64le) (push) Has been cancelled
Go / build (riscv64, freebsd, freebsd-riscv64) (push) Has been cancelled
Go / build (riscv64, linux, linux-riscv64) (push) Has been cancelled
Go / build (riscv64, openbsd, openbsd-riscv64) (push) Has been cancelled
Go / build (s390x, linux, linux-s390x) (push) Has been cancelled
Go / merge-artifacts (push) Has been cancelled
Docker Image / docker (push) Has been cancelled

This commit is contained in:
2026-06-26 12:08:27 +08:00
parent b822993489
commit 629d6d5dbc
17 changed files with 2976 additions and 110 deletions

View File

@@ -53,6 +53,34 @@ const (
RuntimeDisabled = "disabled"
RuntimeDraining = "draining"
PolicyProfileDev = "dev"
PolicyProfileStaging = "staging"
PolicyProfileProd = "prod"
RiskLow = "low"
RiskMedium = "medium"
RiskHigh = "high"
GateSeverityWarning = "warning"
GateSeverityBlocking = "blocking"
GateSeverityInfo = "info"
GovernanceActionEnable = "enable"
GovernanceActionRollback = "rollback"
GovernanceActionPromotion = "promotion_apply"
AdvisoryActionDenylist = "denylist"
AdvisoryActionQuarantine = "quarantine"
AdvisoryActionRevoke = "revoke"
AdvisoryActionMitigate = "mitigate"
ReviewDecisionApproved = "approved"
ReviewDecisionRejected = "rejected"
AdvisoryStatusActive = "active"
AdvisoryStatusRevoked = "revoked"
AdvisoryStatusAcked = "acknowledged"
DefaultPriority = 100
DefaultHandlerTimeout = 3 * time.Second
DefaultManifestMaxBytes = 256 * 1024
@@ -258,6 +286,196 @@ type SecretRecord struct {
UpdatedAt int64 `json:"updated_at"`
}
type PolicySnapshot struct {
Profile string `json:"profile"`
WarningOverrideTTLSeconds int64 `json:"warning_override_ttl_seconds"`
ReviewRequiredRisk string `json:"review_required_risk"`
WarnBenchmarkRegression float64 `json:"warn_benchmark_regression"`
BlockBenchmarkRegression float64 `json:"block_benchmark_regression"`
CreatedAt int64 `json:"created_at"`
}
type GovernanceIssue struct {
Code string `json:"code"`
Severity string `json:"severity"`
Message string `json:"message"`
PluginID string `json:"plugin_id,omitempty"`
ArtifactID string `json:"artifact_id,omitempty"`
Details map[string]any `json:"details,omitempty"`
}
type GovernanceDecision struct {
OK bool `json:"ok"`
Action string `json:"action"`
Profile string `json:"profile"`
RiskLevel string `json:"risk_level"`
PolicyHash string `json:"policy_hash"`
ReviewRequired bool `json:"review_required"`
WarningOverrideUsed bool `json:"warning_override_used"`
Issues []GovernanceIssue `json:"issues"`
Checks []GovernanceIssue `json:"checks"`
CreatedAt int64 `json:"created_at"`
}
type ConflictAnalysis struct {
OK bool `json:"ok"`
Issues []GovernanceIssue `json:"issues"`
Plan DispatchPlan `json:"plan"`
CreatedAt int64 `json:"created_at"`
}
type PreflightCheck struct {
Code string `json:"code"`
Severity string `json:"severity"`
Message string `json:"message"`
Details map[string]any `json:"details,omitempty"`
}
type PreflightResult struct {
OK bool `json:"ok"`
Profile string `json:"profile"`
Checks []PreflightCheck `json:"checks"`
CreatedAt int64 `json:"created_at"`
}
type GovernanceStatus struct {
Decision GovernanceDecision `json:"decision"`
Policy PolicySnapshot `json:"policy"`
Reviews []ReviewRecord `json:"reviews"`
WarningOverrides []WarningOverrideRecord `json:"warning_overrides"`
Preflights []PreflightRecord `json:"preflights"`
Benchmarks []BenchmarkRecord `json:"benchmarks"`
Advisories []AdvisoryRecord `json:"advisories"`
Conflicts ConflictAnalysis `json:"conflicts"`
}
type ReviewRecord struct {
ID int64 `json:"id"`
PluginID string `json:"plugin_id"`
ArtifactID string `json:"artifact_id"`
Profile string `json:"profile"`
RiskLevel string `json:"risk_level"`
ConfigHash string `json:"config_hash"`
ScopeHash string `json:"scope_hash"`
RolloutHash string `json:"rollout_hash"`
RuntimeLimitsHash string `json:"runtime_limits_hash"`
FeaturesHash string `json:"features_hash"`
PolicyHash string `json:"policy_hash"`
Decision string `json:"decision"`
Notes string `json:"notes"`
ReviewedBy string `json:"reviewed_by"`
CreatedAt int64 `json:"created_at"`
}
type WarningOverrideRecord struct {
ID int64 `json:"id"`
PluginID string `json:"plugin_id"`
ArtifactID string `json:"artifact_id"`
Profile string `json:"profile"`
Action string `json:"action"`
PolicyHash string `json:"policy_hash"`
Reason string `json:"reason"`
CreatedBy string `json:"created_by"`
ExpiresAt int64 `json:"expires_at"`
CreatedAt int64 `json:"created_at"`
}
type AdvisoryRecord struct {
ID int64 `json:"id"`
AdvisoryID string `json:"advisory_id"`
Status string `json:"status"`
Action string `json:"action"`
ArtifactSHA256 string `json:"artifact_sha256"`
PluginID string `json:"plugin_id"`
VersionRange string `json:"version_range"`
DependencyName string `json:"dependency_name"`
DependencyRange string `json:"dependency_range"`
RecommendedAction string `json:"recommended_action"`
FixedVersion string `json:"fixed_version"`
Mitigation string `json:"mitigation"`
CreatedBy string `json:"created_by"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
type PreflightRecord struct {
ID int64 `json:"id"`
PluginID string `json:"plugin_id"`
ArtifactID string `json:"artifact_id"`
Profile string `json:"profile"`
Status string `json:"status"`
ResultJSON string `json:"result_json"`
CreatedBy string `json:"created_by"`
CreatedAt int64 `json:"created_at"`
}
type BenchmarkRecord struct {
ID int64 `json:"id"`
PluginID string `json:"plugin_id"`
ArtifactID string `json:"artifact_id"`
Profile string `json:"profile"`
BenchmarkProfile string `json:"benchmark_profile"`
P95MS float64 `json:"p95_ms"`
P99MS float64 `json:"p99_ms"`
ErrorRate float64 `json:"error_rate"`
ActiveProxyCapacity int64 `json:"active_proxy_capacity"`
BaselineDiff float64 `json:"baseline_diff"`
CreatedBy string `json:"created_by"`
CreatedAt int64 `json:"created_at"`
}
type GovernanceReviewRequest struct {
ArtifactID string `json:"artifact_id"`
Profile string `json:"profile"`
Decision string `json:"decision"`
Notes string `json:"notes"`
}
type WarningOverrideRequest struct {
ArtifactID string `json:"artifact_id"`
Profile string `json:"profile"`
Action string `json:"action"`
Reason string `json:"reason"`
TTLSeconds int64 `json:"ttl_seconds"`
}
type PreflightRequest struct {
ArtifactID string `json:"artifact_id"`
Profile string `json:"profile"`
Action string `json:"action"`
ConfigJSON string `json:"config_json"`
}
type SelfTestRequest struct {
ArtifactID string `json:"artifact_id"`
Profile string `json:"profile"`
}
type AdvisoryRequest struct {
AdvisoryID string `json:"advisory_id"`
Status string `json:"status"`
Action string `json:"action"`
ArtifactSHA256 string `json:"artifact_sha256"`
PluginID string `json:"plugin_id"`
VersionRange string `json:"version_range"`
DependencyName string `json:"dependency_name"`
DependencyRange string `json:"dependency_range"`
RecommendedAction string `json:"recommended_action"`
FixedVersion string `json:"fixed_version"`
Mitigation string `json:"mitigation"`
}
type BenchmarkRequest struct {
ArtifactID string `json:"artifact_id"`
Profile string `json:"profile"`
BenchmarkProfile string `json:"benchmark_profile"`
P95MS float64 `json:"p95_ms"`
P99MS float64 `json:"p99_ms"`
ErrorRate float64 `json:"error_rate"`
ActiveProxyCapacity int64 `json:"active_proxy_capacity"`
BaselineDiff float64 `json:"baseline_diff"`
}
type ProxyConnectionSummary struct {
ID uint64 `json:"id"`
PluginID string `json:"plugin_id"`