fix(company): terminalize report-chain failure into FAILED settlement; prompt-spill hygiene

Report chain: when consecutive report cards exceed the failure limit the
parent now fails through transition_work_item (settlement, dependents,
manager visibility) instead of parking forever in AWAITING_MANAGER_REVIEW
behind a metadata hold no reconcile path could clear. The hold stamp
survives only as the quarantine fallback when the FAILED write does not
land, mirroring the attempt ledger's terminalize pattern.

Cursor prompt spill: one stable file per task (retries overwrite instead
of accumulating) and a self-ignoring .gitignore so workspace git never
picks up .opc/external_prompts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
LZH-YS1998
2026-07-31 19:53:13 +08:00
parent 18ddc18948
commit 5f5fbf432e
4 changed files with 121 additions and 17 deletions
+8 -3
View File
@@ -3,7 +3,6 @@
from __future__ import annotations
import asyncio
import hashlib
import re
import shutil
from pathlib import Path
@@ -128,9 +127,15 @@ class CursorAdapter(ExternalAgentAdapter):
root = Path(".").resolve()
prompt_dir = root / ".opc" / "external_prompts"
prompt_dir.mkdir(parents=True, exist_ok=True)
# Self-ignoring directory: agents run `git add` in the workspace and
# must never commit spilled prompts.
gitignore_path = prompt_dir / ".gitignore"
if not gitignore_path.exists():
gitignore_path.write_text("*\n", encoding="utf-8")
task_id = str(getattr(task, "id", "") or "").strip() or "task"
digest = hashlib.sha256(prompt_text.encode("utf-8")).hexdigest()[:16]
prompt_path = prompt_dir / f"cursor_{task_id}_{digest}.md"
# One stable file per task: retries and resumes overwrite instead of
# accumulating a new file per prompt revision.
prompt_path = prompt_dir / f"cursor_{task_id}.md"
prompt_path.write_text(prompt_text, encoding="utf-8")
pointer = (
"Open and follow the complete task instructions in this file exactly:\n"