Cai
2026-08-10 dcbb7e56299807c54800f7b1a7d76e39df5e9df0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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)