Commit Graph

307 Commits

Author SHA1 Message Date
43b8106f55 Fix wakeup API source/triggerDetail enum values
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 10s
Paperclip expects source ∈ {timer, assignment, on_demand, automation}
and triggerDetail ∈ {manual, ping, callback, system}.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 16:08:07 +00:00
ad3c2b7117 Remove duplicate paperclip-assets — source of truth is paperclip-config repo
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>
2026-04-14 15:57:18 +00:00
11c73a7c60 CEO: add email notifications, subtask parentId, and Paperclip UI assets
- 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>
2026-04-14 15:55:55 +00:00
6228846223 Add "Start Workflow" button to trigger CEO agent from web UI
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 49s
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>
2026-04-14 15:51:23 +00:00
82ba4663ba Fix case repo sync + auto-create Gitea repos + add sync indicator
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m30s
- 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>
2026-04-14 15:28:16 +00:00
7509d7e580 CEO: check wake reason first, skip full scan on user_commented
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 8s
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>
2026-04-14 15:09:13 +00:00
2a7174b15d Add chair feedback tools to CEO + use them for draft annotations
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 7s
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>
2026-04-14 14:58:35 +00:00
ce64766f6d CEO: extract draft annotations into chair_directions before routing
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 9s
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>
2026-04-14 14:55:05 +00:00
2d349cf817 CEO must analyze edit requests through methodology before routing
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 8s
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>
2026-04-14 14:48:56 +00:00
598df0dc8c Fix Paperclip API routes and document agent-to-agent wakeup pattern
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 7s
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>
2026-04-14 14:43:54 +00:00
bb6f5e9eff Add mandatory issue template for writer agent with full methodology
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 7s
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>
2026-04-14 14:34:07 +00:00
45d52a74d2 Fix agent wakeup: /wake → /wakeup, remove broken DB fallback
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 7s
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>
2026-04-14 14:18:57 +00:00
1133272e34 Fix Paperclip integration (identifier→issue_prefix) + add settings page
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 34s
- 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>
2026-04-14 14:09:08 +00:00
b755620542 Update CI deploy UUID to new Docker Image app (gyjo0mtw...)
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 4m24s
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>
2026-04-14 13:55:37 +00:00
089a8b3a08 Route user comments through CEO agent + add draft/attachment awareness
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m42s
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>
2026-04-14 13:47:43 +00:00
34fa923a2b Update CI deploy target to unified legal-ai app UUID
Some checks failed
Build & Deploy / build-and-deploy (push) Has been cancelled
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>
2026-04-14 13:46:26 +00:00
d9948045f1 Fix draft label to reflect revision number instead of always showing "first draft"
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m36s
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>
2026-04-14 13:17:44 +00:00
23f6b5d825 Remove Paperclip Docker references — runs locally via pm2
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m38s
- 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>
2026-04-14 13:13:26 +00:00
a093944967 Add delete button for draft files in case drafts panel
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 45s
- 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>
2026-04-14 13:05:30 +00:00
e698419faf Fix git not found error crashing document uploads in container
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m13s
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>
2026-04-14 12:38:40 +00:00
5028f677f1 Fix English statuses and labels throughout UI to Hebrew
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 7s
- Complete STATUS_LABELS in case view (added outcome_set, direction_approved,
  drafting, qa_review, reviewed)
