atlas-project-harness 0.4.0-beta.3 → 0.4.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/DESIGN.md +3 -0
  3. package/NOTICE +17 -0
  4. package/README.md +19 -1
  5. package/_support/__pycache__/workflow_finish.cpython-312.pyc +0 -0
  6. package/_support/__pycache__/workflow_plan.cpython-312.pyc +0 -0
  7. package/_support/__pycache__/workflow_verify.cpython-312.pyc +0 -0
  8. package/_support/workflow_finish.py +197 -8
  9. package/_support/workflow_plan.py +80 -3
  10. package/_support/workflow_verify.py +136 -0
  11. package/apply/reference.md +20 -0
  12. package/bin/atlas.js +1 -1
  13. package/install.py +6 -0
  14. package/package.json +2 -1
  15. package/patches/project-wiring/agent-pointer.md +1 -1
  16. package/scripts/__pycache__/atlas_check.cpython-312.pyc +0 -0
  17. package/scripts/__pycache__/atlas_review.cpython-312.pyc +0 -0
  18. package/scripts/__pycache__/atlas_workflow.cpython-312.pyc +0 -0
  19. package/scripts/__pycache__/changelog_guard.cpython-312.pyc +0 -0
  20. package/scripts/__pycache__/ledger_snapshot.cpython-312.pyc +0 -0
  21. package/scripts/__pycache__/pkg_digest.cpython-312.pyc +0 -0
  22. package/scripts/__pycache__/preflight.cpython-312.pyc +0 -0
  23. package/scripts/__pycache__/release.cpython-312.pyc +0 -0
  24. package/scripts/atlas_check.py +2 -1
  25. package/scripts/atlas_review.py +188 -67
  26. package/scripts/atlas_workflow.py +85 -9
  27. package/scripts/changelog_guard.py +17 -0
  28. package/scripts/ledger_snapshot.py +76 -5
  29. package/scripts/pkg_digest.py +1 -1
  30. package/scripts/preflight.py +6 -2
  31. package/scripts/release.py +61 -11
  32. package/shared/closeout.md +14 -3
  33. package/shared/gates.md +8 -8
  34. package/shared/independent-review.md +13 -4
  35. package/shared/single-source.md +2 -0
  36. package/shared/stack-profile.md +7 -5
  37. package/skills/atlas-ablate/SKILL.md +140 -106
  38. package/templates/adr/template.md +3 -1
  39. package/templates/stack-profile.yaml +6 -4
  40. package/validators/__pycache__/validate_adr.cpython-312.pyc +0 -0
  41. package/validators/__pycache__/validate_e2e_index.cpython-312.pyc +0 -0
  42. package/validators/__pycache__/validate_prd.cpython-312.pyc +0 -0
  43. package/validators/__pycache__/validate_task_card.cpython-312.pyc +0 -0
  44. package/validators/validate_adr.py +10 -6
  45. package/validators/validate_e2e_index.py +93 -0
  46. package/validators/validate_prd.py +49 -0
  47. package/validators/validate_task_card.py +50 -3
package/CHANGELOG.md CHANGED
@@ -4,6 +4,36 @@
4
4
 
5
5
  ---
6
6
 
