atlas-project-harness 0.3.0-beta.1 → 0.3.0-beta.3

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 (49) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/DESIGN.md +2 -1
  3. package/README.md +1 -1
  4. package/_support/__pycache__/ac_coverage.cpython-312.pyc +0 -0
  5. package/_support/__pycache__/ac_crosswalk.cpython-312.pyc +0 -0
  6. package/_support/__pycache__/semver.cpython-312.pyc +0 -0
  7. package/_support/__pycache__/solution.cpython-312.pyc +0 -0
  8. package/_support/__pycache__/solution_e2e.cpython-312.pyc +0 -0
  9. package/_support/__pycache__/solution_task.cpython-312.pyc +0 -0
  10. package/_support/ac_coverage.py +2 -1
  11. package/_support/ac_crosswalk.py +18 -7
  12. package/_support/semver.py +63 -0
  13. package/_support/solution.py +68 -42
  14. package/_support/solution_e2e.py +7 -3
  15. package/_support/solution_task.py +2 -2
  16. package/adapters/ac/__pycache__/js.cpython-312.pyc +0 -0
  17. package/adapters/ac/__pycache__/junit.cpython-312.pyc +0 -0
  18. package/adapters/ac/__pycache__/pytest.cpython-312.pyc +0 -0
  19. package/adapters/ac/js.py +2 -2
  20. package/adapters/ac/junit.py +1 -1
  21. package/adapters/ac/pytest.py +1 -1
  22. package/package.json +1 -1
  23. package/rings/e2e/reference.md +11 -7
  24. package/scripts/__pycache__/atlas_solution.cpython-312.pyc +0 -0
  25. package/scripts/__pycache__/changelog_guard.cpython-312.pyc +0 -0
  26. package/scripts/__pycache__/e2e_console.cpython-312.pyc +0 -0
  27. package/scripts/__pycache__/gen_e2e_scripts.cpython-312.pyc +0 -0
  28. package/scripts/__pycache__/gen_fixture_schemas.cpython-312.pyc +0 -0
  29. package/scripts/__pycache__/ledger_snapshot.cpython-312.pyc +0 -0
  30. package/scripts/__pycache__/preflight.cpython-312.pyc +0 -0
  31. package/scripts/atlas_apply_seal.py +26 -4
  32. package/scripts/atlas_solution.py +24 -35
  33. package/scripts/changelog_guard.py +217 -0
  34. package/scripts/e2e_console.py +22 -3
  35. package/scripts/gen_e2e_scripts.py +19 -4
  36. package/scripts/gen_fixture_schemas.py +119 -0
  37. package/scripts/ledger_snapshot.py +217 -0
  38. package/scripts/preflight.py +195 -0
  39. package/shared/closeout.md +2 -2
  40. package/shared/gates.md +27 -27
  41. package/shared/global-rules.md +1 -0
  42. package/validators/__pycache__/validate_ac_alignment.cpython-312.pyc +0 -0
  43. package/validators/__pycache__/validate_e2e_index.cpython-312.pyc +0 -0
  44. package/validators/__pycache__/validate_e2e_mocks.cpython-312.pyc +0 -0
  45. package/validators/__pycache__/validate_prd.cpython-312.pyc +0 -0
  46. package/validators/validate_ac_alignment.py +2 -2
  47. package/validators/validate_e2e_index.py +81 -13
  48. package/validators/validate_e2e_mocks.py +24 -5
  49. package/validators/validate_prd.py +75 -16
package/CHANGELOG.md CHANGED
@@ -4,6 +4,63 @@
4
4
 
5
5
  ---
6
6
 
