Remove pre-1.0 audit and protected request scaffolding

This commit is contained in:
npc0-hue
2026-08-20 23:42:02 +08:00
parent 40b35b05c7
commit a7e2e4c6c0
130 changed files with 526 additions and 3767 deletions
-196
View File
@@ -2,146 +2,6 @@ package domain
import "time"
type CapacityAdmissionState string
const (
CapacityAdmissionAccepted CapacityAdmissionState = "accepted"
CapacityAdmissionDeferred CapacityAdmissionState = "deferred"
CapacityAdmissionDenied CapacityAdmissionState = "denied"
)
type CapacityPressureCode string
const (
CapacityPressureEndpointOffline CapacityPressureCode = "endpoint.offline"
CapacityPressureEndpointStale CapacityPressureCode = "endpoint.stale"
CapacityPressureCapabilityGap CapacityPressureCode = "capability.missing"
CapacityPressureJobLimit CapacityPressureCode = "job.limit"
CapacityPressureQueueLimit CapacityPressureCode = "queue.limit"
CapacityPressureBacklog CapacityPressureCode = "spool.backlog"
)
type CapacityAdmissionRequest struct {
ServerInstanceID string
RunEndpointID string
Capability string
TargetKey string
IdempotencyKey string
}
type CapacityAdmissionDecision struct {
Accepted bool
State CapacityAdmissionState
Reason string
RetryAfterSeconds int
ServerInstanceID string
RunEndpointID string
Capability string
TargetKey string
MaxJobs int
RunningJobs int
QueuedJobs int
PressureCodes []CapacityPressureCode
CheckedAt time.Time
AlertID string
AuditEventID string
}
type EndpointCapacityProjection struct {
RunEndpointID string
DisplayName string
Status RunEndpointStatus
Capabilities []string
MaxJobs int
RunningJobs int
QueuedJobs int
LogBacklogBatches int
ArtifactBacklogChunks int
PressureCodes []CapacityPressureCode
Summary string
LastHeartbeatAt time.Time
LastAdmissionDecision CapacityAdmissionState
LastAdmissionReason string
LastAdmissionCheckedAt time.Time
}
type ProductionCapacitySummary struct {
Endpoints []EndpointCapacityProjection
TotalMaxJobs int
TotalRunningJobs int
TotalQueuedJobs int
ActiveAlerts int
GeneratedAt time.Time
}
type AlertSeverity string
const (
AlertSeverityInfo AlertSeverity = "info"
AlertSeverityWarning AlertSeverity = "warning"
AlertSeverityCritical AlertSeverity = "critical"
)
type AlertState string
const (
AlertStateActive AlertState = "active"
AlertStateAcknowledged AlertState = "acknowledged"
AlertStateResolved AlertState = "resolved"
)
type AlertRecord struct {
ID string
SourceKind string
SourceID string
RuleKey string
Severity AlertSeverity
State AlertState
Title string
Message string
OccurrenceCount int
Retryable bool
RetryAfterSeconds int
LastJobID string
LastAuditEventID string
LastSeenAt time.Time
AcknowledgedBy string
AcknowledgedAt time.Time
ResolvedBy string
ResolvedAt time.Time
ResolutionNote string
CreatedAt time.Time
UpdatedAt time.Time
}
type AlertFilter struct {
State AlertState
SourceKind string
SourceID string
Severity AlertSeverity
}
type AlertAcknowledgeRequest struct {
AlertID string
Note string
}
type AlertResolveRequest struct {
AlertID string
Note string
}
type AlertRetryRequest struct {
AlertID string
IdempotencyKey string
}
type AlertRetryResult struct {
Alert AlertRecord
Decision CapacityAdmissionDecision
Status string
}
type PluginLifecycleState string
const (
@@ -180,8 +40,6 @@ type PluginLifecycleInstallation struct {
Compatibility string
DependencyState DependencyState
JobID string
AlertID string
AuditEventID string
FailureReason string
IdempotencyKey string
CreatedAt time.Time
@@ -206,8 +64,6 @@ type PluginLifecycleRequest struct {
type PluginLifecycleResult struct {
Installation PluginLifecycleInstallation
Job Job
Decision CapacityAdmissionDecision
Alert *AlertRecord
Status string
}
@@ -261,53 +117,6 @@ type AIConfigDiffApprovalResult struct {
Dispatch ServerConfigWriteDispatch
}
func CopyCapacityAdmissionDecision(decision CapacityAdmissionDecision) CapacityAdmissionDecision {
decision.PressureCodes = CopyCapacityPressureCodes(decision.PressureCodes)
return decision
}
func CopyEndpointCapacityProjection(projection EndpointCapacityProjection) EndpointCapacityProjection {
projection.Capabilities = CopyStringSlice(projection.Capabilities)
projection.PressureCodes = CopyCapacityPressureCodes(projection.PressureCodes)
return projection
}
func CopyProductionCapacitySummary(summary ProductionCapacitySummary) ProductionCapacitySummary {
if summary.Endpoints != nil {
summary.Endpoints = append([]EndpointCapacityProjection(nil), summary.Endpoints...)
for i := range summary.Endpoints {
summary.Endpoints[i] = CopyEndpointCapacityProjection(summary.Endpoints[i])
}
}
return summary
}
func CopyCapacityPressureCodes(codes []CapacityPressureCode) []CapacityPressureCode {
if codes == nil {
return nil
}
out := make([]CapacityPressureCode, len(codes))
copy(out, codes)
return out
}
func CopyAlertRecord(alert AlertRecord) AlertRecord { return alert }
func CopyAlertRecords(alerts []AlertRecord) []AlertRecord {
if alerts == nil {
return nil
}
out := make([]AlertRecord, len(alerts))
copy(out, alerts)
return out
}
func CopyAlertRetryResult(result AlertRetryResult) AlertRetryResult {
result.Alert = CopyAlertRecord(result.Alert)
result.Decision = CopyCapacityAdmissionDecision(result.Decision)
return result
}
func CopyPluginLifecycleInstallation(installation PluginLifecycleInstallation) PluginLifecycleInstallation {
return installation
}
@@ -324,11 +133,6 @@ func CopyPluginLifecycleInstallations(installations []PluginLifecycleInstallatio
func CopyPluginLifecycleResult(result PluginLifecycleResult) PluginLifecycleResult {
result.Installation = CopyPluginLifecycleInstallation(result.Installation)
result.Job = CopyJob(result.Job)
result.Decision = CopyCapacityAdmissionDecision(result.Decision)
if result.Alert != nil {
alert := CopyAlertRecord(*result.Alert)
result.Alert = &alert
}
return result
}