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>
This commit is contained in:
@@ -81,12 +81,21 @@ tools:
|
|||||||
3. שמור (`save_block_content`)
|
3. שמור (`save_block_content`)
|
||||||
4. דווח התקדמות ל-Paperclip
|
4. דווח התקדמות ל-Paperclip
|
||||||
|
|
||||||
### שלב 3: דיווח — חובה!
|
### שלב 3: סיום — חובה!
|
||||||
פרסם comment ב-Paperclip עם:
|
|
||||||
|
**אחרי שכל הבלוקים נשמרו, חובה לבצע את שתי הפעולות הבאות:**
|
||||||
|
|
||||||
|
1. **עדכן סטטוס התיק ל-drafted:**
|
||||||
|
```
|
||||||
|
case_update(case_number, status="drafted")
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **פרסם comment ב-Paperclip עם:**
|
||||||
- אילו בלוקים נכתבו
|
- אילו בלוקים נכתבו
|
||||||
- ספירת מילים לכל בלוק
|
- ספירת מילים לכל בלוק
|
||||||
- יחסי משקל (% מהמסמך)
|
- יחסי משקל (% מהמסמך)
|
||||||
- עדכן סטטוס ל-drafted
|
|
||||||
|
**אם לא תעדכן סטטוס ל-drafted — בודק האיכות לא יוכל לרוץ!**
|
||||||
|
|
||||||
## בלוק י — דיון (הבלוק החשוב ביותר)
|
## בלוק י — דיון (הבלוק החשוב ביותר)
|
||||||
|
|
||||||
|
|||||||
@@ -685,7 +685,10 @@ async def get_block_context(case_id: UUID, block_id: str, instructions: str = ""
|
|||||||
|
|
||||||
|
|
||||||
async def save_block_content(case_id: UUID, block_id: str, content: str) -> dict:
|
async def save_block_content(case_id: UUID, block_id: str, content: str) -> dict:
|
||||||
"""Save block content written by Claude Code (or any external writer)."""
|
"""Save block content written by Claude Code (or any external writer).
|
||||||
|
|
||||||
|
Saves to DB and also writes/updates the draft file on disk.
|
||||||
|
"""
|
||||||
if block_id not in BLOCK_CONFIG:
|
if block_id not in BLOCK_CONFIG:
|
||||||
raise ValueError(f"Unknown block: {block_id}")
|
raise ValueError(f"Unknown block: {block_id}")
|
||||||
|
|
||||||
@@ -699,9 +702,37 @@ async def save_block_content(case_id: UUID, block_id: str, content: str) -> dict
|
|||||||
result["model_used"] = "claude-code"
|
result["model_used"] = "claude-code"
|
||||||
|
|
||||||
await store_block(UUID(decision["id"]), result)
|
await store_block(UUID(decision["id"]), result)
|
||||||
|
|
||||||
|
# Also write/update the draft file on disk
|
||||||
|
await _update_draft_file(case_id, UUID(decision["id"]))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
async def _update_draft_file(case_id: UUID, decision_id: UUID) -> None:
|
||||||
|
"""Rebuild drafts/decision.md from all blocks in DB."""
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
case = await db.get_case(case_id)
|
||||||
|
if not case:
|
||||||
|
return
|
||||||
|
|
||||||
|
case_dir = config.find_case_dir(case["case_number"])
|
||||||
|
draft_dir = case_dir / "drafts"
|
||||||
|
draft_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
pool = await db.get_pool()
|
||||||
|
async with pool.acquire() as conn:
|
||||||
|
rows = await conn.fetch(
|
||||||
|
"SELECT content FROM decision_blocks WHERE decision_id = $1 AND content != '' ORDER BY block_index",
|
||||||
|
decision_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
draft_path = draft_dir / "decision.md"
|
||||||
|
draft_path.write_text("\n\n".join(row["content"] for row in rows if row["content"]), encoding="utf-8")
|
||||||
|
logger.info("Draft file updated: %s (%d blocks)", draft_path, len(rows))
|
||||||
|
|
||||||
|
|
||||||
# ── Renumbering ───────────────────────────────────────────────────
|
# ── Renumbering ───────────────────────────────────────────────────
|
||||||
|
|
||||||
async def renumber_all_blocks(decision_id: UUID) -> dict:
|
async def renumber_all_blocks(decision_id: UUID) -> dict:
|
||||||
|
|||||||
Reference in New Issue
Block a user