feat(tasks): 提供版本化且有界的 Task-grounded 证据包
问题
Task Graph 已默认开启,并持久化 Logical Task、Task Attempt、关系、证据范围、执行身份和用量归因;但生产 Skill 链路仍然只消费 Atom 形态的候选。Q1 要求 Task-grounded Formation 成为真实证据边界,因此在路由和 SkillEdit 接入前,需要一个版本化、有界、隐私安全且不暴露 SQLite/宿主机路径的读取契约。
同时需要明确:用户/任务结果评分属于 Task/Attempt 结果,不是 Atom 边界质量,也不是 (atom_id, skill) 的支持强度。
方案
新增基于单个不可变 Task Graph generation 构建的 TaskEvidenceBundle:
- 保存 tenant、TaskScope、Task、generation 与 source revision 身份;
- 保存 Task 生命周期/结果、已确认 primary Atom membership、Attempt 与关系;
- 只保存有界 EvidenceRange/Atom 引用,不复制原始轨迹正文;
- 保留模型、Harness、Skill 与实测/估算/不可用的用量 provenance;
- 显式输出学习资格和原因;
- 同时提供 generation 级审计指纹与跨 generation 稳定的 Task 证据指纹;
- 对集合数量和序列化字节数设置硬上限。
只有已确认的 primary membership 能进入默认学习证据。未解决、过期、墓碑、跨 scope 或不完整事实必须 fail closed,并保持可观察。
本 Issue 只定义读取契约,不改变 Skill 路由、SkillEdit、Canary 或发布行为。
验收标准
- [x] Schema 版本化、严格校验并确定性序列化。
- [x] Bundle 绑定单个不可变 Task Graph generation。
- [x] Tenant/TaskScope、墓碑、过期证据和未解决 membership 均有关闭式校验。
- [x] Attempt 与证据范围确定性排序,并具有数量硬边界。
- [x] 序列化结果具有 1 MiB 硬边界,超限早停。
- [x] generation 元数据变化不会改变 Task 证据语义指纹。
- [x] 用量 provenance 不虚构缺失 Token 或成本。
- [x] 学习资格与边界置信度、
weightscore相互独立。 - [x] 覆盖重试、纠正、不完整结果、未解决 membership、过期证据、重建幂等和跨 scope 测试。
- [x] 契约未使用时,既有生产行为不变。
Refs #327、#346、#379、#394、#397、#398。
Implementation is prepared locally as one focused, signed-off commit.
Implemented scope:
- versioned and strictly validated
TaskEvidenceBundleschema; - deterministic ordering and SHA-256 content fingerprinting;
- one-generation identity/source fencing and published-store reload stability;
- confirmed-primary-only learning evidence, with unresolved membership kept separate;
- bounded memberships, relations, Attempts, EvidenceRanges, and usage allocations;
- fail-closed handling for tombstones, stale evidence, missing ownership, and cross-scope references;
- Task Outcome-based learning eligibility, including semantic revalidation on deserialization;
- preservation of unavailable Token/cost provenance without inventing values.
Verification:
- 56 focused Task evidence and Task Graph runtime tests passed;
- Ruff check and format check passed;
- 2 files / 699 added lines, within the repository review budget.
I am intentionally holding the PR publication until #404 restores the inherited main-branch scheduler checks and the current active PR queue drops below the configured WIP limit. This avoids opening another immediately unstable PR; no OfficeQA Full run is involved.
当前实现进度
PR #411 已更新到最新修复:
- 新增跨 generation 稳定的 Task 证据语义指纹
- 保留 generation 级 bundle 指纹用于审计和 fencing
- 新增 1 MiB 序列化硬边界与
limit + 1早停 - 嵌套解析异常统一 fail closed
- 16 项定向测试和增量 Ruff 门禁通过
- CI 同款完整 UT/IT 为 2820 通过,仅剩 #404 已修复的两个主分支基线断言
下一步由 maintainer 先合并全绿的 #404,再完成 #411 最终 review。