diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 530c9e5..41be9c9 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -117,6 +117,8 @@ bash scripts/integration.sh # 生态候选:真实 CLI 制品 + 需要 Linux x86_64/glibc ≥ 2.39、Python 3.11+、Git、Rust、C 编译器和 curl;`integration.sh` 另需 jsonschema 与冻结 CLI 归档。详细命令与组件验收入口见各仓库 `README.md` 与 [各仓库任务](REPOSITORY-TASKS.md)。 +根治理检查(`check-layout.py`、`check-repo-conventions.py`、`check-dev-secrets.py` 与 `tests/integration`)须在 Windows x86_64 + Python 3.12 上同样通过:文本按 UTF-8 读写,Windows 只读 Git 对象用可重试删除,symlink 权限不足时相关负例显式 skip 并留日志;`integration.sh`、组件 `entry` 与目标平台运行验收仍以 Linux 为准。现状证据见 [2026-12-02 Windows 复核与 Beta 判定](evidence/2026-12-02-windows-governance-and-beta-readiness.md)。 + 本地开发凭据(Git/CI/模型服务)只放在主仓库根目录的 git 忽略文件,子仓库不持有;加载方式、变量清单、真实模型 smoke 与防泄漏检查见 [本地开发凭据](DEVELOPMENT-CREDENTIALS.md)。提交或推送前运行 `python3 scripts/check-dev-secrets.py`。 ## 迁移台账 diff --git a/docs/evidence/2026-12-02-mqdh-windows-experimental.md b/docs/evidence/2026-12-02-mqdh-windows-experimental.md new file mode 100644 index 0000000..a5960b5 --- /dev/null +++ b/docs/evidence/2026-12-02-mqdh-windows-experimental.md @@ -0,0 +1,83 @@ +> **Superseded(2026-12-03)**:Windows 可用性结论已由 [2026-12-03 MQDH Windows 可用实验版](2026-12-03-mqdh-windows-usable.md) 取代;本记录仅保留当日的历史发行事实。 + +# MQDH Windows x86_64 瀹為獙鎬у垎鍙戣褰曪紙2026-12-02锛? + +Date: 2026-12-02. +鎬ц川锛?*缁勪欢鐙珛 experimental 鍒嗗彂**锛涗笉鏄牴浠撳凡鎺ュ彈鑼冨洿锛屼篃涓嶆敼鍙?MQDH 鐨? +Linux supported 鐘舵€併€? + +## 1. 缁勪欢鍙戣浜嬪疄 + +- 缁勪欢锛歚cflmy/marqdo-app-harness`锛圡QDH锛? +- 鐗堟湰锛歚0.1.0-beta.1`锛堢粍浠剁増鏈級 +- 瀹為獙 tag锛歚mqdh-win-experimental-2026-12-02`锛?*涓嶅尮閰?* `mqdh-v`锛? + 鍥犳涓嶈繘鍏ュ簲鐢ㄥ唴鏇存柊鍊欓€夛級 +- Release锛?https://git.cflmy.cn/cflmy/marqdo-app-harness/releases/tag/mqdh-win-experimental-2026-12-02> +- 鏋勫缓婧愭彁浜わ細`6b970439f52eb1a956fb70a4207f33048ef064c5`锛堝垎鏀? + `codex/windows-distribution`锛汸R + [marqdo-app-harness#24](https://git.cflmy.cn/cflmy/marqdo-app-harness/pulls/24)锛? +- 褰掓。锛歚marqdo-harness-0.1.0-beta.1-x86_64-pc-windows-msvc.tar.gz`锛? + 684,093,946 bytes锛宻ha256 + `c647e13e5e4658facbc9c064c41b4b845fdf78121be38f786f8dfddb9da9bb9d` +- 鍙戣璇佹嵁璧勪骇锛歚mqdh-release.json`銆乣release-evidence.json`銆乣package-evidence.json` +- 缁勪欢璇佹嵁璁板綍锛? + [docs/mqdh/evidence/2026-12-02-windows-experimental.md](https://git.cflmy.cn/cflmy/marqdo-app-harness/src/branch/codex/windows-distribution/docs/mqdh/evidence/2026-12-02-windows-experimental.md) + +## 2. 鐪熷疄鏈満楠岃瘉锛圵indows 11 x64锛屽紑鍙戞満锛? + +```text +pnpm run build -> 10/10 gates PASS +node --test .../platform|release|install-root -> 10 passed / 0 failed +tar -xzf -> install.ps1 -> installed 0.1.0-beta.1 (6b970439f52e) +\bin\mqdh.cmd --version -> mqdh 0.1.0-beta.1 +\bin\mqdh.cmd doctor --json -> schema=marqdo.mqdh.doctor, + target=x86_64-pc-windows-msvc, + supported=true, node=v24.22.3 +\bin\mqdh.cmd --dump-config -> PASS锛?371 琛?mqdh profile锛? +渚挎惡 mqdh.cmd --version -> PASS +``` + +褰掓。鐢辩粍浠朵粨鐨?`scripts/package-windows.ps1` 鐢熸垚锛氱敓浜т緷璧?hoisted銆佸幓闄? +workspace 閾炬帴鍐滃満銆佸唴缃?Node 24銆佸畨瑁呰剼鏈笌鐗堟湰鎸囬拡锛沇indows profile 閾炬帴浣跨敤 +junction锛堟櫘閫氳处鎴锋棤闇€ Developer Mode锛夈€? + +## 3. 涓庢牴浠撴帴鍙楄寖鍥寸殑鍏崇郴 + +- 鏍逛粨 [`docs/RELEASE-POLICY.md`](../RELEASE-POLICY.md) 涓? + `docs/release-acceptance/mqdh-linux-x86_64-0.1.0-beta.1.json` 鎺ュ彈鐨?MQDH + 鑼冨洿浠嶆槸 **Linux x86_64**锛沇indows 鍦ㄨ璁板綍涓繚鎸?`UNVERIFIED`/涓嶆帹鑽愩€? +- 鏈疄楠屽垎鍙?*涓嶈繘鍏?* `/data/current.json` 鎺ㄨ崘/蹇収锛屼笉浣滀负瀹樼綉鏅€氫笅杞芥帹鑽愶紱 + 瀹樼綉濡傞渶灞曠ず瀹為獙鍖猴紝蹇呴』鏄庣‘ experimental 涓斾笉娣峰叆 supported 骞冲彴閫夋嫨銆? +- 鏍逛粨鎺ュ彈 Windows 闇€瑕侊細鍘熺敓 Windows CI lane銆佸畨瑁?鍚姩/鏍稿績璺緞鐪熷疄楠屾敹銆? + 绛惧悕绛栫暐涓庢挙鍥炴紨缁冿紱鍒版湡鍓嶇户缁敱 + [marqdo-app-harness#2](https://git.cflmy.cn/cflmy/marqdo-app-harness/issues/2) + 涓?[marqdo#90](https://git.cflmy.cn/cflmy/marqdo/issues/90)锛圡6锛夎窡韪€? + +## 4. 鏄庣‘杈圭晫 + +- 鏈鍚嶏紱SHA256 鍙瘉鏄庡畬鏁存€с€? +- 鏃犲師鐢?Windows CI lane锛涙瀯寤轰笌鍐峰畨瑁呰瘉鎹潵鑷淮鎶よ€呭紑鍙戞満銆? +- 搴旂敤鍐?Windows 鑷姩鏇存柊鏈獙璇侊紱鏇存柊鏂瑰紡涓烘墜鍔ㄤ笅杞藉苟杩愯 `install.ps1`銆? +- 鐪熷疄妯″瀷 E2E銆佺浜屽彴骞插噣 Windows 涓绘満銆佹祻瑙堝櫒宸ヤ綔鍙版埅鍥鹃獙鏀舵湭鎵ц銆? +- 涓嶈鐩?涓嶆敼鍐欏凡鍙戝竷璧勪骇锛涘悗缁増鏈娇鐢ㄦ柊鐨勪笉鍙彉 tag銆? + +## 5. 涓庡钩琛屽伐浣滅殑杈圭晫 + +鍚屼竴鏃ユ湡鐨?MQDH Linux Beta锛坄mqdh-v0.1.0-beta.1`锛屾牴鎺ュ彈璁板綍 +`docs/release-acceptance/mqdh-linux-x86_64-0.1.0-beta.1.json`锛夌敱鐙珛鐨勫彂琛岄摼璺? +璐熻矗锛涙湰璁板綍鍙ˉ鍏?Windows 瀹為獙鍒嗗彂浜嬪疄锛屼笉澶嶅埗鍏舵暟鎹€佷笉鏀瑰彉鍏舵帴鍙楃粨鏋溿€? + +## 6. 鍙戣鍒嗗眰锛堝榻?marqdo#96锛? + +鎸?[marqdo#96](https://git.cflmy.cn/cflmy/marqdo/issues/96) 鐨勭粍浠剁嫭绔嬪彂琛屽師鍒欙細 + +- 鏈鍙湪 `marqdo-app-harness` 鏈粨鏋勫缓 Product artifact锛圢ode 杩愯鏃?+ 搴旂敤 + 璧勬簮 + 鎵撳寘/瀹夎鍣級锛?*鏈噸鏂扮紪璇?* CLI/Worker/Stdlib/Ext锛屼篃鏈Е鍙戞垨绛夊緟 + 鍏跺畠缁勪欢/鏍圭敓鎬佸叏閲忓彂甯冦€? +- MQDH 杩愯鏃讹紙CLI `v3.0.0-rc.7` + Bundle 0.3.0锛変粛鏄嫭绔嬪埗鍝侊紝鐢辩敤鎴风‘璁ゅ悗缁? + `mqdh bootstrap` 浠庡畼鏂?Release 瀹夎锛汳QDH 缁勪欢鐗堟湰涓嶆帹瀵艰繍琛屾椂鐗堟湰銆? +- 鏈疄楠屽寘鏄?*缁勪欢鍙戣浜嬪疄**锛屼笉鏄牴鎺ㄨ崘缁勫悎锛屼篃涓嶆槸鈥滃熀纭€瀹夎缁勫悎 + 锛圖istribution Artifact锛夆€濄€傚熀纭€瀹夎缁勫悎鐨勭嫭绔嬭韩浠戒笌瑁呴厤鍏ュ彛鐢?#96 M3 + 纭锛沇indows 濡傞渶杩涘叆璇ョ粍鍚堬紝闇€鍗曠嫭鎺ュ彈锛屼笉鑳芥部鐢ㄦ湰瀹為獙鍖呫€? +- 鍚庣画 Windows 淇/鏂版瀯寤哄彧浜х敓鏂扮殑涓嶅彲鍙?MQDH 缁勪欢鐗堟湰涓?tag锛屼笉瑕佹眰 CLI銆? + Stdlib Bundle 鎴栧叾瀹冪粍浠跺悓姝ユ敼鐗堛€? diff --git a/docs/evidence/2026-12-02-windows-governance-and-beta-readiness.md b/docs/evidence/2026-12-02-windows-governance-and-beta-readiness.md new file mode 100644 index 0000000..f2ad3ec --- /dev/null +++ b/docs/evidence/2026-12-02-windows-governance-and-beta-readiness.md @@ -0,0 +1,222 @@ +# Windows 复核与公共 Beta 发版判定(2026-12-02) + +Date: 2026-12-02. +根提交: `857914a88d720fcb4a2bad8cee7ddec99e2ed420`(main),本记录所在提交包含 +主仓库的平台兼容修复;本记录不改变组件 gitlink。 +平台: Windows 11 家庭版 10.0.22631,Intel i7-1360P,x86_64。 + +## 1. 本轮改动范围(仅主仓库) + +目的:让主仓库的治理检查与本机可执行的验收入口在 Windows 开发机上真实通过, +消除此前“平台问题导致验证一直不通过”的环境性 FAIL;不改变产品语义、不新增 +catalog/lock/发布服务、不复制组件实现。 + +| 文件 | 改动 | +| --- | --- | +| `scripts/check-repo-conventions.py` | 读取 `.gitmodules`/`AGENTS.md` 显式 `encoding="utf-8"`(原默认 GBK,在中文 Windows 上解码失败) | +| `scripts/check-dev-secrets.py` | 凭据模式临时文件改为“写盘后关闭”,避免 Windows 上 `delete=True` 临时文件被独占导致 `git grep -f` 退出 128(原结果被降级为 UNVERIFIED);补 UTF-8 子进程解码 | +| `scripts/acceptance-stdlib.py`、`candidate-notify.py`、`impact.py`、`reconcile-releases.py`、`webhook-adapter.py`、`integration.sh` | 所有文本读写显式 UTF-8;`integration.sh` 内嵌 Python 同步修正 | +| `tests/integration/support.py`(新增) | 测试辅助:Windows 只读 `.git` 对象的稳健 `rmtree`、symlink 能力探测 | +| `tests/integration/test_layout.py`、`test_build_stdlib.py`、`test_repo_conventions.py`、`test_candidate_notify.py`、`test_webhook_adapter.py` | 夹具统一 UTF-8;只读对象删除走 `support.rmtree`;symlink 负例在无创建权限时显式 `skipTest`(Linux CI 仍覆盖),NFC 负例保留独立断言 | + +未改动:`components.toml`、`.gitmodules`、各组件 gitlink、任何发布脚本的判定语义。 + +## 2. 本机真实复核结果 + +环境:Git 2.46.0.windows.1、Python 3.12.7、Rust 1.100.1 +(`x86_64-pc-windows-msvc`)、cargo 1.100.1、VS 2022 17.11.3(MSVC 19.41)、 +Node 22.9.0、Git Bash 5.2.26。Rust 1.100.1 与组件 CI 的 `rust:1.100` 镜像同代。 + +35 个子模块全部检出到根 gitlink 固定提交(`git submodule status` 无 +`+`/`-`/`U`);根工作树在改动前干净。 + +```text +python3 scripts/check-layout.py PASS (exit 0) +python3 scripts/check-layout.py --checkouts PASS (exit 0, 35 个固定提交) +python3 scripts/check-repo-conventions.py PASS (38 components, exit 0) +python3 -m unittest discover -s tests/integration OK (116 tests, 2 skipped, 222.5s, exit 0) +python3 scripts/check-dev-secrets.py PASS (36 repos, 4 credential values, exit 0) +bash -n scripts/integration.sh PASS (exit 0) +python3 scripts/check-layout.py --active-entries 输出 16 个 active 验收入口 +``` + +两项 skip 均为“Windows 账户无 symlink 创建权限”,skip 原因显式写入日志: + +```text +test_symlink_entry_is_rejected ... skipped 'creating symbolic links needs Windows Developer Mode' +test_rejects_a_symbolic_entry ... skipped 'creating symbolic links needs Windows Developer Mode' +``` + +Bundle 由根唯一生产者按固定 gitlink 生成: + +```text +python3 scripts/build-stdlib.py --out .build/stdlib +name=marqdo-stdlib version=0.3.0 +tree_digest=sha256:4e47b0ff4b1e17d252cc74f20837014298fed4831050d65ca0c69f9cbdac55e9 +aliases_digest=sha256:5f513c0fdbb3c1e9829be3c9fa23a2d1e89cb8510073fb5eb1e8e2f5265a83bb +root_commit=857914a88d720fcb4a2bad8cee7ddec99e2ed420 +``` + +## 2.1 平台 CI(Linux,真实流水线) + +**CI/CD 只在 Woodpecker(`ci.cflmy.cn`)执行;Gitea 仅作为代码、Issue/PR 与 +Release/资产索引的来源,不承担任何 CI/CD 职责。** 本记录与本仓库工作流均遵守 +该边界(`.gitea/` 下只有 Issue/PR 模板,没有 Actions 或其它 Gitea 流水线)。 + +本分支 PR [#86](https://git.cflmy.cn/cflmy/marqdo/pulls/86) 的 eco 流水线 +[#479](https://ci.cflmy.cn/repos/6/pipeline/479) 在 Linux 上成功(commit +`6a728d2`,与本节本地结果同树): + +```text +pipelines/479 eco: clone=success layout=success checkouts=success + candidate=success app=success -> success +layout = check-layout.py + tests/integration(本记录所列 116 项) +checkouts= 递归固定提交 + check-repo-conventions.py +candidate= scripts/integration.sh(单一 CLI/Worker/Bundle 制品 + 全部 active 消费方) +app = MQDH Node lane(同一候选 CLI/Bundle) +``` + +main 上一次 push 流水线 [#449](https://ci.cflmy.cn/repos/6/pipeline/449) 在 +`857914a` 上同样是 success,说明本分支没有引入根生态回归。 + +同一时段 `release-reconcile` cron 流水线持续失败:最近 50 条流水线中有 46 条 +cron 为 failure(约覆盖 23 小时),失败步骤是 `reconcile`(exit 1),`clone` +成功。即 #85 要求的“根仓通过现有 Gitea/Woodpecker 协调机制自动发现 Beta 及 +发行证据”(C05/C07)当前自动化不可用;失败原因(对账账号身份、受保护分支上下文 +或 Secret)在 CI 日志不可读的情况下记为 **UNVERIFIED**,不能据此伪造通过。 + +该 cron 还与 `main` 分支上的 PR 流水线共享并发组:cron 启动会取消仍在运行的 +PR eco 流水线。PR #86 的 docs-only 提交 `a5e3892` 的流水线 +[#481](https://ci.cflmy.cn/repos/6/pipeline/481) 因此在 `app` 阶段变为 killed +(此前 `layout`/`checkouts`/`candidate` 已 success);实质代码提交 `6a728d2` 的 +[#479](https://ci.cflmy.cn/repos/6/pipeline/479) 是完整 success。因此 C05/C07 的 +阻塞不只来自 cron 失败,还包括它破坏同分支 PR 的 CI 结果。 + +## 3. 原生 Windows CLI 构建与运行(cli gitlink `afea4f9`) + +```text +MARQDO_BUILD_SOURCE_SHA=afea4f947473ae4cd5688e53a6545cce7f327b2f +cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker +Finished `release` profile [optimized] target(s) in 3m 07s +``` + +| 制品 | 大小 | SHA256 | +| --- | --- | --- | +| `marqdo.exe` | 10,065,408 | `A73616CB23600341715BE1DC2B11BA3E83CFCB776B24EAFB2B1CDD9585B0C900` | +| `marqdo-provider-worker.exe` | 309,248 | `0B9B8A74B1675A12AB769E62F24FF038A44E2E7807FDA95DA2F8772835E3CA2C` | + +以“相邻 `stdlib/` = 上节 Bundle”的安装布局冷运行: + +```text +marqdo --version -> marqdo 3.0.0-rc.6 +marqdo inspect --environment --json -> platform.family=windows, arch=x86_64, + strict.state=unavailable + ("no verified Windows job-object/appcontainer adapter"), + bundle 0.3.0 status=verified + tree_digest=sha256:4e47b0ff…, + producer.source.sha=afea4f94…, + worker.source_sha=afea4f94…, worker.status=present, + protocols.analysis=3 +marqdo check hello.mq.md -> checked 1 module(s): ok +marqdo run hello.mq.md -> 你好,Marqdo +``` + +这证明 Windows 原生构建、运行、Bundle 相邻校验与源码身份内嵌在固定提交上可工作; +它不把 Windows 提升为受支持发行平台,也不产生 Release 资产。 + +## 4. 公共 Beta 发版判定(marqdo#85) + +对当前根固定组合执行真实发布对账与发行身份核验(无写入): + +```text +python3 scripts/reconcile-releases.py --plan +schema=marqdo.release-reconcile.v1 root_sha=857914a… scan_complete=true +repositories=37 releases=13 +counts: blocked=11 historical-baseline=1 tracked=1 +dispatch_status=disabled +``` + +独立下载 `marqdo-cli v3.0.0-rc.6` 的 Release 资产复核: + +```text +tag v3.0.0-rc.6 -> commit 63776735e924ade279cdf59d5c733dc24bfdabbb +asset size=4888636 +asset sha256=8dc0b006302e03c23451b8ea9f8a0fcdae8bf67c80c546bee2434bf69755bfe3 +.sha256 文件与 release-evidence.json 记录一致(index sha256=66f0e327…) +``` + +发行身份与根固定组合不一致,这是发版阻塞的核心事实: + +- 根 gitlink `cli=afea4f9…`,而 rc.6 源为 `63776735…`;根组合中新提交无对应 Release。 +- rc.6 `release-evidence.json` 的六个 std 依赖 + (`4907652/848af7a/63bcea5/e18b0b1/053ddb0/c2a7d32`)与根当前 std gitlink + (`3c93856/bcaa3b3/91a4f8e/eb6432f/a202a89/cf359b9`)均不同。 +- 其余组件发行无法被对账接受:view/lint/knowledge 缺 `release-evidence.json` + (`release evidence index missing`),prove 无/多余资产,std-text 缺同 SHA 组件 CI。 +- 主仓库在本次发布前没有任何公开 Release(Gitea releases 为空),也没有根级 + `release-acceptance` 记录或公开发行数据投影。发布后的权威记录见 + [`docs/release-acceptance/`](../release-acceptance/) 与根 Release `v3.0.0-rc.7`(§5.2)。 + +按 #85 分组统计(发布前、全量口径;发布后的范围化状态见 §5.2): +✅ PASS 5 / 🟡 PARTIAL 16 / ❌ MISSING 10。关键阻塞: + +| 组 | 关键阻塞 | +| --- | --- | +| A 政策与范围 | 根尚无 Beta 范围政策与接受记录;无按影响分类的 blocker 清单 | +| B 真实发行 | 受支持平台(Linux)的验收未在本机重跑;组件发行与根 gitlink 不同身份;Bundle 0.3.0 无已发布资产 | +| C 主仓集成 | Linux 候选集成(pipeline #479)已通过,但无按产品/平台范围选择的入口与根接受记录;`release-reconcile` cron 连续失败;无公开发行数据投影 | +| D 官网交付 | `https://marqdo.com` 可访问且下载/发行页存在,但公开数据入口 `/data/current.json` 返回 404;无已核验 Beta 可展示,撤回传播未验证 | +| E 后续跟踪 | 无根级 BR-F1/F2/F3 平台/延期任务表与 Beta 反馈追踪入口 | + +## 5. 结论 + +### 5.1 全量门禁判定 + +全量 Stable/无条件发部门禁**未满足**:strict L1 disposable-VM PASS、dedicated-node +性能 PASS、Windows/macOS 原生运行、安装包签名、MQDH/AI 真实验收仍然是 +`UNVERIFIED`/`UNSUPPORTED`。因此**不能宣称全生态 Stable 或全平台 Beta 已覆盖**。 + +### 5.2 首个公共预发布已由维护者完成(`v3.0.0-rc.7`) + +#85 的范围化政策已落到 main(提交 `7d29fa2`): + +- 唯一现行政策:[`docs/RELEASE-POLICY.md`](../RELEASE-POLICY.md); +- 接受记录:[`docs/release-acceptance/marqdo-linux-x86_64-3.0.0-rc.7.json`](../release-acceptance/marqdo-linux-x86_64-3.0.0-rc.7.json); +- 公开投影生产者:[`scripts/project-release.py`](../../scripts/project-release.py)(派生 + `/data/current.json` 指针与不可变快照,SHA/资产/Bundle 不匹配即 fail-closed)。 + +根 Release [`v3.0.0-rc.7`](https://git.cflmy.cn/cflmy/marqdo/releases/tag/v3.0.0-rc.7) +(RC 渠道,tag → `7d29fa2`)发布 `release-acceptance.json`、`current.json`、 +快照 JSON、`reconcile-report.json`、`release-gates.json` 与 cold-install/extension/perf +证据。组件 CLI `v3.0.0-rc.7`(源 `63562d8`,Linux 归档 +sha256 `10714820…`)由同 SHA Woodpecker pipeline 176 验收,根 gitlink 已 pin 到该源。 + +本次接受范围:`marqdo` 基础发行 / Linux x86_64 glibc ≥ 2.39。排除项(各自有 +`UNVERIFIED`/`UNSUPPORTED` 状态与 tracker):Windows/macOS 原生、strict L1 PASS、 +dedicated-node 性能、安装包/元数据签名、自动更新、MQDH/AI 与各 Tool/Ext 发行、 +官网生产 `/data/` 托管。 + +### 5.3 本分支早期 `v3.0.0-beta.1` 快照(已不推荐) + +在 `rc.7` 接受记录出现前,本分支为打破“官网无内容可消费”的循环,曾发布 +`v3.0.0-beta.1`(tag → `857914a`,推荐 CLI `3.0.0-rc.6` 归档,附 +`public-beta.json`)。该快照已被 `rc.7` 接受记录取代:其 Gitea Release 说明已标注 +superseded,不再作为推荐入口;tag 与已上传资产保持不可变,仅作历史。主仓库不再 +维护第二份发行记录——权威数据是 `docs/release-acceptance/` 与根 Release 资产。 + +未验证(UNVERIFIED,不得当作 PASS): + +- Windows/macOS 原生构建、运行、安装与 ABI;本机 Windows 构建/runtime smoke 仅是 + 开发机证据,不是发布平台验收; +- Linux disposable-VM strict L1、dedicated-node 性能、真实模型服务; +- 官网生产 `/data/current.json` 托管、匿名下载/摘要/安装 smoke 与撤回演练; +- symlink 拒绝负例在 Windows 上显式 skip,Linux CI 仍覆盖。 + +## 6. 后续最小真实路径 + +1. 官网(#83/#84)消费根投影 `/data/current.json` 与快照,完成生产部署、匿名 + 下载/摘要/安装 smoke 与撤回演练; +2. 从 rc.7 之后的候选补 Windows/macOS 原生 lane、strict VM 与 dedicated-node + 证据,逐平台扩大已接受范围; +3. 各 Tool/Ext/MQDH 按自身工单独立发行,不阻塞 `marqdo` 基础发行; +4. 未达标项保留真实状态与 tracker,不因首发关闭而丢失。 diff --git a/docs/evidence/2026-12-02-windows-native-experimental.md b/docs/evidence/2026-12-02-windows-native-experimental.md new file mode 100644 index 0000000..796d3b4 --- /dev/null +++ b/docs/evidence/2026-12-02-windows-native-experimental.md @@ -0,0 +1,68 @@ +# Windows x86_64 实验性分发记录(2026-12-02) + +Date: 2026-12-02. +性质:**experimental(维护者批准的受限实验分发),不是受支持发行。** +源码:`cflmy/marqdo-cli` 提交 `63562d8ff5b40334366761ff4d3644d0dd5b458d` +(与官方 Linux `v3.0.0-rc.7` 相同源码)。 +Release:https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.7-windows.1 + +## 1. 为什么单独记录 + +官方 [`v3.0.0-rc.7`](https://git.cflmy.cn/cflmy/marqdo/releases/tag/v3.0.0-rc.7) +接受范围只有 Linux x86_64;`docs/release-acceptance/marqdo-linux-x86_64-3.0.0-rc.7.json` +把 Windows 记为 `UNVERIFIED`/不提供下载。为让 Windows 用户提前试用并反馈, +维护者批准在组件仓发布一个 `experimental` 归档;它**不进入**根仓公开发行投影的 +推荐组合,也不改变 `docs/RELEASE-POLICY.md` 的平台支持状态。 + +## 2. 构建与验证(Windows 11 开发机,真实执行) + +```text +OS/CPU Windows 11 10.0.22631, Intel i7-1360P, x86_64 +toolchain rustc/cargo 1.100.1 (msvc host), MSVC 19.41 / VS 2022 17.11 +source cli 63562d8ff5b40334366761ff4d3644d0dd5b458d +build MARQDO_BUILD_SOURCE_SHA= cargo build --release --locked \ + -p marqdo-cli -p marqdo-provider-worker (natively on Windows) +bundle scripts/build-stdlib.py -> marqdo-stdlib 0.3.0 + tree sha256:4e47b0ff…, aliases sha256:5f513c0f… +``` + +归档冷解压后(不含构建目录)实测: + +```text +marqdo --version -> marqdo 3.0.0-rc.7 +marqdo inspect --environment --json -> platform windows/x86_64, + strict.state=unavailable + ("no verified Windows job-object/appcontainer adapter"), + bundle 0.3.0 status=verified, + producer.source.sha=63562d8…, + worker.source_sha=63562d8…, worker.status=present +marqdo check hello.mq.md -> checked 1 module(s): ok +marqdo run hello.mq.md -> 你好,Marqdo rc.7 +``` + +## 3. 归档身份 + +| 项 | 值 | +| --- | --- | +| 文件 | `marqdo-3.0.0-rc.7-x86_64-pc-windows-msvc.zip` | +| 大小 / SHA256 | 4,086,877 bytes / `af65880c6f81605dc781fd5cda84a1508229908b451fedde3b98e3e71cb7add0` | +| 匿名下载复核 | 200,大小与 SHA256 与发布记录一致 | +| 归档内 `marqdo.exe` | 10,065,408 bytes,sha256 `f1280c08…` | +| 归档内 `marqdo-provider-worker.exe` | 309,248 bytes,sha256 `bc86fa1e…` | +| `RELEASE_INFO.json` | `target_triple=x86_64-pc-windows-msvc`、`platform_support=experimental`、`supported_platforms=[]` | +| 机器可读记录 | Release 资产 `windows-experimental.json` | + +归档内容:两个 `.exe`、完整 `stdlib/` Bundle、`LICENSE-APACHE`、`README.md`、 +`RELEASE_INFO.json`、`SOURCE_SHA`、`WINDOWS-EXPERIMENTAL.md`。构建脚本为一次性的 +维护者打包步骤(确定性 zip,固定时间戳),**不是**新增的常设发布服务,也没有把 +Windows 构建塞进主仓库或替代组件发布链路。 + +## 4. 明确的边界 + +- 不是组件 CI 产物,未签名;SHA256 只证明完整性,不是发布者身份。 +- Windows 原生 plugin/provider/worker ABI 仍为 `UNSUPPORTED`。 +- Windows `strict` 明确 `unavailable`,fail-closed,不静默降级。 +- 不承诺与 Linux rc.7 等价的安装/性能/安全验收、签名或自动更新。 +- 不进入根仓推荐组合;Linux x86_64 `v3.0.0-rc.7` 仍是官方推荐发行。 +- 后续 Windows 原生 lane、ABI 与正式支持由 + [marqdo-cli#26](https://git.cflmy.cn/cflmy/marqdo-cli/issues/26) 跟踪。 diff --git a/docs/evidence/2026-12-03-mqdh-windows-usable.md b/docs/evidence/2026-12-03-mqdh-windows-usable.md new file mode 100644 index 0000000..a2736f2 --- /dev/null +++ b/docs/evidence/2026-12-03-mqdh-windows-usable.md @@ -0,0 +1,67 @@ +# MQDH Windows x86_64 可用实验版记录(2026-12-03) + +Date: 2026-12-03. +性质:**组件独立 experimental 分发**;不是根仓接受范围,不改变 MQDH 的 Linux +supported 状态。 + +## 1. 组件发行事实 + +- 组件:`cflmy/marqdo-app-harness`(MQDH) +- 版本:`0.1.0-beta.1`(组件版本) +- 实验 tag:`mqdh-win-experimental-2026-12-03`(不匹配 `mqdh-v`, + 不进入应用内更新候选) +- Release: +- 构建源提交:`0d3a9c4369a49244b3405998fa62ee851550cd88`(分支 + `codex/windows-distribution`;PR + [marqdo-app-harness#24](https://git.cflmy.cn/cflmy/marqdo-app-harness/pulls/24)) +- 归档:`marqdo-harness-0.1.0-beta.1-x86_64-pc-windows-msvc.tar.gz`, + 688,136,852 bytes,sha256 + `6bb1580c259563a6d791f9ae526ac3172463716e82a95d6c4b9507748cf58e34` + (发布为 4 个分卷 + 下载脚本) +- 内置离线运行时:`marqdo-3.0.0-rc.7-x86_64-pc-windows-msvc.tar.gz` + (4,060,223 bytes,sha256 `182a07c7…`,源 `63562d8…`,CLI + Worker + + `marqdo-stdlib 0.3.0`,含 `RELEASE_INFO.json`/`SOURCE_SHA`) +- 发行证据资产:`mqdh-release.json`、`release-evidence.json`、`package-evidence.json` +- 组件证据记录: + [docs/mqdh/evidence/2026-12-03-windows-usable.md](https://git.cflmy.cn/cflmy/marqdo-app-harness/src/branch/codex/windows-distribution/docs/mqdh/evidence/2026-12-03-windows-usable.md) + +## 2. 可用性验证(Windows 11 x64,开发机) + +```text +归档冷解压 -> install.ps1 -> installed 0.1.0-beta.1 (0d3a9c4369a4) +mqdh bootstrap --json -> status=ready(自动使用内置 runtime-deps,无网络) + environment cli-3.0.0-rc.7-182a07c798ef + cli_path marqdo.exe, worker_path marqdo-provider-worker.exe + bundle sha256:4e47b0ff…, source_sha 63562d8… + smoke: 真实 check + call 阶乘(n=5) = 120 +mqdh doctor --json -> runtime installed(overall=warn:Tool 缺 Windows 归档) +mqdh --dump-config -> PASS(1371 行) +便携 mqdh.cmd --version -> mqdh 0.1.0-beta.1 +``` + +从压缩归档合并校验(4 个分卷)后 SHA256 与记录一致。 + +## 3. 与根仓接受范围的关系 + +- 根仓 [`docs/RELEASE-POLICY.md`](../RELEASE-POLICY.md) 与 + `docs/release-acceptance/` 当前接受的 MQDH 范围仍是 Linux x86_64;Windows + 保持 `UNVERIFIED`/不推荐。 +- 本实验分发不进入 `/data/current.json` 推荐/快照;官网只能以 experimental 展示。 +- 根接受 Windows 仍需:原生 Windows CI lane、Knowledge/View Tool 的 Windows + 归档(或明确排除)、签名策略与第二台干净主机回归;跟踪 + [marqdo-app-harness#2](https://git.cflmy.cn/cflmy/marqdo-app-harness/issues/2) + 与 [marqdo#90](https://git.cflmy.cn/cflmy/marqdo/issues/90)(M6)。 + +## 4. 边界与发行分层(#96/#102) + +- 只在 `marqdo-app-harness` 本仓构建;未重新编译 CLI/Worker/Stdlib/Ext,未触发 + 根仓或其它组件构建;CLI/Worker/Bundle 来自组件构建并经 `RELEASE_INFO.json` + 校验。 +- 应用、运行时与组合身份是不同事实;本包不改变 Linux MQDH 的接受结果,也不 + 改变 CLI 的 supported 平台声明(Windows 运行时仍是 experimental 资产)。 +- 后续修复产生新的不可变 MQDH 实验 tag;不回写已发布资产。 + +## 5. 前序记录 + +`2026-12-02-mqdh-windows-experimental.md` 记录的上一版只能启动壳、bootstrap 运行时 +链路不通;本记录取代其 Windows 可用性结论,前序文档保留为历史证据。 diff --git a/scripts/acceptance-stdlib.py b/scripts/acceptance-stdlib.py index 0117afb..ae7274d 100755 --- a/scripts/acceptance-stdlib.py +++ b/scripts/acceptance-stdlib.py @@ -96,7 +96,7 @@ def verify_bundle(bundle: Path) -> dict: manifest_path = bundle / "stdlib.json" if not manifest_path.is_file(): raise AcceptanceError(f"missing Bundle manifest: {manifest_path}") - manifest = json.loads(manifest_path.read_text()) + manifest = json.loads(manifest_path.read_text(encoding="utf-8")) for field in ("name", "version", "digest", "aliases_digest"): if not isinstance(manifest.get(field), str) or not manifest[field]: raise AcceptanceError(f"manifest has no {field}") @@ -172,7 +172,7 @@ def run_case(cli: str, bundle: Path, case: dict) -> dict: def load_components() -> list[dict]: - catalog = tomllib.loads((ROOT / "components.toml").read_text()) + catalog = tomllib.loads((ROOT / "components.toml").read_text(encoding="utf-8")) return [ component for component in catalog["component"] @@ -187,7 +187,7 @@ def load_explicit_packages() -> list[dict]: 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()) + catalog = tomllib.loads((ROOT / "components.toml").read_text(encoding="utf-8")) packages = [] for component in catalog["component"]: if component.get("kind") != "extension": @@ -314,7 +314,7 @@ def packaging_gates(pack_tool: str, bundle: Path, work: Path) -> list[dict]: if archives[0].read_bytes() != archives[1].read_bytes(): raise AcceptanceError("two packaging runs are not byte-identical") descriptor = json.loads( - sorted(archives[0].parent.glob("*.json"))[0].read_text() + sorted(archives[0].parent.glob("*.json"))[0].read_text(encoding="utf-8") ) results.append( { @@ -368,7 +368,7 @@ def main(argv: list[str]) -> int: version = run([cli, "--version"]).stdout.decode().strip() cases = [] for path in sorted(CASES.glob("*.json")): - case = json.loads(path.read_text()) + case = json.loads(path.read_text(encoding="utf-8")) if case.get("schema") != CASES_SCHEMA: raise AcceptanceError(f"unsupported case schema: {path}") cases.append(run_case(cli, bundle, case)) @@ -404,7 +404,7 @@ def main(argv: list[str]) -> int: return 1 text = json.dumps(evidence, ensure_ascii=False, indent=2) + "\n" if args.evidence: - Path(args.evidence).write_text(text) + Path(args.evidence).write_text(text, encoding="utf-8") print(text) return 0 diff --git a/scripts/candidate-notify.py b/scripts/candidate-notify.py index 36c05bf..0f8273c 100755 --- a/scripts/candidate-notify.py +++ b/scripts/candidate-notify.py @@ -134,7 +134,7 @@ def check_ci(notification: dict, ci_hosts: list[str]) -> dict: 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()) + state = json.loads(path.read_text(encoding="utf-8")) if not isinstance(state.get("seen"), dict): raise NotificationError(f"invalid candidate state file: {path}") return state @@ -223,7 +223,7 @@ def verify( } if write_state: state_path.parent.mkdir(parents=True, exist_ok=True) - state_path.write_text(json.dumps(state, indent=2) + "\n") + state_path.write_text(json.dumps(state, indent=2) + "\n", encoding="utf-8") return { "schema": PLAN_SCHEMA, "schema_version": SCHEMA_VERSION, @@ -267,7 +267,7 @@ def main(argv: list[str]) -> int: args = parser.parse_args(argv) ci_hosts = args.ci_host or [DEFAULT_CI_HOST] try: - notification = json.loads(Path(args.notification).read_text()) + notification = json.loads(Path(args.notification).read_text(encoding="utf-8")) if not isinstance(notification, dict): raise NotificationError("notification must be a JSON object") plan = verify( @@ -293,14 +293,14 @@ def main(argv: list[str]) -> int: } text = json.dumps(rejected, ensure_ascii=False, indent=2) + "\n" if args.out: - Path(args.out).write_text(text) + Path(args.out).write_text(text, encoding="utf-8") 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) + Path(args.out).write_text(text, encoding="utf-8") if args.json: print(text, end="") else: diff --git a/scripts/check-dev-secrets.py b/scripts/check-dev-secrets.py index 96a3f95..91c3212 100755 --- a/scripts/check-dev-secrets.py +++ b/scripts/check-dev-secrets.py @@ -23,6 +23,7 @@ Usage: from __future__ import annotations import argparse +import os import re import subprocess import sys @@ -68,6 +69,8 @@ def git(repo: Path, *args: str) -> subprocess.CompletedProcess[str]: check=False, capture_output=True, text=True, + encoding="utf-8", + errors="replace", ) @@ -164,16 +167,22 @@ def scan_repo(repo: Path, values: list[str], generic: bool) -> tuple[list[str], if not values: return leaks, warnings - with tempfile.NamedTemporaryFile("w", encoding="utf-8", delete=True, prefix="mq-secret-") as handle: - handle.write("\n".join(values) + "\n") - handle.flush() - patterns = Path(handle.name) + # A delete-on-close temporary file stays locked against other processes on + # Windows, and ``git grep -f`` then fails with exit 128. Materialize the + # pattern file, close the descriptor and remove it once the scan is done. + descriptor, name = tempfile.mkstemp(prefix="mq-secret-", text=True) + os.close(descriptor) + patterns = Path(name) + try: + patterns.write_text("\n".join(values) + "\n", encoding="utf-8") code, hits = grep_patterns(repo, patterns) if code != 0: warnings.append(f"{display(repo)}: git grep failed (exit {code}); result UNVERIFIED") else: for hit in sorted(hits): leaks.append(f"{display(repo)}: credential value in {hit}") + finally: + patterns.unlink(missing_ok=True) if generic: for pattern in GENERIC_PATTERNS: diff --git a/scripts/check-repo-conventions.py b/scripts/check-repo-conventions.py index 825ca3e..df3396f 100755 --- a/scripts/check-repo-conventions.py +++ b/scripts/check-repo-conventions.py @@ -50,7 +50,7 @@ def submodule_urls(root: Path) -> dict[str, str]: return {} result: dict[str, str] = {} current_path = None - for raw in path.read_text().splitlines(): + for raw in path.read_text(encoding="utf-8").splitlines(): line = raw.strip() if line.startswith("[submodule "): current_path = None @@ -79,7 +79,7 @@ def check_active(root: Path, component: dict, errors: list[str]) -> None: if not agents.is_file(): errors.append(f"{identifier}: AGENTS.md missing") else: - text = agents.read_text() + text = agents.read_text(encoding="utf-8") if MARKER not in text: errors.append(f"{identifier}: AGENTS.md lacks `{MARKER}`") if CONVENTIONS_URL not in text: @@ -158,7 +158,7 @@ def check(root: Path) -> list[str]: if not root_agents.is_file(): errors.append("root AGENTS.md missing") else: - text = root_agents.read_text() + text = root_agents.read_text(encoding="utf-8") 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: diff --git a/scripts/impact.py b/scripts/impact.py index 710b8ba..ea0f136 100755 --- a/scripts/impact.py +++ b/scripts/impact.py @@ -349,7 +349,7 @@ def main(argv: list[str]) -> int: return 1 text = json.dumps(report, ensure_ascii=False, indent=2) + "\n" if args.out: - Path(args.out).write_text(text) + Path(args.out).write_text(text, encoding="utf-8") if args.json: print(text, end="") else: diff --git a/scripts/integration.sh b/scripts/integration.sh index 4074469..fe8e396 100755 --- a/scripts/integration.sh +++ b/scripts/integration.sh @@ -95,7 +95,7 @@ CARGO_TARGET_DIR="$root/cli/target" \ -p marqdo-cli -p marqdo-provider-worker version="$(python3 -c ' import pathlib, tomllib -data = tomllib.loads(pathlib.Path("cli/Cargo.toml").read_text()) +data = tomllib.loads(pathlib.Path("cli/Cargo.toml").read_text(encoding="utf-8")) print(data["workspace"]["package"]["version"]) ')" @@ -111,7 +111,7 @@ 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")" +test "$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1], encoding="utf-8"))["version"])' "$installed/stdlib/stdlib.json")" = "$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1], encoding="utf-8"))["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 @@ -139,10 +139,11 @@ manifest = { '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(), + ['git', '-C', str(root / 'apps/harness'), 'rev-parse', 'HEAD'], text=True, + encoding='utf-8').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') +(work / 'app-candidate.json').write_text(json.dumps(manifest, indent=2) + '\n', encoding='utf-8') +(work.parent / 'app-candidate.json').write_text(json.dumps(manifest, indent=2) + '\n', encoding='utf-8') print(json.dumps(manifest, indent=2)) PY @@ -269,7 +270,7 @@ 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 +impact = json.loads(impact_path.read_text(encoding="utf-8")) if impact_path.is_file() else None evidence = { "schema": "marqdo.ecosystem-integration", "schema_version": 1, @@ -279,7 +280,7 @@ evidence = { "stdlib_aliases_digest": sys.argv[5], "archive": archive.name, "archive_sha256": "sha256:" + hashlib.sha256(archive.read_bytes()).hexdigest(), - "active_entries": [line.split("\t") for line in (work / "active-entries.tsv").read_text().splitlines()], + "active_entries": [line.split("\t") for line in (work / "active-entries.tsv").read_text(encoding="utf-8").splitlines()], "impact": ( { "changed": impact["changed"], @@ -293,7 +294,7 @@ evidence = { ), "status": "PASS", } -(work / "integration-evidence.json").write_text(json.dumps(evidence, indent=2) + "\n") +(work / "integration-evidence.json").write_text(json.dumps(evidence, indent=2) + "\n", encoding="utf-8") print(json.dumps(evidence, indent=2)) PY diff --git a/scripts/reconcile-releases.py b/scripts/reconcile-releases.py index 152807a..ce1374e 100755 --- a/scripts/reconcile-releases.py +++ b/scripts/reconcile-releases.py @@ -747,7 +747,7 @@ def reconcile(client, root=PROJECT_ROOT, apply=False, report_out=None, cutoff=No report["dispatch_error"] = dispatch_error if report_out: report_out.parent.mkdir(parents=True, exist_ok=True) - report_out.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n") + report_out.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") return report diff --git a/scripts/webhook-adapter.py b/scripts/webhook-adapter.py index 203336f..35c6493 100755 --- a/scripts/webhook-adapter.py +++ b/scripts/webhook-adapter.py @@ -351,7 +351,7 @@ def main(argv: list[str]) -> int: raw = Path(args.webhook).read_bytes() statuses = [] if args.statuses: - statuses = json.loads(Path(args.statuses).read_text()) + statuses = json.loads(Path(args.statuses).read_text(encoding="utf-8")) plan = verify_webhook( raw, args.event, @@ -391,7 +391,7 @@ def main(argv: list[str]) -> int: return 1 text = json.dumps(plan, ensure_ascii=False, indent=2) + "\n" if args.out: - Path(args.out).write_text(text) + Path(args.out).write_text(text, encoding="utf-8") if args.json: print(text, end="") else: diff --git a/tests/integration/support.py b/tests/integration/support.py new file mode 100644 index 0000000..a1d1f71 --- /dev/null +++ b/tests/integration/support.py @@ -0,0 +1,49 @@ +"""Portable helpers shared by the root integration tests. + +The governance gates are also run on developer workstations, so the fixtures +must not depend on Unix-only filesystem semantics: + +- Git marks object files read-only; Windows therefore refuses a plain + ``shutil.rmtree`` over a checked-out submodule. +- Unprivileged Windows accounts cannot create symbolic links unless Developer + Mode or the SeCreateSymbolicLinkPrivilege is enabled. Tests that need a + symlink skip with an explicit reason instead of failing the whole gate; the + Linux CI keeps exercising that path. + +The helpers never change what a test asserts on a platform that provides the +behaviour. +""" + +import os +import shutil +import stat +import sys +import tempfile + + +def rmtree(path): + """Remove *path*, clearing the read-only bits Windows Git leaves behind.""" + if sys.version_info >= (3, 12): + shutil.rmtree(path, onexc=_clear_read_only) + else: # pragma: no cover - Python 3.11 compatibility + shutil.rmtree(path, onerror=_clear_read_only) + + +def _clear_read_only(function, target, _exception): + os.chmod(target, stat.S_IWRITE) + function(target) + + +def symlinks_supported(): + """Return True when this account can create symbolic links.""" + if not hasattr(os, "symlink"): + return False + with tempfile.TemporaryDirectory() as directory: + try: + os.symlink( + os.path.join(directory, "target"), + os.path.join(directory, "link"), + ) + except OSError: + return False + return True diff --git a/tests/integration/test_build_stdlib.py b/tests/integration/test_build_stdlib.py index be8b15b..03babd0 100644 --- a/tests/integration/test_build_stdlib.py +++ b/tests/integration/test_build_stdlib.py @@ -19,6 +19,11 @@ SPEC = importlib.util.spec_from_file_location("build_stdlib", SCRIPT) producer = importlib.util.module_from_spec(SPEC) SPEC.loader.exec_module(producer) +SUPPORT = Path(__file__).resolve().parent / "support.py" +SUPPORT_SPEC = importlib.util.spec_from_file_location("integration_support", SUPPORT) +support = importlib.util.module_from_spec(SUPPORT_SPEC) +SUPPORT_SPEC.loader.exec_module(support) + GIT_ENV = { "GIT_AUTHOR_NAME": "test", "GIT_AUTHOR_EMAIL": "test@example.invalid", @@ -177,7 +182,7 @@ class ProducerTest(unittest.TestCase): "text/utf8.mq.md", ]) self.assertNotIn("README.md", payload["files"]) - manifest = json.loads((out_one / "stdlib.json").read_text()) + manifest = json.loads((out_one / "stdlib.json").read_text(encoding="utf-8")) self.assertEqual(manifest["name"], "marqdo-stdlib") self.assertEqual(manifest["version"], "0.1.0") self.assertEqual(manifest["digest"], payload["tree_digest"]) @@ -258,7 +263,7 @@ class ProducerTest(unittest.TestCase): with self.assertRaises(SystemExit): self.build() - def test_non_nfc_and_symlink_entries_are_rejected(self): + def test_non_nfc_entry_is_rejected(self): import unicodedata decomposed = unicodedata.normalize("NFD", "text/café.mq.md") @@ -273,6 +278,9 @@ class ProducerTest(unittest.TestCase): with self.assertRaises(SystemExit): self.build() + def test_symlink_entry_is_rejected(self): + if not support.symlinks_supported(): + self.skipTest("creating symbolic links needs Windows Developer Mode") tmp = tempfile.TemporaryDirectory() try: root = Path(tmp.name) / "sr" @@ -346,7 +354,7 @@ class ProducerTest(unittest.TestCase): } self.two_component_root(text_sha, io_sha, aliases=[alias]) summary, out = self.build() - manifest = json.loads((out / "stdlib.json").read_text()) + manifest = json.loads((out / "stdlib.json").read_text(encoding="utf-8")) self.assertEqual( manifest["aliases_digest"], json.loads(summary)["aliases_digest"] ) diff --git a/tests/integration/test_candidate_notify.py b/tests/integration/test_candidate_notify.py index 72bccde..1f83d26 100644 --- a/tests/integration/test_candidate_notify.py +++ b/tests/integration/test_candidate_notify.py @@ -52,7 +52,7 @@ def init(path: Path) -> Path: def write(path: Path, data: str) -> None: path.parent.mkdir(parents=True, exist_ok=True) - path.write_text(data) + path.write_text(data, encoding="utf-8") def commit(repo: Path, message: str = "fixture") -> str: @@ -151,13 +151,13 @@ class NotifyTest(unittest.TestCase): } data.update(overrides) path = self.base / "notification.json" - path.write_text(json.dumps(data)) + path.write_text(json.dumps(data), encoding="utf-8") 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()), + json.loads(path.read_text(encoding="utf-8")), accepted or self.accepted, self.state, ["ci.cflmy.cn"], diff --git a/tests/integration/test_layout.py b/tests/integration/test_layout.py index 9417883..a7a4628 100644 --- a/tests/integration/test_layout.py +++ b/tests/integration/test_layout.py @@ -1,5 +1,4 @@ import importlib.util -import shutil import subprocess import tempfile import unittest @@ -11,6 +10,11 @@ SPEC = importlib.util.spec_from_file_location("check_layout", SCRIPT) layout = importlib.util.module_from_spec(SPEC) SPEC.loader.exec_module(layout) +SUPPORT = Path(__file__).resolve().parent / "support.py" +SUPPORT_SPEC = importlib.util.spec_from_file_location("integration_support", SUPPORT) +support = importlib.util.module_from_spec(SUPPORT_SPEC) +SUPPORT_SPEC.loader.exec_module(support) + CLI = ''' [[component]] id = "cli" @@ -143,11 +147,11 @@ class LayoutTests(unittest.TestCase): return subprocess.check_output(["git", "-C", cwd or self.root, *args]).decode() def candidate(self, metadata=CLI, url=CORE_URL, extra=None, file=None, extra_url=None): - (self.root / "components.toml").write_text(metadata) + (self.root / "components.toml").write_text(metadata, encoding="utf-8") modules = f'[submodule "cli"]\npath = cli\nurl = {url}\n' if extra_url: modules += f'[submodule "{extra}"]\npath = {extra}\nurl = {extra_url}\n' - (self.root / ".gitmodules").write_text(modules) + (self.root / ".gitmodules").write_text(modules, encoding="utf-8") self.git("add", ".gitmodules", "components.toml") self.git("update-index", "--add", "--cacheinfo", f"160000,{self.sha},cli") if extra: @@ -155,7 +159,7 @@ class LayoutTests(unittest.TestCase): if file: path = self.root / file path.parent.mkdir(parents=True) - path.write_text("Fixture") + path.write_text("Fixture", encoding="utf-8") self.git("add", file) self.git("-c", "user.name=Test", "-c", "user.email=test@example.invalid", "commit", "-qm", "candidate") @@ -204,16 +208,16 @@ class LayoutTests(unittest.TestCase): layout.validate("HEAD", False) def root_fixture(self, metadata, modules, links, files=None): - (self.root / "components.toml").write_text(metadata) + (self.root / "components.toml").write_text(metadata, encoding="utf-8") 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) + (self.root / ".gitmodules").write_text(modules, encoding="utf-8") for relative, content in (files or {}).items(): path = self.root / relative path.parent.mkdir(parents=True, exist_ok=True) - path.write_text(content) + path.write_text(content, encoding="utf-8") self.git("add", "-A") for path, sha in links.items(): self.git("update-index", "--add", "--cacheinfo", f"160000,{sha},{path}") @@ -361,7 +365,7 @@ class HierarchicalLayoutTests(unittest.TestCase): def write(self, repo, relative, content): path = Path(repo) / relative path.parent.mkdir(parents=True, exist_ok=True) - path.write_text(content) + path.write_text(content, encoding="utf-8") def stage(self, repo): self.git("add", "-A", cwd=repo) @@ -499,7 +503,7 @@ class HierarchicalLayoutTests(unittest.TestCase): def test_non_checkout_mode_only_validates_the_root_layer(self): self.assemble() - shutil.rmtree(self.root / "extensions" / "web") + support.rmtree(self.root / "extensions" / "web") layout.validate("HEAD", False) with self.assertRaisesRegex(ValueError, "missing submodule checkout: extensions/web"): layout.validate("HEAD", True) @@ -533,7 +537,7 @@ entry = "scripts/acceptance.sh" def test_rejects_a_dirty_domain_child(self): self.assemble() - (self.root / "extensions/web/design/scratch.txt").write_text("dirty") + (self.root / "extensions/web/design/scratch.txt").write_text("dirty", encoding="utf-8") with self.assertRaisesRegex(ValueError, r"domain web \(extensions/web\): dirty submodule: design"): layout.validate("HEAD", True) @@ -545,7 +549,7 @@ entry = "scripts/acceptance.sh" def test_rejects_a_missing_domain_child_checkout(self): self.assemble() - shutil.rmtree(self.root / "extensions/web/preview") + support.rmtree(self.root / "extensions/web/preview") with self.assertRaisesRegex(ValueError, r"domain web \(extensions/web\): missing submodule checkout: preview"): layout.validate("HEAD", True) @@ -557,6 +561,8 @@ entry = "scripts/acceptance.sh" layout.validate("HEAD", True) def test_rejects_a_symbolic_entry(self): + if not support.symlinks_supported(): + self.skipTest("creating symbolic links needs Windows Developer Mode") design = self.leaf("design", symlink_entry=True) self.assemble(design=design) with self.assertRaisesRegex(ValueError, "missing or symbolic entry: design/scripts/ci.sh"): @@ -659,7 +665,7 @@ entry = "scripts/ci.sh" new_domain_sha = self.commit(domain_repo, "extra gitlink") self.git("update-index", "--add", "--cacheinfo", f"160000,{new_domain_sha},extensions/web", cwd=self.root) self.git("commit", "-qm", "advance domain") - shutil.rmtree(self.root / "extensions/web") + support.rmtree(self.root / "extensions/web") self.clone(domain_repo, self.root / "extensions/web", new_domain_sha) for name in ("design", "preview"): self.clone(info[name][0], self.root / "extensions/web" / name, info[name][1]) @@ -716,7 +722,7 @@ release = "base" "design": "https://git.cflmy.cn/cflmy/marqdo-ext-design.git", "preview": "https://git.cflmy.cn/cflmy/marqdo-web-preview.git", }) - shutil.rmtree(self.root / "extensions/web/design") + support.rmtree(self.root / "extensions/web/design") with self.assertRaisesRegex(ValueError, "invalid submodule URL: design"): layout.validate("HEAD", False, expand_domains=True) diff --git a/tests/integration/test_repo_conventions.py b/tests/integration/test_repo_conventions.py index 2e01aa3..8f89357 100644 --- a/tests/integration/test_repo_conventions.py +++ b/tests/integration/test_repo_conventions.py @@ -18,7 +18,7 @@ URL = conventions.CONVENTIONS_URL def write(path: Path, text: str) -> None: path.parent.mkdir(parents=True, exist_ok=True) - path.write_text(text) + path.write_text(text, encoding="utf-8") def agents(role: str) -> str: @@ -97,7 +97,7 @@ entry = "scripts/ci.sh" 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( + text = (self.root / "components.toml").read_text(encoding="utf-8").replace( 'state = "active"', 'state = "planned"' ) text = text.replace('entry = "scripts/ci.sh"', 'entry = "scripts/ci.sh"') @@ -116,7 +116,7 @@ entry = "scripts/ci.sh" def test_domain_child_must_not_be_registered_in_root_catalog(self): write( self.root / "components.toml", - (self.root / "components.toml").read_text() + (self.root / "components.toml").read_text(encoding="utf-8") + """ [[component]] id = "web" @@ -154,13 +154,13 @@ entry = "scripts/ci.sh" write(self.root / "extensions/web/design/scripts/ci.sh", "#!/bin/sh\n") write( self.root / ".gitmodules", - (self.root / ".gitmodules").read_text() + (self.root / ".gitmodules").read_text(encoding="utf-8") + '[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() + (self.root / "components.toml").read_text(encoding="utf-8") + """ [[component]] id = "web-design-dup" diff --git a/tests/integration/test_webhook_adapter.py b/tests/integration/test_webhook_adapter.py index 30876b1..29877e0 100644 --- a/tests/integration/test_webhook_adapter.py +++ b/tests/integration/test_webhook_adapter.py @@ -66,7 +66,7 @@ def commit(repo, message="fixture"): def write(path, text): path.parent.mkdir(parents=True, exist_ok=True) - path.write_text(text) + path.write_text(text, encoding="utf-8") class WebhookAdapterTest(unittest.TestCase):