Files
bot_dev1 5bc7ff957e feat(#53): 移动端交接班摘要生成(NL,PRD 场景C ⑤ 移动端交接班摘要)
对应 PRD 场景C(辅助):交接班 → LLM 汇总本班关键事件/能耗/待办 → 生成交接班
报告 → 推送下一班(line 84/350-351)。把本班原始数据 → 移动端交接班摘要这条
链路模板化、可配置、可测试。

新增 core/shift-handover 内核模块:
- handover.py:班次数据归一化(ShiftRecord) + 摘要配置(HandoverBriefConfig) +
  validate/load 校验对 + build_llm_input(填 shift_handover v1.0.1 提示词占位符) +
  generate_handover_brief(LLM 注入生成, 离线/故障自动降级为确定性摘要) +
  render_handover_brief(编译移动端只读卡片 props)
- 零运行时依赖(仅标准库); LLM 以依赖注入传入, 内核不绑定云端 SDK
- 离线/LLM故障降级保证可用性≥99.8%(PRD 模型服务故障自动降级)
- 含 P0/安全事件时强制 requireConfirm=true(PRD 高利害人工确认)

新增资产/测试/验收:
- templates/ti-cl4/dashboard/handover_brief.ti.yaml(Ti 模板配置资产)
- tests/test_handover.py(32 用例全通过) + tests/_bootstrap.py(连字符目录挂载)
- scripts/verify_handover_brief.py(4 能力点全通过: 配置合法/LLM+降级/
  配置点驱动展示/≤2分钟验收线)
- README.md

验证: python -m unittest discover -s tests (32 OK) +
      python scripts/verify_handover_brief.py (全部通过)
2026-08-05 03:38:07 +08:00

76 lines
2.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""iAOP-Core · 交接班摘要模块(shift-handover)—— 对齐 PRD 场景C / 5.4「④ LLM 网关」。
对外暴露 issue #53「移动端交接班摘要生成(NL)」的能力:把本班关键事件/能耗/待办/
异常归一为 ``ShiftRecord``,按模板配置(``HandoverBriefConfig``)经 LLM(或离线
确定性降级)生成交接班摘要,并编译成移动端只读卡片可直接消费的 props。
LLM 以依赖注入形式传入(``llm_generate``),内核不绑定具体云端 SDK;未注入或调用
失败时自动降级为 ``render_deterministic_brief``(PRD「模型服务故障自动降级」、
「可用性 ≥ 99.8%」),保证离线/降级时交接班链路不中断。
测试:`python -m unittest discover -s tests -v`(在 core/shift-handover 目录下)。
验收:`python scripts/verify_handover_brief.py`。
"""
from __future__ import annotations
from .handover import ( # noqa: F401
DEFAULT_COLLAPSE_THRESHOLD,
DEFAULT_MAX_EVENTS,
DEFAULT_MAX_TODOS,
DEFAULT_PROMPT_TEMPLATE,
DEFAULT_PROMPT_VERSION,
DEFAULT_REQUIRE_CONFIRM,
HANDOVER_CONFIG_SCHEMA_ID,
HANDOVER_CONFIG_SCHEMA_VERSION,
HANDOVER_GENERATION_BUDGET_MS,
MAX_ALLOWED_EVENTS,
MAX_ALLOWED_TODOS,
VALID_FONT_SIZES,
VALID_SECTIONS,
HandoverBriefConfig,
HandoverConfigError,
HandoverConfigValidationResult,
ShiftEvent,
ShiftRecord,
ShiftTodo,
build_llm_input,
generate_handover_brief,
load_handover_config,
normalize_shift_record,
render_deterministic_brief,
render_handover_brief,
validate_handover_config,
within_generation_budget,
)
__all__ = [
"DEFAULT_COLLAPSE_THRESHOLD",
"DEFAULT_MAX_EVENTS",
"DEFAULT_MAX_TODOS",
"DEFAULT_PROMPT_TEMPLATE",
"DEFAULT_PROMPT_VERSION",
"DEFAULT_REQUIRE_CONFIRM",
"HANDOVER_CONFIG_SCHEMA_ID",
"HANDOVER_CONFIG_SCHEMA_VERSION",
"HANDOVER_GENERATION_BUDGET_MS",
"MAX_ALLOWED_EVENTS",
"MAX_ALLOWED_TODOS",
"VALID_FONT_SIZES",
"VALID_SECTIONS",
"HandoverBriefConfig",
"HandoverConfigError",
"HandoverConfigValidationResult",
"ShiftEvent",
"ShiftRecord",
"ShiftTodo",
"build_llm_input",
"generate_handover_brief",
"load_handover_config",
"normalize_shift_record",
"render_deterministic_brief",
"render_handover_brief",
"validate_handover_config",
"within_generation_budget",
]