feat(agent-os): add OCSF schema converter and sink for CloudEvents tr… #4323
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4323"
general
weight: 0.35
MohammadHaroonAbuomar
Related Issue
No linked issue — see Problem & Solution below.
Problem & Solution
Problem:
Agent Governance Toolkit standardizes on CloudEvents v1.0 for audit, policy, and trace event delivery (e.g.
GovernanceEvent.to_cloudevent(),StdoutGovernanceSink,OTLPGovernanceSink). However, enterprise security data lakes, XDRs, and modern SIEMs (such as Amazon Security Lake, Splunk, Datadog, and IBM QRadar) standardize on the Open Cybersecurity Schema Framework (OCSF). Ingesting raw CloudEvents into these platforms currently requires external, custom ETL pipelines that often drop trace correlation identifiers (traceid,spanid,parentspanid) or lose unmapped governance context.Solution:
This PR introduces native OCSF v1.3.0 schema conversion and a streaming sink to
agent-os:1.
agent_os.ocsf— new module containing:-
cloudevent_to_ocsf: Converts any CloudEvents v1.0 governance or trace envelope into an OCSF v1.3.0 record.- Dynamic classification into standard OCSF classes:
- Class 2001 (Security Finding): Policy violations, blocked tool calls, prompt injection detections, and MCP tool poisoning (
category_uid: 2).- Class 6003 (API Activity): Policy checks, tool invocations, and resource accesses (
category_uid: 6).- Class 3002 (Authorize Session): Agent identity verification, rejections, and trust handshakes (
category_uid: 3).- Full trace correlation preservation: extracts
traceid,spanid,parentspanid, andsessionidinto OCSFmetadata.correlation_uidandobservabilityobjects.- 100% data fidelity: custom and non-standard payload attributes are retained under
unmapped.-
OCSFGovernanceSink: A streaming sink implementingGovernanceEventSinkBasethat outputs newline-delimited JSON (NDJSON), ready for direct forwarding to SIEM collectors or AWS Security Lake.2.
GovernanceEvent.to_ocsf()— direct serialization convenience method added on the immutableGovernanceEventenvelope alongside the existingto_cloudevent()andto_dict().Impact on Your Work
Enables streaming agent governance, policy checks, and trace audit logs directly into OCSF-compliant SIEMs and security data lakes without writing proprietary format converters. Security teams can now correlate agent behavior with enterprise identity and threat logs using standard OCSF queries, with zero data loss and full trace context preserved.
Timeline
None
Alternatives Considered
1. Handling conversion downstream via Logstash / FluentBit plugins — Rejected because downstream log shippers lack semantic domain knowledge of AGT's policy decisions, reasons, and kind enums, leading to lossy conversions.
2. Replacing CloudEvents entirely with OCSF — Rejected because CloudEvents is the established CNCF transport standard across AGT's event bus and broker integrations (Azure Event Grid, EventBridge). Translating CloudEvents to OCSF preserves dual compatibility.
Type of Change
Package(s) Affected
Core & runtime:
Governance & security:
Platform & tooling:
CLI plugins:
Shared / other:
Testing
Unit Testing
Added
agent-governance-python/agent-os/tests/test_ocsf.pywith 8 comprehensive unit tests:| Test | What it covers |
|---|---|
|
test_security_finding_policy_violation| Class 2001 mapping, blocked disposition, failure status, trace IDs ||
test_api_activity_policy_check_allowed| Class 6003 mapping, API operation, request resource, allowed disposition ||
test_authorize_session_identity_verified| Class 3002 mapping and session ID binding ||
test_agentmesh_cloudevent_compatibility| AgentMesh CloudEvent compatibility, custom hashes inunmapped||
test_direct_governance_event_to_ocsf| Direct conversion fromGovernanceEventinstance ||
test_governance_event_method_to_ocsf|GovernanceEvent.to_ocsf()convenience method ||
test_emit_writes_ndjson_to_stream| Multi-line NDJSON output fromOCSFGovernanceSink||
test_processor_fan_out_with_ocsf_sink| Async batch delivery viaGovernanceEventProcessor|Manual Testing
Ran full test suite locally under Python 3.14 on Windows:
Result: 42 passed (34 existing regression tests + 8 new OCSF tests), 0 failures.
Checklist
CHANGELOG.mdunder[Unreleased])Attribution & Prior Art
Prior art / related projects:
AI Assistance
AI tools used: Antigravity (Gemini) was used for scaffolding the OCSF class mappings and unit test cases; all logic, types, and test results were reviewed and verified locally before committing.
IP, Patents, and Licensing
---
Usage Example
OCSF Class Mapping Reference
| GovernanceEventKind | OCSF Class | Class UID |
|---|---|---|
|
POLICY_VIOLATION,TOOL_CALL_BLOCKED,PROMPT_INJECTION_DETECTED,MCP_TOOL_POISONING,CONTENT_VIOLATION,ANOMALY_DETECTED| Security Finding | 2001 ||
IDENTITY_VERIFIED,IDENTITY_REJECTED,ESCALATION_REQUESTED| Authorize Session | 3002 ||
POLICY_CHECK,RESOURCE_ACCESS,CHECKPOINT_CREATED| API Activity | 6003 |Future Work
Follow-up PRs can bring OCSF schema conversion parity to the standalone .NET (
agent-governance-dotnet) and Rust (agent-governance-rust) SDKs.