#!/usr/bin/env node // ═══════════════════════════════════════════════════════════════════════════ // Vertical Slice: Otillåtna infra-förändringar blockeras (S-005) v2 // Med Policy Registry och Runtime Trace v2 // ═══════════════════════════════════════════════════════════════════════════ import { AgentRuntimeV3 } from './agent-runtime-v3.mjs'; /** * EOS Policy för infrastruktur med Policy Registry-integration */ function checkInfrastructurePolicy(task) { const isInfrastructure = task.type === 'infrastructure' || task.description?.toLowerCase().includes('skapa') || task.description?.toLowerCase().includes('ändra') || task.description?.toLowerCase().includes('konfigurera'); const isProduction = task.target === 'production' || task.description?.toLowerCase().includes('produktion') || task.description?.toLowerCase().includes('aws-konsolen'); const isChange = task.action !== 'inventory' && task.action !== 'plan' && task.action !== 'validate' && task.action !== 'fmt' && task.action !== 'diff' && task.action !== 'read' && task.action !== 'health-check' && task.action !== 'log-analysis'; const hasApprovedProcess = task.terraform !== undefined || task.iac === true || task.approved === true || task.pipeline !== undefined; if (isInfrastructure && isProduction && isChange && !hasApprovedProcess) { return { passed: false, policyId: 'POL-INFRA-001', rule: 'no-unapproved-infra-change', reason: 'Förändring av produktionsinfrastruktur kräver godkänd Infrastructure-as-Code-process enligt EOS Policy POL-INFRA-001', severity: 'CRITICAL', action: 'STOP', evidence: { type: task.type, target: task.target, action: task.action, hasApprovedProcess } }; } return { passed: true }; } class AgentRuntimeInfraSliceV2 extends AgentRuntimeV3 { constructor(task) { super(task); this.policies = [checkInfrastructurePolicy]; } } export { AgentRuntimeInfraSliceV2, checkInfrastructurePolicy };