7
+ ## [v0.4.0-beta.5] - 2026-11-21
8
+
9
+ - feat(e2e): 文案齐套判据(`#74`)——`validate_e2e_index` 新增「文案齐套」检查:域级 PRD `**文案规范**` 表「场景 | 文案」列 ⇄ 分片 step/expected 的 text/contains/waitFor 期望值差集(`$变量` 运行时取数不比对、`#` 注释先剥、占位 `[必填]`/「不适用(…)」/待定不收);漏断言 ⇒ **WARN 纪律面**(升格 FAIL 另案);全占位/无表 ⇒ `N/A` 门控态;v3 真实仓实测 57 条声明文案 37 条漏断言出声;门册行与 docs/map 同步、用例数锚 205→210(+5 测试)
10
+ - feat(workflow): 需求条目覆盖三件套(`#71/#72/#73`)——`single-source.md` 登记「需求原文(外部原件的仓内转换稿)」为真相源(带页码锚、空白页保留)并把权威源排序写死(需求原文 > 任务 prd.md > 设计文档 > 代码惯例;矛盾登记冲突按 §15 上报,不许就地二选一);`plan --requirement` 自动生成 `requirement-items.md` 条目表骨架(`ID | 页码 | 章节 | 原文`,文末总数自检;重跑不覆盖已填)与 `coverage-matrix.md` 覆盖矩阵骨架(行=条目 ID,列=PRD/设计文档/实现/E2E);`verify` 独立审查通过后跑条目覆盖对账(新增 `_support/workflow_verify.py`:矩阵缺席 / 格留空 / 值出词表 / UNRESOLVED / 条目⇄矩阵双向差集 ⇒ **WARN 纪律面起步**,升格 FAIL 另案;非需求驱动卡沉默不判);`dispatch` 输出开工前提醒
11
+ - feat(release): 发版提交白名单——`chore(release)` 只准含 7 个版本落点,夹带即拒且不带逃生口;查两处(测试门禁前查 HEAD + 建提交后复查),堵「手工预制发版提交→复用发版」旁路(复盘 R5;`787dd42` 曾夹带 install.py/golden/specs 20 文件)
12
+ - feat(ledger,guide): 裸数字 lint(`--lint-bare-numbers`,M194)+ `docs/map` 五处「12 器」转派生占位(实为 13)+ 新派生键 前置SKIP器/前置SKIP清单(散文写 7 列 6 的枚举漂移一并治)+ guide changelog 镜像化(release.py 从根 CHANGELOG 生成,退役人工写入口)+ preflight 触发映射补派生源 `scripts/atlas_check.py`、`validators/`(复盘 R1/L1/C3/R4)
13
+ - feat(skill): atlas-ablate 重定位「自进化减法引擎」(D206)——目的从门禁价值证明改为自进化减负(周期锚=模型代际,目标函数=质量×速度×token);漏斗制三层(成本账本筛短名单→守卫语料豁免→捆绑摘除 A/B,每代 ≈12–30 任务跑,零新代码);减法判据四护栏(保险型豁免=30案台账+灾难面/双证据立案/最小持续2代/复归触发器)+ 降频档位;质量判分(后置未参战门册+人盲评二元+质量噪声带);跨代账本三指纹+方向性案例研究措辞;旧「不给删留结论」纪律作废(四护栏承接);SKILL 重写 + 层3 runbook 落 research/(双评审首轮各3 Blocker 修后再审,修订版终审双通过)
14
+ - fix(ergonomics): `workflow_finish` scope 拦截三分类诊断(W2-②)——extra(审查产物误入暂存面 ⇒ 指名 unstage 指引,重跑 verify 无效)/ missing / changed(⇒ 重新审查)分道指路,替换原「请重新运行 verify」死循环指引;`atlas review` 会话派工包新增「探索预算(硬)」节(W1 模板化:只读指针与实审集、工具上界 N+8、复审收窄、异常扩面须登记 warnings;`independent-review.md` §10.4 同步补方向性纪律行)
15
+ - feat(gate): `validate_prd` 新增「版本口径一致」独立行(W3-① 缩形,首版 WARN)——frontmatter version ⇔ 变更记录最新数据行 + 规则/AC 表内 semver 字面量全链一致(自进化 campaign T3/T4 四次实证失败全部命中本面);+3 测试(17 条)
16
+ - docs(rubric): 层 3 盲评 rubric v0 落 research(五维二元 + indistinguishable 纪律 + 版本化头),runbook §4.3 挂指针
17
+ - fix(gate): `validate_task_card` 收域级 AC 词形 + PRD 存在性校验(D208)——workflow plan 生成的域级 AC 验收行不再必然 `card_acceptance_invalid`;域级编号须在采纳仓 PRD 真实存在(杜撰 ⇒ 新码 `card_acceptance_absent`,比原形态校验更严);方案层 token 投影语义不变;+3 测试(27 条)
18
+ - feat(ablation): RFC-20261101-04「不做(永不):整线束 on/off」显式收窄为工具面(D207)——装配级 L0 宏观锚改双独立快照人工流程(每代 ≤6 跑,预登记五件套),不经 ablation 工具、不进活仓切换
19
+ - feat(canonical): 变异钉双向化——新增 `check_pin_implementation`(门册登记 ⊖ 线束实现即红,M195),盘点清残留:真幽灵 M21/M25 补实现、9 枚实现存在未标号补标、M2x 简写与 M65 陈旧指向修正、`变异编号上限` 派生改扫 docstring(夹具载荷钉号不再当事实);判据类 review 必填「真实样本@commit + 应判不中的反例」(复盘 R3/P3)
20
+
21
+ ## [v0.4.0-beta.4] - 2026-11-20
22
+
23
+ ### 🧭 偏差处置与 ADR 否决态(`RFC-20261120-01`)
24
+
25
+ * `validate_adr` 新增 `rejected` 合法状态:`accepted` / `rejected` 的 Decision 必须非空(rejected 写「为什么不引入」);ADR 模板同步枚举,并加双源一致性钉;
26
+ * `apply` 契约新增 §5.3「偏差三岔口」:实现期偏差按 `spec_gap` / `spec_amend` / `out_of_scope` 归因,只有 `spec_amend` 回写上游;
27
+ * 收口清单新增步骤 12(偏差三岔口对账)与触发行,编号口径改为 1–5、7–12;`atlas_check` 结构漂移 WARN 追加处置指引。
28
+
29
+ ### 🔒 执行层收口(`#68` `#69` `#70`)
30
+
31
+ * `atlas review` 新增 `impl_review.executor: cli|session`:无可用 CLI 时生成 `review-request.md` 派工包并以「待审」(exit 2)退出,会话子代理写 `cli.json` 后复跑完成转换/校验;`finish` 仍只认 `review.json` PASS(`#68`);
32
+ * `finish` 读取任务 AC 关联的 E2E 结论:`red` 阻断收口,索引缺失 / 无 AC 映射 / `skipped` 显式 `SKIP` 并落 `task.json`;验收走查留痕单独记录(`#69`);
33
+ * `finish` 收口后幂等归档到 `.atlas/tasks/archive/`;`load_tasks` 默认只看活跃任务,`status --all` 展示归档;新增 `atlas workflow archive` 供既存 `completed` 单元一次性迁移(`#70`)。
34
+
35
+ ---
36
+
7
37
  ## [v0.4.0-beta.3] - 2026-11-20
8
38
 
9
39
  ### 🧭 只读上下文预览
@@ -17,6 +47,12 @@
17
47
 
18
48
  * `.gitignore` 接线新增 `.atlas` 白名单块:默认 `.atlas/*` 忽略引擎镜像,`!.atlas/tasks/`、`!.atlas/spec/` 放行项目规范与任务账本;带标记幂等,用户已手写任意 `.atlas` 规则时保留其口径不覆盖。
19
49
 
50
+ ### 📜 许可与署名
51
+
52
+ * 新增根 `NOTICE`(Apache-2.0 §4d),并随 `.atlas/` 装配分发、纳入 MANIFEST 摘要与自检声明;
53
+ * `docs/`、`rings/`、`skills/` 中面向人的说明性文字单独按 CC BY 4.0 授权(`docs/LICENSE`:署名 + 附原文链接 + 标明修改),代码仍为 Apache-2.0;
54
+ * 新增 `CITATION.cff`(GitHub 显示 “Cite this repository”);README 增「出处与署名」段:采用本方法论的衍生项目请注明来源。
55
+
20
56
  ---
21
57
 
22
58
  ## [v0.4.0-beta.2] - 2026-11-20