- Add DOC_STATUS_LABELS for diagnostics page (failed/stuck documents)
- Add completed/failed/pending/error to global STEP_LABELS
- Translate settings page table headers to Hebrew

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 06:32:03 +00:00
2faae002e7 Add settings page for tag-to-company mappings and auto-create Paperclip projects
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m22s
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>
2026-04-14 06:24:23 +00:00
140a2e442d Add drafts & feedback tab to case page, remove global feedback page
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 32s
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>
2026-04-14 05:55:46 +00:00
ce61b88438 Add missing pipeline statuses to UI with Hebrew labels
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m26s
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>
2026-04-14 03:38:17 +00:00
e5eee596bc Add pass 2 to legal-analyst: deepen analysis after chair directions
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 7s
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>
2026-04-13 20:27:20 +00:00
bd974f7791 Fix practice_area/appeal_subtype regression in search and case creation
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m55s
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>
2026-04-13 19:37:38 +00:00
b248e1414d Add upload endpoint for updated analysis files
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 34s
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>
2026-04-13 19:34:06 +00:00
9da8dd2c4f Keep curl in Docker image for healthcheck
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m23s
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>
2026-04-13 19:27:41 +00:00
437472be85 Add build number and semver tags to CI images
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 26s
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>
v1.0.0
2026-04-13 19:15:02 +00:00
fdbf22c699 Add download button for analysis-and-research.md
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m22s
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>
2026-04-13 19:08:07 +00:00
2d0e987803 Add missing case_precedents CRUD functions to db module
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m14s
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>
2026-04-13 18:44:50 +00:00
35276eab41 Fix CI: use coolify network for job containers
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 7s
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>
2026-04-13 18:33:34 +00:00
ef448be530 Trigger CI/CD workflow test
Some checks failed
Build & Deploy / build-and-deploy (push) Failing after 5m17s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 18:27:02 +00:00
1d2d9c71d8 Fix duplicate Docker socket mount in CI workflow
Some checks failed
Build & Deploy / build-and-deploy (push) Failing after 1m7s
Runner already passes Docker socket to job containers —
explicit container.volumes caused duplicate mount error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 18:24:59 +00:00
5eab006780 Add Gitea Actions CI/CD: build image + trigger Coolify deploy
Some checks failed
Build & Deploy / build-and-deploy (push) Failing after 46s
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>
2026-04-13 18:23:33 +00:00
bc1456672b Fix document scroll and preview dialog
ScrollArea (Radix) injected display:table on viewport, preventing
scroll — replaced with plain div + overflow-y-auto. Preview dialog
never loaded text because onOpenChange doesn't fire on initial mount —
replaced with useEffect that fetches on open.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 17:58:22 +00:00
2b431e75ab Add document preview, delete, and fix scroll in documents panel
Documents tab was limited to ~9 visible items due to fixed max-height
without overflow-hidden. Now uses 70vh with proper overflow. Added
click-to-preview (shows extracted text in dialog) and delete button
with confirmation dialog + backend DELETE endpoint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 17:45:01 +00:00
2b988fd805 Add UI updates PRD for task master
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 16:54:32 +00:00
62a67e3f31 Add status icons, descriptions, status guide, manual status changer, and merge action buttons into overview tab
- StatusBadge: added icons (lucide-react) and Hebrew descriptions for all 13 statuses
- WorkflowTimeline: added phase icons and current-status description display
- StatusGuide: new collapsible component showing all statuses grouped by phase with explanations
- StatusChanger: new dropdown for manual status override on the case detail sidebar
- Case detail page: merged action buttons into overview tab, removed separate actions tab

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:19:28 +00:00
bf595975bf Fix start.sh: redirect uvicorn output to Docker logs
uvicorn was running in background with no output capture,
making it impossible to debug crashes. Now redirects stderr
to stdout and checks if uvicorn started successfully.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:55:04 +00:00
626d39d1bb Fix Dockerfile: use python:3.12-slim for pre-built wheels
pymupdf and other native deps need compilation on Alpine.
Switch to Debian-based python:3.12-slim which has pre-built
wheels available, avoiding the need for gcc/build-essential.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:36:16 +00:00
94bc66d7c1 Bundle FastAPI backend into Next.js Docker container
The Next.js app was proxying /api/* to the old Flask/FastAPI server
at legal-ai.nautilus.marcusgroup.org. When that server went down,
the Next.js app's API calls failed with 503.

Now both services run in the same container:
- FastAPI (uvicorn) on :8000 — the API backend
- Next.js (node) on :3000 — proxies /api/* to localhost:8000

Changes:
- Dockerfile: multi-stage build with Python 3.12 + Node.js
- next.config.ts: default proxy target is now 127.0.0.1:8000
- start.sh: launches uvicorn in background + node in foreground
- pyproject.toml: add fastapi + uvicorn as explicit deps

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:33:52 +00:00
cc50f0ffde Fix CEO status map — align with actual statuses written by agents
The status map was using informal descriptions ("מסמכים הוגהו")
instead of actual DB values. Now each row shows:
- The exact status string in cases.status
- Which agent sets it
- What the CEO should do next

New statuses added: proofread, analyst_verified, research_complete,
qa_passed, qa_failed, exported. Removed ambiguous conditions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:05:54 +00:00
3f6a130cf9 Make all agent instructions self-contained — no reliance on hope
Every agent now has explicit instructions in its own definition file,
not just in HEARTBEAT.md. An agent following only its own step-by-step
instructions will do the right thing on any new case.

All 6 non-CEO agents: explicit wakeup CEO block in completion step
  (curl API + psql fallback, with agent name customized)

legal-ceo.md: issue template for analyst with 5 mandatory items
  (document mapping table, no-extract list, split large docs,
   wakeup CEO, blocked if failed)

legal-writer.md: explicit Read of decision-methodology.md as step 1
  (before case_get, not just "read before starting")

legal-qa.md: methodology_compliance severity → critical
  (was warning — decisions without syllogisms/steel-man now blocked)

legal-proofreader.md: added case_update tool + status='proofread'
  (was missing entirely — CEO couldn't know proofreading was done)

legal-researcher.md: added case_update + mail notification
  (was missing — CEO couldn't know research was done)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:17:44 +00:00
df4d28eb5c Merge branch 'ui-rewrite' 2026-04-13 12:43:12 +00:00
6b15f84fdb WIP: documents panel UI improvements 2026-04-13 12:43:07 +00:00
bffdfe3e9d Merge ui-rewrite into main: methodology + pipeline fixes
Major changes from ui-rewrite branch:
- Decision-writing methodology (decision-methodology.md) based on FJC, Garner, Posner
- 5 source books downloaded and processed (341K words)
- Methodology integrated into block-yod prompt
- All 8 Paperclip agents updated for methodology compliance
- DB schema V4: claim handling, standard of review, precedent hierarchy
- 15 pipeline gaps identified and fixed after test run on case 1130-25
- Negative checks layer added to CEO and QA agents
- HEARTBEAT: wakeup CEO on completion + blocked status
- Flexible claim handling (bundle/skip via chair_directions)

Conflicts resolved: all 5 files use ui-rewrite version (the latest).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 12:42:32 +00:00
ebecd87ad5 Analyst: split large documents before extraction to avoid timeout
Documents >15K chars must be split by chapter/section and extracted
in parts. If extract_claims times out, retry with chunks or extract
manually. This prevents the Matmon document issue (108K chars, 4x timeout).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 12:40:49 +00:00
b1ad67dc49 Fix 12 of 15 pipeline gaps found in 1130-25 test run
Test run on case 1130-25 revealed critical gaps. This commit fixes:

HEARTBEAT.md (#1, #11):
- Agents MUST wake CEO after completing any task (wakeup request)
- New "blocked" status option — agents cannot mark "done" if something failed
- Fallback: direct DB insert if API wake doesn't work

legal-analyst.md (#2):
- New step 6: completeness checks BEFORE finishing
- Verify all appeal/response documents extracted successfully
- Verify all extracted documents produced claims
- Verify classification is correct (no claims from committee)
- If any check fails → status = "blocked", not "done"

legal-ceo.md (#3, #6, #7, #12, #13, #14, #15):
- Step A rewritten with 3 sub-checks:
  A1: extraction completeness (no missing documents)
  A2: negative checks (wrong classification, abnormal counts, missing parties)
  A3: methodology compliance (syllogisms, CREAC prep, steel-man, etc.)
- Any failure blocks progress to step B

legal-qa.md (#6 reinforcement):
- New step 2b: negative checks on the written decision
- Missing issues, bare quotes, empty formulas, mixed findings/conclusions

Also:
- Synced all agent files to /home/chaim/legal-ai/ (Paperclip reads from there)
- Synced methodology + lessons + corpus docs
- Fixed claim classification in DB: 20 committee/applicant claims → response (#5)

Remaining gaps (3):
- #4: Paperclip cache may need restart to pick up new definitions
- #7: Matmon document retry (25K words, 0 claims extracted)
- #9: 53 appellant claims may need synthesis (high but not blocking)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 12:28:38 +00:00
6cf918ad79 Add DB schema V4: methodology alignment columns
New columns for methodology-aware decision pipeline:

claims table:
- claim_handling (address/bundle/skip) — per-claim handling mode
- bundle_group — group name for bundled claims
- handling_reason — explanation for skip/bundle

cases table:
- standard_of_review — review standard (independent discretion / etc.)
- subject_categories — JSONB array of topics in the appeal

case_law table:
- precedent_level — hierarchy (supreme/administrative/national/district)
- is_binding — binding holding vs. obiter dictum
- creac_role — how it serves reasoning (rule/explanation/analogy)

decisions table:
- issue_order — JSONB array of ordered issues with type
- claim_handling — JSONB overrides from chair_directions

Migration tested and applied successfully on production DB.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 23:47:11 +00:00