Safety Incident Learning Assistant
Outcome
Turn safety incidents, near misses, and observations into transferable learning by clustering causal patterns across sites and linking them to the standards and permits that should have prevented them, with HSE approval before actions are issued.
| Portfolio attribute | Value |
|---|---|
| Primary persona | HSE specialist |
| Primary aggregate | SafetyLearningCase |
| Cosmos DB containers | 2 |
| Grounding data | incidents, observations, permits, standards |
| Development estimate | USD 60-220 monthly dev estimate |
| Runtime options | Python FastAPI and C# ASP.NET Core |
Productivity hypothesis
These measures reflect the workflow, evidence, decision boundary, and industry risk for this use case.
| Impact type | Measure | Conservative internal assumption | Customer measurement |
|---|---|---|---|
| Productivity | First-pass acceptance | 5-12 percentage-point improvement | assisted percentage accepted without material rework - baseline percentage accepted without material rework |
| Quality or risk | Rework rate | 5-10% reduction | (baseline reopened, corrected, or repeated task rate - assisted rate) / baseline rate * 100 |
Important: Conservative internal pilot assumptions only; not public benchmarks, commitments, or expected customer results. Validate against a comparable baseline or matched control cohort with mandatory human review.
Rationale: HSE teams can produce more complete learning summaries with fewer correction loops while retaining safety authority.
Pilot guardrail: Do not make safety determinations; cite incidents, observations, permits, and standards and expose conflicts.
Customer validation plan
- Baseline the current workflow with representative users and tasks.
- Run the accelerator on the same task mix with human review retained.
- Measure first-pass acceptance and rework rate with the documented formulas.
- Replace internal assumptions with customer-observed results before a business case.
Why Azure Cosmos DB
This AI solution needs an operational data plane, not only a vector index:
- Hybrid vector and full-text retrieval combines semantic recall with exact identifiers, codes, names, and domain language.
- Hierarchical partition keys and metadata predicates keep tenant and domain boundaries in the normal query path.
- Operational JSON, source chunks, workflow and agent state, feedback, and audit records remain together for low-latency reads and governed writes.
- Change feed reacts to source and operational updates without polling.
- Autoscale throughput, configurable consistency, and multi-region distribution support variable demand and enterprise availability.
Domain workflow

| Stage | Actor | Input → output | Approval |
|---|---|---|---|
| 1. Capture the incident or observation | Field worker or supervisor | Incident report, near miss, or hazard observation → Structured record with activity and energy source | Policy controlled |
| 2. Classify severity and control failure | Classification agent | Event narrative and permit record → Actual and potential severity with failed control category | Policy controlled |
| 3. Cluster causal patterns across sites | Pattern analysis agent | Historic incidents and observations → Causal themes and recurrence evidence | Policy controlled |
| 4. Map themes to standards and controls | Standards mapping agent | Causal themes and safety standard clauses → Gap analysis between expected and actual controls | Policy controlled |
| 5. Approve and issue learning actions | HSE manager | Proposed actions with target sites → Issued actions with verification plans | Human required |
Technical architecture

Cosmos DB data model
| Container | Hierarchical partition key | Documents | Search paths |
|---|---|---|---|
safetyLearningCases | /tenantId, /operatingSiteId | SafetyLearningCase, IncidentReport, SafetyObservation, PermitRecord, LearningAction | /eventNarrativeVectorEmbedding, /observationVectorEmbedding, /actionVectorEmbedding, /eventNarrativeVector, /observationVector, /actionVector |
safetyStandardsLibrary | /tenantId, /standardId | SafetyStandardClause | /clauseVectorEmbedding, /clauseVector |
Query contract
| Query | Container | Scope | Purpose |
|---|---|---|---|
| Site learning case assembly | safetyLearningCases | single-partition | Read the case with its incidents, observations, and permits in one site partition query. |
| High-potential near miss scan | safetyLearningCases | cross-partition-bounded | Bounded cross-partition control-plane query: surface low-consequence events whose potential severity was severe. It cannot carry the second partition key because learning value comes precisely from comparing near misses across sites, so it runs as a tenant-scoped scheduled sweep off the interactive path, bounded by near-miss classifications inside a 90-day occurredUtc window, executed with MaxItemCount paging and continuation tokens. |
| Recurring hazard by activity | safetyLearningCases | single-partition | Count observations by hazard category for a specific high-risk activity type. |
| Open action verification | safetyLearningCases | cross-partition-bounded | Bounded cross-partition control-plane query: list issued learning actions whose verification is still outstanding. It cannot carry the second partition key because the HSE assurance report is a multi-site compliance view, so it runs as a tenant-scoped scheduled sweep off the interactive path, bounded by issued actions with no verifiedUtc inside the 60-day closure target, executed with MaxItemCount paging and continuation tokens. |
Python and C# services route each document type to its declared container and hierarchical partition key. ETag-based writes protect mutable aggregates, while append-only records and bounded cross-partition queries preserve scale.
Azure deployment

Clone the source repository, authenticate with Azure, and run:
Set-Location accelerators/oil-gas-mining/safety-incident-learning-assistant
az login
./Deploy.ps1 -Runtime python -Location eastus2
Change python to csharp to deploy the .NET implementation.
Explore the implementation
- Launch signed-in demo
- Implementation article
- Domain data model
- Workflow and API contract
- Python application
- C# application
- Domain container Bicep
- Platform Bicep
- Cost and configuration
- Source repository