New /methodology page with 3 tabs for viewing and editing decision
writing methodology. Uses DB override pattern: hardcoded Python
constants serve as defaults, edits saved to appeal_type_rules table,
delete restores default.
Backend: 3 generic endpoints (GET/PUT/DELETE /api/methodology/{category}/{key})
with validation per category type.
Frontend: methodology.ts hooks, GoldenRatiosPanel (number inputs per
outcome/section), DiscussionRulesPanel (accordion with textarea per
rule), ContentChecklistsPanel (markdown editor with preview toggle).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add strip_nevo_preamble() to extractor.py — auto-removes Nevo database
headers (bibliography, legislation, mini-ratio) during training upload
- Add appeal_subtype column to style_patterns table — patterns are now
stored per subtype instead of globally mixed
- Update clear_style_patterns() to support subtype-scoped deletion
- Pass appeal_subtype through analyze_corpus → store → upsert pipeline
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Support ingestion of betterment levy (היטל השבחה) decisions into a
separate training corpus (CMPA). Key changes:
- Add .doc file extraction via LibreOffice conversion in extractor
- Add practice_area/appeal_subtype columns to style_corpus table
- Route training files to cmp/ or cmpa/ subdirs based on appeal subtype
- Fix derive_subtype to handle ARAR-YY-NNNN format (was matching year digit)
- Expose practice_area/appeal_subtype params in MCP upload_training tool
- Add appeal_subtype filter to analyze_style for per-type style analysis
- Update betterment levy methodology in lessons.py: checklist (from generic
to corpus-based), opening/closing strategies, and discussion rules
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
UUID and datetime objects from PostgreSQL RETURNING * were not
serializable. All other tool files already used default=str.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Created 7 agents in CMPA (betterment levy) company, mirroring
the CMP agents with same config and hierarchy. CEO_AGENTS dict
maps company_id to the correct CEO for wakeup routing.
wake_ceo_agent and post_comment now resolve the correct CEO
based on company_id. create_workflow_issue returns company_id.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Role labels: ceo→מנהל, researcher→חוקר, engineer→מהנדס, qa→בודק איכות
Issue status: in_progress→בביצוע, done→הושלם, todo→לביצוע, etc.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New "Agents" tab in case detail shows all Paperclip agent comments,
issue status, and agent status for each case — eliminating the need
to switch between Legal-AI and Paperclip UIs.
Backend: 4 new DB query functions in paperclip_client.py (issues,
comments, agents, post_comment) + 2 new API endpoints (GET/POST
/api/cases/{case_number}/agents). Comment posting uses Board API
with DB+wakeup fallback to ensure CEO routing.
Frontend: agents.ts hooks (10s polling), AgentActivityFeed component
(markdown timeline + comment input), AgentStatusWidget (sidebar),
4th tab in case detail page.
Also includes new-company-setup-guide.md documenting the process
for setting up the betterment levy (CMPA) company.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CEO agent was reverting case status from "processing" to "new" when
updating metadata fields. Added ordered status list — case_update now
silently ignores status changes that would move backwards.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These are source extractions that fed into decision-methodology.md.
Not read by agents — kept as audit trail for methodology origins.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Delete web/static/index.html and design-system.css (replaced by Next.js)
- Remove GET / HTML route and StaticFiles import from app.py
- CLAUDE.md: document that web/ = FastAPI API, web-ui/ = Next.js frontend
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Active scripts (5): auto-sync-cases.sh, backup-db.sh, restore-db.sh,
notify.py, bidi_table.py
Archived (17): one-time migration/seeding scripts whose functionality
is now in MCP server or web API. Moved to scripts/.archive/
Deleted (5): zero-value scripts (duplicates, hardcoded single-case,
debug scripts)
Added scripts/SCRIPTS.md — registry of all scripts with purpose,
status, and what superseded them. CLAUDE.md updated with rule:
any script change requires SCRIPTS.md update.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
skills/decision/references/block-schema.md was a stale copy that
diverged from docs/block-schema.md. Now a symlink — single source of truth.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- CLAUDE.md: clarify vault was deleted, knowledge is in docs/+training/
- Remove import-final-decisions.py (migration completed, all decisions in DB)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assets live in ezer-mishpati/paperclip-config (cloned at ~/.paperclip).
Deploy via: ~/.paperclip/hebrew/apply-hebrew.sh
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- CEO agent now sends email via notify.py when awaiting human response
- CEO creates child issues (parentId) instead of flat disconnected issues
- Fix notify.py email address to chaim+paperclip@marcus-law.co.il
- Move Paperclip UI assets (RTL CSS + Hebrew JS) into repo under scripts/
- Add deploy.sh script to push assets to live Paperclip instance
- Fix comment box positioning: newest comment on top, input below it
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New endpoint POST /api/cases/{case_number}/start-workflow creates a
Paperclip issue, wakes the CEO agent via wakeup API, and transitions
case status to "processing". Button appears on case page only when
status is "new" or "documents_ready".
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- auto-sync-cases.sh: fix broken directory scan (was looking for
status subdirs that don't exist), fix env var word-splitting bug,
add safe.directory handling and error logging
- cases.py: auto-create Gitea repo on case_create, fix
documents/original → documents/originals naming mismatch
- app.py: add GET /api/cases/{case_number}/git-status endpoint
- web-ui: add SyncIndicator component in case header showing
sync status (synced/pending/no remote) with last commit time
- pyproject.toml: add httpx dependency
- CLAUDE.md: update Paperclip wakeup API docs
- settings page: switch tag input from Select to free-text with datalist
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The CEO was ignoring the focused wake reason and doing a full heartbeat
scan of all cases/issues before getting to the actual comment. Added
step 0: check $PAPERCLIP_WAKE_REASON first — if user_commented, skip
directly to comment handling. Don't scan other cases.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CEO was missing get_chair_directions, record_chair_feedback,
list_chair_feedback, and search_case_documents. Without these tools
it couldn't read or update chair directions when processing draft
annotations.
Now the CEO will:
1. Read existing chair_directions via MCP tool
2. Record each draft annotation as chair_feedback
3. Update analysis-and-research.md
4. Post summary for user review before routing to writer
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When the user writes editing instructions inside a draft DOCX, the CEO
must not just forward them as a checklist. Instead:
1. Read analysis-and-research.md + existing chair_directions
2. Translate draft annotations into methodological structure (syllogism)
3. Update chair_directions with the new analysis
4. Post summary to user and WAIT for approval
5. Only after approval → create issue for writer
This gives the user a chance to verify the CEO understood correctly
before the writer starts working.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Even when the user asks to edit specific paragraphs in an existing
draft, the CEO must first analyze through the methodology: identify
which legal issue the edit serves, build syllogistic structure,
reference specific source documents, and state the review standard.
Without this, the writer gets a technical checklist instead of
methodological guidance.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Agent JWT cannot wake other agents directly (returns "Agent can only
invoke itself"). The correct pattern: create an issue + assign to the
target agent → Paperclip triggers wakeup automatically.
Also documented all correct API routes in HEARTBEAT.md:
- POST /api/issues/{id}/comments (not /issues/)
- POST /api/companies/{company-id}/issues (not /api/issues)
- PATCH /api/issues/{id}
- POST /api/agents/{id}/wakeup (self only, with payload.issueId)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The CEO was sending empty issues like "הועבר לכתיבה" without any
methodological content. The writer needs: syllogistic structure per
issue, source document references, claim handling table, chair
directions, style guidelines, and draft file path when available.
Added "תבנית issue לכותב ההחלטה" with all 5 required sections.
Updated comment routing to read drafts word-by-word and use the template.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The agents used /api/agents/{id}/wake (404) with a fallback of INSERT
INTO agent_wakeup_requests. The DB insert creates only the wakeup
record without a heartbeat_run, so the Paperclip dispatcher never
processes it — agents get stuck in queued forever.
Fix:
- All agents: /wake → /wakeup (correct Paperclip API endpoint)
- Remove all DB INSERT fallbacks, replace with warning
- Document the rule in CLAUDE.md: always API, never DB insert
- Save to memory for future conversations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix column name mismatch in paperclip_client.py and app.py: Paperclip's
companies table uses `issue_prefix`, not `identifier`
- Fix _LEGAL_DB_URL to read from POSTGRES_URL env var (used in container)
- Add settings page (/settings) for managing tag → Paperclip company mappings
- Replace "תיק חדש" nav item with "הגדרות" (new case is on home page)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaced Dockerfile-based app with Docker Image app in Coolify.
CI builds and pushes image to registry, Coolify pulls it on deploy.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a user comments on a Paperclip issue, the built-in automation wakes
the assigned agent directly, bypassing the CEO. This meant user instructions
(like "read the uploaded draft and route to the right agent") were ignored.
Changes:
- Plugin: add issue.comment.created event handler that wakes the CEO agent
with the comment context (plugin-legal-ai, separate repo)
- HEARTBEAT: add steps 2b (read recent user comments) and 2c (check
attachments) before agents start working
- CEO agent: add comment-routing section — read, check attachments, route
- Writer agent: add step 0 — check for uploaded DOCX drafts before writing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The old legal-ai-web app (my85gabx...) was deleted — consolidated into
a single ezer-mishpati-web (a99ivjv...) serving both domains.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The drafts panel now checks for עריכה-v* files and shows the correct
draft number (e.g. "טיוטה 2 (מתוקנת) מוכנה לעיון") instead of always
displaying "טיוטה ראשונה מוכנה לעיון".
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Deleted from Coolify (was exited:unhealthy since Apr 7)
- Updated CLAUDE.md service table: Paperclip is now pm2/local
- Removed Docker skills path fallback in app.py (always use local)
- Removed old paperclip-bug-report.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add DELETE /api/cases/{case_number}/exports/{filename} endpoint
- Add useDeleteDraft hook in exports API
- Add trash icon + confirmation dialog in drafts panel UI
- Final files (סופי-) cannot be deleted as a safety measure
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Install git in Docker image and wrap all subprocess git calls in
try/except so a missing or failing git binary never kills an upload
that already succeeded.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a case is created, a Paperclip project is now automatically created in
the correct company based on the appeal_subtype tag. Tag-to-company mappings
are managed via a new Settings page that pulls companies from Paperclip DB.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move draft management (export DOCX, download, upload revised version, mark
final) and chair feedback into a new "טיוטות והערות" tab on the case detail
page. Remove the standalone /feedback page and its nav link since feedback
is now case-scoped.
Also fix /api/admin/skills 500 error when Paperclip DB is unreachable by
adding a connection timeout and graceful fallback to disk-only skills.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Added analyst_verified, research_complete, analysis_enriched, and
ready_for_writing statuses across all UI components: status-badge,
workflow-timeline, status-donut, status-changer, status-guide, and
kpi-cards. Also changed qa_review label from "QA" to "בדיקת איכות".
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
After Dafna fills her positions in the analysis document, the analyst
now runs a second pass to: verify cited case law against corpus and
case documents, deepen factual findings based on the chosen direction,
close open questions, and strengthen CREAC preparation.
Pipeline flow updated: direction_approved → analyst pass 2 →
analysis_enriched → CEO creates writer issue → ready_for_writing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The merge of ui-rewrite removed these parameters from db.search_similar()
and db.create_case() but left the callers passing them, causing TypeError
on any corpus search. Restores the parameters and adds schema migration.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PUT /api/cases/{n}/research/analysis/upload accepts a markdown file and
validates: UTF-8 encoding, parseable structure, at least one threshold
or issue section, matching case number. Backs up existing file before
replacing. UI adds "העלה ניתוח מעודכן" button with status feedback.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Curl was installed to download Node.js setup script then purged.
Coolify needs it for HTTP health checks inside the container.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Every push to main tags with latest + build-N (run number).
Pushing a git tag like v1.0.0 also tags the image with that version.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New GET /api/cases/{n}/research/analysis/download endpoint returns the
raw markdown file. UI adds a "הורד ניתוח" button next to "חזרה לתיק"
on the compose page, visible only when analysis data is loaded.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Four functions were called by tools/precedents.py but never implemented
in services/db.py: create_case_precedent, list_case_precedents,
delete_case_precedent, search_precedent_library. This caused 500 errors
on the /api/cases/{n}/precedents endpoint.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Job containers were on isolated network, couldn't reach Coolify API.
Now runner config sets container.network=coolify and curl targets
http://coolify:8080 (internal container name).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On push to main, the workflow builds a Docker image, pushes to
Gitea Container Registry, then triggers Coolify to pull and redeploy.
Replaces the old Dockerfile-build-on-deploy approach.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>