From 815916a4aac1985f39603b6a4487bfe938b59eb7 Mon Sep 17 00:00:00 2001 From: mashagua <993498039@qq.com> Date: Sun, 6 Dec 2026 11:59:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(catalog):=20=E5=90=88=E9=9B=86=E5=AD=90?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E7=9A=84=E6=A0=B9=20NOTICE=20=E4=BA=A4?= =?UTF-8?q?=E4=BB=98=E8=AE=A4=E5=8F=AF=E5=AE=A2=E6=88=B7=E7=AB=AF=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E5=9B=9E=E8=AF=BB=20(#459)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 让诊断规则 `installed-notice-delivery` 认可**合集子技能**已有的客户端附加回读证据。这一条依据是客户端的真实安装行为,不新增豁免字段。 ## 修改内容 | 类型 | 模块或功能 | 本次修改 | | --- | --- | --- | | 修复 | `installed-notice-delivery` 诊断 | 合集安装(有 `children`)时,如果有效的 `acceptedClientAttachedNotices` 回读里,该子技能的 `attached` 列出了这份根 NOTICE(`sourceName` 等于它的路径,`sha256` 等于新 pin 上的字节哈希),这一行就降为 `info`,并在证据里记录哈希和客户端提交;回读里没有这一项或哈希过期时,仍然 `blocked` | | 不变 | 独立技能 | 独立技能的客户端只附加许可证据文件,就算回读里写了 NOTICE 也不认 | | 新增 | 测试 | 新增 4 个单测:合集放行、合集缺项仍阻断、合集哈希过期仍阻断、独立技能声称附加 NOTICE 仍阻断 | | 更新 | 文档 | `docs/verified-update-automation.md` 按安装类型说明根 NOTICE 的交付规则 | 依据:desirecore 客户端(v10.0.214–v10.0.219,已核验的合集实现 `28128a15`)安装合集子技能时,会调用 `stageMarketSkillDirectory(…, { attachNoticeFilesFrom: contentDir })` → `listRootNoticeFiles`,把合集根目录的**所有** `LICENSE*`/`NOTICE*`/`COPYING*` 都附加进安装副本。独立技能走的是 `requiredRootNotice`,只附加 `governance.license.evidencePath` 这一个文件。 ## 修改前后 | 场景 | 修改前 | 修复后 | | --- | --- | --- | | gamedev-agent-skills `c6ca6c41→523eb36d`(79 个子技能;已有回读记录了 NOTICE,sha `2dcb65b1…`,新旧 pin 上 NOTICE 相同) | 79 行 `installed-notice-delivery: blocked`,草稿 #446 无法修复 | 用现有专项复核原样审核,直接通过,不需要补任何字段 | | blog-repurpose(独立技能,新增根 NOTICE) | 阻断 | 仍然阻断(真实快照验证) | ## 影响范围 | 文件 | 行号 | 改动 | | --- | --- | --- | | `scripts/catalog/update_diagnostics.py` | 212-231 | 合集回读证据的 NOTICE 交付判定 | | `scripts/catalog/test_update_diagnostics.py`(测试) | 616-678 | 4 个测试 | | `docs/verified-update-automation.md` | 206-216 | 按安装类型说明规则 | ## 验证 | 检查项或场景 | 预期结果 | 实际结果 | 证据 | | --- | --- | --- | --- | | 新测试在没有本改动时 | 放行用例失败 | 1 failed / 3 passed(3 个阻断用例本来就通过) | 本地 | | `pytest test_update_diagnostics.py test_tracked_updates.py` | 全部通过 | 120 passed | commit `032ea45` | | 其余 catalog 测试脚本(audit / validate / collection / health / propose / review) | 全部通过 | exit 0 | 本地 | | 真实快照:gamedev #446、blog-repurpose | gamedev 通过、blog 仍阻断 | 符合 | 本地审核器 | | `validate_catalog_metadata.py --require-complete` / `validate-i18n.py` | 0 error | 0 error,105 warning(main 原有) | 本地 | | CI | 全部通过 | 等待中 | 本 PR checks | 这是审核规则改动,需要维护者复核。请勿自动合并。合并后会接着给 #446 开正式 PR。 Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- docs/verified-update-automation.md | 14 +++-- scripts/catalog/test_update_diagnostics.py | 63 ++++++++++++++++++++++ scripts/catalog/update_diagnostics.py | 21 +++++++- 3 files changed, 94 insertions(+), 4 deletions(-) diff --git a/docs/verified-update-automation.md b/docs/verified-update-automation.md index f6c4f74..eb097b3 100644 --- a/docs/verified-update-automation.md +++ b/docs/verified-update-automation.md @@ -203,9 +203,17 @@ blocks on facts that cannot affect the installed payload: directory. `LICENSE*`/`NOTICE*`/`COPYING*` text files and dependency manifests stay protected. -Root `NOTICE` delivery is unchanged: the verified client implementations attach only the -catalog license evidence file, so a client-attach review cannot clear -`installed-notice-delivery` for a separate root `NOTICE`. +Root `NOTICE` delivery depends on the install type, because the verified client +implementations differ: + +- **Standalone installs** attach only the catalog license evidence file + (`governance.license.evidencePath`). A client-attach review cannot clear + `installed-notice-delivery` for a separate root `NOTICE`, even if a readback lists one. +- **Collection child installs** attach every root `LICENSE*`/`NOTICE*`/`COPYING*` file + (`attachNoticeFilesFrom` → `listRootNoticeFiles`). When the valid + `acceptedClientAttachedNotices` readback for a child scope lists the root notice with + `sourceName` equal to its path and the SHA-256 of its bytes at the new pin, the row is + `info`. A missing entry or a stale hash keeps it `blocked`. ### Audited carry-forward rules (reducing repetitive Drafts without skipping checks) diff --git a/scripts/catalog/test_update_diagnostics.py b/scripts/catalog/test_update_diagnostics.py index 7be6e28..c34b806 100644 --- a/scripts/catalog/test_update_diagnostics.py +++ b/scripts/catalog/test_update_diagnostics.py @@ -613,3 +613,66 @@ def test_behavior_review_for_another_pin_stays_manual(case): row=next(r for r in rows if r['gate']=='authorization-config-network-review') assert row['state']=='manual_review' assert '不可跨版本继承' in row['evidence']['behavioralReviewError'] + + +def _collection_notice_case(case): + import hashlib + (case.repo/'skills/sample/LICENSE').unlink() + case.write('NOTICE','Project required notice\n') + case.entry['children']=[{'id':'sample','path':'skills/sample'}] + case.metadata['governance']['compliance']['noticePath']='NOTICE' + baseline(case) + case.write('skills/sample/scripts/tool.py','new') + new=case.commit() + license_sha=hashlib.sha256((case.repo/'LICENSE').read_bytes()).hexdigest() + notice_sha=hashlib.sha256((case.repo/'NOTICE').read_bytes()).hexdigest() + review=_client_attach_review(case, new, ['skills/sample'], license_sha) + review['acceptedClientAttachedNotices'].update( + clientCommit='28128a15b3abd76e1529b983ca8a921bdfe9ff30', + clientTree='e8c1321e6a098eb905f4646b2027bc7b2259ca6b') + return new, review, notice_sha + + +def test_collection_readback_of_root_notice_delivers_it(case): + new, review, notice_sha = _collection_notice_case(case) + review['acceptedClientAttachedNotices']['scopes'][0]['attached'].append( + {'name':'NOTICE','sourceName':'NOTICE','sha256':notice_sha}) + rows=inspect_snapshots(case.repo,case.entry,case.metadata,{'ref':case.old,'head':new},review) + row=next(r for r in rows if r['gate']=='installed-notice-delivery') + assert row['state']=='info' + assert row['evidence']['requiredNoticeSha256']==notice_sha + assert row['evidence']['clientCommit']=='28128a15b3abd76e1529b983ca8a921bdfe9ff30' + + +def test_collection_readback_without_notice_still_blocks(case): + new, review, _ = _collection_notice_case(case) + rows=inspect_snapshots(case.repo,case.entry,case.metadata,{'ref':case.old,'head':new},review) + row=next(r for r in rows if r['gate']=='installed-notice-delivery') + assert row['state']=='blocked' + + +def test_collection_readback_with_stale_notice_hash_still_blocks(case): + new, review, _ = _collection_notice_case(case) + review['acceptedClientAttachedNotices']['scopes'][0]['attached'].append( + {'name':'NOTICE','sourceName':'NOTICE','sha256':'0'*64}) + rows=inspect_snapshots(case.repo,case.entry,case.metadata,{'ref':case.old,'head':new},review) + row=next(r for r in rows if r['gate']=='installed-notice-delivery') + assert row['state']=='blocked' + + +def test_standalone_readback_cannot_claim_root_notice_delivery(case): + import hashlib + (case.repo/'skills/sample/LICENSE').unlink() + case.write('NOTICE','Project required notice\n') + case.metadata['governance']['compliance']['noticePath']='NOTICE' + baseline(case) + case.write('skills/sample/scripts/tool.py','new') + new=case.commit() + license_sha=hashlib.sha256((case.repo/'LICENSE').read_bytes()).hexdigest() + notice_sha=hashlib.sha256((case.repo/'NOTICE').read_bytes()).hexdigest() + review=_client_attach_review(case, new, ['skills/sample'], license_sha) + review['acceptedClientAttachedNotices']['scopes'][0]['attached'].append( + {'name':'NOTICE','sourceName':'NOTICE','sha256':notice_sha}) + rows=inspect_snapshots(case.repo,case.entry,case.metadata,{'ref':case.old,'head':new},review) + row=next(r for r in rows if r['gate']=='installed-notice-delivery') + assert row['state']=='blocked' diff --git a/scripts/catalog/update_diagnostics.py b/scripts/catalog/update_diagnostics.py index 4bf423b..fd03567 100644 --- a/scripts/catalog/update_diagnostics.py +++ b/scripts/catalog/update_diagnostics.py @@ -209,7 +209,26 @@ def inspect_snapshots(repo, entry, metadata, result, special_review=None): if normalized(required) in normalized(read(ref, path)): return True return False - if not notice_delivered(new): + # Collection child installs attach every root LICENSE*/NOTICE*/COPYING* file + # (client attachNoticeFilesFrom -> listRootNoticeFiles); a verified install + # readback that lists this exact notice for this scope proves delivery. + # Standalone installs attach only the catalog license evidence, so they never + # qualify here. + attached_notice = None + if entry.get('children') and scope in attached_scopes: + digest = hashlib.sha256(read(new, notice)).hexdigest() + for item in (review.get('acceptedClientAttachedNotices') or {}).get('scopes', []): + if item.get('path') == scope and any( + a.get('sourceName') == notice and a.get('sha256') == digest for a in item.get('attached', [])): + attached_notice = digest + if attached_notice: + add(scope, 'installed-notice-delivery', 'info', 'pre_existing' if not notice_delivered(old) else 'changed', + '源子目录未携带该 NOTICE;已按绑定当前 pin 的合集客户端安装回读,证明安装副本附带了相同哈希的根 NOTICE。 / The child directory lacks this NOTICE; collection-client install readback bound to this pin proves the staged copy carries the same root NOTICE bytes.', + '该接受不跨 pin 继承;NOTICE 字节或安装范围变化需重新回读。 / Does not carry to a later pin; any NOTICE byte or scope change needs a new readback.', + {'requiredNoticePath': notice, 'requiredNoticeSha256': attached_notice, + 'declaredByCompliance': notice == declared_notice, + 'clientCommit': (review.get('acceptedClientAttachedNotices') or {}).get('clientCommit')}) + elif not notice_delivered(new): add(scope, 'installed-notice-delivery', 'blocked' if notice == declared_notice else 'manual_review', 'pre_existing' if not notice_delivered(old) else 'introduced', '声明的 NOTICE 或仓库根 NOTICE 未证明随所选目录交付;未声明的根 NOTICE 适用性需保守人工确认。 / A declared or root NOTICE is not proven delivered with the selected directory; applicability of an undeclared root NOTICE requires conservative human review.',