Restore commercial monitored-system admission hook contract

This commit is contained in:
rcourtman
2026-05-06 18:04:59 +01:00
parent aeede4fb2f
commit df71bcdf09
3 changed files with 40 additions and 1 deletions
@@ -0,0 +1,24 @@
package extensions
// MonitoredSystemAdmissionInput describes the counted-system state that a
// commercial runtime can use to decide whether adding a candidate should be
// admitted.
type MonitoredSystemAdmissionInput struct {
Current int
Additional int
Limit int
UsageAvailable bool
UsageUnavailableReason string
CandidateCountsTowardCap bool
}
// MonitoredSystemAdmissionDecision is the runtime admission decision returned
// by commercial policy hooks.
type MonitoredSystemAdmissionDecision struct {
Current int
Additional int
Limit int
UsageAvailable bool
UsageUnavailableReason string
Exceeded bool
}
+7 -1
View File
@@ -97,6 +97,11 @@ type BusinessHooks struct {
// CreateAlertAnalyzer creates the premium alert-triggered analyzer.
// Returns nil in OSS. Enterprise provides a concrete implementation.
CreateAlertAnalyzer func(deps aicontracts.AlertAnalyzerDeps) aicontracts.AlertAnalyzer
// ResolveMonitoredSystemAdmissionPolicy lets commercial runtimes own
// monitored-system admission policy while the public server owns inventory
// projection and the shared API contract.
ResolveMonitoredSystemAdmissionPolicy func(context.Context, extensions.MonitoredSystemAdmissionInput) extensions.MonitoredSystemAdmissionDecision
}
var (
@@ -122,7 +127,8 @@ func runtimeIdentityForBusinessHooks(h BusinessHooks) pkglicensing.RuntimeIdenti
h.CreateRemediationEngine != nil ||
h.CreateInvestigationStore != nil ||
h.CreateInvestigationOrchestrator != nil ||
h.CreateAlertAnalyzer != nil {
h.CreateAlertAnalyzer != nil ||
h.ResolveMonitoredSystemAdmissionPolicy != nil {
return pkglicensing.ProRuntimeIdentity()
}
return pkglicensing.CommunityRuntimeIdentity()
+9
View File
@@ -55,6 +55,15 @@ func TestRuntimeIdentityForBusinessHooks(t *testing.T) {
if got.Build != pkglicensing.RuntimeBuildPro {
t.Fatalf("enterprise hooks runtime build=%q, want pro", got.Build)
}
got = runtimeIdentityForBusinessHooks(BusinessHooks{
ResolveMonitoredSystemAdmissionPolicy: func(context.Context, extensions.MonitoredSystemAdmissionInput) extensions.MonitoredSystemAdmissionDecision {
return extensions.MonitoredSystemAdmissionDecision{}
},
})
if got.Build != pkglicensing.RuntimeBuildPro {
t.Fatalf("commercial admission hook runtime build=%q, want pro", got.Build)
}
}
func TestPerformAutoImport_Success(t *testing.T) {