Split 4 oversized files (503-679 LOC each) into focused units all under 500 LOC: - tech_file_generator.go → +_prompts, +_prompt_builder, +_fallback - hazard_patterns_extended.go → +_extended2.go (HP074-HP102 extracted) - models.go → +_entities.go, +_api.go (enums / DB entities / API types) - completeness.go → +_gates.go (gate definitions extracted) All files remain in package iace. Zero behavior changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
204 lines
8.9 KiB
Go
204 lines
8.9 KiB
Go
package iace
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ============================================================================
|
|
// API Request Types
|
|
// ============================================================================
|
|
|
|
// CreateProjectRequest is the API request for creating a new IACE project
|
|
type CreateProjectRequest struct {
|
|
MachineName string `json:"machine_name" binding:"required"`
|
|
MachineType string `json:"machine_type" binding:"required"`
|
|
Manufacturer string `json:"manufacturer" binding:"required"`
|
|
Description string `json:"description,omitempty"`
|
|
NarrativeText string `json:"narrative_text,omitempty"`
|
|
CEMarkingTarget string `json:"ce_marking_target,omitempty"`
|
|
Metadata json.RawMessage `json:"metadata,omitempty"`
|
|
}
|
|
|
|
// UpdateProjectRequest is the API request for updating an existing project
|
|
type UpdateProjectRequest struct {
|
|
MachineName *string `json:"machine_name,omitempty"`
|
|
MachineType *string `json:"machine_type,omitempty"`
|
|
Manufacturer *string `json:"manufacturer,omitempty"`
|
|
Description *string `json:"description,omitempty"`
|
|
NarrativeText *string `json:"narrative_text,omitempty"`
|
|
CEMarkingTarget *string `json:"ce_marking_target,omitempty"`
|
|
Metadata *json.RawMessage `json:"metadata,omitempty"`
|
|
}
|
|
|
|
// CreateComponentRequest is the API request for adding a component to a project
|
|
type CreateComponentRequest struct {
|
|
ProjectID uuid.UUID `json:"project_id" binding:"required"`
|
|
ParentID *uuid.UUID `json:"parent_id,omitempty"`
|
|
Name string `json:"name" binding:"required"`
|
|
ComponentType ComponentType `json:"component_type" binding:"required"`
|
|
Version string `json:"version,omitempty"`
|
|
Description string `json:"description,omitempty"`
|
|
IsSafetyRelevant bool `json:"is_safety_relevant"`
|
|
IsNetworked bool `json:"is_networked"`
|
|
}
|
|
|
|
// CreateHazardRequest is the API request for creating a new hazard
|
|
type CreateHazardRequest struct {
|
|
ProjectID uuid.UUID `json:"project_id" binding:"required"`
|
|
ComponentID uuid.UUID `json:"component_id" binding:"required"`
|
|
LibraryHazardID *uuid.UUID `json:"library_hazard_id,omitempty"`
|
|
Name string `json:"name" binding:"required"`
|
|
Description string `json:"description,omitempty"`
|
|
Scenario string `json:"scenario,omitempty"`
|
|
Category string `json:"category" binding:"required"`
|
|
SubCategory string `json:"sub_category,omitempty"`
|
|
MachineModule string `json:"machine_module,omitempty"`
|
|
Function string `json:"function,omitempty"`
|
|
LifecyclePhase string `json:"lifecycle_phase,omitempty"`
|
|
HazardousZone string `json:"hazardous_zone,omitempty"`
|
|
TriggerEvent string `json:"trigger_event,omitempty"`
|
|
AffectedPerson string `json:"affected_person,omitempty"`
|
|
PossibleHarm string `json:"possible_harm,omitempty"`
|
|
}
|
|
|
|
// AssessRiskRequest is the API request for performing a risk assessment
|
|
type AssessRiskRequest struct {
|
|
HazardID uuid.UUID `json:"hazard_id" binding:"required"`
|
|
Severity int `json:"severity" binding:"required"`
|
|
Exposure int `json:"exposure" binding:"required"`
|
|
Probability int `json:"probability" binding:"required"`
|
|
Avoidance int `json:"avoidance,omitempty"` // 0=disabled, 1-5 (3=neutral)
|
|
ControlMaturity int `json:"control_maturity" binding:"required"`
|
|
ControlCoverage float64 `json:"control_coverage" binding:"required"`
|
|
TestEvidenceStrength float64 `json:"test_evidence_strength" binding:"required"`
|
|
AcceptanceJustification string `json:"acceptance_justification,omitempty"`
|
|
}
|
|
|
|
// CreateMitigationRequest is the API request for creating a mitigation measure
|
|
type CreateMitigationRequest struct {
|
|
HazardID uuid.UUID `json:"hazard_id" binding:"required"`
|
|
ReductionType ReductionType `json:"reduction_type" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
Description string `json:"description,omitempty"`
|
|
}
|
|
|
|
// CreateVerificationPlanRequest is the API request for creating a verification plan
|
|
type CreateVerificationPlanRequest struct {
|
|
ProjectID uuid.UUID `json:"project_id" binding:"required"`
|
|
HazardID *uuid.UUID `json:"hazard_id,omitempty"`
|
|
MitigationID *uuid.UUID `json:"mitigation_id,omitempty"`
|
|
Title string `json:"title" binding:"required"`
|
|
Description string `json:"description,omitempty"`
|
|
AcceptanceCriteria string `json:"acceptance_criteria,omitempty"`
|
|
Method VerificationMethod `json:"method" binding:"required"`
|
|
}
|
|
|
|
// CreateMonitoringEventRequest is the API request for logging a monitoring event
|
|
type CreateMonitoringEventRequest struct {
|
|
ProjectID uuid.UUID `json:"project_id" binding:"required"`
|
|
EventType MonitoringEventType `json:"event_type" binding:"required"`
|
|
Title string `json:"title" binding:"required"`
|
|
Description string `json:"description,omitempty"`
|
|
Severity string `json:"severity" binding:"required"`
|
|
}
|
|
|
|
// InitFromProfileRequest is the API request for initializing a project from a company profile
|
|
type InitFromProfileRequest struct {
|
|
CompanyProfile json.RawMessage `json:"company_profile" binding:"required"`
|
|
ComplianceScope json.RawMessage `json:"compliance_scope" binding:"required"`
|
|
}
|
|
|
|
// ============================================================================
|
|
// API Response Types
|
|
// ============================================================================
|
|
|
|
// ProjectListResponse is the API response for listing projects
|
|
type ProjectListResponse struct {
|
|
Projects []Project `json:"projects"`
|
|
Total int `json:"total"`
|
|
}
|
|
|
|
// ProjectDetailResponse is the API response for a single project with related entities
|
|
type ProjectDetailResponse struct {
|
|
Project
|
|
Components []Component `json:"components"`
|
|
Classifications []RegulatoryClassification `json:"classifications"`
|
|
CompletenessGates []CompletenessGate `json:"completeness_gates"`
|
|
}
|
|
|
|
// RiskSummaryResponse is the API response for an aggregated risk overview
|
|
type RiskSummaryResponse struct {
|
|
TotalHazards int `json:"total_hazards"`
|
|
NotAcceptable int `json:"not_acceptable,omitempty"`
|
|
VeryHigh int `json:"very_high,omitempty"`
|
|
Critical int `json:"critical"`
|
|
High int `json:"high"`
|
|
Medium int `json:"medium"`
|
|
Low int `json:"low"`
|
|
Negligible int `json:"negligible"`
|
|
OverallRiskLevel RiskLevel `json:"overall_risk_level"`
|
|
AllAcceptable bool `json:"all_acceptable"`
|
|
}
|
|
|
|
// LifecyclePhaseInfo represents a machine lifecycle phase with labels
|
|
type LifecyclePhaseInfo struct {
|
|
ID string `json:"id"`
|
|
LabelDE string `json:"label_de"`
|
|
LabelEN string `json:"label_en"`
|
|
Sort int `json:"sort_order"`
|
|
}
|
|
|
|
// RoleInfo represents an affected person role with labels
|
|
type RoleInfo struct {
|
|
ID string `json:"id"`
|
|
LabelDE string `json:"label_de"`
|
|
LabelEN string `json:"label_en"`
|
|
Sort int `json:"sort_order"`
|
|
}
|
|
|
|
// EvidenceTypeInfo represents an evidence/verification type with labels
|
|
type EvidenceTypeInfo struct {
|
|
ID string `json:"id"`
|
|
Category string `json:"category"`
|
|
LabelDE string `json:"label_de"`
|
|
LabelEN string `json:"label_en"`
|
|
Tags []string `json:"tags,omitempty"`
|
|
Sort int `json:"sort_order"`
|
|
}
|
|
|
|
// ProtectiveMeasureEntry represents a protective measure from the library
|
|
type ProtectiveMeasureEntry struct {
|
|
ID string `json:"id"`
|
|
ReductionType string `json:"reduction_type"`
|
|
SubType string `json:"sub_type,omitempty"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
HazardCategory string `json:"hazard_category,omitempty"`
|
|
Examples []string `json:"examples,omitempty"`
|
|
Tags []string `json:"tags,omitempty"`
|
|
}
|
|
|
|
// ValidateMitigationHierarchyRequest is the request for hierarchy validation
|
|
type ValidateMitigationHierarchyRequest struct {
|
|
HazardID uuid.UUID `json:"hazard_id" binding:"required"`
|
|
ReductionType ReductionType `json:"reduction_type" binding:"required"`
|
|
}
|
|
|
|
// ValidateMitigationHierarchyResponse is the response from hierarchy validation
|
|
type ValidateMitigationHierarchyResponse struct {
|
|
Valid bool `json:"valid"`
|
|
Warnings []string `json:"warnings,omitempty"`
|
|
}
|
|
|
|
// CompletenessGate represents a single gate in the project completeness checklist
|
|
type CompletenessGate struct {
|
|
ID string `json:"id"`
|
|
Category string `json:"category"`
|
|
Label string `json:"label"`
|
|
Required bool `json:"required"`
|
|
Passed bool `json:"passed"`
|
|
Details string `json:"details,omitempty"`
|
|
}
|