7
+ ## [v0.3.0-beta.3] - 2026-11-17
8
+
9
+ ### 🛡 清单版本门:0.3.0 预发布不再被误判成旧读者
10
+
11
+ * 全局安装 0.3.0-beta.2 在 v2 清单仓库上 `atlas solution check` 直接 exit 2(`manifest_schema_unsupported`),并连带打穿父仓 `check --fast` 的 AC 对齐与 apply record 两条检查;根因是门拿正式版号 `0.3.0` 当界,而 `0.3.0-beta.2 < 0.3.0` 按 semver 成立。门改用 0.3.0 预发布线(`0.3.0-0`),比较器语义不变:0.2.x 仍只读 v1,不可解析仍不放行,0.3.0 正式版读 v2(含正反例钉)。
12
+
13
+ ### 🧩 分层与版本比较(P1 / 2A)
14
+
15
+ * 两份 semver 比较合成一份:判不出版本时统一「不放行」,不再出现两处结论相反;并加了一条钉,同一组输入在两处必须一致(`49c58e3`);
16
+ * 给「内核反过来依赖校验器」加了棘轮:现有几处登记在案、每处写明暂时拆不掉的原因,新增一处就红;相关 docstring 改成如实说明这是已知倒置(`f2b3b45`)。
17
+ * `_support/solution.py` 顶部加了分节地图,并把两个被反向调用的路径助手下沉到 §2(`70f9d4b`);只调位置、不拆文件(P4 结论 C)。
18
+
19
+ ### 🚦 批次门与记账
20
+
21
+ * 新增「按这批改了哪些文件挑测试」的批次预检:改完就能跑,跑不到测试的文件会显式标「无覆盖」,不静默放过(`54918df`);
22
+ * CI 的 POSIX 任务改用同一条预检入口,不再单独写死两个测试文件;Windows 仍保留固定基线作平台对照(`9a685de`);
23
+ * changelog 守卫搬进 `scripts/`、随装配下发;判定改为只认根 `CHANGELOG.md`,每批一行(`e0b0d59`、`7831b68`);
24
+ * 决策作废统一成「只改该行」的行级标记(删除线 + `【已作废 日期:原因 / 承接 D 号】`),只约束增量,存量不迁移(2026-11-17)。
25
+
26
+ ### 🧪 E2E 账本:缺来源按 E1 切点归因
27
+
28
+ * 旧账里没有 `source` 的事件不再一律当成 prototype:早于 2026-09-27(E1 退役日)才算原型存量,之后或判定不了归 `unknown`;写侧本来就恒写来源,新事件不会再被算进退役来源(`dbb64f5`)。
29
+
30
+ ### 🧾 账本单一源(补记 11-17 已推送批次)
31
+
32
+ * 提案评审模板开始强制写「最强反方」和「怎么证伪它」,评审不再只看结论(`de6990a`);
33
+ * 新增一个自动算账的小工具:测试文件数、校验器数、变异编号上限等从源算,不再手抄(`9d0d52d`);
34
+ * 实现地图的数字快照改成自动对账:只改数字不改地图,门会直接红(`23d771e`);
35
+ * 门册里手写的各类计数改成占位,删掉五条「按句式猜数字」的旧正则(`b0c230d`);
36
+ * 实现地图各章的版本号只在页头写一次,不再逐章手抄(`99acadc`);
37
+ * 门册「校验器数量」也改成自动算,并把口径落进决策 D201(`7fb581a`);
38
+ * 实现地图文件条目里漏网的「N 个测试文件」纳入自动计数(`1a17306`);
39
+ * 门册「编排门行」的行数改为自动算,不再手写(`0357bea`);
40
+ * 新增一道检查:测试里声明的变异钉必须与门册登记一致,少登记就红(`0eac771`);
41
+ * 留档 2026-11-17 的设计缺陷审计与账本单一源设计案(`96fcd8b`)。
42
+
43
+ ---
44
+
45
+ ## [v0.3.0-beta.2] - 2026-11-15
46
+
47
+ ### 🧪 E2E 文本期门:R3 机器化 + R11 扩面到 `select`
48
+
49
+ * `validators/validate_e2e_index.py`:`同控件回读禁令` 纳入 `select`;新增门 **`断言异源(R3)`**——非 `initial:` / `unchanged:` 断言若全部落在被交互动作操作过的控件上 ⇒ FAIL(`waitFor` / `read` 不计入,`request` / `api` 天然异源);契约 `rings/e2e/reference.md` §5.6 / §8.2 同步;
50
+ * `validators/validate_e2e_mocks.py`:`mode: on` 时每份 fixture 缺 `<fixture>.schema.json` ⇒ **FAIL**;新增 `scripts/gen_fixture_schemas.py`(`--write` 落盘,只锁形状);
51
+ * `scripts/gen_e2e_scripts.py`:`hidden` 发射改为「先 `not.toHaveCount(0)` 再 `toBeHidden()`」,新增断言动词 `absent`(`toHaveCount(0)`);
52
+ * 契约 `rings/e2e/reference.md` §5.8 增「系统级套件另环」;新增项目侧 `product/e2e/system/` 样板(无环境 skip,不冒充通过)。
53
+
54
+ ### 🧪 AC 文法扩容与解析器口径统一
55
+
56
+ * `_support/solution.py`:`requirements[].acs` 去掉旧正则副本,与 D 批 crosswalk 共用 `_AC_TOKEN_RE` 单源——`AC-V2-DP-01`(连字符前缀段 + 2 位序号)通过,`AC-SYNC-006` 等 3 位旧号继续可用,**4 位及以上仍判非法**;
57
+ * `_support/ac_crosswalk.py`:成员 PRD 域取 front matter 的 `domain_code`(`domain` 是域 slug,不是同一口径),无 `domain_code` 时回落 `domain`;冲突仍报 `member_domain_mismatch`,`detail.source` 标明取用字段;
58
+ * `scripts/atlas_apply_seal.py`:`--card` 按成员仓内相对路径解析;卡未声明 `atlas-acceptance` 时封条照签但打 `[WARN]`,不再静默签出空投影;
59
+ * `validators/validate_prd.py`:`prd/` 白名单只放行 `ac-crosswalk.md` / `ac-crosswalk-waivers.md`;`domain_code` 允许连字符段(`V2-DP`);
60
+ * 发版门清障:`shared/gates.md` 与 `docs/map` 计数锚随实况回正;`rings/e2e/reference.md` 系统级套件条目去掉具体测试框架名。
61
+
62
+ ---
63
+
7
64
  ## [v0.3.0-beta.1] - 2026-11-14
8
65
 
9
66
  ### 🔐 验收面:`SEAL_UPSTREAM_BIND_FROM` 落值 D 批首版 tag 日期(案 10 A / D-48)
package/DESIGN.md CHANGED
@@ -427,7 +427,7 @@ adapters:
427
427
 
428
428
  默认在 atlas 各环与 `apply` 时跑;**可选**再加 git pre-commit 钩子做兜底。
429
429
 
430
- **实现状态**:12 个校验器(`validate_{structure,stack_profile,prd,testids,e2e_index,design_exemptions,e2e_mocks,ac_alignment,adr,walkthrough,task_card,apply_record}.py`)+ `scripts/atlas_check.py`(门总览:校验器 / 出厂测试 / 生成物 / 真跑,**一门一行 `ok|FAIL|WARN|SKIP`**)。
430
+ **实现状态**:〔数:校验器文件=12〕 个校验器(`validate_{structure,stack_profile,prd,testids,e2e_index,design_exemptions,e2e_mocks,ac_alignment,adr,walkthrough,task_card,apply_record}.py`)+ `scripts/atlas_check.py`(门总览:校验器 / 出厂测试 / 生成物 / 真跑,**一门一行 `ok|FAIL|WARN|SKIP`**)。
431
431
 
432
432
  **门总账与收口清单(2026-09-28 落地,`3509 §B112`/`§B114`)**:所有门登记在 `shared/gates.md`(含**对账平面 / 显式盲区 / 验证预算 / 假绿测试取证等级**三列)—— **不在表 = 不存在**;人侧收口步骤表 = `shared/closeout.md`(此前被多处定形引用却长期不存在)。`SKIP` 是**一等结论**(未就绪),不是通过。
