Commit Graph

39 Commits

Author SHA1 Message Date
8b816c8b61 Voice corpus deep read: precedent network + architecture-by-outcome
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 6s
After reading all 23 1xxx decisions from style_corpus DB (in addition to
the 10 training files and 1130-25/1194-25 deep reads), synthesized two
new operational documents:

docs/daphna-precedent-network.md
- Maps each legal issue to the specific precedent Daphna cites
- 9 threshold issues (standing, השפר, סעיף 152, קנייני, פגמי פרסום,
  פסילה, עבירות בנייה) with her preferred quotes for each
- 8 substantive issues (תכנון נקודתי vs כולל, חיקוק תכנית, סטייה ניכרת,
  62א, חניה, תמ"א 38, תכניות ישנות, שימוש חורג)
- Lists ~30 external precedents she cites consistently + ~15 personal
  precedents (her own canon — 1110/20 בעלז, 1112/22 שקופה, 1181/22 אדלר,
  1130-25, etc.)
- Distinguishes precedents she cites vs. those she does NOT cite

docs/daphna-architecture-by-outcome.md
- 7 distinct block-yod architectures keyed to outcome type:
  1. Pure rejection (short, 555-2000 words)
  2. Rejection after complex analysis (2500-4500)
  3. Threshold dismissal + merits "ועל מנת לא לצאת בחסר" (mode F)
  4. Three or more distinct issues (sub-headings)
  5. Partial acceptance (full funnel architecture)
  6. Joined appeals
  7. Remand follow-up
- Decision tree for the agent (4 questions → architecture choice)
- Internal proportions table (opening 5-10%, doctrine 15-25%, etc.)
- Costs matrix with 6 scenarios

Updated docs/daphna-voice-fingerprint.md with section 6 (additions from
23-file corpus read): 2 new opening modes (F: threshold+merits, G:
remand follow-up), nuanced sub-heading rule, self-citation of full
analytical blocks, 10 new "we" verbs, 11 traditional phrases with
sources, expanded costs matrix, transparency about petition outcomes,
warning that 1015-24 is dissent (not Daphna's voice).

Updated .claude/agents/legal-writer.md to require reading all 4 voice
docs before block-yod (the "voice quartet"), with explicit decision
tree integration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 07:26:45 +00:00
bccc0a132f Refine voice fingerprint with full 1xxx corpus (24 cases)
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m3s
After analyzing all 24 building_permit decisions in style_corpus DB
(not just the 2 local files), refined two anti-patterns:

1. Sub-headings: actually permitted when block-yod handles 3+ distinct
   legal issues (e.g., 1079-24 had "הבקשות לפסילה" / "מעמד המבקשת
   וזכות עמידה" / "עותרים ציבוריים"). The earlier rule of "no
   sub-headings except academic cases" was too strict — based only on
   small local sample.

2. Paragraph numbering: discovered it's an evolutionary pattern, not
   a static rule. Pre-2025 decisions had sequential paragraph numbers
   (1, 2, 3 throughout); recent decisions (1126-25, 1128-25, 1130-25,
   1194-25) abandoned it for narrative flow. The agent should NOT add
   paragraph numbers — the new style.

The (1)...(2)...(3)... in-paragraph enumeration ban remains absolute —
0/33 final decisions used it. Distinction now made explicit:
in-paragraph enumeration ≠ paragraph-level numbering (former always
forbidden; latter is evolutionary).

Updated:
- docs/daphna-voice-fingerprint.md — corpus stats, refined anti-patterns
- .claude/agents/legal-writer.md — checklist with new distinctions

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 06:45:55 +00:00
deb8baab5d Inject Daphna's voice into legal-writer + corpus fingerprint
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 7s
Synthesized two voice documents from corpus reading:

- docs/voice-1130-25.md: deep read of case 1130-25 block-yod (5000 words),
  extracting the 9-movement funnel architecture, 8 reasoning templates,
  10 'we' verbs with their distinct functions, the 'akhen...ulam' pattern,
  pacing/silence principles, and the deliberative meta-narrative.
- docs/daphna-voice-fingerprint.md: cross-corpus synthesis of 10 finals
  (1 planning + 9 appraisal levy). Identifies 10 invariants, 5 opening
  modes mapped to outcome certainty, mandatory ברמ 3644/13 preamble for
  shamai cases, copy-paste templates, and 7 anti-patterns to avoid.

Updated .claude/agents/legal-writer.md:
- Added voice docs as MUST-READ before block-yod (was missing the deep
  voice layer; only had surface style_guide patterns)
- Replaced the ' (1)...(2)...(3)...' enumeration template with the 5 opening
  modes (the enumeration was a known anti-pattern Daphna always removes)
- Added the 'we' verbs catalog with explicit functions
- Made 'אכן...אולם' pattern mandatory for issues with substantial
  counter-arguments (was vaguely 'אמנם...אולם')
- Added mandatory ברמ 3644/13 preamble for 8xxx shamai cases
- Added self-citation triple-mode (refer/defer/distinguish) — Daphna's
  emerging practice of building personal jurisprudence
- Added 8-item anti-patterns checklist for post-write review
- Replaced block-yod-alef section with proper 4-paragraph closing
  template (process narrative → outcome → costs → date)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 19:38:17 +00:00
e88e5f3849 CEO: move issue to in_review while waiting on chaim
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 3m7s
Paperclip auto-blocks any in_progress issue without a live execution path
within ~1 minute of the run finishing. When the CEO ends a run with an
@chaim question pending, the main case issue was staying in_progress and
getting auto-blocked, flooding the case timeline with "automatically
retried continuation" system comments (7 occurrences on 2026-04-16).

Add an explicit status protocol to the CEO instructions:
- in_review at the end of any run that leaves a pending @chaim question
- in_progress when resuming from user_commented (also at start of comment routing)
- done only after final export

Applied at all three @chaim waiting points (stages B/C) and at the top
of comment routing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 05:52:21 +00:00
726498126d Add Track Changes architecture for draft revisions (CMP + CMPA)
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m29s
Fixes critical bug in 1033-25: user-uploaded עריכה-*.docx files were
orphaned on disk while exports kept rebuilding from stale DB blocks.

New architecture:
- User-uploaded DOCX becomes the source of truth (cases.active_draft_path)
- System edits via XML surgery with real Word <w:ins>/<w:del> revisions
- User can Accept/Reject each change from within Word

Components:
- docx_reviser.py: XML surgery for Track Changes (15 tests)
- docx_retrofit.py: retroactive bookmark injection with Hebrew marker
  detection + heading heuristic (9 tests)
- docx_exporter.py: emits bookmarks around each of the 12 blocks
- 3 new MCP tools: apply_user_edit, list_bookmarks, revise_draft
- 4 new/updated endpoints: upload (auto-registers active draft),
  /exports/revise, /exports/bookmarks, /exports/{filename}/retrofit,
  /active-draft
- DB migration: cases.active_draft_path column
- UI: correct banner using real v-numbers, "מקור האמת" badge,
  detailed upload toast with bookmarks_added/missing_blocks
- agents: legal-exporter (3 export modes), legal-ceo (stage G for
  revision handling), legal-writer (revision mode)

Multi-tenancy:
- Works for both CMP (1xxx cases) and CMPA (8xxx/9xxx cases)
- New revise-draft skill added to both companies
- deploy-track-changes.sh syncs skills CMP ↔ CMPA
- retrofit_case.py: one-off retrofit of existing files

Tests: 34 passing (15 reviser + 9 retrofit + 4 exporter bookmarks + 6 e2e)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-16 18:49:30 +00:00
28daff58be Pre-existing agent updates + analysis DOCX export
Updates accumulated from prior sessions:
- HEARTBEAT: company-based filtering (CMP/CMPA) rules
- legal-qa, legal-researcher: routine updates
- analysis_docx_exporter: new service for analysis DOCX export
- compose page: "הורד כ-DOCX" button for analysis
- decision_template.docx: template for exporter

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-16 18:49:10 +00:00
3da4d73498 Upgrade agents to Claude Opus 4.7
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m28s
- legal-analyst: opus 4.6 → opus 4.7
- legal-proofreader: opus 4.6 → opus 4.7
- legal-writer: sonnet 4.6 → opus 4.7 (complex block writing benefits from stronger model)
- block_writer MODEL_MAP: updated opus ID to 4.7

Opus 4.7 brings: high-res images (2576px), better file-based memory,
improved DOCX generation, and task budgets for agentic loops.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:10:56 +00:00
7b28549b2b CEO agent: require plugin_state linkage after creating issues
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 10s
New issues created by the CEO via curl were missing plugin_state records,
causing them to be invisible in the legal-ai UI. Added iron rule: after every
POST to create an issue, INSERT into plugin_state with the case number.
Also fixed 8070-25 CMPA issues directly in DB (3 records added).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 14:59:58 +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
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
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
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
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
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
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
444fb73681 Align all Paperclip agents with decision-methodology.md
All agents audited line-by-line against the new methodology.

legal-analyst (18 changes):
- Reads methodology before starting
- Issues formulated as syllogisms (rule + facts + question)
- SWOT replaced with analytical structure (rule/facts/open questions)
- Factual findings separated from legal conclusions
- Issue ordering: threshold → dispositive → secondary
- Claim handling section (bundle/skip recommendations)
- Standard of review field added
- CREAC preparation per issue
- Steel-man field per issue
- "הגוף המחליט" replaces "צד מיוצג"

legal-ceo (14 changes):
- Knows methodology exists, reads it before orchestrating
- Step B: asks claim handling (bundle/skip table) + appeal classification
- Step B: key questions as condensed syllogisms
- Step C: directions structured as syllogisms (rule + facts + conclusion)
- Step D: verifies chair_directions completeness before sending to writer
- Status map expanded with intermediate states
- Fallback conditions for every step
- Methodology consistency rule added

legal-researcher (4 changes):
- Reads methodology before starting
- Case law summaries include hierarchy level and CREAC role
- Plan mapping requires exact quotation + ambiguity detection
- Reporting structured by source type (text/precedent/policy)

legal-exporter (1 change):
- Verifies QA passed before export

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 23:43:42 +00:00
be9fa9e712 Add decision-writing methodology based on FJC, Garner, Posner sources
"בית ספר להחלטות" Phase 2 — the system now has formal analytical
methodology for building quasi-judicial decisions, separate from
Dafna's writing style (SKILL.md) and content checklists.

What was done:
- Downloaded 5 authoritative sources (~341K words): FJC Judicial
  Writing Manual (1991+2020), Garner Legal Writing in Plain English,
  Posner How Judges Think, Scalia/Garner Making Your Case
- Extracted principles from all sources into intermediate docs
- Synthesized into docs/decision-methodology.md (3,400 words,
  12 sections, 10 guiding principles)
- Integrated methodology into block-yod prompt via {methodology_guidance}
- Restructured legal-writer agent workflow to follow analytical stages
- Made "answer all claims" flexible (bundle/skip via chair_directions)
- Added methodology compliance check (#7) to legal-qa agent
- Updated all knowledge files (CLAUDE.md, SKILL.md, lessons, corpus)

Three-layer architecture:
1. Methodology (decision-methodology.md) — universal, how to think
2. Content checklists (lessons.py) — specific per appeal subtype
3. Style (SKILL.md) — Dafna's personal writing patterns

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 23:29:16 +00:00
0c4886afe6 Wire legal-writer to chair directions from analysis-and-research.md
Closes the loop so דפנה's positions (written inline in the UI and
saved to analysis-and-research.md) automatically become binding
direction for the legal-writer agent — no manual copy-paste,
no bypass.

Backend:
- research_md.extract_chair_directions(path) returns a compact dict
  with status (missing/empty/partial/complete), filled_count,
  empty_count, and a reduced list of threshold_claims + issues each
  with {id, number, title, direction}. Designed to be directly usable
  as direction_doc by the writer.
- New MCP tool: drafting.get_chair_directions(case_number) wraps the
  helper, resolves the case research file path via config.find_case_dir,
  returns formatted JSON.
- Registered in server.py as mcp__legal-ai__get_chair_directions.

legal-writer agent update:
- Adds get_chair_directions to the tools list.
- New mandatory "שלב 1ב" before any block writing: call
  get_chair_directions, branch on status.
  - missing → halt, report "legal-analyst לא רץ עדיין"
  - empty → halt, instruct Dafna to fill positions via the UI URL
  - partial → halt unless user confirms; write only filled sections
  - complete → proceed
- New "שלב 1ג" constructs an internal direction_doc from the
  received chair rulings before writing block י.
- Block י section expanded with 5 binding rules:
  1. Open each discussion with Dafna's ruling as the thesis
  2. Frame the reasoning in her style (use get_style_guide phrases)
  3. Match her tone (decisive vs nuanced)
  4. Must NOT contradict her position — if she disagreed with your
     own inclination, her position rules
  5. Use legal_questions from the analysis file as the analytical
     structure (principle question first, concrete application second)
- New bullet section for block יא: summarize each chair ruling
  briefly, state final outcome, close with the signed date formula.

Verified all four status paths (missing/empty/partial/complete) via
local test. Now Dafna's workflow is fully end-to-end: she reads the
analyst report in the UI, fills "עמדת ועדת הערר" in each card, hits
blur to auto-save, then triggers legal-writer — which picks up her
positions as direction without any file shuffle.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 13:04:30 +00:00
ecda95d610 Add committee position field to analyst template and fix UI
- Add "עמדת ועדת הערר" placeholder to legal-analyst agent template
  for each legal issue, to be filled by the chair as guidance for the
  writing agent
- Fix green checkmark not showing for proofread documents (treat
  'proofread' status same as 'completed')
- Show time alongside date in local files listing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 18:00:01 +00:00
3f759d3610 Improve document processing pipeline and agent workflows
- Add delete_document_chunks for reprocessing, save extracted text to disk
- Expand case directory structure (original/extracted/proofread/backup)
- Update classifier patterns (תגובה, הודעת עמדה)
- Fix proofreader agent paths for new directory layout
- Update HEARTBEAT to notify on every task completion
- Improve bidi_table with LRE/PDF directional embedding
- Add Paperclip project verification and auto-close setup issue
- Add auto-sync-cases.sh for Gitea synchronization

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 16:45:49 +00:00
22e819363e Flatten cases directory structure and unify paths
- Remove cases/new|in-progress|completed subdivision (status managed in DB)
- Rename documents/original → documents/originals (consistent plural)
- Move exports from global data/exports/ into cases/{num}/exports/
- Add documents/research/ for case law and analysis files
- Update all agents, scripts, config, web API endpoints, and DB paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 14:33:27 +00:00
4d674bf475 Add proofreader and exporter agents + abbreviations dictionary
- legal-proofreader: OCR proofreading agent (Opus) that fixes broken
  Hebrew text before legal analysis — corrects abbreviations (עוייד→עו"ד),
  broken words, and illogical sentences
- legal-exporter: Final draft export agent — validates decision,
  exports DOCX, saves versioned drafts (טיוטה-V1.docx etc.)
- abbreviations.json: Dictionary of ~70 Hebrew legal/general/planning
  abbreviations for automated OCR correction
- legal-ceo.md: Updated workflow to include proofreader before analyst
  and exporter after QA

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 20:34:10 +00:00
e1d2e18ea8 Add email notifications: agents send mail when human action needed
New: scripts/notify.py — sends via SMTP (notify@marcus-law.co.ilpaperclip+chaim@marcus-law.co.il)
Updated: HEARTBEAT.md — agents must send email when waiting for human decision

Triggers: outcome choice, direction approval, QA failures, review ready.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 17:07:43 +00:00
22196f48cb Enforce Hebrew-only output for all agents in HEARTBEAT.md
All agent output — comments, status, errors, summaries, thinking — must be in Hebrew.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 16:58:46 +00:00
4df2040a40 Fix: save_block_content now writes draft file + writer must update status
Two issues that caused QA agent to fail:
1. save_block_content saved to DB only — now also rebuilds drafts/decision.md
2. legal-writer.md now has explicit mandatory step: case_update(status="drafted")

Without these, workflow_status reports has_draft=false and QA can't run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 15:25:53 +00:00
e6293250aa Fix CEO agent: brainstorm directly instead of calling claude-in-claude
brainstorm_directions tool uses claude -p subprocess which times out
when called from inside a claude session (agent). CEO should think
about directions directly — it already has all the context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 18:37:45 +00:00
6a93292f56 Update CEO agent with interactive decision workflow via Paperclip
CEO now follows a step-by-step interactive flow:
A. Check status and what's been done
B. Summarize case + ask Chaim for outcome (1/2/3)
C. Read response, run brainstorm, present directions
D. Read direction choice, approve, launch writer agent
E. Monitor writing progress
F. QA and export

All interaction happens through Paperclip comments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 18:10:19 +00:00
65e78f493c Add CEO agent: עוזר משפטי — orchestrates all legal agents
Manages the decision writing pipeline:
- Creates issues and assigns to specialist agents
- Tracks status across all active cases
- Reports to human (Chaim) when approvals needed
- Never writes or analyzes directly — delegates

All 4 specialist agents now report to CEO.
Hierarchy: עוזר משפטי → מנתח/חוקר/כותב/בודק

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 17:18:35 +00:00
f4dd4f7134 Add shared HEARTBEAT.md checklist for all agents
Symlinked to Paperclip instructions directory for each agent.
Single source of truth: .claude/agents/ files → symlinked to Paperclip.
Cleaned duplicate soul_md from DB metadata.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 17:02:15 +00:00
4574987a69 Add 3 new agents: legal-researcher, legal-writer, legal-qa
Complete agent pipeline for decision writing:
1. legal-analyst (existing) — extract claims/responses/replies
2. legal-researcher (new) — analyze precedents, plans, protocols
3. legal-writer (new) — write decision blocks in Dafna's style
4. legal-qa (new) — validate before export (6 checks)

All agents use claude_local adapter (Claude Code session, zero API cost).
Each has YAML frontmatter with specific tools and detailed Hebrew instructions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 16:47:28 +00:00
9ba489ee21 Add legal-analyst agent definition in .claude/agents/
Defines the agent's role, tools, document type rules, and workflow.
Linked to Paperclip agent via --agent legal-analyst extraArg.

Key rules:
- Claims only from appeal docs, responses from response docs, replies from supplementary
- Never extract from precedents, plans, or protocols
- Must report results to Paperclip before finishing

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