Developers / 03
Hazard Model
Data model, sync boundary with the DFD/Asset stores, and the review-workspace UI for the optional safety-analysis tab.
01
Data model
HazardItem(shared/models/hazard-types.ts) — lean; relations stored separately asContributesToRelation/EndangersRelation(aHazardRelationunion), joined by brandedHazardItemIdHazardCombinationType—ANY(OR, default) |ALL(AND) — the Bowtie gate; only meaningful with ≥2 contributing causesHazardImpact(shared/models/hazard-impact.ts) — discriminated union overhuman | environment | infrastructure, each with its own severity scale (SEVERITY_SCALE_BY_TARGET);HumanHarmSeverity = SafetyImpact—"none"(no injury, S0) is a rating, never counted as harm on the asset; environment and infrastructure uselow | medium | high | critical- Asset references on relations are plain
AssetReference.idstrings, not the branded asset id type Project.hazards: HazardData | null—HazardData = { hazards, relations, lastModified, configuration? };nullfor pre-existing / non-safety projects, no migration required- Schema v2 inserted Hazard as its own
PhaseId(id 1) — all later phase ids shifted; every call site references phases viaPhaseId.X, never a bare literal
02
Gating & progress
- Gate flag lives in
ProjectInfoData.safetyRelevant(not a separate settings object), toggled via the Safety Analysis switch in the Overview tab; defaultfalse;requiresHazardAnalysis(tags)(EN 50742, IEC 81001, IEC TR 60601, IEC 63452, CLC/TS 50701) forces it on when the project is opened - Tab visibility: filtered out of
phase-tab-bar's workflow sort when off, with a render-guard + redirect to Overview inworkspace-layoutas a second line of defense PROGRESS_PHASE_IDS/getProgressPhaseIds(safetyRelevant)inphase-types.tsis the single source of truth for which phases count toward the progress bar — Hazard only counts when the toggle is on; Documentation/Audit/Integration are excluded from all workflows
03
Asset creation & the DFD sync boundary
- No separate
AssetStore—dfd.assetsstays the canonical store; asset creation from the Hazard tab goes through a shared pure primitive,shared/services/asset-creation.ts - Bowtie
onSave(draft, sessionAssets)buffers created assets on the tab (pendingCreatedAssets) until autosave folds them intodfd.assetsviaaddCreatedAssets(features/dfd/services/dfd-asset-creation.ts); dialog-cancel discards the buffered assets, no leak - Known sharp edge: the Hazard write path bypasses the normal DFD→Assets sync (
syncFromDFD) unlessworkspace-layout'shandleHazardsUpdateexplicitly re-invokes it afteraddCreatedAssets— two stores (project.dfd.assets/project.assets.assets) exist today, which is the interim state pending a tracked single-source-of-truth consolidation environmentis a 9thAssetGroup(prefixEN), added specifically to give hazard causes/targets outside the DFD (e.g. ambient conditions) somewhere to live
04
Review workspace
hazard-dialog.tsxis a master-detail review workspace, not a single edit form — a sidebar over every hazard, a detail pane with the scope decision, hazard fields, and a Bowtie editorsystemRelevance: "in_scope" | "out_of_scope" | "unknown"is the hazard-level rollup that gates whether a Bowtie needs modeling — it is the coarse, hazard-level counterpart to the still-parked edge-level Security-Safety Independence analysis (Phase 6), vocabulary-compatible with it- Progressive disclosure: hazard fields are always visible; the Bowtie collapses (not disabled) until scope is
in_scope - No Save/Cancel — commit-on-close: OK, Escape, and backdrop click all call a single
commitAndClose; a missing required label closes without persisting
05
Import bridge
- Profile-based, format-agnostic: CSV (
papaparse), XLSX/XLSM/XLS/ODS (SheetJSxlsx), and a native TARAflow-JSON adapter, all registered against oneCanonicalFieldcontract insafety-hazard-importer.ts hazard-bridge.tsmaps legacySafetyHazardrecords into the native graph —affectedPersonsbecomes deduplicated human assets connected via structured, per-roleendangersedges (SEVERITY_TO_HUMAN), deliberately not a single flattened severity value- Unrecognized source columns are retained as
importMeta(provenance), not dropped