diff --git a/.gitignore b/.gitignore index 2058b9a..b867550 100755 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ # Local build/cache/scratch (DSH workspace tooling) /.build/ + +# Local audit/experiment scratch (issue #25) +/.issue-work/ +/.app-verify/ diff --git a/.gitmodules b/.gitmodules index 92ae6ec..dca8539 100644 --- a/.gitmodules +++ b/.gitmodules @@ -100,3 +100,6 @@ [submodule "stdlib/text"] path = stdlib/text url = https://git.cflmy.cn/cflmy/marqdo-std-text.git +[submodule "apps/harness"] + path = apps/harness + url = https://git.cflmy.cn/cflmy/marqdo-app-harness.git diff --git a/.woodpecker/eco.yml b/.woodpecker/eco.yml index 326cb97..0fc334e 100644 --- a/.woodpecker/eco.yml +++ b/.woodpecker/eco.yml @@ -50,3 +50,27 @@ steps: apt-get -o Acquire::Retries=3 -o Acquire::http::Timeout=30 install -y --no-install-recommends python3-jsonschema util-linux unset MARQDO_BIN MARQDO_STDLIB_DIR bash scripts/integration.sh + + app: + # Dedicated Node lane: the app gitlink is built and tested against the same + # CLI/Bundle candidate the Rust candidate lane just produced. The Rust lane + # never installs Node or Electron. + image: node:24.22.3-bookworm + depends_on: [candidate] + when: *needs_candidate + commands: + - corepack enable + - corepack prepare pnpm@11.28.5 --activate + - | + set -eu + test -f .integration-work/app-candidate.json + export MARQDO_BIN="$(python3 -c 'import json;print(json.load(open(".integration-work/app-candidate.json"))["cli_path"])')" + export MARQDO_STDLIB_DIR="$(python3 -c 'import json;print(json.load(open(".integration-work/app-candidate.json"))["installed_dir"])')/stdlib" + test -x "$MARQDO_BIN" + test -f "$MARQDO_STDLIB_DIR/stdlib.json" + cd apps/harness + # The upstream hook installer refuses the submodule common config; CI + # is the documented skip path and hooks are not needed in this lane. + CI=true pnpm install --frozen-lockfile + pnpm run build + MARQDO_CI_OUT="$PWD/.ci" bash scripts/ci.sh diff --git a/AGENTS.md b/AGENTS.md index 15c581e..9d55b40 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,7 +1,7 @@ # Marqdo 维护指引 1. 从 [各仓库任务](docs/REPOSITORY-TASKS.md)、[组件目录](components.toml) 与 [架构边界](docs/ARCHITECTURE.md) 确定**唯一**责任仓库:功能缺陷在功能仓库,领域合同/组合在领域聚合仓库,gitlink、跨领域集成、发行组合与治理在主仓库。主仓库和聚合仓库不实现子组件业务。 -2. 治理树最多两级:根 → 领域聚合(`kind = "domain"`)→ 功能组件。每个组件只有一个父级,全局 ID 与权威远端唯一,领域聚合仓库只做治理、合同、示例和组合验收。已发布的 `planned` 仓库可以挂载真实 gitlink。激活时登记实际 `entry`,只有通过验收的 active 组件计入完成率。 +2. 治理树最多两级:根 → 领域聚合(`kind = "domain"`)→ 功能组件。每个组件只有一个父级,全局 ID 与权威远端唯一,领域聚合仓库只做治理、合同、示例和组合验收。根层另有 `kind = "app"` 产品应用(`app-` → `apps/`,`release = "optional"`):它是根 leaf,只消费 active 叶组件,不能被其它组件依赖,也不进入 base 发行。已发布的 `planned` 仓库可以挂载真实 gitlink。激活时登记实际 `entry`,只有通过验收的 active 组件计入完成率。 3. 找到或建立责任仓库的工单,按 `.gitea/ISSUE_TEMPLATE/change.md` 记录目标、当前提交、最小复现、公共契约、影响消费者和验收命令。跨仓库阻塞在上游开关联工单,并在消费者记录回归条件。不要按错误最终显示的仓库定责,找第一个违反公开合同的所有者。 4. 在责任仓库独立修改、构建和测试。需要调整公共语义时,在 CLI 提交 ADR;调整 Web 作者面语义时,只在 `marqdo-ext-web` 的 [WEB-DESIGN 合同](https://git.cflmy.cn/cflmy/marqdo-ext-web/src/branch/main/docs/WEB-DESIGN.md) 走 ADR,并与实际消费者(Design/Preview)同候选验证;不得并列维护第二份现行规范或旧协议 fallback。 5. 逐层晋升:功能提交 C2 通过组件 CI → 领域 PR 更新 gitlink 至 C2 并通过领域 CI(B2)→ 主仓库 PR 更新领域 gitlink 至 B2 并通过根递归校验与受影响组合验收(A2)。先推送子仓库提交,再在主仓库提交精确 gitlink;区分组件 CI、公共契约 CI 和生态 CI 证据。以 [开发流程](docs/DEVELOPMENT.md) 为准。 diff --git a/README.md b/README.md index 5363e36..559deed 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ marqdo run hello.mq.md | 仓库 | 职责 | | --- | --- | +| [marqdo-app-harness](https://git.cflmy.cn/cflmy/marqdo-app-harness) | 官方单用户应用:生态安装、文稿程序化执行、私人知识库与 `/mdh` 工作台(DSH 下游) | | [marqdo-site](https://git.cflmy.cn/cflmy/marqdo-site) | 官网、入门文档、静态站点构建与托管 | | [marqdo-vscode](https://git.cflmy.cn/cflmy/marqdo-vscode) | VS Code 文件关联、编辑体验、CLI 集成与 VSIX 发布 | diff --git a/apps/harness b/apps/harness new file mode 160000 index 0000000..ee482a2 --- /dev/null +++ b/apps/harness @@ -0,0 +1 @@ +Subproject commit ee482a23c2e0ae3ca4c2b56281ea82e9fb58619d diff --git a/components.toml b/components.toml index 0b88b45..d8a50f7 100644 --- a/components.toml +++ b/components.toml @@ -392,3 +392,15 @@ scope = "IANA 时区、DST 和高级日历" requires = ["cli", "std-system"] checks_with = [] release = "optional" + +[[component]] +id = "app-harness" +path = "apps/harness" +kind = "app" +state = "active" +owner = "cflmy" +scope = "官方单用户智能体应用、Marqdo 生态安装与更新、文稿执行、私人知识库" +requires = ["cli"] +checks_with = ["knowledge", "view"] +release = "optional" +entry = "scripts/ci.sh" diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index c85a2f8..60c9534 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -18,12 +18,13 @@ - **领域(`kind = "domain"`)**:工程治理角色,不是语言层也不是运行协议。领域仓库只登记直属子组件,可拥有 `components.toml`、`.gitmodules`、领域公共规范、跨组件集成测试、综合示例、发布装配脚本、ADR 与维护指南;禁止在其中建立 renderer、解析器、数据库驱动等生产实现,也禁止把子仓库源码复制进普通目录。领域 `requires = []`,`release` 为 `none`(普通领域)或 `base`(Stdlib Bundle 聚合)。 - **功能组件**:`kind` 仍为 `core/stdlib/extension/tool/test`,在责任仓库独立实现、测试和发版;`release` 与 `kind` 的对应关系不变(base/optional/none)。 +- **应用(`kind = "app"`)**:根层产品消费者,ID 为 `app-`、路径为 `apps/`、`release = "optional"`。应用是根 leaf,只依赖 active 的 `core/stdlib/extension/tool` 叶组件,不得被其它组件依赖,也不得登记在领域内。当前唯一应用为 `app-harness`(`apps/harness`)。 - **唯一归属**:一个功能只有一个权威实现,一个组件只有一个治理归属,一个公共边界只有一套现行合同。已有仓库直接复用,不能因为命名不符创建重复实现。 - **`planned` 纪律**:已有仓库可以通过 gitlink 固定已发布的开发提交。尚无提交的仓库登记在 [迁移台账](MIGRATION.md)。组件通过联合验收后才晋升为 `active` 并登记实际 `entry`。将直属组件迁入领域时,在同一根候选转移清单和 gitlink,保证一个组件只有一个父级。 - **聚合准入**:功能拆分须至少有一种独立价值(独立维护责任、显著不同依赖/安全/平台边界、独立版本与制品、可重复独立验收)。若两个仓库几乎每个 PR 都必须一起改动且接口未稳定,应先收敛合同或合并,不能无限拆分。 - **工具目录**(`tools/`)暂不聚合,现有四个 Tool 保持原路径。 -**当前状态**(以 [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` 聚合仍在计划中。 +**当前状态**(以 [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` 聚合仍在计划中。根层 `app-harness` 是 active 应用:它组合 CLI、Bundle、Tool 与私人知识,不进入 CLI 基础发行,也不被任何组件依赖。 ## 语言与产品层(不因仓库变多而改变) diff --git a/docs/REPOSITORY-CONVENTIONS.md b/docs/REPOSITORY-CONVENTIONS.md index a0344e1..2846101 100644 --- a/docs/REPOSITORY-CONVENTIONS.md +++ b/docs/REPOSITORY-CONVENTIONS.md @@ -20,6 +20,7 @@ - `planned` 仓库允许挂载真实开发提交,但**不计完成率**、不登记 `entry`、不要求发布制品;只能有 README/必要源码/最小测试,不得批量复制模板、CI 徽章、占位实现或假入口。 - 从 `planned` 激活必须同时具备:真实实现、README(职责/构建/依赖/平台)、`AGENTS.md`(本仓边界与路由)、可执行 CI 入口、真实正反例、交付/发布方式、候选证据;并在父级 catalog 登记 `entry`。 - 只有规范/fixture 的仓库允许源码归档交付,不强制二进制;但必须有确定性归档与证据。 +- 应用(`kind = "app"`)只允许在根层登记,ID 为 `app-`、路径为 `apps/`、`release = "optional"`。应用依赖 active 叶组件,不能被其它组件依赖;激活时必须登记真实 `entry` 与独立 CI。 - `active` 仓库不得回退为"文档占位";若失去责任,必须记录替代仓库与迁移/归档计划。 ## 3. 角色与禁止事项 @@ -27,7 +28,9 @@ | 所有者 | 应做 | 禁止 | | --- | --- | --- | | 功能仓库(core/stdlib/extension/tool/test) | 自身实现、测试、制品、发布、消费上游候选、修复本仓缺陷 | 实现其它仓库功能;依赖父仓或兄弟仓 checkout;复制其它仓实现/parser/合同;偷偷替换上游逻辑 | +| 应用仓库(app) | 下游产品装配、生态安装/更新、文稿执行与知识复用;独立 CI/发行 | 发布公共语言/运行时合同;复制生态生产源码;被基础组件依赖 | | 领域聚合仓(`kind=domain`) | 领域合同、组合、领域候选 gitlink、领域验收、通知父仓 | 重复叶子实现;第二套调用协议;登记后代到根 catalog | +| 应用仓(`kind=app`) | 产品装配、生态安装、文稿执行、私人知识与 UI;消费公开合同 | 复制 CLI/stdlib/ext/tool 源码;成为其它组件依赖;进入 base 发行;自建第二套解析器/锁 | | 根仓库 | 展开依赖、传播协调、全局候选、递归集成、正式发行、滞后报告 | 实现子组件业务;批量直接改子仓代码;成为每个仓的构建前置 | | CLI | 语言/通用能力、公开协议、CLI/Worker/基础产品打包 | 生态调度代码;反向依赖 stdlib 源码;物理拆仓 | | Conformance | 独立公共契约运行验收 | 取代组件自测;伪造未支持平台的 PASS | diff --git a/docs/REPOSITORY-TASKS.md b/docs/REPOSITORY-TASKS.md index 7f9becd..bbad986 100644 --- a/docs/REPOSITORY-TASKS.md +++ b/docs/REPOSITORY-TASKS.md @@ -32,6 +32,7 @@ | `marqdo-lint` | 扩展静态规则和诊断定位,为可修复规则提供显式修复。 | | `marqdo-site` | **大改**。用现行 CLI 和 View 重建官网与入门内容,验证新站和旧链接后切换托管。 | | `marqdo-vscode` | **大改**。按现行 CLI 重做诊断和运行适配,先完成高亮、静态诊断、显式运行和可安装的 VSIX。 | +| `marqdo-app-harness` | **大改**。官方单用户应用(DSH 下游):产品 profile、生态安装/回退、文稿 PTC、私人知识、`/mdh` 工作台、独立 CI 与冷安装。父仓 `apps/harness`。 | ## 标准库 diff --git a/docs/adr/0002-application-layer-and-harness-admission.md b/docs/adr/0002-application-layer-and-harness-admission.md new file mode 100644 index 0000000..5615318 --- /dev/null +++ b/docs/adr/0002-application-layer-and-harness-admission.md @@ -0,0 +1,80 @@ +# ADR 0002:应用层(app)准入与 Marqdo Harness + +- 状态:已采纳(2026-11-28),实施工单为 `marqdo#25`(Application / P0)。 +- 现行权威:`docs/ARCHITECTURE.md`、`docs/REPOSITORY-CONVENTIONS.md`、`components.toml`、`.gitmodules` 与 Git tree gitlink。本 ADR 记录决策,不构成第二套规范。 +- 影响仓库:`marqdo`(根治理)、`marqdo-app-harness`(新应用仓库)。CLI、Std、Ext、Tool 的现行合同不因本 ADR 改变。 + +## 背景 + +生态此前只有 `core/stdlib/extension/tool/test/domain` 六种组件角色。Marqdo Harness +(MDH)是一个**产品消费者**:它组合已发布的 CLI、单一 Bundle、Tool 与 Ext,向最终 +用户提供安装入口、文稿执行入口、私人知识库和成果复用。它既不发布语言/运行时合同, +也不被任何基础组件依赖。直接复用 `tool` 或 `extension` 会把产品应用错误地放进 +`requires` 图,导致 CLI 基础发行被应用反向阻塞。 + +## 决策 + +### 1. 新增根层 `kind = "app"` + +- 只允许出现在根治理层(`depth == 0`),不允许登记在领域聚合仓库内。 +- ID 固定为 `app-`,路径固定为 `apps/`,权威远端固定为 + `https://git.cflmy.cn/cflmy/marqdo-.git`(即 `marqdo-app-harness.git`)。 +- `release = "optional"`:应用不属于 CLI 基础发行,不进入 `base` 装配。 +- 应用是根 leaf:仓库自身不得再登记 `components.toml`、`.gitmodules` 或任何 + gitlink。父仓只固定其提交,不读取其内部子模块。 +- `requires` 只能指向 active 的 `core/stdlib/extension/tool` 叶组件;不得指向 + `domain`、`test` 或另一个 `app`。任何其它 kind 都不得以 app 为依赖目标。 +- `checks_with` 仍只表示协同验收,不是安装依赖。 +- 首期只登记一个应用,不建立 `marqdo-app` 聚合仓库;未来第二个独立应用出现时 + 再以新 ADR 评估是否聚合。 + +### 2. `app-harness` 的上游与产品身份 + +- 应用仓库为 `cflmy/marqdo-app-harness`,路径 `apps/harness`。 +- 保留 DSH 的 Git 历史、MIT `LICENSE` 与第三方声明;`origin` 为 Gitea 权威远端, + `upstream` 为 `https://git.cflmy.cn/cflmy/deepseek-harness.git`(DSH 权威镜像)。 + GitHub 官方仓库只作为审计与回馈来源,不进入父仓 `.gitmodules`。 +- 发布名、包名(`@marqdo/*`)、命令(`mdh`)、应用标识和发行地址与 DeepSeek 官方 + DSH 完全分离;不得复用官方上传工作流或凭证。 +- 首版支持平台以真实证据为准:Linux x86_64 / glibc ≥ 2.39;Node 24.22.3、 + pnpm 11.28.5(由选定 DSH 提交与锁文件决定)。Web 默认 loopback。 + +### 3. 产品装配 + +- 唯一正式产品入口为 `mdh` 启动器,唯一产品 profile 为 `mdh`,组合为 + `dsh-base` + `dsh-web-app` + 下游 `@marqdo/mdh-bundle`。 +- 下游产品包集中在 fork 的 `packages/marqdo/*`,不散改上游包;必须修改的上游文件 + 逐项记录在 `docs/mdh/upstream-delta.md`。 +- DSH 的 Node PTC 模型入口在产品 profile 中关闭;面向模型的文稿执行只经由 + `marqdo_program` 一条组合入口。上游 PTC 源码保留用于同步与基线,不作为第二个 + 用户可选执行模式。 +- 应用运行数据使用独立 `MDH_HOME`;DSH 会话放在 `MDH_HOME/harness`,不覆盖用户 + 已有的 DSH 数据。 + +### 4. 晋升门槛 + +1. M0:登记 planned 条目并固定真实初始提交;`app-harness` 仍不计完成率,不登记 + `entry`。 +2. MDH-01..09 完成应用自身实现、独立 CI、冷安装与真实候选证据后,应用仓库登记 + `entry = "scripts/ci.sh"` 并推送。 +3. MDH-10:根 PR 只更新 gitlink、catalog、集成调度与证据;应用加入 `requires` 的 + 组件必须已 active。根 Node lane 使用与 CLI/Bundle/Tool 相同的候选身份运行真实 + 应用验收。 +4. 应用激活前不得成为 CLI 独立发行的前置;应用失败不得阻断合法的 CLI 基础发行, + 但包含 app 的根生态候选必须如实记录失败,禁止静默跳过。 + +## 后果 + +- `scripts/check-layout.py` 增加 app kind、路径/远端/依赖方向校验与正反例; + `kinds` 与 `release` 的既有约束保持不变。 +- `scripts/integration.sh` 增加显式 app 分派,传入真实 CLI/Bundle/Tool 候选身份; + 未知 active 项继续失败。 +- `docs/ARCHITECTURE.md`、`docs/REPOSITORY-TASKS.md`、`docs/REPOSITORY-CONVENTIONS.md` + 登记应用层职责与边界;根 README 给出应用入口。 +- 应用仓库必须遵守仓库规范最低集(README、AGENTS、`scripts/ci.sh`、正反例、 + 独立 CI、证据),并在 `AGENTS.md` 保留 `marqdo:repo-conventions v1` 标记。 + +## 非目标 + +公共知识共享插件、知识市场、多租户/云托管、桌面签名、独立 TUI、完整 host-binding +PTC 与自动发布用户成果均不在本 ADR 与首版范围内;它们需要独立工单与 ADR。 diff --git a/docs/adr/README.md b/docs/adr/README.md index d56abb5..78bdf54 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -5,3 +5,4 @@ | ADR | 状态 | 主题 | | --- | --- | --- | | [0001](0001-hierarchical-ecosystem-and-web-domain.md) | 已采纳(实施记录) | 分层生态治理(根→领域→功能)与 Web 原型设计领域合同 | +| [0002](0002-application-layer-and-harness-admission.md) | 已采纳(实施中) | 根层 `app` 角色、`marqdo-app-harness` 准入、DSH 上游与产品装配边界 | diff --git a/docs/evidence/2026-11-28-marqdo-harness.md b/docs/evidence/2026-11-28-marqdo-harness.md new file mode 100644 index 0000000..3633378 --- /dev/null +++ b/docs/evidence/2026-11-28-marqdo-harness.md @@ -0,0 +1,55 @@ +# Marqdo Harness 根消费者验收证据(2026-11-28) + +本文件记录主仓库对 `marqdo-app-harness` 的接入证据。应用自身状态与未验证范围以 +`apps/harness/docs/mdh/STATUS.md` 为准;本文件不重复、也不改写那些结论。 + +## 身份 + +| 对象 | 身份 | +| --- | --- | +| 主仓库候选 | 本提交(`git rev-parse HEAD`) | +| 应用 gitlink | `apps/harness` → `ee482a23c2e0ae3ca4c2b56281ea82e9fb58619d` | +| 应用 origin | `https://git.cflmy.cn/cflmy/marqdo-app-harness.git` | +| DSH 上游 | `4b399c39a6d1479cd84ca591b4d7c88e24d38a96`(`dsh-v0.2.3-alpha.2`) | +| CLI gitlink | `63776735e924ade279cdf59d5c733dc24bfdabbb`(`v3.0.0-rc.6`) | +| CLI 资产 | sha256 `8dc0b006302e03c23451b8ea9f8a0fcdae8bf67c80c546bee2434bf69755bfe3` | +| Std Bundle | tree digest `sha256:db905508dde89763b9d43b47fc5d52c6a1d5445a91f3c86a550ced43e8aac9d7` | + +## 根治理校验 + +| 命令 | 结果 | +| --- | --- | +| `python3 scripts/check-layout.py` | 通过;`app-harness apps/harness d28c5e4051... active` | +| `python3 -m unittest tests.integration.test_layout` | 60 tests PASS;含 app 路径/远端/前缀/release/嵌套/依赖方向负例 | +| `python3 scripts/check-repo-conventions.py` | PASS(38 components);应用 README/AGENTS/entry 真实存在 | + +## 组合调度 + +- `scripts/integration.sh` 的 active entry 分派对 `app:app-harness:scripts/ci.sh` 使用独立 `app` gate。 +- Rust candidate lane 仍只构建一个 CLI/Worker/Bundle 制品,并在安装后写出稳定的 + `.integration-work/app-candidate.json`:归档 SHA-256、CLI source SHA、Bundle digest、 + 安装目录、CLI 绝对路径与应用 gitlink。 +- `.woodpecker/eco.yml` 增加专用 Node lane(`node:24.22.3-bookworm`),消费同一 + candidate manifest,`pnpm install --frozen-lockfile && pnpm run build` 后运行 + `apps/harness/scripts/ci.sh`;Rust lane 不安装 Node/Electron。 +- 未知 active entry 仍以非零退出失败,不静默跳过;应用为 `release = "optional"`, + 其失败不阻断合法 CLI 基础发行,但包含 app 的根候选会如实记录失败。 + +## 应用侧已复核证据 + +证据全文见 `apps/harness/docs/mdh/evidence/`。 + +- 上游基线 `pnpm install --frozen-lockfile` 与 `pnpm run build`:10/10 gates PASS。 +- 下游 28 项测试:27 PASS;网络安装测试在 `MDH_TEST_INSTALL=1` 下 PASS(rc.5→rc.6→回退)。 +- 真实 CLI 执行 factorial `n=5` → `{"type":"int","decimal":"120"}`;除零 → `failed`;摘要不符 → `incomplete`。 +- 真实 `marqdo-knowledge` 编译/查询:`mode=compiled`,命中带精确源路径、摘要、span 与通道。 +- `/mdh` 页面与 API:200;cross-site / 错误 Host / 不匹配 Origin → 403。 +- `scripts/package.sh`:预构建归档冷组合 PASS(748,901,507 bytes,sha256 `21a532d2949a25bae76a41b2a4e0f08d06f39a084db2f02a1cd1506ad5a24617`)。 + +## UNVERIFIED + +- 父仓 PR#48 的 Woodpecker pipeline 已真实运行;首次 candidate 失败于 app-candidate manifest 把摘要字符串误转为 `Path`,已修复并等待 rerun 通过。Node lane 尚未在该次 pipeline 中执行完成。 +- 真实模型两轮任务(任务 A/B)未运行:本机没有模型凭据,没有用 fixture 冒充。 +- 浏览器自动化未运行;页面与 API 通过真实 HTTP 请求验证。 +- 上游同步演练未运行:镜像 HEAD 等于基线,没有更新的提交。 +- 候选归档未签名,未在第二台干净主机或更低 glibc 上冷安装。 diff --git a/scripts/check-layout.py b/scripts/check-layout.py index 8d6071b..4298e48 100644 --- a/scripts/check-layout.py +++ b/scripts/check-layout.py @@ -32,10 +32,14 @@ ROOT = Path(__file__).resolve().parents[1] NAME = r"[a-z][a-z0-9]*(?:-[a-z0-9]+)*" FIELDS = {"id", "path", "kind", "state", "owner", "scope", "requires", "checks_with", "release"} ROOT_FILES = {".gitattributes", ".gitignore", ".gitmodules", "AGENTS.md", "LICENSE", "README.md", "components.toml"} -ROOT_DIRS = {".gitea", ".woodpecker", "ci", "docs", "examples", "scripts"} +ROOT_DIRS = {".gitea", ".woodpecker", "apps", "ci", "docs", "examples", "scripts"} CATEGORY_READMES = {"stdlib/README.md", "extensions/README.md"} RELEASE_ROLES = {"core": "base", "stdlib": "base", "extension": "optional", "tool": "optional", "test": "none"} DOMAIN_RELEASE = {"none", "base"} +# An app is a root-only, optional product consumer: it owns no runtime contract +# and never becomes a dependency of another component. Its id carries the +# `app-` prefix that maps onto `apps/`. +APP_RELEASE = {"optional"} DOMAIN_FILES = {".gitattributes", ".gitignore", ".gitmodules", "AGENTS.md", "LICENSE", "README.md", "components.toml"} DOMAIN_DIRS = {".gitea", ".woodpecker", "docs", "examples", "scripts", "tests"} DOMAIN_CHILD_KINDS = {"stdlib", "extension", "tool"} @@ -106,6 +110,8 @@ def expected_root_path(component): return f"tools/{id}" if kind == "domain": return "stdlib" if id == "stdlib" else f"extensions/{id}" + if kind == "app": + return f"apps/{id.removeprefix('app-')}" if id.startswith("app-") else None return None @@ -149,11 +155,16 @@ def check_component(raw, depth, label, by_id, paths, path_keys): require(id not in items and len(set(items)) == len(items), f"{label}: invalid {key}: {id}") kind = raw["kind"] - require(kind in RELEASE_ROLES or kind == "domain", f"{label}: unknown kind: {id}: {kind!r}") + require(kind in RELEASE_ROLES or kind in {"domain", "app"}, + f"{label}: unknown kind: {id}: {kind!r}") if kind == "domain": require(depth == 0, f"{label}: domain kind is only allowed at the root layer: {id}") require(raw["release"] in DOMAIN_RELEASE, f"{label}: invalid release role: {id}") require(raw["requires"] == [], f"{label}: domain requires must be empty: {id}") + elif kind == "app": + require(depth == 0, f"{label}: app kind is only allowed at the root layer: {id}") + require(id.startswith("app-"), f"{label}: app id must start with 'app-': {id}") + require(raw["release"] in APP_RELEASE, f"{label}: invalid release role: {id}") else: require(depth == 0 or kind in DOMAIN_CHILD_KINDS, f"{label}: component kind is not allowed inside a domain: {id} ({kind})") @@ -385,8 +396,13 @@ def validate_graph(layers): source_kind = component["kind"] require(target_kind != "domain", f"{layer.label}: requires must not target a domain: {id} -> {dependency}") + require(target_kind != "app", + f"{layer.label}: app components cannot be dependencies: {id} -> {dependency}") if source_kind in {"core", "domain"}: require(False, f"{layer.label}: dependency violation: {id} must not require {dependency}") + if source_kind == "app": + require(target_kind in {"core", "stdlib", "extension", "tool"}, + f"{layer.label}: app dependency violation: {id} -> {dependency}") if source_kind == "stdlib": require(target_kind in {"core", "stdlib"}, f"{layer.label}: stdlib dependency violation: {id} -> {dependency}") diff --git a/scripts/integration.sh b/scripts/integration.sh index 24b2093..e3ec8f1 100755 --- a/scripts/integration.sh +++ b/scripts/integration.sh @@ -19,6 +19,7 @@ while IFS=$'\t' read -r id kind path entry; do stdlib:*:scripts/test.sh) gate=stdlib ;; test:conformance:scripts/build_all.sh) gate=conformance ;; domain:web:scripts/domain-acceptance.sh) gate=web ;; + app:app-harness:scripts/ci.sh) gate=app ;; tool:view:scripts/acceptance.sh) gate=view ;; tool:knowledge:scripts/ci.sh) gate=knowledge ;; tool:prove:scripts/package-tool.sh) gate=prove ;; @@ -104,6 +105,38 @@ 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" +# Fixed identity handoff for the Node application lane. The manifest is a +# consumer input, not a new lock: it names the exact archive, CLI source, +# Bundle digest and installed binary produced above. +python3 - "$work" "$archive" "$source_sha" "$bundle_digest" "$bundle_aliases" "$installed" "$root" <<'PY' +import hashlib, json, pathlib, subprocess, sys +work = pathlib.Path(sys.argv[1]) +archive = pathlib.Path(sys.argv[2]) +source_sha = sys.argv[3] +bundle_digest = sys.argv[4] +aliases = sys.argv[5] +installed = pathlib.Path(sys.argv[6]) +root = pathlib.Path(sys.argv[7]) +manifest = { + 'schema': 'marqdo.app-candidate', + 'schema_version': 1, + 'candidate_root': str(root), + 'archive': str(archive), + 'archive_sha256': 'sha256:' + hashlib.sha256(archive.read_bytes()).hexdigest(), + 'installed_dir': str(installed), + 'cli_path': str(installed / 'marqdo'), + 'cli_source_sha': source_sha, + 'stdlib_tree_digest': bundle_digest, + 'stdlib_aliases_digest': aliases, + 'platform': 'x86_64-unknown-linux-gnu', + 'app_gitlink': subprocess.check_output( + ['git', '-C', str(root / 'apps/harness'), 'rev-parse', 'HEAD'], text=True).strip(), +} +(work / 'app-candidate.json').write_text(json.dumps(manifest, indent=2) + '\n') +(work.parent / 'app-candidate.json').write_text(json.dumps(manifest, indent=2) + '\n') +print(json.dumps(manifest, indent=2)) +PY + # Tool consumers use the same candidate installation and the catalog order. # The candidate image uses a minimal Rust profile; component entries run # fmt/clippy, so add those components once when the active toolchain lacks them. @@ -136,6 +169,13 @@ run_consumer() ( "$MARQDO_BIN" tool remove web test "$(sha256sum "$MARQDO_BIN")" = "$cli_before" ;; + app) + # The Rust candidate lane builds the one CLI/Bundle artifact and + # emits its identity. The dedicated Node lane runs scripts/ci.sh + # against that exact artifact; this lane must not install Node. + test -x "$PWD/$entry" + echo "APP_LANE: candidate manifest $work/app-candidate.json" + ;; view) export MARQDO_TOOL_HOME="$work/view-registry" scripts/package.sh diff --git a/tests/integration/test_layout.py b/tests/integration/test_layout.py index 0b49034..9417883 100644 --- a/tests/integration/test_layout.py +++ b/tests/integration/test_layout.py @@ -105,6 +105,24 @@ checks_with = ["web-preview"] release = "optional" ''' +APP = ''' +[[component]] +id = "app-harness" +path = "apps/harness" +kind = "app" +state = "planned" +owner = "maintainer" +scope = "official single-user agent application" +requires = ["cli"] +checks_with = [] +release = "optional" +''' + +APP_ACTIVE = APP.replace('state = "planned"', 'state = "active"').replace( + 'release = "optional"', 'release = "optional"\nentry = "scripts/ci.sh"') + +APP_URL = "https://git.cflmy.cn/cflmy/marqdo-app-harness.git" + def catalog(*blocks): return "".join(blocks) @@ -185,6 +203,119 @@ class LayoutTests(unittest.TestCase): with self.assertRaisesRegex(ValueError, "invalid submodule URL"): layout.validate("HEAD", False) + def root_fixture(self, metadata, modules, links, files=None): + (self.root / "components.toml").write_text(metadata) + if 'id = "cli"' in metadata and "path = cli" not in modules: + modules += f'[submodule "cli"]\npath = cli\nurl = {CORE_URL}\n' + if 'id = "cli"' in metadata and "cli" not in links: + links = {**links, "cli": self.sha} + (self.root / ".gitmodules").write_text(modules) + for relative, content in (files or {}).items(): + path = self.root / relative + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(content) + self.git("add", "-A") + for path, sha in links.items(): + self.git("update-index", "--add", "--cacheinfo", f"160000,{sha},{path}") + self.git("-c", "user.name=Test", "-c", "user.email=test@example.invalid", + "commit", "-qm", "app fixture") + + def test_accepts_a_planned_app_gitlink(self): + self.root_fixture( + CLI + APP, + f'[submodule "cli"]\npath = cli\nurl = {CORE_URL}\n' + f'[submodule "apps/harness"]\npath = apps/harness\nurl = {APP_URL}\n', + {"cli": self.sha, "apps/harness": self.sha}) + root = layout.validate("HEAD", False)[0] + self.assertEqual(root.linked["apps/harness"]["kind"], "app") + self.assertEqual(root.linked["apps/harness"]["state"], "planned") + + def test_rejects_an_app_outside_the_apps_path(self): + self.root_fixture( + CLI + APP.replace('path = "apps/harness"', 'path = "apps/other"'), + f'[submodule "other"]\npath = apps/other\nurl = {APP_URL}\n', + {"apps/other": self.sha}) + with self.assertRaisesRegex(ValueError, "invalid path: app-harness: apps/other"): + layout.validate("HEAD", False) + + def test_rejects_an_app_id_without_the_app_prefix(self): + self.root_fixture( + CLI + APP.replace('id = "app-harness"', 'id = "harness"'), + f'[submodule "harness"]\npath = apps/harness\nurl = {APP_URL}\n', + {"apps/harness": self.sha}) + with self.assertRaisesRegex(ValueError, "app id must start with 'app-'"): + layout.validate("HEAD", False) + + def test_rejects_a_wrong_app_remote(self): + self.root_fixture( + CLI + APP, + f'[submodule "harness"]\npath = apps/harness\nurl = ' + f'https://git.cflmy.cn/cflmy/marqdo-harness.git\n', + {"apps/harness": self.sha}) + with self.assertRaisesRegex(ValueError, "invalid submodule URL: apps/harness"): + layout.validate("HEAD", False) + + def test_rejects_an_app_with_a_base_release_role(self): + self.root_fixture( + CLI + APP.replace('release = "optional"', 'release = "base"'), + f'[submodule "harness"]\npath = apps/harness\nurl = {APP_URL}\n', + {"apps/harness": self.sha}) + with self.assertRaisesRegex(ValueError, "invalid release role: app-harness"): + layout.validate("HEAD", False) + + def test_rejects_an_app_dependency_on_a_domain(self): + domain = WEB_DOMAIN.replace('state = "active"', 'state = "planned"').replace( + 'entry = "scripts/integration.sh"\n', '') + self.root_fixture( + CLI + domain + APP.replace('requires = ["cli"]', 'requires = ["cli", "web"]'), + f'[submodule "harness"]\npath = apps/harness\nurl = {APP_URL}\n', + {"apps/harness": self.sha}) + with self.assertRaisesRegex(ValueError, "requires must not target a domain: app-harness -> web"): + layout.validate("HEAD", False) + + def test_rejects_an_app_dependency_on_another_app(self): + second = APP.replace('id = "app-harness"', 'id = "app-other"').replace( + 'path = "apps/harness"', 'path = "apps/other"').replace( + 'requires = ["cli"]', 'requires = ["cli", "app-harness"]') + self.root_fixture( + CLI + APP + second, + f'[submodule "harness"]\npath = apps/harness\nurl = {APP_URL}\n' + f'[submodule "other"]\npath = apps/other\nurl = ' + f'https://git.cflmy.cn/cflmy/marqdo-app-other.git\n', + {"apps/harness": self.sha, "apps/other": self.sha}) + with self.assertRaisesRegex(ValueError, "app components cannot be dependencies: app-other -> app-harness"): + layout.validate("HEAD", False) + + def test_rejects_a_component_dependency_on_an_app(self): + view = ''' +[[component]] +id = "view" +path = "tools/view" +kind = "tool" +state = "active" +owner = "maintainer" +scope = "read and observe" +requires = ["cli", "app-harness"] +checks_with = [] +release = "optional" +entry = "scripts/acceptance.sh" +''' + self.root_fixture( + CLI + APP_ACTIVE + view, + f'[submodule "cli"]\npath = cli\nurl = {CORE_URL}\n' + f'[submodule "harness"]\npath = apps/harness\nurl = {APP_URL}\n' + f'[submodule "view"]\npath = tools/view\nurl = https://git.cflmy.cn/cflmy/marqdo-view.git\n', + {"cli": self.sha, "apps/harness": self.sha, "tools/view": self.sha}) + with self.assertRaisesRegex(ValueError, "app components cannot be dependencies: view -> app-harness"): + layout.validate("HEAD", False) + + def test_rejects_an_app_inside_a_domain(self): + nested = {"id": "app-nested", "path": "harness", "kind": "app", "state": "planned", + "owner": "maintainer", "scope": "nested", "requires": [], "checks_with": [], + "release": "optional"} + with self.assertRaisesRegex(ValueError, "app kind is only allowed at the root layer"): + layout.check_component(nested, 1, "fixture domain", {}, set(), set()) + def test_rejects_unstaged_checkout(self): self.candidate() with self.assertRaisesRegex(ValueError, "missing submodule checkout"): @@ -437,6 +568,63 @@ entry = "scripts/acceptance.sh" with self.assertRaisesRegex(ValueError, r"domain web \(extensions/web\) leaf web-design \(design\): leaf must not register gitlinks"): layout.validate("HEAD", True) + def test_accepts_an_active_app_leaf_checkout(self): + core = self.leaf("core", entry="scripts/test.sh") + app = self.leaf("harness") + self.root_repo(catalog(CLI, APP_ACTIVE), {"cli": core[1], "apps/harness": app[1]}, + {"cli": CORE_URL, "apps/harness": APP_URL}) + self.clone(core[0], self.root / "cli", core[1]) + self.clone(app[0], self.root / "apps/harness", app[1]) + layers = layout.validate("HEAD", True) + self.assertEqual(layers[0].linked["apps/harness"]["kind"], "app") + entries = list(layout.active_entries(layers)) + self.assertIn(("app-harness", "app", "apps/harness", "scripts/ci.sh"), entries) + ids = [entry[0] for entry in entries] + self.assertLess(ids.index("cli"), ids.index("app-harness")) + + def test_rejects_an_app_with_a_nested_gitlink(self): + core = self.leaf("core", entry="scripts/test.sh") + app = self.leaf_with_gitlink("harness") + self.root_repo(catalog(CLI, APP_ACTIVE), {"cli": core[1], "apps/harness": app[1]}, + {"cli": CORE_URL, "apps/harness": APP_URL}) + self.clone(core[0], self.root / "cli", core[1]) + self.clone(app[0], self.root / "apps/harness", app[1]) + with self.assertRaisesRegex( + ValueError, r"leaf app-harness \(apps/harness\): leaf must not register gitlinks"): + layout.validate("HEAD", True) + + def test_rejects_an_app_registered_by_a_domain_catalog(self): + nested = ''' +[[component]] +id = "app-nested" +path = "nested-app" +kind = "app" +state = "planned" +owner = "maintainer" +scope = "not allowed inside a domain" +requires = [] +checks_with = [] +release = "optional" +''' + core = self.leaf("core", entry="scripts/test.sh") + design = self.leaf("design") + preview = self.leaf("preview") + nested_leaf = self.leaf("nested-app") + domain_repo, domain_sha = self.domain( + DOMAIN + nested, + {"design": design[1], "preview": preview[1], "nested-app": nested_leaf[1]}, + modules={ + "design": "https://git.cflmy.cn/cflmy/marqdo-web-design.git", + "preview": "https://git.cflmy.cn/cflmy/marqdo-web-preview.git", + "nested-app": APP_URL, + }) + self.root_repo(catalog(CLI, WEB_DOMAIN), {"cli": core[1], "extensions/web": domain_sha}, + {"cli": CORE_URL, + "extensions/web": "https://git.cflmy.cn/cflmy/marqdo-ext-web.git"}) + self.clone(domain_repo, self.root / "extensions/web", domain_sha) + with self.assertRaisesRegex(ValueError, "app kind is only allowed at the root layer: app-nested"): + layout.validate("HEAD", False, expand_domains=True) + # -- catalog and layer failures ---------------------------------------- def test_rejects_a_missing_domain_catalog(self):