Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bf8a68cf5 | ||
|
|
277f9c307d | ||
|
|
01fb8ff7d0 | ||
|
|
4a92201708 | ||
|
|
633ce64cdf | ||
|
|
0655e8f4d5 | ||
|
|
903f729a4d | ||
|
|
d4ccb77003 | ||
|
|
328cc5c61b | ||
|
|
520931ca34 | ||
|
|
f17e23aeec | ||
|
|
f4e292e7b0 | ||
|
|
e7324edc0f | ||
|
|
c190ffb184 | ||
|
|
380d4f95a3 | ||
|
|
48189243f7 | ||
|
|
4fade3e981 | ||
|
|
0c7430ede0 | ||
|
|
8fa728b302 |
No files matched your search
@@ -16,6 +16,7 @@ steps:
|
|||||||
git -C "$domain" submodule update --init
|
git -C "$domain" submodule update --init
|
||||||
done
|
done
|
||||||
- python3 scripts/check-layout.py --checkouts
|
- python3 scripts/check-layout.py --checkouts
|
||||||
|
- python3 scripts/check-repo-conventions.py
|
||||||
|
|
||||||
candidate:
|
candidate:
|
||||||
# Match the Linux/glibc environment already used by View for the RC.4 artifact.
|
# Match the Linux/glibc environment already used by View for the RC.4 artifact.
|
||||||
|
|||||||
@@ -8,3 +8,14 @@
|
|||||||
6. 新接入组件先核对公开 API、直接依赖、独立入口和实际测试。空仓在 [迁移台账](docs/MIGRATION.md) 中保持 `planned`;Web 领域的 Design/Preview 子组件记录在 `marqdo-ext-web` 自己的 `components.toml`,根目录不登记其后代路径。
|
6. 新接入组件先核对公开 API、直接依赖、独立入口和实际测试。空仓在 [迁移台账](docs/MIGRATION.md) 中保持 `planned`;Web 领域的 Design/Preview 子组件记录在 `marqdo-ext-web` 自己的 `components.toml`,根目录不登记其后代路径。
|
||||||
7. 记录 FAIL 和 UNVERIFIED 的具体环境、命令和日志。只有实际通过且匹配候选 SHA 的证据才可用于集成与发行;模拟、mock 或原型测试不能冒充生产验收。
|
7. 记录 FAIL 和 UNVERIFIED 的具体环境、命令和日志。只有实际通过且匹配候选 SHA 的证据才可用于集成与发行;模拟、mock 或原型测试不能冒充生产验收。
|
||||||
8. Web 边界硬约束:不新增 CLI 核心语法或 Web 专属关键字;不复制 Markdown/语言解析器;默认不允许 HTML 注入、业务 JS 或真实网络/数据库/认证;预览是有限确定性解释,生产实现由成熟框架在目标应用仓库承担。
|
8. Web 边界硬约束:不新增 CLI 核心语法或 Web 专属关键字;不复制 Markdown/语言解析器;默认不允许 HTML 注入、业务 JS 或真实网络/数据库/认证;预览是有限确定性解释,生产实现由成熟框架在目标应用仓库承担。
|
||||||
|
|
||||||
|
## 生态仓库开发规范(防膨胀,强制)
|
||||||
|
|
||||||
|
本文件与 [docs/REPOSITORY-CONVENTIONS.md](docs/REPOSITORY-CONVENTIONS.md) 共同约束所有仓库;后者是仓库组织、准入、最低文件集、AGENTS 模板、CI/发布/晋升与防膨胀清单的详细规范。做任何跨仓、建仓、激活、拆目录、加合同/清单/发布线之前必须先读它。
|
||||||
|
|
||||||
|
- **禁止膨胀**:不为单个功能/页面/算法/实验建仓;不建空壳/镜像/docs-only 仓;治理树最多两级 gitlink;禁止第三级、重复 catalog、第二套 contract/manifest/lock/parser/发布服务。
|
||||||
|
- **每个 active 仓最低集**:README、AGENTS.md(含 `<!-- marqdo:repo-conventions v1 -->` 与根规范链接)、真实 `entry`、正反例、可复现证据、独立 CI;planned 仓库不登记 entry、不批量生成模板、不计完成率,激活时补齐。
|
||||||
|
- **单一事实源**:源码组合=gitlink+.gitmodules;职责/依赖=catalog;依赖=各仓锁/manifest;发布=Gitea tag/资产;CI=真实 pipeline;推进=Issue/PR。不手工维护“最新版本表”。
|
||||||
|
- **四种事实分开**:组件 CI 通过、release 发布、消费者接入、父级接受互不推导。晋升固定顺序 C2(组件)→ B2(领域)→ A2(根),先推子仓再更 gitlink,父级 PR 不夹带子仓源码。
|
||||||
|
- **证据纪律**:记录 SHA、制品摘要、平台、命令、退出码、日志范围;未运行写 `UNVERIFIED`;不伪造 entry/版本/CI/PASS/发布资产;不提交密钥或构建产物。
|
||||||
|
- **检查入口**:`scripts/check-repo-conventions.py`、`scripts/check-layout.py --checkouts`、`tests/integration`;CI layout 阶段强制执行,规则变更必须同步测试与模板。
|
||||||
@@ -106,7 +106,7 @@ marqdo run hello.mq.md
|
|||||||
|
|
||||||
### Web 领域聚合
|
### Web 领域聚合
|
||||||
|
|
||||||
Web 领域以设计文档为源材料,面向可交互的原型预览与工程交付。HTTP、数据库、认证和浏览器运行时各自独立维护。`extensions/web` 链接 `planned` 的 Web 领域仓,Design 和 Preview 由该领域仓固定。 [WEB-DESIGN](https://git.cflmy.cn/cflmy/marqdo-ext-web/src/branch/main/docs/WEB-DESIGN.md)
|
Web 领域以设计文档为源材料,面向可交互的原型预览与工程交付。HTTP、数据库、认证和浏览器运行时各自独立维护。`extensions/web` 链接 active 的 Web 领域仓;Design 和 Preview 已在该领域 catalog 激活并登记真实入口,`web` Tool 通过冷安装验证。 [WEB-DESIGN](https://git.cflmy.cn/cflmy/marqdo-ext-web/src/branch/main/docs/WEB-DESIGN.md)
|
||||||
|
|
||||||
| 仓库 | 职责 |
|
| 仓库 | 职责 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
|
|||||||
+1
-1
Submodule cli updated: 452e9a32bd...13affa76dd.
+22
-15
@@ -93,23 +93,25 @@ release = "base"
|
|||||||
id = "std-collections"
|
id = "std-collections"
|
||||||
path = "stdlib/collections"
|
path = "stdlib/collections"
|
||||||
kind = "stdlib"
|
kind = "stdlib"
|
||||||
state = "planned"
|
state = "active"
|
||||||
owner = "cflmy"
|
owner = "cflmy"
|
||||||
scope = "List、Map 和 Table 值操作"
|
scope = "List、Map 和 Table 值操作"
|
||||||
requires = ["cli", "std-core"]
|
requires = ["cli"]
|
||||||
checks_with = []
|
checks_with = ["std-data"]
|
||||||
release = "base"
|
release = "base"
|
||||||
|
entry = "scripts/test.sh"
|
||||||
|
|
||||||
[[component]]
|
[[component]]
|
||||||
id = "std-text"
|
id = "std-text"
|
||||||
path = "stdlib/text"
|
path = "stdlib/text"
|
||||||
kind = "stdlib"
|
kind = "stdlib"
|
||||||
state = "planned"
|
state = "active"
|
||||||
owner = "cflmy"
|
owner = "cflmy"
|
||||||
scope = "Unicode 文本、字节值与 UTF-8"
|
scope = "Unicode 文本、字节值与 UTF-8"
|
||||||
requires = ["cli", "std-core", "std-collections"]
|
requires = ["cli"]
|
||||||
checks_with = []
|
checks_with = []
|
||||||
release = "base"
|
release = "base"
|
||||||
|
entry = "scripts/test.sh"
|
||||||
|
|
||||||
[[component]]
|
[[component]]
|
||||||
id = "std-encoding"
|
id = "std-encoding"
|
||||||
@@ -126,45 +128,49 @@ release = "base"
|
|||||||
id = "std-data"
|
id = "std-data"
|
||||||
path = "stdlib/data"
|
path = "stdlib/data"
|
||||||
kind = "stdlib"
|
kind = "stdlib"
|
||||||
state = "planned"
|
state = "active"
|
||||||
owner = "cflmy"
|
owner = "cflmy"
|
||||||
scope = "JSON、CSV、TOML 与 GFM 数据转换"
|
scope = "JSON、CSV、TOML 与 GFM 数据转换"
|
||||||
requires = ["cli", "std-collections", "std-text", "std-encoding"]
|
requires = ["cli"]
|
||||||
checks_with = []
|
checks_with = ["std-collections"]
|
||||||
release = "base"
|
release = "base"
|
||||||
|
entry = "scripts/test.sh"
|
||||||
|
|
||||||
[[component]]
|
[[component]]
|
||||||
id = "std-io"
|
id = "std-io"
|
||||||
path = "stdlib/io"
|
path = "stdlib/io"
|
||||||
kind = "stdlib"
|
kind = "stdlib"
|
||||||
state = "planned"
|
state = "active"
|
||||||
owner = "cflmy"
|
owner = "cflmy"
|
||||||
scope = "Console、Stream、格式化和官方 print 别名"
|
scope = "Console、Stream、格式化和官方 print 别名"
|
||||||
requires = ["cli", "std-core", "std-text"]
|
requires = ["cli"]
|
||||||
checks_with = []
|
checks_with = []
|
||||||
release = "base"
|
release = "base"
|
||||||
|
entry = "scripts/test.sh"
|
||||||
|
|
||||||
[[component]]
|
[[component]]
|
||||||
id = "std-fs"
|
id = "std-fs"
|
||||||
path = "stdlib/fs"
|
path = "stdlib/fs"
|
||||||
kind = "stdlib"
|
kind = "stdlib"
|
||||||
state = "planned"
|
state = "active"
|
||||||
owner = "cflmy"
|
owner = "cflmy"
|
||||||
scope = "文件、目录与路径"
|
scope = "文件、目录与路径"
|
||||||
requires = ["cli", "std-io", "std-text"]
|
requires = ["cli"]
|
||||||
checks_with = []
|
checks_with = []
|
||||||
release = "base"
|
release = "base"
|
||||||
|
entry = "scripts/test.sh"
|
||||||
|
|
||||||
[[component]]
|
[[component]]
|
||||||
id = "std-system"
|
id = "std-system"
|
||||||
path = "stdlib/system"
|
path = "stdlib/system"
|
||||||
kind = "stdlib"
|
kind = "stdlib"
|
||||||
state = "planned"
|
state = "active"
|
||||||
owner = "cflmy"
|
owner = "cflmy"
|
||||||
scope = "时钟、UTC、环境、进程与随机"
|
scope = "时钟、UTC、环境、进程与随机"
|
||||||
requires = ["cli", "std-text", "std-io"]
|
requires = ["cli"]
|
||||||
checks_with = []
|
checks_with = []
|
||||||
release = "base"
|
release = "base"
|
||||||
|
entry = "scripts/test.sh"
|
||||||
|
|
||||||
[[component]]
|
[[component]]
|
||||||
id = "std-net"
|
id = "std-net"
|
||||||
@@ -313,12 +319,13 @@ release = "optional"
|
|||||||
id = "web"
|
id = "web"
|
||||||
path = "extensions/web"
|
path = "extensions/web"
|
||||||
kind = "domain"
|
kind = "domain"
|
||||||
state = "planned"
|
state = "active"
|
||||||
owner = "cflmy"
|
owner = "cflmy"
|
||||||
scope = "Web 原型设计领域治理:唯一设计合同、组合验收与交付协调"
|
scope = "Web 原型设计领域治理:唯一设计合同、组合验收与交付协调"
|
||||||
requires = []
|
requires = []
|
||||||
checks_with = []
|
checks_with = []
|
||||||
release = "none"
|
release = "none"
|
||||||
|
entry = "scripts/domain-acceptance.sh"
|
||||||
|
|
||||||
[[component]]
|
[[component]]
|
||||||
id = "browser"
|
id = "browser"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
- **聚合准入**:功能拆分须至少有一种独立价值(独立维护责任、显著不同依赖/安全/平台边界、独立版本与制品、可重复独立验收)。若两个仓库几乎每个 PR 都必须一起改动且接口未稳定,应先收敛合同或合并,不能无限拆分。
|
- **聚合准入**:功能拆分须至少有一种独立价值(独立维护责任、显著不同依赖/安全/平台边界、独立版本与制品、可重复独立验收)。若两个仓库几乎每个 PR 都必须一起改动且接口未稳定,应先收敛合同或合并,不能无限拆分。
|
||||||
- **工具目录**(`tools/`)暂不聚合,现有四个 Tool 保持原路径。
|
- **工具目录**(`tools/`)暂不聚合,现有四个 Tool 保持原路径。
|
||||||
|
|
||||||
**当前状态**(以 [components.toml](../components.toml) 与 [迁移台账](MIGRATION.md) 为准):根仓库有六个直属 active 组件(`cli`、`conformance`、`view`、`knowledge`、`prove`、`lint`)。九个标准库和十八个独立扩展是根层的 planned 子模块。`extensions/web` 是 planned 领域子模块,Design 和 Preview 由 Web 领域仓挂载。`marqdo-stdlib` 聚合和 `web-components` 仍在计划中。
|
**当前状态**(以 [components.toml](../components.toml) 与 [迁移台账](MIGRATION.md) 为准):根仓库有六个核心/工具 active 组件(`cli`、`conformance`、`view`、`knowledge`、`prove`、`lint`)和六个已交付源码的 active 标准库组件(`std-collections/data/fs/io/system/text`)。`std-core/encoding/net` 与十八个独立扩展仍是根层 planned 子模块。`extensions/web` 是 **active 领域**:Design/Preview 在其领域 catalog 激活并登记真实入口,`web-components` 仍 planned。`marqdo-stdlib` 聚合仍在计划中。
|
||||||
|
|
||||||
## 语言与产品层(不因仓库变多而改变)
|
## 语言与产品层(不因仓库变多而改变)
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -52,12 +52,12 @@ bash scripts/integration.sh # 生态候选:真实 CLI 制品 +
|
|||||||
- 生态候选使用**固定、可验证**的 CLI/Worker/Stdlib 候选制品;输入必须绑定 CLI gitlink SHA、目标平台、归档/二进制/Bundle digest、工具链与锁。
|
- 生态候选使用**固定、可验证**的 CLI/Worker/Stdlib 候选制品;输入必须绑定 CLI gitlink SHA、目标平台、归档/二进制/Bundle digest、工具链与锁。
|
||||||
- 标准库 Bundle 的唯一生产者是根仓库的 `scripts/build-stdlib.py`:它从根提交的精确组件 gitlink 读取各 active `kind = "stdlib"` 组件的 `modules/`,校验发布路径(只发布 `.mq.md`、拒绝 symlink/子模块/大小写与 NFC 冲突、`tests/` 不入库),生成现行 `stdlib.json`(tree digest + aliases digest),配置在 `scripts/stdlib-bundle.json`。版本变化必须显式(`--baseline-manifest` 拒绝同版本不同摘要)。组件仓继续拥有源码与测试,根不复制模块。
|
- 标准库 Bundle 的唯一生产者是根仓库的 `scripts/build-stdlib.py`:它从根提交的精确组件 gitlink 读取各 active `kind = "stdlib"` 组件的 `modules/`,校验发布路径(只发布 `.mq.md`、拒绝 symlink/子模块/大小写与 NFC 冲突、`tests/` 不入库),生成现行 `stdlib.json`(tree digest + aliases digest),配置在 `scripts/stdlib-bundle.json`。版本变化必须显式(`--baseline-manifest` 拒绝同版本不同摘要)。组件仓继续拥有源码与测试,根不复制模块。
|
||||||
- 组合验收入口是根仓库的 `scripts/acceptance-stdlib.py`:只接受显式 `--cli` 与 `--bundle`(或按根 gitlink 构建),运行各 active 组件的 `entry`、跨仓组合 fixture(别名、Table 切分、默认 Bundle smoke)和必须失败的负例;提供 `--pack-tool` 时用 CLI 自己的打包器做两次确定性打包并核对摘要。CLI 自身打包请使用 Phase A 之后的 `--stdlib-dir` 输入,不再默认读取 CLI 源码树。
|
- 组合验收入口是根仓库的 `scripts/acceptance-stdlib.py`:只接受显式 `--cli` 与 `--bundle`(或按根 gitlink 构建),运行各 active 组件的 `entry`、跨仓组合 fixture(别名、Table 切分、默认 Bundle smoke)和必须失败的负例;提供 `--pack-tool` 时用 CLI 自己的打包器做两次确定性打包并核对摘要。CLI 自身打包请使用 Phase A 之后的 `--stdlib-dir` 输入,不再默认读取 CLI 源码树。
|
||||||
- 当前候选的冻结制品适配器以正式 RC.4 为基线,临时从 View 的 `frozen-beta.sh` 获取;这属于待替换的过渡实现,CLI 版本不得由任一消费者决定。主仓库统一制品准备落地后,在此切换并记录证据。
|
- 统一制品输入已落地(ECO-02 核心):`scripts/integration.sh` 不再从 View 的冻结脚本取 CLI 制品,而是由同一根候选派生全部输入——根唯一生产者 `scripts/build-stdlib.py` 按固定 gitlink 生成 Bundle;`cli/` 固定提交构建 CLI 与 Worker;`cli/tools/release/package.py --stdlib-dir <Bundle>` 生成发行归档;随后 Conformance、View、Knowledge、Prove、Lint 与根 `acceptance-stdlib.py` 全部使用同一安装后二进制与相邻 Bundle。任何消费者都不能决定 CLI 版本,也不再有浮动或隐式制品。
|
||||||
- 组件验收只读取传入制品,不自行下载未知版本;开发目录覆盖入口(如 `MARQDO_STDLIB_DIR`)不得当作发行行为。缺失、摘要不符或平台不符必须拒绝。
|
- 组件验收只读取传入制品,不自行下载未知版本;开发目录覆盖入口(如 `MARQDO_STDLIB_DIR`)不得当作发行行为。缺失、摘要不符或平台不符必须拒绝。
|
||||||
|
|
||||||
## 影响范围与调度
|
## 影响范围与调度
|
||||||
|
|
||||||
比较已接受根提交与候选递归展开的 `(global_id, parent, remote, SHA, state)`;领域指针变化必须展开差异,不能只标记父节点。变更叶子加入集合后,取反向传递依赖闭包,再加所在祖先领域及需要协同验收的 `checks_with`(固定点去重、不作为构建先决);公共协议/权限/根集成逻辑变化触发相应全量 conformance 与消费者。删除或移动组件用新旧图并集计算受影响者。无法确定影响范围时全量而非跳过;正式发行执行所有 active 组件与完整测试。
|
根 `scripts/impact.py` 比较已接受根提交与候选递归展开的 `(global_id, parent, remote, SHA, state)`:领域指针变化展开到子组件身份,不能只标记父节点;变更叶子加入集合后,取 `requires` 新旧图并集的反向传递依赖闭包,再加所在祖先领域及 `checks_with` 固定点(协同验收不是构建先决)。领域无法展开(缺对象/检出)时结果标 UNVERIFIED 并**全量**扩大范围,不静默跳过;`--fail-on-unverified` 可把该情形变成硬失败。`integration.sh` 将报告写入候选证据(changed/affected/checks_with/fallback),正式发行仍执行所有 active 组件与完整测试。
|
||||||
|
|
||||||
## 工单路由与状态
|
## 工单路由与状态
|
||||||
|
|
||||||
@@ -76,7 +76,9 @@ bash scripts/integration.sh # 生态候选:真实 CLI 制品 +
|
|||||||
|
|
||||||
## 自动化权限
|
## 自动化权限
|
||||||
|
|
||||||
先实现人工触发与 PR/CI 门禁,不开发自动 Agent 管理平台。Webhook 只作通知(记录仓库、完整 SHA、CI URL);上级通过 API 验证存在性、审批与权限后再创建候选 PR,不得自动合入或提升权限。外部不可信 PR、未批准 gitlink 或脚本不得在拥有跨仓库写权限/发版密钥的 runner 中运行;区分只读 checkout/test token、受限 issue/PR token、受保护发布权限。日志不得输出凭证、完整 Analysis 或生产 API key。
|
先实现人工触发与 PR/CI 门禁,不开发自动 Agent 管理平台。候选通知的授权校验由根 `scripts/candidate-notify.py` 承担:只接受规范化通知(仓库、类型、head/base SHA、CI 状态与 URL),校验仓库在根图远端允许列表内、提交在本地对象库可达、组件候选的 base 必须是 accepted 根图当前固定的 SHA、CI 为允许主机上的 success 且必须是 https;按 `(repository, head SHA)` 去重,拒绝重放,accepted 基线变化时标记 `revalidate` 并要求重跑门禁;影响范围复用 `scripts/impact.py`,无法确定时全量。校验器只输出计划(`auto_promote=false`、`auto_merge=false`、仅创建候选分支需人工评审),不合并、不推送、不扩权。Webhook 只作通知(记录仓库、完整 SHA、CI URL);上级通过 API 验证存在性、审批与权限后再创建候选 PR,不得自动合入或提升权限。
|
||||||
|
|
||||||
|
经过授权的 webhook 入口由根 `scripts/webhook-adapter.py` 实现:先以仓库 webhook secret 校验 `X-Gitea-Signature`(HMAC-SHA256)原始 body,再只接受 `push`(非删除)与 `pull_request`(opened/synchronized/reopened)事件;仓库必须来自 accepted 根图的远端允许列表,base 使用 accepted 图当前固定 SHA(payload base 只作 hint),CI 聚合要求至少一个状态且全部 success、URL 为允许 CI 主机上的 https。校验通过后交给同一 `candidate-notify.py` 做可达性/去重/重放/基线重验与影响分析,输出计划(不合并、不推送、不建 PR)。通知丢失的恢复由同一脚本 `--reconcile` 承担:扫描允许列表仓库的开放 PR 与 head statuses,对未入账的成功候选执行同一验证(幂等状态文件,重复运行只报 duplicate);API transient 错误有限退避重试,401/403 立即失败,不把触发成功当作下游已处理。外部不可信 PR、未批准 gitlink 或脚本不得在拥有跨仓库写权限/发版密钥的 runner 中运行;区分只读 checkout/test token、受限 issue/PR token、受保护发布权限。日志不得输出凭证、完整 Analysis 或生产 API key。
|
||||||
|
|
||||||
## 发行与回滚
|
## 发行与回滚
|
||||||
|
|
||||||
|
|||||||
+19
-17
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
| 已有仓库 | 审计时默认分支 | 发行或证据 |
|
| 已有仓库 | 审计时默认分支 | 发行或证据 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| [marqdo-cli](https://git.cflmy.cn/cflmy/marqdo-cli) | `master` | v3.0.0-rc.4 |
|
| [marqdo-cli](https://git.cflmy.cn/cflmy/marqdo-cli) | `master` | v3.0.0-rc.5 |
|
||||||
| [marqdo-extension-conformance](https://git.cflmy.cn/cflmy/marqdo-extension-conformance) | `main` | 有独立固定 fixture |
|
| [marqdo-extension-conformance](https://git.cflmy.cn/cflmy/marqdo-extension-conformance) | `main` | 有独立固定 fixture |
|
||||||
| [marqdo-knowledge](https://git.cflmy.cn/cflmy/marqdo-knowledge) | `master` | v0.1.0-beta.3 |
|
| [marqdo-knowledge](https://git.cflmy.cn/cflmy/marqdo-knowledge) | `master` | v0.1.0-beta.3 |
|
||||||
| [marqdo-lint](https://git.cflmy.cn/cflmy/marqdo-lint) | `main` | v0.2.0 |
|
| [marqdo-lint](https://git.cflmy.cn/cflmy/marqdo-lint) | `main` | v0.2.0 |
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
| [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) | `main` | Web Design 组件,planned;初始开发文档 |
|
| [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) | `main` | Web Design 组件,planned;初始开发文档 |
|
||||||
| [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview) | `main` | Web Preview 组件,planned;初始开发文档 |
|
| [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview) | `main` | Web Preview 组件,planned;初始开发文档 |
|
||||||
|
|
||||||
CLI gitlink 采用 RC.4 正式发布源码,以匹配冻结归档和现有 View/Lint 契约。
|
CLI gitlink 采用 RC.5 正式发布源码(`c44b0f9`,tag `v3.0.0-rc.5`),以匹配冻结归档和现有 View/Lint 契约。
|
||||||
其文档后续提交曾用于 Knowledge 的独立 CI;生态候选以自身测试判定实际组合。
|
其文档后续提交曾用于 Knowledge 的独立 CI;生态候选以自身测试判定实际组合。
|
||||||
Conformance 使用 CLI 已固定的真实 fixture 提交。
|
Conformance 使用 CLI 已固定的真实 fixture 提交。
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ Conformance 使用 CLI 已固定的真实 fixture 提交。
|
|||||||
|
|
||||||
**扩展(planned,独立组件)** · [math](https://git.cflmy.cn/cflmy/marqdo-ext-math) · [linalg](https://git.cflmy.cn/cflmy/marqdo-ext-linalg) · [quantum](https://git.cflmy.cn/cflmy/marqdo-ext-quantum) · [http](https://git.cflmy.cn/cflmy/marqdo-ext-http) · [websocket](https://git.cflmy.cn/cflmy/marqdo-ext-websocket) · [ai](https://git.cflmy.cn/cflmy/marqdo-ext-ai) · [mcp](https://git.cflmy.cn/cflmy/marqdo-ext-mcp) · [crypto](https://git.cflmy.cn/cflmy/marqdo-ext-crypto) · [database](https://git.cflmy.cn/cflmy/marqdo-ext-database) · [storage](https://git.cflmy.cn/cflmy/marqdo-ext-storage) · [cache](https://git.cflmy.cn/cflmy/marqdo-ext-cache) · [security](https://git.cflmy.cn/cflmy/marqdo-ext-security) · [browser](https://git.cflmy.cn/cflmy/marqdo-ext-browser) · [document](https://git.cflmy.cn/cflmy/marqdo-ext-document) · [archive](https://git.cflmy.cn/cflmy/marqdo-ext-archive) · [engineering](https://git.cflmy.cn/cflmy/marqdo-ext-engineering) · [regex](https://git.cflmy.cn/cflmy/marqdo-ext-regex) · [datetime](https://git.cflmy.cn/cflmy/marqdo-ext-datetime)
|
**扩展(planned,独立组件)** · [math](https://git.cflmy.cn/cflmy/marqdo-ext-math) · [linalg](https://git.cflmy.cn/cflmy/marqdo-ext-linalg) · [quantum](https://git.cflmy.cn/cflmy/marqdo-ext-quantum) · [http](https://git.cflmy.cn/cflmy/marqdo-ext-http) · [websocket](https://git.cflmy.cn/cflmy/marqdo-ext-websocket) · [ai](https://git.cflmy.cn/cflmy/marqdo-ext-ai) · [mcp](https://git.cflmy.cn/cflmy/marqdo-ext-mcp) · [crypto](https://git.cflmy.cn/cflmy/marqdo-ext-crypto) · [database](https://git.cflmy.cn/cflmy/marqdo-ext-database) · [storage](https://git.cflmy.cn/cflmy/marqdo-ext-storage) · [cache](https://git.cflmy.cn/cflmy/marqdo-ext-cache) · [security](https://git.cflmy.cn/cflmy/marqdo-ext-security) · [browser](https://git.cflmy.cn/cflmy/marqdo-ext-browser) · [document](https://git.cflmy.cn/cflmy/marqdo-ext-document) · [archive](https://git.cflmy.cn/cflmy/marqdo-ext-archive) · [engineering](https://git.cflmy.cn/cflmy/marqdo-ext-engineering) · [regex](https://git.cflmy.cn/cflmy/marqdo-ext-regex) · [datetime](https://git.cflmy.cn/cflmy/marqdo-ext-datetime)
|
||||||
|
|
||||||
**Web 领域(planned domain)** · 聚合 [marqdo-ext-web](https://git.cflmy.cn/cflmy/marqdo-ext-web)(唯一合同 `docs/WEB-DESIGN.md`)· 子组件 [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) · [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview)
|
**Web 领域(active domain,WEB-05 起)** · 聚合 [marqdo-ext-web](https://git.cflmy.cn/cflmy/marqdo-ext-web)(唯一合同 `docs/WEB-DESIGN.md`)· 子组件 [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) · [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview)
|
||||||
|
|
||||||
## 分层治理与领域聚合(2026-11-26 起)
|
## 分层治理与领域聚合(2026-11-26 起)
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ Conformance 使用 CLI 已固定的真实 fixture 提交。
|
|||||||
- 领域激活门禁:子组件具备真实入口与候选提交、领域 catalog 与 gitlink 一致、领域 CI 通过、根 `check-layout.py --checkouts` 递归校验通过、存在依赖关系的组件以同候选证据验证。
|
- 领域激活门禁:子组件具备真实入口与候选提交、领域 catalog 与 gitlink 一致、领域 CI 通过、根 `check-layout.py --checkouts` 递归校验通过、存在依赖关系的组件以同候选证据验证。
|
||||||
- 主仓库 `scripts/check-layout.py` 已引入 domain 角色与递归校验;统一 CLI 制品准备、声明驱动调度、递归影响分析仍在推进,CI 证据以真实候选为准。
|
- 主仓库 `scripts/check-layout.py` 已引入 domain 角色与递归校验;统一 CLI 制品准备、声明驱动调度、递归影响分析仍在推进,CI 证据以真实候选为准。
|
||||||
|
|
||||||
当前状态:**没有任何 active 领域**。Web 领域为 planned(`extensions/web`,聚合仓 marqdo-ext-web,子组件 design/preview 在其 catalog 登记);标准库聚合 marqdo-stdlib 尚未创建,九个 `std-*` 保持根 catalog 的 planned 直属记录;HTTP/WebSocket 等仍为独立 planned 扩展,等至少两个真实组件形成共同边界后再评估聚合。首批 Web 实施工单为 WEB-00(合同与真实 Analysis 风险探测)、WEB-01(Design)、WEB-02(Preview)、WEB-03(handoff/组件图)、WEB-04(组合案例与框架交付)、WEB-05(根接入与冷安装),WEB-06(components)为候选;工单在对应责任仓库创建。Web 合同语义冲突由 marqdo-ext-web 协调,不回流 CLI 核心。
|
当前状态:**有一个 active 领域**——Web(`extensions/web`,聚合仓 marqdo-ext-web,子组件 design/preview 已在其 catalog 激活并登记真实入口,web-components 仍 planned);标准库聚合 marqdo-stdlib 尚未创建,九个 `std-*` 保持根 catalog 的 planned 直属记录;HTTP/WebSocket 等仍为独立 planned 扩展,等至少两个真实组件形成共同边界后再评估聚合。首批 Web 实施工单为 WEB-00(合同与真实 Analysis 风险探测)、WEB-01(Design)、WEB-02(Preview)、WEB-03(handoff/组件图)、WEB-04(组合案例与框架交付)、WEB-05(根接入与冷安装),WEB-06(components)为候选;工单在对应责任仓库创建。Web 合同语义冲突由 marqdo-ext-web 协调,不回流 CLI 核心。
|
||||||
|
|
||||||
## 阶段与阻塞
|
## 阶段与阻塞
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@ Conformance 使用 CLI 已固定的真实 fixture 提交。
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| M0 盘点 | 自建 Git、历史标签、已有六组件和新仓位 | 通过真实远端候选持续维护台账 |
|
| M0 盘点 | 自建 Git、历史标签、已有六组件和新仓位 | 通过真实远端候选持续维护台账 |
|
||||||
| M1 集成骨架 | 六个 active gitlink,另固定 28 个直属和 2 个 Web 子级的 planned 开发提交 | 查看候选 Woodpecker 运行及各组件独立 CI |
|
| M1 集成骨架 | 六个 active gitlink,另固定 28 个直属和 2 个 Web 子级的 planned 开发提交 | 查看候选 Woodpecker 运行及各组件独立 CI |
|
||||||
| M2 标准库切换 | planned,CLI RC.4 提供官方完整 Bundle | [CLI 外部 Bundle](https://git.cflmy.cn/cflmy/marqdo-cli/issues/11) 和 [九组件切换](https://git.cflmy.cn/cflmy/marqdo/issues/2),包括 HTTP、Regex、Archive 迁出与同步删除旧路径 |
|
| M2 标准库切换 | **已切换基础发行**:CLI/Worker/Stdlib rc.5 归档 + 单一外部 Bundle;HTTP/Regex/Archive 已验证 | [CLI 外部 Bundle](https://git.cflmy.cn/cflmy/marqdo-cli/issues/11) 与 [九组件切换](https://git.cflmy.cn/cflmy/marqdo/issues/2) 完成;strict/perf 门禁限制见 rc.5 release notes |
|
||||||
| M3 跨仓闭环 | 工单、人工候选、同 SHA 门禁 | [跨仓库 CI](https://git.cflmy.cn/cflmy/marqdo/issues/3) 跟踪真实缺陷闭环、候选通知鉴权、去重和影响分析 |
|
| M3 跨仓闭环 | 工单、人工候选、同 SHA 门禁 | [跨仓库 CI](https://git.cflmy.cn/cflmy/marqdo/issues/3) 跟踪真实缺陷闭环、候选通知鉴权、去重和影响分析 |
|
||||||
| M4 领域接入 | Web 领域 planned:三仓文档与工单就绪;根 catalog 登记 planned domain | W-M0 真实 CLI 风险探测、WEB-01/02 实现、领域 gitlink、根递归校验与冷安装验收;Stdlib 聚合按 STD-01..04 独立推进 |
|
| M4 领域接入 | Web 领域 active:WEB-00..04 完成,领域 catalog/gitlink 固定 Design/Preview;根 catalog 激活与 gitlink 一次切换 | 根 `check-layout --checkouts`、领域组件入口、`web` Tool 冷安装与既有消费者同候选证据;Stdlib 聚合按 STD-01..04 独立推进 |
|
||||||
| 后续领域 | 空仓和预期职责 | 逐组件开展最小真实功能、独立 CI、制品与接入 |
|
| 后续领域 | 空仓和预期职责 | 逐组件开展最小真实功能、独立 CI、制品与接入 |
|
||||||
|
|
||||||
### 标准库切换顺序
|
### 标准库切换顺序
|
||||||
@@ -63,7 +63,7 @@ Conformance 使用 CLI 已固定的真实 fixture 提交。
|
|||||||
1. CLI 打包器与产品测试接受单一显式外部 Bundle 输入。内核独立编译;制品仍附带一个校验过的标准库。
|
1. CLI 打包器与产品测试接受单一显式外部 Bundle 输入。内核独立编译;制品仍附带一个校验过的标准库。
|
||||||
2. 标准库在各组件维护唯一生产源码和自测。组装拒绝冲突、符号链接或测试污染,调用 CLI 权威打包器。std-io 维护 print/打印 的别名元数据。
|
2. 标准库在各组件维护唯一生产源码和自测。组装拒绝冲突、符号链接或测试污染,调用 CLI 权威打包器。std-io 维护 print/打印 的别名元数据。
|
||||||
3. HTTP、Regex、Archive 的真实替代和授权回归先行。候选同时移除 CLI 中旧领域宿主服务和旧导入。
|
3. HTTP、Regex、Archive 的真实替代和授权回归先行。候选同时移除 CLI 中旧领域宿主服务和旧导入。
|
||||||
4. 验证同输入两次组装结果、摘要及路径负例、C1/C2/C3、独立冷安装和真实工具集成后,再切换基础发行。当前状态为 UNVERIFIED。
|
4. 验证同输入两次组装结果、摘要及路径负例、C1/C2/C3、独立冷安装和真实工具集成后,再切换基础发行。**2026-11-27 已切换:rc.5 归档(sha256 `fd7a313e...`)发布,CLI gitlink 固定 `c44b0f9`;strict L1 与获批节点 G4 仍为 UNVERIFIED 限制,见根证据 `docs/evidence/2026-11-27-base-release-rc5-switch.md`。**
|
||||||
|
|
||||||
## 标准库源码归位迁移(marqdo#9,2026-11-26 M0 冻结)
|
## 标准库源码归位迁移(marqdo#9,2026-11-26 M0 冻结)
|
||||||
|
|
||||||
@@ -101,9 +101,9 @@ Conformance 使用 CLI 已固定的真实 fixture 提交。
|
|||||||
| `path.mq.md` | [std-fs#1](https://git.cflmy.cn/cflmy/marqdo-std-fs/issues/1) | `path.mq.md` | 8 |
|
| `path.mq.md` | [std-fs#1](https://git.cflmy.cn/cflmy/marqdo-std-fs/issues/1) | `path.mq.md` | 8 |
|
||||||
| `text.mq.md` | [std-text#1](https://git.cflmy.cn/cflmy/marqdo-std-text/issues/1) | `text.mq.md`(`utf8编码` 薄封装) | 1 |
|
| `text.mq.md` | [std-text#1](https://git.cflmy.cn/cflmy/marqdo-std-text/issues/1) | `text.mq.md`(`utf8编码` 薄封装) | 1 |
|
||||||
| `text/utf8.mq.md` | [std-text#1](https://git.cflmy.cn/cflmy/marqdo-std-text/issues/1) | `text/utf8.mq.md`(唯一编解码实现) | 10 |
|
| `text/utf8.mq.md` | [std-text#1](https://git.cflmy.cn/cflmy/marqdo-std-text/issues/1) | `text/utf8.mq.md`(唯一编解码实现) | 10 |
|
||||||
| `net/http.mq.md` | [ext-http#1](https://git.cflmy.cn/cflmy/marqdo-ext-http/issues/1) | 显式 Package 模块,**不进入默认 Bundle**,不再是 `std:` | 11 |
|
| `net/http.mq.md` | [ext-http#1](https://git.cflmy.cn/cflmy/marqdo-ext-http/issues/1) | 显式 Package 入口 `index.mq.md`,**不进入默认 Bundle**,不再是 `std:` | 11 |
|
||||||
| `regex.mq.md` | [ext-regex#1](https://git.cflmy.cn/cflmy/marqdo-ext-regex/issues/1) | 显式 Package 模块,**不进入默认 Bundle**,不再是 `std:` | 22 |
|
| `regex.mq.md` | [ext-regex#1](https://git.cflmy.cn/cflmy/marqdo-ext-regex/issues/1) | 显式 Package 入口 `index.mq.md`,**不进入默认 Bundle**,不再是 `std:` | 22 |
|
||||||
| `compress.mq.md` | [ext-archive#1](https://git.cflmy.cn/cflmy/marqdo-ext-archive/issues/1) | 显式 Package 模块,**不进入默认 Bundle**,不再是 `std:` | 2 |
|
| `compress.mq.md` | [ext-archive#1](https://git.cflmy.cn/cflmy/marqdo-ext-archive/issues/1) | 显式 Package 入口 `index.mq.md`,**不进入默认 Bundle**,不再是 `std:` | 2 |
|
||||||
| `demo.mq.md` | 不设接收仓;根 Bundle 组合 fixture | 不作为公开安装模块 | 2 |
|
| `demo.mq.md` | 不设接收仓;根 Bundle 组合 fixture | 不作为公开安装模块 | 2 |
|
||||||
|
|
||||||
`std-core`、`std-encoding`、`std-net` 没有与之对应的旧模块:本轮不发空工单、不激活、不要求补齐未来规划;若已实现模块被本期 Bundle 实际依赖,再按真实依赖补充工单。
|
`std-core`、`std-encoding`、`std-net` 没有与之对应的旧模块:本轮不发空工单、不激活、不要求补齐未来规划;若已实现模块被本期 Bundle 实际依赖,再按真实依赖补充工单。
|
||||||
@@ -132,7 +132,7 @@ Conformance 使用 CLI 已固定的真实 fixture 提交。
|
|||||||
3. **Table 切分**:值操作以 `std:collections/table` 为唯一权威,GFM 序列化以 `std:data/table` 为唯一权威;不保留旧 `std:data/table` 的值操作兼容转发,已知消费者在同一候选内更新。
|
3. **Table 切分**:值操作以 `std:collections/table` 为唯一权威,GFM 序列化以 `std:data/table` 为唯一权威;不保留旧 `std:data/table` 的值操作兼容转发,已知消费者在同一候选内更新。
|
||||||
4. **Text 去重**:UTF-8 编解码唯一实现在 `text/utf8.mq.md`,`text.mq.md#utf8编码` 为保留公开名称的薄封装。
|
4. **Text 去重**:UTF-8 编解码唯一实现在 `text/utf8.mq.md`,`text.mq.md#utf8编码` 为保留公开名称的薄封装。
|
||||||
5. **IO 别名**:`io.mq.md` 保持官方 `print`/`打印` 的别名目标 `写值`,签名与 effects 不变;别名元数据仍由 Bundle 生产者生成。
|
5. **IO 别名**:`io.mq.md` 保持官方 `print`/`打印` 的别名目标 `写值`,签名与 effects 不变;别名元数据仍由 Bundle 生产者生成。
|
||||||
6. **三个领域模块**:HTTP/Regex/Archive 迁入既有扩展仓并退出默认 Bundle,不保留隐藏的 `std:` fallback;CLI 现有 `regex.*`/`compress.*` 宿主请求是历史例外,本轮不删除也不新增同类请求,彻底消除另开工单。
|
6. **三个领域模块**:HTTP/Regex/Archive 迁入既有扩展仓,按现行 Package 布局以 `index.mq.md` 为唯一公开入口(消费者经 `@alias` 显式依赖),退出默认 Bundle,不保留隐藏的 `std:` fallback;HTTP 的 bundle 内相对 import 改为公开 `std:text/utf8`。CLI 现有 `regex.*`/`compress.*` 宿主请求是历史例外,本轮不删除也不新增同类请求,彻底消除另开工单。
|
||||||
7. **`demo.mq.md`**:不作为公开库模块,转为根 Bundle 组合 fixture,避免为了放置文件创建无独立责任的新仓库。
|
7. **`demo.mq.md`**:不作为公开库模块,转为根 Bundle 组合 fixture,避免为了放置文件创建无独立责任的新仓库。
|
||||||
8. **staging 不是发行**:迁移期为了隔离测试,允许用基线 Bundle 覆盖组件模块并重算 digest 的 staging 组合;它不是官方发布源,最终只有根唯一生产路径。
|
8. **staging 不是发行**:迁移期为了隔离测试,允许用基线 Bundle 覆盖组件模块并重算 digest 的 staging 组合;它不是官方发布源,最终只有根唯一生产路径。
|
||||||
9. **CLI 侧最小修改**:Phase A 显式制品输入已落地;Phase B 删除仓内官方源树只在组件替代与根组合验收通过后执行,不同时进行核心重构。
|
9. **CLI 侧最小修改**:Phase A 显式制品输入已落地;Phase B 删除仓内官方源树只在组件替代与根组合验收通过后执行,不同时进行核心重构。
|
||||||
@@ -143,12 +143,14 @@ Conformance 使用 CLI 已固定的真实 fixture 提交。
|
|||||||
| 项 | 状态 | 证据 |
|
| 项 | 状态 | 证据 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| M0 盘点与派单 | 完成 | 本节、9 个接收仓 issue #1、[marqdo#9](https://git.cflmy.cn/cflmy/marqdo/issues/9) 评论 |
|
| M0 盘点与派单 | 完成 | 本节、9 个接收仓 issue #1、[marqdo#9](https://git.cflmy.cn/cflmy/marqdo/issues/9) 评论 |
|
||||||
| 组件接收(源码+断言) | 候选已推送(6 个 std 仓) | [std-text PR #2](https://git.cflmy.cn/cflmy/marqdo-std-text/pulls/2)、[std-system PR #2](https://git.cflmy.cn/cflmy/marqdo-std-system/pulls/2)、[std-io PR #2](https://git.cflmy.cn/cflmy/marqdo-std-io/pulls/2)、[std-fs PR #2](https://git.cflmy.cn/cflmy/marqdo-std-fs/pulls/2)、[std-data PR #2](https://git.cflmy.cn/cflmy/marqdo-std-data/pulls/2)、[std-collections PR #2](https://git.cflmy.cn/cflmy/marqdo-std-collections/pulls/2) |
|
| 组件接收(源码+断言) | 候选已推送(6 个 std 仓,同候选配对) | [std-text PR #2](https://git.cflmy.cn/cflmy/marqdo-std-text/pulls/2)、[std-system PR #2](https://git.cflmy.cn/cflmy/marqdo-std-system/pulls/2)、[std-io PR #2](https://git.cflmy.cn/cflmy/marqdo-std-io/pulls/2)、[std-fs PR #2](https://git.cflmy.cn/cflmy/marqdo-std-fs/pulls/2)、[std-data PR #2](https://git.cflmy.cn/cflmy/marqdo-std-data/pulls/2)、[std-collections PR #2](https://git.cflmy.cn/cflmy/marqdo-std-collections/pulls/2) |
|
||||||
| 领域模块(http/regex/archive) | 未开始 | ext-http/ext-regex/ext-archive issue #1 |
|
| 领域模块(http/regex/archive) | 候选已合并为显式 Package | [ext-http PR #2](https://git.cflmy.cn/cflmy/marqdo-ext-http/pulls/2)、[ext-regex PR #2](https://git.cflmy.cn/cflmy/marqdo-ext-regex/pulls/2)、[ext-archive PR #2](https://git.cflmy.cn/cflmy/marqdo-ext-archive/pulls/2) |
|
||||||
| Bundle 唯一生产者 | 脚本与契约测试已落地,待根候选验收 | `scripts/build-stdlib.py`、`scripts/stdlib-bundle.json`、`tests/integration/test_build_stdlib.py` |
|
| Bundle 唯一生产者 | 已实现,M2 候选真实构建两次逐字节一致 | `scripts/build-stdlib.py`、`scripts/stdlib-bundle.json`、`tests/integration/test_build_stdlib.py` |
|
||||||
| 组合验收入口 | 已落地,待根候选执行 | `scripts/acceptance-stdlib.py`、`tests/integration/composition/` |
|
| 组合验收入口 | M2 候选 PASS(组件 entry + 跨仓组合 + 负例 + 相邻离线安装 + CLI 确定性打包) | `scripts/acceptance-stdlib.py`、[M2 候选证据](evidence/2026-11-26-stdlib-m2-candidate.md)、[根 PR #11](https://git.cflmy.cn/cflmy/marqdo/pulls/11) |
|
||||||
| CLI 旧源树删除 | 未开始(等待根组合验收) | [marqdo-cli#11](https://git.cflmy.cn/cflmy/marqdo-cli/issues/11) Phase B |
|
| CLI 旧源树删除 | 候选完成:CLI 仓已无 `stdlib/` 源树、无编译期 fallback,pin 指向生态 Bundle | [marqdo-cli#11](https://git.cflmy.cn/cflmy/marqdo-cli/issues/11)、[CLI PR #17](https://git.cflmy.cn/cflmy/marqdo-cli/pulls/17)、[Phase B 证据](https://git.cflmy.cn/cflmy/marqdo-cli/src/branch/migration/cli-stdlib-phase-b/docs/evidence/2026-11-27-issue-11-phase-b.md) |
|
||||||
| 根组合与切换 | 未开始 | 本仓 MIG-RELEASE 候选 |
|
| 统一 CLI/Worker/Bundle 制品输入(ECO-02 核心) | 已落地:integration.sh 由同一根候选派生全部输入,不再使用 View 冻结制品 | 根 `scripts/integration.sh`、[marqdo#7](https://git.cflmy.cn/cflmy/marqdo/issues/7) |
|
||||||
|
| 根组合与切换 | **已晋升**:`main` = `f4e292e`,固定 CLI Phase B `deadf6e` 与六个 std/三个 ext 组件;根生态 CI(pipeline 38)PASS | [M3 证据](evidence/2026-11-27-stdlib-m3-candidate.md)、[根 PR #12](https://git.cflmy.cn/cflmy/marqdo/pulls/12) |
|
||||||
|
| M4 发行级验收 | 离线冷安装 PASS(`ubuntu:24.04 --network none`,归档 `sha256:377d2787...`);多平台不在本线支持矩阵 | [M3 证据的晋升章节](evidence/2026-11-27-stdlib-m3-candidate.md#晋升与-m4-验收) |
|
||||||
|
|
||||||
## v2 功能历史索引
|
## v2 功能历史索引
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
# 仓库开发规范(生态级)
|
||||||
|
|
||||||
|
本文件把 [marqdo#10](https://git.cflmy.cn/cflmy/marqdo/issues/10) 与既有架构/开发/迁移文档中的仓库组织要求整理为**可执行的仓库规范**,供主仓库、领域聚合仓和功能仓共同遵守。它不新建第二套权威:仓库身份仍以 `components.toml` + Git tree/gitlink + `.gitmodules` 为准,合同仍以各仓现行规范为准,流程细节以 [DEVELOPMENT.md](DEVELOPMENT.md)、[ARCHITECTURE.md](ARCHITECTURE.md)、[REPOSITORY-TASKS.md](REPOSITORY-TASKS.md)、[MIGRATION.md](MIGRATION.md) 为准。
|
||||||
|
|
||||||
|
## 1. 目的:防膨胀,而不是少文件
|
||||||
|
|
||||||
|
建立子仓库的唯一理由是形成**明确职责、独立开发闭环和可追溯协作**;不是为了减少单仓文件数量。任何新增仓库、目录层级、合同、清单、构建入口或发布线都必须证明:
|
||||||
|
|
||||||
|
1. 存在唯一责任所有者,且没有现成仓库能承担;
|
||||||
|
2. 有独立构建/测试/交付或独立合同边界,而不是"按功能/按文件"拆分;
|
||||||
|
3. 至少一个真实消费者或明确的默认发行需求(新增标准库还须满足 ARCHITECTURE 的准入门槛);
|
||||||
|
4. 有可验证的激活路径(entry、测试、证据、CI),不产生空壳仓库;
|
||||||
|
5. 不引入第二套 parser、manifest、catalog、lock、版本表、制品服务或发布流程。
|
||||||
|
|
||||||
|
**治理树最多两级 gitlink**:根 → 领域聚合(可选)→ 功能组件。禁止第三级;禁止用目录复制模拟仓库;禁止为单个功能、页面、算法、表格或实验创建仓库。
|
||||||
|
|
||||||
|
## 2. 仓库准入与状态
|
||||||
|
|
||||||
|
- 新仓库必须先在根仓库开 Issue/ADR,记录责任、消费者、退出条件,并在 `components.toml` 登记 `planned`;不得先建空仓再补理由。
|
||||||
|
- `planned` 仓库允许挂载真实开发提交,但**不计完成率**、不登记 `entry`、不要求发布制品;只能有 README/必要源码/最小测试,不得批量复制模板、CI 徽章、占位实现或假入口。
|
||||||
|
- 从 `planned` 激活必须同时具备:真实实现、README(职责/构建/依赖/平台)、`AGENTS.md`(本仓边界与路由)、可执行 CI 入口、真实正反例、交付/发布方式、候选证据;并在父级 catalog 登记 `entry`。
|
||||||
|
- 只有规范/fixture 的仓库允许源码归档交付,不强制二进制;但必须有确定性归档与证据。
|
||||||
|
- `active` 仓库不得回退为"文档占位";若失去责任,必须记录替代仓库与迁移/归档计划。
|
||||||
|
|
||||||
|
## 3. 角色与禁止事项
|
||||||
|
|
||||||
|
| 所有者 | 应做 | 禁止 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 功能仓库(core/stdlib/extension/tool/test) | 自身实现、测试、制品、发布、消费上游候选、修复本仓缺陷 | 实现其它仓库功能;依赖父仓或兄弟仓 checkout;复制其它仓实现/parser/合同;偷偷替换上游逻辑 |
|
||||||
|
| 领域聚合仓(`kind=domain`) | 领域合同、组合、领域候选 gitlink、领域验收、通知父仓 | 重复叶子实现;第二套调用协议;登记后代到根 catalog |
|
||||||
|
| 根仓库 | 展开依赖、传播协调、全局候选、递归集成、正式发行、滞后报告 | 实现子组件业务;批量直接改子仓代码;成为每个仓的构建前置 |
|
||||||
|
| CLI | 语言/通用能力、公开协议、CLI/Worker/基础产品打包 | 生态调度代码;反向依赖 stdlib 源码;物理拆仓 |
|
||||||
|
| Conformance | 独立公共契约运行验收 | 取代组件自测;伪造未支持平台的 PASS |
|
||||||
|
|
||||||
|
## 4. 每个 active 仓库的最低文件集
|
||||||
|
|
||||||
|
```text
|
||||||
|
<repo>/
|
||||||
|
├── README.md # 职责、构建、测试、依赖、支持平台、状态
|
||||||
|
├── AGENTS.md # 本仓边界、禁止项、输入/输出、工单路由(含规范标记)
|
||||||
|
├── scripts/ci.sh # 非交互构建+检查+真实功能测试;失败非零;不打印秘密
|
||||||
|
├── scripts/package.sh # 有制品时:生成候选并验证冷使用
|
||||||
|
├── scripts/upstream.sh # 有外部依赖时:消费候选/生成最小依赖更新
|
||||||
|
├── tests/ 或 fixtures/ # 真实正反例
|
||||||
|
├── .woodpecker/ # 独立远程 CI;发布门禁与普通 CI 分离
|
||||||
|
└── docs/ 或 spec/ # 公开接口/合同/证据
|
||||||
|
```
|
||||||
|
|
||||||
|
允许复用现有脚本名(如 `scripts/test.sh`、`scripts/acceptance.sh`、`scripts/package-tool.sh`),但 `entry` 必须真实存在、可本地执行、非交互、默认无网络写副作用。构建产物、缓存、日志只写声明输出(如 `MARQDO_CI_OUT`),不得污染源码树;不得提交 `target/`、`dist/`、浏览器产物、凭证或本地绝对路径。
|
||||||
|
|
||||||
|
## 5. `AGENTS.md` 规范
|
||||||
|
|
||||||
|
每个 active 仓库必须有 `AGENTS.md`,以 `<!-- marqdo:repo-conventions v1 -->` 开头,并至少包含:
|
||||||
|
|
||||||
|
1. 本仓定位、catalog ID、父级、唯一权威合同/输入;
|
||||||
|
2. 必做/禁止边界(不复制、不越界、不建第二目录/清单/合同/发布线);
|
||||||
|
3. 构建/测试入口、实际依赖输入、证据要求(SHA、摘要、平台、命令、退出码、日志;未运行 = UNVERIFIED);
|
||||||
|
4. 工单路由(上游合同缺陷去哪、跨仓组合如何晋升);
|
||||||
|
5. 指向根规范:`https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/REPOSITORY-CONVENTIONS.md`。
|
||||||
|
|
||||||
|
模板见 [templates/AGENTS.component.md](templates/AGENTS.component.md)。`AGENTS.md` 只写本仓边界,不复制全局规范正文;合同正文仍只在唯一权威仓维护。
|
||||||
|
|
||||||
|
## 6. 独立 CI/CD 与证据
|
||||||
|
|
||||||
|
- 每个 active 功能仓必须能在**全新临时目录独立 clone**、无父仓、无兄弟源码、无隐式 PATH/缓存的情况下完成声明的构建与测试;可从权威远端下载固定 SHA/摘要的依赖,冷安装阶段禁网。
|
||||||
|
- 依赖 CLI 的组件用绝对 `MARQDO_BIN` 并验证相应 `SOURCE_SHA`/制品;需要外部 Bundle 时用显式 `MARQDO_STDLIB_DIR`,不得用它替代最终发行默认 Bundle 检查。
|
||||||
|
- 工具链、镜像、锁文件、target、CI 脚本变化必须进入缓存 key;cache hit 不是 PASS;测试脚本与持有发布密钥的脚本分离。
|
||||||
|
- 普通 push/PR 只做检查与回归;发布仅消费**准确同 SHA** 的受保护 tag/批准工作流;不得用历史 PASS、浮动分支或 tag 名代替。
|
||||||
|
- 正式发布必须记录:tag→完整 source SHA、真实 CI 证据、资产 basename/size/sha256、实际依赖身份、平台。发布后通知失败只重试通知,不重复发布或覆盖已公开资产。
|
||||||
|
|
||||||
|
## 7. 四种事实与晋升
|
||||||
|
|
||||||
|
必须分别记录,禁止推导:
|
||||||
|
|
||||||
|
1. 组件提交已通过本仓 CI;
|
||||||
|
2. 组件 release 资产已完整发布;
|
||||||
|
3. 消费者已对特定候选组合验证/接入;
|
||||||
|
4. 领域或根主分支/正式发行已接受该组合。
|
||||||
|
|
||||||
|
晋升顺序:组件提交 C2(组件 PR + 组件 CI)→ 领域提交 B2(领域 PR 更新子 gitlink + 领域验收)→ 根提交 A2(根 PR 更新领域 gitlink + 递归布局/受影响组合/冷安装)。先推送子仓提交,再更新父级 gitlink;父级 PR 只改计划中的 gitlink/catalog/证据,不夹带子仓源码。禁止自动合并、自动提升或把通知成功当作下游已处理。
|
||||||
|
|
||||||
|
## 8. 单一事实源
|
||||||
|
|
||||||
|
| 信息 | 唯一来源 |
|
||||||
|
| --- | --- |
|
||||||
|
| 源码组合 | 根 Git tree 的 gitlink(递归)+ `.gitmodules` 权威远端 |
|
||||||
|
| 仓库职责/依赖/影响 | 各级 `components.toml` 的 `kind/state/entry/requires/checks_with` |
|
||||||
|
| 组件真实依赖 | 各仓 Cargo.lock/Cargo.toml、`marqdo.yaml`/`marqdo.lock`、现行 Tool/Bundle manifest |
|
||||||
|
| 发布身份与资产 | 权威 Gitea Release/tag、发布证据与 SHA-256 |
|
||||||
|
| CI 结果 | Woodpecker 真实 pipeline/日志/同 SHA 证据 |
|
||||||
|
| 推进/缺陷/搁置 | Gitea Issue/PR/评论 |
|
||||||
|
|
||||||
|
禁止手工维护"全生态最新版本表"、第二套 catalog、重复 contract、复制 lock/manifest、把组件 SHA 写进 catalog。报告、影响分析、候选计划、发布索引只做派生视图,且不成为新锁。
|
||||||
|
|
||||||
|
## 9. 硬禁止(防膨胀清单)
|
||||||
|
|
||||||
|
- 不因文件多、模块多、页面多、功能多而拆仓;不为单个功能/实验/平台建仓。
|
||||||
|
- 不建空壳仓、占位仓、镜像仓、docs-only 副本、重复服务或第二套包管理/制品服务/消息队列/Issue 数据库。
|
||||||
|
- 不复制 Markdown/语言/表格 parser 或其它仓实现;不并列维护第二份现行合同。
|
||||||
|
- 不在根/领域仓库实现子组件业务;不把子仓源码复制到父仓。
|
||||||
|
- 不让子仓依赖父仓 checkout、兄弟仓相对路径或 `../design` 类发布依赖。
|
||||||
|
- 不新增未在 catalog 的路径/仓库层级;不在根 catalog 登记领域后代。
|
||||||
|
- 不伪造 entry、CI 徽章、版本、gitlink、PASS 或发布资产;未运行写 UNVERIFIED。
|
||||||
|
- 不自动 tag/release/合并;不覆盖已公开 tag/资产;不使用未审查分支发布。
|
||||||
|
- 不提交密钥、凭证、完整 Analysis、生产配置或本地绝对路径。
|
||||||
|
- 不为 planned 仓库批量生成模板/脚本;激活时按最低集补齐。
|
||||||
|
|
||||||
|
## 10. 审核清单
|
||||||
|
|
||||||
|
**新仓/激活**:唯一职责?现有仓为何不能承担?谁消费?entry/测试/证据/发布方式齐全?planned 未计入完成率?根 catalog 与 `.gitmodules` 一致?
|
||||||
|
|
||||||
|
**子仓 PR**:只改本仓?未复制/越界?合同变更在唯一权威仓?依赖以固定身份验证?证据可复现?没有假 PASS/未验证声明?
|
||||||
|
|
||||||
|
**领域/根晋升**:只改计划 gitlink/catalog/证据?固定完整 SHA?递归布局通过?受影响消费者同候选通过?冷安装/回滚已记录?
|
||||||
|
|
||||||
|
**发布**:tag 指向冻结 SHA?同 SHA CI 真实成功?资产可下载且摘要一致?旧资产未被覆盖?通知与后续接入有追踪?
|
||||||
|
|
||||||
|
## 11. 工具与检查
|
||||||
|
|
||||||
|
- `python3 scripts/check-repo-conventions.py`:校验 active 仓最低文件集/AGENTS 标记/entry/catalog 一致性/无后代重复登记/叶子仓无子模块/无第二 catalog。
|
||||||
|
- `python3 scripts/check-layout.py --checkouts`:治理树、远端、路径、全局 ID、依赖 DAG 与固定 checkout。
|
||||||
|
- `python3 -m unittest discover -s tests/integration`:布局、影响分析、候选、Webhook/对账、仓库规范测试。
|
||||||
|
- 根 `.woodpecker/eco.yml` 的 layout 阶段执行上述检查;任何规则变更加测试,不删检查放行。
|
||||||
|
|
||||||
|
## 12. 例外与记录
|
||||||
|
|
||||||
|
任何偏离本规范的例外(例如临时 planned 实现、平台限制、无法运行的 strict/perf 门禁)必须在工单/ADR 中记录:原因、责任者、复查日期、退出条件;不得以"先这样"长期沉积。规范本身变更走根仓库 PR + Issue/ADR,并同步模板与检查器。
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
按仓库领取任务。标为 **大改** 的条目可涉及模块拆分、实现重写或发布切换。责任仓库应先限定本轮交付范围,涉及公共接口时与实际消费者一起验收。
|
按仓库领取任务。标为 **大改** 的条目可涉及模块拆分、实现重写或发布切换。责任仓库应先限定本轮交付范围,涉及公共接口时与实际消费者一起验收。
|
||||||
|
|
||||||
生态治理采用“根 → 领域聚合 → 功能组件”最多两级 Gitlink:功能仓库实现与修复、领域聚合仓库维护合同与组合验收、主仓库固定 gitlink、治理与发行。`planned` 组件可以挂载真实开发提交,实际入口随验收登记。当前没有 active 领域;Web 领域为 planned(聚合仓 `marqdo-ext-web`,子组件 `marqdo-web-design`/`marqdo-web-preview` 在其 catalog 登记)。先推进 CLI 外部 Bundle、九个标准库,以及 HTTP、Regex、Archive 的迁出;这些改动在同一候选组合中验证后切换基础发行。官网和 VS Code 可独立推进。[迁移台账](MIGRATION.md) · [开发流程](DEVELOPMENT.md)
|
生态治理采用“根 → 领域聚合 → 功能组件”最多两级 Gitlink:功能仓库实现与修复、领域聚合仓库维护合同与组合验收、主仓库固定 gitlink、治理与发行。`planned` 组件可以挂载真实开发提交,实际入口随验收登记。当前 Web 领域为 active(聚合仓 `marqdo-ext-web`,子组件 `marqdo-web-design`/`marqdo-web-preview` 在其 catalog 激活并登记真实入口;`web-components` 仍 planned)。先推进 CLI 外部 Bundle、九个标准库,以及 HTTP、Regex、Archive 的迁出;这些改动在同一候选组合中验证后切换基础发行。官网和 VS Code 可独立推进。[迁移台账](MIGRATION.md) · [开发流程](DEVELOPMENT.md)
|
||||||
|
|
||||||
## 集成和语言
|
## 集成和语言
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
## 标准库
|
## 标准库
|
||||||
|
|
||||||
每个仓库交付可独立测试的模块,共同组成默认 Bundle。聚合仓库 `marqdo-stdlib` 尚未创建,九个 `std-*` 当前保持根 catalog 的 planned 直属记录;CLI 内置标准库仍是现行发行权威,迁移完成前不得声称拆分完成。迁移的基线、模块/函数与断言台账、冻结发布路径见 [迁移台账](MIGRATION.md) 的“标准库源码归位迁移”一节;唯一 Bundle 生产者是根 `scripts/build-stdlib.py`,组合验收入口是 `scripts/acceptance-stdlib.py`。
|
每个仓库交付可独立测试的模块,共同组成默认 Bundle。标准库源码归位已完成并晋升:六个交付源码的 `std-*` 在根 catalog 为 active,`std-core/encoding/net` 保持 planned 且不入 Bundle;CLI 已无内置标准库源树,唯一 Bundle 由根 `scripts/build-stdlib.py` 从固定 gitlink 生成,组合验收为 `scripts/acceptance-stdlib.py`。迁移基线、模块/函数与断言台账、冻结发布路径见 [迁移台账](MIGRATION.md) 的“标准库源码归位迁移”一节。`marqdo-stdlib` 聚合仓库仍未建立;发行级冷安装已通过,后续缺陷回各责任仓。
|
||||||
|
|
||||||
| 仓库 | 要完成的任务 |
|
| 仓库 | 要完成的任务 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# 标准库源码归位 M2 候选证据(2026-11-26)
|
||||||
|
|
||||||
|
父仓工单:[cflmy/marqdo#9](https://git.cflmy.cn/cflmy/marqdo/issues/9)。本文件记录 **M2 候选组合**的真实执行结果,是候选证据,不是已发布声明。根主分支仍保持迁移前组合(`484cb10`);本候选只有在 CLI Phase A 与六个接收仓 PR 合并、且完整生态门禁通过后才可晋升。
|
||||||
|
|
||||||
|
## 候选身份
|
||||||
|
|
||||||
|
| 对象 | 身份 |
|
||||||
|
| --- | --- |
|
||||||
|
| 根候选分支 | `migration/stdlib-m2-candidate`(本文档提交前树 `8fa728b302fa29caf8268a758eb4b0e90431d780`) |
|
||||||
|
| 根主分支基线 | `484cb10d66db9b92f0527499642ae6abddb3ef29`(未改动) |
|
||||||
|
| CLI gitlink(未变) | `cflmy/marqdo-cli@452e9a32bd9e40dba427d4180691c58bab74449e`(RC.4 组合) |
|
||||||
|
| CLI Phase A 候选(仅用于打包/验证,PR #12) | `cflmy/marqdo-cli@f8b82d414328d92b31865fed05e68223f7bee917` |
|
||||||
|
| std-text | `cflmy/marqdo-std-text@c2a7d327e5d1914db8952562614707c112a07da1`(PR #2) |
|
||||||
|
| std-system | `cflmy/marqdo-std-system@053ddb0e59dc016b9c7833f115d14fa04e721d48`(PR #2) |
|
||||||
|
| std-io | `cflmy/marqdo-std-io@e18b0b1b40fcc6adcb42b5ab9fe1c9c04e9b8263`(PR #2) |
|
||||||
|
| std-fs | `cflmy/marqdo-std-fs@63bceae58736f13770c7eead02535726d08c19d0`(PR #2) |
|
||||||
|
| std-data | `cflmy/marqdo-std-data@848af7a357ceda2cfc20721b93406cf4be705889`(PR #2) |
|
||||||
|
| std-collections | `cflmy/marqdo-std-collections@490765226866ac74b7365471c202e7638187bff8`(PR #2) |
|
||||||
|
| ext-http(显式 Package) | `cflmy/marqdo-ext-http@368b33d241`(PR #2,合并后精确 SHA 以根 gitlink 为准) |
|
||||||
|
| ext-regex(显式 Package) | `cflmy/marqdo-ext-regex@6e7e633798`(PR #2) |
|
||||||
|
| ext-archive(显式 Package) | `cflmy/marqdo-ext-archive@aba6b60934`(PR #2) |
|
||||||
|
|
||||||
|
`std-core`、`std-encoding`、`std-net` 保持 `planned`,不加入 Bundle。HTTP/Regex/Archive 已迁为显式 Package(`index.mq.md` + `marqdo.yaml`,消费者经 `@alias` 导入),不进入默认 Bundle;其源码候选已合并到各自仓库 main,根候选固定对应提交并执行显式 Package 消费门禁(`kind = "explicit-package"`)。
|
||||||
|
|
||||||
|
## 唯一 Bundle 制品
|
||||||
|
|
||||||
|
`scripts/build-stdlib.py` 从上述根 gitlink 组合,两次干净构建逐字节一致:
|
||||||
|
|
||||||
|
| 字段 | 值 |
|
||||||
|
| --- | --- |
|
||||||
|
| name / version | `marqdo-stdlib` / `0.2.0`(内容变化显式升版本;摘要算法不变) |
|
||||||
|
| tree digest | `sha256:db905508dde89763b9d43b47fc5d52c6a1d5445a91f3c86a550ced43e8aac9d7` |
|
||||||
|
| aliases digest | `sha256:5f513c0fdbb3c1e9829be3c9fa23a2d1e89cb8510073fb5eb1e8e2f5265a83bb`(与迁移前一致) |
|
||||||
|
| 模块数 | 17(仅模块;`tests/`、`demo.mq.md`、`net/http`、`regex`、`compress` 均不在默认 Bundle) |
|
||||||
|
| 打包归档 | `marqdo-stdlib-0.2.0.tar.gz`,`sha256:212cca32f10ecfa0cdedfa976f7726db5e01cdb0e664a41ae26d4b34a8fd7048`(CLI Phase A `tools/pack-stdlib.py` 两次输出逐字节一致) |
|
||||||
|
|
||||||
|
## 门禁结果
|
||||||
|
|
||||||
|
| 门禁 | 命令 | 结果 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 根布局 | `python3 scripts/check-layout.py` | PASS |
|
||||||
|
| 递归布局 | `python3 scripts/check-layout.py --checkouts` | PASS(33 个固定子树;6 个 active stdlib entry 存在且工作区干净) |
|
||||||
|
| 根集成测试 | `python3 -m unittest discover -s tests/integration` | Ran 56 tests,OK(含 9 个 Bundle 生产者契约测试) |
|
||||||
|
| 组件独立验收 | `MARQDO_BIN=<RC.4 由 452e9a3 构建> MARQDO_STDLIB_DIR=<新 Bundle> scripts/test.sh`(各仓) | 6/6 PASS,共 17 个 case(collections 1、text 2、data 3、io 4、fs 2、system 5) |
|
||||||
|
| 跨仓组合 | `scripts/acceptance-stdlib.py --cli <CLI> --bundle <新 Bundle>` | PASS:官方 `print`/`打印` 别名、Table 值操作+GFM 跨模块、默认 Bundle smoke |
|
||||||
|
| Table 等价性 | 组合 fixture 终值与迁移前原 `stdlib/tests/table.mq.md` 终值 | 逐字节一致 |
|
||||||
|
| 显式 Package 消费 | `scripts/acceptance-stdlib.py` 内 http/regex/archive 各自 `scripts/test.sh`(临时消费者工程 + `marqdo lock` + `@alias` 导入) | PASS(原领域测试终值与迁移前基线一致) |
|
||||||
|
| 失败负例 | 缺显式 Bundle、篡改模块摘要 | 均按预期失败(exit 1),不静默回退 |
|
||||||
|
| 相邻安装离线运行 | 把新 Bundle 放到 CLI 二进制旁 `stdlib/`,不设 `MARQDO_STDLIB_DIR` | PASS(默认离线安装路径可用) |
|
||||||
|
| CLI 打包 | Phase A `pack-stdlib.py --stdlib-dir <新 Bundle>` ×2 + 篡改输入 | 确定性 PASS;篡改拒绝 |
|
||||||
|
|
||||||
|
CLI 身份(sha256):由 `452e9a3` 构建的 RC.4 二进制 `sha256:0377b855...`;Phase A 合并 master(`f8b82d4`)二进制 `sha256:6ede3b9e...`。两者对同一 Bundle 的组件与组合门禁结果一致。
|
||||||
|
|
||||||
|
## 未验证 / 待办
|
||||||
|
|
||||||
|
- 完整 `scripts/integration.sh` 的既有消费者门禁(Conformance/View/Knowledge/Prove/Lint)本轮**未执行**:该流程仍取冻结 RC.4 制品,本次未替换为统一制品输入(ECO-02,marqdo#7);不能把本次 PASS 当作生态发行验收。
|
||||||
|
- CLI Phase B(删除仓内官方标准库源树、pin 切换)未做,等待 CLI PR #12 合并与本候选组件 PR 合并。
|
||||||
|
- HTTP/Regex/Archive 已成为显式 Package 且组件内测试通过;本候选的根组合门禁只验证了独立 Package 行为,尚未验证真实应用项目的 `git` 依赖锁定/同步与发布分发,也尚未从默认 Bundle 删除后验证既有 `std:` 用户的迁移提示(按合同不保留 fallback)。
|
||||||
|
- 未做完整产品归档冷安装(新 Bundle + 新 CLI 发行归档)与多平台证据;Windows/macOS 未验证。
|
||||||
|
- 根主分支未改动,回退方式为放弃本候选分支,迁移前组合 `484cb10` 仍可检出。
|
||||||
|
|
||||||
|
## 复现
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git checkout migration/stdlib-m2-candidate
|
||||||
|
git submodule update --init --recursive
|
||||||
|
python3 scripts/check-layout.py --checkouts
|
||||||
|
python3 -m unittest discover -s tests/integration
|
||||||
|
python3 scripts/build-stdlib.py --out build/stdlib
|
||||||
|
python3 scripts/acceptance-stdlib.py --cli <verified-marqdo> --work build/accept
|
||||||
|
# 可选:--pack-tool <cli>/tools/pack-stdlib.py(Phase A 之后)
|
||||||
|
```
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# 基础发行切换:rc.5 发布与根 gitlink 固定(2026-11-27)
|
||||||
|
|
||||||
|
父工单:[marqdo#2](https://git.cflmy.cn/cflmy/marqdo/issues/2)。本文件记录实际发布与根组合切换。
|
||||||
|
|
||||||
|
## 发布身份
|
||||||
|
|
||||||
|
| 对象 | 身份 |
|
||||||
|
| --- | --- |
|
||||||
|
| 发布 | [marqdo-cli v3.0.0-rc.5](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.5) |
|
||||||
|
| tag / 源码 | `v3.0.0-rc.5` → CLI `c44b0f943875d563bb7c170f8ccd3fd56a82360f` |
|
||||||
|
| CLI 同 SHA CI | pull_request + push pipeline **success**(Woodpecker CLI repo) |
|
||||||
|
| 归档 | `marqdo-3.0.0-rc.5-x86_64-unknown-linux-gnu.tar.gz`,4,907,427 bytes,sha256 `fd7a313e0ddaf38a9b1901ff2a9aa7b9a0a153e65522a9c0c60f01e2549f583b` |
|
||||||
|
| 归档资产 | release assets:tar.gz + `.sha256`;下载后 sha256 与本地构建一致 |
|
||||||
|
| Bundle | `marqdo-stdlib@0.2.0`,digest `sha256:db905508...`,外部显式输入 |
|
||||||
|
| 根 CLI gitlink | `c44b0f94`(本候选切换;旧 rc.4 源码 `452e9a3` 为回滚目标) |
|
||||||
|
| 平台 | Linux x86_64 / glibc 2.39(Ubuntu 24.04 容器验证) |
|
||||||
|
|
||||||
|
## 发布门禁(同一最终归档上真实执行)
|
||||||
|
|
||||||
|
- CLI 发布 SHA 的 Woodpecker pull_request/push pipeline **success**。
|
||||||
|
- 确定性归档:同一 `SOURCE_SHA` + 同一 Bundle 连续两次 package,sha256 完全一致(`fd7a313e...`)。
|
||||||
|
- `smoke.py` PASS。
|
||||||
|
- Ubuntu 24.04 / glibc 2.39、`--network none`、非 root、无 Cargo 冷安装 PASS(缺 Bundle fail-closed;语言-only 可运行)。
|
||||||
|
- 归档 CLI + 归档 Bundle:三个迁出扩展 http/regex/archive PASS;冻结外部 conformance 七类 PASS。
|
||||||
|
- 发布资产下载校验:下载归档 sha256 = `fd7a313e...`。
|
||||||
|
- 根同候选:`check-layout --checkouts`、根集成测试与生态 candidate CI(含既有消费者)以 `cli/c44b0f9` 为输入;结果以根 PR CI 为准。
|
||||||
|
|
||||||
|
## 已记录的未验证限制(不冒充 PASS)
|
||||||
|
|
||||||
|
- Strict L1 独立 VM/非 root:本发布环境无 disposable VM/命名空间,**UNVERIFIED**;release notes 明示无 PASS。
|
||||||
|
- G4 性能:paired shared-node 比较 9/9 工作负载、最大 p50 +5.15%、最大 RSS +4.87%,低于阈值,但**不是获批节点 PASS**;release notes 记录为 shared-node WARN 限制。
|
||||||
|
- 维护者已明确批准本次 rc.5 发布并接受上述两项记录限制。
|
||||||
|
|
||||||
|
## 回滚
|
||||||
|
|
||||||
|
若不接受 rc.5,恢复根 `cli` gitlink 到 `452e9a3`(rc.4 发布源码)并重跑候选;已发布 tag/资产不可变,不回写。
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# 候选 Webhook 可信入口与漏通知对账证据(#3 / #10 GAP-05)
|
||||||
|
|
||||||
|
日期:2026-11-27。责任仓:根 `marqdo`。工单:[marqdo#3](https://git.cflmy.cn/cflmy/marqdo/issues/3)、[#10](https://git.cflmy.cn/cflmy/marqdo/issues/10)(发布传播/漏通知恢复 GAP-05/GAP-06 的仓库侧基础)。
|
||||||
|
|
||||||
|
## 实现
|
||||||
|
|
||||||
|
`scripts/webhook-adapter.py`(无长驻服务、无合并/推送权):
|
||||||
|
|
||||||
|
1. **来源认证**:`X-Gitea-Signature` HMAC-SHA256 校验原始 body;secret 仅来自环境变量,缺失/不匹配即拒绝,拒绝前不解析为可信输入。
|
||||||
|
2. **事件白名单**:`push`(拒绝删除分支)与 `pull_request`(仅 opened/synchronized/reopened);其它事件拒绝。
|
||||||
|
3. **仓库身份**:从 accepted 根图的远端允许列表解析;未知仓库拒绝;payload 的仓库名只用于匹配该表。
|
||||||
|
4. **base 语义**:组件候选 base 使用 accepted 根图当前固定 SHA(新基线需重验),payload base/branch 只作 hint;根候选 base 为 accepted revision。
|
||||||
|
5. **CI 聚合**:至少一个 status 且全部 `success` 才算成功;URL 必须是允许 CI 主机上的 https;pending/failure/空状态拒绝。
|
||||||
|
6. **复用同一验证器**:交给 `scripts/candidate-notify.py` 做可达性、去重/重放、基线 revalidate 与 `scripts/impact.py` 影响范围;输出计划 `auto_promote=false`/`auto_merge=false`。
|
||||||
|
7. **漏通知对账**:`--reconcile` 扫描允许列表仓库开放 PR 的 head statuses,对未入账的成功候选执行同一验证并写入幂等状态;重复运行报 duplicate;API transient 错误有限退避重试,401/403 立即失败,报告不写成功。
|
||||||
|
|
||||||
|
## 验证(真实临时 Git 仓库,无网络 fixture)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 -m unittest tests.integration.test_webhook_adapter
|
||||||
|
# 8 tests OK
|
||||||
|
python3 -m unittest discover -s tests/integration
|
||||||
|
# 79 tests OK
|
||||||
|
```
|
||||||
|
|
||||||
|
覆盖:签名正确/篡改/缺失 secret、未知事件/删除分支、未知仓库、failure/pending/空 CI、PR 事件、基线固定而非 payload base、重放拒绝、对账恢复丢失通知且第二次幂等、API 失败不写状态。
|
||||||
|
|
||||||
|
## 未验证 / 外部依赖
|
||||||
|
|
||||||
|
- 未在本环境配置真实 Gitea 仓库 webhook endpoint/secret 与 Woodpecker 触发器;本证据只证明仓库侧可信入口与对账逻辑,不代表平台已部署(不伪造部署 PASS)。
|
||||||
|
- 长驻接收服务、bot 账号最小权限、cron 工作流与平台并发/限流按 #10 M0 实测后部署;仓库侧不新增第二套协议。
|
||||||
|
- 受保护发布工作流/制品资产(GAP-05 发布侧)仍属 #10。
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# #2 基础发行切换:发行门禁候选证据(2026-11-27)
|
||||||
|
|
||||||
|
工单:[marqdo#2](https://git.cflmy.cn/cflmy/marqdo/issues/2)。本文件记录**未发布**的本地发行候选验证;它不是 release、没有 tag、没有上传资产。按 `cli/docs/releasing.md`,tag/Release 需要维护者在冻结 SHA 上显式批准,自动化只能预备 RC 与证据。
|
||||||
|
|
||||||
|
## 候选身份
|
||||||
|
|
||||||
|
| 对象 | 身份 |
|
||||||
|
| --- | --- |
|
||||||
|
| 根组合 | `cflmy/marqdo@4a922017088490dfe7be75f76f70fa8fd5bb1c54`(本地验证基线) |
|
||||||
|
| CLI 源码 | `cflmy/marqdo-cli@deadf6edeea6dd0f5abf51c47e80204fd851baf0`(Phase B,无内置 `stdlib/` 源码树) |
|
||||||
|
| CLI 同 SHA CI | Woodpecker CLI pipeline 122(push)/121(pull_request)**success** |
|
||||||
|
| Bundle | `marqdo-stdlib@0.2.0`,tree digest `sha256:db905508dde89763b9d43b47fc5d52c6a1d5445a91f3c86a550ced43e8aac9d7` |
|
||||||
|
| 归档(验证用,未发布) | `marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz`,sha256 `377d2787e9cdeeb7c8e70024dacd0e2790fb0752716abeb5c0f72509807644d0` |
|
||||||
|
| 平台 | Linux x86_64 宿主;冷安装容器 Ubuntu 24.04 / glibc 2.39,`--network none`,无 Cargo |
|
||||||
|
|
||||||
|
**版本冲突声明**:该验证归档沿用 Cargo workspace 的 `3.0.0-rc.4` 版本但内容/mtime 组合与已发布 rc.4 不同(sha 不同)。它绝不能上传或作为 rc.4 再发布。正式候选必须先冻结新 SHA 并把版本/README/CHANGELOG/COMPATIBILITY/开发者文档统一提升到 `3.0.0-rc.5`,再重跑全部门禁。
|
||||||
|
|
||||||
|
## 已真实执行的本地门禁(PASS)
|
||||||
|
|
||||||
|
1. **Bundle 生产**:`scripts/build-stdlib.py` 从固定 gitlinks 生成 Bundle;`digest=sha256:db905508...`。
|
||||||
|
2. **确定性归档**:`cli/tools/release/package.py` 对同一 `SOURCE_SHA` + 同一 Bundle 连续构建两次,两个 tar.gz sha256 完全一致(`377d2787...`)。
|
||||||
|
3. **归档 smoke**:`cli/tools/release/smoke.py` PASS;缺少随附 Bundle 时 fail-closed,语言-only 程序可运行。
|
||||||
|
4. **离线冷安装**:`cli/tools/release/cold-install.sh` 在 Ubuntu 24.04/glibc 2.39、无网络、非 root、无 Cargo 容器内 PASS:`SOURCE_SHA` 与 `--version` 一致,`run`/`check`/`call`/JSONL `run.completed` 正常,移动 `stdlib` 后 `打印` 以 `kernel.unavailable` fail-closed,语言-only `阶乘` 仍可运行。
|
||||||
|
5. **标准库面**:同一归档 CLI 运行 `std-surface`,text/JSON/FS/path/datetime/table/Console 输出符合预期(实际 `call` 返回数组)。
|
||||||
|
6. **三个迁出扩展**:`extensions/http`、`extensions/regex`、`extensions/archive` 的 `scripts/test.sh` 使用**归档 CLI + 归档 Bundle** 全部 PASS。
|
||||||
|
7. **外部 conformance**:`cli/tools/ci/verify_extension_contracts.py --cli <归档 CLI> --release-info <归档 RELEASE_INFO>` 七类结果全部 PASS(plugin/worker/callable/negative-security/foreign-kernel/resource-provider/tool-analysis/package-pinned-git/reference-apps)。
|
||||||
|
8. **负例**:篡改归档随附 Bundle 的 `stdlib.json.digest` → CLI 退出 2(`stdlib digest mismatch`);缺失 Bundle → fail-closed。
|
||||||
|
9. **无重复源码**:CLI 源码树 `git ls-tree HEAD stdlib` 为空;归档内只有单一 Bundle。
|
||||||
|
|
||||||
|
## 未完成 / BLOCKED(不是 PASS)
|
||||||
|
|
||||||
|
| 门禁 | 状态 | 需要 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 冻结 release SHA + 版本/文档一致性(rc.5) | NOT STARTED | 维护者决定版本与候选 SHA;本次验证归档版本冲突,不可发布 |
|
||||||
|
| Strict L1 独立 VM、非 root、same-SHA 证据 | UNVERIFIED | 可用的 disposable VM/隔离 runner;本地 bubblewrap 命名空间不可用 |
|
||||||
|
| G4 性能(固定节点或维护者批准的 shared-node WARN) | UNVERIFIED | 固定/获批节点与正确性基线 |
|
||||||
|
| 维护者显式 tag/Release 批准 | NOT STARTED | 按 `cli/docs/releasing.md` 由维护者签署 |
|
||||||
|
| Windows/macOS | UNSUPPORTED | 本 RC 范围只声明 Linux x86_64 glibc |
|
||||||
|
|
||||||
|
## 结论
|
||||||
|
|
||||||
|
外部 Bundle、确定性归档、离线冷安装、三个迁出扩展与工具/外部 conformance 已在**同一 CLI+Bundle 组合**上通过;基础发行切换所缺的是新版本冻结、strict VM、性能与维护者发布批准。未创建 tag、未上传资产、未修改根发行身份;在获批前根 CLI/Bundle gitlink 与迁移台账保持现状。
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# 仓库开发规范内化与防膨胀门禁(2026-11-27)
|
||||||
|
|
||||||
|
来源:[marqdo#10](https://git.cflmy.cn/cflmy/marqdo/issues/10)(生态独立 CI/CD、制品发布与跨仓库传播实施规范)中的职责模型、独立 CI 合同、制品/发布事务、晋升与对账要求,经与现有 ARCHITECTURE/DEVELOPMENT/REPOSITORY-TASKS/MIGRATION 对齐后整理为仓库级规范。
|
||||||
|
|
||||||
|
## 落地内容
|
||||||
|
|
||||||
|
| 类型 | 文件/工具 |
|
||||||
|
| --- | --- |
|
||||||
|
| 根规范 | `docs/REPOSITORY-CONVENTIONS.md`:仓库准入、两层治理、职责矩阵、最低文件集、AGENTS 规范、独立 CI/CD、四种事实与 C2→B2→A2 晋升、单一事实源、防膨胀硬禁止清单、审核清单、例外记录 |
|
||||||
|
| 根约束 | `AGENTS.md` 增加“生态仓库开发规范(防膨胀,强制)”章节与规范链接 |
|
||||||
|
| 模板 | `docs/templates/AGENTS.component.md`(含 `<!-- marqdo:repo-conventions v1 -->` 标记) |
|
||||||
|
| 门禁 | `scripts/check-repo-conventions.py`:校验 active 仓 README/AGENTS 标记与链接/真实 entry、planned 不登记 entry、根 catalog 不重复登记领域后代、叶子仓无第二 catalog/.gitmodules、根 .gitmodules 权威远端 |
|
||||||
|
| 测试 | `tests/integration/test_repo_conventions.py`(6 个正反例),并纳入根 `.woodpecker/eco.yml` layout 阶段 |
|
||||||
|
| 子仓规范 | 每个 active 仓与已迁入实现的 extension 仓新增/更新 `AGENTS.md`,只写本仓边界并链接根规范 |
|
||||||
|
|
||||||
|
## 已传播的仓库(各自 PR 合并且按 fast-forward 合并)
|
||||||
|
|
||||||
|
| 仓库 | 规范提交 |
|
||||||
|
| --- | --- |
|
||||||
|
| marqdo-cli(根 gitlink,docs-only) | `13affa76dd8aa15d54ac89d580d5e60bff692384` |
|
||||||
|
| marqdo-extension-conformance | `665c12e9b1c116121cbed82c9014db208587dd58` |
|
||||||
|
| marqdo-view | `48e530935880989d95b54f81af0944a031543d65` |
|
||||||
|
| marqdo-knowledge | `6e881000898b0130a4d783c285d8e2967f8d7a0b` |
|
||||||
|
| marqdo-prove | `e9fce68551726a992167669d76c0bc1f9f0e4d14` |
|
||||||
|
| marqdo-lint | `aa0bdac7de9ed5aaa96c660657770a6f6dd90ed2` |
|
||||||
|
| marqdo-std-collections | `f18eec7ada16c5a28dd4f58daa5b1b7d2089b65d` |
|
||||||
|
| marqdo-std-text | `5b5d3b67c3c114a305a08e3a90c0d3ae008f7c34` |
|
||||||
|
| marqdo-std-data | `6f79b1345da0444418f5e9cd5a226d3df2a2e2bb` |
|
||||||
|
| marqdo-std-io | `02d1ad172c077674b6a0c3d0bd7a61092b278b10` |
|
||||||
|
| marqdo-std-fs | `104741bca034f8ae537389fef7c75c10eaed5b8c` |
|
||||||
|
| marqdo-std-system | `1561a6b7b6a2eb1f249976aaf6e05941d2db5296` |
|
||||||
|
| marqdo-ext-http | `6efcbc8c8cf90d4d5da36e923c0df0ac24a416a6` |
|
||||||
|
| marqdo-ext-regex | `23f9417809fae669bf8e690d56637be8f86fd27a` |
|
||||||
|
| marqdo-ext-archive | `86dcca0881c52e87cb3671e8cdace64a46f60c85` |
|
||||||
|
| marqdo-ext-web(领域,含 Design/Preview 子 gitlink 更新) | `70ba4a27e592edab74348e599b6d3882dcdfcbaf` |
|
||||||
|
| marqdo-web-design | `cbef7b622a96cd7057bd03cb206fe67089843dc4` |
|
||||||
|
| marqdo-web-preview | `86a260c64634eee263e19e7620f56dd2a86330f8` |
|
||||||
|
|
||||||
|
- Design/Preview 的 stale `planned` 声明同步修正为 active,Web 领域 README/AGENTS 的组件状态表同步修正;`web-components` 仍 planned。
|
||||||
|
- 根候选把上述子仓提交固定进 gitlink;本地 `check-repo-conventions.py` PASS(37 components)、`check-layout.py --checkouts` PASS、完整集成测试 **85 tests OK**;根 CI candidate 为最终门禁。
|
||||||
|
|
||||||
|
## 明确未做/后续
|
||||||
|
|
||||||
|
- 本 PR 只落“仓库组织/开发规范与门禁”,不实现 #10 的 CI/CD 工作流、发布索引、通知/reconcile 工作流、Woodpecker manual/cron;这些仍按 #10 逐项实施并需平台 M0 实测。
|
||||||
|
- planned 仓库(core/encoding/net、其余扩展、web-components)不批量生成 AGENTS/CI 模板;按规范在激活时补齐。
|
||||||
|
- 规范例外仍须在 Issue/ADR 记录原因、责任者、复查日期与退出条件。
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# 标准库源码归位 M3 候选证据(2026-11-27)
|
||||||
|
|
||||||
|
父仓工单:[cflmy/marqdo#9](https://git.cflmy.cn/cflmy/marqdo/issues/9)。
|
||||||
|
本文件记录 **M3 候选组合**(源码所有权切换 + 统一制品输入)的候选证据,不是已完成发行声明。主分支仍保持迁移前组合 `484cb10`,根 PR #12 只有在 CI 通过且 CLI Phase B 合并后才晋升。
|
||||||
|
|
||||||
|
## 候选身份
|
||||||
|
|
||||||
|
| 对象 | 身份 |
|
||||||
|
| --- | --- |
|
||||||
|
| 根候选 | `migration/stdlib-m2-candidate`(CLI Phase B 合并提交 `deadf6e`) |
|
||||||
|
| CLI Phase B 合并 | `cflmy/marqdo-cli@deadf6edeea6dd0f5abf51c47e80204fd851baf0`(PR #17 fast-forward 合并;Phase B 代码提交 `72f57be`,另含 CI 脚本修复;`stdlib/` 已删除,pin 指向生态 Bundle) |
|
||||||
|
| 生态 Bundle | `marqdo-stdlib@0.2.0`,source `cflmy/marqdo@48189243f7`,tree digest `sha256:db905508...`,aliases digest `sha256:5f513c0f...`(17 模块 + manifest) |
|
||||||
|
| 组件固定 | 六个 std 与三个 ext 的已合并候选 SHA(M2 证据同一组) |
|
||||||
|
| 发行归档(本地候选) | `marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz`,`sha256:9a926010ffe8e7353ee18b65fc568ced8bbf4b09b7592713f1213e2f3e3d40f9`(CLI `72f57be` + 新 Bundle) |
|
||||||
|
|
||||||
|
## 统一制品输入(ECO-02 核心)
|
||||||
|
|
||||||
|
根 `scripts/integration.sh` 不再读取 View 的冻结 RC.4 脚本;一次候选内派生全部输入:
|
||||||
|
|
||||||
|
1. `scripts/build-stdlib.py --out <work>/stdlib` 由固定组件 gitlink 生成唯一 Bundle;
|
||||||
|
2. 从根固定的 `cli/` 提交构建 CLI 与 Provider Worker;
|
||||||
|
3. `cli/tools/release/package.py --source-sha <cli SHA> --version <workspace version> --stdlib-dir <Bundle>` 生成发行归档与 `RELEASE_INFO.json`;
|
||||||
|
4. `cli/tools/release/smoke.py` 验证归档、`SOURCE_SHA`、stdlib 摘要与语言-only 运行;
|
||||||
|
5. `scripts/acceptance-stdlib.py --cli <installed> --bundle <Bundle>` 跑组件 entry、显式 Package、组合 fixture 与失败负例;
|
||||||
|
6. Conformance、View、Knowledge、Prove、Lint 使用同一安装后二进制与相邻 Bundle。
|
||||||
|
|
||||||
|
## 本地候选验证
|
||||||
|
|
||||||
|
| 门禁 | 命令 | 结果 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 根布局 | `python3 scripts/check-layout.py --checkouts` | PASS(含 6 个 active stdlib entry 与 9 个固定组件) |
|
||||||
|
| Bundle | `python3 scripts/build-stdlib.py --out <dir>` | 两次构建一致,digest `sha256:db9055...` |
|
||||||
|
| CLI Phase B | `cargo fmt` / `clippy -D warnings` / `cargo test --workspace`(显式 Bundle) | fmt/clippy PASS;72 个测试二进制 PASS |
|
||||||
|
| CLI 工具测试 | `MARQDO_TEST_STDLIB_BUNDLE=<bundle> python3 -m unittest discover -s tools/ci` | 75 tests OK |
|
||||||
|
| 独立构建 | `python3 tools/ci/independent_build.py` | PASS(无 stdlib 源树、无兄弟 Bundle,语言-only 运行成功,依赖 std 的程序 fail-closed) |
|
||||||
|
| 发行归档 | `package.py --stdlib-dir <Bundle>` + `smoke.py --archive` | PASS(stdlib 0.2.0 摘要校验、缺失 Bundle fail-closed、language-only 运行) |
|
||||||
|
| 验收脚本 | `scripts/acceptance-stdlib.py` 本地 M2 版 | PASS(6 组件 + 3 显式 Package + 4 组合 + 2 负例) |
|
||||||
|
|
||||||
|
## 未验证 / 待办
|
||||||
|
|
||||||
|
- 完整根 CI(`scripts/integration.sh` 含 View/Knowledge/Prove/Lint 消费者)在候选分支执行,结果记录在 PR #12/评论,不以本地部分运行替代。
|
||||||
|
- 根晋升(合并 CLI PR #17 与根 PR #12、climo gitlink 与制品同一候选)属 MIG-RELEASE。
|
||||||
|
- 完整产品归档冷安装(docker `--network none`)、多平台、ext-http loopback 领域测试仍待补;如需标记为发行门禁必须另行执行,不得以本文件冒充 PASS。
|
||||||
|
|
||||||
|
|
||||||
|
## 晋升与 M4 验收(2026-11-27)
|
||||||
|
|
||||||
|
- CLI Phase B [PR #17](https://git.cflmy.cn/cflmy/marqdo-cli/pulls/17) fast-forward 合并,`master` = `deadf6e`(contract/test/independent-build/minimum-rust/build 全绿)。
|
||||||
|
- 根 [PR #12](https://git.cflmy.cn/cflmy/marqdo/pulls/12) fast-forward 合并,`main` = `f4e292e7b09057c77e2a9293b40051be2666c4f8`;根树固定 CLI Phase B 与六个 std、三个 ext 提交,六个 stdlib 组件 active。
|
||||||
|
- 根生态 CI 必须门禁 `ci/woodpecker/pr/eco` PASS([pipeline 38](https://ci.cflmy.cn/repos/6/pipeline/38/1)):一次候选派生 Bundle(`sha256:db9055...`)→ 从 cli gitlink 构建 CLI/Worker → `package.py --stdlib-dir`(归档 `sha256:0827ba4b...`)→ smoke → 根 acceptance(组件 entry、显式 Package、组合、负例)→ Conformance/View/Knowledge/Prove/Lint 全部同一安装后二进制与相邻 Bundle。
|
||||||
|
- 发行级离线冷安装:在本机对同一晋升组合(根 `f4e292e`、CLI `deadf6e`、Bundle `db9055`)重新打包(归档 `sha256:377d2787...`)并执行 `cli/tools/release/cold-install.sh`(`ubuntu:24.04`、`--network none`、非 root 用户):PASS——安装后打印、`check`、示例运行、隐藏 Bundle 时 fail-closed、仅语言程序可运行均符合门禁。
|
||||||
|
- 两个归档 SHA 不同是因为示例插件二进制由本机构建产生,不是同一构建环境的确定性证据;确定性打包证据以 CI 同一环境两次构建为准。发行归档身份以 CI/发布记录为准,本文件只记录晋升组合与冷安装通过。
|
||||||
|
|
||||||
|
仍保留为后续(不阻塞本轮关闭):Windows/macOS 不在本线发行支持矩阵;`marqdo-ext-http` 的 HTTP-over-TCP loopback 领域测试;ECO-02 的递归影响分析自动化。
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# WEB-05 Web 领域根接入与冷安装候选证据(2026-11-27)
|
||||||
|
|
||||||
|
父工单:[marqdo#6](https://git.cflmy.cn/cflmy/marqdo/issues/6)。本文件记录根侧候选证据;领域侧见 `marqdo-ext-web` 的 `docs/evidence/WEB-05-domain-activation.md`。主分支组合在合并前保持不变。
|
||||||
|
|
||||||
|
## 候选身份
|
||||||
|
|
||||||
|
| 对象 | 身份 |
|
||||||
|
| --- | --- |
|
||||||
|
| 根候选 | `release/web05-domain-active`(根 `main` 基线 `d4ccb77`) |
|
||||||
|
| Web 领域 | `cflmy/marqdo-ext-web@f6d0a9067cad9f685a501a7bc3f3c3d302fe4f16`(active,入口 `scripts/domain-acceptance.sh`) |
|
||||||
|
| Design(active) | `cflmy/marqdo-web-design@1b6607fd3cc09801b4f6eacd2fba547caa0ec637`(entry `scripts/ci.sh`) |
|
||||||
|
| Preview(active) | `cflmy/marqdo-web-preview@eff273f7f2f3919bab62eacded781c61d5f03f91`(entry `scripts/ci.sh`) |
|
||||||
|
| web-components | planned(无独立实现,不伪造入口) |
|
||||||
|
| CLI | 根固定 `cli/deadf6e` 构建的 `marqdo 3.0.0-rc.4`,`sha256:6ede3b9e...` |
|
||||||
|
|
||||||
|
## 根侧门禁与结果(本地候选,CI 为最终门禁)
|
||||||
|
|
||||||
|
| 门禁 | 命令 | 结果 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 递归布局 | `python3 scripts/check-layout.py --checkouts` | **PASS**(根 + Web 域 + Design/Preview active 入口;本地候选) |
|
||||||
|
| 根集成测试 | `python3 -m unittest discover -s tests/integration` | **71 tests OK**(本地候选) |
|
||||||
|
| 领域组件入口 | `extensions/web/design/scripts/ci.sh`、`extensions/web/preview/scripts/ci.sh` | **PASS**(本地候选;24/24 Design,web Tool install/check/preview/handoff/remove) |
|
||||||
|
| web Tool 冷安装 | `tool install` → `web check/preview/handoff` → `tool remove`,CLI SHA 前后一致 | **PASS**(CLI `sha256:6ede3b9e...` 前后一致;本地候选) |
|
||||||
|
| 领域验收 | `extensions/web/scripts/domain-acceptance.sh`(三案例 + 生产 API/浏览器 E2E) | **PASS**(WEB-04 证据:三案例 + API + Chromium E2E,同一领域提交) |
|
||||||
|
| 既有消费者 | Conformance/View/Knowledge/Prove/Lint 同一 CLI/Bundle | 由 `integration.sh` 6 在 CI candidate 执行(CI 为最终门禁) |
|
||||||
|
|
||||||
|
## 边界
|
||||||
|
|
||||||
|
- 根与领域 catalog 都登记 `cli` 依赖;根不实现 Design/Preview/生产应用代码。
|
||||||
|
- 冷安装只安装构建出的 `web` Tool bundle;生产应用不是 Tool 运行依赖。
|
||||||
|
- `web-components` 未激活、无 entry,不计完成率。
|
||||||
|
- 本文件不把本地候选当已发布证据;根 CI(layout + candidate)通过后才晋升。
|
||||||
Vendored
+42
@@ -0,0 +1,42 @@
|
|||||||
|
<!-- marqdo:repo-conventions v1 -->
|
||||||
|
# AGENTS.md — <repo>
|
||||||
|
|
||||||
|
本文件约束在本仓库工作的维护者与 AI Agent。全局规则唯一来源:
|
||||||
|
[marqdo 仓库开发规范](https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/REPOSITORY-CONVENTIONS.md)。
|
||||||
|
本文件只写本仓边界,不复制全局规范或合同正文。
|
||||||
|
|
||||||
|
## 1. 本仓定位与唯一权威
|
||||||
|
|
||||||
|
- catalog ID:`<id>`;父级:`<root|domain>`;角色:`<core|stdlib|extension|tool|test|domain>`;状态:`<planned|active>`。
|
||||||
|
- 职责:<scope>。
|
||||||
|
- 本仓拥有:<唯一实现/合同/制品/测试>。
|
||||||
|
- 本仓不拥有:<其它仓的实现/合同/调度/发布>。
|
||||||
|
- 权威输入/合同:<e.g. 真实 CLI 公开 Analysis 3、MARQDO_BIN 绝对路径、WEB-DESIGN 合同、外部 Bundle>。
|
||||||
|
|
||||||
|
## 2. 必做 / 禁止
|
||||||
|
|
||||||
|
| 必做 | 禁止 |
|
||||||
|
| --- | --- |
|
||||||
|
| 只在本仓职责内修改,先开本仓工单 | 实现其它仓库功能、复制 parser/实现/合同 |
|
||||||
|
| 用真实 CLI/制品与独立期望测试 | mock 或字符串检查冒充真实验收/PASS |
|
||||||
|
| 依赖用固定 SHA/摘要,显式输入 | 依赖父仓 checkout、兄弟仓相对路径、浮动分支 |
|
||||||
|
| 未运行写 `UNVERIFIED` | 伪造 entry/版本/CI 徽章/gitlink/发布资产 |
|
||||||
|
| 记录 SHA、制品摘要、平台、命令、退出码 | 提交密钥、凭证、构建产物或本地绝对路径 |
|
||||||
|
| 跨仓变更走 C2→B2→A2 晋升 | 自动 tag/release/合并,或直接改父仓/兄弟仓 |
|
||||||
|
|
||||||
|
- 不新增第二 catalog/manifest/lock/version 表/发布流程;不建空壳仓或为单功能拆仓。
|
||||||
|
- 不在本仓登记其它仓库的后代路径;治理树最多两级。
|
||||||
|
|
||||||
|
## 3. 构建、测试与证据
|
||||||
|
|
||||||
|
- CI 入口:`<entry>`(非交互、失败非零、不打印秘密、只写声明输出;构建与发布权限分离)。
|
||||||
|
- 输入:<MARQDO_BIN / MARQDO_STDLIB_DIR / lock/manifest;绝对路径并验证身份>。
|
||||||
|
- 测试:真实正例 + 错误/授权/边界负例;本地可复现;默认禁网。
|
||||||
|
- 证据:候选 SHA、依赖/制品 SHA-256、平台/工具链、命令与退出码、日志位置、测试范围;FAIL/UNVERIFIED 不得写成 PASS。
|
||||||
|
- 交付:<source archive | tool bundle | domain evidence | none>;发布仅在受保护 tag/批准工作流后,不自动发布。
|
||||||
|
|
||||||
|
## 4. 变更与工单路由
|
||||||
|
|
||||||
|
- 本仓缺陷在本仓开工单;上游公共合同/协议缺陷路由到 `<repo>`;作者面/领域语义在领域仓 ADR。
|
||||||
|
- 新仓库、新公共合同、新目录层级或破坏性语义:先在根/领域开 Issue/ADR,记录责任、消费者、退出条件。
|
||||||
|
- 跨仓组合:组件 PR+CI → 领域 PR/验收 → 根 PR/递归与冷安装证据;父级只更新固定 gitlink 与证据。
|
||||||
+1
-1
Submodule extensions/archive updated: 527650e726...86dcca0881.
+1
-1
Submodule extensions/http updated: f2dde4234c...6efcbc8c8c.
+1
-1
Submodule extensions/regex updated: 5458dff039...23f9417809.
+1
-1
Submodule extensions/web updated: f70095d60a...70ba4a27e5.
@@ -157,6 +157,17 @@ def run_case(cli: str, bundle: Path, case: dict) -> dict:
|
|||||||
raise AcceptanceError(
|
raise AcceptanceError(
|
||||||
f"composition case {case['name']} stdout changed: {stdout!r}"
|
f"composition case {case['name']} stdout changed: {stdout!r}"
|
||||||
)
|
)
|
||||||
|
lines = stdout.splitlines()
|
||||||
|
for left, right in case.get("stdout_line_pairs", []):
|
||||||
|
if left >= len(lines) or right >= len(lines):
|
||||||
|
raise AcceptanceError(
|
||||||
|
f"composition case {case['name']} has no line pair {left}/{right}"
|
||||||
|
)
|
||||||
|
if lines[left] != lines[right]:
|
||||||
|
raise AcceptanceError(
|
||||||
|
f"composition case {case['name']}: line {left} differs from line {right}: "
|
||||||
|
f"{lines[left]!r} != {lines[right]!r}"
|
||||||
|
)
|
||||||
return {"name": case["name"], "status": "PASS"}
|
return {"name": case["name"], "status": "PASS"}
|
||||||
|
|
||||||
|
|
||||||
@@ -169,6 +180,26 @@ def load_components() -> list[dict]:
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def load_explicit_packages() -> list[dict]:
|
||||||
|
"""Planned extensions that already publish an explicit Package entry.
|
||||||
|
|
||||||
|
A component is gated as an explicit package only when its pinned checkout
|
||||||
|
carries the current package layout (``marqdo.yaml`` + ``index.mq.md`` +
|
||||||
|
``scripts/test.sh``); it is never silently loaded into the default Bundle.
|
||||||
|
"""
|
||||||
|
catalog = tomllib.loads((ROOT / "components.toml").read_text())
|
||||||
|
packages = []
|
||||||
|
for component in catalog["component"]:
|
||||||
|
if component.get("kind") != "extension":
|
||||||
|
continue
|
||||||
|
checkout = ROOT / component["path"]
|
||||||
|
if (checkout / "marqdo.yaml").is_file() and (
|
||||||
|
checkout / "index.mq.md"
|
||||||
|
).is_file() and (checkout / "scripts" / "test.sh").is_file():
|
||||||
|
packages.append(component)
|
||||||
|
return packages
|
||||||
|
|
||||||
|
|
||||||
def component_gates(cli: str, bundle: Path) -> list[dict]:
|
def component_gates(cli: str, bundle: Path) -> list[dict]:
|
||||||
results = []
|
results = []
|
||||||
for component in load_components():
|
for component in load_components():
|
||||||
@@ -194,14 +225,34 @@ def component_gates(cli: str, bundle: Path) -> list[dict]:
|
|||||||
"output": output,
|
"output": output,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
for component in load_explicit_packages():
|
||||||
|
entry = ROOT / component["path"] / "scripts" / "test.sh"
|
||||||
|
env = os.environ.copy()
|
||||||
|
env["MARQDO_BIN"] = cli
|
||||||
|
env["MARQDO_STDLIB_DIR"] = str(bundle)
|
||||||
|
result = run([str(entry)], cwd=ROOT / component["path"], env=env)
|
||||||
|
output = (result.stdout + result.stderr).decode(errors="replace").strip()
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise AcceptanceError(
|
||||||
|
f"explicit package {component['id']} failed: {output}"
|
||||||
|
)
|
||||||
|
results.append(
|
||||||
|
{
|
||||||
|
"id": component["id"],
|
||||||
|
"entry": "scripts/test.sh",
|
||||||
|
"kind": "explicit-package",
|
||||||
|
"status": "PASS",
|
||||||
|
"output": output,
|
||||||
|
}
|
||||||
|
)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def negative_gates(cli: str, bundle: Path, work: Path) -> list[dict]:
|
def negative_gates(cli: str, bundle: Path, work: Path) -> list[dict]:
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
def expect_failure(name, command):
|
def expect_failure(name, command, env_for_gate):
|
||||||
result = run(command)
|
result = run(command, env=env_for_gate)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
raise AcceptanceError(f"negative gate {name} unexpectedly passed")
|
raise AcceptanceError(f"negative gate {name} unexpectedly passed")
|
||||||
results.append(
|
results.append(
|
||||||
@@ -219,6 +270,7 @@ def negative_gates(cli: str, bundle: Path, work: Path) -> list[dict]:
|
|||||||
expect_failure(
|
expect_failure(
|
||||||
"missing-explicit-bundle",
|
"missing-explicit-bundle",
|
||||||
[cli, "run", str(ROOT / "tests/integration/composition/default-bundle.mq.md")],
|
[cli, "run", str(ROOT / "tests/integration/composition/default-bundle.mq.md")],
|
||||||
|
env,
|
||||||
)
|
)
|
||||||
|
|
||||||
tampered = work / "tampered-bundle"
|
tampered = work / "tampered-bundle"
|
||||||
@@ -231,6 +283,7 @@ def negative_gates(cli: str, bundle: Path, work: Path) -> list[dict]:
|
|||||||
expect_failure(
|
expect_failure(
|
||||||
"tampered-module-digest",
|
"tampered-module-digest",
|
||||||
[cli, "run", str(ROOT / "tests/integration/composition/default-bundle.mq.md")],
|
[cli, "run", str(ROOT / "tests/integration/composition/default-bundle.mq.md")],
|
||||||
|
env,
|
||||||
)
|
)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
Executable
+317
@@ -0,0 +1,317 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Verify one candidate notification before any automation acts on it.
|
||||||
|
|
||||||
|
The ecosystem uses manual PR gates; this verifier is the authorization step for
|
||||||
|
a (future) bot that may only create candidate branches/PRs. It accepts a
|
||||||
|
normalized notification (from a reviewed webhook adapter), never a raw remote
|
||||||
|
payload, and returns a machine plan. It refuses forged, replayed, stale,
|
||||||
|
unknown or failed candidates instead of trusting the sender.
|
||||||
|
|
||||||
|
Checks, in order:
|
||||||
|
|
||||||
|
1. notification schema and 40-hex commits;
|
||||||
|
2. the repository is an allowlisted component remote (or the root repository);
|
||||||
|
3. the CI result is `success` on an allowlisted CI host with an https URL;
|
||||||
|
4. the commit is reachable in the owning local repository;
|
||||||
|
5. a component candidate starts from the exact SHA currently pinned by the
|
||||||
|
accepted root graph (a stale/retargeted base is rejected);
|
||||||
|
6. the (repository, head SHA) pair is not a replay; a new accepted baseline
|
||||||
|
allows a re-validation and marks the result `revalidate`;
|
||||||
|
7. impact is computed with the shared union-graph analyzer; undetermined scope
|
||||||
|
widens to full re-validation instead of skipping.
|
||||||
|
|
||||||
|
The verifier never merges, pushes, grants permissions or fetches floating
|
||||||
|
branches. Its only proposed action is recording the candidate / creating a
|
||||||
|
candidate branch that a human still reviews.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import datetime as dt
|
||||||
|
import importlib.util
|
||||||
|
import json
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tomllib
|
||||||
|
import urllib.parse
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
ROOT = PROJECT_ROOT
|
||||||
|
SCHEMA = "marqdo.candidate-notification"
|
||||||
|
PLAN_SCHEMA = "marqdo.candidate-plan"
|
||||||
|
SCHEMA_VERSION = 1
|
||||||
|
DEFAULT_CI_HOST = "ci.cflmy.cn"
|
||||||
|
|
||||||
|
|
||||||
|
def load_impact():
|
||||||
|
"""Load the shared analyzer and point it at the verifier's root checkout."""
|
||||||
|
spec = importlib.util.spec_from_file_location(
|
||||||
|
"marqdo_impact", PROJECT_ROOT / "scripts" / "impact.py"
|
||||||
|
)
|
||||||
|
module = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
module.ROOT = ROOT
|
||||||
|
return module
|
||||||
|
|
||||||
|
|
||||||
|
def git(repo: Path, *args: str) -> str:
|
||||||
|
result = subprocess.run(["git", "-C", str(repo), *args], capture_output=True)
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise NotificationError(
|
||||||
|
f"git {' '.join(args)} failed in {repo}: "
|
||||||
|
f"{result.stderr.decode(errors='replace').strip()}"
|
||||||
|
)
|
||||||
|
return result.stdout.decode(errors="replace")
|
||||||
|
|
||||||
|
|
||||||
|
class NotificationError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def is_sha(value) -> bool:
|
||||||
|
return isinstance(value, str) and len(value) == 40 and all(
|
||||||
|
ch in "0123456789abcdef" for ch in value
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def repository_allowlist(accepted_revision: str) -> dict[str, dict]:
|
||||||
|
"""Map `owner/name` -> component identity from the accepted root graph."""
|
||||||
|
impact = load_impact()
|
||||||
|
graph, unverified = impact.load_graph(ROOT, accepted_revision, "root")
|
||||||
|
if unverified:
|
||||||
|
raise NotificationError(
|
||||||
|
"accepted graph cannot be expanded: " + "; ".join(unverified)
|
||||||
|
)
|
||||||
|
allowlist: dict[str, dict] = {}
|
||||||
|
for component in graph.values():
|
||||||
|
remote = component.get("remote")
|
||||||
|
if not remote:
|
||||||
|
continue
|
||||||
|
parsed = urllib.parse.urlparse(remote)
|
||||||
|
name = parsed.path.strip("/")
|
||||||
|
if name.endswith(".git"):
|
||||||
|
name = name[:-4]
|
||||||
|
if name:
|
||||||
|
allowlist[name] = component
|
||||||
|
return allowlist
|
||||||
|
|
||||||
|
|
||||||
|
def check_schema(notification: dict) -> None:
|
||||||
|
if notification.get("schema") != SCHEMA:
|
||||||
|
raise NotificationError(f"unsupported notification schema: {notification.get('schema')!r}")
|
||||||
|
if notification.get("schema_version") != SCHEMA_VERSION:
|
||||||
|
raise NotificationError("unsupported notification schema_version")
|
||||||
|
if notification.get("kind") not in ("component", "root"):
|
||||||
|
raise NotificationError("kind must be 'component' or 'root'")
|
||||||
|
for field in ("repository", "head_sha", "base_sha"):
|
||||||
|
if not isinstance(notification.get(field), str) or not notification[field]:
|
||||||
|
raise NotificationError(f"notification has no {field}")
|
||||||
|
if not is_sha(notification["head_sha"]) or not is_sha(notification["base_sha"]):
|
||||||
|
raise NotificationError("head_sha/base_sha must be full lowercase commit SHAs")
|
||||||
|
if notification["head_sha"] == notification["base_sha"]:
|
||||||
|
raise NotificationError("head_sha equals base_sha; nothing to verify")
|
||||||
|
|
||||||
|
|
||||||
|
def check_ci(notification: dict, ci_hosts: list[str]) -> dict:
|
||||||
|
ci = notification.get("ci")
|
||||||
|
if not isinstance(ci, dict):
|
||||||
|
raise NotificationError("notification has no ci object")
|
||||||
|
if ci.get("status") != "success":
|
||||||
|
raise NotificationError(f"CI status is not success: {ci.get('status')!r}")
|
||||||
|
url = ci.get("url")
|
||||||
|
if not isinstance(url, str):
|
||||||
|
raise NotificationError("notification ci.url must be a string")
|
||||||
|
parsed = urllib.parse.urlparse(url)
|
||||||
|
if parsed.scheme != "https" or parsed.hostname not in ci_hosts:
|
||||||
|
raise NotificationError(
|
||||||
|
f"CI URL must be https on one of {ci_hosts}: {url!r}"
|
||||||
|
)
|
||||||
|
return ci
|
||||||
|
|
||||||
|
|
||||||
|
def load_state(path: Path) -> dict:
|
||||||
|
if not path.is_file():
|
||||||
|
return {"schema": "marqdo.candidate-state", "schema_version": 1, "seen": {}}
|
||||||
|
state = json.loads(path.read_text())
|
||||||
|
if not isinstance(state.get("seen"), dict):
|
||||||
|
raise NotificationError(f"invalid candidate state file: {path}")
|
||||||
|
return state
|
||||||
|
|
||||||
|
|
||||||
|
def verify(
|
||||||
|
notification: dict,
|
||||||
|
accepted_ref: str,
|
||||||
|
state_path: Path,
|
||||||
|
ci_hosts: list[str],
|
||||||
|
root_repository: str,
|
||||||
|
write_state: bool,
|
||||||
|
) -> dict:
|
||||||
|
check_schema(notification)
|
||||||
|
ci = check_ci(notification, ci_hosts)
|
||||||
|
impact = load_impact()
|
||||||
|
impact.ROOT = ROOT
|
||||||
|
accepted_revision = impact.resolve(ROOT, accepted_ref)
|
||||||
|
reasons: list[str] = []
|
||||||
|
revalidate = False
|
||||||
|
kind = notification["kind"]
|
||||||
|
repository = notification["repository"]
|
||||||
|
allowlist = repository_allowlist(accepted_revision)
|
||||||
|
if kind == "root":
|
||||||
|
if repository != root_repository:
|
||||||
|
raise NotificationError(
|
||||||
|
f"unknown root repository {repository!r}; allowlist is {root_repository!r}"
|
||||||
|
)
|
||||||
|
if not subprocess.run(
|
||||||
|
["git", "-C", str(ROOT), "cat-file", "-e", notification["head_sha"] + "^{commit}"],
|
||||||
|
capture_output=True,
|
||||||
|
).returncode == 0:
|
||||||
|
raise NotificationError("candidate commit is not reachable in the root repository")
|
||||||
|
report = impact.analyze(accepted_revision, notification["head_sha"])
|
||||||
|
base_sha = accepted_revision
|
||||||
|
key = f"root@{notification['head_sha']}"
|
||||||
|
else:
|
||||||
|
component = allowlist.get(repository)
|
||||||
|
if component is None:
|
||||||
|
raise NotificationError(
|
||||||
|
f"unknown repository {repository!r}; allowlist: {sorted(allowlist)}"
|
||||||
|
)
|
||||||
|
component_id = notification.get("component") or component["id"]
|
||||||
|
if component_id != component["id"]:
|
||||||
|
raise NotificationError(
|
||||||
|
f"notification component {component_id!r} does not own repository {repository!r}"
|
||||||
|
)
|
||||||
|
checkout = ROOT / component["path"]
|
||||||
|
if not (checkout / ".git").exists():
|
||||||
|
raise NotificationError(f"missing component checkout: {checkout}")
|
||||||
|
if not subprocess.run(
|
||||||
|
["git", "-C", str(checkout), "cat-file", "-e", notification["head_sha"] + "^{commit}"],
|
||||||
|
capture_output=True,
|
||||||
|
).returncode == 0:
|
||||||
|
raise NotificationError("candidate commit is not reachable in the component repository")
|
||||||
|
if component.get("sha") != notification["base_sha"]:
|
||||||
|
raise NotificationError(
|
||||||
|
"base_sha is stale: the accepted root graph pins "
|
||||||
|
f"{component.get('sha')} for {component_id}"
|
||||||
|
)
|
||||||
|
report = impact.consumers_of(component_id, accepted_revision)
|
||||||
|
base_sha = component["sha"]
|
||||||
|
key = f"{repository}@{notification['head_sha']}"
|
||||||
|
state = load_state(state_path)
|
||||||
|
previous = state["seen"].get(key)
|
||||||
|
if previous is not None:
|
||||||
|
if previous.get("accepted") == accepted_revision:
|
||||||
|
raise NotificationError(
|
||||||
|
"duplicate/replay: this candidate was already verified against the same accepted baseline"
|
||||||
|
)
|
||||||
|
revalidate = True
|
||||||
|
reasons.append(
|
||||||
|
"new accepted baseline since first notification; re-run the full candidate gates"
|
||||||
|
)
|
||||||
|
if report.get("unverified"):
|
||||||
|
reasons.append("impact scope undetermined; full re-validation required")
|
||||||
|
state["seen"][key] = {
|
||||||
|
"accepted": accepted_revision,
|
||||||
|
"base_sha": base_sha,
|
||||||
|
"kind": kind,
|
||||||
|
"repository": repository,
|
||||||
|
"first_verified": previous.get("first_verified")
|
||||||
|
if previous
|
||||||
|
else dt.datetime.now(dt.timezone.utc).isoformat(),
|
||||||
|
"last_verified": dt.datetime.now(dt.timezone.utc).isoformat(),
|
||||||
|
}
|
||||||
|
if write_state:
|
||||||
|
state_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
state_path.write_text(json.dumps(state, indent=2) + "\n")
|
||||||
|
return {
|
||||||
|
"schema": PLAN_SCHEMA,
|
||||||
|
"schema_version": SCHEMA_VERSION,
|
||||||
|
"verified": True,
|
||||||
|
"revalidate": revalidate,
|
||||||
|
"reasons": reasons,
|
||||||
|
"kind": kind,
|
||||||
|
"repository": repository,
|
||||||
|
"head_sha": notification["head_sha"],
|
||||||
|
"base_sha": notification["base_sha"],
|
||||||
|
"accepted": {"ref": accepted_ref, "revision": accepted_revision},
|
||||||
|
"ci": ci,
|
||||||
|
"impact": {
|
||||||
|
"affected": report.get("affected", []),
|
||||||
|
"changed": report.get("changed", []),
|
||||||
|
"checks_with": report.get("checks_with", []),
|
||||||
|
"fallback": report.get("fallback"),
|
||||||
|
"unverified": report.get("unverified", []),
|
||||||
|
},
|
||||||
|
"actions": {
|
||||||
|
"auto_promote": False,
|
||||||
|
"auto_merge": False,
|
||||||
|
"create_candidate_branch": True,
|
||||||
|
"requires_human_review": True,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv: list[str]) -> int:
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("--notification", required=True, help="normalized notification JSON")
|
||||||
|
parser.add_argument("--accepted", required=True, help="accepted root revision")
|
||||||
|
parser.add_argument("--state", required=True, help="candidate dedupe state file")
|
||||||
|
parser.add_argument(
|
||||||
|
"--ci-host", action="append", default=None, help="allowlisted CI host (repeatable)"
|
||||||
|
)
|
||||||
|
parser.add_argument("--root-repository", default="cflmy/marqdo")
|
||||||
|
parser.add_argument("--out", default=None)
|
||||||
|
parser.add_argument("--json", action="store_true")
|
||||||
|
parser.add_argument("--dry-run", action="store_true", help="do not write the dedupe state")
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
ci_hosts = args.ci_host or [DEFAULT_CI_HOST]
|
||||||
|
try:
|
||||||
|
notification = json.loads(Path(args.notification).read_text())
|
||||||
|
if not isinstance(notification, dict):
|
||||||
|
raise NotificationError("notification must be a JSON object")
|
||||||
|
plan = verify(
|
||||||
|
notification,
|
||||||
|
args.accepted,
|
||||||
|
Path(args.state),
|
||||||
|
ci_hosts,
|
||||||
|
args.root_repository,
|
||||||
|
write_state=not args.dry_run,
|
||||||
|
)
|
||||||
|
except (NotificationError, json.JSONDecodeError, OSError) as error:
|
||||||
|
rejected = {
|
||||||
|
"schema": PLAN_SCHEMA,
|
||||||
|
"schema_version": SCHEMA_VERSION,
|
||||||
|
"verified": False,
|
||||||
|
"reasons": [str(error)],
|
||||||
|
"actions": {
|
||||||
|
"auto_promote": False,
|
||||||
|
"auto_merge": False,
|
||||||
|
"create_candidate_branch": False,
|
||||||
|
"requires_human_review": True,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
text = json.dumps(rejected, ensure_ascii=False, indent=2) + "\n"
|
||||||
|
if args.out:
|
||||||
|
Path(args.out).write_text(text)
|
||||||
|
if args.json:
|
||||||
|
print(text, end="")
|
||||||
|
print(f"candidate-notify: rejected: {error}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
text = json.dumps(plan, ensure_ascii=False, indent=2) + "\n"
|
||||||
|
if args.out:
|
||||||
|
Path(args.out).write_text(text)
|
||||||
|
if args.json:
|
||||||
|
print(text, end="")
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
f"verified {plan['kind']} candidate {plan['repository']}@{plan['head_sha'][:12]} "
|
||||||
|
f"affected={len(plan['impact']['affected'])} revalidate={plan['revalidate']}"
|
||||||
|
)
|
||||||
|
for reason in plan["reasons"]:
|
||||||
|
print(f" note: {reason}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main(sys.argv[1:]))
|
||||||
Executable
+209
@@ -0,0 +1,209 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Check ecosystem repository development conventions.
|
||||||
|
|
||||||
|
This is a repository-hygiene gate, not a new catalog: it reads the existing
|
||||||
|
root (and domain) components.toml, .gitmodules and gitlinks. It enforces the
|
||||||
|
rules in docs/REPOSITORY-CONVENTIONS.md for active repositories, the AGENTS.md
|
||||||
|
marker/links, real entry files, no duplicated descendant paths in the root
|
||||||
|
catalog, no nested submodules in leaf components and no second catalog.
|
||||||
|
|
||||||
|
Exit code 0 = PASS, 1 = violations, 2 = usage/environment failure.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import tomllib
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
MARKER = "<!-- marqdo:repo-conventions v1 -->"
|
||||||
|
CONVENTIONS_URL = (
|
||||||
|
"https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/REPOSITORY-CONVENTIONS.md"
|
||||||
|
)
|
||||||
|
ROOT_AGENTS_LINK = "docs/REPOSITORY-CONVENTIONS.md"
|
||||||
|
|
||||||
|
|
||||||
|
class Error(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def read_toml(path: Path) -> dict:
|
||||||
|
try:
|
||||||
|
with path.open("rb") as handle:
|
||||||
|
return tomllib.load(handle)
|
||||||
|
except FileNotFoundError as error:
|
||||||
|
raise Error(f"missing catalog: {path.relative_to(PROJECT_ROOT)}") from error
|
||||||
|
except tomllib.TOMLDecodeError as error:
|
||||||
|
raise Error(f"invalid TOML {path.relative_to(PROJECT_ROOT)}: {error}") from error
|
||||||
|
|
||||||
|
|
||||||
|
def components(root: Path) -> list[dict]:
|
||||||
|
return read_toml(root / "components.toml").get("component", [])
|
||||||
|
|
||||||
|
|
||||||
|
def submodule_urls(root: Path) -> dict[str, str]:
|
||||||
|
path = root / ".gitmodules"
|
||||||
|
if not path.is_file():
|
||||||
|
return {}
|
||||||
|
result: dict[str, str] = {}
|
||||||
|
current_path = None
|
||||||
|
for raw in path.read_text().splitlines():
|
||||||
|
line = raw.strip()
|
||||||
|
if line.startswith("[submodule "):
|
||||||
|
current_path = None
|
||||||
|
continue
|
||||||
|
if line.startswith("path ="):
|
||||||
|
current_path = line.split("=", 1)[1].strip()
|
||||||
|
elif line.startswith("url =") and current_path:
|
||||||
|
result[current_path] = line.split("=", 1)[1].strip()
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def check_active(root: Path, component: dict, errors: list[str]) -> None:
|
||||||
|
identifier = component.get("id", "?")
|
||||||
|
rel = component.get("path", "")
|
||||||
|
checkout = root / rel
|
||||||
|
if not rel:
|
||||||
|
errors.append(f"{identifier}: active component has no path")
|
||||||
|
return
|
||||||
|
if not checkout.is_dir():
|
||||||
|
errors.append(f"{identifier}: checkout path missing: {rel}")
|
||||||
|
return
|
||||||
|
readme = checkout / "README.md"
|
||||||
|
if not readme.is_file() or readme.stat().st_size < 100:
|
||||||
|
errors.append(f"{identifier}: README.md missing or too small")
|
||||||
|
agents = checkout / "AGENTS.md"
|
||||||
|
if not agents.is_file():
|
||||||
|
errors.append(f"{identifier}: AGENTS.md missing")
|
||||||
|
else:
|
||||||
|
text = agents.read_text()
|
||||||
|
if MARKER not in text:
|
||||||
|
errors.append(f"{identifier}: AGENTS.md lacks `{MARKER}`")
|
||||||
|
if CONVENTIONS_URL not in text:
|
||||||
|
errors.append(f"{identifier}: AGENTS.md does not link the root conventions")
|
||||||
|
if len(text) < 300:
|
||||||
|
errors.append(f"{identifier}: AGENTS.md is too small to state boundaries")
|
||||||
|
entry = component.get("entry", "")
|
||||||
|
if not entry:
|
||||||
|
errors.append(f"{identifier}: active component has no entry")
|
||||||
|
elif not (checkout / entry).is_file():
|
||||||
|
errors.append(f"{identifier}: entry file missing: {rel}/{entry}")
|
||||||
|
for forbidden in ("components.toml", ".gitmodules"):
|
||||||
|
if (checkout / forbidden).is_file() and component.get("kind") != "domain":
|
||||||
|
errors.append(f"{identifier}: leaf component must not own {forbidden}")
|
||||||
|
|
||||||
|
|
||||||
|
def check_planned(component: dict, errors: list[str]) -> None:
|
||||||
|
identifier = component.get("id", "?")
|
||||||
|
if component.get("entry"):
|
||||||
|
errors.append(f"{identifier}: planned component must not declare entry")
|
||||||
|
|
||||||
|
|
||||||
|
def flatten(root: Path) -> tuple[list[dict], dict[str, dict]]:
|
||||||
|
root_components = components(root)
|
||||||
|
by_id: dict[str, dict] = {}
|
||||||
|
for component in root_components:
|
||||||
|
identifier = component.get("id")
|
||||||
|
if identifier in by_id:
|
||||||
|
raise Error(f"duplicate global component id: {identifier}")
|
||||||
|
by_id[identifier] = component
|
||||||
|
children: dict[str, dict] = {}
|
||||||
|
for component in root_components:
|
||||||
|
if component.get("kind") != "domain":
|
||||||
|
continue
|
||||||
|
domain = root / component.get("path", "")
|
||||||
|
catalog = domain / "components.toml"
|
||||||
|
if not catalog.is_file():
|
||||||
|
raise Error(f"domain {component.get('id')} has no components.toml")
|
||||||
|
for child in read_toml(catalog).get("component", []):
|
||||||
|
child = dict(child)
|
||||||
|
child["domain_path"] = component["path"]
|
||||||
|
identifier = child.get("id")
|
||||||
|
if identifier in by_id:
|
||||||
|
raise Error(f"duplicate global component id: {identifier}")
|
||||||
|
by_id[identifier] = child
|
||||||
|
child["path"] = f"{component['path']}/{child.get('path', '')}"
|
||||||
|
children[identifier] = child
|
||||||
|
return root_components + list(children.values()), by_id
|
||||||
|
|
||||||
|
|
||||||
|
def check(root: Path) -> list[str]:
|
||||||
|
errors: list[str] = []
|
||||||
|
flat, by_id = flatten(root)
|
||||||
|
root_components = components(root)
|
||||||
|
root_paths = {component.get("path") for component in root_components}
|
||||||
|
domain_paths = [
|
||||||
|
component["path"]
|
||||||
|
for component in root_components
|
||||||
|
if component.get("kind") == "domain" and component.get("path")
|
||||||
|
]
|
||||||
|
for component in root_components:
|
||||||
|
path = component.get("path", "")
|
||||||
|
for domain_path in domain_paths:
|
||||||
|
if path.startswith(f"{domain_path}/"):
|
||||||
|
errors.append(
|
||||||
|
f"{component.get('id')}: descendant of {domain_path} is also registered in the root catalog"
|
||||||
|
)
|
||||||
|
for component in flat:
|
||||||
|
if component.get("state") == "active":
|
||||||
|
check_active(root, component, errors)
|
||||||
|
elif component.get("state") == "planned":
|
||||||
|
check_planned(component, errors)
|
||||||
|
else:
|
||||||
|
errors.append(f"{component.get('id')}: unknown state {component.get('state')!r}")
|
||||||
|
root_agents = root / "AGENTS.md"
|
||||||
|
if not root_agents.is_file():
|
||||||
|
errors.append("root AGENTS.md missing")
|
||||||
|
else:
|
||||||
|
text = root_agents.read_text()
|
||||||
|
if ROOT_AGENTS_LINK not in text:
|
||||||
|
errors.append(f"root AGENTS.md does not link {ROOT_AGENTS_LINK}")
|
||||||
|
if "防膨胀" not in text and "REPOSITORY-CONVENTIONS" not in text:
|
||||||
|
errors.append("root AGENTS.md does not state the repository conventions")
|
||||||
|
urls = submodule_urls(root)
|
||||||
|
for component in root_components:
|
||||||
|
path = component.get("path", "")
|
||||||
|
if path not in urls:
|
||||||
|
errors.append(f"{component.get('id')}: path {path!r} is not in root .gitmodules")
|
||||||
|
else:
|
||||||
|
url = urls[path]
|
||||||
|
if not url.startswith("https://git.cflmy.cn/cflmy/") or not url.endswith(".git"):
|
||||||
|
errors.append(f"{component.get('id')}: non-canonical submodule URL {url!r}")
|
||||||
|
for component in root_components:
|
||||||
|
if component.get("kind") == "domain":
|
||||||
|
continue
|
||||||
|
rel = component.get("path", "")
|
||||||
|
checkout = root / rel
|
||||||
|
if (checkout / "components.toml").is_file():
|
||||||
|
errors.append(f"{component.get('id')}: leaf component owns a second catalog")
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv: list[str]) -> int:
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("--root", default=str(PROJECT_ROOT), help="checkout root to inspect")
|
||||||
|
parser.add_argument("--report", action="store_true", help="print the checked component set")
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
root = Path(args.root).resolve()
|
||||||
|
try:
|
||||||
|
errors = check(root)
|
||||||
|
flat, _ = flatten(root)
|
||||||
|
except Error as error:
|
||||||
|
print(f"repo-conventions: error: {error}", file=sys.stderr)
|
||||||
|
return 2
|
||||||
|
if args.report:
|
||||||
|
for component in flat:
|
||||||
|
print(component.get("id"), component.get("path"), component.get("state"))
|
||||||
|
if errors:
|
||||||
|
for error in errors:
|
||||||
|
print(f"repo-conventions: FAIL: {error}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
print(f"repo-conventions: PASS ({len(flat)} components)")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main(sys.argv[1:]))
|
||||||
Executable
+423
@@ -0,0 +1,423 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Recursive impact analysis between an accepted root commit and a candidate.
|
||||||
|
|
||||||
|
Compares the recursively expanded governance tree of two root revisions. A
|
||||||
|
component identity is `(global_id, parent, remote, SHA, state)`; a domain
|
||||||
|
gitlink change is expanded to its child identities so leaf changes are visible
|
||||||
|
even when the parent pointer did not change as a string.
|
||||||
|
|
||||||
|
The affected set is computed in the order the development contract requires:
|
||||||
|
|
||||||
|
1. changed or removed leaves;
|
||||||
|
2. reverse transitive closure over `requires` edges from the union of both
|
||||||
|
graphs (removed edges cannot hide a consumer);
|
||||||
|
3. parent domains of affected components;
|
||||||
|
4. `checks_with` fixed point (co-validation is not a build prerequisite).
|
||||||
|
|
||||||
|
When a domain cannot be expanded (missing object/checkout) the result is marked
|
||||||
|
UNVERIFIED and the whole domain is treated as affected rather than silently
|
||||||
|
skipping it.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tomllib
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
SCHEMA = "marqdo.impact"
|
||||||
|
SCHEMA_VERSION = 1
|
||||||
|
|
||||||
|
|
||||||
|
class ImpactError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def git(repo: Path, *args: str) -> bytes:
|
||||||
|
result = subprocess.run(["git", "-C", str(repo), *args], capture_output=True)
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise ImpactError(
|
||||||
|
f"git {' '.join(args)} failed in {repo}: "
|
||||||
|
f"{result.stderr.decode(errors='replace').strip()}"
|
||||||
|
)
|
||||||
|
return result.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def show(repo: Path, revision: str, path: str) -> bytes | None:
|
||||||
|
result = subprocess.run(
|
||||||
|
["git", "-C", str(repo), "show", f"{revision}:{path}"], capture_output=True
|
||||||
|
)
|
||||||
|
return result.stdout if result.returncode == 0 else None
|
||||||
|
|
||||||
|
|
||||||
|
def resolve(repo: Path, revision: str) -> str:
|
||||||
|
try:
|
||||||
|
return (
|
||||||
|
git(repo, "rev-parse", "--verify", revision + "^{commit}")
|
||||||
|
.decode()
|
||||||
|
.strip()
|
||||||
|
)
|
||||||
|
except ImpactError as error:
|
||||||
|
raise ImpactError(f"cannot resolve revision {revision!r}: {error}") from error
|
||||||
|
|
||||||
|
|
||||||
|
def tree_entries(repo: Path, revision: str) -> dict[str, tuple[str, str]]:
|
||||||
|
output = git(repo, "ls-tree", "-r", "-z", revision)
|
||||||
|
entries: dict[str, tuple[str, str]] = {}
|
||||||
|
for record in output.split(b"\0"):
|
||||||
|
if not record:
|
||||||
|
continue
|
||||||
|
header, _, raw_path = record.partition(b"\t")
|
||||||
|
fields = header.decode().split()
|
||||||
|
if len(fields) != 3:
|
||||||
|
raise ImpactError(f"invalid tree record in {repo}@{revision}")
|
||||||
|
mode, _kind, sha = fields
|
||||||
|
entries[raw_path.decode()] = (mode, sha)
|
||||||
|
return entries
|
||||||
|
|
||||||
|
|
||||||
|
def submodule_urls(repo: Path, revision: str) -> dict[str, str]:
|
||||||
|
"""Map `.gitmodules` path to URL at a revision (authority for remotes)."""
|
||||||
|
raw = show(repo, revision, ".gitmodules")
|
||||||
|
if raw is None:
|
||||||
|
return {}
|
||||||
|
config = git(
|
||||||
|
repo, "config", "--null", "--blob", f"{revision}:.gitmodules", "--list"
|
||||||
|
)
|
||||||
|
urls: dict[str, str] = {}
|
||||||
|
pending: dict[str, dict[str, str]] = {}
|
||||||
|
for record in config.split(b"\0"):
|
||||||
|
if not record:
|
||||||
|
continue
|
||||||
|
key, _, value = record.decode(errors="replace").partition("\n")
|
||||||
|
match = re.fullmatch(r"submodule\.(.+)\.(path|url)", key)
|
||||||
|
if match:
|
||||||
|
name, field = match.groups()
|
||||||
|
pending.setdefault(name, {})[field] = value
|
||||||
|
for fields in pending.values():
|
||||||
|
if "path" in fields and "url" in fields:
|
||||||
|
urls[fields["path"]] = fields["url"]
|
||||||
|
return urls
|
||||||
|
|
||||||
|
|
||||||
|
def read_catalog(repo: Path, revision: str, label: str) -> list[dict]:
|
||||||
|
raw = show(repo, revision, "components.toml")
|
||||||
|
if raw is None:
|
||||||
|
raise ImpactError(f"{label}: revision {revision} has no components.toml")
|
||||||
|
try:
|
||||||
|
catalog = tomllib.loads(raw.decode())
|
||||||
|
except (UnicodeDecodeError, tomllib.TOMLDecodeError) as error:
|
||||||
|
raise ImpactError(f"{label}: invalid components.toml: {error}") from error
|
||||||
|
components = catalog.get("component")
|
||||||
|
if not isinstance(components, list):
|
||||||
|
raise ImpactError(f"{label}: components.toml has no [[component]] entries")
|
||||||
|
return components
|
||||||
|
|
||||||
|
|
||||||
|
def load_graph(
|
||||||
|
repo: Path, revision: str, label: str, depth: int = 0
|
||||||
|
) -> tuple[dict[str, dict], list[str]]:
|
||||||
|
"""Expand one governance layer (root then domains) into global identities."""
|
||||||
|
components = read_catalog(repo, revision, label)
|
||||||
|
entries = tree_entries(repo, revision)
|
||||||
|
urls = submodule_urls(repo, revision)
|
||||||
|
gitlinks = {path: sha for path, (mode, sha) in entries.items() if mode == "160000"}
|
||||||
|
graph: dict[str, dict] = {}
|
||||||
|
unverified: list[str] = []
|
||||||
|
for component in components:
|
||||||
|
component_id = component.get("id")
|
||||||
|
path = component.get("path")
|
||||||
|
if not isinstance(component_id, str) or not isinstance(path, str):
|
||||||
|
raise ImpactError(f"{label}: component without id/path")
|
||||||
|
sha = gitlinks.get(path)
|
||||||
|
identity = {
|
||||||
|
"id": component_id,
|
||||||
|
"parent": None,
|
||||||
|
"path": path,
|
||||||
|
"remote": urls.get(path),
|
||||||
|
"sha": sha,
|
||||||
|
"state": component.get("state"),
|
||||||
|
"kind": component.get("kind"),
|
||||||
|
"requires": sorted(component.get("requires", [])),
|
||||||
|
"checks_with": sorted(component.get("checks_with", [])),
|
||||||
|
"layer": label,
|
||||||
|
}
|
||||||
|
graph[component_id] = identity
|
||||||
|
if component.get("kind") != "domain" or depth > 0:
|
||||||
|
continue
|
||||||
|
domain_repo = repo / path
|
||||||
|
if sha is None or not (domain_repo / ".git").exists():
|
||||||
|
unverified.append(
|
||||||
|
f"{label}: domain {component_id} ({path}) cannot be expanded: "
|
||||||
|
"missing gitlink or checkout"
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
children, child_unverified = load_graph(
|
||||||
|
domain_repo, sha, f"domain {component_id}", depth + 1
|
||||||
|
)
|
||||||
|
except ImpactError as error:
|
||||||
|
unverified.append(
|
||||||
|
f"{label}: domain {component_id} ({path})@{sha} cannot be expanded: {error}"
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
unverified.extend(child_unverified)
|
||||||
|
for child_id, child in children.items():
|
||||||
|
if child_id in graph:
|
||||||
|
raise ImpactError(f"{label}: duplicate global id {child_id}")
|
||||||
|
child["parent"] = component_id
|
||||||
|
graph[child_id] = child
|
||||||
|
return graph, unverified
|
||||||
|
|
||||||
|
|
||||||
|
def identity_fields(component: dict) -> tuple:
|
||||||
|
return (
|
||||||
|
component.get("parent"),
|
||||||
|
component.get("remote"),
|
||||||
|
component.get("sha"),
|
||||||
|
component.get("state"),
|
||||||
|
tuple(component.get("requires", [])),
|
||||||
|
tuple(component.get("checks_with", [])),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def changed_components(
|
||||||
|
accepted: dict[str, dict], candidate: dict[str, dict]
|
||||||
|
) -> list[dict]:
|
||||||
|
changed = []
|
||||||
|
for component_id in sorted(set(accepted) | set(candidate)):
|
||||||
|
before = accepted.get(component_id)
|
||||||
|
after = candidate.get(component_id)
|
||||||
|
if before is None:
|
||||||
|
changed.append({"id": component_id, "reason": "added"})
|
||||||
|
continue
|
||||||
|
if after is None:
|
||||||
|
changed.append({"id": component_id, "reason": "removed"})
|
||||||
|
continue
|
||||||
|
if before.get("sha") != after.get("sha"):
|
||||||
|
changed.append({"id": component_id, "reason": "sha"})
|
||||||
|
elif before.get("state") != after.get("state"):
|
||||||
|
changed.append({"id": component_id, "reason": "state"})
|
||||||
|
elif before.get("remote") != after.get("remote"):
|
||||||
|
changed.append({"id": component_id, "reason": "remote"})
|
||||||
|
elif before.get("parent") != after.get("parent"):
|
||||||
|
changed.append({"id": component_id, "reason": "parent"})
|
||||||
|
elif before.get("requires") != after.get("requires") or before.get(
|
||||||
|
"checks_with"
|
||||||
|
) != after.get("checks_with"):
|
||||||
|
changed.append({"id": component_id, "reason": "dependencies"})
|
||||||
|
return changed
|
||||||
|
|
||||||
|
|
||||||
|
def affected_set(
|
||||||
|
accepted: dict[str, dict], candidate: dict[str, dict], changed: list[dict]
|
||||||
|
) -> tuple[list[str], list[str], list[str]]:
|
||||||
|
graph = {**accepted, **candidate}
|
||||||
|
dependents: dict[str, set[str]] = {component_id: set() for component_id in graph}
|
||||||
|
for component in graph.values():
|
||||||
|
for dependency in component.get("requires", []):
|
||||||
|
dependents.setdefault(dependency, set()).add(component["id"])
|
||||||
|
affected = {item["id"] for item in changed}
|
||||||
|
queue = list(affected)
|
||||||
|
while queue:
|
||||||
|
current = queue.pop()
|
||||||
|
for consumer in dependents.get(current, set()):
|
||||||
|
if consumer not in affected:
|
||||||
|
affected.add(consumer)
|
||||||
|
queue.append(consumer)
|
||||||
|
domains = set()
|
||||||
|
for component_id in list(affected):
|
||||||
|
parent = graph[component_id].get("parent")
|
||||||
|
while parent:
|
||||||
|
if parent not in affected:
|
||||||
|
domains.add(parent)
|
||||||
|
parent = graph[parent].get("parent") if parent in graph else None
|
||||||
|
co_validation: set[str] = set()
|
||||||
|
while True:
|
||||||
|
additions = set()
|
||||||
|
for component_id in affected:
|
||||||
|
for partner in graph[component_id].get("checks_with", []):
|
||||||
|
if partner not in affected:
|
||||||
|
additions.add(partner)
|
||||||
|
if not additions:
|
||||||
|
break
|
||||||
|
affected |= additions
|
||||||
|
co_validation |= additions
|
||||||
|
return sorted(affected), sorted(domains), sorted(co_validation)
|
||||||
|
|
||||||
|
|
||||||
|
def consumers_of(component_id: str, revision: str) -> dict:
|
||||||
|
"""Consumers of one component at a revision (component-PR impact scope).
|
||||||
|
|
||||||
|
Uses the accepted graph only: a component candidate cannot change the root
|
||||||
|
graph it is evaluated against. Unknown component or unexpandable domain
|
||||||
|
widens the scope to the whole graph (never silently skip).
|
||||||
|
"""
|
||||||
|
revision_sha = resolve(ROOT, revision)
|
||||||
|
graph, unverified = load_graph(ROOT, revision_sha, "root")
|
||||||
|
if component_id not in graph:
|
||||||
|
graph, unverified = load_graph(ROOT, revision_sha, "root")
|
||||||
|
return {
|
||||||
|
"schema": SCHEMA,
|
||||||
|
"schema_version": SCHEMA_VERSION,
|
||||||
|
"accepted": {"ref": revision, "revision": revision_sha},
|
||||||
|
"component": component_id,
|
||||||
|
"affected": sorted(graph),
|
||||||
|
"checks_with": [],
|
||||||
|
"domain_ancestors": [],
|
||||||
|
"fallback": "full",
|
||||||
|
"unverified": unverified
|
||||||
|
+ [f"unknown component {component_id!r} at {revision_sha}; scope widened"],
|
||||||
|
}
|
||||||
|
dependents: dict[str, set[str]] = {key: set() for key in graph}
|
||||||
|
for component in graph.values():
|
||||||
|
for dependency in component.get("requires", []):
|
||||||
|
dependents.setdefault(dependency, set()).add(component["id"])
|
||||||
|
affected = {component_id}
|
||||||
|
queue = [component_id]
|
||||||
|
while queue:
|
||||||
|
current = queue.pop()
|
||||||
|
for consumer in dependents.get(current, set()):
|
||||||
|
if consumer not in affected:
|
||||||
|
affected.add(consumer)
|
||||||
|
queue.append(consumer)
|
||||||
|
domains = set()
|
||||||
|
for item in list(affected):
|
||||||
|
parent = graph[item].get("parent")
|
||||||
|
while parent:
|
||||||
|
if parent not in affected:
|
||||||
|
domains.add(parent)
|
||||||
|
parent = graph[parent].get("parent") if parent in graph else None
|
||||||
|
co_validation: set[str] = set()
|
||||||
|
while True:
|
||||||
|
additions = {
|
||||||
|
partner
|
||||||
|
for item in affected
|
||||||
|
for partner in graph[item].get("checks_with", [])
|
||||||
|
if partner not in affected
|
||||||
|
}
|
||||||
|
if not additions:
|
||||||
|
break
|
||||||
|
affected |= additions
|
||||||
|
co_validation |= additions
|
||||||
|
fallback = None
|
||||||
|
if unverified:
|
||||||
|
affected = set(graph)
|
||||||
|
domains = set()
|
||||||
|
co_validation = set()
|
||||||
|
fallback = "full"
|
||||||
|
return {
|
||||||
|
"schema": SCHEMA,
|
||||||
|
"schema_version": SCHEMA_VERSION,
|
||||||
|
"accepted": {"ref": revision, "revision": revision_sha},
|
||||||
|
"component": component_id,
|
||||||
|
"affected": sorted(affected),
|
||||||
|
"checks_with": sorted(co_validation),
|
||||||
|
"domain_ancestors": sorted(domains),
|
||||||
|
"fallback": fallback,
|
||||||
|
"unverified": unverified,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def analyze(accepted_ref: str, candidate_ref: str) -> dict:
|
||||||
|
accepted_revision = resolve(ROOT, accepted_ref)
|
||||||
|
candidate_revision = resolve(ROOT, candidate_ref)
|
||||||
|
accepted, accepted_unverified = load_graph(ROOT, accepted_revision, "root")
|
||||||
|
candidate, candidate_unverified = load_graph(ROOT, candidate_revision, "root")
|
||||||
|
changed = changed_components(accepted, candidate)
|
||||||
|
affected, domains, co_validation = affected_set(accepted, candidate, changed)
|
||||||
|
unverified = accepted_unverified + candidate_unverified
|
||||||
|
fallback = None
|
||||||
|
if unverified:
|
||||||
|
# Undetermined scope must widen, never silently skip.
|
||||||
|
affected = sorted(set(accepted) | set(candidate))
|
||||||
|
domains = []
|
||||||
|
co_validation = []
|
||||||
|
fallback = "full"
|
||||||
|
return {
|
||||||
|
"schema": SCHEMA,
|
||||||
|
"schema_version": SCHEMA_VERSION,
|
||||||
|
"accepted": {"ref": accepted_ref, "revision": accepted_revision},
|
||||||
|
"candidate": {"ref": candidate_ref, "revision": candidate_revision},
|
||||||
|
"counts": {
|
||||||
|
"accepted_components": len(accepted),
|
||||||
|
"candidate_components": len(candidate),
|
||||||
|
"changed": len(changed),
|
||||||
|
"affected": len(affected),
|
||||||
|
},
|
||||||
|
"changed": changed,
|
||||||
|
"affected": affected,
|
||||||
|
"domain_ancestors": domains,
|
||||||
|
"checks_with": co_validation,
|
||||||
|
"fallback": fallback,
|
||||||
|
"unverified": unverified,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv: list[str]) -> int:
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("--accepted", required=True, help="accepted root revision")
|
||||||
|
parser.add_argument("--candidate", default="HEAD", help="candidate root revision")
|
||||||
|
parser.add_argument("--out", default=None)
|
||||||
|
parser.add_argument("--json", action="store_true")
|
||||||
|
parser.add_argument(
|
||||||
|
"--component",
|
||||||
|
default=None,
|
||||||
|
help="report consumers of one component at --accepted instead of a root diff",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--fail-on-unverified",
|
||||||
|
action="store_true",
|
||||||
|
help="exit 2 when a domain cannot be expanded",
|
||||||
|
)
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
try:
|
||||||
|
if args.component:
|
||||||
|
report = consumers_of(args.component, args.accepted)
|
||||||
|
else:
|
||||||
|
report = analyze(args.accepted, args.candidate)
|
||||||
|
except ImpactError as error:
|
||||||
|
print(f"impact: error: {error}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
text = json.dumps(report, ensure_ascii=False, indent=2) + "\n"
|
||||||
|
if args.out:
|
||||||
|
Path(args.out).write_text(text)
|
||||||
|
if args.json:
|
||||||
|
print(text, end="")
|
||||||
|
else:
|
||||||
|
if "candidate" in report:
|
||||||
|
print(
|
||||||
|
f"accepted {report['accepted']['revision'][:12]} "
|
||||||
|
f"candidate {report['candidate']['revision'][:12]}"
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
f"changed={report['counts']['changed']} "
|
||||||
|
f"affected={report['counts']['affected']}"
|
||||||
|
)
|
||||||
|
for item in report["changed"]:
|
||||||
|
print(f" changed {item['id']}: {item['reason']}")
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
f"component {report['component']} at "
|
||||||
|
f"{report['accepted']['revision'][:12]}"
|
||||||
|
)
|
||||||
|
print(f"consumers={len(report['affected'])}")
|
||||||
|
print("affected: " + ", ".join(report["affected"]))
|
||||||
|
if report["checks_with"]:
|
||||||
|
print("co-validation: " + ", ".join(report["checks_with"]))
|
||||||
|
if report["fallback"]:
|
||||||
|
print("fallback: full (impact scope undetermined)")
|
||||||
|
for note in report["unverified"]:
|
||||||
|
print(f"UNVERIFIED: {note}", file=sys.stderr)
|
||||||
|
if args.fail_on_unverified and report["unverified"]:
|
||||||
|
return 2
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main(sys.argv[1:]))
|
||||||
+138
-24
@@ -1,10 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# Ecosystem integration for one exact candidate combination.
|
||||||
|
#
|
||||||
|
# Inputs are the pinned root gitlinks: the root-owned Bundle producer assembles
|
||||||
|
# the one stdlib Bundle, the CLI/Worker are built from the pinned `cli` commit,
|
||||||
|
# the release archive is packaged with that explicit Bundle, and every consumer
|
||||||
|
# runs against that same installed binary + adjacent Bundle. There is no
|
||||||
|
# implicit artifact from View, no floating branch and no network-selected CLI.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
root="$PWD"
|
root="$PWD"
|
||||||
active="$(python3 scripts/check-layout.py --checkouts --active-paths)"
|
active="$(python3 scripts/check-layout.py --checkouts --active-paths)"
|
||||||
expected=$'cli\ntests/conformance\ntools/knowledge\ntools/lint\ntools/prove\ntools/view'
|
expected=$'cli\nextensions/web\nstdlib/collections\nstdlib/data\nstdlib/fs\nstdlib/io\nstdlib/system\nstdlib/text\ntests/conformance\ntools/knowledge\ntools/lint\ntools/prove\ntools/view'
|
||||||
if [[ "$active" != "$expected" ]]; then
|
if [[ "$active" != "$expected" ]]; then
|
||||||
echo "UNVERIFIED: update the integration plan for the changed active component set" >&2
|
echo "UNVERIFIED: update the integration plan for the changed active component set" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -15,6 +22,7 @@ work="$(mktemp -d "$root/.integration-work/run.XXXXXX")"
|
|||||||
echo "integration evidence: $work"
|
echo "integration evidence: $work"
|
||||||
exec > >(tee "$work/run.log") 2>&1
|
exec > >(tee "$work/run.log") 2>&1
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
git rev-parse HEAD
|
git rev-parse HEAD
|
||||||
git submodule status --recursive
|
git submodule status --recursive
|
||||||
uname -m
|
uname -m
|
||||||
@@ -22,35 +30,108 @@ ldd --version
|
|||||||
cargo --version
|
cargo --version
|
||||||
python3 --version
|
python3 --version
|
||||||
python3 -c 'import jsonschema'
|
python3 -c 'import jsonschema'
|
||||||
|
python3 scripts/check-layout.py --checkouts > "$work/layout.txt"
|
||||||
|
cat "$work/layout.txt"
|
||||||
|
|
||||||
unset MARQDO_STDLIB_DIR
|
# Recursive impact analysis against the accepted root commit: the change set
|
||||||
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
|
# comes from the recursively expanded (global_id, parent, remote, SHA, state)
|
||||||
mkdir "$work/frozen"
|
# identities, then reverse `requires` closure, parent domains and `checks_with`
|
||||||
frozen="$root/tools/view/scripts/frozen-beta.sh"
|
# fixed point. An undetermined scope widens to the full candidate.
|
||||||
metadata="$("$frozen" metadata)"
|
accepted_ref="${MARQDO_ACCEPTED_REF:-}"
|
||||||
artifact="$(sed -n 's/^artifact=//p' <<<"$metadata")"
|
if [[ -z "$accepted_ref" && -n "${CI_COMMIT_TARGET_BRANCH:-}" ]] \
|
||||||
if [[ -n "${MARQDO_INTEGRATION_ARCHIVE:-}" ]]; then
|
&& git rev-parse --verify "origin/$CI_COMMIT_TARGET_BRANCH" >/dev/null 2>&1; then
|
||||||
archive="$(realpath "$MARQDO_INTEGRATION_ARCHIVE")"
|
accepted_ref="origin/$CI_COMMIT_TARGET_BRANCH"
|
||||||
archive_sha="$(sed -n 's/^archive_sha=//p' <<<"$metadata")"
|
elif [[ -z "$accepted_ref" ]] && git rev-parse --verify origin/main >/dev/null 2>&1; then
|
||||||
printf '%s %s\n' "$archive_sha" "$archive" | sha256sum -c -
|
accepted_ref="origin/main"
|
||||||
tar -xzf "$archive" -C "$work/frozen"
|
fi
|
||||||
MARQDO_BIN="$work/frozen/$artifact/marqdo"
|
if [[ -n "$accepted_ref" ]]; then
|
||||||
"$frozen" verify "$MARQDO_BIN"
|
python3 scripts/impact.py --accepted "$accepted_ref" --candidate HEAD \
|
||||||
else
|
--out "$work/impact.json"
|
||||||
MARQDO_BIN="$("$frozen" fetch "$work/frozen")"
|
|
||||||
archive="$work/frozen/$artifact.tar.gz"
|
|
||||||
fi
|
fi
|
||||||
export MARQDO_BIN
|
|
||||||
source_sha="$(git -C cli rev-parse HEAD)"
|
|
||||||
test "$(cat "$(dirname "$MARQDO_BIN")/SOURCE_SHA")" = "$source_sha"
|
|
||||||
sha256sum "$archive" "$MARQDO_BIN" "$(dirname "$MARQDO_BIN")/marqdo-provider-worker"
|
|
||||||
|
|
||||||
|
# 1. One Bundle, produced by the root-owned producer from the pinned gitlinks.
|
||||||
|
python3 scripts/build-stdlib.py --out "$work/stdlib" | tee "$work/bundle.json"
|
||||||
|
bundle_digest="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["tree_digest"])' < "$work/bundle.json")"
|
||||||
|
bundle_aliases="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["aliases_digest"])' < "$work/bundle.json")"
|
||||||
|
test -f "$work/stdlib/stdlib.json"
|
||||||
|
|
||||||
|
# 2. CLI and Worker from the exact pinned CLI gitlink.
|
||||||
|
source_sha="$(git -C cli rev-parse HEAD)"
|
||||||
|
# The CLI release packager resolves its binaries from the pinned CLI checkout's
|
||||||
|
# own target directory; keep this build there so the package step consumes the
|
||||||
|
# same artifacts without a second build. Do not export CARGO_TARGET_DIR: the
|
||||||
|
# consumer repositories build into their own target directories.
|
||||||
|
CARGO_TARGET_DIR="$root/cli/target" \
|
||||||
|
cargo build --manifest-path cli/Cargo.toml --locked --release \
|
||||||
|
-p marqdo-cli -p marqdo-provider-worker
|
||||||
|
version="$(python3 -c '
|
||||||
|
import pathlib, tomllib
|
||||||
|
data = tomllib.loads(pathlib.Path("cli/Cargo.toml").read_text())
|
||||||
|
print(data["workspace"]["package"]["version"])
|
||||||
|
')"
|
||||||
|
|
||||||
|
# 3. The release archive takes the Bundle as one explicit input.
|
||||||
|
python3 cli/tools/release/package.py \
|
||||||
|
--source-sha "$source_sha" --version "$version" \
|
||||||
|
--stdlib-dir "$work/stdlib" --out-dir "$work/dist" | tee "$work/package.json"
|
||||||
|
archive="$(find "$work/dist" -maxdepth 1 -name 'marqdo-*.tar.gz' -print -quit)"
|
||||||
python3 cli/tools/release/smoke.py --archive "$archive"
|
python3 cli/tools/release/smoke.py --archive "$archive"
|
||||||
|
mkdir -p "$work/install"
|
||||||
|
tar -xzf "$archive" -C "$work/install"
|
||||||
|
installed="$(find "$work/install" -mindepth 1 -maxdepth 1 -type d -print -quit)"
|
||||||
|
MARQDO_BIN="$installed/marqdo"
|
||||||
|
export MARQDO_BIN
|
||||||
|
test "$(cat "$installed/SOURCE_SHA")" = "$source_sha"
|
||||||
|
test "$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["version"])' "$installed/stdlib/stdlib.json")" = "$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["version"])' "$work/stdlib/stdlib.json")"
|
||||||
|
sha256sum "$archive" "$MARQDO_BIN" "$installed/marqdo-provider-worker"
|
||||||
|
|
||||||
|
# 4. Root stdlib acceptance: component entries, explicit Packages, composition
|
||||||
|
# fixtures and fail-closed negatives with the same installed CLI/Bundle.
|
||||||
|
python3 scripts/acceptance-stdlib.py \
|
||||||
|
--cli "$MARQDO_BIN" --bundle "$work/stdlib" \
|
||||||
|
--work "$work/stdlib-acceptance" --evidence "$work/stdlib-acceptance.json"
|
||||||
|
|
||||||
|
# 5. Frozen independent public-contract fixtures against the same CLI.
|
||||||
python3 cli/tools/ci/verify_extension_contracts.py \
|
python3 cli/tools/ci/verify_extension_contracts.py \
|
||||||
--source-repo cli --tested-sha "$source_sha" --cli "$MARQDO_BIN" \
|
--source-repo cli --tested-sha "$source_sha" --cli "$MARQDO_BIN" \
|
||||||
--release-info "$(dirname "$MARQDO_BIN")/RELEASE_INFO.json" \
|
--release-info "$installed/RELEASE_INFO.json" \
|
||||||
--fixtures tests/conformance --out "$work/conformance.json"
|
--fixtures tests/conformance --out "$work/conformance.json"
|
||||||
|
|
||||||
|
|
||||||
|
# 5.5 Web domain: component entries from the pinned domain gitlink, then a cold
|
||||||
|
# install of the same-built web Tool with a generic check/preview/handoff run.
|
||||||
|
# The candidate image uses a minimal Rust profile; component entries run
|
||||||
|
# fmt/clippy, so add those components once when the active toolchain lacks them.
|
||||||
|
if command -v rustup >/dev/null 2>&1 \
|
||||||
|
&& ! rustup component list --installed 2>/dev/null | grep -qx 'rustfmt.*'; then
|
||||||
|
rustup component add rustfmt clippy
|
||||||
|
fi
|
||||||
|
(
|
||||||
|
cd extensions/web/design
|
||||||
|
MARQDO_BIN="$MARQDO_BIN" scripts/ci.sh
|
||||||
|
)
|
||||||
|
(
|
||||||
|
cd extensions/web/preview
|
||||||
|
MARQDO_BIN="$MARQDO_BIN" scripts/ci.sh
|
||||||
|
)
|
||||||
|
web_tool="$root/extensions/web/preview/dist/marqdo-web-preview/tool.json"
|
||||||
|
test -f "$web_tool"
|
||||||
|
export MARQDO_TOOL_HOME="$work/web-tool-home"
|
||||||
|
cli_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||||
|
"$MARQDO_BIN" tool install "$web_tool"
|
||||||
|
"$MARQDO_BIN" web check extensions/web/examples/research-workspace/index.mq.md \
|
||||||
|
--unit 工作台 --root extensions/web/examples/research-workspace
|
||||||
|
"$MARQDO_BIN" web preview extensions/web/examples/research-workspace/index.mq.md \
|
||||||
|
--unit 工作台 --root extensions/web/examples/research-workspace --out "$work/web-preview"
|
||||||
|
test -f "$work/web-preview/index.html"
|
||||||
|
"$MARQDO_BIN" web handoff extensions/web/examples/research-workspace/index.mq.md \
|
||||||
|
--unit 工作台 --root extensions/web/examples/research-workspace --out "$work/web-handoff.md"
|
||||||
|
test -s "$work/web-handoff.md"
|
||||||
|
"$MARQDO_BIN" tool remove web
|
||||||
|
cli_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||||
|
test "$cli_before" = "$cli_after"
|
||||||
|
echo "web domain: component entries + cold Tool install PASS"
|
||||||
|
# 6. Existing consumers, same installed binary and adjacent Bundle.
|
||||||
(
|
(
|
||||||
cd tools/view
|
cd tools/view
|
||||||
export MARQDO_TOOL_HOME="$work/view-registry"
|
export MARQDO_TOOL_HOME="$work/view-registry"
|
||||||
@@ -87,7 +168,6 @@ python3 cli/tools/ci/verify_extension_contracts.py \
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
cd tools/knowledge
|
cd tools/knowledge
|
||||||
MARQDO_TEST_BIN="$MARQDO_BIN" cargo test --locked --test core_cli --test compile
|
MARQDO_TEST_BIN="$MARQDO_BIN" cargo test --locked --test core_cli --test compile
|
||||||
@@ -105,4 +185,38 @@ python3 cli/tools/ci/verify_extension_contracts.py \
|
|||||||
"$MARQDO_BIN" tool remove lint
|
"$MARQDO_BIN" tool remove lint
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "PASS: ecosystem RC.4 candidate checks"
|
# 7. Evidence identity for the accepted candidate.
|
||||||
|
root_commit="$(git rev-parse HEAD)"
|
||||||
|
python3 - "$work" "$root_commit" "$source_sha" "$bundle_digest" "$bundle_aliases" "$archive" <<'PY'
|
||||||
|
import hashlib, json, pathlib, sys
|
||||||
|
work = pathlib.Path(sys.argv[1])
|
||||||
|
archive = pathlib.Path(sys.argv[6])
|
||||||
|
impact_path = work / "impact.json"
|
||||||
|
impact = json.loads(impact_path.read_text()) if impact_path.is_file() else None
|
||||||
|
evidence = {
|
||||||
|
"schema": "marqdo.ecosystem-integration",
|
||||||
|
"schema_version": 1,
|
||||||
|
"root_commit": sys.argv[2],
|
||||||
|
"cli_source_sha": sys.argv[3],
|
||||||
|
"stdlib_tree_digest": sys.argv[4],
|
||||||
|
"stdlib_aliases_digest": sys.argv[5],
|
||||||
|
"archive": archive.name,
|
||||||
|
"archive_sha256": "sha256:" + hashlib.sha256(archive.read_bytes()).hexdigest(),
|
||||||
|
"impact": (
|
||||||
|
{
|
||||||
|
"changed": impact["changed"],
|
||||||
|
"affected": impact["affected"],
|
||||||
|
"checks_with": impact["checks_with"],
|
||||||
|
"fallback": impact["fallback"],
|
||||||
|
"unverified": impact["unverified"],
|
||||||
|
}
|
||||||
|
if impact
|
||||||
|
else None
|
||||||
|
),
|
||||||
|
"status": "PASS",
|
||||||
|
}
|
||||||
|
(work / "integration-evidence.json").write_text(json.dumps(evidence, indent=2) + "\n")
|
||||||
|
print(json.dumps(evidence, indent=2))
|
||||||
|
PY
|
||||||
|
|
||||||
|
echo "PASS: ecosystem candidate (single CLI/Worker/Bundle artifact, consumers green)"
|
||||||
Executable
+406
@@ -0,0 +1,406 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Trusted adapter for candidate webhooks and release/candidate reconciliation.
|
||||||
|
|
||||||
|
This turns an authenticated Gitea webhook (push / pull_request) into the
|
||||||
|
normalized candidate notification verified by `scripts/candidate-notify.py`, and
|
||||||
|
provides the periodic reconciliation path required when a fast notification is
|
||||||
|
lost. It is deliberately small: no long-running service, no merge/push rights,
|
||||||
|
no trust in payload asset URLs or commands.
|
||||||
|
|
||||||
|
Trust rules:
|
||||||
|
|
||||||
|
* the raw body is authenticated with the repository webhook secret
|
||||||
|
(`X-Gitea-Signature`, HMAC-SHA256 hex) — an unsigned or wrong-signature body
|
||||||
|
never reaches verification;
|
||||||
|
* the repository must be an allowlisted component remote (or the root
|
||||||
|
repository) discovered from the accepted root graph, never from the payload;
|
||||||
|
* the candidate base is the SHA currently pinned by the accepted graph (payload
|
||||||
|
branch/base is only a hint);
|
||||||
|
* the commit must be reachable in the owning local repository;
|
||||||
|
* CI aggregation requires at least one status and only `success`; the URL must
|
||||||
|
be an https URL on an allowlisted CI host;
|
||||||
|
* replay/duplicate/revalidation is handled by the shared candidate state file;
|
||||||
|
* reconciliation scans open PRs in allowlisted repositories, so a lost webhook
|
||||||
|
is recovered by the next successful run (idempotent with the same state).
|
||||||
|
|
||||||
|
The adapter outputs a plan only (`auto_promote=false`, `auto_merge=false`);
|
||||||
|
a human still reviews candidate branches/PRs.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import hmac
|
||||||
|
import importlib.util
|
||||||
|
import json
|
||||||
|
import random
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import urllib.error
|
||||||
|
import urllib.request
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
ROOT = PROJECT_ROOT
|
||||||
|
DEFAULT_CI_HOST = "ci.cflmy.cn"
|
||||||
|
DEFAULT_ROOT_REPOSITORY = "cflmy/marqdo"
|
||||||
|
|
||||||
|
|
||||||
|
class AdapterError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def load_notify():
|
||||||
|
spec = importlib.util.spec_from_file_location(
|
||||||
|
"marqdo_candidate_notify", PROJECT_ROOT / "scripts" / "candidate-notify.py"
|
||||||
|
)
|
||||||
|
module = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
module.ROOT = ROOT
|
||||||
|
return module
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_revision(notify, ref: str) -> str:
|
||||||
|
impact = notify.load_impact()
|
||||||
|
impact.ROOT = ROOT
|
||||||
|
return impact.resolve(ROOT, ref)
|
||||||
|
|
||||||
|
|
||||||
|
def verify_signature(raw: bytes, signature: str | None, secret: str) -> None:
|
||||||
|
if not secret:
|
||||||
|
raise AdapterError("webhook secret is required")
|
||||||
|
if not signature:
|
||||||
|
raise AdapterError("missing X-Gitea-Signature")
|
||||||
|
expected = hmac.new(secret.encode(), raw, hashlib.sha256).hexdigest()
|
||||||
|
if not hmac.compare_digest(expected, signature.strip().lower()):
|
||||||
|
raise AdapterError("webhook signature does not match the raw body")
|
||||||
|
|
||||||
|
|
||||||
|
def parse_event(raw: bytes, event: str, signature: str | None, secret: str) -> dict:
|
||||||
|
verify_signature(raw, signature, secret)
|
||||||
|
try:
|
||||||
|
payload = json.loads(raw)
|
||||||
|
except json.JSONDecodeError as error:
|
||||||
|
raise AdapterError(f"webhook body is not JSON: {error}") from error
|
||||||
|
if not isinstance(payload, dict):
|
||||||
|
raise AdapterError("webhook body must be a JSON object")
|
||||||
|
repository = (payload.get("repository") or {}).get("full_name")
|
||||||
|
if not isinstance(repository, str) or not repository:
|
||||||
|
raise AdapterError("webhook payload has no repository.full_name")
|
||||||
|
if event == "push":
|
||||||
|
if payload.get("deleted"):
|
||||||
|
raise AdapterError("branch deletion is not a candidate")
|
||||||
|
before = payload.get("before")
|
||||||
|
after = payload.get("after")
|
||||||
|
if not isinstance(before, str) or not isinstance(after, str):
|
||||||
|
raise AdapterError("push payload has no before/after commit")
|
||||||
|
if set(after) == {"0"}:
|
||||||
|
raise AdapterError("push payload deletes the branch")
|
||||||
|
return {
|
||||||
|
"kind": "push",
|
||||||
|
"repository": repository,
|
||||||
|
"head_sha": after.lower(),
|
||||||
|
"payload_base": before.lower(),
|
||||||
|
"ref": payload.get("ref"),
|
||||||
|
}
|
||||||
|
if event == "pull_request":
|
||||||
|
action = payload.get("action")
|
||||||
|
if action not in ("opened", "synchronized", "reopened"):
|
||||||
|
raise AdapterError(f"pull_request action {action!r} is not a new candidate")
|
||||||
|
pull = payload.get("pull_request") or {}
|
||||||
|
head = (pull.get("head") or {}).get("sha")
|
||||||
|
base = (pull.get("base") or {}).get("sha")
|
||||||
|
if not isinstance(head, str) or not isinstance(base, str):
|
||||||
|
raise AdapterError("pull_request payload has no head/base SHA")
|
||||||
|
return {
|
||||||
|
"kind": "pull_request",
|
||||||
|
"repository": repository,
|
||||||
|
"head_sha": head.lower(),
|
||||||
|
"payload_base": base.lower(),
|
||||||
|
"number": pull.get("number"),
|
||||||
|
"action": action,
|
||||||
|
}
|
||||||
|
raise AdapterError(f"unsupported webhook event {event!r}; expected push or pull_request")
|
||||||
|
|
||||||
|
|
||||||
|
def aggregate_ci(statuses: list[dict], ci_hosts: list[str]) -> dict:
|
||||||
|
if not statuses:
|
||||||
|
return {"status": "pending", "url": None}
|
||||||
|
states = [str(item.get("status", "pending")) for item in statuses]
|
||||||
|
url = None
|
||||||
|
for item in statuses:
|
||||||
|
candidate = item.get("target_url") or ""
|
||||||
|
if isinstance(candidate, str) and candidate.startswith("https://"):
|
||||||
|
url = candidate
|
||||||
|
if any(state == "failure" or state == "error" for state in states):
|
||||||
|
return {"status": "failure", "url": url}
|
||||||
|
if all(state == "success" for state in states):
|
||||||
|
return {"status": "success", "url": url}
|
||||||
|
return {"status": "pending", "url": url}
|
||||||
|
|
||||||
|
|
||||||
|
def build_notification(
|
||||||
|
event: dict, ci: dict, accepted_revision: str, root_repository: str
|
||||||
|
) -> dict:
|
||||||
|
notify = load_notify()
|
||||||
|
if event["repository"] == root_repository:
|
||||||
|
kind = "root"
|
||||||
|
component = None
|
||||||
|
base_sha = accepted_revision
|
||||||
|
else:
|
||||||
|
allowlist = notify.repository_allowlist(accepted_revision)
|
||||||
|
component_record = allowlist.get(event["repository"])
|
||||||
|
if component_record is None:
|
||||||
|
raise AdapterError(
|
||||||
|
f"unknown repository {event['repository']!r}; allowlist: {sorted(allowlist)}"
|
||||||
|
)
|
||||||
|
kind = "component"
|
||||||
|
component = component_record["id"]
|
||||||
|
base_sha = component_record.get("sha")
|
||||||
|
if not isinstance(base_sha, str) or not base_sha:
|
||||||
|
raise AdapterError(
|
||||||
|
f"accepted graph has no pinned SHA for {component}; cannot verify a candidate"
|
||||||
|
)
|
||||||
|
notification = {
|
||||||
|
"schema": "marqdo.candidate-notification",
|
||||||
|
"schema_version": 1,
|
||||||
|
"repository": event["repository"],
|
||||||
|
"kind": kind,
|
||||||
|
"head_sha": event["head_sha"],
|
||||||
|
"base_sha": base_sha,
|
||||||
|
"ci": ci,
|
||||||
|
}
|
||||||
|
if component is not None:
|
||||||
|
notification["component"] = component
|
||||||
|
if event.get("number") is not None:
|
||||||
|
notification["pull_request"] = event["number"]
|
||||||
|
return notification
|
||||||
|
|
||||||
|
|
||||||
|
def verify_webhook(
|
||||||
|
raw: bytes,
|
||||||
|
event_name: str,
|
||||||
|
signature: str | None,
|
||||||
|
secret: str,
|
||||||
|
statuses: list[dict],
|
||||||
|
accepted: str,
|
||||||
|
state_path: Path,
|
||||||
|
ci_hosts: list[str] | None = None,
|
||||||
|
root_repository: str = DEFAULT_ROOT_REPOSITORY,
|
||||||
|
write_state: bool = True,
|
||||||
|
) -> dict:
|
||||||
|
event = parse_event(raw, event_name, signature, secret)
|
||||||
|
notify = load_notify()
|
||||||
|
accepted_revision = resolve_revision(notify, accepted)
|
||||||
|
ci = aggregate_ci(statuses, ci_hosts or [DEFAULT_CI_HOST])
|
||||||
|
notification = build_notification(event, ci, accepted_revision, root_repository)
|
||||||
|
try:
|
||||||
|
return notify.verify(
|
||||||
|
notification,
|
||||||
|
accepted,
|
||||||
|
state_path,
|
||||||
|
ci_hosts or [DEFAULT_CI_HOST],
|
||||||
|
root_repository,
|
||||||
|
write_state=write_state,
|
||||||
|
)
|
||||||
|
except notify.NotificationError as error:
|
||||||
|
return {"verified": False, "reason": str(error)}
|
||||||
|
|
||||||
|
|
||||||
|
def http_json(url: str, token: str, attempts: int = 3) -> object:
|
||||||
|
last: Exception | None = None
|
||||||
|
for attempt in range(attempts):
|
||||||
|
request = urllib.request.Request(
|
||||||
|
url,
|
||||||
|
headers={"Authorization": f"token {token}", "Accept": "application/json"},
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(request, timeout=30) as response:
|
||||||
|
return json.loads(response.read())
|
||||||
|
except urllib.error.HTTPError as error:
|
||||||
|
if error.code in (401, 403):
|
||||||
|
raise AdapterError(f"authorization rejected for {url}: HTTP {error.code}") from error
|
||||||
|
last = error
|
||||||
|
except (urllib.error.URLError, TimeoutError) as error:
|
||||||
|
last = error
|
||||||
|
if attempt + 1 < attempts:
|
||||||
|
time.sleep(min(2 ** attempt, 4) + random.random() * 0.2)
|
||||||
|
raise AdapterError(f"cannot read {url} after {attempts} attempts: {last}")
|
||||||
|
|
||||||
|
|
||||||
|
def fetch_statuses(api_base: str, repository: str, sha: str, token: str) -> list[dict]:
|
||||||
|
data = http_json(
|
||||||
|
f"{api_base}/repos/{repository}/commits/{sha}/statuses", token
|
||||||
|
)
|
||||||
|
return data if isinstance(data, list) else []
|
||||||
|
|
||||||
|
|
||||||
|
def list_open_prs(api_base: str, repository: str, token: str) -> list[dict]:
|
||||||
|
data = http_json(
|
||||||
|
f"{api_base}/repos/{repository}/pulls?state=open&limit=50", token
|
||||||
|
)
|
||||||
|
return data if isinstance(data, list) else []
|
||||||
|
|
||||||
|
|
||||||
|
def reconcile(
|
||||||
|
accepted: str,
|
||||||
|
state_path: Path,
|
||||||
|
repositories: list[str],
|
||||||
|
accepted_revision: str,
|
||||||
|
statuses_fetcher,
|
||||||
|
prs_fetcher,
|
||||||
|
ci_hosts: list[str] | None = None,
|
||||||
|
root_repository: str = DEFAULT_ROOT_REPOSITORY,
|
||||||
|
) -> dict:
|
||||||
|
notify = load_notify()
|
||||||
|
ci_hosts = ci_hosts or [DEFAULT_CI_HOST]
|
||||||
|
results = []
|
||||||
|
for repository in sorted(set(repositories)):
|
||||||
|
try:
|
||||||
|
pulls = prs_fetcher(repository)
|
||||||
|
except AdapterError as error:
|
||||||
|
results.append({"repository": repository, "status": "ERROR", "reason": str(error)})
|
||||||
|
continue
|
||||||
|
for pull in pulls:
|
||||||
|
head = ((pull.get("head") or {}).get("sha")) or ""
|
||||||
|
number = pull.get("number")
|
||||||
|
if len(head) != 40:
|
||||||
|
results.append(
|
||||||
|
{"repository": repository, "status": "ERROR", "reason": "PR has no head SHA"}
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
statuses = statuses_fetcher(repository, head)
|
||||||
|
ci = aggregate_ci(statuses, ci_hosts)
|
||||||
|
event = {
|
||||||
|
"kind": "pull_request",
|
||||||
|
"repository": repository,
|
||||||
|
"head_sha": head,
|
||||||
|
"payload_base": ((pull.get("base") or {}).get("sha")) or "",
|
||||||
|
"number": number,
|
||||||
|
}
|
||||||
|
notification = build_notification(
|
||||||
|
event, ci, accepted_revision, root_repository
|
||||||
|
)
|
||||||
|
plan = notify.verify(
|
||||||
|
notification,
|
||||||
|
accepted,
|
||||||
|
state_path,
|
||||||
|
ci_hosts,
|
||||||
|
root_repository,
|
||||||
|
write_state=True,
|
||||||
|
)
|
||||||
|
results.append(
|
||||||
|
{
|
||||||
|
"repository": repository,
|
||||||
|
"pull_request": number,
|
||||||
|
"head_sha": head,
|
||||||
|
"status": "VERIFIED",
|
||||||
|
"revalidate": plan["revalidate"],
|
||||||
|
"affected": plan["impact"]["affected"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
except notify.NotificationError as error:
|
||||||
|
message = str(error)
|
||||||
|
status = "DUPLICATE" if "duplicate/replay" in message else "REJECTED"
|
||||||
|
results.append(
|
||||||
|
{
|
||||||
|
"repository": repository,
|
||||||
|
"pull_request": number,
|
||||||
|
"head_sha": head,
|
||||||
|
"status": status,
|
||||||
|
"reason": message,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
"schema": "marqdo.candidate-reconcile",
|
||||||
|
"schema_version": 1,
|
||||||
|
"accepted": {"ref": accepted, "revision": accepted_revision},
|
||||||
|
"repositories": sorted(set(repositories)),
|
||||||
|
"results": results,
|
||||||
|
"verified": sum(1 for item in results if item["status"] == "VERIFIED"),
|
||||||
|
"pending": sum(
|
||||||
|
1 for item in results if item["status"] in ("DUPLICATE", "REJECTED", "ERROR")
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv: list[str]) -> int:
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
group = parser.add_mutually_exclusive_group(required=True)
|
||||||
|
group.add_argument("--webhook", help="raw webhook body file")
|
||||||
|
group.add_argument("--reconcile", action="store_true", help="recover lost notifications")
|
||||||
|
parser.add_argument("--event", default="push", help="X-Gitea-Event value")
|
||||||
|
parser.add_argument("--signature", default=None, help="X-Gitea-Signature value")
|
||||||
|
parser.add_argument("--secret-env", default="MARQDO_WEBHOOK_SECRET")
|
||||||
|
parser.add_argument("--statuses", default=None, help="JSON array of commit statuses")
|
||||||
|
parser.add_argument("--accepted", required=True)
|
||||||
|
parser.add_argument("--state", required=True)
|
||||||
|
parser.add_argument("--ci-host", action="append", default=None)
|
||||||
|
parser.add_argument("--root-repository", default=DEFAULT_ROOT_REPOSITORY)
|
||||||
|
parser.add_argument("--api-base", default="https://git.cflmy.cn/api/v1")
|
||||||
|
parser.add_argument("--token-env", default="MARQDO_GIT_TOKEN")
|
||||||
|
parser.add_argument("--out", default=None)
|
||||||
|
parser.add_argument("--json", action="store_true")
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
ci_hosts = args.ci_host or [DEFAULT_CI_HOST]
|
||||||
|
try:
|
||||||
|
if args.webhook:
|
||||||
|
secret = __import__("os").environ.get(args.secret_env, "")
|
||||||
|
raw = Path(args.webhook).read_bytes()
|
||||||
|
statuses = []
|
||||||
|
if args.statuses:
|
||||||
|
statuses = json.loads(Path(args.statuses).read_text())
|
||||||
|
plan = verify_webhook(
|
||||||
|
raw,
|
||||||
|
args.event,
|
||||||
|
args.signature,
|
||||||
|
secret,
|
||||||
|
statuses,
|
||||||
|
args.accepted,
|
||||||
|
Path(args.state),
|
||||||
|
ci_hosts,
|
||||||
|
args.root_repository,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
import os
|
||||||
|
|
||||||
|
token = os.environ.get(args.token_env, "")
|
||||||
|
if not token:
|
||||||
|
raise AdapterError(f"{args.token_env} is required for reconciliation")
|
||||||
|
notify = load_notify()
|
||||||
|
accepted_revision = resolve_revision(notify, args.accepted)
|
||||||
|
repositories = sorted(notify.repository_allowlist(accepted_revision)) + [
|
||||||
|
args.root_repository
|
||||||
|
]
|
||||||
|
plan = reconcile(
|
||||||
|
args.accepted,
|
||||||
|
Path(args.state),
|
||||||
|
repositories,
|
||||||
|
accepted_revision,
|
||||||
|
lambda repository, sha: fetch_statuses(
|
||||||
|
args.api_base, repository, sha, token
|
||||||
|
),
|
||||||
|
lambda repository: list_open_prs(args.api_base, repository, token),
|
||||||
|
ci_hosts,
|
||||||
|
args.root_repository,
|
||||||
|
)
|
||||||
|
except (AdapterError, json.JSONDecodeError, OSError) as error:
|
||||||
|
print(f"webhook-adapter: rejected: {error}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
text = json.dumps(plan, ensure_ascii=False, indent=2) + "\n"
|
||||||
|
if args.out:
|
||||||
|
Path(args.out).write_text(text)
|
||||||
|
if args.json:
|
||||||
|
print(text, end="")
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
f"{plan.get('schema')}: verified={plan.get('verified', 0)} "
|
||||||
|
f"pending={plan.get('pending', 0)}"
|
||||||
|
)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main(sys.argv[1:]))
|
||||||
+1
-1
Submodule stdlib/collections updated: 0851e1f8a0...f18eec7ada.
+1
-1
Submodule stdlib/data updated: e3c9488dca...6f79b1345d.
+1
-1
Submodule stdlib/fs updated: 3ef21c7de0...104741bca0.
+1
-1
Submodule stdlib/io updated: 945e76eed8...02d1ad172c.
+1
-1
Submodule stdlib/system updated: e1c4da4cc5...1561a6b7b6.
+1
-1
Submodule stdlib/text updated: 9f1e862953...5b5d3b67c3.
+1
-1
Submodule tests/conformance updated: 015ff8ac15...665c12e9b1.
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"schema": "marqdo.stdlib-test-case",
|
||||||
|
"schema_version": 1,
|
||||||
|
"name": "print-routing",
|
||||||
|
"file": "print-routing.mq.md",
|
||||||
|
"args": [],
|
||||||
|
"stdin": "",
|
||||||
|
"env": {},
|
||||||
|
"expected_stdout": "[\"文本\", 2, 1.5, [3, true], {a: 1, b: \"x\"}, None]\n[\"文本\", 2, 1.5, [3, true], {a: 1, b: \"x\"}, None]\nTable[名称 | 分数]{甲 | 87; 乙 | 92}\nTable[名称 | 分数]{甲 | 87; 乙 | 92}\n[Formula(\"a = 1\"), Code(\"text\", 9 bytes), FunctionRef(root:default::print-routing.mq.md::演示函数)]\n[Formula(\"a = 1\"), Code(\"text\", 9 bytes), FunctionRef(root:default::print-routing.mq.md::演示函数)]\n",
|
||||||
|
"expected_terminal": {
|
||||||
|
"type": "none"
|
||||||
|
},
|
||||||
|
"stdout_line_pairs": [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
[
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
[
|
||||||
|
4,
|
||||||
|
5
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,317 @@
|
|||||||
|
{
|
||||||
|
"schema": "marqdo.stdlib-test-case",
|
||||||
|
"schema_version": 1,
|
||||||
|
"name": "table-pure",
|
||||||
|
"file": "table.mq.md",
|
||||||
|
"args": [
|
||||||
|
"--mode",
|
||||||
|
"pure"
|
||||||
|
],
|
||||||
|
"stdin": "",
|
||||||
|
"env": {},
|
||||||
|
"expected_stdout": "",
|
||||||
|
"expected_terminal": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"header": [
|
||||||
|
"分数"
|
||||||
|
],
|
||||||
|
"rows": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"decimal": "87",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"decimal": "92",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"decimal": "71",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"header": [
|
||||||
|
"名称",
|
||||||
|
"分数"
|
||||||
|
],
|
||||||
|
"rows": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "甲"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "87",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "乙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "92",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"header": [
|
||||||
|
"名称",
|
||||||
|
"分数"
|
||||||
|
],
|
||||||
|
"rows": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "丙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "71",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "甲"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "87",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "乙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "92",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"header": [
|
||||||
|
"名称",
|
||||||
|
"分数"
|
||||||
|
],
|
||||||
|
"rows": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "甲"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "87",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "乙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "92",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "丙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "71",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "丁"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "65",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"header": [
|
||||||
|
"名称",
|
||||||
|
"分数"
|
||||||
|
],
|
||||||
|
"rows": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "甲"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "99",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "乙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "92",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "丙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "71",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"header": [
|
||||||
|
"名称",
|
||||||
|
"分数",
|
||||||
|
"名称",
|
||||||
|
"等级"
|
||||||
|
],
|
||||||
|
"rows": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "甲"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "87",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "甲"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "B"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "乙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "92",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "乙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "A"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entries": {
|
||||||
|
"a": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"decimal": "1",
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "3",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"decimal": "2",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "list"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "map"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"header": [
|
||||||
|
"名称",
|
||||||
|
"分数"
|
||||||
|
],
|
||||||
|
"rows": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "甲"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "87",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "乙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "92",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "丙"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decimal": "71",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"value": "| 名称 | 分数 |\n| --- | --- |\n| 甲 | 87 |\n| 乙 | 92 |\n| 丙 | 71 |"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "list"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
import:
|
||||||
|
io: "std:io"
|
||||||
|
---
|
||||||
|
|
||||||
|
## @exec 演示函数
|
||||||
|
|
||||||
|
`return 1`
|
||||||
|
|
||||||
|
## @exec main
|
||||||
|
|
||||||
|
### @knowledge 公式
|
||||||
|
|
||||||
|
$$a = 1$$
|
||||||
|
|
||||||
|
### @knowledge 代码
|
||||||
|
|
||||||
|
```text
|
||||||
|
print(1)
|
||||||
|
```
|
||||||
|
|
||||||
|
### @exec 主流程
|
||||||
|
|
||||||
|
**列表 = ["文本", 2, 1.5, [3, true], {a: 1, b: "x"}, None]**
|
||||||
|
|
||||||
|
> **io.写值(列表)**
|
||||||
|
|
||||||
|
> **打印(列表)**
|
||||||
|
|
||||||
|
**表格 = 表(["名称", "分数"], [["甲", 87], ["乙", 92]])**
|
||||||
|
|
||||||
|
> **io.写值(表格)**
|
||||||
|
|
||||||
|
> **打印(表格)**
|
||||||
|
|
||||||
|
**特殊 = [ref("#公式"), ref("#代码"), ref("#演示函数")]**
|
||||||
|
|
||||||
|
> **io.写值(特殊)**
|
||||||
|
|
||||||
|
> **打印(特殊)**
|
||||||
|
|
||||||
|
`return None`
|
||||||
@@ -0,0 +1,259 @@
|
|||||||
|
"""Candidate notification authorization contract tests (issue #3).
|
||||||
|
|
||||||
|
Fixtures are real temporary Git repositories: a root catalog with `.gitmodules`
|
||||||
|
and gitlinks, a component repository with two commits, and normalized
|
||||||
|
notifications. The verifier must refuse forged/replayed/stale/failed candidates
|
||||||
|
and never claim an auto-promotion action.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import importlib.util
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
IMPACT_SPEC = importlib.util.spec_from_file_location("impact", ROOT / "scripts/impact.py")
|
||||||
|
impact = importlib.util.module_from_spec(IMPACT_SPEC)
|
||||||
|
IMPACT_SPEC.loader.exec_module(impact)
|
||||||
|
NOTIFY_SPEC = importlib.util.spec_from_file_location(
|
||||||
|
"candidate_notify", ROOT / "scripts/candidate-notify.py"
|
||||||
|
)
|
||||||
|
notify = importlib.util.module_from_spec(NOTIFY_SPEC)
|
||||||
|
NOTIFY_SPEC.loader.exec_module(notify)
|
||||||
|
|
||||||
|
GIT_ENV = {
|
||||||
|
"GIT_AUTHOR_NAME": "test",
|
||||||
|
"GIT_AUTHOR_EMAIL": "test@example.invalid",
|
||||||
|
"GIT_COMMITTER_NAME": "test",
|
||||||
|
"GIT_COMMITTER_EMAIL": "test@example.invalid",
|
||||||
|
}
|
||||||
|
CI = {"status": "success", "url": "https://ci.cflmy.cn/repos/6/pipeline/1/1"}
|
||||||
|
|
||||||
|
|
||||||
|
def git(cwd, *args, check=True):
|
||||||
|
env = os.environ.copy()
|
||||||
|
env.update(GIT_ENV)
|
||||||
|
result = subprocess.run(["git", "-C", str(cwd), *args], capture_output=True, env=env)
|
||||||
|
if check and result.returncode != 0:
|
||||||
|
raise AssertionError(
|
||||||
|
f"git {' '.join(args)} failed: {result.stderr.decode(errors='replace')}"
|
||||||
|
)
|
||||||
|
return result.stdout.decode()
|
||||||
|
|
||||||
|
|
||||||
|
def init(path: Path) -> Path:
|
||||||
|
path.mkdir(parents=True, exist_ok=True)
|
||||||
|
git(path, "init", "-q")
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def write(path: Path, data: str) -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text(data)
|
||||||
|
|
||||||
|
|
||||||
|
def commit(repo: Path, message: str = "fixture") -> str:
|
||||||
|
git(repo, "add", "-A")
|
||||||
|
git(repo, "commit", "-q", "-m", message)
|
||||||
|
return git(repo, "rev-parse", "HEAD").strip()
|
||||||
|
|
||||||
|
|
||||||
|
def catalog(cli_sha_gitlink: bool = True) -> str:
|
||||||
|
return """[[component]]
|
||||||
|
id = "cli"
|
||||||
|
path = "cli"
|
||||||
|
kind = "core"
|
||||||
|
state = "active"
|
||||||
|
owner = "t"
|
||||||
|
scope = "s"
|
||||||
|
requires = []
|
||||||
|
checks_with = []
|
||||||
|
release = "base"
|
||||||
|
entry = "scripts/test.sh"
|
||||||
|
|
||||||
|
[[component]]
|
||||||
|
id = "std-text"
|
||||||
|
path = "stdlib/text"
|
||||||
|
kind = "stdlib"
|
||||||
|
state = "active"
|
||||||
|
owner = "t"
|
||||||
|
scope = "s"
|
||||||
|
requires = ["cli"]
|
||||||
|
checks_with = []
|
||||||
|
release = "base"
|
||||||
|
entry = "scripts/test.sh"
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
GITMODULES = """[submodule "cli"]
|
||||||
|
\tpath = cli
|
||||||
|
\turl = https://git.cflmy.cn/cflmy/marqdo-cli.git
|
||||||
|
[submodule "stdlib/text"]
|
||||||
|
\tpath = stdlib/text
|
||||||
|
\turl = https://git.cflmy.cn/cflmy/marqdo-std-text.git
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class NotifyTest(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.tmp = tempfile.TemporaryDirectory()
|
||||||
|
self.base = Path(self.tmp.name)
|
||||||
|
self.root = self.base / "root"
|
||||||
|
init(self.root)
|
||||||
|
write(self.root / "components.toml", catalog())
|
||||||
|
write(self.root / ".gitmodules", GITMODULES)
|
||||||
|
self.cli = init(self.root / "cli")
|
||||||
|
write(self.cli / "README.md", "cli")
|
||||||
|
self.cli_sha1 = commit(self.cli)
|
||||||
|
self.text = init(self.root / "stdlib/text")
|
||||||
|
write(self.text / "README.md", "text")
|
||||||
|
self.text_sha1 = commit(self.text)
|
||||||
|
git(self.root, "add", "components.toml", ".gitmodules")
|
||||||
|
git(self.root, "update-index", "--add", "--cacheinfo", f"160000,{self.cli_sha1},cli")
|
||||||
|
git(
|
||||||
|
self.root, "update-index", "--add", "--cacheinfo",
|
||||||
|
f"160000,{self.text_sha1},stdlib/text",
|
||||||
|
)
|
||||||
|
git(self.root, "commit", "-q", "-m", "accepted root")
|
||||||
|
self.accepted = git(self.root, "rev-parse", "HEAD").strip()
|
||||||
|
# Candidate component commit after the accepted root was frozen.
|
||||||
|
write(self.cli / "README.md", "cli v2")
|
||||||
|
self.cli_sha2 = commit(self.cli, "candidate")
|
||||||
|
# Candidate root commit moving the cli gitlink.
|
||||||
|
git(self.root, "update-index", "--cacheinfo", f"160000,{self.cli_sha2},cli")
|
||||||
|
git(self.root, "commit", "-q", "-m", "candidate root")
|
||||||
|
self.candidate_root = git(self.root, "rev-parse", "HEAD").strip()
|
||||||
|
self.notify_original_root = notify.ROOT
|
||||||
|
self.impact_original_root = impact.ROOT
|
||||||
|
notify.ROOT = self.root
|
||||||
|
impact.ROOT = self.root
|
||||||
|
self.state = self.base / "state.json"
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
notify.ROOT = self.notify_original_root
|
||||||
|
impact.ROOT = self.impact_original_root
|
||||||
|
self.tmp.cleanup()
|
||||||
|
|
||||||
|
def notification(self, **overrides) -> Path:
|
||||||
|
data = {
|
||||||
|
"schema": "marqdo.candidate-notification",
|
||||||
|
"schema_version": 1,
|
||||||
|
"repository": "cflmy/marqdo-cli",
|
||||||
|
"kind": "component",
|
||||||
|
"component": "cli",
|
||||||
|
"head_sha": self.cli_sha2,
|
||||||
|
"base_sha": self.cli_sha1,
|
||||||
|
"ci": dict(CI),
|
||||||
|
"pull_request": 17,
|
||||||
|
}
|
||||||
|
data.update(overrides)
|
||||||
|
path = self.base / "notification.json"
|
||||||
|
path.write_text(json.dumps(data))
|
||||||
|
return path
|
||||||
|
|
||||||
|
def run_verify(self, path: Path, accepted: str | None = None, write_state: bool = True):
|
||||||
|
try:
|
||||||
|
return notify.verify(
|
||||||
|
json.loads(path.read_text()),
|
||||||
|
accepted or self.accepted,
|
||||||
|
self.state,
|
||||||
|
["ci.cflmy.cn"],
|
||||||
|
"cflmy/marqdo",
|
||||||
|
write_state=write_state,
|
||||||
|
)
|
||||||
|
except notify.NotificationError as error:
|
||||||
|
return {"verified": False, "reason": str(error)}
|
||||||
|
|
||||||
|
def test_component_candidate_verified_with_consumers_and_no_auto_promotion(self):
|
||||||
|
plan = self.run_verify(self.notification())
|
||||||
|
self.assertTrue(plan["verified"])
|
||||||
|
self.assertIn("std-text", plan["impact"]["affected"])
|
||||||
|
self.assertFalse(plan["actions"]["auto_promote"])
|
||||||
|
self.assertFalse(plan["actions"]["auto_merge"])
|
||||||
|
self.assertTrue(plan["actions"]["requires_human_review"])
|
||||||
|
self.assertTrue(self.state.is_file())
|
||||||
|
|
||||||
|
def test_unknown_repository_is_rejected(self):
|
||||||
|
plan = self.run_verify(self.notification(repository="cflmy/unknown"))
|
||||||
|
self.assertFalse(plan["verified"])
|
||||||
|
self.assertIn("unknown repository", plan["reason"])
|
||||||
|
|
||||||
|
def test_failed_ci_is_rejected(self):
|
||||||
|
plan = self.run_verify(self.notification(ci={"status": "failure", "url": CI["url"]}))
|
||||||
|
self.assertFalse(plan["verified"])
|
||||||
|
self.assertIn("CI status", plan["reason"])
|
||||||
|
|
||||||
|
def test_non_allowlisted_ci_host_is_rejected(self):
|
||||||
|
plan = self.run_verify(
|
||||||
|
self.notification(ci={"status": "success", "url": "https://evil.example/p/1"})
|
||||||
|
)
|
||||||
|
self.assertFalse(plan["verified"])
|
||||||
|
self.assertIn("CI URL", plan["reason"])
|
||||||
|
|
||||||
|
def test_unreachable_commit_is_rejected(self):
|
||||||
|
plan = self.run_verify(self.notification(head_sha="0" * 40))
|
||||||
|
self.assertFalse(plan["verified"])
|
||||||
|
self.assertIn("not reachable", plan["reason"])
|
||||||
|
|
||||||
|
def test_stale_base_sha_is_rejected(self):
|
||||||
|
plan = self.run_verify(
|
||||||
|
self.notification(base_sha=self.text_sha1)
|
||||||
|
)
|
||||||
|
self.assertFalse(plan["verified"])
|
||||||
|
self.assertIn("base_sha is stale", plan["reason"])
|
||||||
|
|
||||||
|
def test_replay_is_rejected_and_new_baseline_requires_revalidation(self):
|
||||||
|
first = self.run_verify(self.notification())
|
||||||
|
self.assertTrue(first["verified"])
|
||||||
|
replay = self.run_verify(self.notification())
|
||||||
|
self.assertFalse(replay["verified"])
|
||||||
|
self.assertIn("duplicate/replay", replay["reason"])
|
||||||
|
# A new accepted baseline that still pins the same component SHA (here
|
||||||
|
# another component moved) must re-validate the same candidate.
|
||||||
|
write(self.text / "README.md", "text v2")
|
||||||
|
text_sha2 = commit(self.text, "text candidate")
|
||||||
|
git(self.root, "update-index", "--cacheinfo", f"160000,{self.cli_sha1},cli")
|
||||||
|
git(self.root, "update-index", "--cacheinfo", f"160000,{text_sha2},stdlib/text")
|
||||||
|
git(self.root, "commit", "-q", "-m", "baseline 2")
|
||||||
|
baseline2 = git(self.root, "rev-parse", "HEAD").strip()
|
||||||
|
revalidated = self.run_verify(self.notification(), accepted=baseline2)
|
||||||
|
self.assertTrue(revalidated["verified"], revalidated.get("reason"))
|
||||||
|
self.assertTrue(revalidated["revalidate"])
|
||||||
|
|
||||||
|
def test_root_candidate_uses_union_graph_diff(self):
|
||||||
|
plan = self.run_verify(
|
||||||
|
self.notification(
|
||||||
|
repository="cflmy/marqdo",
|
||||||
|
kind="root",
|
||||||
|
component=None,
|
||||||
|
head_sha=self.candidate_root,
|
||||||
|
base_sha=self.accepted,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.assertTrue(plan["verified"])
|
||||||
|
self.assertEqual([c["id"] for c in plan["impact"]["changed"]], ["cli"])
|
||||||
|
self.assertIn("std-text", plan["impact"]["affected"])
|
||||||
|
|
||||||
|
def test_root_repository_must_be_named_explicitly(self):
|
||||||
|
plan = self.run_verify(
|
||||||
|
self.notification(
|
||||||
|
repository="cflmy/marqdo-cli",
|
||||||
|
kind="root",
|
||||||
|
head_sha=self.candidate_root,
|
||||||
|
base_sha=self.accepted,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.assertFalse(plan["verified"])
|
||||||
|
self.assertIn("unknown root repository", plan["reason"])
|
||||||
|
|
||||||
|
def test_state_is_not_written_in_dry_run(self):
|
||||||
|
plan = self.run_verify(self.notification(), write_state=False)
|
||||||
|
self.assertTrue(plan["verified"])
|
||||||
|
self.assertFalse(self.state.exists())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,274 @@
|
|||||||
|
"""Recursive impact analysis contract tests (ECO-02 / issue #7).
|
||||||
|
|
||||||
|
Builds real temporary Git repositories for two root candidates and asserts the
|
||||||
|
ordering required by the development contract: changed leaves, reverse
|
||||||
|
`requires` closure over the union graph, parent domains, then `checks_with`
|
||||||
|
fixed point; undetermined scope widens to the full candidate instead of being
|
||||||
|
skipped.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import importlib.util
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
SCRIPT = Path(__file__).resolve().parents[2] / "scripts" / "impact.py"
|
||||||
|
SPEC = importlib.util.spec_from_file_location("impact", SCRIPT)
|
||||||
|
impact = importlib.util.module_from_spec(SPEC)
|
||||||
|
SPEC.loader.exec_module(impact)
|
||||||
|
|
||||||
|
GIT_ENV = {
|
||||||
|
"GIT_AUTHOR_NAME": "test",
|
||||||
|
"GIT_AUTHOR_EMAIL": "test@example.invalid",
|
||||||
|
"GIT_COMMITTER_NAME": "test",
|
||||||
|
"GIT_COMMITTER_EMAIL": "test@example.invalid",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def git(cwd, *args, check=True):
|
||||||
|
env = os.environ.copy()
|
||||||
|
env.update(GIT_ENV)
|
||||||
|
result = subprocess.run(
|
||||||
|
["git", "-C", str(cwd), *args], capture_output=True, env=env
|
||||||
|
)
|
||||||
|
if check and result.returncode != 0:
|
||||||
|
raise AssertionError(
|
||||||
|
f"git {' '.join(args)} failed: {result.stderr.decode(errors='replace')}"
|
||||||
|
)
|
||||||
|
return result.stdout.decode()
|
||||||
|
|
||||||
|
|
||||||
|
def init(path: Path) -> Path:
|
||||||
|
path.mkdir(parents=True, exist_ok=True)
|
||||||
|
git(path, "init", "-q")
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def write(path: Path, data) -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_bytes(data if isinstance(data, bytes) else data.encode())
|
||||||
|
|
||||||
|
|
||||||
|
def commit(repo: Path, message: str = "fixture") -> str:
|
||||||
|
git(repo, "add", "-A")
|
||||||
|
git(repo, "commit", "-q", "-m", message)
|
||||||
|
return git(repo, "rev-parse", "HEAD").strip()
|
||||||
|
|
||||||
|
|
||||||
|
def component(**fields) -> str:
|
||||||
|
lines = ["[[component]]"]
|
||||||
|
for key, value in fields.items():
|
||||||
|
if isinstance(value, list):
|
||||||
|
rendered = "[" + ", ".join(f'"{item}"' for item in value) + "]"
|
||||||
|
else:
|
||||||
|
rendered = f'"{value}"'
|
||||||
|
lines.append(f"{key} = {rendered}")
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def catalog(*components: str) -> str:
|
||||||
|
return "\n\n".join(components) + "\n"
|
||||||
|
|
||||||
|
|
||||||
|
def leaf(base: Path, name: str, files: dict[str, str]) -> str:
|
||||||
|
repo = init(base / name)
|
||||||
|
for relative, data in files.items():
|
||||||
|
write(repo / relative, data)
|
||||||
|
return commit(repo)
|
||||||
|
|
||||||
|
|
||||||
|
def root_repo(
|
||||||
|
path: Path, catalog_text: str, links: dict[str, str], urls: dict[str, str] | None = None
|
||||||
|
) -> str:
|
||||||
|
init(path)
|
||||||
|
write(path / "components.toml", catalog_text)
|
||||||
|
if urls:
|
||||||
|
modules = ["[submodule \"x\"]"]
|
||||||
|
lines = []
|
||||||
|
for link_path, url in urls.items():
|
||||||
|
lines.extend([f"\tpath = {link_path}", f"\turl = {url}"])
|
||||||
|
write(path / ".gitmodules", "\n".join(modules + lines) + "\n")
|
||||||
|
git(path, "add", ".gitmodules")
|
||||||
|
git(path, "add", "components.toml")
|
||||||
|
for link_path, sha in links.items():
|
||||||
|
git(path, "update-index", "--add", "--cacheinfo", f"160000,{sha},{link_path}")
|
||||||
|
git(path, "commit", "-q", "-m", "root fixture")
|
||||||
|
return git(path, "rev-parse", "HEAD").strip()
|
||||||
|
|
||||||
|
|
||||||
|
COMPONENTS_V1 = catalog(
|
||||||
|
component(id="cli", path="cli", kind="core", state="active", owner="t", scope="s",
|
||||||
|
requires=[], checks_with=[], release="base"),
|
||||||
|
component(id="std-core", path="stdlib/core", kind="stdlib", state="active", owner="t",
|
||||||
|
scope="s", requires=["cli"], checks_with=[], release="base"),
|
||||||
|
component(id="std-text", path="stdlib/text", kind="stdlib", state="active", owner="t",
|
||||||
|
scope="s", requires=["cli", "std-core"], checks_with=["probe"], release="base"),
|
||||||
|
component(id="probe", path="tools/probe", kind="tool", state="active", owner="t",
|
||||||
|
scope="s", requires=["cli"], checks_with=["std-text"], release="optional"),
|
||||||
|
component(id="tool", path="tools/tool", kind="tool", state="active", owner="t",
|
||||||
|
scope="s", requires=["cli"], checks_with=[], release="optional"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ImpactTest(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.tmp = tempfile.TemporaryDirectory()
|
||||||
|
self.base = Path(self.tmp.name)
|
||||||
|
self.root = self.base / "root"
|
||||||
|
self.original_root = impact.ROOT
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
impact.ROOT = self.original_root
|
||||||
|
self.tmp.cleanup()
|
||||||
|
|
||||||
|
def make_tree(self, catalog_text: str, leaves: dict[str, str]) -> str:
|
||||||
|
return root_repo(self.root, catalog_text, {path: leaves[name] for name, path in {
|
||||||
|
"cli": "cli", "std-core": "stdlib/core", "std-text": "stdlib/text",
|
||||||
|
"probe": "tools/probe", "tool": "tools/tool",
|
||||||
|
}.items() if name in leaves})
|
||||||
|
|
||||||
|
def leaf_shas(self):
|
||||||
|
return {
|
||||||
|
"cli": leaf(self.base, "cli", {"README.md": "cli"}),
|
||||||
|
"std-core": leaf(self.base, "core", {"modules/core.mq.md": "# core\n"}),
|
||||||
|
"std-text": leaf(self.base, "text", {"modules/text.mq.md": "# text\n"}),
|
||||||
|
"probe": leaf(self.base, "probe", {"README.md": "probe"}),
|
||||||
|
"tool": leaf(self.base, "tool", {"README.md": "tool"}),
|
||||||
|
}
|
||||||
|
|
||||||
|
def analyze(self, first: str, second: str):
|
||||||
|
impact.ROOT = self.root
|
||||||
|
return impact.analyze(first, second)
|
||||||
|
|
||||||
|
def test_changed_leaf_closes_over_requires_then_checks_with(self):
|
||||||
|
leaves = self.leaf_shas()
|
||||||
|
first = self.make_tree(COMPONENTS_V1, leaves)
|
||||||
|
leaves["std-core"] = leaf(self.base, "core2", {"modules/core.mq.md": "# core v2\n"})
|
||||||
|
second = root_repo(
|
||||||
|
self.root,
|
||||||
|
COMPONENTS_V1,
|
||||||
|
{
|
||||||
|
"cli": leaves["cli"],
|
||||||
|
"stdlib/core": leaves["std-core"],
|
||||||
|
"stdlib/text": leaves["std-text"],
|
||||||
|
"tools/probe": leaves["probe"],
|
||||||
|
"tools/tool": leaves["tool"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
report = self.analyze(first, second)
|
||||||
|
self.assertEqual(
|
||||||
|
[(c["id"], c["reason"]) for c in report["changed"]],
|
||||||
|
[("std-core", "sha")],
|
||||||
|
)
|
||||||
|
self.assertEqual(report["affected"], ["probe", "std-core", "std-text"])
|
||||||
|
self.assertEqual(report["checks_with"], ["probe"])
|
||||||
|
self.assertNotIn("tool", report["affected"])
|
||||||
|
|
||||||
|
def test_removed_component_and_its_checks_with_partner_are_affected(self):
|
||||||
|
leaves = self.leaf_shas()
|
||||||
|
first = self.make_tree(COMPONENTS_V1, leaves)
|
||||||
|
without_text = catalog(
|
||||||
|
component(id="cli", path="cli", kind="core", state="active", owner="t",
|
||||||
|
scope="s", requires=[], checks_with=[], release="base"),
|
||||||
|
component(id="std-core", path="stdlib/core", kind="stdlib", state="active",
|
||||||
|
owner="t", scope="s", requires=["cli"], checks_with=[], release="base"),
|
||||||
|
component(id="probe", path="tools/probe", kind="tool", state="active", owner="t",
|
||||||
|
scope="s", requires=["cli"], checks_with=["std-text"], release="optional"),
|
||||||
|
component(id="tool", path="tools/tool", kind="tool", state="active", owner="t",
|
||||||
|
scope="s", requires=["cli"], checks_with=[], release="optional"),
|
||||||
|
)
|
||||||
|
second = root_repo(
|
||||||
|
self.root,
|
||||||
|
without_text,
|
||||||
|
{
|
||||||
|
"cli": leaves["cli"],
|
||||||
|
"stdlib/core": leaves["std-core"],
|
||||||
|
"tools/probe": leaves["probe"],
|
||||||
|
"tools/tool": leaves["tool"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
report = self.analyze(first, second)
|
||||||
|
self.assertIn({"id": "std-text", "reason": "removed"}, report["changed"])
|
||||||
|
self.assertIn("probe", report["affected"])
|
||||||
|
|
||||||
|
def test_dependency_change_is_reported_and_widens_scope(self):
|
||||||
|
leaves = self.leaf_shas()
|
||||||
|
first = self.make_tree(COMPONENTS_V1, leaves)
|
||||||
|
changed_text = COMPONENTS_V1.replace(
|
||||||
|
'requires = ["cli", "std-core"]', 'requires = ["cli", "std-core", "tool"]'
|
||||||
|
)
|
||||||
|
second = self.make_tree(changed_text, leaves)
|
||||||
|
report = self.analyze(first, second)
|
||||||
|
self.assertEqual(
|
||||||
|
[(c["id"], c["reason"]) for c in report["changed"]],
|
||||||
|
[("std-text", "dependencies")],
|
||||||
|
)
|
||||||
|
self.assertIn("std-text", report["affected"])
|
||||||
|
|
||||||
|
def test_domain_gitlink_change_expands_to_child_identity(self):
|
||||||
|
child = init(self.root / "extensions/web")
|
||||||
|
write(child / "components.toml", catalog(
|
||||||
|
component(id="web-design", path="design", kind="stdlib", state="planned",
|
||||||
|
owner="t", scope="s", requires=["cli"], checks_with=[], release="base"),
|
||||||
|
))
|
||||||
|
design = leaf(self.base, "design", {"index.mq.md": "# design v1\n"})
|
||||||
|
git(child, "add", "components.toml")
|
||||||
|
git(child, "update-index", "--add", "--cacheinfo", f"160000,{design},design")
|
||||||
|
git(child, "commit", "-q", "-m", "domain v1")
|
||||||
|
domain_v1 = git(child, "rev-parse", "HEAD").strip()
|
||||||
|
root_catalog = catalog(
|
||||||
|
component(id="cli", path="cli", kind="core", state="active", owner="t",
|
||||||
|
scope="s", requires=[], checks_with=[], release="base"),
|
||||||
|
component(id="web", path="extensions/web", kind="domain", state="planned",
|
||||||
|
owner="t", scope="s", requires=[], checks_with=[], release="none"),
|
||||||
|
)
|
||||||
|
first = root_repo(
|
||||||
|
self.root,
|
||||||
|
root_catalog,
|
||||||
|
{"cli": leaf(self.base, "cli2", {"README.md": "cli"}), "extensions/web": domain_v1},
|
||||||
|
{"extensions/web": "https://git.example.invalid/web.git"},
|
||||||
|
)
|
||||||
|
design_v2 = leaf(self.base, "design2", {"index.mq.md": "# design v2\n"})
|
||||||
|
git(child, "update-index", "--cacheinfo", f"160000,{design_v2},design")
|
||||||
|
git(child, "commit", "-q", "-m", "domain v2")
|
||||||
|
domain_v2 = git(child, "rev-parse", "HEAD").strip()
|
||||||
|
second = root_repo(
|
||||||
|
self.root,
|
||||||
|
root_catalog,
|
||||||
|
{"cli": leaf(self.base, "cli3", {"README.md": "cli"}), "extensions/web": domain_v2},
|
||||||
|
{"extensions/web": "https://git.example.invalid/web.git"},
|
||||||
|
)
|
||||||
|
report = self.analyze(first, second)
|
||||||
|
self.assertIn("web", [c["id"] for c in report["changed"]])
|
||||||
|
self.assertIn("web-design", [c["id"] for c in report["changed"]])
|
||||||
|
self.assertIn("web-design", report["affected"])
|
||||||
|
|
||||||
|
def test_unexpandable_domain_widens_to_full_scope(self):
|
||||||
|
root_catalog = catalog(
|
||||||
|
component(id="cli", path="cli", kind="core", state="active", owner="t",
|
||||||
|
scope="s", requires=[], checks_with=[], release="base"),
|
||||||
|
component(id="web", path="extensions/web", kind="domain", state="planned",
|
||||||
|
owner="t", scope="s", requires=[], checks_with=[], release="none"),
|
||||||
|
)
|
||||||
|
cli = leaf(self.base, "cli4", {"README.md": "cli"})
|
||||||
|
first = root_repo(
|
||||||
|
self.root, root_catalog,
|
||||||
|
{"cli": cli, "extensions/web": leaf(self.base, "web1", {"README.md": "web"})},
|
||||||
|
{"extensions/web": "https://git.example.invalid/web.git"},
|
||||||
|
)
|
||||||
|
second = root_repo(
|
||||||
|
self.root, root_catalog,
|
||||||
|
{"cli": cli, "extensions/web": leaf(self.base, "web2", {"README.md": "web2"})},
|
||||||
|
{"extensions/web": "https://git.example.invalid/web.git"},
|
||||||
|
)
|
||||||
|
# The root fixture points at a plain repository without a components.toml.
|
||||||
|
report = self.analyze(first, second)
|
||||||
|
self.assertTrue(report["unverified"])
|
||||||
|
self.assertEqual(report["fallback"], "full")
|
||||||
|
self.assertEqual(report["affected"], ["cli", "web"])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
"""Repository development conventions gate tests (docs/REPOSITORY-CONVENTIONS.md)."""
|
||||||
|
|
||||||
|
import importlib.util
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
SPEC = importlib.util.spec_from_file_location(
|
||||||
|
"repo_conventions", ROOT / "scripts" / "check-repo-conventions.py"
|
||||||
|
)
|
||||||
|
conventions = importlib.util.module_from_spec(SPEC)
|
||||||
|
SPEC.loader.exec_module(conventions)
|
||||||
|
|
||||||
|
MARKER = conventions.MARKER
|
||||||
|
URL = conventions.CONVENTIONS_URL
|
||||||
|
|
||||||
|
|
||||||
|
def write(path: Path, text: str) -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text(text)
|
||||||
|
|
||||||
|
|
||||||
|
def agents(role: str) -> str:
|
||||||
|
return f"""{MARKER}
|
||||||
|
# AGENTS.md — {role}
|
||||||
|
|
||||||
|
全局规范唯一来源:{URL}
|
||||||
|
本文件只写本仓边界,不复制全局规范或合同正文。
|
||||||
|
|
||||||
|
## 本仓定位
|
||||||
|
|
||||||
|
catalog 角色 `{role}`;只在本仓职责范围内修改,先开本仓工单。
|
||||||
|
本仓拥有自己的实现、测试与制品;不拥有其它仓的实现、合同或调度。
|
||||||
|
|
||||||
|
## 必做 / 禁止
|
||||||
|
|
||||||
|
- 必做:真实 CLI/制品验证、固定 SHA/摘要、证据记录、未运行写 UNVERIFIED。
|
||||||
|
- 禁止:复制 parser/实现/合同;依赖父仓或兄弟仓 checkout;第二 catalog/manifest;伪造 PASS;提交密钥。
|
||||||
|
- 禁止:自动 tag/release/合并;跨仓变更必须走 C2 → B2 → A2 晋升。
|
||||||
|
|
||||||
|
## 构建与证据
|
||||||
|
|
||||||
|
CI 入口非交互、失败非零、不打印秘密;证据含 SHA、制品摘要、平台、命令、退出码、日志。
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class RepoConventionsTest(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.tmp = tempfile.TemporaryDirectory()
|
||||||
|
self.root = Path(self.tmp.name)
|
||||||
|
write(self.root / "AGENTS.md", f"# 根\n\n防膨胀规则见 docs/REPOSITORY-CONVENTIONS.md\n")
|
||||||
|
write(self.root / "docs/REPOSITORY-CONVENTIONS.md", "规则")
|
||||||
|
write(self.root / ".gitmodules", "")
|
||||||
|
write(
|
||||||
|
self.root / "components.toml",
|
||||||
|
"""[[component]]
|
||||||
|
id = "cli"
|
||||||
|
path = "cli"
|
||||||
|
kind = "core"
|
||||||
|
state = "active"
|
||||||
|
owner = "t"
|
||||||
|
scope = "s"
|
||||||
|
requires = []
|
||||||
|
checks_with = []
|
||||||
|
release = "base"
|
||||||
|
entry = "scripts/ci.sh"
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
write(self.root / "cli/README.md", "x" * 200)
|
||||||
|
write(self.root / "cli/AGENTS.md", agents("cli"))
|
||||||
|
write(self.root / "cli/scripts/ci.sh", "#!/bin/sh\n")
|
||||||
|
write(
|
||||||
|
self.root / ".gitmodules",
|
||||||
|
'[submodule "cli"]\n\tpath = cli\n\turl = https://git.cflmy.cn/cflmy/marqdo-cli.git\n',
|
||||||
|
)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.tmp.cleanup()
|
||||||
|
|
||||||
|
def test_active_repository_with_required_files_passes(self):
|
||||||
|
self.assertEqual(conventions.check(self.root), [])
|
||||||
|
|
||||||
|
def test_missing_agents_or_marker_fails(self):
|
||||||
|
(self.root / "cli/AGENTS.md").unlink()
|
||||||
|
self.assertTrue(any("AGENTS.md missing" in item for item in conventions.check(self.root)))
|
||||||
|
write(self.root / "cli/AGENTS.md", agents("cli").replace(MARKER, ""))
|
||||||
|
self.assertTrue(
|
||||||
|
any("lacks `<!-- marqdo:repo-conventions v1 -->`" in item for item in conventions.check(self.root))
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_active_entry_and_readme_are_required(self):
|
||||||
|
(self.root / "cli/README.md").unlink()
|
||||||
|
(self.root / "cli/scripts/ci.sh").unlink()
|
||||||
|
errors = conventions.check(self.root)
|
||||||
|
self.assertTrue(any("README.md missing" in item for item in errors))
|
||||||
|
self.assertTrue(any("entry file missing" in item for item in errors))
|
||||||
|
|
||||||
|
def test_planned_component_must_not_declare_entry(self):
|
||||||
|
text = (self.root / "components.toml").read_text().replace(
|
||||||
|
'state = "active"', 'state = "planned"'
|
||||||
|
)
|
||||||
|
text = text.replace('entry = "scripts/ci.sh"', 'entry = "scripts/ci.sh"')
|
||||||
|
write(self.root / "components.toml", text)
|
||||||
|
self.assertTrue(
|
||||||
|
any("planned component must not declare entry" in item for item in conventions.check(self.root))
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_leaf_repository_must_not_own_second_catalog_or_submodules(self):
|
||||||
|
write(self.root / "cli/components.toml", "[[component]]\n")
|
||||||
|
write(self.root / "cli/.gitmodules", "")
|
||||||
|
errors = conventions.check(self.root)
|
||||||
|
self.assertTrue(any("leaf component must not own components.toml" in item for item in errors))
|
||||||
|
self.assertTrue(any("leaf component must not own .gitmodules" in item for item in errors))
|
||||||
|
|
||||||
|
def test_domain_child_must_not_be_registered_in_root_catalog(self):
|
||||||
|
write(
|
||||||
|
self.root / "components.toml",
|
||||||
|
(self.root / "components.toml").read_text()
|
||||||
|
+ """
|
||||||
|
[[component]]
|
||||||
|
id = "web"
|
||||||
|
path = "extensions/web"
|
||||||
|
kind = "domain"
|
||||||
|
state = "active"
|
||||||
|
owner = "t"
|
||||||
|
scope = "d"
|
||||||
|
requires = []
|
||||||
|
checks_with = []
|
||||||
|
release = "none"
|
||||||
|
entry = "scripts/domain.sh"
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
write(self.root / "extensions/web/README.md", "x" * 200)
|
||||||
|
write(self.root / "extensions/web/AGENTS.md", agents("web"))
|
||||||
|
write(self.root / "extensions/web/scripts/domain.sh", "#!/bin/sh\n")
|
||||||
|
write(
|
||||||
|
self.root / "extensions/web/components.toml",
|
||||||
|
"""[[component]]
|
||||||
|
id = "web-design"
|
||||||
|
path = "design"
|
||||||
|
kind = "extension"
|
||||||
|
state = "active"
|
||||||
|
owner = "t"
|
||||||
|
scope = "d"
|
||||||
|
requires = ["cli"]
|
||||||
|
checks_with = []
|
||||||
|
release = "optional"
|
||||||
|
entry = "scripts/ci.sh"
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
write(self.root / "extensions/web/design/README.md", "x" * 200)
|
||||||
|
write(self.root / "extensions/web/design/AGENTS.md", agents("web-design"))
|
||||||
|
write(self.root / "extensions/web/design/scripts/ci.sh", "#!/bin/sh\n")
|
||||||
|
write(
|
||||||
|
self.root / ".gitmodules",
|
||||||
|
(self.root / ".gitmodules").read_text()
|
||||||
|
+ '[submodule "web"]\n\tpath = extensions/web\n\turl = https://git.cflmy.cn/cflmy/marqdo-ext-web.git\n',
|
||||||
|
)
|
||||||
|
self.assertEqual(conventions.check(self.root), [])
|
||||||
|
write(
|
||||||
|
self.root / "components.toml",
|
||||||
|
(self.root / "components.toml").read_text()
|
||||||
|
+ """
|
||||||
|
[[component]]
|
||||||
|
id = "web-design-dup"
|
||||||
|
path = "extensions/web/design"
|
||||||
|
kind = "extension"
|
||||||
|
state = "planned"
|
||||||
|
owner = "t"
|
||||||
|
scope = "d"
|
||||||
|
requires = ["cli"]
|
||||||
|
checks_with = []
|
||||||
|
release = "optional"
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
any("also registered in the root catalog" in item for item in conventions.check(self.root))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,257 @@
|
|||||||
|
"""Trusted webhook adapter and reconciliation tests (issue #3 / #10 gap).
|
||||||
|
|
||||||
|
The fixtures are real temporary Git repositories. Webhook bodies are signed with
|
||||||
|
a test secret; the adapter must refuse tampered bodies, unknown repositories,
|
||||||
|
failed CI and replayed candidates, and reconciliation must recover a candidate
|
||||||
|
whose fast notification was lost while remaining idempotent.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import hmac
|
||||||
|
import importlib.util
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
ADAPTER_SPEC = importlib.util.spec_from_file_location(
|
||||||
|
"marqdo_webhook_adapter", ROOT / "scripts" / "webhook-adapter.py"
|
||||||
|
)
|
||||||
|
adapter = importlib.util.module_from_spec(ADAPTER_SPEC)
|
||||||
|
ADAPTER_SPEC.loader.exec_module(adapter)
|
||||||
|
|
||||||
|
GIT_ENV = {
|
||||||
|
"GIT_AUTHOR_NAME": "test",
|
||||||
|
"GIT_AUTHOR_EMAIL": "test@example.invalid",
|
||||||
|
"GIT_COMMITTER_NAME": "test",
|
||||||
|
"GIT_COMMITTER_EMAIL": "test@example.invalid",
|
||||||
|
}
|
||||||
|
SECRET = "test-webhook-secret"
|
||||||
|
CI_URL = "https://ci.cflmy.cn/repos/1/pipeline/7/1"
|
||||||
|
CATALOG = """[[component]]
|
||||||
|
id = "cli"
|
||||||
|
path = "cli"
|
||||||
|
kind = "core"
|
||||||
|
state = "active"
|
||||||
|
owner = "t"
|
||||||
|
scope = "s"
|
||||||
|
requires = []
|
||||||
|
checks_with = []
|
||||||
|
release = "base"
|
||||||
|
entry = "scripts/test.sh"
|
||||||
|
"""
|
||||||
|
GITMODULES = """[submodule "cli"]
|
||||||
|
\tpath = cli
|
||||||
|
\turl = https://git.cflmy.cn/cflmy/marqdo-cli.git
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def git(cwd, *args):
|
||||||
|
env = os.environ.copy()
|
||||||
|
env.update(GIT_ENV)
|
||||||
|
result = subprocess.run(["git", "-C", str(cwd), *args], capture_output=True, env=env)
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise AssertionError(f"git {' '.join(args)}: {result.stderr.decode(errors='replace')}")
|
||||||
|
return result.stdout.decode()
|
||||||
|
|
||||||
|
|
||||||
|
def commit(repo, message="fixture"):
|
||||||
|
git(repo, "add", "-A")
|
||||||
|
git(repo, "commit", "-q", "-m", message)
|
||||||
|
return git(repo, "rev-parse", "HEAD").strip()
|
||||||
|
|
||||||
|
|
||||||
|
def write(path, text):
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text(text)
|
||||||
|
|
||||||
|
|
||||||
|
class WebhookAdapterTest(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.tmp = tempfile.TemporaryDirectory()
|
||||||
|
self.base = Path(self.tmp.name)
|
||||||
|
self.root = self.base / "root"
|
||||||
|
self.root.mkdir()
|
||||||
|
git(self.root, "init", "-q")
|
||||||
|
write(self.root / "components.toml", CATALOG)
|
||||||
|
write(self.root / ".gitmodules", GITMODULES)
|
||||||
|
self.cli = self.root / "cli"
|
||||||
|
self.cli.mkdir()
|
||||||
|
git(self.cli, "init", "-q")
|
||||||
|
write(self.cli / "README.md", "cli")
|
||||||
|
self.sha1 = commit(self.cli)
|
||||||
|
git(self.root, "add", "components.toml", ".gitmodules")
|
||||||
|
git(self.root, "update-index", "--add", "--cacheinfo", f"160000,{self.sha1},cli")
|
||||||
|
git(self.root, "commit", "-q", "-m", "accepted")
|
||||||
|
self.accepted = git(self.root, "rev-parse", "HEAD").strip()
|
||||||
|
write(self.cli / "README.md", "cli v2")
|
||||||
|
self.sha2 = commit(self.cli, "candidate")
|
||||||
|
self.state = self.base / "state.json"
|
||||||
|
self.originals = (adapter.PROJECT_ROOT, adapter.ROOT)
|
||||||
|
adapter.ROOT = self.root
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
adapter.PROJECT_ROOT, adapter.ROOT = self.originals
|
||||||
|
self.tmp.cleanup()
|
||||||
|
|
||||||
|
def push_body(self, after=None, before=None, repository="cflmy/marqdo-cli"):
|
||||||
|
return json.dumps(
|
||||||
|
{
|
||||||
|
"repository": {"full_name": repository},
|
||||||
|
"ref": "refs/heads/candidate",
|
||||||
|
"before": before or self.sha1,
|
||||||
|
"after": after or self.sha2,
|
||||||
|
}
|
||||||
|
).encode()
|
||||||
|
|
||||||
|
def statuses(self, status="success"):
|
||||||
|
return [{"status": status, "context": "ci/woodpecker/pr/main", "target_url": CI_URL}]
|
||||||
|
|
||||||
|
def verify(self, body, event="push", signature=None, statuses=None, write_state=True):
|
||||||
|
signature = signature if signature is not None else hmac.new(
|
||||||
|
SECRET.encode(), body, hashlib.sha256
|
||||||
|
).hexdigest()
|
||||||
|
return adapter.verify_webhook(
|
||||||
|
body,
|
||||||
|
event,
|
||||||
|
signature,
|
||||||
|
SECRET,
|
||||||
|
statuses if statuses is not None else self.statuses(),
|
||||||
|
self.accepted,
|
||||||
|
self.state,
|
||||||
|
["ci.cflmy.cn"],
|
||||||
|
"cflmy/marqdo",
|
||||||
|
write_state,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_signed_push_candidate_is_verified_without_auto_promotion(self):
|
||||||
|
plan = self.verify(self.push_body())
|
||||||
|
self.assertTrue(plan["verified"])
|
||||||
|
self.assertIsNotNone(plan.get("impact"))
|
||||||
|
self.assertFalse(plan["actions"]["auto_promote"])
|
||||||
|
self.assertFalse(plan["actions"]["auto_merge"])
|
||||||
|
self.assertTrue(self.state.is_file())
|
||||||
|
|
||||||
|
def test_tampered_body_and_missing_secret_are_refused_before_verification(self):
|
||||||
|
body = self.push_body()
|
||||||
|
with self.assertRaises(adapter.AdapterError):
|
||||||
|
self.verify(body, signature="0" * 64)
|
||||||
|
with self.assertRaises(adapter.AdapterError):
|
||||||
|
self.verify(body, signature="")
|
||||||
|
with self.assertRaises(adapter.AdapterError):
|
||||||
|
adapter.verify_webhook(
|
||||||
|
body, "push", None, "", self.statuses(), self.accepted, self.state,
|
||||||
|
["ci.cflmy.cn"], "cflmy/marqdo",
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_unsupported_events_and_deleted_branches_are_refused(self):
|
||||||
|
with self.assertRaises(adapter.AdapterError):
|
||||||
|
self.verify(self.push_body(), event="issues")
|
||||||
|
body = json.dumps(
|
||||||
|
{
|
||||||
|
"repository": {"full_name": "cflmy/marqdo-cli"},
|
||||||
|
"before": self.sha1,
|
||||||
|
"after": "0" * 40,
|
||||||
|
"deleted": True,
|
||||||
|
}
|
||||||
|
).encode()
|
||||||
|
with self.assertRaises(adapter.AdapterError):
|
||||||
|
self.verify(body)
|
||||||
|
|
||||||
|
def test_unknown_repository_and_failed_or_missing_ci_are_rejected(self):
|
||||||
|
with self.assertRaises(adapter.AdapterError):
|
||||||
|
self.verify(self.push_body(repository="cflmy/unknown"))
|
||||||
|
failed = self.verify(self.push_body(), statuses=self.statuses("failure"))
|
||||||
|
self.assertFalse(failed["verified"])
|
||||||
|
self.assertIn("CI status", failed["reason"])
|
||||||
|
pending = self.verify(self.push_body(), statuses=self.statuses("pending"))
|
||||||
|
self.assertFalse(pending["verified"])
|
||||||
|
empty = self.verify(self.push_body(), statuses=[])
|
||||||
|
self.assertFalse(empty["verified"])
|
||||||
|
|
||||||
|
def test_pr_event_uses_the_accepted_pin_not_the_payload_base(self):
|
||||||
|
body = json.dumps(
|
||||||
|
{
|
||||||
|
"action": "opened",
|
||||||
|
"repository": {"full_name": "cflmy/marqdo-cli"},
|
||||||
|
"pull_request": {
|
||||||
|
"number": 21,
|
||||||
|
"head": {"sha": self.sha2},
|
||||||
|
"base": {"sha": self.sha1},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
).encode()
|
||||||
|
plan = self.verify(body, event="pull_request")
|
||||||
|
self.assertTrue(plan["verified"])
|
||||||
|
self.assertIsNotNone(plan.get("impact"))
|
||||||
|
|
||||||
|
def test_replayed_candidate_is_rejected(self):
|
||||||
|
self.assertTrue(self.verify(self.push_body())["verified"])
|
||||||
|
replay = self.verify(self.push_body())
|
||||||
|
self.assertFalse(replay["verified"])
|
||||||
|
self.assertIn("duplicate/replay", replay["reason"])
|
||||||
|
|
||||||
|
def test_reconciliation_recovers_a_lost_notification_and_is_idempotent(self):
|
||||||
|
pulls = [
|
||||||
|
{
|
||||||
|
"number": 33,
|
||||||
|
"head": {"sha": self.sha2},
|
||||||
|
"base": {"sha": self.sha1},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
def prs_fetcher(repository):
|
||||||
|
return pulls if repository == "cflmy/marqdo-cli" else []
|
||||||
|
|
||||||
|
def statuses_fetcher(repository, sha):
|
||||||
|
return self.statuses() if sha == self.sha2 else []
|
||||||
|
|
||||||
|
plan = adapter.reconcile(
|
||||||
|
self.accepted,
|
||||||
|
self.state,
|
||||||
|
["cflmy/marqdo-cli", "cflmy/marqdo"],
|
||||||
|
self.accepted,
|
||||||
|
statuses_fetcher,
|
||||||
|
prs_fetcher,
|
||||||
|
["ci.cflmy.cn"],
|
||||||
|
"cflmy/marqdo",
|
||||||
|
)
|
||||||
|
self.assertEqual(plan["verified"], 1)
|
||||||
|
result = [item for item in plan["results"] if item.get("pull_request") == 33][0]
|
||||||
|
self.assertEqual(result["status"], "VERIFIED")
|
||||||
|
self.assertTrue(self.state.is_file())
|
||||||
|
|
||||||
|
again = adapter.reconcile(
|
||||||
|
self.accepted,
|
||||||
|
self.state,
|
||||||
|
["cflmy/marqdo-cli", "cflmy/marqdo"],
|
||||||
|
self.accepted,
|
||||||
|
statuses_fetcher,
|
||||||
|
prs_fetcher,
|
||||||
|
["ci.cflmy.cn"],
|
||||||
|
"cflmy/marqdo",
|
||||||
|
)
|
||||||
|
self.assertEqual(again["verified"], 0)
|
||||||
|
self.assertTrue(any(item["status"] == "DUPLICATE" for item in again["results"]))
|
||||||
|
|
||||||
|
def test_reconciliation_reports_api_failures_without_writing_state(self):
|
||||||
|
plan = adapter.reconcile(
|
||||||
|
self.accepted,
|
||||||
|
self.state,
|
||||||
|
["cflmy/marqdo-cli"],
|
||||||
|
self.accepted,
|
||||||
|
lambda repository, sha: self.statuses(),
|
||||||
|
lambda repository: (_ for _ in ()).throw(adapter.AdapterError("HTTP 403")),
|
||||||
|
["ci.cflmy.cn"],
|
||||||
|
"cflmy/marqdo",
|
||||||
|
)
|
||||||
|
self.assertEqual(plan["verified"], 0)
|
||||||
|
self.assertEqual(plan["results"][0]["status"], "ERROR")
|
||||||
|
self.assertFalse(self.state.exists())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
+1
-1
Submodule tools/knowledge updated: d8fa201b28...6e88100089.
+1
-1
Submodule tools/lint updated: 111e085f24...aa0bdac7de.
+1
-1
Submodule tools/prove updated: d8c340b6e2...e9fce68551.
+1
-1
Submodule tools/view updated: 04f3a0e9e5...48e5309358.
Reference in new issue
Block a user