Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8a8098b9a | ||
|
|
a93cb0e921 | ||
|
|
6e4a7d5c10 | ||
|
|
bc30587a0c | ||
|
|
68b7fe0511 | ||
|
|
4e25b120af | ||
|
|
3eeb574e6b | ||
|
|
35234edb3f | ||
|
|
af60b89dcf | ||
|
|
e07cf9e7f1 | ||
|
|
69212ae01f | ||
|
|
99f31354ba | ||
|
|
d014ddb661 | ||
|
|
068f91cd31 | ||
|
|
c5e9180404 | ||
|
|
4cde0e256a | ||
|
|
0bf8a68cf5 | ||
|
|
277f9c307d |
No files matched your search
+23
-11
@@ -1,13 +1,26 @@
|
|||||||
when:
|
when:
|
||||||
event: [push, pull_request, manual]
|
- event: [pull_request, manual]
|
||||||
|
- event: push
|
||||||
|
branch: main
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
layout:
|
layout:
|
||||||
image: rust:1.100-bookworm
|
image: git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5@sha256:8184439a201da451271f37596f4e38afeab16e044d7591853779887ef5ec28c1
|
||||||
commands:
|
commands:
|
||||||
- apt-get update && apt-get install -y --no-install-recommends ca-certificates git python3
|
|
||||||
- python3 scripts/check-layout.py
|
- python3 scripts/check-layout.py
|
||||||
- python3 -m unittest discover -s tests/integration
|
- python3 -m unittest discover -s tests/integration
|
||||||
|
|
||||||
|
checkouts:
|
||||||
|
image: git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5@sha256:8184439a201da451271f37596f4e38afeab16e044d7591853779887ef5ec28c1
|
||||||
|
depends_on: [layout]
|
||||||
|
when: &needs_candidate
|
||||||
|
- event: manual
|
||||||
|
- event: [push, pull_request]
|
||||||
|
path:
|
||||||
|
# Governance, executable Markdown, packaging and unknown paths stay in scope.
|
||||||
|
exclude: [README.md, 'docs/evidence/*.md']
|
||||||
|
on_empty: true
|
||||||
|
commands:
|
||||||
- git submodule update --init
|
- git submodule update --init
|
||||||
- |
|
- |
|
||||||
set -eu
|
set -eu
|
||||||
@@ -16,16 +29,17 @@ 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.
|
image: git.cflmy.cn/cflmy/marqdo-ci-rust:3.0.0-rc.5@sha256:73481a35339157b1a3f3b23076517e96e302fbb5158e6ffcb1582acf22c6af94
|
||||||
image: mcr.microsoft.com/playwright:v1.49.0-noble
|
depends_on: [checkouts]
|
||||||
depends_on: [layout]
|
when: *needs_candidate
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
set -eu
|
set -eu
|
||||||
for attempt in 1 2 3; do
|
for attempt in 1 2 3; do
|
||||||
if apt-get -o Acquire::By-Hash=force -o Acquire::Retries=3 update --error-on=any; then
|
if apt-get -o Acquire::By-Hash=force -o Acquire::http::Timeout=30 update --error-on=any; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
if [ "$attempt" -eq 3 ]; then
|
if [ "$attempt" -eq 3 ]; then
|
||||||
@@ -33,8 +47,6 @@ steps:
|
|||||||
fi
|
fi
|
||||||
sleep 15
|
sleep 15
|
||||||
done
|
done
|
||||||
apt-get -o Acquire::Retries=3 install -y --no-install-recommends ca-certificates curl git python3 python3-jsonschema build-essential
|
apt-get -o Acquire::Retries=3 -o Acquire::http::Timeout=30 install -y --no-install-recommends python3-jsonschema util-linux
|
||||||
curl -fsSL --retry 3 https://sh.rustup.rs -o /tmp/marqdo-rustup.sh
|
unset MARQDO_BIN MARQDO_STDLIB_DIR
|
||||||
sh /tmp/marqdo-rustup.sh -y --profile minimal --default-toolchain 1.100.0 --no-modify-path
|
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
bash scripts/integration.sh
|
bash scripts/integration.sh
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Release discovery, asset verification and tracking-Issue reconciliation.
|
||||||
|
#
|
||||||
|
# Runs only from the protected default branch, on a manual trigger or the
|
||||||
|
# `release-reconcile` cron. The fast path (component release workflows) only
|
||||||
|
# asks this same workflow to run; correctness comes from this reconcile.
|
||||||
|
when:
|
||||||
|
event: [manual, cron]
|
||||||
|
branch: [main]
|
||||||
|
|
||||||
|
concurrency: 1
|
||||||
|
|
||||||
|
steps:
|
||||||
|
reconcile:
|
||||||
|
image: git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5@sha256:8184439a201da451271f37596f4e38afeab16e044d7591853779887ef5ec28c1
|
||||||
|
environment:
|
||||||
|
MARQDO_GIT_TOKEN:
|
||||||
|
from_secret: gitea_reconcile_token
|
||||||
|
commands:
|
||||||
|
- python3 scripts/check-layout.py
|
||||||
|
- git submodule update --init
|
||||||
|
- python3 scripts/reconcile-releases.py --apply --published-after 2026-11-27T02:00:00Z --report-out reconcile-report.json
|
||||||
@@ -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 阶段强制执行,规则变更必须同步测试与模板。
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Shared Rust-component CI image: shell base + one pinned Rust toolchain
|
||||||
|
# (rustfmt/clippy included) and a warm cargo cache. Published by immutable tag;
|
||||||
|
# repositories only run their own scripts/ci.sh.
|
||||||
|
FROM marqdo-ci-shell:3.0.0-rc.5
|
||||||
|
|
||||||
|
COPY rust-toolchain /opt/rust
|
||||||
|
COPY cargo-home /opt/cargo-home
|
||||||
|
ENV PATH=/opt/rust/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
||||||
|
CARGO_HOME=/opt/cargo-home \
|
||||||
|
RUSTUP_HOME=/opt/rustup-unused
|
||||||
|
|
||||||
|
RUN cargo --version && rustc --version && cargo fmt --version && cargo clippy --version
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Lean shared Rust CI image: shell base + host-only Rust toolchain and a warm
|
||||||
|
# cargo cache. Cross targets, rust docs and unused manifests are stripped to
|
||||||
|
# keep the registry pull small. Published by immutable tag; components only run
|
||||||
|
# their own scripts/ci.sh.
|
||||||
|
FROM marqdo-ci-shell:3.0.0-rc.5
|
||||||
|
|
||||||
|
COPY rust-toolchain /opt/rust
|
||||||
|
COPY cargo-home /opt/cargo-home
|
||||||
|
ENV PATH=/opt/rust/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
||||||
|
CARGO_HOME=/opt/cargo-home
|
||||||
|
|
||||||
|
RUN cargo --version && rustc --version && cargo fmt --version && cargo clippy --version
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Shared shell/source-component CI image. Published to the Gitea container
|
||||||
|
# registry and consumed by component repos by immutable version tag.
|
||||||
|
#
|
||||||
|
# It contains the published CLI/Bundle (one pinned release), common test tools
|
||||||
|
# and the supported glibc baseline (Ubuntu 24.04, glibc 2.39). Repositories do
|
||||||
|
# not need apt installs, Rust toolchains or archive downloads in their lanes.
|
||||||
|
FROM ubuntu:24.04
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
ca-certificates curl git python3 python3-venv build-essential ripgrep \
|
||||||
|
xz-utils unzip \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY marqdo.tar.gz /tmp/marqdo.tar.gz
|
||||||
|
RUN mkdir -p /opt/marqdo \
|
||||||
|
&& tar -xzf /tmp/marqdo.tar.gz -C /opt/marqdo \
|
||||||
|
&& rm /tmp/marqdo.tar.gz
|
||||||
|
|
||||||
|
ENV MARQDO_BIN=/opt/marqdo/marqdo-3.0.0-rc.5-x86_64-unknown-linux-gnu/marqdo \
|
||||||
|
MARQDO_STDLIB_DIR=/opt/marqdo/marqdo-3.0.0-rc.5-x86_64-unknown-linux-gnu/stdlib \
|
||||||
|
MARQDO_CLI_VERSION=3.0.0-rc.5
|
||||||
|
|
||||||
|
RUN test -x "$MARQDO_BIN" && "$MARQDO_BIN" --version
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
FROM ubuntu:24.04
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive \
|
||||||
|
PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
|
||||||
|
PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright \
|
||||||
|
NPM_CONFIG_REGISTRY=https://registry.npmmirror.com \
|
||||||
|
MARQDO_BIN=/opt/marqdo/marqdo-3.0.0-rc.5-x86_64-unknown-linux-gnu/marqdo \
|
||||||
|
MARQDO_STDLIB_DIR=/opt/marqdo/marqdo-3.0.0-rc.5-x86_64-unknown-linux-gnu/stdlib \
|
||||||
|
MARQDO_WEB_TOOL_JSON=/opt/web-tool/tool.json \
|
||||||
|
MARQDO_CLI_VERSION=3.0.0-rc.5
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
ca-certificates curl git python3 nodejs npm xz-utils unzip fonts-noto-cjk \
|
||||||
|
&& npm install -g playwright@1.49.0 \
|
||||||
|
&& npx playwright install-deps chromium \
|
||||||
|
&& curl -fsSL --retry 3 -o /tmp/chromium.zip "https://cdn.npmmirror.com/binaries/playwright/builds/chromium/1148/chromium-linux.zip" \
|
||||||
|
&& mkdir -p /ms-playwright/chromium-1148 \
|
||||||
|
&& unzip -q /tmp/chromium.zip -d /ms-playwright/chromium-1148 \
|
||||||
|
&& touch /ms-playwright/chromium-1148/INSTALLATION_COMPLETE \
|
||||||
|
&& rm /tmp/chromium.zip \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
COPY marqdo.tar.gz /tmp/marqdo.tar.gz
|
||||||
|
COPY marqdo-web-preview.tgz /tmp/web.tgz
|
||||||
|
RUN mkdir -p /opt/marqdo /opt/web-tool \
|
||||||
|
&& tar -xzf /tmp/marqdo.tar.gz -C /opt/marqdo \
|
||||||
|
&& tar -xzf /tmp/web.tgz -C /opt/web-tool --strip-components=1 \
|
||||||
|
&& rm /tmp/marqdo.tar.gz /tmp/web.tgz \
|
||||||
|
&& test -x "$MARQDO_BIN" && "$MARQDO_BIN" --version && test -f "$MARQDO_WEB_TOOL_JSON"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Shared Marqdo CI images are project infrastructure, not product releases.
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Shared Marqdo CI images
|
||||||
|
|
||||||
|
The ecosystem publishes exactly these reusable runtime images to the Gitea
|
||||||
|
container registry, per released CLI version:
|
||||||
|
|
||||||
|
| Image | Contents | Consumers |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5` | Ubuntu 24.04 (glibc 2.39), git/curl/python3/build tools, released CLI + Bundle (`MARQDO_BIN`/`MARQDO_STDLIB_DIR` preset) | standard library, extension, conformance and reconcile lanes |
|
||||||
|
| `git.cflmy.cn/cflmy/marqdo-ci-rust:3.0.0-rc.5` | shell image + pinned Rust 1.100 toolchain (rustfmt/clippy) + warm cargo cache | Design/Preview and Rust tool lanes |
|
||||||
|
| `git.cflmy.cn/cflmy/marqdo-ci-web:3.0.0-rc.5` (digest `0cccda995d77...`) | Ubuntu 24.04 + Node/Playwright Chromium(npmmirror 二进制源)+ released CLI/Bundle + packaged preview web Tool | Web domain browser acceptance |
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
|
||||||
|
- Tags are immutable and tied to one released CLI version; do not move a tag.
|
||||||
|
A new CLI release publishes new tags; consumers update in reviewed PRs.
|
||||||
|
- Images are public for anonymous pull; CI never needs registry push credentials.
|
||||||
|
- Component lanes contain only their own `scripts/*` entry command. No per-repo
|
||||||
|
image variance, apt installs, Rust toolchain downloads or CLI rebuilds.
|
||||||
|
- Core CLI keeps its specialized Rust/Windows-cross gates. The root ecosystem
|
||||||
|
candidate uses the shared Rust toolchain to build the fixed CLI/Worker/Bundle
|
||||||
|
combination. View and Web keep browser coverage in their own workflows.
|
||||||
|
- The images are CI infrastructure, not product releases; their provenance is
|
||||||
|
recorded here and in `docs/evidence/`.
|
||||||
Executable
+66
@@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build and optionally publish the shared Marqdo CI images.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# MARQDO_GIT_TOKEN=... ci/images/build.sh [--push]
|
||||||
|
#
|
||||||
|
# The images are immutable per released CLI version. They are the only shared
|
||||||
|
# CI runtime images: shell/source components use `marqdo-ci-shell`, Rust
|
||||||
|
# components use `marqdo-ci-rust`, the Web domain uses `marqdo-ci-web`.
|
||||||
|
# Core CLI/root keep their own specialized gates and images.
|
||||||
|
set -euo pipefail
|
||||||
|
if ! command -v cargo >/dev/null 2>&1; then
|
||||||
|
export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:$PATH"
|
||||||
|
fi
|
||||||
|
root="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||||
|
toolchain="${MARQDO_CI_RUST_TOOLCHAIN:-$(rustc --print sysroot)}"
|
||||||
|
cargo_cache="${MARQDO_CI_CARGO_CACHE:-${CARGO_HOME:-$HOME/.cargo}}"
|
||||||
|
preview_checkout="${MARQDO_CI_PREVIEW_CHECKOUT:-$root/extensions/web/preview}"
|
||||||
|
version="${MARQDO_CLI_VERSION:-3.0.0-rc.5}"
|
||||||
|
registry="${MARQDO_CI_REGISTRY:-git.cflmy.cn/cflmy}"
|
||||||
|
commit="${MARQDO_CI_IMAGE_COMMIT:-$(git -C "$root" rev-parse --short HEAD)}"
|
||||||
|
context="$root/.build/ci-images/$commit-$version"
|
||||||
|
push=0
|
||||||
|
[[ "${1:-}" == "--push" ]] && push=1
|
||||||
|
|
||||||
|
archive_url="https://git.cflmy.cn/cflmy/marqdo-cli/releases/download/v${version}/marqdo-${version}-x86_64-unknown-linux-gnu.tar.gz"
|
||||||
|
archive_sha="fd7a313e0ddaf38a9b1901ff2a9aa7b9a0a153e65522a9c0c60f01e2549f583b"
|
||||||
|
|
||||||
|
rm -rf "$context"; mkdir -p "$context"
|
||||||
|
echo "==> download published CLI/Bundle"
|
||||||
|
curl -fsSL --retry 3 -o "$context/marqdo.tar.gz" "$archive_url"
|
||||||
|
echo "$archive_sha $context/marqdo.tar.gz" | sha256sum -c -
|
||||||
|
|
||||||
|
echo "==> package the preview web Tool from the pinned preview checkout"
|
||||||
|
(
|
||||||
|
cd "$preview_checkout"
|
||||||
|
scripts/package.sh >/dev/null
|
||||||
|
)
|
||||||
|
tar -czf "$context/marqdo-web-preview.tgz" -C "$preview_checkout/dist" marqdo-web-preview
|
||||||
|
|
||||||
|
echo "==> stage the pinned Rust toolchain and cargo cache"
|
||||||
|
cp -a "$toolchain" "$context/rust-toolchain"
|
||||||
|
cp -a "$cargo_cache" "$context/cargo-home"
|
||||||
|
cp "$root/ci/images/LICENSE" "$context/marqdo-ci-shell-license" 2>/dev/null || echo "internal CI image" > "$context/marqdo-ci-shell-license"
|
||||||
|
cp "$root/ci/images/Dockerfile.shell" "$root/ci/images/Dockerfile.rust" "$root/ci/images/Dockerfile.web" "$context/"
|
||||||
|
|
||||||
|
build() {
|
||||||
|
local tag="$1" file="$2"
|
||||||
|
echo "==> docker build $tag"
|
||||||
|
DOCKER_CONFIG="${DOCKER_CONFIG:-$root/.build/docker-config}" \
|
||||||
|
docker build -f "$context/$file" -t "$registry/$tag" "$context"
|
||||||
|
}
|
||||||
|
build "marqdo-ci-shell:$version" Dockerfile.shell
|
||||||
|
docker tag "$registry/marqdo-ci-shell:$version" "marqdo-ci-shell:$version"
|
||||||
|
build "marqdo-ci-rust:$version" Dockerfile.rust
|
||||||
|
build "marqdo-ci-web:$version" Dockerfile.web
|
||||||
|
|
||||||
|
if [[ "$push" == 1 ]]; then
|
||||||
|
: "${MARQDO_GIT_TOKEN:?set MARQDO_GIT_TOKEN to publish images}"
|
||||||
|
export DOCKER_CONFIG="${DOCKER_CONFIG:-$root/.build/docker-config}"
|
||||||
|
echo "$MARQDO_GIT_TOKEN" | docker login "${registry%%/*}" -u "${MARQDO_GIT_USERNAME:-cflmy}" --password-stdin
|
||||||
|
docker push "$registry/marqdo-ci-shell:$version"
|
||||||
|
docker push "$registry/marqdo-ci-rust:$version"
|
||||||
|
docker push "$registry/marqdo-ci-web:$version"
|
||||||
|
echo "published immutable CI images for $version"
|
||||||
|
fi
|
||||||
+1
-1
Submodule cli updated: deadf6edee...13affa76dd.
+7
-1
@@ -35,7 +35,9 @@ bash scripts/integration.sh # 生态候选:真实 CLI 制品 +
|
|||||||
- 校验器读取 Git tree 中固定提交的 catalog,不以工作区改动替代候选;`--checkouts` 需要子模块已初始化,缺失、错误 HEAD、脏工作区、错误入口都明确 FAIL/UNVERIFIED,不静默跳过。CI 先验证并检出直属子模块,再用 `--domain-paths` 校验领域的子模块远端,最后逐个领域检出直属子库。
|
- 校验器读取 Git tree 中固定提交的 catalog,不以工作区改动替代候选;`--checkouts` 需要子模块已初始化,缺失、错误 HEAD、脏工作区、错误入口都明确 FAIL/UNVERIFIED,不静默跳过。CI 先验证并检出直属子模块,再用 `--domain-paths` 校验领域的子模块远端,最后逐个领域检出直属子库。
|
||||||
- 没有 active 领域时,新校验规则同样接受合法的直属功能组件,这不是历史协议兼容。
|
- 没有 active 领域时,新校验规则同样接受合法的直属功能组件,这不是历史协议兼容。
|
||||||
- 未知的 active 入口、未声明的 gitlink、目录与 catalog 不一致都必须让候选失败。`planned` 不进入验收计数。
|
- 未知的 active 入口、未声明的 gitlink、目录与 catalog 不一致都必须让候选失败。`planned` 不进入验收计数。
|
||||||
- 当前 CI 为 `layout` 与 `candidate` 两段;统一 CLI 制品准备、声明驱动调度与递归影响分析仍在推进(见 `.woodpecker/eco.yml` 与主仓库工单),不得以本文件描述当作已实现。
|
- `python3 scripts/check-layout.py --active-entries` 从已验证的根与领域 checkout 输出验收计划。根集成按依赖顺序使用同一次安装的 CLI 和 Bundle 执行计划,领域验收晚于其 active 子组件。通用入口接收 `MARQDO_BIN`、`MARQDO_STDLIB_DIR` 和 `MARQDO_CI_OUT`,已有公共契约、真实 Tool 冷安装等组合门禁继续使用各自的现有入口。
|
||||||
|
- 根 Web 组合检查对该次构建的 Preview Tool 执行冷安装、`check`、`preview` 和 `handoff`。生产浏览器验收由 Web 聚合仓已有的 `scripts/domain-acceptance.sh` 负责。
|
||||||
|
- 根 `eco` 在 PR、`main` 推送和显式手动运行时执行。PR 始终保留 `layout` 状态。仅改动根 `README.md` 或 `docs/evidence/` 下的 Markdown 记录时,自动运行只执行轻量结构校验和脚本测试。混合改动、其他路径、缺失变更列表和手动运行都执行递归检出及完整生态验收。
|
||||||
|
|
||||||
## 三层验收
|
## 三层验收
|
||||||
|
|
||||||
@@ -80,6 +82,10 @@ bash scripts/integration.sh # 生态候选:真实 CLI 制品 +
|
|||||||
|
|
||||||
经过授权的 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。
|
经过授权的 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。
|
||||||
|
|
||||||
|
正式发布对账使用 `python3 scripts/reconcile-releases.py --plan --published-after <ISO-8601 时间>`。从固定根及领域 tree 解析受管仓库,核对 Gitea tag、`release-evidence.json`、同 SHA Woodpecker 组件 CI 和资产字节摘要。根 `reconcile` 工作流从当前受保护的 `main` 串行运行,使用 `gitea_reconcile_token` 以专用非管理员账号写追踪工单。`historical-baseline` 表示已登记历史输入,`blocked` 表示发布验证未通过,`tracked` 表示已记录经验证的发布。消费者验收和父级接受均需各自的 CI 与 PR 证据。
|
||||||
|
|
||||||
|
对已验证的发布,`--plan` 计算直接 active 消费者的输入摘要。受保护 `--apply` 按发布和消费者登记一条任务,基线变化时在原任务中记录新输入。输入附精确资产、依赖、消费者基线和根追踪编号。下游独立 CI 及批准后的晋升基于各自的真实结果。
|
||||||
|
|
||||||
## 发行与回滚
|
## 发行与回滚
|
||||||
|
|
||||||
- 组件可独立 SemVer 发布;领域可发布经过验证的组合制品;根生态 release 固定整个 gitlink 树。独立版本不代表维护多套现行协议。
|
- 组件可独立 SemVer 发布;领域可发布经过验证的组合制品;根生态 release 固定整个 gitlink 树。独立版本不代表维护多套现行协议。
|
||||||
|
|||||||
+4
-4
@@ -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 提交。
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ 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 领域 active:WEB-00..04 完成,领域 catalog/gitlink 固定 Design/Preview;根 catalog 激活与 gitlink 一次切换 | 根 `check-layout --checkouts`、领域组件入口、`web` Tool 冷安装与既有消费者同候选证据;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 冻结)
|
||||||
|
|
||||||
|
|||||||
@@ -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,并同步模板与检查器。
|
||||||
@@ -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,58 @@
|
|||||||
|
# 共享 CI 镜像、单仓 CI 与发布对账(2026-11-27)
|
||||||
|
|
||||||
|
来源:[marqdo#10](https://git.cflmy.cn/cflmy/marqdo/issues/10)。本文件记录本轮 CI/CD 基础设施实现与可验证结果。
|
||||||
|
|
||||||
|
## 共享运行时镜像(Gitea Container Registry)
|
||||||
|
|
||||||
|
组件不再各自安装工具链或重复下载/编译 CLI。根 `ci/images/` 定义并发布不可变镜像:
|
||||||
|
|
||||||
|
| 镜像 | digest | 内容 | 消费方 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| `git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5` | `sha256:8184439a201d...` | Ubuntu 24.04/glibc 2.39、git/curl/python3/build 工具、已发布 CLI+Bundle(`MARQDO_BIN`/`MARQDO_STDLIB_DIR` 预置) | stdlib、extension、conformance、reconcile |
|
||||||
|
| `git.cflmy.cn/cflmy/marqdo-ci-rust:3.0.0-rc.5` | `sha256:73481a353391...` | shell 镜像 + Rust 1.100(rustfmt/clippy)+ 预热 cargo cache | Design/Preview 与 Rust Tool |
|
||||||
|
| `git.cflmy.cn/cflmy/marqdo-ci-web:3.0.0-rc.5` | `sha256:0cccda995d77...` | Ubuntu 24.04 + Node 18/Playwright 1.49 Chromium(npmmirror 二进制源,`channel: chromium`)+ CLI/Bundle + 打包 preview web Tool | Web domain 浏览器验收(pipeline 1 **success**) |
|
||||||
|
|
||||||
|
- 镜像通过 `ci/images/build.sh [--push]` 从**已发布 rc.5 CLI 归档**(sha256 固定)与固定预览包构建;标签不可变,按 CLI 版本发布;公开匿名拉取,CI 不需要 registry push 凭据。
|
||||||
|
- 单仓工作流因此只剩本仓入口命令;例如 stdlib/extension/conformance 为:
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
test:
|
||||||
|
image: git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5
|
||||||
|
commands: [sh scripts/test.sh]
|
||||||
|
```
|
||||||
|
Rust 组件为 `marqdo-ci-rust` + `scripts/ci.sh`。CLI/根仍保留各自专用镜像与门禁(CLI Windows 交叉、根 Playwright/Docker 冷安装),属有限例外。
|
||||||
|
|
||||||
|
## 实际流水线结果(2026-11-27 本机观测)
|
||||||
|
|
||||||
|
| lane | 结果 |
|
||||||
|
| --- | --- |
|
||||||
|
| stdlib ×6 / extension ×3 / conformance(shell 镜像) | push/PR/manual lane **success**(例:conformance #12、std-text #12、collections #12、data #11、fs #11、io #11、system #11、ext-http #11、ext-regex #11、ext-archive #11) |
|
||||||
|
| Design / Preview(rust 镜像) | pipeline 6/7 **success** |
|
||||||
|
| knowledge / lint / prove(rust 镜像) | pipeline 22 / 12 / 17 **success** |
|
||||||
|
| View(rust 构建 + Playwright 浏览器两步) | pipeline 24 **success**(rc.5 CLI 适配) |
|
||||||
|
| Web domain(web 镜像:三案例 + 生产 API/Chromium E2E) | pipeline 1 **success** |
|
||||||
|
| 根 release 对账 | manual #71 **success**(创建 rc.5 追踪 Issue #22);cron #72 **success**(幂等 tracked) |
|
||||||
|
| 发布快速通知 | 临时 release 触发 std-text release pipeline #23 **success** → 根 manual #73 **success** 并创建追踪 Issue;测试 release/tag/Issue 已清理 |
|
||||||
|
|
||||||
|
## Woodpecker 接入
|
||||||
|
|
||||||
|
- 19 个仓库已在 Woodpecker 激活(std ×6、ext ×3、conformance、Design/Preview、tool ×4、ext-web domain、根、CLI)。
|
||||||
|
- 已写入并合并单仓 `.woodpecker/ci.yml`;std/conformance/ext 的 push/pull_request 镜像 lane 已实际 **success**(例如 conformance 使用 shell 镜像通过)。
|
||||||
|
- `.woodpecker/reconcile.yml`:仅保护默认分支、manual/cron;`release-reconcile` cron `@every 30m` 已创建;根 repo secret `gitea_token` 已设置(不记录值)。
|
||||||
|
- 快速通知路径:组件发布成功后由 release 工作流请求根 reconcile;丢失通知由 cron 补偿。两者共用 `scripts/reconcile-releases.py`,不新增接收服务或第二套协议。
|
||||||
|
|
||||||
|
## 发布对账
|
||||||
|
|
||||||
|
`scripts/reconcile-releases.py`:
|
||||||
|
|
||||||
|
- 从既有 catalog/gitmodules 派生受管仓库,扫描 Gitea release(含 prerelease,排除 draft),验证 tag/资产名、大小与下载字节 SHA-256;
|
||||||
|
- 在根仓库创建带 `release-tracking` 标签与稳定 marker 的追踪 Issue(幂等;历史 release 可用 `--published-after` 基线过滤);
|
||||||
|
- 只创建/更新追踪 Issue,不改 gitlink、不发布、不执行 release body/URL;失败资产验证会报告并返回非零;
|
||||||
|
- 6 个单元测试覆盖 dry-run、资产验证、幂等、draft 过滤、时间过滤、坏资产/路径。
|
||||||
|
|
||||||
|
## 未完成 / 限制
|
||||||
|
|
||||||
|
- `marqdo-ci-web` 已改为 Ubuntu + Node/Playwright Chromium(npmmirror 镜像源,避免 MCR 拉取超时)并发布;Web domain pipeline 1 success。ghproxy `https://ghproxy.cflmy.top` 对 GitHub 资源可用,但本轮浏览器资源使用 npmmirror,未依赖 ghproxy。
|
||||||
|
- View 已迁到 rust + Playwright 两步;knowledge/lint/prove 已迁到共享 rust 镜像。
|
||||||
|
- 组件 release 发布工作流(source archive/tool bundle 上传 + 快速通知)尚未全部落地;当前 CLI rc.5 已发布,reconcile 可追踪新发布。
|
||||||
|
- registry 镜像 digest/扫描策略、runner 拉取缓存与多架构未验证;CI 账号最小权限仍沿用现有项目 token(M0 记录限制)。
|
||||||
@@ -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 记录原因、责任者、复查日期与退出条件。
|
||||||
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: aba6b60934...9af27f0eb6.
+1
-1
Submodule extensions/http updated: 368b33d241...a42db224e9.
+1
-1
Submodule extensions/regex updated: 6e7e633798...a9088ae457.
+1
-1
Submodule extensions/web updated: f6d0a9067c...a3ddccd8a4.
+28
-3
@@ -32,7 +32,7 @@ ROOT = Path(__file__).resolve().parents[1]
|
|||||||
NAME = r"[a-z][a-z0-9]*(?:-[a-z0-9]+)*"
|
NAME = r"[a-z][a-z0-9]*(?:-[a-z0-9]+)*"
|
||||||
FIELDS = {"id", "path", "kind", "state", "owner", "scope", "requires", "checks_with", "release"}
|
FIELDS = {"id", "path", "kind", "state", "owner", "scope", "requires", "checks_with", "release"}
|
||||||
ROOT_FILES = {".gitattributes", ".gitignore", ".gitmodules", "AGENTS.md", "LICENSE", "README.md", "components.toml"}
|
ROOT_FILES = {".gitattributes", ".gitignore", ".gitmodules", "AGENTS.md", "LICENSE", "README.md", "components.toml"}
|
||||||
ROOT_DIRS = {".gitea", ".woodpecker", "docs", "examples", "scripts"}
|
ROOT_DIRS = {".gitea", ".woodpecker", "ci", "docs", "examples", "scripts"}
|
||||||
CATEGORY_READMES = {"stdlib/README.md", "extensions/README.md"}
|
CATEGORY_READMES = {"stdlib/README.md", "extensions/README.md"}
|
||||||
RELEASE_ROLES = {"core": "base", "stdlib": "base", "extension": "optional", "tool": "optional", "test": "none"}
|
RELEASE_ROLES = {"core": "base", "stdlib": "base", "extension": "optional", "tool": "optional", "test": "none"}
|
||||||
DOMAIN_RELEASE = {"none", "base"}
|
DOMAIN_RELEASE = {"none", "base"}
|
||||||
@@ -423,18 +423,43 @@ def validate(revision, checkouts, expand_domains=False):
|
|||||||
return layers
|
return layers
|
||||||
|
|
||||||
|
|
||||||
|
def active_entries(layers):
|
||||||
|
root = layers[0]
|
||||||
|
root_domains = {root.repo / path: item["id"] for path, item in root.linked.items()
|
||||||
|
if item["kind"] == "domain"}
|
||||||
|
entries = {}
|
||||||
|
requirements = {}
|
||||||
|
for layer in layers:
|
||||||
|
parent = root_domains.get(layer.repo)
|
||||||
|
for path, item in sorted(layer.linked.items()):
|
||||||
|
if item["state"] != "active":
|
||||||
|
continue
|
||||||
|
component_id = item["id"]
|
||||||
|
relative = (layer.repo / path).relative_to(root.repo).as_posix()
|
||||||
|
entries[component_id] = (component_id, item["kind"], relative, item["entry"])
|
||||||
|
requirements[component_id] = list(item["requires"])
|
||||||
|
if parent in requirements:
|
||||||
|
requirements[parent].append(component_id)
|
||||||
|
for component_id in graphlib.TopologicalSorter(requirements).static_order():
|
||||||
|
yield entries[component_id]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Validate a Marqdo ecosystem Git tree")
|
parser = argparse.ArgumentParser(description="Validate a Marqdo ecosystem Git tree")
|
||||||
parser.add_argument("revision", nargs="?", default="HEAD")
|
parser.add_argument("revision", nargs="?", default="HEAD")
|
||||||
parser.add_argument("--checkouts", action="store_true")
|
parser.add_argument("--checkouts", action="store_true")
|
||||||
paths = parser.add_mutually_exclusive_group()
|
paths = parser.add_mutually_exclusive_group()
|
||||||
paths.add_argument("--active-paths", action="store_true", help="print only direct active component paths")
|
paths.add_argument("--active-paths", action="store_true", help="print only direct active component paths")
|
||||||
|
paths.add_argument("--active-entries", action="store_true", help="print validated active entries in dependency order")
|
||||||
paths.add_argument("--domain-paths", action="store_true", help="validate domain URLs and print domain paths")
|
paths.add_argument("--domain-paths", action="store_true", help="validate domain URLs and print domain paths")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
try:
|
try:
|
||||||
revision = git("rev-parse", "--verify", args.revision + "^{commit}").strip()
|
revision = git("rev-parse", "--verify", args.revision + "^{commit}").strip()
|
||||||
layers = validate(revision, args.checkouts, expand_domains=args.domain_paths)
|
layers = validate(revision, args.checkouts or args.active_entries, expand_domains=args.domain_paths)
|
||||||
if args.active_paths:
|
if args.active_entries:
|
||||||
|
for entry in active_entries(layers):
|
||||||
|
print("\t".join(entry))
|
||||||
|
elif args.active_paths:
|
||||||
for path, component in sorted(layers[0].linked.items()):
|
for path, component in sorted(layers[0].linked.items()):
|
||||||
if component["state"] == "active":
|
if component["state"] == "active":
|
||||||
print(path)
|
print(path)
|
||||||
|
|||||||
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:]))
|
||||||
+37
-74
@@ -11,8 +11,8 @@ The affected set is computed in the order the development contract requires:
|
|||||||
1. changed or removed leaves;
|
1. changed or removed leaves;
|
||||||
2. reverse transitive closure over `requires` edges from the union of both
|
2. reverse transitive closure over `requires` edges from the union of both
|
||||||
graphs (removed edges cannot hide a consumer);
|
graphs (removed edges cannot hide a consumer);
|
||||||
3. parent domains of affected components;
|
3. `checks_with` and reverse dependency fixed point;
|
||||||
4. `checks_with` fixed point (co-validation is not a build prerequisite).
|
4. parent domains of affected components in both graphs.
|
||||||
|
|
||||||
When a domain cannot be expanded (missing object/checkout) the result is marked
|
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
|
UNVERIFIED and the whole domain is treated as affected rather than silently
|
||||||
@@ -217,37 +217,42 @@ def changed_components(
|
|||||||
def affected_set(
|
def affected_set(
|
||||||
accepted: dict[str, dict], candidate: dict[str, dict], changed: list[dict]
|
accepted: dict[str, dict], candidate: dict[str, dict], changed: list[dict]
|
||||||
) -> tuple[list[str], list[str], list[str]]:
|
) -> tuple[list[str], list[str], list[str]]:
|
||||||
graph = {**accepted, **candidate}
|
dependents: dict[str, set[str]] = {}
|
||||||
dependents: dict[str, set[str]] = {component_id: set() for component_id in graph}
|
partners: dict[str, set[str]] = {}
|
||||||
for component in graph.values():
|
parents: dict[str, set[str]] = {}
|
||||||
|
for graph in (accepted, candidate):
|
||||||
|
for component_id, component in graph.items():
|
||||||
for dependency in component.get("requires", []):
|
for dependency in component.get("requires", []):
|
||||||
dependents.setdefault(dependency, set()).add(component["id"])
|
dependents.setdefault(dependency, set()).add(component_id)
|
||||||
|
for partner in component.get("checks_with", []):
|
||||||
|
partners.setdefault(component_id, set()).add(partner)
|
||||||
|
partners.setdefault(partner, set()).add(component_id)
|
||||||
|
if component.get("parent"):
|
||||||
|
parents.setdefault(component_id, set()).add(component["parent"])
|
||||||
|
|
||||||
affected = {item["id"] for item in changed}
|
affected = {item["id"] for item in changed}
|
||||||
queue = list(affected)
|
queue = list(affected)
|
||||||
while queue:
|
while queue:
|
||||||
current = queue.pop()
|
for consumer in dependents.get(queue.pop(), set()) - affected:
|
||||||
for consumer in dependents.get(current, set()):
|
|
||||||
if consumer not in affected:
|
|
||||||
affected.add(consumer)
|
affected.add(consumer)
|
||||||
queue.append(consumer)
|
queue.append(consumer)
|
||||||
|
|
||||||
|
build_affected = affected.copy()
|
||||||
|
queue = list(affected)
|
||||||
|
while queue:
|
||||||
|
current = queue.pop()
|
||||||
|
additions = (partners.get(current, set()) | dependents.get(current, set())) - affected
|
||||||
|
affected.update(additions)
|
||||||
|
queue.extend(additions)
|
||||||
|
co_validation = {partner for current in affected for partner in partners.get(current, set())}
|
||||||
|
co_validation -= build_affected
|
||||||
|
|
||||||
domains = set()
|
domains = set()
|
||||||
for component_id in list(affected):
|
queue = list(affected)
|
||||||
parent = graph[component_id].get("parent")
|
while queue:
|
||||||
while parent:
|
for parent in parents.get(queue.pop(), set()) - affected - domains:
|
||||||
if parent not in affected:
|
|
||||||
domains.add(parent)
|
domains.add(parent)
|
||||||
parent = graph[parent].get("parent") if parent in graph else None
|
queue.append(parent)
|
||||||
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)
|
return sorted(affected), sorted(domains), sorted(co_validation)
|
||||||
|
|
||||||
|
|
||||||
@@ -261,56 +266,14 @@ def consumers_of(component_id: str, revision: str) -> dict:
|
|||||||
revision_sha = resolve(ROOT, revision)
|
revision_sha = resolve(ROOT, revision)
|
||||||
graph, unverified = load_graph(ROOT, revision_sha, "root")
|
graph, unverified = load_graph(ROOT, revision_sha, "root")
|
||||||
if component_id not in graph:
|
if component_id not in graph:
|
||||||
graph, unverified = load_graph(ROOT, revision_sha, "root")
|
unverified.append(
|
||||||
return {
|
f"unknown component {component_id!r} at {revision_sha}; scope widened"
|
||||||
"schema": SCHEMA,
|
)
|
||||||
"schema_version": SCHEMA_VERSION,
|
fallback = "full" if unverified else None
|
||||||
"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:
|
if unverified:
|
||||||
affected = set(graph)
|
affected, domains, co_validation = sorted(graph), [], []
|
||||||
domains = set()
|
else:
|
||||||
co_validation = set()
|
affected, domains, co_validation = affected_set(graph, graph, [{"id": component_id}])
|
||||||
fallback = "full"
|
|
||||||
return {
|
return {
|
||||||
"schema": SCHEMA,
|
"schema": SCHEMA,
|
||||||
"schema_version": SCHEMA_VERSION,
|
"schema_version": SCHEMA_VERSION,
|
||||||
|
|||||||
+86
-57
@@ -10,12 +10,30 @@ set -euo pipefail
|
|||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
root="$PWD"
|
root="$PWD"
|
||||||
active="$(python3 scripts/check-layout.py --checkouts --active-paths)"
|
plan="$(python3 scripts/check-layout.py --active-entries)"
|
||||||
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'
|
declare -a gates=()
|
||||||
if [[ "$active" != "$expected" ]]; then
|
cli_smoke=
|
||||||
echo "UNVERIFIED: update the integration plan for the changed active component set" >&2
|
while IFS=$'\t' read -r id kind path entry; do
|
||||||
|
case "$kind:$id:$entry" in
|
||||||
|
core:cli:tools/release/smoke.py) cli_smoke="$path/$entry"; gate=core ;;
|
||||||
|
stdlib:*:scripts/test.sh) gate=stdlib ;;
|
||||||
|
test:conformance:scripts/build_all.sh) gate=conformance ;;
|
||||||
|
domain:web:scripts/domain-acceptance.sh) gate=web ;;
|
||||||
|
tool:view:scripts/acceptance.sh) gate=view ;;
|
||||||
|
tool:knowledge:scripts/ci.sh) gate=knowledge ;;
|
||||||
|
tool:prove:scripts/package-tool.sh) gate=prove ;;
|
||||||
|
tool:lint:scripts/package-tool.sh) gate=lint ;;
|
||||||
|
tool:*:scripts/ci.sh|tool:*:scripts/integration.sh|extension:*:scripts/ci.sh|extension:*:scripts/integration.sh|test:*:scripts/ci.sh|test:*:scripts/integration.sh)
|
||||||
|
gate=entry
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "UNVERIFIED: unsupported integration entry $id ($kind): $entry" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
gates+=("$gate")
|
||||||
|
done <<< "$plan"
|
||||||
|
test -n "$cli_smoke"
|
||||||
|
|
||||||
mkdir -p .integration-work
|
mkdir -p .integration-work
|
||||||
work="$(mktemp -d "$root/.integration-work/run.XXXXXX")"
|
work="$(mktemp -d "$root/.integration-work/run.XXXXXX")"
|
||||||
@@ -32,6 +50,7 @@ python3 --version
|
|||||||
python3 -c 'import jsonschema'
|
python3 -c 'import jsonschema'
|
||||||
python3 scripts/check-layout.py --checkouts > "$work/layout.txt"
|
python3 scripts/check-layout.py --checkouts > "$work/layout.txt"
|
||||||
cat "$work/layout.txt"
|
cat "$work/layout.txt"
|
||||||
|
printf '%s\n' "$plan" > "$work/active-entries.tsv"
|
||||||
|
|
||||||
# Recursive impact analysis against the accepted root commit: the change set
|
# Recursive impact analysis against the accepted root commit: the change set
|
||||||
# comes from the recursively expanded (global_id, parent, remote, SHA, state)
|
# comes from the recursively expanded (global_id, parent, remote, SHA, state)
|
||||||
@@ -75,7 +94,7 @@ python3 cli/tools/release/package.py \
|
|||||||
--source-sha "$source_sha" --version "$version" \
|
--source-sha "$source_sha" --version "$version" \
|
||||||
--stdlib-dir "$work/stdlib" --out-dir "$work/dist" | tee "$work/package.json"
|
--stdlib-dir "$work/stdlib" --out-dir "$work/dist" | tee "$work/package.json"
|
||||||
archive="$(find "$work/dist" -maxdepth 1 -name 'marqdo-*.tar.gz' -print -quit)"
|
archive="$(find "$work/dist" -maxdepth 1 -name 'marqdo-*.tar.gz' -print -quit)"
|
||||||
python3 cli/tools/release/smoke.py --archive "$archive"
|
python3 "$cli_smoke" --archive "$archive"
|
||||||
mkdir -p "$work/install"
|
mkdir -p "$work/install"
|
||||||
tar -xzf "$archive" -C "$work/install"
|
tar -xzf "$archive" -C "$work/install"
|
||||||
installed="$(find "$work/install" -mindepth 1 -maxdepth 1 -type d -print -quit)"
|
installed="$(find "$work/install" -mindepth 1 -maxdepth 1 -type d -print -quit)"
|
||||||
@@ -85,55 +104,39 @@ 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]))["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"
|
sha256sum "$archive" "$MARQDO_BIN" "$installed/marqdo-provider-worker"
|
||||||
|
|
||||||
# 4. Root stdlib acceptance: component entries, explicit Packages, composition
|
# Tool consumers use the same candidate installation and the catalog order.
|
||||||
# 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 \
|
|
||||||
--source-repo cli --tested-sha "$source_sha" --cli "$MARQDO_BIN" \
|
|
||||||
--release-info "$installed/RELEASE_INFO.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
|
# The candidate image uses a minimal Rust profile; component entries run
|
||||||
# fmt/clippy, so add those components once when the active toolchain lacks them.
|
# fmt/clippy, so add those components once when the active toolchain lacks them.
|
||||||
if command -v rustup >/dev/null 2>&1 \
|
if command -v rustup >/dev/null 2>&1 \
|
||||||
&& ! rustup component list --installed 2>/dev/null | grep -qx 'rustfmt.*'; then
|
&& ! rustup component list --installed 2>/dev/null | grep -qx 'rustfmt.*'; then
|
||||||
rustup component add rustfmt clippy
|
rustup component add rustfmt clippy
|
||||||
fi
|
fi
|
||||||
(
|
|
||||||
cd extensions/web/design
|
run_consumer() (
|
||||||
MARQDO_BIN="$MARQDO_BIN" scripts/ci.sh
|
cd "$root/$path"
|
||||||
)
|
export MARQDO_CI_OUT="$work/components/$id"
|
||||||
(
|
mkdir -p "$MARQDO_CI_OUT"
|
||||||
cd extensions/web/preview
|
case "$gate" in
|
||||||
MARQDO_BIN="$MARQDO_BIN" scripts/ci.sh
|
entry)
|
||||||
)
|
MARQDO_STDLIB_DIR="$installed/stdlib" "./$entry"
|
||||||
web_tool="$root/extensions/web/preview/dist/marqdo-web-preview/tool.json"
|
;;
|
||||||
test -f "$web_tool"
|
web)
|
||||||
export MARQDO_TOOL_HOME="$work/web-tool-home"
|
web_tool="$PWD/preview/dist/marqdo-web-preview/tool.json"
|
||||||
cli_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
export MARQDO_TOOL_HOME="$MARQDO_CI_OUT/tool-home"
|
||||||
|
cli_before="$(sha256sum "$MARQDO_BIN")"
|
||||||
"$MARQDO_BIN" tool install "$web_tool"
|
"$MARQDO_BIN" tool install "$web_tool"
|
||||||
"$MARQDO_BIN" web check extensions/web/examples/research-workspace/index.mq.md \
|
example=examples/research-workspace
|
||||||
--unit 工作台 --root extensions/web/examples/research-workspace
|
"$MARQDO_BIN" web check "$example/index.mq.md" --unit 工作台 --root "$example"
|
||||||
"$MARQDO_BIN" web preview extensions/web/examples/research-workspace/index.mq.md \
|
"$MARQDO_BIN" web preview "$example/index.mq.md" --unit 工作台 --root "$example" \
|
||||||
--unit 工作台 --root extensions/web/examples/research-workspace --out "$work/web-preview"
|
--out "$MARQDO_CI_OUT/preview"
|
||||||
test -f "$work/web-preview/index.html"
|
test -s "$MARQDO_CI_OUT/preview/index.html"
|
||||||
"$MARQDO_BIN" web handoff extensions/web/examples/research-workspace/index.mq.md \
|
"$MARQDO_BIN" web handoff "$example/index.mq.md" --unit 工作台 --root "$example" \
|
||||||
--unit 工作台 --root extensions/web/examples/research-workspace --out "$work/web-handoff.md"
|
--out "$MARQDO_CI_OUT/handoff.md"
|
||||||
test -s "$work/web-handoff.md"
|
test -s "$MARQDO_CI_OUT/handoff.md"
|
||||||
"$MARQDO_BIN" tool remove web
|
"$MARQDO_BIN" tool remove web
|
||||||
cli_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
test "$(sha256sum "$MARQDO_BIN")" = "$cli_before"
|
||||||
test "$cli_before" = "$cli_after"
|
;;
|
||||||
echo "web domain: component entries + cold Tool install PASS"
|
view)
|
||||||
# 6. Existing consumers, same installed binary and adjacent Bundle.
|
|
||||||
(
|
|
||||||
cd tools/view
|
|
||||||
export MARQDO_TOOL_HOME="$work/view-registry"
|
export MARQDO_TOOL_HOME="$work/view-registry"
|
||||||
scripts/package.sh
|
scripts/package.sh
|
||||||
"$MARQDO_BIN" tool install dist/marqdo-view/tool.json
|
"$MARQDO_BIN" tool install dist/marqdo-view/tool.json
|
||||||
@@ -167,24 +170,49 @@ echo "web domain: component entries + cold Tool install PASS"
|
|||||||
echo "view still dispatches after removal" >&2
|
echo "view still dispatches after removal" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
)
|
;;
|
||||||
(
|
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
|
||||||
)
|
;;
|
||||||
(
|
prove)
|
||||||
cd tools/prove
|
|
||||||
cargo test --locked --test analysis_document --test document_contract
|
cargo test --locked --test analysis_document --test document_contract
|
||||||
)
|
;;
|
||||||
(
|
lint)
|
||||||
cd tools/lint
|
|
||||||
export MARQDO_TOOL_HOME="$work/lint-registry"
|
export MARQDO_TOOL_HOME="$work/lint-registry"
|
||||||
scripts/package-tool.sh "$work/lint"
|
"./$entry" "$work/lint"
|
||||||
"$MARQDO_BIN" tool install "$work/lint/tool.json"
|
"$MARQDO_BIN" tool install "$work/lint/tool.json"
|
||||||
"$MARQDO_BIN" lint examples/nested/inventory.mq.md --format json
|
"$MARQDO_BIN" lint examples/nested/inventory.mq.md --format json
|
||||||
"$MARQDO_BIN" tool remove lint
|
"$MARQDO_BIN" tool remove lint
|
||||||
|
;;
|
||||||
|
esac
|
||||||
)
|
)
|
||||||
|
|
||||||
|
stdlib_accepted=false
|
||||||
|
index=0
|
||||||
|
while IFS=$'\t' read -r -u 3 id kind path entry; do
|
||||||
|
gate="${gates[index]}"
|
||||||
|
index=$((index + 1))
|
||||||
|
echo "candidate gate: $id ($path/$entry)"
|
||||||
|
case "$gate" in
|
||||||
|
core) ;; # CLI/Worker packaging and smoke ran before consumer gates.
|
||||||
|
stdlib)
|
||||||
|
if [ "$stdlib_accepted" = false ]; then
|
||||||
|
python3 scripts/acceptance-stdlib.py \
|
||||||
|
--cli "$MARQDO_BIN" --bundle "$work/stdlib" \
|
||||||
|
--work "$work/stdlib-acceptance" --evidence "$work/stdlib-acceptance.json"
|
||||||
|
stdlib_accepted=true
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
conformance)
|
||||||
|
python3 cli/tools/ci/verify_extension_contracts.py \
|
||||||
|
--source-repo cli --tested-sha "$source_sha" --cli "$MARQDO_BIN" \
|
||||||
|
--release-info "$installed/RELEASE_INFO.json" \
|
||||||
|
--fixtures "$path" --out "$work/conformance.json"
|
||||||
|
;;
|
||||||
|
*) run_consumer ;;
|
||||||
|
esac
|
||||||
|
done 3<<< "$plan"
|
||||||
|
|
||||||
# 7. Evidence identity for the accepted candidate.
|
# 7. Evidence identity for the accepted candidate.
|
||||||
root_commit="$(git rev-parse HEAD)"
|
root_commit="$(git rev-parse HEAD)"
|
||||||
python3 - "$work" "$root_commit" "$source_sha" "$bundle_digest" "$bundle_aliases" "$archive" <<'PY'
|
python3 - "$work" "$root_commit" "$source_sha" "$bundle_digest" "$bundle_aliases" "$archive" <<'PY'
|
||||||
@@ -202,6 +230,7 @@ evidence = {
|
|||||||
"stdlib_aliases_digest": sys.argv[5],
|
"stdlib_aliases_digest": sys.argv[5],
|
||||||
"archive": archive.name,
|
"archive": archive.name,
|
||||||
"archive_sha256": "sha256:" + hashlib.sha256(archive.read_bytes()).hexdigest(),
|
"archive_sha256": "sha256:" + hashlib.sha256(archive.read_bytes()).hexdigest(),
|
||||||
|
"active_entries": [line.split("\t") for line in (work / "active-entries.tsv").read_text().splitlines()],
|
||||||
"impact": (
|
"impact": (
|
||||||
{
|
{
|
||||||
"changed": impact["changed"],
|
"changed": impact["changed"],
|
||||||
|
|||||||
Executable
+562
@@ -0,0 +1,562 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Verify published releases and reconcile their tracking Issues (marqdo#10)."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import datetime
|
||||||
|
import hashlib
|
||||||
|
import http.client
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import impact
|
||||||
|
|
||||||
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
FORGE = "https://git.cflmy.cn"
|
||||||
|
CI = "https://ci.cflmy.cn"
|
||||||
|
ROOT_REPOSITORY = "cflmy/marqdo"
|
||||||
|
LABEL = "release-tracking"
|
||||||
|
RECONCILE_ACCOUNT = "marqdo-reconcile"
|
||||||
|
INDEX = "release-evidence.json"
|
||||||
|
PAGE_SIZE = 50
|
||||||
|
MAX_PAGES = 100
|
||||||
|
MAX_INDEX_BYTES = 1024 * 1024
|
||||||
|
MAX_ASSET_BYTES = 256 * 1024 * 1024
|
||||||
|
MAX_ASSETS = 128
|
||||||
|
MAX_DEPENDENCIES = 256
|
||||||
|
SHA = re.compile(r"[0-9a-f]{40}")
|
||||||
|
DIGEST = re.compile(r"[0-9a-f]{64}")
|
||||||
|
BASENAME = re.compile(r"[A-Za-z0-9][A-Za-z0-9._+-]{0,254}")
|
||||||
|
TAG = re.compile(r"[A-Za-z0-9][A-Za-z0-9._+-]{0,127}")
|
||||||
|
REPOSITORY = re.compile(r"https://git\.cflmy\.cn/(cflmy/[A-Za-z0-9-]+)\.git")
|
||||||
|
HISTORICAL_CLI = ("cflmy/marqdo-cli", "v3.0.0-rc.5",
|
||||||
|
"c44b0f943875d563bb7c170f8ccd3fd56a82360f")
|
||||||
|
|
||||||
|
|
||||||
|
class ReconcileError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NoRedirect(urllib.request.HTTPRedirectHandler):
|
||||||
|
def redirect_request(self, request, fp, code, message, headers, newurl):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class Gitea:
|
||||||
|
def __init__(self, token: str):
|
||||||
|
self.token = token
|
||||||
|
self.opener = urllib.request.build_opener(NoRedirect())
|
||||||
|
|
||||||
|
def open(self, method, url, data=None, authenticated=False):
|
||||||
|
headers = {}
|
||||||
|
if authenticated and self.token:
|
||||||
|
headers["Authorization"] = f"token {self.token}"
|
||||||
|
if data is not None:
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
request = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||||
|
return self.opener.open(request, timeout=30)
|
||||||
|
|
||||||
|
def request(self, method, base, path, data=None, authenticated=False):
|
||||||
|
try:
|
||||||
|
with self.open(method, base + path, data, authenticated) as response:
|
||||||
|
payload = response.read(8 * MAX_INDEX_BYTES + 1)
|
||||||
|
require(len(payload) <= 8 * MAX_INDEX_BYTES, "API response exceeds size limit")
|
||||||
|
return json.loads(payload)
|
||||||
|
except urllib.error.HTTPError as error:
|
||||||
|
raise ReconcileError(f"{method} {path}: HTTP {error.code}") from error
|
||||||
|
except (OSError, ValueError, http.client.HTTPException) as error:
|
||||||
|
raise ReconcileError(f"{method} {path}: {error}") from error
|
||||||
|
|
||||||
|
def get(self, path):
|
||||||
|
return self.request("GET", FORGE + "/api/v1", path, authenticated=True)
|
||||||
|
|
||||||
|
def post(self, path, data):
|
||||||
|
return self.request("POST", FORGE + "/api/v1", path,
|
||||||
|
json.dumps(data).encode(), authenticated=True)
|
||||||
|
|
||||||
|
def ci(self, path):
|
||||||
|
return self.request("GET", CI + "/api", path)
|
||||||
|
|
||||||
|
def asset(self, path, size, *, index=False):
|
||||||
|
limit = MAX_INDEX_BYTES if index else MAX_ASSET_BYTES
|
||||||
|
require(type(size) is int and 0 < size <= limit, "invalid asset size")
|
||||||
|
digest = hashlib.sha256()
|
||||||
|
payload = bytearray()
|
||||||
|
received = 0
|
||||||
|
try:
|
||||||
|
with self.open("GET", FORGE + path) as response:
|
||||||
|
while chunk := response.read(min(1024 * 1024, size - received + 1)):
|
||||||
|
received += len(chunk)
|
||||||
|
require(received <= size, f"asset {path} size mismatch")
|
||||||
|
digest.update(chunk)
|
||||||
|
if index:
|
||||||
|
payload.extend(chunk)
|
||||||
|
except urllib.error.HTTPError as error:
|
||||||
|
raise ReconcileError(f"GET {path}: HTTP {error.code}") from error
|
||||||
|
except (OSError, http.client.HTTPException) as error:
|
||||||
|
raise ReconcileError(f"GET {path}: {error}") from error
|
||||||
|
require(received == size, f"asset {path} size mismatch")
|
||||||
|
return digest.hexdigest(), bytes(payload)
|
||||||
|
|
||||||
|
|
||||||
|
def require(condition, message):
|
||||||
|
if not condition:
|
||||||
|
raise ReconcileError(message)
|
||||||
|
|
||||||
|
|
||||||
|
def match(pattern, value):
|
||||||
|
return isinstance(value, str) and pattern.fullmatch(value) is not None
|
||||||
|
|
||||||
|
|
||||||
|
def exact_fields(value, fields, optional=()):
|
||||||
|
return (isinstance(value, dict) and set(fields) <= value.keys()
|
||||||
|
and value.keys() <= set(fields) | set(optional))
|
||||||
|
|
||||||
|
|
||||||
|
def unique_object(pairs):
|
||||||
|
result = dict(pairs)
|
||||||
|
require(len(result) == len(pairs), "release evidence contains duplicate JSON fields")
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def pages(client, path, **params):
|
||||||
|
for page in range(1, MAX_PAGES + 1):
|
||||||
|
query = urllib.parse.urlencode(dict(params, limit=PAGE_SIZE, page=page))
|
||||||
|
batch = client.get(f"{path}?{query}")
|
||||||
|
require(isinstance(batch, list) and all(isinstance(item, dict) for item in batch),
|
||||||
|
f"{path}: invalid page {page}")
|
||||||
|
require(len(batch) <= PAGE_SIZE, f"{path}: invalid page size")
|
||||||
|
yield from batch
|
||||||
|
if len(batch) < PAGE_SIZE:
|
||||||
|
return
|
||||||
|
raise ReconcileError(f"{path}: pagination limit reached")
|
||||||
|
|
||||||
|
|
||||||
|
def timestamp(value):
|
||||||
|
try:
|
||||||
|
result = datetime.datetime.fromisoformat(value)
|
||||||
|
except (TypeError, ValueError) as error:
|
||||||
|
raise ReconcileError("invalid release timestamp") from error
|
||||||
|
require(result.tzinfo is not None, "release timestamp requires a time zone")
|
||||||
|
return result.astimezone(datetime.timezone.utc)
|
||||||
|
|
||||||
|
|
||||||
|
def managed_repositories(root):
|
||||||
|
try:
|
||||||
|
revision = impact.resolve(root, "HEAD")
|
||||||
|
graph, unverified = impact.load_graph(root, revision, "root")
|
||||||
|
except impact.ImpactError as error:
|
||||||
|
raise ReconcileError(str(error)) from error
|
||||||
|
require(not unverified, "; ".join(unverified))
|
||||||
|
managed = {}
|
||||||
|
for cid, item in sorted(graph.items()):
|
||||||
|
if not item["sha"]:
|
||||||
|
continue
|
||||||
|
remote = item["remote"] or ""
|
||||||
|
canonical = REPOSITORY.fullmatch(remote)
|
||||||
|
require(canonical is not None, f"{cid}: non-canonical repository")
|
||||||
|
repository = canonical[1]
|
||||||
|
require(repository not in managed, f"duplicate repository {repository}")
|
||||||
|
path = item["path"]
|
||||||
|
if item["parent"]:
|
||||||
|
path = f"{graph[item['parent']]['path']}/{path}"
|
||||||
|
managed[repository] = {**item, "path": path, "repository": repository}
|
||||||
|
return revision, graph, managed
|
||||||
|
|
||||||
|
|
||||||
|
def verify_pipeline(client, repository, source_sha, evidence):
|
||||||
|
require(exact_fields(evidence, {"pipeline_number", "url", "source_sha"}),
|
||||||
|
"invalid component CI evidence")
|
||||||
|
number = evidence["pipeline_number"]
|
||||||
|
require(type(number) is int and number > 0 and evidence["source_sha"] == source_sha,
|
||||||
|
"release has no component CI evidence for its exact SHA")
|
||||||
|
repo = client.ci(f"/repos/lookup/{repository}")
|
||||||
|
forge_repo = client.get(f"/repos/{repository}")
|
||||||
|
require(isinstance(repo, dict) and repo.get("full_name") == repository
|
||||||
|
and type(repo.get("id")) is int and repo["id"] > 0
|
||||||
|
and isinstance(forge_repo, dict) and type(forge_repo.get("id")) is int
|
||||||
|
and repo.get("forge_remote_id") == str(forge_repo["id"]),
|
||||||
|
"CI repository identity mismatch")
|
||||||
|
expected_url = f"{CI}/repos/{repo['id']}/pipeline/{number}"
|
||||||
|
require(evidence["url"] == expected_url, "component CI URL mismatch")
|
||||||
|
pipeline = client.ci(f"/repos/{repo['id']}/pipelines/{number}")
|
||||||
|
workflow = "main" if repository == "cflmy/marqdo-cli" else "ci"
|
||||||
|
require(isinstance(pipeline, dict) and pipeline.get("number") == number
|
||||||
|
and pipeline.get("commit") == source_sha and pipeline.get("status") == "success"
|
||||||
|
and pipeline.get("event") in {"push", "pull_request", "manual"}
|
||||||
|
and any(w.get("name") == workflow and w.get("state") == "success"
|
||||||
|
and any(step.get("type") == "commands" and step.get("state") == "success"
|
||||||
|
for step in w.get("children", []))
|
||||||
|
for w in pipeline.get("workflows", [])), "component CI did not verify the exact SHA")
|
||||||
|
|
||||||
|
|
||||||
|
def asset_path(repository, tag, asset):
|
||||||
|
name = asset.get("name")
|
||||||
|
require(match(BASENAME, name), "unsafe release asset name")
|
||||||
|
escaped = urllib.parse.quote(name, safe="")
|
||||||
|
path = f"/{repository}/releases/download/{urllib.parse.quote(tag, safe='')}/{escaped}"
|
||||||
|
require(asset.get("browser_download_url") == FORGE + path,
|
||||||
|
f"asset {name} has a non-canonical URL")
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def verify_release(client, repository, component, tag, release, graph):
|
||||||
|
identity = client.get(f"/repos/{repository}/tags/{urllib.parse.quote(tag, safe='')}")
|
||||||
|
require(isinstance(identity, dict) and identity.get("name") == tag
|
||||||
|
and isinstance(identity.get("commit"), dict)
|
||||||
|
and match(SHA, identity["commit"].get("sha")), "invalid release tag identity")
|
||||||
|
source_sha = identity["commit"]["sha"]
|
||||||
|
attachments = release.get("assets")
|
||||||
|
require(isinstance(attachments, list) and 0 < len(attachments) <= MAX_ASSETS + 1,
|
||||||
|
"missing or excessive release assets")
|
||||||
|
assets = {}
|
||||||
|
for asset in attachments:
|
||||||
|
require(isinstance(asset, dict), "invalid release asset")
|
||||||
|
path = asset_path(repository, tag, asset)
|
||||||
|
name = asset["name"]
|
||||||
|
require(name not in assets, "duplicate release asset")
|
||||||
|
assets[name] = (path, asset.get("size"))
|
||||||
|
if INDEX not in assets and (repository, tag, source_sha) == HISTORICAL_CLI:
|
||||||
|
return {"source_sha": source_sha, "historical": True}
|
||||||
|
|
||||||
|
require(INDEX in assets, "release evidence index missing")
|
||||||
|
index_digest, payload = client.asset(*assets.pop(INDEX), index=True)
|
||||||
|
try:
|
||||||
|
evidence = json.loads(payload, object_pairs_hook=unique_object)
|
||||||
|
except (UnicodeDecodeError, ValueError, RecursionError) as error:
|
||||||
|
raise ReconcileError("invalid release evidence JSON") from error
|
||||||
|
require(exact_fields(evidence, {"repository", "component_id", "tag", "source_sha",
|
||||||
|
"ci", "assets", "dependencies"}), "invalid release evidence fields")
|
||||||
|
require((evidence["repository"], evidence["component_id"], evidence["tag"], evidence["source_sha"])
|
||||||
|
== (repository, component["id"], tag, source_sha), "release evidence identity mismatch")
|
||||||
|
verify_pipeline(client, repository, source_sha, evidence["ci"])
|
||||||
|
|
||||||
|
dependencies = evidence["dependencies"]
|
||||||
|
require(isinstance(dependencies, list) and len(dependencies) <= MAX_DEPENDENCIES,
|
||||||
|
"invalid release dependency list")
|
||||||
|
seen = set()
|
||||||
|
for dependency in dependencies:
|
||||||
|
require(exact_fields(dependency, {"id", "source_sha"}, {"asset_sha256"})
|
||||||
|
and isinstance(dependency["id"], str) and dependency["id"] in graph
|
||||||
|
and dependency["id"] not in seen and dependency["id"] != component["id"]
|
||||||
|
and match(SHA, dependency["source_sha"])
|
||||||
|
and ("asset_sha256" not in dependency or match(DIGEST, dependency["asset_sha256"])),
|
||||||
|
"invalid release dependency identity")
|
||||||
|
seen.add(dependency["id"])
|
||||||
|
require(set(component["requires"]) <= seen, "release evidence is missing a declared dependency")
|
||||||
|
|
||||||
|
records = evidence["assets"]
|
||||||
|
require(isinstance(records, list) and 0 < len(records) == len(assets),
|
||||||
|
"release evidence does not cover the published assets")
|
||||||
|
for item in records:
|
||||||
|
require(exact_fields(item, {"name", "size", "target", "sha256"})
|
||||||
|
and match(BASENAME, item["name"]) and item["name"] in assets
|
||||||
|
and match(BASENAME, item["target"]) and match(DIGEST, item["sha256"])
|
||||||
|
and type(item["size"]) is int, "invalid release asset evidence")
|
||||||
|
path, size = assets.pop(item["name"])
|
||||||
|
require(size == item["size"], f"asset {item['name']} size mismatch")
|
||||||
|
digest, _ = client.asset(path, size)
|
||||||
|
require(digest == item["sha256"], f"asset {item['name']} digest mismatch")
|
||||||
|
return {"source_sha": source_sha, "index_sha256": index_digest,
|
||||||
|
"ci": evidence["ci"], "assets": records, "dependencies": dependencies}
|
||||||
|
|
||||||
|
|
||||||
|
def release_marker(repository, tag):
|
||||||
|
return f"<!-- marqdo:release-reconcile repository={repository} tag={tag} -->"
|
||||||
|
|
||||||
|
|
||||||
|
def identity_marker(entry):
|
||||||
|
return f"<!-- marqdo:verified-release {entry['source_sha']} {entry['index_sha256']} -->"
|
||||||
|
|
||||||
|
|
||||||
|
def consumer_inputs(entry, graph):
|
||||||
|
release_key = hashlib.sha256(
|
||||||
|
f"{entry['repository']}\n{entry['tag']}\n{entry['source_sha']}".encode()
|
||||||
|
).hexdigest()
|
||||||
|
release = {key: entry[key] for key in ("repository", "tag", "source_sha", "index_sha256")}
|
||||||
|
release["assets"] = sorted(entry["assets"], key=lambda asset: asset["name"])
|
||||||
|
release["dependencies"] = sorted(entry["dependencies"], key=lambda dependency: dependency["id"])
|
||||||
|
conflicts = [dependency["id"] for dependency in release["dependencies"]
|
||||||
|
if dependency["source_sha"] != graph[dependency["id"]]["sha"]]
|
||||||
|
tasks = []
|
||||||
|
for consumer_id in entry["direct_consumers"]:
|
||||||
|
consumer = graph[consumer_id]
|
||||||
|
remote = REPOSITORY.fullmatch(consumer.get("remote") or "")
|
||||||
|
require(remote is not None and match(SHA, consumer.get("sha")),
|
||||||
|
f"{consumer_id}: consumer is missing its managed repository or accepted SHA")
|
||||||
|
inputs = {
|
||||||
|
"release": release,
|
||||||
|
"consumer": {"id": consumer_id, "source_sha": consumer["sha"]},
|
||||||
|
"accepted_dependencies": [
|
||||||
|
{"id": dep, "source_sha": graph[dep]["sha"]} for dep in sorted(consumer["requires"])
|
||||||
|
if dep != entry["component"]
|
||||||
|
],
|
||||||
|
}
|
||||||
|
digest = hashlib.sha256(json.dumps(inputs, sort_keys=True, separators=(",", ":")).encode()).hexdigest()
|
||||||
|
key = hashlib.sha256(f"{release_key}\n{consumer_id}\n{digest}".encode()).hexdigest()
|
||||||
|
tasks.append({"consumer": consumer_id, "repository": remote[1], "key": key, "digest": digest,
|
||||||
|
"baseline_sha": consumer["sha"], "inputs": inputs,
|
||||||
|
"status": "waiting-for-dependencies" if conflicts else "pending",
|
||||||
|
"different_dependencies": conflicts})
|
||||||
|
return release_key, tasks
|
||||||
|
|
||||||
|
|
||||||
|
def tracking_body(entry):
|
||||||
|
lines = [entry["marker"], f"## {entry['repository']} {entry['tag']}",
|
||||||
|
"", f"- Component: {entry['component']} ({entry['path']})",
|
||||||
|
f"- Published: {entry['published_at']}", f"- Accepted gitlink: {entry['accepted_sha']}",
|
||||||
|
f"- Release: {FORGE}/{entry['repository']}/releases/tag/{entry['tag']}"]
|
||||||
|
if "error" in entry:
|
||||||
|
return "\n".join(lines + ["", "## Blocked", "", f"- {entry['error']}"])
|
||||||
|
return "\n".join(lines + ["", identity_marker(entry),
|
||||||
|
f"- Source SHA: {entry['source_sha']}", f"- Index SHA-256: {entry['index_sha256']}",
|
||||||
|
f"- Component CI: {entry['ci']['url']}",
|
||||||
|
"", "## Verified assets", "",
|
||||||
|
*(f"- {a['name']} ({a['target']}, {a['size']} bytes): {a['sha256']}" for a in entry["assets"]),
|
||||||
|
"", "## Pending consumer validation", "",
|
||||||
|
f"- Direct consumers: {', '.join(entry['direct_consumers']) or 'none'}",
|
||||||
|
*(f"- {task['consumer']} at {task['baseline_sha']}: {task['status']} (inputs {task['digest']})"
|
||||||
|
for task in entry["consumer_tasks"]),
|
||||||
|
f"- Affected: {', '.join(entry['affected']) or 'none'}",
|
||||||
|
f"- Governance owner: {entry['governance_owner']}"])
|
||||||
|
|
||||||
|
|
||||||
|
def is_writer(record):
|
||||||
|
return (record.get("user") or {}).get("login") == RECONCILE_ACCOUNT
|
||||||
|
|
||||||
|
|
||||||
|
def tracking_comments(client, issues_url, tracker):
|
||||||
|
if not is_writer(tracker):
|
||||||
|
return []
|
||||||
|
comments_url = f"{issues_url}/{tracker['number']}/comments"
|
||||||
|
return [comment.get("body") or "" for comment in pages(client, comments_url)
|
||||||
|
if is_writer(comment)]
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_tracking_note(client, issues_url, tracker, entry, comments):
|
||||||
|
if not is_writer(tracker):
|
||||||
|
entry["tracking_update"] = "tracker author differs from configured account"
|
||||||
|
return
|
||||||
|
note = tracking_body(entry)
|
||||||
|
if note not in comments and note != tracker.get("body"):
|
||||||
|
client.post(f"{issues_url}/{tracker['number']}/comments", {"body": note})
|
||||||
|
|
||||||
|
|
||||||
|
def verify_apply_context(client, root_sha):
|
||||||
|
writer = client.get("/user")
|
||||||
|
require(isinstance(writer, dict) and writer.get("login") == RECONCILE_ACCOUNT
|
||||||
|
and writer.get("is_admin") is False, "apply requires the non-admin reconcile account")
|
||||||
|
root = client.get(f"/repos/{ROOT_REPOSITORY}")
|
||||||
|
require(isinstance(root, dict) and root.get("default_branch") == "main",
|
||||||
|
"apply requires the root default branch")
|
||||||
|
verify_root_base(client, root_sha)
|
||||||
|
|
||||||
|
|
||||||
|
def verify_root_base(client, root_sha):
|
||||||
|
branch = client.get(f"/repos/{ROOT_REPOSITORY}/branches/main")
|
||||||
|
require(isinstance(branch, dict) and branch.get("protected") is True
|
||||||
|
and (branch.get("commit") or {}).get("id") == root_sha,
|
||||||
|
"apply requires the current protected root commit")
|
||||||
|
|
||||||
|
|
||||||
|
def register_consumer_tasks(client, root_sha, entry, issue_cache):
|
||||||
|
for task in entry["consumer_tasks"]:
|
||||||
|
issues_url = f"/repos/{task['repository']}/issues"
|
||||||
|
marker = f"<!-- marqdo:upstream release={entry['release_key']} consumer={task['consumer']} -->"
|
||||||
|
body = "\n".join([
|
||||||
|
marker,
|
||||||
|
f"<!-- marqdo:candidate-inputs {task['key']} -->",
|
||||||
|
"",
|
||||||
|
f"- Root tracking issue: {FORGE}/{ROOT_REPOSITORY}/issues/{entry['issue']}",
|
||||||
|
f"- Root candidate: {root_sha}",
|
||||||
|
f"- Consumer baseline: {task['baseline_sha']}",
|
||||||
|
f"- Input digest: {task['digest']}",
|
||||||
|
f"- State: {task['status']}",
|
||||||
|
"",
|
||||||
|
"```json",
|
||||||
|
json.dumps(task["inputs"], ensure_ascii=False, sort_keys=True, indent=2),
|
||||||
|
"```",
|
||||||
|
])
|
||||||
|
try:
|
||||||
|
if issues_url not in issue_cache:
|
||||||
|
issue_cache[issues_url] = list(pages(client, issues_url, state="all", type="issues"))
|
||||||
|
issues = issue_cache[issues_url]
|
||||||
|
matches = [issue for issue in issues if is_writer(issue)
|
||||||
|
and (issue.get("body") or "").splitlines()[:1] == [marker]]
|
||||||
|
require(len(matches) <= 1, "multiple matching consumer tasks")
|
||||||
|
if matches:
|
||||||
|
issue = matches[0]
|
||||||
|
if issue["state"] == "open":
|
||||||
|
comments = tracking_comments(client, issues_url, issue)
|
||||||
|
key_line = f"<!-- marqdo:candidate-inputs {task['key']} -->"
|
||||||
|
baselines = [note.splitlines() for note in [issue["body"], *comments]
|
||||||
|
if note.splitlines()[:1] == [marker]]
|
||||||
|
if not {key_line, f"- Root candidate: {root_sha}"} <= set(baselines[-1]):
|
||||||
|
verify_root_base(client, root_sha)
|
||||||
|
client.post(f"{issues_url}/{issue['number']}/comments", {"body": body})
|
||||||
|
else:
|
||||||
|
task["registration"] = "closed"
|
||||||
|
else:
|
||||||
|
verify_root_base(client, root_sha)
|
||||||
|
issue = client.post(issues_url, {
|
||||||
|
"title": f"[upstream] {entry['component']} {entry['tag']} for {task['consumer']}",
|
||||||
|
"body": body,
|
||||||
|
})
|
||||||
|
issues.append(issue)
|
||||||
|
task["issue"] = issue["number"]
|
||||||
|
task.setdefault("registration", "recorded")
|
||||||
|
except ReconcileError as error:
|
||||||
|
task.update(registration="blocked", error=str(error))
|
||||||
|
|
||||||
|
|
||||||
|
def reconcile(client, root=PROJECT_ROOT, apply=False, report_out=None, cutoff=None):
|
||||||
|
root_sha, graph, managed = managed_repositories(root)
|
||||||
|
cutoff_time = timestamp(cutoff) if cutoff else None
|
||||||
|
issues_url = f"/repos/{ROOT_REPOSITORY}/issues"
|
||||||
|
issues = list(pages(client, issues_url, state="all", type="issues", labels=LABEL))
|
||||||
|
if apply:
|
||||||
|
verify_apply_context(client, root_sha)
|
||||||
|
labels = f"/repos/{ROOT_REPOSITORY}/labels"
|
||||||
|
label_id = next((x["id"] for x in pages(client, labels) if x.get("name") == LABEL), None) if apply else None
|
||||||
|
results, errors, consumer_issues = [], {}, {}
|
||||||
|
for repository, component in managed.items():
|
||||||
|
known_tags = set()
|
||||||
|
try:
|
||||||
|
releases = list(pages(client, f"/repos/{repository}/releases"))
|
||||||
|
for release in releases:
|
||||||
|
if release.get("draft"):
|
||||||
|
continue
|
||||||
|
tag = release.get("tag_name")
|
||||||
|
require(match(TAG, tag), "invalid release tag in listing")
|
||||||
|
require(tag not in known_tags, f"duplicate release in paginated listing: {tag}")
|
||||||
|
known_tags.add(tag)
|
||||||
|
published = timestamp(release.get("published_at") or release.get("created_at"))
|
||||||
|
marker = release_marker(repository, tag)
|
||||||
|
trackers = [issue for issue in issues
|
||||||
|
if (issue.get("body") or "").splitlines()[:1] == [marker]]
|
||||||
|
if cutoff_time and published < cutoff_time and not trackers:
|
||||||
|
continue
|
||||||
|
entry = {
|
||||||
|
"component": component["id"], "path": component["path"], "repository": repository,
|
||||||
|
"tag": tag, "marker": marker, "published_at": published.isoformat(),
|
||||||
|
"accepted_sha": component["sha"],
|
||||||
|
"component_state": component["state"],
|
||||||
|
}
|
||||||
|
comments = tracking_comments(client, issues_url, trackers[0]) if len(trackers) == 1 else []
|
||||||
|
recorded = comments + ([trackers[0].get("body") or ""] if trackers and
|
||||||
|
is_writer(trackers[0]) else [])
|
||||||
|
try:
|
||||||
|
require(len(trackers) <= 1, "multiple release tracking Issues")
|
||||||
|
entry.update(verify_release(client, repository, component, tag, release, graph))
|
||||||
|
if entry.get("historical"):
|
||||||
|
entry["status"] = "historical-baseline"
|
||||||
|
else:
|
||||||
|
affected, domains, co_validation = impact.affected_set(
|
||||||
|
graph, graph, [{"id": component["id"]}])
|
||||||
|
direct = [cid for cid, item in graph.items()
|
||||||
|
if component["id"] in item["requires"]]
|
||||||
|
entry.update(status="pending", affected=affected, domains=domains,
|
||||||
|
checks_with=co_validation,
|
||||||
|
direct_consumers=sorted(cid for cid in direct if graph[cid]["state"] == "active"),
|
||||||
|
planned_consumers=sorted(cid for cid in direct if graph[cid]["state"] == "planned"),
|
||||||
|
governance_owner=component["parent"] or ROOT_REPOSITORY)
|
||||||
|
old = {line for body in recorded for line in body.splitlines()
|
||||||
|
if line.startswith("<!-- marqdo:verified-release ")}
|
||||||
|
require(not old or old == {identity_marker(entry)},
|
||||||
|
"published release identity or index digest changed")
|
||||||
|
entry["release_key"], entry["consumer_tasks"] = consumer_inputs(entry, graph)
|
||||||
|
except ReconcileError as error:
|
||||||
|
entry.update(status="blocked", error=str(error))
|
||||||
|
|
||||||
|
if trackers:
|
||||||
|
entry["issue"] = trackers[0]["number"]
|
||||||
|
if entry["status"] == "pending" and any(
|
||||||
|
identity_marker(entry) in body.splitlines() for body in recorded):
|
||||||
|
entry["status"] = "tracked"
|
||||||
|
if apply and len(trackers) == 1 and entry["status"] in {"pending", "tracked", "blocked"}:
|
||||||
|
ensure_tracking_note(client, issues_url, trackers[0], entry, comments)
|
||||||
|
elif apply and entry["status"] in {"pending", "blocked"}:
|
||||||
|
require(label_id is not None, f"tracking label {LABEL!r} is missing")
|
||||||
|
created = client.post(issues_url, {
|
||||||
|
"title": f"[release] {repository} {tag}", "labels": [label_id],
|
||||||
|
"body": tracking_body(entry),
|
||||||
|
})
|
||||||
|
entry["issue"] = created["number"]
|
||||||
|
if entry["status"] == "pending":
|
||||||
|
entry["status"] = "created"
|
||||||
|
if (apply and entry.get("consumer_tasks") and not entry.get("tracking_update")
|
||||||
|
and entry["status"] in {"created", "pending", "tracked"}
|
||||||
|
and (not trackers or trackers[0]["state"] == "open")):
|
||||||
|
register_consumer_tasks(client, root_sha, entry, consumer_issues)
|
||||||
|
results.append(entry)
|
||||||
|
prefix = f"<!-- marqdo:release-reconcile repository={repository} tag="
|
||||||
|
for issue in issues:
|
||||||
|
marker = (issue.get("body") or "").partition("\n")[0]
|
||||||
|
if marker.startswith(prefix) and marker.endswith(" -->"):
|
||||||
|
tag = marker[len(prefix):-4]
|
||||||
|
if match(TAG, tag) and tag not in known_tags:
|
||||||
|
error = "previously tracked release is absent from the public list"
|
||||||
|
entry = {"repository": repository, "component": component["id"],
|
||||||
|
"tag": tag, "issue": issue["number"], "status": "blocked",
|
||||||
|
"error": error}
|
||||||
|
if apply and is_writer(issue):
|
||||||
|
note = f"{marker}\n\n## Blocked\n\n- {error}"
|
||||||
|
if note not in tracking_comments(client, issues_url, issue):
|
||||||
|
client.post(f"{issues_url}/{issue['number']}/comments", {"body": note})
|
||||||
|
results.append(entry)
|
||||||
|
except ReconcileError as error:
|
||||||
|
errors[repository] = str(error)
|
||||||
|
report = {
|
||||||
|
"schema": "marqdo.release-reconcile.v1", "schema_version": 1,
|
||||||
|
"root_repository": ROOT_REPOSITORY, "root_sha": root_sha,
|
||||||
|
"apply": apply, "repositories": len(managed), "releases": len(results),
|
||||||
|
"scan_complete": not errors, "scan_errors": errors, "results": results,
|
||||||
|
"counts": {status: sum(item["status"] == status for item in results)
|
||||||
|
for status in sorted({item["status"] for item in results})},
|
||||||
|
"generated_at": datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||||||
|
}
|
||||||
|
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")
|
||||||
|
return report
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
mode = parser.add_mutually_exclusive_group()
|
||||||
|
mode.add_argument("--plan", action="store_true", help="verify without writing to Gitea (default)")
|
||||||
|
mode.add_argument("--apply", action="store_true", help="reconcile release tracking Issues")
|
||||||
|
parser.add_argument("--report-out", type=Path)
|
||||||
|
parser.add_argument("--root", type=Path, default=PROJECT_ROOT)
|
||||||
|
parser.add_argument("--published-after", default=os.environ.get("MARQDO_RECONCILE_PUBLISHED_AFTER"))
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
token = os.environ.get("MARQDO_GIT_TOKEN", "")
|
||||||
|
if args.apply and not token:
|
||||||
|
parser.error("--apply requires MARQDO_GIT_TOKEN")
|
||||||
|
try:
|
||||||
|
if args.published_after:
|
||||||
|
timestamp(args.published_after)
|
||||||
|
except ReconcileError as error:
|
||||||
|
parser.error(str(error))
|
||||||
|
try:
|
||||||
|
report = reconcile(Gitea(token), args.root.resolve(), args.apply,
|
||||||
|
args.report_out, args.published_after)
|
||||||
|
except (OSError, ReconcileError) as error:
|
||||||
|
print(f"reconcile: {error}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||||
|
return int(not report["scan_complete"] or any(
|
||||||
|
item["status"] == "blocked" or "tracking_update" in item
|
||||||
|
or any(task.get("registration") == "blocked" for task in item.get("consumer_tasks", []))
|
||||||
|
for item in report["results"]))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main(sys.argv[1:]))
|
||||||
+1
-1
Submodule stdlib/collections updated: 4907652268...60f0e82737.
+1
-1
Submodule stdlib/data updated: 848af7a357...0775c1af3c.
+1
-1
Submodule stdlib/fs updated: 63bceae587...ef9e1a8cad.
+1
-1
Submodule stdlib/io updated: e18b0b1b40...efcf1a0fb4.
+1
-1
Submodule stdlib/system updated: 053ddb0e59...cfe98c6339.
+1
-1
Submodule stdlib/text updated: c2a7d327e5...161600102d.
+1
-1
Submodule tests/conformance updated: 015ff8ac15...4a6f564ea5.
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
Builds real temporary Git repositories for two root candidates and asserts the
|
Builds real temporary Git repositories for two root candidates and asserts the
|
||||||
ordering required by the development contract: changed leaves, reverse
|
ordering required by the development contract: changed leaves, reverse
|
||||||
`requires` closure over the union graph, parent domains, then `checks_with`
|
`requires` closure over the union graph, `checks_with` fixed point, then
|
||||||
fixed point; undetermined scope widens to the full candidate instead of being
|
parent domains. Undetermined scope widens to the full candidate.
|
||||||
skipped.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import importlib.util
|
import importlib.util
|
||||||
@@ -207,6 +206,19 @@ class ImpactTest(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertIn("std-text", report["affected"])
|
self.assertIn("std-text", report["affected"])
|
||||||
|
|
||||||
|
def test_removed_requires_edge_remains_in_the_impact_scope(self):
|
||||||
|
leaves = self.leaf_shas()
|
||||||
|
first = self.make_tree(COMPONENTS_V1, leaves)
|
||||||
|
without_dependency = COMPONENTS_V1.replace(
|
||||||
|
'requires = ["cli", "std-core"]', 'requires = ["cli"]'
|
||||||
|
)
|
||||||
|
second = self.make_tree(without_dependency, leaves)
|
||||||
|
before, _ = impact.load_graph(self.root, first, "before")
|
||||||
|
after, _ = impact.load_graph(self.root, second, "after")
|
||||||
|
affected, _, partners = impact.affected_set(before, after, [{"id": "std-core"}])
|
||||||
|
self.assertIn("std-text", affected)
|
||||||
|
self.assertIn("probe", partners)
|
||||||
|
|
||||||
def test_domain_gitlink_change_expands_to_child_identity(self):
|
def test_domain_gitlink_change_expands_to_child_identity(self):
|
||||||
child = init(self.root / "extensions/web")
|
child = init(self.root / "extensions/web")
|
||||||
write(child / "components.toml", catalog(
|
write(child / "components.toml", catalog(
|
||||||
|
|||||||
@@ -334,6 +334,27 @@ class HierarchicalLayoutTests(unittest.TestCase):
|
|||||||
layout.validate("HEAD", True)
|
layout.validate("HEAD", True)
|
||||||
layout.validate("HEAD", False)
|
layout.validate("HEAD", False)
|
||||||
|
|
||||||
|
def test_active_entries_use_the_dependency_order_and_include_a_new_leaf(self):
|
||||||
|
design = self.leaf("design")
|
||||||
|
catalog_text = DOMAIN.replace('state = "planned"', 'state = "active"').replace(
|
||||||
|
'checks_with = ["web-preview"]\nrelease = "optional"',
|
||||||
|
'checks_with = ["web-preview"]\nrelease = "optional"\nentry = "scripts/ci.sh"',
|
||||||
|
)
|
||||||
|
self.assemble(domain_catalog=catalog_text, design=design,
|
||||||
|
extra_domain_link=("components", design[1]), domain_modules={
|
||||||
|
"design": "https://git.cflmy.cn/cflmy/marqdo-web-design.git",
|
||||||
|
"preview": "https://git.cflmy.cn/cflmy/marqdo-web-preview.git",
|
||||||
|
"components": "https://git.cflmy.cn/cflmy/marqdo-web-components.git",
|
||||||
|
})
|
||||||
|
layers = layout.validate("HEAD", True)
|
||||||
|
entries = list(layout.active_entries(layers))
|
||||||
|
ids = [entry[0] for entry in entries]
|
||||||
|
self.assertIn(("web-components", "extension", "extensions/web/components", "scripts/ci.sh"), entries)
|
||||||
|
self.assertLess(ids.index("cli"), ids.index("web-design"))
|
||||||
|
self.assertLess(ids.index("web-design"), ids.index("web-preview"))
|
||||||
|
self.assertLess(ids.index("web-components"), ids.index("web"))
|
||||||
|
self.assertEqual(set(ids), {"cli", "web", "web-design", "web-preview", "web-components"})
|
||||||
|
|
||||||
def test_accepts_a_planned_domain_and_planned_child_gitlinks(self):
|
def test_accepts_a_planned_domain_and_planned_child_gitlinks(self):
|
||||||
web = WEB_DOMAIN.replace('state = "active"', 'state = "planned"').replace(
|
web = WEB_DOMAIN.replace('state = "active"', 'state = "planned"').replace(
|
||||||
'entry = "scripts/integration.sh"\n', '')
|
'entry = "scripts/integration.sh"\n', '')
|
||||||
|
|||||||
@@ -0,0 +1,299 @@
|
|||||||
|
"""Release reconciliation tests for marqdo#10."""
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import importlib.util
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest.mock import patch
|
||||||
|
from urllib.parse import parse_qs, urlsplit
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
SPEC = importlib.util.spec_from_file_location(
|
||||||
|
"reconcile_releases", ROOT / "scripts" / "reconcile-releases.py"
|
||||||
|
)
|
||||||
|
reconcile = importlib.util.module_from_spec(SPEC)
|
||||||
|
with patch.object(sys, "path", [str(ROOT / "scripts"), *sys.path]):
|
||||||
|
SPEC.loader.exec_module(reconcile)
|
||||||
|
|
||||||
|
REPO = "cflmy/marqdo-std-text"
|
||||||
|
SOURCE = "a" * 40
|
||||||
|
BASE = "b" * 40
|
||||||
|
TAG = "v0.1.0-rc.1"
|
||||||
|
PUBLISHED = "2026-11-27T08:00:00+08:00"
|
||||||
|
ASSET = "text-source.tar.gz"
|
||||||
|
ISSUES = "/repos/cflmy/marqdo/issues"
|
||||||
|
CONSUMER_ISSUES = "/repos/cflmy/marqdo-ext-archive/issues"
|
||||||
|
FORGE = reconcile.FORGE
|
||||||
|
ACTOR = {"login": reconcile.RECONCILE_ACCOUNT}
|
||||||
|
COMPONENT = {"id": "std-text", "sha": BASE, "path": "stdlib/text",
|
||||||
|
"parent": None, "requires": [], "checks_with": [], "state": "active"}
|
||||||
|
|
||||||
|
|
||||||
|
class FakeForge:
|
||||||
|
def __init__(self):
|
||||||
|
self.writes = []
|
||||||
|
self.issues = []
|
||||||
|
self.consumer_issues = []
|
||||||
|
self.comments = {}
|
||||||
|
self.pages = []
|
||||||
|
self.pipeline_reads = []
|
||||||
|
self.downloads = []
|
||||||
|
self.blobs = {ASSET: b"abc"}
|
||||||
|
self.evidence = {
|
||||||
|
"repository": REPO, "component_id": COMPONENT["id"], "tag": TAG, "source_sha": SOURCE,
|
||||||
|
"ci": {"pipeline_number": 12, "source_sha": SOURCE,
|
||||||
|
"url": f"{reconcile.CI}/repos/8/pipeline/12"},
|
||||||
|
"assets": [{"name": ASSET, "size": 3, "target": "source",
|
||||||
|
"sha256": hashlib.sha256(self.blobs[ASSET]).hexdigest()}],
|
||||||
|
"dependencies": [],
|
||||||
|
}
|
||||||
|
self.release = {"tag_name": TAG, "draft": False, "prerelease": True,
|
||||||
|
"published_at": PUBLISHED}
|
||||||
|
self.releases = [self.release]
|
||||||
|
self.protected = True
|
||||||
|
self.root_sha = BASE
|
||||||
|
self.tag_sha = SOURCE
|
||||||
|
self.pipeline_sha = SOURCE
|
||||||
|
self.wrong_account = False
|
||||||
|
self.fail_page = None
|
||||||
|
self.refresh_assets()
|
||||||
|
|
||||||
|
def refresh_assets(self):
|
||||||
|
self.blobs[reconcile.INDEX] = json.dumps(self.evidence).encode()
|
||||||
|
self.release["assets"] = [
|
||||||
|
{"name": name, "size": len(blob),
|
||||||
|
"browser_download_url": f"{FORGE}/{REPO}/releases/download/{TAG}/{name}"}
|
||||||
|
for name, blob in self.blobs.items()
|
||||||
|
]
|
||||||
|
|
||||||
|
def get(self, url):
|
||||||
|
parsed = urlsplit(url)
|
||||||
|
path = parsed.path
|
||||||
|
query = parse_qs(parsed.query)
|
||||||
|
if query:
|
||||||
|
page = int(query["page"][0])
|
||||||
|
self.pages.append((path, page))
|
||||||
|
if path.endswith("/releases") and page == self.fail_page:
|
||||||
|
raise reconcile.ReconcileError("API HTTP 503")
|
||||||
|
records = {
|
||||||
|
f"/repos/{REPO}/releases": self.releases,
|
||||||
|
ISSUES: self.issues,
|
||||||
|
CONSUMER_ISSUES: self.consumer_issues,
|
||||||
|
"/repos/cflmy/marqdo/labels": [{"id": 5, "name": reconcile.LABEL}],
|
||||||
|
**self.comments,
|
||||||
|
}.get(path, [])
|
||||||
|
return records[(page - 1) * reconcile.PAGE_SIZE: page * reconcile.PAGE_SIZE]
|
||||||
|
|
||||||
|
return {
|
||||||
|
f"/repos/{REPO}": {"id": 10},
|
||||||
|
f"/repos/{REPO}/tags/{TAG}": {"name": TAG, "commit": {"sha": self.tag_sha}},
|
||||||
|
"/repos/cflmy/marqdo": {"default_branch": "main"},
|
||||||
|
"/repos/cflmy/marqdo/branches/main": {"protected": self.protected,
|
||||||
|
"commit": {"id": self.root_sha}},
|
||||||
|
"/user": ({"login": "admin", "is_admin": True} if self.wrong_account
|
||||||
|
else {**ACTOR, "is_admin": False}),
|
||||||
|
}[path]
|
||||||
|
|
||||||
|
def ci(self, path):
|
||||||
|
self.pipeline_reads.append(path)
|
||||||
|
if path == f"/repos/lookup/{REPO}":
|
||||||
|
return {"id": 8, "full_name": REPO, "forge_remote_id": "10"}
|
||||||
|
if path == "/repos/8/pipelines/12":
|
||||||
|
return {"number": 12, "commit": self.pipeline_sha, "status": "success", "event": "push",
|
||||||
|
"workflows": [{"name": "ci", "state": "success",
|
||||||
|
"children": [{"type": "commands", "state": "success"}]}]}
|
||||||
|
raise AssertionError(path)
|
||||||
|
|
||||||
|
def asset(self, path, size, *, index=False):
|
||||||
|
self.downloads.append(path)
|
||||||
|
data = self.blobs[path.rsplit("/", 1)[1]]
|
||||||
|
if len(data) != size:
|
||||||
|
raise reconcile.ReconcileError("asset size mismatch")
|
||||||
|
return hashlib.sha256(data).hexdigest(), data if index else b""
|
||||||
|
|
||||||
|
def post(self, path, data):
|
||||||
|
self.writes.append((path, data))
|
||||||
|
item = {"body": data["body"], "user": ACTOR, "state": "open"}
|
||||||
|
if path in {ISSUES, CONSUMER_ISSUES}:
|
||||||
|
issues = self.issues if path == ISSUES else self.consumer_issues
|
||||||
|
item["number"] = 100 + len(issues)
|
||||||
|
issues.append(item)
|
||||||
|
else:
|
||||||
|
self.comments.setdefault(path, []).append(item)
|
||||||
|
return item
|
||||||
|
|
||||||
|
|
||||||
|
class ReconcileTest(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
graph = {COMPONENT["id"]: COMPONENT}
|
||||||
|
catalog = (BASE, graph, {REPO: COMPONENT})
|
||||||
|
mocked = patch.object(reconcile, "managed_repositories", return_value=catalog)
|
||||||
|
mocked.start()
|
||||||
|
self.addCleanup(mocked.stop)
|
||||||
|
self.forge = FakeForge()
|
||||||
|
|
||||||
|
def run_scan(self, **kwargs):
|
||||||
|
return reconcile.reconcile(self.forge, **kwargs)
|
||||||
|
|
||||||
|
def test_dry_run_fully_verifies_without_writing(self):
|
||||||
|
report = self.run_scan()
|
||||||
|
self.assertEqual(self.forge.writes, [])
|
||||||
|
entry, = report["results"]
|
||||||
|
self.assertEqual(entry["status"], "pending")
|
||||||
|
self.assertEqual(entry["source_sha"], SOURCE)
|
||||||
|
self.assertEqual(entry["governance_owner"], "cflmy/marqdo")
|
||||||
|
self.assertEqual(len(self.forge.downloads), 2)
|
||||||
|
self.assertEqual(len(self.forge.pipeline_reads), 2)
|
||||||
|
|
||||||
|
def test_consumer_inputs_are_tied_to_assets_dependencies_and_accepted_sha(self):
|
||||||
|
consumer = {"id": "archive", "state": "active", "sha": "c" * 40,
|
||||||
|
"remote": FORGE + "/cflmy/marqdo-ext-archive.git",
|
||||||
|
"requires": ["std-text", "cli"], "checks_with": []}
|
||||||
|
cli = {"id": "cli", "state": "active", "sha": "d" * 40,
|
||||||
|
"requires": [], "checks_with": []}
|
||||||
|
graph = {item["id"]: item for item in (COMPONENT, consumer, cli)}
|
||||||
|
with patch.object(reconcile, "managed_repositories", return_value=(BASE, graph, {REPO: COMPONENT})):
|
||||||
|
entry, = self.run_scan()["results"]
|
||||||
|
task, = entry["consumer_tasks"]
|
||||||
|
self.assertEqual(task["consumer"], "archive")
|
||||||
|
self.assertEqual(task["baseline_sha"], consumer["sha"])
|
||||||
|
self.assertEqual(task["inputs"]["release"]["assets"][0]["name"], ASSET)
|
||||||
|
self.assertEqual(task["inputs"]["accepted_dependencies"], [{"id": "cli", "source_sha": cli["sha"]}])
|
||||||
|
self.assertEqual(task["status"], "pending")
|
||||||
|
cli["sha"] = "e" * 40
|
||||||
|
first_key = task["key"]
|
||||||
|
entry, = self.run_scan()["results"]
|
||||||
|
task, = entry["consumer_tasks"]
|
||||||
|
self.assertNotEqual(task["key"], first_key)
|
||||||
|
self.forge.evidence["dependencies"] = [{"id": "cli", "source_sha": "d" * 40}]
|
||||||
|
self.forge.refresh_assets()
|
||||||
|
entry, = self.run_scan()["results"]
|
||||||
|
task, = entry["consumer_tasks"]
|
||||||
|
self.assertEqual(task["status"], "waiting-for-dependencies")
|
||||||
|
self.assertEqual(task["different_dependencies"], ["cli"])
|
||||||
|
self.assertEqual(self.forge.writes, [])
|
||||||
|
|
||||||
|
def test_apply_creates_one_consumer_issue_and_records_new_inputs_in_it(self):
|
||||||
|
consumer = {"id": "archive", "state": "active", "sha": "c" * 40,
|
||||||
|
"remote": FORGE + "/cflmy/marqdo-ext-archive.git",
|
||||||
|
"requires": ["std-text"], "checks_with": []}
|
||||||
|
graph = {item["id"]: item for item in (COMPONENT, consumer)}
|
||||||
|
with patch.object(reconcile, "managed_repositories", return_value=(BASE, graph, {REPO: COMPONENT})):
|
||||||
|
entry, = self.run_scan(apply=True)["results"]
|
||||||
|
task, = entry["consumer_tasks"]
|
||||||
|
self.assertEqual(task["registration"], "recorded")
|
||||||
|
self.assertEqual(task["issue"], 100)
|
||||||
|
self.assertIn(FORGE + "/cflmy/marqdo/issues/100", self.forge.consumer_issues[0]["body"])
|
||||||
|
self.run_scan(apply=True)
|
||||||
|
self.assertEqual(len(self.forge.writes), 2)
|
||||||
|
consumer["sha"] = "e" * 40
|
||||||
|
self.run_scan(apply=True)
|
||||||
|
self.assertEqual(len(self.forge.consumer_issues), 1)
|
||||||
|
self.assertEqual(len(self.forge.comments[CONSUMER_ISSUES + "/100/comments"]), 1)
|
||||||
|
self.run_scan(apply=True)
|
||||||
|
self.assertEqual(len(self.forge.comments[CONSUMER_ISSUES + "/100/comments"]), 1)
|
||||||
|
new_root = "f" * 40
|
||||||
|
self.forge.root_sha = new_root
|
||||||
|
with patch.object(reconcile, "managed_repositories", return_value=(new_root, graph, {REPO: COMPONENT})):
|
||||||
|
self.run_scan(apply=True)
|
||||||
|
self.run_scan(apply=True)
|
||||||
|
notes = self.forge.comments[CONSUMER_ISSUES + "/100/comments"]
|
||||||
|
self.assertEqual(len(notes), 2)
|
||||||
|
self.assertIn(f"- Root candidate: {new_root}", notes[-1]["body"])
|
||||||
|
|
||||||
|
def test_apply_creates_one_verified_tracker_then_rechecks_it(self):
|
||||||
|
entry, = self.run_scan(apply=True)["results"]
|
||||||
|
self.assertEqual(entry["status"], "created")
|
||||||
|
self.assertEqual(entry["issue"], 100)
|
||||||
|
self.assertEqual(self.forge.writes[0][1]["labels"], [5])
|
||||||
|
body = self.forge.issues[0]["body"]
|
||||||
|
self.assertIn(reconcile.release_marker(REPO, TAG), body)
|
||||||
|
self.assertIn(reconcile.identity_marker(entry), body)
|
||||||
|
entry, = self.run_scan(apply=True)["results"]
|
||||||
|
self.assertEqual(entry["status"], "tracked")
|
||||||
|
self.assertEqual(len(self.forge.writes), 1)
|
||||||
|
self.assertEqual(len(self.forge.downloads), 4)
|
||||||
|
|
||||||
|
def test_partial_upload_and_wrong_ci_sha_block_once(self):
|
||||||
|
self.forge.pipeline_sha = BASE
|
||||||
|
for _ in range(2):
|
||||||
|
entry, = self.run_scan(apply=True)["results"]
|
||||||
|
self.assertEqual(entry["status"], "blocked")
|
||||||
|
self.assertIn("exact SHA", entry["error"])
|
||||||
|
self.assertEqual(len(self.forge.writes), 1)
|
||||||
|
self.forge.pipeline_sha = SOURCE
|
||||||
|
self.forge.release["assets"].pop(0)
|
||||||
|
entry, = self.run_scan()["results"]
|
||||||
|
self.assertEqual(entry["status"], "blocked")
|
||||||
|
self.assertIn("cover the published assets", entry["error"])
|
||||||
|
|
||||||
|
def test_validated_tracker_detects_an_updated_index_and_disappearing_release(self):
|
||||||
|
self.run_scan(apply=True)
|
||||||
|
self.forge.evidence["assets"][0]["target"] = "x86_64-unknown-linux-gnu"
|
||||||
|
self.forge.refresh_assets()
|
||||||
|
entry, = self.run_scan(apply=True)["results"]
|
||||||
|
self.assertEqual(entry["status"], "blocked")
|
||||||
|
self.assertIn("index digest changed", entry["error"])
|
||||||
|
self.assertEqual(len(self.forge.issues), 1)
|
||||||
|
self.forge.releases = []
|
||||||
|
entry, = self.run_scan()["results"]
|
||||||
|
self.assertIn("absent", entry["error"])
|
||||||
|
|
||||||
|
def test_previously_blocked_tracker_records_verified_identity_in_bot_comment(self):
|
||||||
|
self.forge.pipeline_sha = BASE
|
||||||
|
self.run_scan(apply=True)
|
||||||
|
self.forge.pipeline_sha = SOURCE
|
||||||
|
entry, = self.run_scan(apply=True)["results"]
|
||||||
|
self.assertEqual(entry["status"], "pending")
|
||||||
|
self.assertIn(reconcile.identity_marker(entry), self.forge.writes[-1][1]["body"])
|
||||||
|
entry, = self.run_scan(apply=True)["results"]
|
||||||
|
self.assertEqual(entry["status"], "tracked")
|
||||||
|
self.assertEqual(len(self.forge.writes), 2)
|
||||||
|
|
||||||
|
def test_uses_normalized_publish_timestamp_and_skips_draft(self):
|
||||||
|
self.assertEqual(self.run_scan(cutoff="2026-11-27T00:00:01Z")["results"], [])
|
||||||
|
self.assertTrue(self.run_scan(cutoff="2026-11-27T00:00:00Z")["results"])
|
||||||
|
self.forge.release["draft"] = True
|
||||||
|
self.assertEqual(self.run_scan()["results"], [])
|
||||||
|
|
||||||
|
def test_multiple_pages_and_partial_list_error(self):
|
||||||
|
self.forge.releases = [{"draft": True}] * reconcile.PAGE_SIZE + [self.forge.release]
|
||||||
|
report = self.run_scan()
|
||||||
|
self.assertTrue(report["scan_complete"])
|
||||||
|
self.assertEqual(len(report["results"]), 1)
|
||||||
|
self.assertIn((f"/repos/{REPO}/releases", 2), self.forge.pages)
|
||||||
|
self.forge.fail_page = 2
|
||||||
|
report = self.run_scan(apply=True)
|
||||||
|
self.assertFalse(report["scan_complete"])
|
||||||
|
self.assertEqual(report["scan_errors"][REPO], "API HTTP 503")
|
||||||
|
self.assertEqual(self.forge.writes, [])
|
||||||
|
|
||||||
|
def test_asset_location_name_and_digest_are_checked(self):
|
||||||
|
asset = self.forge.release["assets"][0]
|
||||||
|
asset["browser_download_url"] = "https://invalid.example/capture"
|
||||||
|
entry, = self.run_scan()["results"]
|
||||||
|
self.assertIn("non-canonical URL", entry["error"])
|
||||||
|
self.assertEqual(self.forge.downloads, [])
|
||||||
|
self.forge.refresh_assets()
|
||||||
|
self.forge.release["assets"][0]["name"] = "../escape.tar.gz"
|
||||||
|
entry, = self.run_scan()["results"]
|
||||||
|
self.assertIn("unsafe release asset name", entry["error"])
|
||||||
|
self.forge.refresh_assets()
|
||||||
|
self.forge.blobs[ASSET] = b"xxx"
|
||||||
|
entry, = self.run_scan()["results"]
|
||||||
|
self.assertIn("digest mismatch", entry["error"])
|
||||||
|
|
||||||
|
def test_apply_requires_current_protected_branch_and_non_admin_identity(self):
|
||||||
|
self.forge.protected = False
|
||||||
|
with self.assertRaisesRegex(reconcile.ReconcileError, "protected root"):
|
||||||
|
self.run_scan(apply=True)
|
||||||
|
self.forge.wrong_account = True
|
||||||
|
with self.assertRaisesRegex(reconcile.ReconcileError, "non-admin"):
|
||||||
|
self.run_scan(apply=True)
|
||||||
|
self.assertEqual(self.forge.writes, [])
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
||||||
+1
-1
Submodule tools/knowledge updated: d8fa201b28...3cc477de60.
+1
-1
Submodule tools/lint updated: 111e085f24...c21e1a9d8a.
+1
-1
Submodule tools/prove updated: d8c340b6e2...5201d8b6a3.
+1
-1
Submodule tools/view updated: 04f3a0e9e5...13f89f758d.
Reference in new issue
Block a user