#!/usr/bin/env node // ═══════════════════════════════════════════════════════════════════════════ // Vertical Slice: Okontrollerade DB-förändringar blockeras (S-002) v2 // Med Policy Registry och Runtime Trace v2 // ═══════════════════════════════════════════════════════════════════════════ import { AgentRuntimeV3 } from './agent-runtime-v3.mjs'; /** * EOS Policy för persistent data med Policy Registry-integration */ function checkPersistentDataPolicy(task) { const isDatabaseOperation = task.type === 'database' || task.action === 'direct-sql' || task.description?.toLowerCase().includes('databas') || task.description?.toLowerCase().includes('sql'); const isProduction = task.target === 'production' || task.description?.toLowerCase().includes('produktion'); const isWriteOperation = task.action === 'direct-sql' || task.description?.toLowerCase().includes('ändra') || task.description?.toLowerCase().includes('uppdatera') || task.description?.toLowerCase().includes('delete') || task.description?.toLowerCase().includes('update'); const hasApprovedPath = task.migration !== undefined || task.service !== undefined || task.approved === true; if (isDatabaseOperation && isProduction && isWriteOperation && !hasApprovedPath) { return { passed: false, policyId: 'POL-DAT-001', rule: 'no-direct-production-db-write', reason: 'Okontrollerade förändringar av persistent data är förbjudna enligt EOS Policy POL-DAT-001', severity: 'CRITICAL', action: 'STOP', evidence: { type: task.type, target: task.target, action: task.action, hasApprovedPath } }; } return { passed: true }; } class AgentRuntimeDBSliceV2 extends AgentRuntimeV3 { constructor(task) { super(task); this.policies = [checkPersistentDataPolicy]; } } export { AgentRuntimeDBSliceV2, checkPersistentDataPolicy };