* ci(interface): 添加接口完整性和CLI烟雾测试检查 - 在Makefile中新增interface-integrity、update-interface-baseline、cli-smoke和mock-mcp-smoke目标 - 实现接口基线脚本以比较CLI公共命令树与基线文件 - 新增脚本确保二进制文件可渲染所有顶层命令的帮助信息 - 添加mock-mcp-smoke测试验证HTTP和stdio MCP请求/响应传输 - 在GitHub Actions CI工作流中加入interface-integrity、cli-smoke和mock-mcp-smoke检查 - 新增AI行为检查工作流,限制AI生成PR的改动范围和禁改保护文件 - 文档中补充PR质量门禁要求及接口变更流程说明 * feat(policy): 增加多项兼容性和完整性检查 - Makefile中新增reset-interface-baseline、schema-compatibility、update-schema-baseline、skill-command-integrity等目标 - CI流程新增schema-compatibility和skill-command-integrity步骤 - 文档中详细说明接口兼容性基线更新和重置流程及schema基线注意事项 - 实现interface-baseline工具支持兼容性重置和合并,多项接口兼容性检查逻辑完善 - 新增schema-compat工具用于标准化schema列表及兼容性检查与合并 - 新增skill-command-integrity检查确保技能中引用命令存在 - 为interface-baseline和schema-compat添加单元测试覆盖基本兼容性规则 * test(skill-command-check): 增加命令解析和解析结果测试用例 - 补充对 parseReference 函数的边界情况和跳过条件的测试 - 新增 resolveCommandReference 函数测试,覆盖有效、无效及跳过场景 - 增加 isPlaceholder 函数的测试,验证占位符识别准确性 refactor(skill-command-check): 优化命令路径解析和验证逻辑 - 使用 resolveCommandReference 统一处理命令解析结果,清晰区分有效、无效和跳过情况 - 新增 commandResolution 类型及常量,提升代码可读性和扩展性 - 调整 parseReference 增加对 shell 组合符 “ & ” 的跳过处理 docs(mono): 更新最佳实践和产品文档命令示例 - 优化《best_practices/07-minutes.md》中行动项与摘要拉取示例命令,提升准确性 - 修改产品文档中 ALIDOC 表格数据和多维表格记录相关命令,命令路径更规范统一 - 同步多端技能文档,确保命令示例一致且正确 * ci: check interface against PR merge-base * feat(policy): enforce CLI contract compatibility * ci: enforce PR coverage thresholds * ci: add fail-closed CI gate * ci: adapt schema compatibility gate to runtime catalog * fix(ci): close schema compatibility gate gaps * test(auth): skip POSIX mode assertion on Windows * test(auth): scope POSIX file-backend checks * fix(ci): enforce native platform coverage * test(ci): make skill paths portable --------- Co-authored-by: 修雨 <huyizhou.hyz@alibaba-inc.com>
92 lines
2.3 KiB
Bash
Executable File
92 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
# Compare the candidate command tree against a Git-owned historical source
|
|
# revision. CI invokes this for both the PR merge-base and latest stable tag; a
|
|
# fixture from the candidate branch is never used as authority.
|
|
|
|
ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)"
|
|
BASE_REF=""
|
|
|
|
usage() {
|
|
printf '%s\n' "usage: $0 --base-ref <ref>" >&2
|
|
}
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
case "$1" in
|
|
--base-ref)
|
|
[ "$#" -ge 2 ] || { usage; exit 2; }
|
|
BASE_REF="$2"
|
|
shift 2
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
printf 'error: unknown argument: %s\n' "$1" >&2
|
|
usage
|
|
exit 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
[ -n "$BASE_REF" ] || { usage; exit 2; }
|
|
|
|
cd "$ROOT"
|
|
git rev-parse --verify --quiet "${BASE_REF}^{commit}" >/dev/null || {
|
|
printf 'error: interface authority is not available locally: %s\n' "$BASE_REF" >&2
|
|
exit 2
|
|
}
|
|
|
|
TMP_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/dws-interface-authority.XXXXXX")"
|
|
BASE_WORKTREE="$TMP_ROOT/base-worktree"
|
|
BASELINE="$TMP_ROOT/merge-base.txt"
|
|
CANDIDATE_BIN="$TMP_ROOT/interface-baseline"
|
|
CANDIDATE_HOME="$TMP_ROOT/candidate-home"
|
|
|
|
cleanup() {
|
|
git -C "$ROOT" worktree remove --force "$BASE_WORKTREE" >/dev/null 2>&1 || true
|
|
rm -rf "$TMP_ROOT"
|
|
}
|
|
trap cleanup EXIT
|
|
trap 'exit 129' HUP
|
|
trap 'exit 130' INT
|
|
trap 'exit 143' TERM
|
|
|
|
install_snapshot_helper() {
|
|
worktree="$1"
|
|
helper="$worktree/scripts/policy/interface-baseline"
|
|
|
|
# Use one contract format on both sides while constructing the command tree
|
|
# from the authoritative historical source revision.
|
|
rm -rf "$helper"
|
|
mkdir -p "$helper"
|
|
cp -R "$ROOT/scripts/policy/interface-baseline/." "$helper/"
|
|
}
|
|
|
|
generate_reference() {
|
|
ref="$1"
|
|
worktree="$2"
|
|
output="$3"
|
|
home="$4"
|
|
bin="$TMP_ROOT/reference-$(basename "$worktree")"
|
|
|
|
git -C "$ROOT" worktree add --detach "$worktree" "$ref" >/dev/null
|
|
install_snapshot_helper "$worktree"
|
|
mkdir -p "$home"
|
|
(
|
|
cd "$worktree"
|
|
go build -o "$bin" ./scripts/policy/interface-baseline
|
|
HOME="$home" DWS_LANG=zh "$bin" >"$output"
|
|
)
|
|
}
|
|
|
|
generate_reference "$BASE_REF" "$BASE_WORKTREE" "$BASELINE" "$TMP_ROOT/base-home"
|
|
|
|
mkdir -p "$CANDIDATE_HOME"
|
|
go build -o "$CANDIDATE_BIN" ./scripts/policy/interface-baseline
|
|
|
|
printf 'checking candidate against authoritative interface ref %s\n' "$BASE_REF"
|
|
HOME="$CANDIDATE_HOME" DWS_LANG=zh "$CANDIDATE_BIN" --check "$BASELINE"
|