433
433
 
@@ -674,6 +674,7 @@ adapters:
674
674
  | D198 | **评审新鲜度改绑用例内容指纹(修「用例没变也被判重审」)**(2026-11-12;`scripts/e2e_console.py`(`case_content_hashes` / `review_fingerprint` / `case_review_state`)、`rings/e2e/reference.md` §10.1、`tests/test_e2e_console.py`;现场 = `api` 动词加入、`.atlas` 重放、spec 重生成后,已审用例在控制台被标回待审) | ① **病灶**:D174 把评审指纹绑在**生成物**(`.spec.ts` 的 test 块 / 块外代码 / 共享脚本 / 应用代码)上,生成器升级或 `.atlas` 重放会改这些字节 ⇒ 已审用例被误判 `stale`;`mtime`/`VERSION`/`HEAD` 同样不能表达「用例内容是否变化」。② **定案**:新增 `fp.case` = 真相源 `product/e2e/cases/*.md` 的 `atlas-case` 块归一化 SHA-16(剥行内 `#` 注释、折叠空白、丢空行;排除 `_file`/`_body` 原文)。有 `fp.case` 时**只比它**:`step`/`expected`/`testid`/`precondition`/`mock`/覆盖维度不变 ⇒ `fresh`,即使 `.atlas` 重放、生成器升级、spec 重生成。③ **记录**:`review_fingerprint` 产出 `case` 映射,`_compact` 落账本 `prov.fp.case`。④ **迁移**:旧账本无 `fp.case` 且能解析出当前指纹 ⇒ 沿用已审(旧账本无法还原评审时 md,块差异可能是生成器升级;重跑/提交后自动写入);解析不到才退回块比较(忽略 `shared`/`app`)。⑤ **范围**:生成器 / 控制台 / 校验门中不新增任何 `mtime` 信号;`review_state` 仅由内容指纹与(迁移期)生成物块决定。⑥ **钉**:注释/空行不改变指纹、`expected` 改变即变、spec/共享/应用全变仍 `fresh`、内容变 `stale`、旧账本迁移沿用已审。 |
675
675
  | D199 | **DSL 动作阶段 `send`(发请求 + 捕获响应值)+ 变量插值扩展到 testid / api·send 路径 / 请求体**(2026-11-12;`scripts/gen_e2e_scripts.py`(`parse_send_line` / `parse_api_request` / `interp_testid` / `interp_path` / `interp_body` / `ts_send_helpers`)、`validators/validate_e2e_index.py`(`send` / `api` 动词表 + 捕获变量登记)、`validators/validate_testids.py`(`api`/`send` 无 testid + 动态 testid 不进双向集合)、`rings/e2e/reference.md` §5.5/§8.2、`tests/test_gen_e2e_scripts.py`;动因 = 用例需「每次执行新建一条专属事项 → 用它去同步 → 断言本次批次」,既有 DSL 无法表达自造数据的跨步引用) | ① **语法**:`send <METHOD> <PATH> [body <JSON>] -> capture <变量名> <json-path>`;请求面与 `api` 共用 `parse_api_request`(方法白名单 / PATH 锚定 / body JSON 单点校验);`-> capture` 必填(丢弃响应的动作无断言价值)。② **变量表**:捕获变量与 `read` 同表(`read_known_before` / 先捕获后用 / 重名中止);捕获值限**标量**,2xx 必达。③ **fail-loud**:非 2xx 由 `atlasApi` 抛错(带 `METHOD URL` / HTTP 状态 / 响应片段);路径缺席或非标量由 `atlasCapture` 抛错(带 `json-path` / HTTP 状态 / 响应片段)—— 不降级成空串或 `undefined`。④ **插值四面**:值段(D191 不变)、**testid**(`row-$slug` / `row-${slug}[0]`)、**api·send PATH**(`/records/${batchNo}`)、**api·send body 字符串叶子**;`$名` 为规范形态、`${名}` 为别名(值段仍只认 `$名`,零变化)。⑤ **发射形态**:含变量的 testid/PATH 发 JS 模板字面量(反引号 + `${atlasVar_<名>}`),静态仍发单引号/JSON 字面量(逐字节不变);`testid:` **声明**必须静态(变量形态 ⇒ 生成期中止,守卫不得等字面量);静态双向集合门不收集含 `$` 的动态 testid(运行期拼名不可枚举,真红归执行面)。⑥ **零变化承诺**:无 `send` 且无插值的页面不发射 `atlasCapture`、不出现模板字面量;`mock:` / `atlas-mock` 留痕 / 未桩 fail-loud / 零步基线语义不动(含变量断言本就退出基线)。⑦ **钉**:解析成功/失败、捕获 + body/testid/path 插值发射、捕获缺失的可读错误、未知变量与动态声明中止、无新动词零变化;`api` 的 `-> json` 在 PATH 插值后断言语义不变。 |
