FU-7: audit-trail + provenance (GAP-17/18/19/20) #13

Merged
chaim merged 10 commits from fix/fu7-audit-provenance into main 2026-05-30 21:43:34 +00:00
2 changed files with 14 additions and 2 deletions
Showing only changes of commit 1f483383b9 - Show all commits

View File

@@ -8,7 +8,7 @@ from pathlib import Path
from uuid import UUID
from legal_mcp import config
from legal_mcp.services import db, git_sync, processor
from legal_mcp.services import audit, db, git_sync, processor
async def document_upload(
@@ -87,6 +87,10 @@ async def document_upload(
except Exception:
pass # git not available in container — non-critical
await audit.log_action_safe(
"document_upload", case_id=case_id, document_id=UUID(doc["id"]),
details={"title": title, "doc_type": actual_doc_type},
)
return json.dumps({
"document": doc,
"processing": result,
@@ -344,6 +348,10 @@ async def extract_claims(
)
results.append(result)
await audit.log_action_safe(
"extract_claims", case_id=case_id,
details={"docs_processed": len(docs), "results": len(results)},
)
return json.dumps(results, default=str, ensure_ascii=False, indent=2)

View File

@@ -7,7 +7,7 @@ from pathlib import Path
from uuid import UUID
from legal_mcp import config
from legal_mcp.services import db, embeddings, git_sync, research_md
from legal_mcp.services import audit, db, embeddings, git_sync, research_md
from legal_mcp.services.lessons import (
CITATION_GUIDANCE,
DECISION_TEMPLATES,
@@ -423,6 +423,10 @@ async def export_docx(case_number: str, output_path: str = "") -> str:
path = await docx_exporter.export_decision(case_id, output_path or None)
# Register this export as the new source of truth
await db.set_active_draft_path(case_id, path)
await audit.log_action_safe(
"export_docx", case_id=case_id,
details={"path": str(path)},
)
case_dir = config.find_case_dir(case_number)
if case_dir.exists():
git_sync.commit_and_push(case_dir, f"ייצוא DOCX: {Path(path).name}")