package/DESIGN.md CHANGED
@@ -671,6 +671,9 @@ adapters:
671
671
  | D203 | **自建执行层第一刀:实现完成暂存区独立审查(check 行为者;`atlas review --staged` + 工具链并轨 + 审修循环;RFC-20261119-02;D100 区分)**(2026-11-19;`scripts/atlas_review.py`、`patches/project-wiring/agent-pointer.md`、`proposals/RFC-20261119-02-check-actor-auto-review.md`、`tests/test_atlas_review.py`;动因 = 执行层 停更、会话内 Verify 与 Atlas 判据面脱节,实现完成到收口间审查全靠口头请求) | ① **终局拍板**:执行层终局 = **执行层 等界编排接管**(编排/注入/持久化/检查四阶段皆可接管;写码仍由宿主 agent 执行;不产需要创造判断的业务代码;**R-5 细化非翻案**:Atlas 产确定性派生物、编排实现阶段、不产业务实现)。② **触发面定案**:**v1 = B2 (agent-pointer 纪律行) + C (`atlas review --staged` 入口)**;A (git 钩子) 降为条件候选(前置:D100 显式区分案 + 需求 ID 机器通道)。**D100 显式区分**:D100 否的是提交期同步校验兜底阻断;本案是实现完成暂存后由 agent-pointer 纪律提醒的显式独立审查与工具链复验,软形态不阻断提交,硬门设在收口侧(无报告视同未审)。③ **管线扩展**:`atlas review` 支持 `--staged`(与 `--from/--to` 互斥,不传 ref 时底层以 staged 模式调审查器并自动反查暂存文件);支持 `--check-cmd` 将确定性检查结果同轨并入步骤与报告;支持 `--auto-fix` / `--fix-cmd` 机械类问题零轮修复与判断类重审一轮复验。④ **验收与留痕**:playground 合成靶场同 diff 双跑对照(`proposals/BENCHMARK-20261119-02-playground.md`),在上下文注入精度(0.4KB vs 15KB+)、依据可得性(精确锚定 AC-HOME-001 vs 泛化文字建议)、闭环硬度(v4 审计产物 + 收口硬门 vs 易失记录)三项全胜,满足「拿过来就能用,效果只能比 执行层 好、不能比 执行层 差」验收线。 |
672
672
  | D204 | **自建完整执行层调度总入口:Plan/Implement/Verify/Finish 四阶段闭环(`atlas workflow`;RFC-20261119-02 完备版)**(2026-11-19;`scripts/atlas_workflow.py`、`_support/workflow_plan.py`、`_support/workflow_dispatch.py`、`_support/workflow_finish.py`、`bin/atlas.js`、`tests/test_atlas_workflow.py`;动因 = 彻底接管执行层生命周期,大任务自动拆解 Task DAG、最小上下文精准派发、确定性工具链与独立审查并轨、收口门硬阻断,全流程摆脱 执行层 依赖) | ① **架构与命令面**:Node CLI 与 Python 编排器双向注册 `atlas workflow`,支持 `plan`(需求自动拆解并生成合规 Task Card 与四列表格)、`dispatch`(提取 AC 映射与域透镜最小上下文生成 `dispatch.md`,状态流转至 `in_progress`)、`verify`(透传触发 `atlas review --staged` 暂存区审查)、`finish`(核验 `review.json` 且无未决 Critical 方可收口,状态更新至 `completed`)、`status`(DAG 台账监控)、`run`(一键闭环串联)。② **纪律遵守**:严格禁止子任务树(No Subtask Tree),以有序 Task DAG 扁平表达;状态机锁定三态(todo / in_progress / completed);最小上下文比 执行层 原生 spec 注入减少 85%+ token 噪音。③ **测试与靶场验证**:新增 `tests/test_atlas_workflow.py`(6 测试用例全绿);在 `verify_playground` 靶场实测跑通全流程(`proposals/BENCHMARK-20261119-03-full-workflow.md`),证明自主闭环能力。 |
673
673
  | D205 | **移除 Trellis:运行时 / 装配 / 契约 / 文档全部改由 `atlas workflow` 承载**(2026-11-19;supersedes D18、D37、D38、D66、D73、D159;`install.py`、`bin/`、`patches/`、`_support/solution_task.py`、`scripts/*`、`validators/*`、`shared/*`、`rings/*`、`apply/reference.md`、`README.md`、`docs/**`) | ① **落点**:任务账本 `.atlas/tasks`;结构事实 `.atlas/spec/structure`;testid 薄桩 `.atlas/spec/conventions`;工作流参数 `.atlas/config.yaml`;成员任务卡由 `workflow_plan.write_task_card` 原生写入(不再调用宿主 `task.py`)。② **装配**:删 `--no-trellis` / `--no-patch` 与四组 workflow 补丁;仅保留 `patches/project-wiring/`(AGENTS.md / 测试配置 / `.gitignore` / pi 扩展);`--profile audit|adopt = --no-wiring`。③ **触发时机**:`after_archive` hook 取消,结构事实刷新改为显式 `refresh_structure.py --chain`(收口后 / CI)。④ **历史边界**:`proposals/`、`research/`、`handoff/`、`CHANGELOG.md`、`docs/guide/changelog.md`、审计快照与 `docs/guide/{comparison,legacy-adoption}.md` 保留原字样。 |
