Cerbi.CerbiShield.Contracts
0.2.0
dotnet add package Cerbi.CerbiShield.Contracts --version 0.2.0
NuGet\Install-Package Cerbi.CerbiShield.Contracts -Version 0.2.0
<PackageReference Include="Cerbi.CerbiShield.Contracts" Version="0.2.0" />
<PackageVersion Include="Cerbi.CerbiShield.Contracts" Version="0.2.0" />
<PackageReference Include="Cerbi.CerbiShield.Contracts" />
paket add Cerbi.CerbiShield.Contracts --version 0.2.0
#r "nuget: Cerbi.CerbiShield.Contracts, 0.2.0"
#:package Cerbi.CerbiShield.Contracts@0.2.0
#addin nuget:?package=Cerbi.CerbiShield.Contracts&version=0.2.0
#tool nuget:?package=Cerbi.CerbiShield.Contracts&version=0.2.0
Cerbi.Contracts
Canonical scoring contracts shared between logger adapters, the Scoring API, and any analytics services that need to understand scoring payloads.
Installation
Add the package reference (after publishing to your feed) to any producer or consumer that needs to understand scoring payloads:
<ItemGroup>
<PackageReference Include="Cerbi.CerbiShield.Contracts" Version="0.1.0" />
</ItemGroup>
Usage
Reference the DTOs when producing payloads and keep ContractVersions in sync so consumers can branch safely:
using Cerbi.Contracts.Contracts;
var payload = new ScoringEventDto
{
SchemaVersion = ContractVersions.ScoringEventSchemaVersion,
AppName = "ScoringWorker",
TimestampUtc = DateTime.UtcNow,
Score = new ScoreBreakdownDto { Overall = 88 }
};
var envelope = new ScoringQueueEnvelopeDto
{
EnvelopeVersion = ContractVersions.ScoringEnvelopeVersion,
EnqueuedUtc = DateTime.UtcNow,
Payload = payload
};
Emit the DTOs as JSON using the exact property names defined in the contracts so downstream analytics services can deserialize reliably.
JSON serialization rules
- Payloads use the property names defined in the DTOs; do not rely on runtime naming policies to rename fields.
- If a service enforces
camelCaseserialization, apply explicitJsonPropertyNameattributes locally so the JSON produced matches these contract names. - Nullable properties must be emitted as
nullrather than dropped whenever the value is unknown. - All timestamps represent UTC instants using ISO-8601 strings.
- The queue envelope always sets
MessageTypeto "scoring-event" and includesEnvelopeVersionfor forward compatibility.
Contract reference
| DTO | Key properties |
|---|---|
ScoringEventDto |
SchemaVersion, TenantId, AppName, optional Environment, Runtime, CorrelationId, LogId, GovernanceProfile, GovernanceMode, LogLevel, Score, Violations, and GovernanceFlags |
ScoringQueueEnvelopeDto |
EnvelopeVersion, constant MessageType, producer metadata, and the scoring payload |
ScoreBreakdownDto |
Optional numeric buckets for Overall, Governance, and Safety |
ViolationDto |
Optional RuleId, Code, Field, Severity, and Message annotations |
GovernanceFlagsDto |
GovernanceRelaxed indicates whether mitigations were applied |
ContractVersions |
Canonical version integers for schema/envelope coordination |
Versioning
ContractVersions.ScoringEventSchemaVersionandContractVersions.ScoringEnvelopeVersionare the canonical integers to bump when the payload schema or envelope changes.- Producers should populate
ScoringEventDto.SchemaVersionandScoringQueueEnvelopeDto.EnvelopeVersionwith these constants so consumers can branch safely.
Breaking changes
- Any DTO rename, removal, or property shape change requires bumping the relevant constant in
ContractVersions. - Update the contract-lock tests to pin the serialized JSON property names and version fields before publishing.
- Communicate version bumps to all producers/consumers and republish the package
Cerbi.CerbiShield.Contracts.
Testing
Run dotnet test tests/Cerbi.Contracts.Tests/Cerbi.Contracts.Tests.csproj to validate the DTO defaults and round-trip behavior before publishing a package.
| 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 is compatible. 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 is compatible. 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Cerbi.CerbiShield.Contracts:
| Package | Downloads |
|---|---|
|
Cerbi.MEL.Governance
Real-time governance enforcement for Microsoft.Extensions.Logging (MEL) using the Cerbi validation engine. |
GitHub repositories
This package is not used by any popular GitHub repositories.