from __future__ import annotations
|
|
from collections import OrderedDict
|
from datetime import datetime, timezone
|
import hashlib
|
from pathlib import Path
|
|
from hibor_fast_collection.models import TASK_KEYS
|
|
|
def task_spec(root: Path, *, mode: str = "dry-run", quantity: int = 1) -> OrderedDict:
|
values = {
|
"schema_version": "HIBOR_FAST_TASK_SPEC_V004",
|
"contract_version": "REPORT-COLLECTION-CAPABILITY-V1",
|
"project_id": "project-info", "handoff_id": "HANDOFF-TEST", "task_id": "TASK-TEST",
|
"source_role_instance_id": "case_analysis.report_collector",
|
"source_thread_id": "thread-source", "target_role_instance_id": "dev.developer.ana.cai",
|
"target_thread_id": "thread-target", "reply_thread_id": "thread-reply",
|
"requester": "case_analysis.report_collector", "review_owner": "case_analysis.report_collector",
|
"mode": mode, "query": "中国中免", "quantity": quantity, "aliases": [], "analysts": [],
|
"institutions": [], "report_types": ["行业研报"], "date_range": None,
|
"minimum_pages": 1, "exclude": [], "source_scope": {},
|
"destination": "ana-data/tmp/test", "priority": "NORMAL", "naming_requirement": "standard",
|
"output_root": str(root / "output"), "quota_ledger": str(root / "quota.csv"),
|
"adb_executable": str(root / "adb.exe"), "pdfinfo_executable": str(root / "pdfinfo.exe"),
|
"package_name": "cn.com.hibor",
|
"cache_root": "/sdcard/Android/data/cn.com.hibor/files/myfile/", "device_serial": None,
|
"observed_at_utc": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
|
"total_budget_ms": 600_000 + 240_000 * (quantity - 1), "close_reserve_ms": 30_000,
|
"batch_increment_budget_ms": 240_000, "min_screens": 3, "normal_max_screens": 5,
|
"hard_max_screens": 20, "hard_max_candidates": 100,
|
"performance_slot_id": "SLOT-1", "performance_plan_id": "PERF-1",
|
"expected_reports": [],
|
}
|
if mode in {"collect-one", "batch"}:
|
reports = [
|
("中国中免深度研究", "测试证券", "2026-07-29", 1),
|
("中国中免 NEW REPORT", "NEW-INSTITUTION", "2026-07-29", 1),
|
]
|
while len(reports) < quantity:
|
reports.append((f"中国中免测试报告{len(reports) + 1}", "测试证券",
|
"2026-07-29", 1))
|
values["expected_reports"] = [
|
{
|
"report_identity": hashlib.sha256(
|
f"{title}|{institution}|{report_date}".encode("utf-8")
|
).hexdigest(),
|
"title": title,
|
"institution": institution,
|
"report_date": report_date,
|
"page_count": pages,
|
}
|
for title, institution, report_date, pages in reports[:quantity]
|
]
|
return OrderedDict((key, values[key]) for key in TASK_KEYS)
|