676
676
  | D200 | **`families.py --json` 双轨批:人读轨不动,尾部机器段供脚本取数**(2026-11-14;`proposals/RFC-20261114-06` + 独立评审 `proposals/REVIEW-20261114-06`〔tech-proposal-reviewer 只读,总判定「改造后采纳」:P0 钉 1 重设计 / 登记面修正,P1 双轨形态 / 变异补齐 / 序列化陷阱〕;维护者拍板落刀) | ① **病灶**:`scripts/duty_signals.sh:30` 唯一调用只输出人读文本(`main()` 无结构化出口),巡检自动化与其他信号面对账只能正则刮中文列;现网 families 段 **1142 字节 / 6 行**(2026-11-14 实测)。② **定案**:`duty-review/families.py` 的 `main()` 加 `--json` 旗标(**扫描剥离** `--json`,不上 argparse——未知旗标 exit 2 与 `-h` 行为面不扩张;`--json <path>` 与 `<path> --json` 皆通);`--json` 输出 compact 单行 JSON(`ensure_ascii=False`、无 indent)= `{"ledger", "cutoff", "families":[{family,count,exact,last_date,active,verdict,warns[]}], "warns"}`,**显式挑字段序列化**(rows 内含 `ids` / `exact_ids` 两个 set,直接 `json.dumps` 必炸),**不重复 render_text**(人读文本由 `duty_signals.sh` 第一次调用提供);台账缺 ⇒ `families=[]` / `warns=[]` / `cutoff=null`(不崩不编造);**无旗标输出逐字节不变**。`scripts/duty_signals.sh` 两次调用:`:30` 原行一字不动,其下加 marker `== bugs.md 族 JSON (机器段,供脚本取数) ==` + `--json` 调用;文件头自述改「人读为主,尾部机器段供脚本取数」。**介质不动** = `bugs.md` / `QUEUE.md` 不动(承 D154 拒 JSON/SQLite 搬介质),本决策只加**读取侧出口**。③ **被否**:argparse(行为面扩张);payload 带 `render_text`(纯重复);直接 `json.dumps(rows)`(set 崩);真实台账永久冻结钉(`families()` 内部取运行日,四周内必翻「族已静默」);JSON 落文件(违巡检只读铁则)。④ **钉与变异**:`tests/test_duty_bug_families.py` 19 → **22** 条(JSON 机器段 3:钉 1 派生日期夹具 + 同源逐字段对照;钉 2 warns 双轨等值;钉 3 no-flag = `render()` 单源直通 + 首行措辞逐字,不做真实台账冻结);变异 **MB24/MB25/MB26** 四段协议,红因集合恰等于被摘物。⑤ **登记面七处**:`shared/gates.md` 条数 / 测试文件头计数行 / `duty-review/README.md` :30、:32、:65(§4)/ 本行 / `CHANGELOG.md` 新批段。 |
677
+ | D201 | **账本单一源:计数改「活源派生 + 占位 + 重渲染字节门」**(2026-11-17;`scripts/ledger_snapshot.py`、`tests/test_ledger_snapshot.py`、`tests/test_canonical_consistency.py`、`tests/test_map_anchors.py`、`tests/refresh_count_anchors.py`、`shared/gates.md`、`docs/map/*.md`;维护者拍板落刀) | ① **病灶**:同一计数在门册 / 数字快照 / 章节散文里多份手抄,门只锁其中一部分固定句式;实测「门全绿但账本自相矛盾」三例(章节版本串 7 处停在旧版、map 章 77 vs 实况 80、同文件 M162/M164 互斥)。② **定案**:计数一律由 `ledger_snapshot.derive` 从源算出,正文只留派生占位(`ledger_snapshot` 的 `数:键=值` 标注);`check_ledger_tokens` 判「重渲染后逐字节不变」,扫描面含 `shared/gates.md` / `DESIGN.md` / `docs/map/*.md`。删除 A–E 五条计数正则(「移除后 N/N」「当前 N)」实测 0 命中,属静默死判据;「当前 N」仍由 `check_gates_gates_are_scheduled` 守)。四枚真钉 M20′/M22′/M23′/M24′ 接管原右列 M20–M24(后者在代码里无实现,属假绿声明)。`docs/map` 版本副本 11 份 → 3 份(index 锚定行 + html 两处,全部在 `check_freshness` 值域)。③ **边界**:判断性内容不派生(门册「不查什么」/取证等级/决策理由/changelog 措辞);缺源与未知键一律响亮失败,不静默 0。 |
677
678
 
678
679
  ---
679
680
 
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.3.0--beta.1-blue.svg" alt="Version" />
4
+ <img src="https://img.shields.io/badge/version-0.3.0--beta.3-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>
@@ -33,7 +33,8 @@ _DIM_CLAIM_RE = re.compile(r"(?<!AC-)(?<![0-9A-Za-z])[Cc](\d{1,2})(?![0-9])")
33
33
 
34
34
  # `关联AC` 单元格多值口径(RFC-20261111-03 §1.6):一格可写单值或分隔列表,
35
35
  # 分隔符 `、` / `,` / `,`;逐 token 去首尾空白。token 合法性仍须整串匹配本正则。
36
- AC_REF_RE = re.compile(r"^AC-[A-Z0-9]+-\d{3}$")
36
+ # AC 文法:前缀可含连字符段(`AC-V2-DP-*`),序号 2–3 位(`AC-SYNC-006`)。
37
+ AC_REF_RE = re.compile(r"^AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3}$")
37
38
  _AC_REF_DELIMS = re.compile(r"[、,,]")
38
39
 
39
40
 
@@ -48,8 +48,12 @@ from datetime import date
48
48
  from typing import Any
49
49
 
50
50
  SOLUTION_AC_RE = re.compile(r"^AC-SOLUTION-\d{3}$")
51
- MEMBER_AC_RE = re.compile(r"^AC-[A-Z0-9]+-\d{3}$")
52
- MEMBER_AC_PARTS_RE = re.compile(r"^AC-(?P<code>.+)-(?P<num>\d{3})$")
51
+ # 成员 AC 文法:前缀可含连字符段(`AC-V2-DP-*`),序号 2–3 位(`AC-SYNC-006`)。
52
+ # 与 `_support/solution.py::_AC_TOKEN_RE`、`validators/validate_prd.py::AC_RE`
53
+ # 同文法(一致性钉见 `tests/test_ac_crosswalk.py`)。
54
+ _AC_CODE = r"[A-Z0-9]+(?:-[A-Z0-9]+)*"
55
+ MEMBER_AC_RE = re.compile(rf"^AC-{_AC_CODE}-\d{{2,3}}$")
56
+ MEMBER_AC_PARTS_RE = re.compile(rf"^AC-(?P<code>.+)-(?P<num>\d{{2,3}})$")
53
57
  CONTRACT_AC_RE = re.compile(r"^AC-CONTRACT-\d{3}$")
