chore(market): 专项复核并更新 humanizer / impeccable / last30days / khazix-skills 上游快照 (#299)

专项复核(Class C)并更新 humanizer / impeccable / last30days / khazix-skills
的上游快照,使自动核验真正通过后再开正式 PR。

本 PR 取代仍停在草稿里的 desirecore/market#295、#296、#297、#298。不会把那些失败草稿标成
Ready,也不合并它们。本次不涉及 dingtalk-cli(#294 仍只上架)。

## 复核结论

- **humanizer** `8c307f367c91bd974002f10f2be2965d642c13df` →
`b48c832f0f809c1b5658edbb838c2521b72f2413`(4.0.0)。MIT 未变。接受新增的根目录 pi
`package.json`(无 dependencies / scripts),并同步去掉维基百科引用后的简介。
- **impeccable** `d34c87e1a00989ae8dbdd7f6b30b70f23319e860` →
`d41d9860b0094dcb68030657da63461212835aaa`(4.9.2)。Apache-2.0 与 NOTICE.md
未变。`plugin/skills/impeccable/scripts/data/font-index.json`(1,100,013
字节,blob `9d2029971df232a72ff6584d264c104490521742`)新旧 pin
相同,作预算豁免、不从安装范围拿掉。接受引擎 pin 0.1.18 → 0.1.25。
- **last30days** `e06af25a9a78487b75e8509e0e1687fec137176e` →
`a854f3bcb2c4344d7498426d653378510f8b253a`(4.3.2)。MIT 未变。审核树排除
`skills/last30days/assets`(五份超预算示例媒体,已在上游 `.skillignore`,blob 与旧 pin
相同)。接受根 `pyproject.toml` 仅版本变化,以及 `uv.lock` 中 dev-only pytest 9.1.1 →
9.2.0。DesireCore 安装器在支持 exclude 前仍会拉取 assets。
- **khazix-skills** `322346ded8129436b3f64707789a73e732ae24d9` →
`725ac9421901ef7fac6761136969d032737abcf3`。根目录与 aihot 的 MIT
未变,合集成员未变。审核树排除 neat-freak 评测夹具里 5 个指向 `CLAUDE.md` 的既有符号链接。子技能简介按官方
`gen-collection-children.py` 同步;保留已有的 `leader` 展示文案覆盖。

专项复核记录写在各技能的 `special-review.v1.json`(reviewedBy: mashagua,reviewedAt:
2026-11-18)。通过后的机器回执是 `upstream-audit.v1.json`,`reviewedBy` 为
`automated:source-license-metadata-v1`,`reviewedRef` 为新
SHA,`observed_at` 为 `2026-11-18T15:21:35Z`。

为支持上述复核,本次同时加入 `schemas/special-review.v1.schema.json`,并让
`audit_skill_update.py` 在自动核验时读取 excludePaths / budgetExemptPaths /
已接受的依赖与 frontmatter 身份。`excludePaths` 只从审核树省略路径,不能隐藏 LICENSE / NOTICE /
COPYING 或依赖清单。没有提高 `MAX_FILE_BYTES`。

## 本地验证

在当前 main(`23b4124dc4dba88a7a531fe6d502dba9993d0558`)上的工作副本中:

- `audit_snapshots`:四个技能均 PASS
- `scripts/catalog/test_audit_skill_update.py`:18/18
- `scripts/catalog/test_validate_catalog_metadata.py`:62/62
-
`scripts/catalog/test_collection_generator.py`、`test_propose_upstream_updates.py`、`test_check_upstream_health.py`、`test_review_workflow.py`、`scripts/i18n/test_validate_i18n.py`:全部通过
- `validate_catalog_metadata.py --require-complete`:0 error / 104
warning(警告为目录中既有项)
- `gen-collection-children.py --check khazix-skills`:OK(6 children)
- `scripts/i18n/validate-i18n.py`:0 error
- `scripts/i18n/translate.py --check`:通过

本 PR 不代表运行或安全认证,也不自动合并。
This commit is contained in:
mashagua authored and GitHub committed 2026-11-19 07:26:12 +08:00
1 parent 7d92094b97
commit f9d2f810c7
20 files changed
+481 -75

No files matched your search

+86 -11
View File
@@ -3,6 +3,7 @@
from __future__ import annotations
import copy
import fnmatch
import hashlib
import json
import re
@@ -41,20 +42,27 @@ def safe_path(value: str) -> str:
return '' if str(path) == '.' else str(path)
def tree(repo: Path, ref: str, path: str = '') -> dict[str, tuple[str, str, int]]:
records = git(repo, 'ls-tree', '-rlz', ref, '--', path or '.').split(b'\0')
def tree(repo: Path, ref: str, path: str = '', exclude_paths=(), budget_exempt_paths=()) -> dict[str, tuple[str, str, int]]:
# Do not use ls-tree -l: in a partial clone it fetches every blob just to read
# the size, including files we are about to exclude (multi-megabyte demos).
records = git(repo, 'ls-tree', '-rz', ref, '--', path or '.').split(b'\0')
result = {}
for record in records:
if not record:
continue
meta, filename = record.split(b'\t', 1)
mode, kind, oid, size = meta.decode().split()
mode, kind, oid = meta.decode().split()[:3]
name = filename.decode('utf-8')
if path_matches(name, exclude_paths):
if protected_audit_path(name):
raise AuditBlocked('排除列表不能用于许可、Notice 或依赖清单')
continue
if kind != 'blob' or mode not in ('100644', '100755'):
raise AuditBlocked('来源包含符号链接、子模块或不支持的节点')
if int(size) > MAX_FILE_BYTES:
size = int(git(repo, 'cat-file', '-s', oid))
if size > MAX_FILE_BYTES and not path_matches(name, budget_exempt_paths):
raise AuditBlocked('单文件超过自动审核预算')
result[name] = (mode, oid, int(size))
result[name] = (mode, oid, size)
if len(result) > MAX_FILES or sum(item[2] for item in result.values()) > MAX_CONTENT_BYTES:
raise AuditBlocked('来源超过自动审核内容预算')
return result
@@ -101,6 +109,39 @@ def dependency_file(path: str) -> bool:
def path_matches(name: str, patterns: list[str] | tuple[str, ...] | None) -> bool:
"""Exact path, directory prefix, or fnmatch glob. Patterns are repo-relative."""
for raw in patterns or ():
pattern = raw[:-1] if raw.endswith('/') else raw
if name == pattern or name.startswith(pattern + '/'):
return True
if fnmatch.fnmatch(name, raw) or fnmatch.fnmatch(name, pattern):
return True
return False
def protected_audit_path(path: str) -> bool:
name = PurePosixPath(path).name.upper()
return name.startswith(('LICENSE', 'NOTICE', 'COPYING')) or dependency_file(path)
def frontmatter_identity(fm: dict) -> str:
return hashlib.sha256(json.dumps(stable_frontmatter(fm), sort_keys=True, ensure_ascii=False).encode()).hexdigest()
def dependency_acceptance_key(identity: tuple) -> str:
return identity[1]
def load_special_review(record) -> dict:
if not record:
return {}
if not isinstance(record, dict) or record.get('schemaVersion') != 1:
raise AuditBlocked('专项复核记录格式无效')
return record
def dependency_identity(repo: Path, ref: str, path: str, record):
if PurePosixPath(path).name.lower() == 'package.json':
try:
@@ -116,7 +157,7 @@ def dependency_identity(repo: Path, ref: str, path: str, record):
def audit_snapshots(repo: Path, entry: dict, sidecar: dict, result: dict,
observed_at: str | None = None) -> tuple[dict, dict, dict]:
observed_at: str | None = None, special_review: dict | None = None) -> tuple[dict, dict, dict]:
old, new = result['ref'], result['head']
if not all(re.fullmatch('[0-9a-f]{40}', ref) for ref in (old, new)):
raise AuditBlocked('审核必须绑定完整 SHA')
@@ -135,12 +176,22 @@ def audit_snapshots(repo: Path, entry: dict, sidecar: dict, result: dict,
now = observed_at or datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
if not re.fullmatch(r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z', now):
raise AuditBlocked('审核时间格式不正确')
review = load_special_review(special_review)
exclude_paths = review.get('excludePaths') or []
budget_exempt_paths = review.get('budgetExemptPaths') or []
if not isinstance(exclude_paths, list) or not isinstance(budget_exempt_paths, list):
raise AuditBlocked('专项复核的排除或预算豁免列表无效')
if any(not isinstance(item, str) or item != safe_path(item) for item in [*exclude_paths, *budget_exempt_paths]):
raise AuditBlocked('专项复核路径不安全')
if any(protected_audit_path(item) for item in exclude_paths):
raise AuditBlocked('排除列表不能用于许可、Notice 或依赖清单')
paths = [safe_path(child['path']) for child in entry.get('children', [])]
if not paths:
paths = [safe_path(entry['source'].get('path', ''))]
old_files, new_files = {}, {}
for path in paths:
old_files.update(tree(repo, old, path)); new_files.update(tree(repo, new, path))
old_files.update(tree(repo, old, path, exclude_paths, budget_exempt_paths))
new_files.update(tree(repo, new, path, exclude_paths, budget_exempt_paths))
if not new_files or len(new_files) > MAX_FILES or sum(item[2] for item in new_files.values()) > MAX_CONTENT_BYTES:
raise AuditBlocked('新快照为空或超过总预算')
licenses = root_evidence(repo, old)
@@ -176,7 +227,18 @@ def audit_snapshots(repo: Path, entry: dict, sidecar: dict, result: dict,
old_dependencies = {path: dependency_identity(repo, old, path, value) for path, value in old_files.items() if dependency_file(path)}
new_dependencies = {path: dependency_identity(repo, new, path, value) for path, value in new_files.items() if dependency_file(path)}
if old_dependencies != new_dependencies:
raise AuditBlocked('依赖清单有变化,无法自动确认新的前置条件')
accepted = review.get('acceptedDependencyIdentities') or {}
if not isinstance(accepted, dict) or any(not isinstance(k, str) or not isinstance(v, str) for k, v in accepted.items()):
raise AuditBlocked('依赖清单有变化,无法自动确认新的前置条件')
if set(old_dependencies) - set(new_dependencies):
raise AuditBlocked('依赖清单有变化,无法自动确认新的前置条件')
expected = {
path: dependency_acceptance_key(value)
for path, value in new_dependencies.items()
if path not in old_dependencies or dependency_acceptance_key(old_dependencies[path]) != dependency_acceptance_key(value)
}
if accepted != expected:
raise AuditBlocked('依赖清单有变化,无法自动确认新的前置条件')
versions = {}
for path in paths:
marker = f'{path}/SKILL.md' if path else 'SKILL.md'
@@ -185,7 +247,9 @@ def audit_snapshots(repo: Path, entry: dict, sidecar: dict, result: dict,
if not isinstance(old_fm, dict) or not isinstance(new_fm, dict):
raise AuditBlocked('技能 frontmatter 必须是对象')
if stable_frontmatter(old_fm) != stable_frontmatter(new_fm):
raise AuditBlocked('名称、简介、依赖、兼容性或其他结构化声明有变化,需同步审核元数据和翻译')
accepted_fm = review.get('acceptedFrontmatterSha256') or {}
if not isinstance(accepted_fm, dict) or accepted_fm.get(path) != frontmatter_identity(new_fm):
raise AuditBlocked('名称、简介、依赖、兼容性或其他结构化声明有变化,需同步审核元数据和翻译')
raw = new_fm.get('version')
if raw is None and not entry.get('children'):
details = new_fm.get('metadata')
@@ -239,13 +303,24 @@ def audit_snapshots(repo: Path, entry: dict, sidecar: dict, result: dict,
'fileCount': len(new_files),
'limitations': ['自动来源、许可和结构化元数据核验;不执行上游代码,不代表软件安全认证或真实运行验收。',
'未结构化表达的依赖与行为变化仍在 PR 差异中供复核,不据此扩大授权。']}
if review:
report['specialReview'] = {
'reviewedBy': review.get('reviewedBy'),
'reviewedAt': review.get('reviewedAt'),
'excludePaths': list(exclude_paths),
'budgetExemptPaths': list(budget_exempt_paths),
}
report['limitations'].append('依赖清单或结构化简介如有变化,已按专项复核记录中的接受哈希核对,不代表这些字段与旧快照逐字节相同。')
if exclude_paths:
report['limitations'].append('excludePaths 只从本仓库的自动审核树遍历中省略路径;DesireCore 安装器在支持该字段前仍会从上游 pin 安装这些文件。')
errors = validate_record(metadata, report)
if errors:
raise AuditBlocked('; '.join(errors))
return updated, metadata, report
def audit_update(entry: dict, sidecar: dict, result: dict) -> tuple[dict, dict, dict]:
def audit_update(entry: dict, sidecar: dict, result: dict,
special_review: dict | None = None) -> tuple[dict, dict, dict]:
url = entry['source']['repoUrl']
if not re.fullmatch(r'https://github\.com/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+(?:\.git)?/?', url):
raise AuditBlocked('自动获取仅使用已登记的 GitHub HTTPS 来源')
@@ -253,4 +328,4 @@ def audit_update(entry: dict, sidecar: dict, result: dict) -> tuple[dict, dict,
repo = Path(temporary)
git(repo, 'init', '--quiet')
git(repo, 'fetch', '--quiet', '--no-tags', '--depth=1', url, result['ref'], result['head'])
return audit_snapshots(repo, entry, sidecar, result)
return audit_snapshots(repo, entry, sidecar, result, special_review=special_review)
+3 -1
View File
@@ -53,7 +53,9 @@ def prepare_proposal(entry: dict, metadata: dict, result: dict):
if proposed is None:
return None, None, '不符合固定来源候选条件'
try:
updated, sidecar, audit = audit_update(entry, metadata, result)
review_path = ROOT / "skills" / entry["id"] / "special-review.v1.json"
special_review = json.loads(review_path.read_text()) if review_path.is_file() else None
updated, sidecar, audit = audit_update(entry, metadata, result, special_review=special_review)
return (updated, sidecar), audit, None
except (AuditBlocked, OSError, ValueError, RuntimeError, subprocess.SubprocessError) as error:
# 保留旧审核证据;失败必须可见,不能改成机器审核已通过。
@@ -183,6 +183,57 @@ class AuditTests(unittest.TestCase):
validator.validate_sidecar(path, Draft7Validator(schema, format_checker=FormatChecker()), report, root, {'zh-CN','en-US'}, entry_validators)
self.assertTrue(any(issue.rule == 'automated-review-evidence' for issue in report.issues))
def test_exclude_paths_skip_symlinks_and_cannot_hide_license(self):
(self.repo/'skills/sample/evals').mkdir(parents=True)
(self.repo/'skills/sample/evals/AGENTS.md').symlink_to('SKILL.md')
with self.assertRaisesRegex(AuditBlocked, '符号链接'):
self.audit()
self.run_git('reset', '--hard', self.old); self.run_git('clean', '-fd')
(self.repo/'skills/sample/evals').mkdir(parents=True)
(self.repo/'skills/sample/evals/AGENTS.md').symlink_to('SKILL.md')
self.write('skills/sample/scripts/tool.py', 'print("new fixture")\n')
new = self.commit()
review = {'schemaVersion': 1, 'excludePaths': ['skills/sample/evals/AGENTS.md']}
audit_snapshots(self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, '2026-10-31T01:02:03Z', special_review=review)
review = {'schemaVersion': 1, 'excludePaths': ['skills/sample/evals/AGENTS.md', 'LICENSE']}
with self.assertRaisesRegex(AuditBlocked, '排除列表'):
audit_snapshots(self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, '2026-10-31T01:02:03Z', special_review=review)
def test_budget_exempt_allows_known_oversize_file(self):
big = 'skills/sample/data/index.json'
self.write(big, 'x' * (1024 * 1024 + 50))
self.old = self.commit()
self.entry['source']['ref'] = self.old
self.metadata['provenance']['content']['ref'] = self.old
self.metadata['governance']['compliance']['reviewedRef'] = self.old
self.write('skills/sample/scripts/tool.py', 'print("new fixture")\n')
new = self.commit()
with self.assertRaisesRegex(AuditBlocked, '单文件超过'):
audit_snapshots(self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, '2026-10-31T01:02:03Z')
review = {'schemaVersion': 1, 'budgetExemptPaths': [big]}
audit_snapshots(self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, '2026-10-31T01:02:03Z', special_review=review)
def test_special_review_accepts_dependency_and_frontmatter_change(self):
from audit_skill_update import dependency_identity, frontmatter_identity
from check_upstream_health import GENERATOR
self.write('package.json', json.dumps({'name':'humanizer','private':True,'license':'MIT'}))
path = 'skills/sample/SKILL.md'
self.write(path, (self.repo/path).read_text().replace('description: Fixture', 'description: Rewritten blurb'))
new = self.commit()
with self.assertRaisesRegex(AuditBlocked, '依赖清单'):
audit_snapshots(self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, '2026-10-31T01:02:03Z')
ident = dependency_identity(self.repo, new, 'package.json', ('100644', 'unused', 0))
fm = GENERATOR.skill_frontmatter(self.repo, path, new)
review = {
'schemaVersion': 1,
'acceptedDependencyIdentities': {'package.json': ident[1]},
'acceptedFrontmatterSha256': {'skills/sample': frontmatter_identity(fm)},
}
entry, metadata, report = audit_snapshots(self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, '2026-10-31T01:02:03Z', special_review=review)
self.assertEqual(metadata['governance']['compliance']['reviewedBy'], REVIEWER)
self.assertEqual(report['specialReview']['reviewedBy'] if report.get('specialReview') else None, None)
def test_disallows_non_github_fetch_targets(self):
self.entry['source']['repoUrl'] = 'file:///private/source'
with self.assertRaisesRegex(AuditBlocked, 'HTTPS'): audit_update(self.entry, self.metadata, {})