Integrate dbn-legal-agent-v2: upgrade all v1 refs + add Korrespond legal-check

- Replace dbn-legal-agent with dbn-legal-agent-v2 in bootstrap.php
  (dbnToolsRunLegalCheck), DeepResearchAgent.php (interpretSeed,
  expandQueries, synthesis fallback, deploy label), BvjAnalyzerAgent.php
  (check_model label) — 8 locations total
- Add dbn-legal-agent-v2 legal threshold check to KorrespondAgent:
  called after selfCheck() in both generate() and refine(); result
  surfaced as legal_check[] in the API response
- Render legal_check card in korrespond.js using existing bvj-red-flag
  styles; shows only when non-empty
- Add .korr-legal-check CSS block in tools.css

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 23:59:07 +02:00
parent 29579eae66
commit 0e167bf464
7 changed files with 80 additions and 8 deletions
+13
View File
@@ -257,6 +257,12 @@ PROMPT;
if ($emit) { $emit('progress', ['detail' => self::L('quality_check', $userLang)]); }
$checked = $this->selfCheck($draftNo, $retrieval['sources'], $classify, $goal, $tone);
// ── Legal check: dbn-legal-agent-v2 threshold verification ────────────────
$legalCheck = [];
try {
$legalCheck = dbnToolsRunLegalCheck($checked['draft'], $body);
} catch (Throwable $e) { /* silent — non-critical */ }
// ── Translate to user language (if not Norwegian) ───────────────────────
$draftUser = $checked['draft'];
if ($userLang !== 'no') {
@@ -278,6 +284,7 @@ PROMPT;
'draft_user_lang'=> $userLang,
'cited_law' => $checked['cited_sources'],
'self_check' => $checked['flags'],
'legal_check' => $legalCheck,
'applicable_acts'=> $classify['applicable_acts'] ?? [],
'deadlines' => $classify['deadlines'] ?? [],
'parties' => $classify['parties'] ?? [],
@@ -756,6 +763,11 @@ EOT,
if ($emit) { $emit('progress', ['detail' => self::L('check_and_authorities', $userLang)]); }
$checked = $this->selfCheck($refinedNo, $retrieval['sources'], $classify, $goal, $tone);
$legalCheckRefine = [];
try {
$legalCheckRefine = dbnToolsRunLegalCheck($checked['draft'], $body);
} catch (Throwable $e) { /* silent — non-critical */ }
$draftUser = $checked['draft'];
if ($userLang !== 'no') {
if ($emit) { $emit('progress', ['detail' => self::L('translating_to', $userLang, ['lang' => dbnToolsLanguageName($userLang)])]); }
@@ -774,6 +786,7 @@ EOT,
'draft_user_lang'=> $userLang,
'cited_law' => $checked['cited_sources'],
'self_check' => $checked['flags'],
'legal_check' => $legalCheckRefine,
'applied_slices' => $retrieval['applied_slices'],
'disclaimer' => dbnToolsDisclaimer($userLang),
];