Cerbi.Governance.Runtime
1.1.7
dotnet add package Cerbi.Governance.Runtime --version 1.1.7
NuGet\Install-Package Cerbi.Governance.Runtime -Version 1.1.7
<PackageReference Include="Cerbi.Governance.Runtime" Version="1.1.7" />
<PackageVersion Include="Cerbi.Governance.Runtime" Version="1.1.7" />
<PackageReference Include="Cerbi.Governance.Runtime" />
paket add Cerbi.Governance.Runtime --version 1.1.7
#r "nuget: Cerbi.Governance.Runtime, 1.1.7"
#:package Cerbi.Governance.Runtime@1.1.7
#addin nuget:?package=Cerbi.Governance.Runtime&version=1.1.7
#tool nuget:?package=Cerbi.Governance.Runtime&version=1.1.7
Cerbi.Governance.Runtime
🛡️ Real-time governance enforcement & scoring for structured logging in .NET
Cerbi.Governance.Runtime validates structured log records against Cerbi governance profiles at runtime, annotates them, computes optional governance score impact, and (optionally) ships compact score events asynchronously to CerbiShield.
Added Capabilities (Scoring & Shipping)
Runtime Scoring
When profile Scoring.Enabled = true:
- Violations converted to impact via severity weights (defaults: Info=0.5, Warn=2.0, Error=5.0).
- Overrides via
WeightsBySeverity. - Plugin impacts multiplied by
PluginWeights[ruleId]when present (default multiplier 1.0). - Relaxed events (
GovernanceRelaxed = true+ profileAllowRelax) force impact to 0 but remain tagged.
Annotated keys:
GovernanceScoreImpact(double)GovernanceScoringVersion(optional)- Existing:
GovernanceViolations,GovernanceProfileUsed,GovernanceMode,GovernanceEnforced,GovernanceRelaxed.
Score Shipping (Non-Blocking)
Configure ScoreShippingOptions + initialize:
var shipOpts = new ScoreShippingOptions {
Enabled = true,
LicenseAllowsScoring = true,
Endpoint = "https://tenant/api/governance/scores",
BatchSize = 50,
FlushInterval = TimeSpan.FromSeconds(5)
};
var shipper = new ScoreShipper(shipOpts);
LoggerGovernanceExtensions.InitializeScoreShipping(shipOpts, shipper);
Channel-based batching ensures logging hot path is not blocked.
Score event model (GovernanceScoreEvent) includes: AppName, Environment, Timestamp, ScoreImpact, GovernanceRelaxed, Violations[].
Governance JSON Example with Scoring
A simplified example profile for an Orders domain:
{
"EnforcementMode": "Strict",
"LoggingProfiles": {
"Orders": {
"FieldSeverities": { "userId": "Required", "password": "Forbidden" },
"Scoring": {
"Enabled": true,
"WeightsBySeverity": { "Error": 5, "Warn": 2 },
"PluginWeights": { "plugin.teamid.required": 2.0 },
"Version": "1.0"
},
"AllowRelax": true
}
}
}
Profiles are usually authored and versioned via Cerbi.Governance.Core schema and surfaced in CerbiShield.
Usage
Manual Validation (In-Place)
using Cerbi.Governance.Runtime;
using Cerbi.Governance.Core.Models;
var validator = new RuntimeGovernanceValidator(
isEnabled: () => true,
profileName: "Orders",
source: new FileGovernanceSource("cerbi_governance.json"));
var record = new Dictionary<string, object?>
{
["userId"] = "abc123",
["Status"] = "Failed"
};
validator.ValidateInPlace(record);
// record now includes:
// - GovernanceProfileUsed
// - GovernanceEnforced
// - GovernanceMode
// - GovernanceViolations (if any)
The record stays fully usable as a standard structured log object — just with extra governance metadata attached.
ILogger Extension Usage
You can wire the validator into your existing ILogger pipeline:
// Example signature; actual extensions live in LoggerGovernanceExtensions
logger.LogInformation(validator, "Processing order {OrderId}", Guid.NewGuid().ToString());
The extension will:
- Apply runtime governance using the configured profile.
- Enrich the log with governance metadata and environment context.
- Forward the resulting structured log to whatever sinks you already use (Serilog, NLog, OTEL exporters, Seq, Loki, ELK/OpenSearch, Fluentd, etc.).
Environment Metadata
LoggerGovernanceExtensions can automatically enrich logs with environment metadata, including:
ApplicationId- From
CERBI_APP_ID - Default:
"MyApp"
- From
InstanceId- From machine name (host identifier)
Region- From
CLOUD_REGION - Default:
"unknown-region"
- From
CloudProvider- Inferred as one of:
AWS,GCP,Azure, orOnPrem(best-effort heuristic)
- Inferred as one of:
This enrichment is designed for downstream correlation in systems like Loki, Seq, Elastic/OpenSearch, Graylog, VictoriaLogs, or OTEL-backed pipelines.
Relaxation Mode
Sometimes you want to temporarily bypass strict governance (e.g., debugging or emergencies) but still record that this happened.
Profiles with AllowRelax: true let producers set GovernanceRelaxed = true.
In that case:
- Strict enforcement can be skipped.
- The record is still tagged with governance metadata, such as:
{
"GovernanceRelaxed": true,
"GovernanceEnforced": false,
"GovernanceProfileUsed": "Orders"
}
This allows CerbIQ / CerbiSense and your auditors to see where and when governance was relaxed.
Performance Notes
Cerbi.Governance.Runtime is built with high-throughput services in mind:
- Uses
stackallocfor required-field tracking where appropriate. - Caches compiled profile rules for faster evaluation.
- Avoids reflection unless topic inference requires it.
- Performs in-place mutation to minimize extra allocations.
The intent is to keep governance overhead low enough to use on every log event in high-volume systems.
Extensibility
The runtime engine is source-agnostic. Implement IRuntimeGovernanceSource to load governance profiles from wherever you like (files, blob storage, feature-flag system, HTTP API, etc.):
public interface IRuntimeGovernanceSource
{
CerbiGovernance? Load();
DateTime GetLastUpdatedUtc();
}
Provided implementation:
FileGovernanceSource– loads from a local JSON file and uses timestamp polling for hot reload.
Implement IRuntimeGovernancePlugin to contribute PluginImpactResult items for inline scoring.
License
MIT
Part of CerbiSuite – Unified Logging Governance.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Cerbi.Governance.Core (>= 1.0.2)
- Microsoft.Extensions.Logging (>= 9.0.5)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Cerbi.Governance.Runtime:
| Package | Downloads |
|---|---|
|
CerbiStream
CerbiStream.Logging - Secure, Scalable, and Standardized Logging for Modern Applications. |
|
|
Cerbi.MEL.Governance
Real-time governance enforcement for Microsoft.Extensions.Logging (MEL) using the Cerbi validation engine. |
|
|
Cerbi.Serilog.GovernanceAnalyzer
Serilog governance analyzer plugin: runtime validation, filtering, enrichment, live reload, correlation, relaxed diagnostics, and high-throughput score shipping with ArrayPool optimizations. Supports .NET 9.0+ |
|
|
Cerbi.Serilog.Governance
Serilog plugin that enforces Cerbi governance at runtime. Provides filtering to block non-compliant logs and enrichment to tag governance metadata. |
GitHub repositories
This package is not used by any popular GitHub repositories.