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.',