54
58
  CONTRACT_AC_PREFIX = "AC-CONTRACT-"
55
59
  DATE_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$")
@@ -327,13 +331,20 @@ def crosswalk_findings(table: CrosswalkTable, manifest: dict, reader,
327
331
  prd_rel))
328
332
  if reader.exists(prd_rel):
329
333
  fm = reader.front_matter(prd_rel) or {}
330
- domain = str(fm.get("domain") or "").strip()
331
- if domain and domain.lower() != row.member_domain.lower():
334
+ # 成员域取 AC 前缀(`AC-SYNC-*` → `sync`),对应 PRD 的 `domain_code`;
335
+ # `domain` 是域 slug(`cross-network-sync`),不是同一口径。无 `domain_code`
336
+ # 的存量 PRD 才回落到 `domain`(旧口径继续可用)。
337
+ code = str(fm.get("domain_code") or "").strip()
338
+ slug = str(fm.get("domain") or "").strip()
339
+ source = "domain_code" if code else "domain"
340
+ declared = code or slug
341
+ if declared and declared.lower() != row.member_domain.lower():
332
342
  add("member_domain_mismatch", "error",
333
343
  f"member_domain_mismatch: 成员 PRD front matter "
334
- f"domain={domain!r} 与 crosswalk 成员域 "
344
+ f"{source}={declared!r} 与 crosswalk 成员域 "
335
345
  f"{row.member_domain!r} 不符({prd_rel})", prd_rel,
336
- {"line": row.line, "kind": "front_matter"},
346
+ {"line": row.line, "kind": "front_matter",
347
+ "source": source},
337
348
  dedupe=("member_domain_mismatch", "front_matter", row.member,
338
349
  row.prd))
339
350
 
@@ -540,7 +551,7 @@ def _contract_ac_findings(text: str, manifest: dict, rel: str) -> list[Finding]:
540
551
  for idx, line in enumerate(text.splitlines(), 1):
541
552
  if idx in contract_lines or not line.strip().startswith("|"):
542
553
  continue
543
- for token in re.findall(r"AC-[A-Z0-9]+-\d{3}", line):
554
+ for token in re.findall(rf"AC-{_AC_CODE}-\d{{2,3}}", line):
544
555
  if not token.startswith(CONTRACT_AC_PREFIX):
545
556
  section_ac.add(token)