674
+ | D206 | **atlas-ablate skill 重定位「自进化减法引擎」:目的从门禁价值证明改为自进化减负,交付物从「只出证据」改为「减法清单 + 四护栏」(2026-11-21;`skills/atlas-ablate/SKILL.md` 重写、`research/2026-11-21-ablation-outcome-campaign-runbook.md` 新建;双评审 tech-proposal-reviewer × 2 互不可见,首轮各 3 Blocker 判「修后再审」,修订版终审双通过;动因 = 维护者定性:Atlas 全部附加物都是成本项,模型能力提升后旧机制会变成限制(Dify/Coze 式工作流被强模型淘汰同形态),目标函数 = 产出质量 × 速度 × token 三元总优化,消融 = 新陈代谢器官,周期锚 = 模型代际)** | ① **漏斗制三层**(每代 ≈12–30 次任务跑,零新代码):层 1 成本账本(`ablate_all.py` 一键,短名单 = 耗时份额>5% ∨ 0 触发)→ 层 2 守卫语料豁免(独占接住移出短名单;只跑层 1 必声明「本批无收益面证据」)→ 层 3 产出面 A/B(**捆绑摘除**:全量 vs 全量−候选组,3 任务 × 2 臂 = 6 跑,组伤质量才二分 log2(k))。② **减法判据四护栏**:保险型豁免清单先行(30 案台账 + gates.md 灾难面永不进清单,除非守卫冗余实证——「无事件的预防不可见」是构造性限制 §3.5);双证据立案(delta≤0 ∧ 成本份额超阈 ∨ 过时拦截实证 ∨ 冗余实证);最小持续 2 代(首代只观察);复归触发器(closeout 步骤 11 归因命中已退役门 ⇒ 复活评估 + D 行)。③ **判分**:后置未参战门册机器主判(摘 X 用含 X 全门册 shadow 判,非循环)+ L0 裸跑组自带测试(禁 Atlas 门当尺)+ 人盲评二元最小化(6 件/代,rubric 版本化)+ 质量噪声带(同配置重复,差异小于噪声只写 indistinguishable)+ 质量/产物集合完整性分列。④ **token**:宿主会话手工转录字段可空,禁 Atlas 侧遥测(宿主无关),放弃逐机制归因;跨代记原始 token + 币价备注(评审 Nit:货币归一引汇率混淆,已弃)。⑤ **跨代账本**:三指纹(Atlas 装配摘要/模型标识/任务快照摘要)+ rubric 版本;措辞只许「当前系统 vs 当前系统减 X」方向性案例研究,禁「模型变强所以 X 无用」(混淆显式化非消除)。⑥ **误拦第五类「过时拦截」**:假设标签(0 实例)+ `check-events.jsonl` 处置面粗筛,不建分类器。⑦ **新增「降频」档位**:低置信候选改 gates.md 触发物(生产型机制退役证据走消费面 + 真跑日摩擦账,不进 L1 单摘)。⑧ **旧纪律作废留痕**:旧「不给删留结论」纪律(原 SKILL §0 与 differential §4.4 措辞)作废——其保护目的由四护栏承接;宿主钉死采纳仓(源仓 23 机制全 SKIP 实测教训)。⑨ **被否**:定时巡检(代际是事件非时刻表);Atlas 侧 token 遥测;逐机制 A/B(经济性,23×2×3–5 ≈ 140–230 跑/代不可执行);分组消融为默认(组内归因模糊,捆绑+二分替代)。 |
675
+ | D207 | **L0 整线束对照片面豁免:装配级双独立快照人工流程,不经消融工具(RFC-20261101-04「永不:整线束 on/off」显式收窄为工具面)**(2026-11-21;`proposals/RFC-20261101-04` §2.1 条款修订、`research/2026-11-21-ablation-outcome-campaign-runbook.md` §7;动因 = 自进化定位需要宏观锚「整个 Atlas 还有净贡献吗」,当年六混淆否 L0 是「证价值」目的下的选择,自进化目的下重新过堂:学习效应/小样本由跨代账本 + 任务卫生缓解,成本翻倍由每代 ≤6 跑预算收口)** | ① **范围收窄**:RFC-20261101-04「不做(永不):整线束 on/off」收窄为**工具面**——ablation 工具永不承做整线束切换、不做自动还原/冲突合并的原清单其余项不变。② **豁免形态**:L0 = 双独立准备快照(装配态 vs 未装配态)+ 每臂全新会话 + 臂序随机 + 同一时间盒 + 盲评 + 案例研究措辞 + 裸跑组自带测试保底(differential §3.1 预登记协议全盘继承),每代 ≤6 跑,用后即弃、工作树零接触。③ **留痕**:本行即 D 行留痕(满足 global-rules 决策作废只改该行纪律);旧 SKILL「要重开另立窗口、另行预登记」要求由 runbook §7 承接。 |
676
+ | D208 | **任务卡验收行收域级 AC 词形 + PRD 存在性校验(`validate_task_card`;2026-11-21 自进化 campaign T5 实测驱动;维护者拍板「门收域级编号」)** | ① **病灶**:`atlas workflow plan`(D204)生成的任务卡验收行为域级 AC(`AC-HOME-xxx`),而本器 `AC_TOKEN_RE` 只认 `AC-(SOLUTION\|CONTRACT)-\d{3}` ⇒ plan 产物在采纳仓 `atlas check` 必然 `card_acceptance_invalid`——两组件词表从未对过话,1894 测试全绿未覆盖该集成面(无测试让 plan 产物过 task card 门)。② **定案**:新增域级词形 `AC-(?!SOLUTION-\|CONTRACT-)[A-Z][A-Z0-9_]*-\d{3}`;域级 token 不走 (req, member) 投影,改走 **PRD 存在性校验**(`_prd_ac_tokens` 扫 `prd/*.md` 与 `*/prd/*.md` 全文词匹配,杜撰编号 ⇒ 新码 `card_acceptance_absent`——比原形态校验更严);方案层 token 投影语义逐字节不变。③ **修法替代被否**:plan 改发方案层 token(小项目多养一层方案表格,违自进化方向);豁免直通通道(豁免语义与正常验收混用)。④ **钉**:`test_domain_ac_accepted_when_present_in_prd` / `test_domain_ac_absent_in_prd_is_fabrication` / `test_domain_ac_malformed_shape_rejected`(27 条)。 |
674
677
 
675
678
  ---
676
679
 
