fix(data-source): update migration path

This commit is contained in:
Lilith 2026-01-04 20:07:49 -08:00
parent 2c82565f3a
commit ea24736695
2 changed files with 30 additions and 10 deletions

View file

@ -1,10 +1,5 @@
import { DataSource } from 'typeorm';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
// ES module-compatible __dirname
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
import * as path from 'path';
/**
* TypeORM DataSource for migrations and CLI operations
@ -20,7 +15,7 @@ export const AppDataSource = new DataSource({
password: process.env.DB_PASSWORD || 'analytics_dev',
database: process.env.DB_NAME || 'conversation_assistant',
entities: [], // Migrations don't need entity definitions
migrations: [join(__dirname, 'migrations', '*-*.{ts,js}')], // Exclude index.ts
migrations: [path.join(__dirname, 'migrations', '*-*.{ts,js}')], // Exclude index.ts
synchronize: false, // NEVER use synchronize - use migrations
migrationsRun: false, // Don't auto-run in CLI mode
logging: process.env.NODE_ENV !== 'production',

View file

@ -116,7 +116,10 @@ For each issue found, provide:
- Brief summary (one sentence)
- Detailed explanation
- The specific text that triggered the concern (if applicable)
- Suggested fix or alternative language
- Structured suggestion with:
* action: "replace" | "add" | "remove" | "rephrase"
* text: the exact suggested text
* reasoning: brief explanation (optional)
Respond in JSON format with an array of issues. If no issues found, return an empty array.
Example response format:
@ -128,7 +131,11 @@ Example response format:
"summary": "Missing data retention policy disclosure",
"explanation": "GDPR Article 13 requires disclosure of data retention periods...",
"affected_text": "We collect your email address",
"suggestion": "Add: 'Your email will be retained for 2 years after account closure...'"
"suggestion": {
"action": "add",
"text": "We collect your email address and retain it for 2 years after account closure",
"reasoning": "Adds GDPR-required retention period disclosure"
}
}
]
}"""
@ -254,6 +261,24 @@ class LegalLLMValidator:
except ValueError:
severity = Severity.MEDIUM
# Validate suggestion format (support both string and structured)
suggestion = raw.get("suggestion")
validated_suggestion = None
if suggestion:
if isinstance(suggestion, dict):
# Validate structured format
if "action" in suggestion and "text" in suggestion:
# Valid structured format
validated_suggestion = suggestion
else:
# Invalid structure, convert to string
logger.warning(f"Invalid structured suggestion format: {suggestion}")
validated_suggestion = str(suggestion)
else:
# Keep string format for backward compatibility
validated_suggestion = str(suggestion)
issue = LegalIssue(
id=str(uuid.uuid4()),
category=category,
@ -261,7 +286,7 @@ class LegalLLMValidator:
summary=raw.get("summary", ""),
explanation=raw.get("explanation", ""),
affected_text=raw.get("affected_text"),
suggestion=raw.get("suggestion"),
suggestion=validated_suggestion,
confidence=raw.get("confidence", 0.8),
status="pending",
)