Import record from scripts/import_yinduzhanxing.py --apply on a clean d09feab7 clone (root SKILL.md unchanged since ea2a9d65); source-manifest and import plan point at d09feab7; the ea2a9d65 record test becomes history. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
44 lines
2.3 KiB
Python
44 lines
2.3 KiB
Python
"""Git-mode import record for upstream main ea2a9d65 (eleventh sync, 2026-11-07), kept as history.
|
||
|
||
原值: 本文件要求 source-manifest.json 仍停在 ea2a9d65、且与本记录的树哈希相同
|
||
新值: 只核对这份历史记录自身完整、SKILL.md 快照哈希不变(d09feab7 未改根 SKILL.md),且已不是当前镜像
|
||
原因: 产品 2026-11-07 同步占星师工作分支 d09feab7(tests/test_upstream_git_import_d09feab7.py)
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import hashlib
|
||
import json
|
||
import re
|
||
from pathlib import Path
|
||
|
||
from jsonschema import Draft202012Validator, FormatChecker
|
||
|
||
ROOT = Path(__file__).resolve().parents[1]
|
||
RECORD = ROOT / "references/cross_project_contract/imports/commit-ea2a9d657451cd04615a3a7108dc92666dc8340c.json"
|
||
SOURCE_MANIFEST = ROOT / "references/upstream/yinduzhanxing/source-manifest.json"
|
||
SKILL_SNAPSHOT = ROOT / "references/upstream/yinduzhanxing/SKILL.md"
|
||
SCHEMA = ROOT / "references/cross_project_contract/import_manifest.schema.json"
|
||
COMMIT = "ea2a9d657451cd04615a3a7108dc92666dc8340c"
|
||
|
||
|
||
def test_git_import_record_matches_mirrored_skill_and_manifest() -> None:
|
||
record = json.loads(RECORD.read_text(encoding="utf-8"))
|
||
manifest = json.loads(SOURCE_MANIFEST.read_text(encoding="utf-8"))
|
||
schema = json.loads(SCHEMA.read_text(encoding="utf-8"))
|
||
Draft202012Validator(schema, format_checker=FormatChecker()).validate(record)
|
||
|
||
assert record["source_mode"] == "git"
|
||
assert record["source_commit"] == COMMIT
|
||
assert re.fullmatch(r"[0-9a-f]{40}", record["source_commit"])
|
||
assert re.fullmatch(r"[0-9a-f]{64}", record["source_tree_hash"])
|
||
assert record["source_tree_hash"] != manifest["source_tree_sha256"]
|
||
assert record["source_skill_sha256"] == manifest["source_skill_sha256"]
|
||
snapshot_hash = hashlib.sha256(SKILL_SNAPSHOT.read_bytes()).hexdigest()
|
||
assert snapshot_hash == record["source_skill_sha256"] == record["mirror_files"][0]["target_sha256_after"]
|
||
assert record["mirror_files"][0]["status"] == "applied"
|
||
assert manifest["source_mode"] == "git"
|
||
assert manifest["source_commit"] != COMMIT
|
||
# 原值: 全部 review_required。新值: 另允许 unchanged。原因: 产品 2026-11-07 同步占星师上游 ea2a9d65,strict-workflow-router.md 两边已一致
|
||
assert all(row["status"] in {"review_required", "unchanged"} for row in record["semantic_merge_files"])
|