Files
breakpilot-compliance/backend-compliance/migrations/022_template_block_markers.sql
Benjamin Admin 1c5a4c2d96
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 36s
CI / test-python-backend-compliance (push) Successful in 31s
CI / test-python-document-crawler (push) Successful in 22s
CI / test-python-dsms-gateway (push) Successful in 19s
feat: Template-Spec v1 Phase B — Rule Engine + Block Removal
- ruleEngine.ts: Minimal JSONLogic evaluator, 6-phase runner (compute_flags,
  auto_defaults, hard_validations, auto_remove_blocks, module_requirements,
  warnings), getDocType mapping, applyBlockRemoval
- ruleEngine.test.ts: 49 Vitest tests (alle grün)
- page.tsx: ruleResult useMemo, enabledModules state, computed flags pills,
  module toggles, rule engine banners (errors/warnings/legal notice)
- migrations/022_template_block_markers.sql: Dokumentation + Verify-Query
- scripts/apply_block_markers_022.py: NDA_PENALTY_BLOCK, COOKIE_ANALYTICS_BLOCK,
  COOKIE_MARKETING_BLOCK in DB-Templates einfügen

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 13:23:03 +01:00

43 lines
1.8 KiB
SQL

-- Migration 022: Template Block Markers
-- ============================================================
-- This migration documents the block marker system introduced
-- in Template-Spec v1 Phase B.
--
-- Block markers are inserted into template content via the
-- Python script: scripts/apply_block_markers_022.py
--
-- Block IDs:
-- NDA_PENALTY_BLOCK — Vertragsstrafe section (NDA DE + EN)
-- COOKIE_ANALYTICS_BLOCK — Analyse-Tools section (Cookie Banner DE)
-- COOKIE_MARKETING_BLOCK — Marketing-Partner section (Cookie Banner DE)
--
-- Marker syntax in template content:
-- [BLOCK:NDA_PENALTY_BLOCK]
-- ## §N Vertragsstrafe
-- ...content...
-- [/BLOCK:NDA_PENALTY_BLOCK]
--
-- The Rule Engine (ruleEngine.ts) evaluates ruleset.v1.json and
-- produces a list of block IDs to remove before placeholder substitution.
-- The applyBlockRemoval() function strips matching [BLOCK:ID]...[/BLOCK:ID]
-- sections from template content.
--
-- Run the Python migration script to apply markers to DB content:
-- docker exec bp-compliance-backend python3 /tmp/apply_block_markers_022.py
--
-- No schema changes are required — block markers are stored inline
-- in the existing `content` TEXT column of compliance_legal_templates.
-- ============================================================
-- Verify markers were applied (run after script):
SELECT
document_type,
language,
title,
CASE WHEN content LIKE '%[BLOCK:NDA_PENALTY_BLOCK]%' THEN 'YES' ELSE 'no' END AS has_nda_penalty,
CASE WHEN content LIKE '%[BLOCK:COOKIE_ANALYTICS_BLOCK]%' THEN 'YES' ELSE 'no' END AS has_cookie_analytics,
CASE WHEN content LIKE '%[BLOCK:COOKIE_MARKETING_BLOCK]%' THEN 'YES' ELSE 'no' END AS has_cookie_marketing
FROM compliance.compliance_legal_templates
WHERE document_type IN ('nda', 'cookie_banner')
ORDER BY document_type, language;