546
557
  ids: list[str] = []
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env python3
2
+ """semver 比较单源(2026-11-17 P1 / 2A)。
3
+
4
+ 背景:此前有两份 `semver_lt`——内核 `_support/solution.py` 一份、CLI
5
+ `scripts/atlas_solution.py` 一份;两份在**不可解析输入**上结论相反(内核判
6
+ "不小于",CLI 退回字符串比较),同一组输入可以给出相反答案。本模块是唯一实现。
7
+
8
+ `lt(a, b)` 的不可判定语义 = **False**(fail-closed):
9
+
10
+ - 对「宽限/放行」类门(CLI 的 `--allow-dangling-acs` 版本门控):False ⇒ 不放行;
11
+ - 对「拒绝」类门(内核 schema 门):调用方都在**空版本**处先短路(`if reader and ...`),
12
+ 非空但不可解析的值不应被当成"新版本"继续放宽——宁可判不出就不放行。
13
+
14
+ 不返回"看起来合理"的结果,也不抛异常:调用方需要的是布尔门,不是排序。
15
+
16
+ 注意:`scripts/release.py` 另有 `parse_semver`(5 元组、带预发布序号、用于版本推导),
17
+ 与比较门不是同一职责,未并入本模块。
18
+ """
19
+ from __future__ import annotations
20
+
21
+ import re
22
+
23
+ _SEMVER_RE = re.compile(
24
+ r"^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$")
25
+
26
+
27
+ def parse(raw: str) -> tuple[tuple[int, int, int], tuple[str, ...]] | None:
28
+ """`((major, minor, patch), (pre, ...))`;不可解析 ⇒ None(含装配摘要形态)。"""
29
+ m = _SEMVER_RE.match((raw or "").strip())
30
+ if m is None:
31
+ return None
32
+ pre = tuple(m.group(4).split(".")) if m.group(4) else ()
33
+ return (int(m.group(1)), int(m.group(2)), int(m.group(3))), pre
34
+
35
+
36
+ def _cmp_pre(a: tuple[str, ...], b: tuple[str, ...]) -> int:
37
+ """semver §11 预发布比较:数字段按数值、数字 < 字母、前缀相同则更短更小。"""
38
+ if a == b:
39
+ return 0
40
+ if not a:
41
+ return 1 # 正式版 > 预发布
42
+ if not b:
43
+ return -1
44
+ for x, y in zip(a, b):
45
+ if x == y:
46
+ continue
47
+ xn, yn = x.isdigit(), y.isdigit()
48
+ if xn and yn:
49
+ return -1 if int(x) < int(y) else 1
50
+ if xn != yn:
51
+ return -1 if xn else 1
52
+ return -1 if x < y else 1
53
+ return -1 if len(a) < len(b) else 1
54
+
55
+
56
+ def lt(a: str, b: str) -> bool:
57
+ """`a < b`;任一不可解析(空串、非版本串、装配摘要)⇒ **False**(fail-closed)。"""
58
+ pa, pb = parse(a), parse(b)
59
+ if pa is None or pb is None:
60
+ return False
61
+ if pa[0] != pb[0]:
62
+ return pa[0] < pb[0]
63
+ return _cmp_pre(pa[1], pb[1]) < 0
@@ -16,6 +16,19 @@ CI 按锁还原由流水线自行 clone + checkout 承担(见 `shared/solution
16
16
  这些属于 Phase 2/3;遇到 `mode: unified` 必须显式拒绝,不得静默降级。
17
17
 
18
18
  契约正文见 `shared/solution.md`。
19
+
20
+ 分节地图(2026-11-17 P4/X2,仅索引;分节以 `# ----` 为准,不写行号以免漂):
21
+ §0 模块头 SolutionError / _load_sibling / 清单·锁常量
22
+ §1 manifest manifest_path
23
+ §2 reader load_manifest / reader_version 三级回落 / semver / _assets_root / _valid_task_slug
24
+ §3 git _git* / _is_git / _head / member_state
25
+ §4 契约锁 contract_states / 锁摘要工具
26
+ §5 definition read_lock / write_lock / definition 链与 PRD front matter
27
+ §6 init/adopt init_solution / adopt_solution / 安装骨架
28
+ §7 status status / 锁成员与 acceptance_cutover 检查
29
+ §8 B-0 ⓪ 层错误类型 / path_at / 历史前缀纯函数
30
+ §9 D 批 check_solution / AC crosswalk / 契约检查
31
+ §10 封条写侧 select_seal_path / freeze_seal / render_*
19
32
  """
20
33
  from __future__ import annotations
21
34
 
@@ -91,6 +104,15 @@ case_id = _load_sibling("case_id", "_atlas_solution_case_id")
91
104
  _LAYOUT = _load_sibling("layout", "_atlas_solution_layout")
92
105
  # 封条单源(C 批):路径宇宙 / 续签链 / 状态机 / 写侧。
93
106
  _SEAL = _load_sibling("solution_seal", "_atlas_solution_seal")
107
+ # semver 比较单源(2026-11-17 P1):与 `scripts/atlas_solution.py` 共用一份实现,
108
+ # 不可解析 ⇒ False(fail-closed)。见 `_support/semver.py` 顶部说明。
109
+ _SEMVER = _load_sibling("semver", "_atlas_semver")
110
+
111
+ # AC ID 文法单源(`AC-V2-DP-01`:前缀可含连字符段,序号 2–3 位;`AC-SYNC-006` 等
112
+ # 3 位旧号继续可用,4 位及以上仍非法)。`validate_manifest` 的 `requirements[].acs`
113
+ # 与 D 批 crosswalk 解析共用本常量——同一文件内不得再写第二份正则副本;跨模块
114
+ # (`ac_crosswalk` / `validate_prd` / `solution_e2e`)须同文法,改动一并同步。
115
+ _AC_TOKEN_RE = re.compile(r"^AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3}$")
94
116
 
95
117
 
96
118
  # ---------------------------------------------------------------- manifest
@@ -105,27 +127,21 @@ def manifest_path(root: Path) -> Path:
105
127
  # **只用来定位工具自身的版本来源,绝不读被检查仓 `<root>/package.json`**(v11/重要 3)。
106
128
  _TOOL_PACKAGE_ROOT = Path(__file__).resolve().parents[1]
107
129
 
108
- _SEMVER_RE = re.compile(
109
- r"^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$")
110
-
111
-
112
130
  def parse_semver(raw: str) -> tuple[int, int, int, str] | None:
113
- """(major, minor, patch, prerelease);不可解析 ⇒ None(含装配摘要形态)。"""
114
- m = _SEMVER_RE.match((raw or "").strip())
115
- if m is None:
131
+ """(major, minor, patch, prerelease);不可解析 ⇒ None(含装配摘要形态)。
132
+
133
+ 实现单源在 `_support/semver.py`;这里只保留 4 元组形态的历史调用面。
134
+ """
135
+ parsed = _SEMVER.parse(raw)
136
+ if parsed is None:
116
137
  return None
117
- return int(m.group(1)), int(m.group(2)), int(m.group(3)), m.group(4) or ""
138
+ (major, minor, patch), pre = parsed
139
+ return major, minor, patch, ".".join(pre)
118
140
 
119
141
 
120
142
  def semver_lt(raw: str, bound: tuple[int, int, int]) -> bool:
121
- """`raw < bound`(同版本时预发布视为更小);`raw` 不可解析 ⇒ False。"""
122
- parsed = parse_semver(raw)
123
- if parsed is None:
124
- return False
125
- base, pre = parsed[:3], parsed[3]
126
- if base != bound:
127
- return base < bound
128
- return bool(pre)
143
+ """`raw < bound`(同版本时预发布视为更小);`raw` 不可解析 ⇒ False(fail-closed)。"""
144
+ return _SEMVER.lt(raw, "%d.%d.%d" % tuple(bound[:3]))
129
145
 
130
146
 
131
147
  def resolve_reader_version(root: Path) -> tuple[str, list[dict]]:
@@ -224,6 +240,29 @@ def _scalar(raw: str):
224
240
  return v
225
241
 
226
242
 
243
+ # 基础路径助手(2026-11-17 P4/X1):被 §2 自身与后续各节共用。放在 §2 顶部,
244
+ # 使 §2 不再反向调用 §6/§9;后续节的调用属于向下依赖,不再是分层倒置。
245
+ def _valid_task_slug(slug: str) -> bool:
246
+ if not slug or "/" in slug or "\\" in slug or ".." in slug:
247
+ return False
248
+ if re.match(r"^\d{2}-\d{2}-", slug):
249
+ return False
250
+ return True
251
+
252
+
253
+ def _assets_root(root: Path) -> str:
254
+ """资产根:读 `atlas.config.yaml` 的 `assets_root:`,缺省 `product`。"""
255
+ config = root / CONFIG_NAME
256
+ if config.is_file():
257
+ for line in config.read_text(encoding="utf-8", errors="replace").splitlines():
258
+ s = line.strip()
259
+ if s.startswith("assets_root:"):
260
+ v = _scalar(s.split(":", 1)[1])
261
+ if isinstance(v, str) and v:
262
+ return v
263
+ return "product"
264
+
265
+
227
266
  _URL_SCHEMES = ("http", "https", "ssh", "git", "file")
228
267
  _CREDENTIAL_QUERY = re.compile(
229
268
  r"(?:^|[?&])(?:access_token|private_token|token|auth|key|sig|signature|"
@@ -464,19 +503,25 @@ def _cutover_note(value: str, cutover: str | None) -> str:
464
503
  return f"acceptance_cutover={value}(可用 --cutover 覆盖)"
465
504
 
466
505
 
506
+ # v2 清单的引入线:0.3.0 的**任何预发布**都在线内(`0.3.0-beta.N` / `rc.N` 都读得懂 v2)。
507
+ # 不能用正式版号 `0.3.0` 当界——按 semver,`0.3.0-beta.2 < 0.3.0`,会把整条 0.3.x
508
+ # 预发布线误判成"旧读者"并拒掉 v2 清单(2026-11-17 跨网传输复验实测)。
509
+ _V2_MANIFEST_FLOOR = "0.3.0-0"
510
+
511
+
467
512
  def _manifest_version(raw, root: Path | None = None) -> int:
468
513
  """清单 schema 版本门(RFC §5.2 / §5.3)。
469
514
 
470
515
  判定依据是**读者版本**(工具自身,见 `reader_version`):
471
516
  - 不可判(`""`):不设门,`{1,2}` 都收——判不出自身版本时不得误拒;
472
- - `< 0.3.0`:只收 `1`(v2 清单是 0.3.0 才引入的,旧读者读不懂 `definition`);
473
- - `0.3.x`(B-0 发布带):`{1,2}`(迁移窗口);
517
+ - `< 0.3.0-0`(即 0.2.x 及更早):只收 `1`(v2 清单是 0.3.0 引入的,旧读者读不懂 `definition`);
518
+ - `0.3.0` 线(含 beta / rc 预发布):`{1,2}`(迁移窗口);
474
519
  - `>= 0.4.0`:只收 `2`,v1 给迁移口令而不是裸拒(0.4.0 不再注册 `migrate`)。
475
520
  """
476
521
  value = str(raw or "").strip()
477
522
  reader = reader_version(Path(root)) if root is not None else ""
478
523
  allowed = {"1", "2"}
479
- if reader and semver_lt(reader, (0, 3, 0)):
524
+ if reader and _SEMVER.lt(reader, _V2_MANIFEST_FLOOR):
480
525
  allowed = {"1"}
481
526
  elif reader and not semver_lt(reader, (0, 4, 0)):
482
527
  allowed = {"2"}
@@ -607,7 +652,7 @@ def validate_manifest(data: dict, root: Path, phase1: bool = True) -> dict:
607
652
  if not acs:
608
653
  raise SolutionError(f"requirement {rid} 缺少 acs")
609
654
  for ac in acs:
610
- if not re.fullmatch(r"AC-[A-Z0-9]+-\d{3}", ac):
655
+ if not _AC_TOKEN_RE.match(ac):
611
656
  raise SolutionError(f"requirement {rid} 的 AC ID 非法: {ac!r}")
612
657
  slug = str(item.get("task_slug") or "").strip()
613
658
  if not _valid_task_slug(slug):
@@ -1791,14 +1836,6 @@ def _member_entries(members: list[tuple], root: Path | None = None) -> list[dict
1791
1836
  return out
1792
1837
 
1793
1838
 
1794
- def _valid_task_slug(slug: str) -> bool:
1795
- if not slug or "/" in slug or "\\" in slug or ".." in slug:
1796
- return False
1797
- if re.match(r"^\d{2}-\d{2}-", slug):
1798
- return False
1799
- return True
1800
-
1801
-
1802
1839
  def _yaml_value(value: str) -> str:
1803
1840
  """清单值:含 `#` 时加引号,避免被行内注释截断。"""
1804
1841
  s = str(value)
@@ -3041,7 +3078,6 @@ def _layer0_lock(root: Path):
3041
3078
 
3042
3079
  CROSSWALK_FILE = "ac-crosswalk.md"
3043
3080
  CROSSWALK_WAIVERS_FILE = "ac-crosswalk-waivers.md"
3044
- _AC_TOKEN_RE = re.compile(r"^AC-[A-Z0-9]+-\d{3}$")
3045
3081
  _SOLUTION_AC_RE = re.compile(r"^AC-SOLUTION-\d{3}$")
3046
3082
 
3047
3083
 
@@ -3126,7 +3162,9 @@ class _SolutionPrdReader:
3126
3162
 
3127
3163
  def front_matter(self, path: str) -> dict:
3128
3164
  fm = _prd_front_matter(self.root / path)
3129
- return {"domain": fm.get("domain", ""), "prd_schema": fm.get("prd_schema", "")}
3165
+ return {"domain": fm.get("domain", ""),
3166
+ "domain_code": fm.get("domain_code", ""),
3167
+ "prd_schema": fm.get("prd_schema", "")}
3130
3168
 
3131
3169
  def ac_links(self, path: str) -> list[dict]:
3132
3170
  file = self.root / path
@@ -3777,18 +3815,6 @@ def has_apply_seal(root: Path) -> bool:
3777
3815
  return any(base.rglob("*.seal.json"))
3778
3816
 
3779
3817
 
3780
- def _assets_root(root: Path) -> str:
3781
- config = root / CONFIG_NAME
3782
- if config.is_file():
3783
- for line in config.read_text(encoding="utf-8", errors="replace").splitlines():
3784
- s = line.strip()
3785
- if s.startswith("assets_root:"):
3786
- v = _scalar(s.split(":", 1)[1])
3787
- if isinstance(v, str) and v:
3788
- return v
3789
- return "product"
3790
-
3791
-
3792
3818
  # ---------------------------------------------------------------- 封条写侧(C 批)
3793
3819
 
3794
3820
  def select_seal_path(root: Path, requested: str | None = None) -> str:
@@ -12,7 +12,11 @@
12
12
  **只读**:不接管成员执行、不写成员索引/账本;成员 `review_state` 按**成员根**重算,
13
13
  结果只在内存/`--json` 中展示,不落盘。唯一的写动作是显式 `--snapshot` 写父仓自己的
14
14
  `<assets_root>/e2e/reviews/aggregate/`(保留名,非成员状态第二份账本)。
15
- 纯标准库;索引/分片解析复用既有校验器(同一份解析,不另写)。
15
+ 纯标准库。**已知分层倒置(勿模仿)**:索引/分片解析目前直接 `load_module` 校验器
16
+ `validators/validate_e2e_index`(处数见棘轮清单),形成 `_support → validators` 的反向依赖,
17
+ 靠惰性加载掩盖环;正在按 2026-11-17 排序 P3(2B)收敛到
18
+ `_support/e2e_index_core.py`。在此之前**不要**新增同类依赖——棘轮钉在
19
+ `tests/test_shared_kernel.py::test_kernel_reverse_dependencies_are_ratcheted`。
16
20
  """
17
21
  from __future__ import annotations
18
22
 
@@ -365,7 +369,7 @@ def _ac_coverage(root: Path | None, index: dict, data: dict | None = None) -> di
365
369
  except OSError:
366
370
  return dict(_AC_COVERAGE_EMPTY)
367
371
  defs = {m.group(1) for m in
368
- re.finditer(r"^\|\s*`?(AC-[A-Z0-9]+-\d{3})`?\s*\|", prd_text, re.M)}
372
+ re.finditer(r"^\|\s*`?(AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3})`?\s*\|", prd_text, re.M)}
369
373
  # RFC-20261111-03 §1.6:`关联AC` 一格可持多值,按 token 拆开后再与定义集求交。
