fix(api): route Paperclip title-sync/webhooks through the Port — 500 on case rename (INV-G12)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 3s

PUT /api/cases/{n} crashed with 500 (NameError: 'paperclip_client' is
not defined) whenever the title changed. The G12 platform-port refactor
dropped the `paperclip_client`/`paperclip_api` module imports from
app.py but left three call sites still referencing the old module names:

  - app.py:2096  paperclip_client.update_project_name  (title sync → fires on every rename)
  - app.py:3806  paperclip_api.emit_export_complete_webhook
  - app.py:7390  paperclip_api.emit_missing_precedent_webhook

All three are background_tasks, so the latter two were latent NameErrors
waiting to fire. Expose the three functions through agent_platform_port
(the single Paperclip seam) and call them via the Port, restoring G12.

Invariants: upholds INV-G12 (all Paperclip access via agent_platform_port).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-14 08:37:51 +00:00
parent 6fc87de1c5
commit e2c94144d0
2 changed files with 14 additions and 3 deletions

View File

@@ -52,6 +52,8 @@ from web.progress_store import ProgressStore
from web.agent_platform_port import (
PAPERCLIP_COMPANIES,
emit_case_status_webhook,
emit_export_complete_webhook,
emit_missing_precedent_webhook,
get_project_url,
pc_accept_interaction,
pc_archive_project,
@@ -73,6 +75,7 @@ from web.agent_platform_port import (
pc_respond_to_interaction,
pc_restore_project,
pc_wake_analyst_for_appraiser_facts,
rename_case_project,
pc_wake_ceo,
pc_wake_ceo_for_feedback_fold,
pc_wake_curator_for_final,
@@ -2093,7 +2096,7 @@ async def api_case_update(case_number: str, req: CaseUpdateRequest, background_t
old_title = (existing or {}).get("title", "")
if req.title and req.title != old_title:
background_tasks.add_task(
paperclip_client.update_project_name,
rename_case_project,
case_number=case_number,
new_title=req.title,
)
@@ -3816,7 +3819,7 @@ async def api_export_docx(case_number: str, background_tasks: BackgroundTasks):
else None
)
background_tasks.add_task(
paperclip_api.emit_export_complete_webhook,
emit_export_complete_webhook,
case_number=case_number,
docx_filename=docx_filename,
company_id=company_id,
@@ -7544,7 +7547,7 @@ async def missing_precedent_create(
# Trigger plugin to ask Daphna via askUserQuestions interaction.
if case_number_for_webhook and row.get("id"):
background_tasks.add_task(
paperclip_api.emit_missing_precedent_webhook,
emit_missing_precedent_webhook,
case_number=case_number_for_webhook,
missing_precedent_id=str(row["id"]),
citation=req.citation.strip(),