package/NOTICE ADDED
@@ -0,0 +1,17 @@
1
+ Atlas — Project Harness 工作流治理引擎
2
+ Copyright 2026 sunwenzhe-git
3
+
4
+ This product includes software developed as part of the Atlas project
5
+ (https://github.com/sunwenzhe-git/atlas).
6
+
7
+ 本产品包含 Atlas 项目原创的工作流治理方法论、契约、校验器、模板与工程线束。
8
+ 分发本软件或其衍生作品时,请随附本 NOTICE 与根目录 LICENSE(Apache-2.0),
9
+ 并在衍生项目的 README 或关于页面注明来源:
10
+ https://github.com/sunwenzhe-git/atlas
11
+
12
+ 文档与规范正文(docs/、rings/、skills/ 中面向人的说明性文字)另按
13
+ Creative Commons Attribution 4.0 International(CC BY 4.0)授权,
14
+ 署名与链接要求见 docs/LICENSE。
15
+
16
+ "Atlas" 与 "Project Harness" 为本项目名称;依 Apache License 2.0 第 6 条,
17
+ 本许可不授予任何商标使用权。
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Atlas — 践行 Project Harness 的全流程 AI 编程工作流
2
2
 
3
3
  <p align="left">
4
- <img src="https://img.shields.io/badge/version-0.4.0--beta.3-blue.svg" alt="Version" />
4
+ <img src="https://img.shields.io/badge/version-0.4.0--beta.5-blue.svg" alt="Version" />
5
5
  <img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License" />
6
6
  <img src="https://img.shields.io/badge/tests-passing-success.svg" alt="Tests" />
7
7
  <a href="https://sunwenzhe-git.github.io/atlas/"><img src="https://img.shields.io/badge/docs-VitePress-green.svg" alt="Docs" /></a>
@@ -42,6 +42,7 @@
42
42
  - [十、贡献与流水线协同(RFC 机制)](#十贡献与流水线协同rfc-机制)
43
43
  - [十一、社区交流(钉钉群)](#十一社区交流钉钉群)
44
44
  - [十二、开源协议(License)](#十二开源协议license)
45
+ - [十三、出处与署名(Attribution)](#十三出处与署名attribution)
45
46
 
46
47
  ---
47
48
 
@@ -489,6 +490,7 @@ Atlas 坚持**变异证明(Mutation Proving / M 系列钉子测试)**原则
489
490
  * **步骤 3 风险定档**:低/中/高三档 + **Always-Human 路径**(`auth / permission / routing / CI / package deps / shared contracts` 一律禁止 Agent 代勾);
490
491
  * **步骤 4 缺陷修复验证 7 检查点**:含「先有一条会失败的测试再修」(Red First)与「关闭的证据在哪」;
491
492
  * **步骤 11 事故追问**:每个逃逸缺陷必须回答「哪一层本该接住它」,并落成一条 E2E 回归用例或一条 M 系列变异钉——事故就此变成评测集。
493
+ * **步骤 12 偏差三岔口**:`结构漂移` 点名的新增键、`testid` 多写、AC 对齐偏差,收口时逐条归因为 `spec_gap` / `spec_amend` / `out_of_scope`(`apply/reference.md` §5.3);只有 `spec_amend` 回写上游,其余走执行层任务,防止「实现怎么写、规格就怎么改」。
492
494
 
493
495
  ---
494
496
 
@@ -572,6 +574,22 @@ Atlas 随包完整分发了一套自洽的高阶开发与评审套件:
572
574
 
573
575
  本项目基于 **[Apache License, Version 2.0](LICENSE)** 协议开源。
574
576
 
577
+ - 代码、脚本、模板、校验器:Apache-2.0。分发时请保留 [LICENSE](LICENSE) 与 [NOTICE](NOTICE),修改过的文件请标注。
578
+ - 文档与规范正文(`docs/`、`rings/`、`skills/` 中面向人的说明性文字):[CC BY 4.0](docs/LICENSE)。复制、改编、商用都需署名并附原文链接。
579
+ - 引用本方法论:见 [CITATION.cff](CITATION.cff)(GitHub 仓库页会出现 “Cite this repository”)。
580
+
581
+ ---
582
+
583
+ ## 十三、出处与署名(Attribution)
584
+
585
+ 如果你在项目、文章或产品中采用了 Atlas 的 Project Harness 方法论(契约先行、机器门禁、变异证明、独立审查等),请在 README 或关于页面注明来源:
586
+
587
+ > 本项目的工程治理思路来自 **Atlas — Project Harness 工作流治理引擎**:<https://github.com/sunwenzhe-git/atlas>
588
+
589
+ 这是一条署名请求,不是许可条款——方法论本身不受著作权保护,无法强制;但“来源可追溯”是这个项目愿意被复用的前提。
590
+
591
+ `Atlas` 与 `Project Harness` 为项目名称,依 Apache-2.0 第 6 条,本许可不授予商标使用权。
592
+
575
593
  ---
576
594
 
577
595
  <p align="center">
@@ -13,11 +13,15 @@ from __future__ import annotations
13
13
 
14
14
  import json
15
15
  import re
16
+ import shutil
16
17
  import subprocess
18
+ from collections import Counter
19
+ from datetime import date
17
20
  from pathlib import Path
18
21
 
19
22
  from _support import review_scope_core as scope_core
20
- from _support.workflow_plan import load_tasks, atomic_write_json, UNIT_RE
23
+ from _support.layout import LayoutError, load_layout
24
+ from _support.workflow_plan import ARCHIVE_DIR, load_tasks, atomic_write_json, UNIT_RE
21
25
 
22
26
 
23
27
  class FinishError(ValueError):
@@ -25,6 +29,7 @@ class FinishError(ValueError):
25
29
 
26
30
 
27
31
  REVIEW_DIR_PREFIX_RE = r"^\d{4}-\d{2}-\d{2}-impl-review-"
32
+ ARCHIVE_MONTH_RE = re.compile(r"^\d{4}-(0[1-9]|1[0-2])$") # `archive/<YYYY-MM>/<ID>/`
28
33
 
29
34
 
30
35
  def _staged_files(root: Path) -> list[str] | None:
@@ -41,7 +46,13 @@ def _staged_files(root: Path) -> list[str] | None:
41
46
 
42
47
 
43
48
  def _scope_matches(root: Path, data: dict) -> tuple[bool, str]:
44
- """检查报告落盘后暂存区内容未被替换(v4 内容封口)。"""
49
+ """检查报告落盘后暂存区内容未被替换(v4 内容封口)。
50
+
51
+ 三分类诊断(2026-11-21,自进化 campaign T3 三撞实测):extra(暂存面多出实审集
52
+ 之外的路径——典型 = 审查产物误入暂存)/ missing(实审文件未暂存)/ changed
53
+ (实审文件内容已变)。extra 全落审查产物目录 ⇒ 指引 unstage(该场景重跑
54
+ verify 无效);changed ⇒ 指引重新审查。整体摘要一致即放行(快速路径)。
55
+ """
45
56
  scope = data.get("review_scope")
46
57
  if not isinstance(scope, dict) or not scope.get("sha256"):
47
58
  return True, "" # 旧报告兼容:无内容锚,无法比对
@@ -52,9 +63,46 @@ def _scope_matches(root: Path, data: dict) -> tuple[bool, str]:
52
63
  manifest = scope_core.build_manifest(root, staged)
53
64
  except Exception as exc: # noqa: BLE001 —— 路径/状态异常一律视为不可封口
54
65
  return False, f"暂存区内容无法重算摘要:{exc}"
55
- if manifest.get("scope_sha256") != scope.get("sha256"):
56
- return False, "审查后暂存区内容已变化(review_scope 摘要不一致);请重新运行 verify"
57
- return True, ""
66
+ if manifest.get("scope_sha256") == scope.get("sha256"):
67
+ return True, ""
68
+ files = scope.get("files") or []
69
+ if not files:
70
+ return False, ("审查后暂存区内容已变化(review_scope 摘要不一致;旧报告无逐文件锚,"
71
+ "无法自动分类):实审文件内容已变 ⇒ 须重新审查(fresh review)后重跑 "
72
+ "verify;实审文件未变 ⇒ 通常是审查产物误入暂存面,unstage 后重跑 finish")
73
+ recorded = {f.get("path"): f.get("sha256", "") for f in files
74
+ if isinstance(f, dict) and f.get("path")}
75
+ review_prefixes = ("product/reviews/", "product/e2e/reviews/")
76
+ extra = sorted(set(staged) - set(recorded))
77
+ missing = sorted(set(recorded) - set(staged))
78
+ changed = []
79
+ for p in sorted(set(recorded) & set(staged)):
80
+ try:
81
+ m = scope_core.build_manifest(root, [p])
82
+ except Exception: # noqa: BLE001
83
+ changed.append(p)
84
+ continue
85
+ entry = (m.get("files") or [{}])[0]
86
+ if entry.get("sha256") != recorded.get(p):
87
+ changed.append(p)
88
+ extra_review = [q for q in extra if q.startswith(review_prefixes)]
89
+ extra_other = [q for q in extra if not q.startswith(review_prefixes)]
90
+ parts = []
91
+ if extra_review:
92
+ parts.append("审查产物不得进暂存面:`git restore --staged "
93
+ + " ".join(extra_review)
94
+ + "` 后重跑 finish(实审文件未变时重跑 verify 无效)")
95
+ if extra_other:
96
+ parts.append("暂存面多出实审集之外的非审查产物路径:" + " ".join(extra_other)
97
+ + "(纳入实审需重新审查)")
98
+ if missing:
99
+ parts.append("实审文件未暂存:" + " ".join(missing) + ";暂存后重跑 verify")
100
+ if changed:
101
+ parts.append("实审文件内容已变(" + " ".join(changed)
102
+ + "):须重新审查(fresh review)后重跑 verify")
103
+ if not parts:
104
+ parts.append("暂存面与实审集内容均一致但整体摘要不一致(罕见);请重跑 verify")
105
+ return False, ";".join(parts)
58
106
 
59
107
 
60
108
  def check_task_review_passed(root: Path, unit: str) -> tuple[bool, str]:
@@ -99,6 +147,132 @@ def check_task_review_passed(root: Path, unit: str) -> tuple[bool, str]:
99
147
  return True, str(latest_dir)
100
148
 
101
149
 
150
+ def _acceptance_evidence(lay) -> dict:
151
+ """用户验收走查留痕:`<e2e>/reviews/*-acceptance-*/README.md`(缺 ⇒ SKIP,人工责任)。"""
152
+ reviews = lay.e2e_reviews_dir
153
+ if not reviews.is_dir():
154
+ return {"status": "SKIP", "reason": "无 E2E 验收走查留痕目录(人工责任)"}
155
+ docs = sorted(p for p in reviews.glob("*-acceptance-*")
156
+ if p.is_dir() and (p / "README.md").is_file())
157
+ if not docs:
158
+ return {"status": "SKIP", "reason": "未见 *-acceptance-*/README.md(用户验收走查为人工责任)"}
159
+ latest = docs[-1]
160
+ return {"status": "PASS", "path": str(latest.relative_to(lay.root)),
161
+ "reason": "找到验收走查留痕"}
162
+
163
+
164
+ E2E_MAIN_COLUMNS = ["用例ID", "页面", "中文标题", "类型", "关联AC", "需求", "状态", "状态原因", "分片"]
165
+
166
+
167
+ def _markdown_tables(text: str) -> list[tuple[list[str], list[list[str]]]]:
168
+ """轻量读取 Markdown 表(列头 + 行),与 `validators/validate_e2e_index.tables` 同口径。
169
+
170
+ 不直接 import 校验器:`_support → validators` 反向依赖有棘轮上限
171
+ (`tests/test_shared_kernel.py`),新增依赖须先拆旧的。
172
+ """
173
+ out: list[tuple[list[str], list[list[str]]]] = []
174
+ block: list[list[str]] = []
175
+ for line in text.splitlines():
176
+ if line.strip().startswith("|"):
177
+ block.append([c.strip() for c in line.strip().strip("|").split("|")])
178
+ elif block:
179
+ out.append((block[0], [r for r in block[1:]
180
+ if not all(set(c) <= set("-: ") for c in r)]))
181
+ block = []
182
+ if block:
183
+ out.append((block[0], [r for r in block[1:]
184
+ if not all(set(c) <= set("-: ") for c in r)]))
185
+ return out
186
+
187
+
188
+ def check_e2e_precondition(root: Path, task: dict) -> dict:
189
+ """收口前把 E2E 结论纳入校验输入(issue #69)。
190
+
191
+ - 与本任务 AC 关联的用例存在 `red` ⇒ `FAIL`(阻断收口);
192
+ - 索引缺失 / 任务卡无 AC / 本任务 AC 未出现在索引 / 含 `skipped` ⇒ `SKIP`(显式记录原因,
193
+ 不静默当作通过);
194
+ - 其余(`green` / `blocked` 带原因)⇒ `PASS`。
195
+ 验收走查留痕单独记录,不改变 E2E 结论(缺留痕 = `SKIP`,人工责任)。
196
+ """
197
+ try:
198
+ lay = load_layout(root)
199
+ except LayoutError as exc:
200
+ return {"status": "SKIP", "reason": f"布局不可解析:{exc}"}
201
+ index = lay.e2e_index
202
+ if not index.is_file():
203
+ return {"status": "SKIP", "reason": f"未找到 E2E 索引({index.relative_to(root)}):按人工责任处理"}
204
+ try:
205
+ tabs = _markdown_tables(index.read_text(encoding="utf-8"))
206
+ except OSError as exc:
207
+ return {"status": "SKIP", "reason": f"E2E 索引不可读:{exc}"}
208
+ if not tabs:
209
+ return {"status": "SKIP", "reason": "E2E 索引无可解析表格"}
210
+ matched = next(((h, r) for h, r in tabs if h == E2E_MAIN_COLUMNS), None)
211
+ if matched is None:
212
+ return {"status": "SKIP",
213
+ "reason": f"E2E 主表列头不可识别(期望 {E2E_MAIN_COLUMNS})"}
214
+ header, rows = matched
215
+ grid = [dict(zip(header, r + [""] * (len(header) - len(r)))) for r in rows]
216
+ acs = [str(a) for a in (task.get("acs") or []) if str(a).strip()]
217
+ if not acs:
218
+ return {"status": "SKIP", "reason": "任务卡未声明 AC,无法定位 E2E 适用面", "acs": []}
219
+ scoped = [g for g in grid if any(a in (g.get("关联AC") or "") for a in acs)]
220
+ if not scoped:
221
+ return {"status": "SKIP", "reason": f"本任务 AC 未出现在 E2E 索引:{acs}", "acs": acs}
222
+ counts = dict(Counter((g.get("状态") or "") for g in scoped))
223
+ cases = [g.get("用例ID") or "?" for g in scoped]
224
+ red = [cid for cid, g in zip(cases, scoped) if (g.get("状态") or "") == "red"]
225
+ skipped = [cid for cid, g in zip(cases, scoped) if (g.get("状态") or "") == "skipped"]
226
+ out = {"acs": acs, "cases": cases, "counts": counts,
227
+ "acceptance": _acceptance_evidence(lay)}
228
+ if red:
229
+ out.update(status="FAIL", reason=f"E2E 关联用例存在 red:{red}")
230
+ elif skipped:
231
+ out.update(status="SKIP", reason=f"E2E 关联用例含 skipped(不得当通过):{skipped}")
232
+ else:
233
+ out.update(status="PASS", reason=f"E2E 关联用例无 red({counts})")
234
+ return out
235
+
236
+
237
+ def archive_month(t_dir: Path, tasks_root: Path) -> str | None:
238
+ """任务目录若已在 `archive/<YYYY-MM>/<ID>/` 下,返回月份名;否则 None。
239
+
240
+ 月份层是判据侧的既有契约:`validators/validate_task_card.py` 按
241
+ `archive/*/*/prd.md` 找卡,封条按 `archive/*/<ID>/<tail>` 定位。写入侧
242
+ 只用月度目录,避免归档卡静默掉出判据覆盖(issue #70)。
243
+ """
244
+ archive_root = (tasks_root / ARCHIVE_DIR).resolve()
245
+ try:
246
+ rel = t_dir.resolve().relative_to(archive_root)
247
+ except ValueError:
248
+ return None
249
+ if len(rel.parts) == 2 and ARCHIVE_MONTH_RE.match(rel.parts[0]):
250
+ return rel.parts[0]
251
+ return None
252
+
253
+
254
+ def archive_task(root: Path, tasks_root: Path, t_dir: Path, t_id: str) -> dict:
255
+ """把已收口任务移到 `.atlas/tasks/archive/<YYYY-MM>/<id>/`(幂等;issue #70)。
256
+
257
+ 月份取归档当天。历史扁平存档(`archive/<id>/`)或缺/错月份层的目录会在
258
+ 下次归档时迁入当月,从而重新进入判据与封条的扫描面。
259
+ """
260
+ if not UNIT_RE.match(t_id):
261
+ raise FinishError(f"非法任务标识:{t_id!r}")
262
+ root = root.resolve()
263
+ if archive_month(t_dir, tasks_root) is not None:
264
+ return {"status": "already", "path": str(t_dir.resolve().relative_to(root))}
265
+ dest = tasks_root / ARCHIVE_DIR / date.today().strftime("%Y-%m") / t_id
266
+ if dest.exists():
267
+ raise FinishError(f"归档目标已存在:{dest}(源目录仍在 {t_dir};请人工核对后处理)")
268
+ try:
269
+ dest.parent.mkdir(parents=True, exist_ok=True)
270
+ shutil.move(str(t_dir), str(dest))
271
+ except OSError as exc:
272
+ raise FinishError(f"归档失败:{t_dir} → {dest}({exc})") from exc
273
+ return {"status": "moved", "path": str(dest.relative_to(root))}
274
+
275
+
102
276
  def finish_task(root: Path, task: dict, *, force: bool = False) -> dict:
103
277
  """完成单个任务的收口流转。"""
104
278
  root = root.resolve()
@@ -112,12 +286,21 @@ def finish_task(root: Path, task: dict, *, force: bool = False) -> dict:
112
286
 
113
287
  if not t_dir.is_dir():
114
288
  raise FinishError(f"任务目录不存在:{t_dir}")
289
+ if archive_month(t_dir, tasks_root) is None:
290
+ archive_dest = tasks_root / ARCHIVE_DIR / date.today().strftime("%Y-%m") / t_id
291
+ if archive_dest.exists():
292
+ raise FinishError(
293
+ f"归档目标已存在:{archive_dest}(源目录仍在 {t_dir};请人工核对后处理)")
115
294
  if not force:
116
295
  passed, reason = check_task_review_passed(root, t_id)
117
296
  if not passed:
118
297
  raise FinishError(f"任务 {t_id} 无法收口:{reason}")
119
298
 
120
- # 更新 task.json 状态为 completed
299
+ e2e = check_e2e_precondition(root, task)
300
+ if e2e["status"] == "FAIL":
301
+ raise FinishError(f"任务 {t_id} 无法收口:{e2e['reason']}")
302
+
303
+ # 更新 task.json 状态为 completed(E2E 前置结论一并落盘,issue #69)
121
304
  task_json_file = t_dir / "task.json"
122
305
  if task_json_file.is_file():
123
306
  try:
@@ -128,10 +311,14 @@ def finish_task(root: Path, task: dict, *, force: bool = False) -> dict:
128
311
  meta = task
129
312
 
130
313
  meta["status"] = "completed"
314
+ meta["e2e_precondition"] = e2e
131
315
  atomic_write_json(task_json_file, meta)
132
316
 
133
- # 检查整体工作流是否全部收工
134
- all_tasks = load_tasks(t_dir.parent)
317
+ # 归档(issue #70):completed 任务移出活跃区;幂等,失败显式报错
318
+ archived = archive_task(root, tasks_root, t_dir, t_id)
319
+
320
+ # 检查整体工作流是否全部收工(含归档任务)
321
+ all_tasks = load_tasks(tasks_root, include_archived=True)
135
322
  total = len(all_tasks)
136
323
  completed_count = sum(1 for t in all_tasks if t.get("status") == "completed")
137
324
 
@@ -141,4 +328,6 @@ def finish_task(root: Path, task: dict, *, force: bool = False) -> dict:
141
328
  "total_tasks": total,
142
329
  "completed_tasks": completed_count,
143
330
  "all_done": (total > 0 and completed_count == total),
331
+ "e2e_precondition": e2e,
332
+ "archived": archived,
144
333
  }
@@ -19,6 +19,7 @@ from pathlib import Path
19
19
 
20
20
  AC_RE = re.compile(r"AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3}")
21
21
  UNIT_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$")
22
+ ARCHIVE_DIR = "archive" # `.atlas/tasks/archive/<YYYY-MM>/<ID>/`:已收口任务归档区(issue #70)
22
23
 
23
24
 
24
25
  class PlanError(ValueError):
@@ -172,12 +173,74 @@ def atomic_write_json(path: Path, data: dict) -> None:
172
173
  os.replace(tmp, path)
173
174
 
174
175
 
175
- def write_task_card(task_dir: Path, task: dict) -> Path:
176
+ REQUIREMENT_ITEMS_FILE = "requirement-items.md"
177
+ COVERAGE_MATRIX_FILE = "coverage-matrix.md"
178
+
179
+
180
+ def write_requirement_items(task_dir: Path, task: dict) -> Path:
181
+ """需求条目表骨架(#72 开工前置产物):先枚举再动手。
182
+
183
+ 无外部需求原件的卡显式声明豁免(`条目总数:0(本卡无外部需求原件)`);
184
+ 已存在则跳过——重跑 plan 不覆盖已填内容。
185
+ """
186
+ path = task_dir / REQUIREMENT_ITEMS_FILE
187
+ if path.exists():
188
+ return path
189
+ path.write_text("\n".join([
190
+ f"# 需求条目表 — {task['title']}",
191
+ "",
192
+ "> 开工前置产物(#72):本卡承接的需求条目逐条枚举,**开工前完成**;"
193
+ "原文逐字不改写,限定语(如「实际以接口为准」)必须保留。",
194
+ "> 需求原件(PDF / 图片)先转成带页码锚的 Markdown 落本卡 `work/需求PDF-全文.md`"
195
+ "(页码锚 `<!-- page N -->`,空白页保留裸锚,正文逐字可回查);「页码」列对齐该锚。",
196
+ "> 表格类需求按行拼接为一句,不改措辞;文末声明条目总数与页码分布,"
197
+ "表行数必须等于声明总数。",
198
+ "> 本卡确无外部需求原件时写:`条目总数:0(本卡无外部需求原件)`。",
199
+ "",
200
+ "| ID | 页码 | 章节 | 原文 |",
201
+ "|---|---|---|---|",
202
+ "",
203
+ "条目总数:待填",
204
+ "页码分布:待填",
205
+ "",
206
+ ]), encoding="utf-8")
207
+ return path
208
+
209
+
210
+ def write_coverage_matrix(task_dir: Path, task: dict) -> Path:
211
+ """需求条目覆盖矩阵骨架(#73):行 = 条目 ID,列 = 四个资产面。
212
+
213
+ 已存在则跳过;矩阵格值词表与 verify 判据见 `_support/workflow_verify.py`。
214
+ """
215
+ path = task_dir / COVERAGE_MATRIX_FILE
216
+ if path.exists():
217
+ return path
218
+ path.write_text("\n".join([
219
+ f"# 需求条目覆盖矩阵 — {task['title']}",
220
+ "",
221
+ "> 每格只能是「覆盖(位置)」或「不涉及(理由)」,两者都给不出写 `UNRESOLVED`;"
222
+ "留空格或存在 UNRESOLVED ⇒ `atlas workflow verify` WARN(纪律面起步,升格 FAIL 另案)。",
223
+ "> 行 = `requirement-items.md` 的条目 ID;实现列以**当前代码**取证,"
224
+ "文档说覆盖而代码没有按未覆盖处理。",
225
+ "",
226
+ "| ID | PRD | 设计文档 | 实现 | E2E |",
227
+ "|---|---|---|---|---|",
228
+ "",
229
+ ]), encoding="utf-8")
230
+ return path
231
+
232
+
233
+ def write_task_card(task_dir: Path, task: dict, *,
234
+ with_requirement_items: bool = False) -> Path:
176
235
  """写入单个任务卡目录(包含 prd.md 与 task.json)。
177
236
 
178
237
  重跑 plan 不得把已推进的状态打回 `todo`(状态机单调:todo < in_progress < completed);
179
238
  已有 task.json 时沿用其 status 与 created_at。
239
+ `with_requirement_items=True`(plan 显式给了 `--requirement`)时同步写需求条目表与
240
+ 条目覆盖矩阵骨架(#71/#72/#73:需求原文入库 → 条目枚举 → 覆盖对账)。
180
241
  """
242
+ if task.get("id") == ARCHIVE_DIR:
243
+ raise PlanError(f"任务标识 {ARCHIVE_DIR!r} 与归档目录保留名冲突")
181
244
  task_dir.mkdir(parents=True, exist_ok=True)
182
245
  prd_path = task_dir / "prd.md"
183
246
  task_json_path = task_dir / "task.json"
@@ -213,15 +276,27 @@ def write_task_card(task_dir: Path, task: dict) -> Path:
213
276
  if "paths" not in meta and isinstance(prev.get("paths"), list):
214
277
  meta["paths"] = prev["paths"]
215
278
  atomic_write_json(task_json_path, meta)
279
+ if with_requirement_items:
280
+ write_requirement_items(task_dir, task)
281
+ write_coverage_matrix(task_dir, task)
216
282
  return task_dir
217
283
 
218
284
 
219
- def load_tasks(tasks_root: Path) -> list[dict]:
220
- """读取所有任务元数据并进行依赖拓扑排序。"""
285
+ def load_tasks(tasks_root: Path, *, include_archived: bool = False) -> list[dict]:
286
+ """读取任务元数据并做依赖拓扑排序。
287
+
288
+ `include_archived=False`(缺省)只扫**活跃**任务;归档在
289
+ `<tasks_root>/archive/`(issue #70,由 finish / `atlas workflow archive` 迁入),
290
+ 带 `_archived: True` 标记,只能经 `include_archived=True` 或 `status --all` 看到。
291
+ """
221
292
  if not tasks_root.is_dir():
222
293
  return []
223
294
  tasks: dict[str, dict] = {}
224
295
  for p in sorted(tasks_root.rglob("task.json")):
296
+ rel = p.relative_to(tasks_root)
297
+ archived = bool(rel.parts) and rel.parts[0] == ARCHIVE_DIR
298
+ if archived and not include_archived:
299
+ continue
225
300
  try:
226
301
  data = json.loads(p.read_text(encoding="utf-8"))
227
302
  except (OSError, json.JSONDecodeError) as exc:
@@ -229,6 +304,8 @@ def load_tasks(tasks_root: Path) -> list[dict]:
229
304
  if not (isinstance(data, dict) and data.get("id")):
230
305
  raise PlanError(f"任务卡缺少 id:{p}")
231
306
  data["_dir"] = str(p.parent)
307
+ if archived:
308
+ data["_archived"] = True
232
309
  tasks[data["id"]] = data
233
310
 
234
311
  # 简单拓扑排序