M8:天工阁、叩心与辰正——受托任务后台并行、叩心四约束、时态感知投影

- 天工阁域 domains/tiangong:backstage_tasks(委托包+验收标准+结果证据);有限分解(parent 链)与受控并行(各自后台 Run);子任务全终态级联父任务进入待验收;按证据 accept/reject
- kernel.start_backstage_run(kind=background_task):loop 后台分支不占前台席位、与前台对话并行;断言放宽容纳无人物功能任务;结果只经回调回呈任务——无身份写入路径
- 叩心域 domains/kouxin:knocking_candidates(event/time_anchor/manual 触发 + 草稿 + 裁决快照);四约束裁决(总开关→静默窗口【本地时区判定】→24h 频率→预算),dispatch 未过 429 且快照留痕;候选默认不自动发送;expire_stale 过期推进不触碰缘契
- 辰正 domains/zhengchen:temporal_context() 复用 time_sense 计算核(快照/农历/季节),产出【时态感知】投影段接入镜树生成 prompt(客观时间语境,不附情绪臆测——守一纪律)
- 退役:modules/goal_orchestrator|planner|perception|big_cycle、application/planning、services/governance|goal_persist、candidates 表链(imports 候选抽取 API 面)、goals/plans/agent_roster/perception_channels/big_cycles/旧候选表(迁移 009);前端 admin goals/plans/agents/perception/world 页与六组件;governance 只留 GenerationPreferences;admin 治理面收敛为司命+百工两枢;pivots 健康以域表计数重建
- 验收(test_m8_tiangong 五用例):后台任务无身份写入(记忆/魂籍/缘契零新增);后台与前台并行;分解级联;叩心四约束逐项;不回应不降低关系(缘契维度/状态/版本零变化)
- 四套件:后端 345、前端 203、BFF 4、神识 5 包全绿(2 个预存环境失败不变);迁移 009 净库干净
This commit is contained in:
chenxin committed 2026-08-28 09:13:39 +08:00
1 parent b419e0afde
commit c63b75152a
68 files changed
+1205 -4750

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
"""天工阁表模型:后台受托任务(无魂籍的功能代理任务)。
设计依据 mandate-and-capability-model.md §7 与 PRD §9.5:
- 任务 Agent 是功能代理,没有魂籍、缘契、情态或独立长期身份;
- 承载受托任务、有限分解、受控并行与按证据验收;
- 后台 Run(runs.kind=background_task)不占前台席位、不构成第二意识。
"""
from datetime import datetime
from sqlalchemy import DateTime, ForeignKey, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.core.ids import new_id
from app.core.time import utc_now
from app.db.base import Base
class BackstageTask(Base):
"""受托任务:委托包 + 验收标准 + 结果证据;可分解(parent 链)受控并行。"""
__tablename__ = "backstage_tasks"
id: Mapped[str] = mapped_column(String(80), primary_key=True, default=lambda: new_id("task"))
owner_scope: Mapped[str] = mapped_column(String(80), nullable=False, index=True)
# 委托对象人物(可空:纯功能任务无人物语境)
character_id: Mapped[str | None] = mapped_column(
String(80), ForeignKey("characters.id"), nullable=True, index=True
)
# 父任务(分解链:子任务并行执行,全部完成后父任务进入待验收)
parent_task_id: Mapped[str | None] = mapped_column(
String(80), ForeignKey("backstage_tasks.id"), nullable=True, index=True
)
title: Mapped[str] = mapped_column(String(200), nullable=False)
# 最小委托包(受托边界:达成目标与停止条件;任务 Agent 不扩使命)
brief: Mapped[str] = mapped_column(Text, nullable=False, default="")
# 按证据验收:明确的完成判据
acceptance_criteria: Mapped[str] = mapped_column(Text, nullable=False, default="")
# pending / running / awaiting_acceptance / accepted / rejected / failed
status: Mapped[str] = mapped_column(String(30), nullable=False, default="pending", index=True)
# 执行产出(净化摘要 + 证据引用;不构成身份/记忆写入)
result_digest: Mapped[str] = mapped_column(Text, nullable=False, default="")
evidence_json: Mapped[str] = mapped_column(Text, nullable=False, default="{}")
# 关联后台 Run(kind=background_task,不占前台席位)
run_id: Mapped[str | None] = mapped_column(String(80), index=True)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utc_now)
completed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))