370
374
  attached = {ac for r in index["rows"]
371
375
  for ac in load_module("ac_coverage").split_acs(r.get("关联AC"))} & defs
@@ -445,7 +449,7 @@ def read_member_summary(root: Path, member: dict) -> dict:
445
449
  ledger = cons.Ledger(path, "只读视图")
446
450
  committed = ledger.committed_snapshot("app", current)
447
451
  submits = [e for e in ledger.read()
448
- if e.get("kind") == "submit" and e.get("source", "prototype") == "app"]
452
+ if e.get("kind") == "submit" and cons.Ledger.event_source(e) == "app"]
449
453
  review = _empty_review()
450
454
  for row in parsed["rows"]:
451
455
  cid = row["用例ID"]
@@ -19,7 +19,7 @@ import sys
19
19
  from datetime import datetime
20
20
  from pathlib import Path
21
21
 
22
- AC_RE = re.compile(r"AC-[A-Z0-9]+-\d{3}")
22
+ AC_RE = re.compile(r"AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3}")
23
23
  SLUG_BAD = re.compile(r"[/\\]|\.\.")
24
24
 
25
25
 
@@ -160,7 +160,7 @@ def _ac_defs(root: Path, data: dict, assets_root: str | None = None) -> set[str]
160
160
  return set()
