feat(iace): Customer-Standard-Reuse across customer's prior projects
CI / detect-changes (push) Successful in 10s
CI / guardrail-integrity (push) Has been skipped
CI / branch-name (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / validate-canonical-controls (push) Successful in 14s
CI / loc-budget (push) Failing after 19s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / test-go (push) Successful in 47s
CI / nodejs-build (push) Successful in 2m46s
CI / iace-gt-coverage (push) Successful in 28s
CI / test-python-backend (push) Has been skipped
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
CI / detect-changes (push) Successful in 10s
CI / guardrail-integrity (push) Has been skipped
CI / branch-name (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / validate-canonical-controls (push) Successful in 14s
CI / loc-budget (push) Failing after 19s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / test-go (push) Successful in 47s
CI / nodejs-build (push) Successful in 2m46s
CI / iace-gt-coverage (push) Successful in 28s
CI / test-python-backend (push) Has been skipped
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
[migration-approved] Task #22. The IACE module is used by a single Maschinenhersteller, but their plants land at many different end customers. When the safety expert commissions the second or third plant at the same customer, whole classes of mitigations (company-wide PPE rules, locked-out energy isolation, customer-standard signage) are already in place there — but rediscovered from scratch every project. Migration 031: iace_projects.customer_name TEXT + partial index. The customer is stored as a plain text field rather than a normalised iace_customers table (option A from the design discussion). A proper customer-management screen can promote this to a FK later without data loss. Backend store_customer_standards.go: - ListCustomerStandardSuggestions(projectID, includeVerified) collects mitigations from all non-archived prior projects sharing the same tenant_id AND case-insensitive customer_name. Aggregates by mitigation.name (since same-named measures from different prior projects collapse into one suggestion) and surfaces: • source_project_count + source_project_names • is_customer_standard / has_verified_instances flags includeVerified=false → strictly is_customer_standard=true includeVerified=true → also status='verified' - ImportCustomerStandardSuggestion(projectID, name): for every prior (mitigation.name → hazard.name) pairing, finds matching hazards in the current project (by name) and ensures a customer-standard mitigation exists. New rows via CreateMitigation (idempotent through the UNIQUE(hazard_id, name) from migration 030); existing rows are flipped to is_relevant=true + is_customer_standard=true + status='verified' via UPDATE. Routes: GET /api/v1/iace/projects/:id/customer-standards?include_verified= POST /api/v1/iace/projects/:id/customer-standards/import body {name} Frontend: - New page /sdk/iace/[projectId]/customer-standards with: • empty-state hint pointing to Auftrag → Kundenname • per-suggestion checkbox + per-row Übernehmen button • bulk "N übernehmen" button • toggle "Auch verifizierte einbeziehen" widening the pool • per-suggestion source_project_count + status badges - Sidebar item "Kundenstandards" (building icon) placed between Verifikation and Nachweise. - Order-page now mirrors Auftraggeber.Firmenname into the top-level customer_name column on save, so the Reuse feature is fed automatically without a separate input field. The same expert effect from migration 029's is_customer_standard flag — "I already know it's covered, no evidence needed" — now becomes a cross-project asset rather than a per-project annotation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ func (s *Store) CreateProject(ctx context.Context, tenantID uuid.UUID, req Creat
|
||||
MachineName: req.MachineName,
|
||||
MachineType: req.MachineType,
|
||||
Manufacturer: req.Manufacturer,
|
||||
CustomerName: req.CustomerName,
|
||||
Description: req.Description,
|
||||
NarrativeText: req.NarrativeText,
|
||||
Status: ProjectStatusDraft,
|
||||
@@ -35,19 +36,19 @@ func (s *Store) CreateProject(ctx context.Context, tenantID uuid.UUID, req Creat
|
||||
_, err := s.pool.Exec(ctx, `
|
||||
INSERT INTO iace_projects (
|
||||
id, tenant_id, parent_project_id, machine_name, machine_type, manufacturer,
|
||||
description, narrative_text, status, ce_marking_target,
|
||||
customer_name, description, narrative_text, status, ce_marking_target,
|
||||
completeness_score, risk_summary, triggered_regulations, metadata,
|
||||
created_at, updated_at, archived_at
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6,
|
||||
$7, $8, $9, $10,
|
||||
$11, $12, $13, $14,
|
||||
$15, $16, $17
|
||||
$7, $8, $9, $10, $11,
|
||||
$12, $13, $14, $15,
|
||||
$16, $17, $18
|
||||
)
|
||||
`,
|
||||
project.ID, project.TenantID, project.ParentProjectID,
|
||||
project.MachineName, project.MachineType, project.Manufacturer,
|
||||
project.Description, project.NarrativeText, string(project.Status), project.CEMarkingTarget,
|
||||
project.CustomerName, project.Description, project.NarrativeText, string(project.Status), project.CEMarkingTarget,
|
||||
project.CompletenessScore, nil, project.TriggeredRegulations, project.Metadata,
|
||||
project.CreatedAt, project.UpdatedAt, project.ArchivedAt,
|
||||
)
|
||||
@@ -67,7 +68,7 @@ func (s *Store) GetProject(ctx context.Context, id uuid.UUID) (*Project, error)
|
||||
err := s.pool.QueryRow(ctx, `
|
||||
SELECT
|
||||
id, tenant_id, parent_project_id, machine_name, machine_type, manufacturer,
|
||||
description, narrative_text, status, ce_marking_target,
|
||||
COALESCE(customer_name, ''), description, narrative_text, status, ce_marking_target,
|
||||
completeness_score, risk_summary, triggered_regulations, metadata,
|
||||
created_at, updated_at, archived_at
|
||||
FROM iace_projects WHERE id = $1
|
||||
@@ -97,7 +98,7 @@ func (s *Store) ListProjects(ctx context.Context, tenantID uuid.UUID) ([]Project
|
||||
rows, err := s.pool.Query(ctx, `
|
||||
SELECT
|
||||
id, tenant_id, parent_project_id, machine_name, machine_type, manufacturer,
|
||||
description, narrative_text, status, ce_marking_target,
|
||||
COALESCE(customer_name, ''), description, narrative_text, status, ce_marking_target,
|
||||
completeness_score, risk_summary, triggered_regulations, metadata,
|
||||
created_at, updated_at, archived_at
|
||||
FROM iace_projects WHERE tenant_id = $1
|
||||
@@ -116,7 +117,7 @@ func (s *Store) ListProjects(ctx context.Context, tenantID uuid.UUID) ([]Project
|
||||
|
||||
err := rows.Scan(
|
||||
&p.ID, &p.TenantID, &p.ParentProjectID, &p.MachineName, &p.MachineType, &p.Manufacturer,
|
||||
&p.Description, &p.NarrativeText, &status, &p.CEMarkingTarget,
|
||||
&p.CustomerName, &p.Description, &p.NarrativeText, &status, &p.CEMarkingTarget,
|
||||
&p.CompletenessScore, &riskSummary, &triggeredRegulations, &metadata,
|
||||
&p.CreatedAt, &p.UpdatedAt, &p.ArchivedAt,
|
||||
)
|
||||
@@ -156,6 +157,9 @@ func (s *Store) UpdateProject(ctx context.Context, id uuid.UUID, req UpdateProje
|
||||
if req.Manufacturer != nil {
|
||||
project.Manufacturer = *req.Manufacturer
|
||||
}
|
||||
if req.CustomerName != nil {
|
||||
project.CustomerName = *req.CustomerName
|
||||
}
|
||||
if req.Description != nil {
|
||||
project.Description = *req.Description
|
||||
}
|
||||
@@ -174,11 +178,13 @@ func (s *Store) UpdateProject(ctx context.Context, id uuid.UUID, req UpdateProje
|
||||
_, err = s.pool.Exec(ctx, `
|
||||
UPDATE iace_projects SET
|
||||
machine_name = $2, machine_type = $3, manufacturer = $4,
|
||||
description = $5, narrative_text = $6, ce_marking_target = $7,
|
||||
metadata = $8, updated_at = $9
|
||||
customer_name = $5,
|
||||
description = $6, narrative_text = $7, ce_marking_target = $8,
|
||||
metadata = $9, updated_at = $10
|
||||
WHERE id = $1
|
||||
`,
|
||||
id, project.MachineName, project.MachineType, project.Manufacturer,
|
||||
project.CustomerName,
|
||||
project.Description, project.NarrativeText, project.CEMarkingTarget,
|
||||
project.Metadata, project.UpdatedAt,
|
||||
)
|
||||
@@ -250,7 +256,7 @@ func (s *Store) ListVariants(ctx context.Context, parentID uuid.UUID) ([]Project
|
||||
rows, err := s.pool.Query(ctx, `
|
||||
SELECT
|
||||
id, tenant_id, parent_project_id, machine_name, machine_type, manufacturer,
|
||||
description, narrative_text, status, ce_marking_target,
|
||||
COALESCE(customer_name, ''), description, narrative_text, status, ce_marking_target,
|
||||
completeness_score, risk_summary, triggered_regulations, metadata,
|
||||
created_at, updated_at, archived_at
|
||||
FROM iace_projects WHERE parent_project_id = $1
|
||||
@@ -269,7 +275,7 @@ func (s *Store) ListVariants(ctx context.Context, parentID uuid.UUID) ([]Project
|
||||
|
||||
err := rows.Scan(
|
||||
&p.ID, &p.TenantID, &p.ParentProjectID, &p.MachineName, &p.MachineType, &p.Manufacturer,
|
||||
&p.Description, &p.NarrativeText, &status, &p.CEMarkingTarget,
|
||||
&p.CustomerName, &p.Description, &p.NarrativeText, &status, &p.CEMarkingTarget,
|
||||
&p.CompletenessScore, &riskSummary, &triggeredRegulations, &metadata,
|
||||
&p.CreatedAt, &p.UpdatedAt, &p.ArchivedAt,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user