161
161
  defs: set[str] = set()
162
162
  for line in prd.read_text(encoding="utf-8", errors="replace").splitlines():
163
- m = re.match(r"^\|\s*`?(AC-[A-Z0-9]+-\d{3})`?\s*\|", line)
163
+ m = re.match(r"^\|\s*`?(AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3})`?\s*\|", line)
164
164
  if m:
165
165
  defs.add(m.group(1))
166
166
  return defs
package/adapters/ac/js.py CHANGED
@@ -26,8 +26,8 @@ from _support.siblings import load_module # noqa: E402
26
26
 
27
27
  _ac_coverage = load_module("ac_coverage")
28
28
 
29
- AC_ID_RE = re.compile(r"\b(AC-[A-Z0-9]+-\d+)\b")
30
- TITLE_AC_RE = re.compile(r"\[(AC-[A-Z0-9]+-\d+)\]")
29
+ AC_ID_RE = re.compile(r"\b(AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3})\b")
30
+ TITLE_AC_RE = re.compile(r"\[(AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3})\]")
31
31
  CALL_RE = re.compile(
32
32
  r"\b(it|test|describe|xit|xdescribe|fit|fdescribe)\b"
33
33
  r"(\s*\.\s*(skip|todo|only|fails|concurrent|skipIf|each))?\s*\("
@@ -28,7 +28,7 @@ from _support.siblings import load_module # noqa: E402
28
28
 
29
29
  _ac_coverage = load_module("ac_coverage")
30
30
 
31
- TITLE_AC_RE = re.compile(r"\[(AC-[A-Z0-9]+-\d+)\]")
31
+ TITLE_AC_RE = re.compile(r"\[(AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3})\]")
32
32
  TEST_ANN_RE = re.compile(r"@(Test|ParameterizedTest|RepeatedTest|TestFactory)\b")
33
33
  CLASS_RE = re.compile(r"\b(?:class|interface|record|enum)\s+([A-Za-z_]\w*)")
34
34
  METHOD_RE = re.compile(r"([A-Za-z_]\w*)\s*\(")
@@ -110,7 +110,7 @@ def wire_project(target: Path, force: bool = False) -> dict:
110
110
  "detail": "appended ac marker registration to existing pytest.ini",
111
111
  "_write": (ini_path, new_content)}
112
112
 
113
- AC_ID_RE = re.compile(r"\b(AC-[A-Z0-9]+-\d+)\b")
113
+ AC_ID_RE = re.compile(r"\b(AC-[A-Z0-9]+(?:-[A-Z0-9]+)*-\d{2,3})\b")
114
114
  SKIP_DIRS = {
115
115
  "node_modules", ".git", "dist", "build", ".next", "coverage", "__pycache__",
116
116
  ".venv", "venv", "vendor", ".cache", "out", "target", ".atlas", ".atlas-run", ".scratch", ".trellis",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atlas-project-harness",
3
- "version": "0.3.0-beta.1",
3
+ "version": "0.3.0-beta.3",
4
4
  "description": "践行 Project Harness 的全流程 AI 编程工作流治理引擎",
5
5
  "bin": {
6
6
  "atlas": "bin/atlas.js"