diff --git a/docs/verified-update-automation.md b/docs/verified-update-automation.md index 3fc3504..9a3bdeb 100644 --- a/docs/verified-update-automation.md +++ b/docs/verified-update-automation.md @@ -132,3 +132,31 @@ can prove arbitrary upstream script/instruction behavior safe. Expanding that coverage needs a real behavioral review mechanism, not deletion of the safeguard. Identity verification, trusted-main re-audit, local-patch preservation, finite budgets, exact-head binding, strict server rules and no-admin/no-force stay intact. + +## Special-review and release-gate requirements (2026-11-29) + +Three additional gates learned from manual PR reviews (`#368`, `#358`, `#360`) are +now encoded in `schemas/special-review.v1.schema.json` and +`scripts/catalog/audit_skill_update.py`: + +1. **Client release gate for `acceptedClientAttachedNotices`**: Binding a verified + client source commit/tree (`CLIENT_COLLECTION_NOTICE_IMPLEMENTATIONS` or + `CLIENT_STANDALONE_NOTICE_IMPLEMENTATIONS`) proves the implementation, not that + users have received it in a public build. Before clearing Draft on a notice-delivery + update, confirm the verified implementation is shipped in an official client release + (e.g. `DesireCore v10.0.214`) with no unverified drift in `skill-staging.ts`, + `market-install.ts`, or `source-fetch.ts`. Record the release tag in + `acceptedClientAttachedNotices.clientReleaseTag` when bound to a shipped build. +2. **Exact-pin non-inheritable license exceptions (`acceptedExactPinLicenseException`)**: + Entries without a standalone `LICENSE` file (such as `follow-builders`, which relies + on a one-line `README.md` MIT declaration) never inherit a previous human exception + across commits. Each new pin requires an explicit exact-`fromRef`→`toRef` review + record binding the unchanged evidence SHA-256, updated bilingual catalog descriptions, + and a dated review document under `docs/`. +3. **Behavioral security review gate (`acceptedBehavioralSecurityReview`)**: + When an upstream snapshot modifies credential/environment loading, browser cookie or + consent gating, authorization/network boundaries, or `.skillignore` inside the + install scope (such as `last30days`), matching dependency hashes alone is insufficient. + A read-only behavioral review document under `docs/reviews/` must be committed and + bound to the exact `fromRef`→`toRef` pair and `reviewedPaths` in `special-review.v1.json`. + This remains a read-only review boundary, not a security certification or runtime acceptance. diff --git a/schemas/special-review.v1.schema.json b/schemas/special-review.v1.schema.json index 15b7761..b6ff925 100644 --- a/schemas/special-review.v1.schema.json +++ b/schemas/special-review.v1.schema.json @@ -81,6 +81,11 @@ "sourceRef": { "type": "string", "pattern": "^[0-9a-f]{40}$" }, "clientCommit": { "type": "string", "pattern": "^[0-9a-f]{40}$" }, "clientTree": { "type": "string", "pattern": "^[0-9a-f]{40}$" }, + "clientReleaseTag": { + "type": "string", + "description": "Optional shipped official DesireCore release tag (e.g. v10.0.214) verified to include clientCommit without unverified staging/install drift.", + "pattern": "^v\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$" + }, "observedAt": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$" }, "noticeRootPath": { "type": "string", "minLength": 1 }, "noticeSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, @@ -151,6 +156,36 @@ } } } + }, + "acceptedExactPinLicenseException": { + "type": "object", + "description": "Exact-pin human license exception for entries without a standalone LICENSE file (e.g. one-line README MIT declaration). Never inherited automatically across snapshots: fromRef/toRef must match the audited old and new pins, evidenceSha256 must match the file bytes at toRef, and reviewDoc must point to a repo-relative review document under docs/.", + "additionalProperties": false, + "required": ["fromRef", "toRef", "evidencePath", "evidenceSha256", "reviewDoc"], + "properties": { + "fromRef": { "type": "string", "pattern": "^[0-9a-f]{40}$" }, + "toRef": { "type": "string", "pattern": "^[0-9a-f]{40}$" }, + "evidencePath": { "type": "string", "minLength": 1 }, + "evidenceSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, + "reviewDoc": { "type": "string", "minLength": 1 } + } + }, + "acceptedBehavioralSecurityReview": { + "type": "object", + "description": "Exact-pin read-only behavioral review for updates touching credentials, browser cookies/consent, authorization/network boundaries, or .skillignore inside the install scope. Bound to fromRef/toRef, a repo-relative reviewDoc under docs/, and the reviewedPaths list. Does not extend to later pins and is not a security certification or runtime acceptance.", + "additionalProperties": false, + "required": ["fromRef", "toRef", "reviewDoc", "reviewedPaths"], + "properties": { + "fromRef": { "type": "string", "pattern": "^[0-9a-f]{40}$" }, + "toRef": { "type": "string", "pattern": "^[0-9a-f]{40}$" }, + "reviewDoc": { "type": "string", "minLength": 1 }, + "reviewedPaths": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { "type": "string", "minLength": 1 } + } + } } }, "allOf": [ @@ -169,6 +204,14 @@ { "if": { "required": ["acceptedDescriptionAndLocales"] }, "then": { "required": ["reviewedBy", "reviewedAt", "notes"] } + }, + { + "if": { "required": ["acceptedExactPinLicenseException"] }, + "then": { "required": ["reviewedBy", "reviewedAt", "notes"] } + }, + { + "if": { "required": ["acceptedBehavioralSecurityReview"] }, + "then": { "required": ["reviewedBy", "reviewedAt", "notes"] } } ] } diff --git a/scripts/catalog/audit_skill_update.py b/scripts/catalog/audit_skill_update.py index 5cf9d48..b384a74 100644 --- a/scripts/catalog/audit_skill_update.py +++ b/scripts/catalog/audit_skill_update.py @@ -251,6 +251,7 @@ def accept_client_attached_notices(review: dict, repo: Path, new: str, install_s source_ref = accepted.get('sourceRef') client_commit = accepted.get('clientCommit') client_tree = accepted.get('clientTree') + client_release_tag = accepted.get('clientReleaseTag') observed_at = accepted.get('observedAt') notice_path = accepted.get('noticeRootPath') notice_sha = accepted.get('noticeSha256') @@ -258,6 +259,11 @@ def accept_client_attached_notices(review: dict, repo: Path, new: str, install_s raise AuditBlocked('客户端附加通知专项复核未绑定完整上游 pin') if source_ref != new: raise AuditBlocked('客户端附加通知专项复核未绑定当前固定快照') + if client_release_tag is not None and not ( + isinstance(client_release_tag, str) + and re.fullmatch(r'v\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?', client_release_tag) + ): + raise AuditBlocked('客户端附加通知专项复核的发行版标签格式不正确') if not isinstance(client_commit, str) or not re.fullmatch(r'[0-9a-f]{40}', client_commit): raise AuditBlocked('客户端附加通知专项复核的客户端提交无效') implementations = (CLIENT_COLLECTION_NOTICE_IMPLEMENTATIONS if is_collection @@ -332,6 +338,60 @@ def accept_client_attached_notices(review: dict, repo: Path, new: str, install_s return seen +def accept_exact_pin_license_exception(review: dict, repo: Path, old: str, new: str) -> bool: + """Validate an exact-pin human license exception (never inherited across pins).""" + accepted = review.get('acceptedExactPinLicenseException') + if not accepted: + return False + if not isinstance(accepted, dict): + raise AuditBlocked('精确固定提交许可例外记录无效') + if not all(isinstance(review.get(key), str) and review[key].strip() + for key in ('reviewedBy', 'reviewedAt', 'notes')): + raise AuditBlocked('精确固定提交许可例外必须包含审核人、日期和理由') + from_ref, to_ref = accepted.get('fromRef'), accepted.get('toRef') + if from_ref != old or to_ref != new: + raise AuditBlocked('精确固定提交许可例外未绑定当前旧/新快照,不可跨版本继承') + evidence_path = accepted.get('evidencePath') + evidence_sha = accepted.get('evidenceSha256') + review_doc = accepted.get('reviewDoc') + if not isinstance(evidence_path, str) or safe_path(evidence_path) != evidence_path or not evidence_path: + raise AuditBlocked('精确固定提交许可例外的证据路径无效') + if not _sha256_hex(evidence_sha): + raise AuditBlocked('精确固定提交许可例外的证据哈希无效') + actual_bytes = blob(repo, new, evidence_path) + if not actual_bytes or hashlib.sha256(actual_bytes).hexdigest() != evidence_sha: + raise AuditBlocked('精确固定提交许可例外的证据哈希与当前快照不一致') + if (not isinstance(review_doc, str) or safe_path(review_doc) != review_doc + or not review_doc.startswith('docs/')): + raise AuditBlocked('精确固定提交许可例外必须引用 docs/ 下的复审文档') + return True + + +def accept_behavioral_security_review(review: dict, old: str, new: str) -> bool: + """Validate an exact-pin read-only behavioral security review record.""" + accepted = review.get('acceptedBehavioralSecurityReview') + if not accepted: + return False + if not isinstance(accepted, dict): + raise AuditBlocked('安全与行为专项复核记录无效') + if not all(isinstance(review.get(key), str) and review[key].strip() + for key in ('reviewedBy', 'reviewedAt', 'notes')): + raise AuditBlocked('安全与行为专项复核必须包含审核人、日期和理由') + from_ref, to_ref = accepted.get('fromRef'), accepted.get('toRef') + if from_ref != old or to_ref != new: + raise AuditBlocked('安全与行为专项复核未绑定当前旧/新快照,不可跨版本继承') + review_doc = accepted.get('reviewDoc') + if (not isinstance(review_doc, str) or safe_path(review_doc) != review_doc + or not review_doc.startswith('docs/')): + raise AuditBlocked('安全与行为专项复核必须引用 docs/ 下的复审文档') + reviewed_paths = accepted.get('reviewedPaths') + if (not isinstance(reviewed_paths, list) or not reviewed_paths + or any(not isinstance(p, str) or not p or safe_path(p) != p for p in reviewed_paths) + or len(set(reviewed_paths)) != len(reviewed_paths)): + raise AuditBlocked('安全与行为专项复核的已审路径列表无效') + return True + + LATIN_TOKEN = re.compile(r"[A-Za-z][A-Za-z0-9'-]{4,}") @@ -662,6 +722,10 @@ def _audit_snapshots(repo: Path, entry: dict, sidecar: dict, result: dict, is_collection=bool(entry.get('children'))) if review.get('acceptedDescriptionAndLocales'): accept_description_and_locales(review, entry, sidecar, repo, old, new, paths) + if review.get('acceptedExactPinLicenseException'): + accept_exact_pin_license_exception(review, repo, old, new) + if review.get('acceptedBehavioralSecurityReview'): + accept_behavioral_security_review(review, old, new) if old_root != new_root: accepted_root = review.get('acceptedRootEvidenceSha256') or {} if set(old_root) - set(new_root): diff --git a/scripts/catalog/test_audit_skill_update.py b/scripts/catalog/test_audit_skill_update.py index f07ba51..2c325a7 100644 --- a/scripts/catalog/test_audit_skill_update.py +++ b/scripts/catalog/test_audit_skill_update.py @@ -988,5 +988,72 @@ class AuditTests(unittest.TestCase): self.assertEqual(entry['source']['ref'], new) self.assertEqual(metadata['governance']['compliance']['reviewedRef'], new) + def test_client_attached_notices_validates_optional_release_tag(self): + from jsonschema import Draft7Validator + schema = json.loads((Path(__file__).resolve().parents[2] / 'schemas' / 'special-review.v1.schema.json').read_text()) + (self.repo / 'skills/sample/LICENSE').unlink() + self._rebind_old(self.commit()) + self.write('skills/sample/scripts/tool.py', 'print("release tag fixture")\n') + notice_sha = hashlib.sha256((self.repo / 'LICENSE').read_bytes()).hexdigest() + new = self.commit() + valid = self._client_attach_review( + new, ['skills/sample'], notice_sha, + acceptedClientAttachedNotices={'clientReleaseTag': 'v10.0.214'}) + Draft7Validator(schema).validate(valid) + audit_snapshots( + self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, + '2026-10-31T01:02:03Z', special_review=valid) + invalid = self._client_attach_review( + new, ['skills/sample'], notice_sha, + acceptedClientAttachedNotices={'clientReleaseTag': '10.0.214'}) + with self.assertRaisesRegex(AuditBlocked, '发行版标签格式不正确'): + audit_snapshots( + self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, + '2026-10-31T01:02:03Z', special_review=invalid) + + def test_exact_pin_license_exception_and_behavioral_security_review(self): + from jsonschema import Draft7Validator + schema = json.loads((Path(__file__).resolve().parents[2] / 'schemas' / 'special-review.v1.schema.json').read_text()) + self.write('skills/sample/scripts/tool.py', 'print("security review fixture")\n') + new = self.commit() + lic_sha = hashlib.sha256((self.repo / 'LICENSE').read_bytes()).hexdigest() + valid = { + 'schemaVersion': 1, + 'reviewedBy': 'mashagua', + 'reviewedAt': '2026-11-29', + 'notes': 'Exact-pin license exception and read-only behavioral review.', + 'acceptedExactPinLicenseException': { + 'fromRef': self.old, + 'toRef': new, + 'evidencePath': 'LICENSE', + 'evidenceSha256': lic_sha, + 'reviewDoc': 'docs/follow-builders-snapshot-review-20261128.md', + }, + 'acceptedBehavioralSecurityReview': { + 'fromRef': self.old, + 'toRef': new, + 'reviewDoc': 'docs/reviews/last30days-pr360-7c2e1c2b099b.md', + 'reviewedPaths': ['skills/sample/scripts/tool.py'], + }, + } + Draft7Validator(schema).validate(valid) + audit_snapshots( + self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, + '2026-10-31T01:02:03Z', special_review=valid) + + stale_exc = json.loads(json.dumps(valid)) + stale_exc['acceptedExactPinLicenseException']['toRef'] = self.old + with self.assertRaisesRegex(AuditBlocked, '不可跨版本继承'): + audit_snapshots( + self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, + '2026-10-31T01:02:03Z', special_review=stale_exc) + + bad_doc = json.loads(json.dumps(valid)) + bad_doc['acceptedBehavioralSecurityReview']['reviewDoc'] = 'README.md' + with self.assertRaisesRegex(AuditBlocked, 'docs/ 下的复审文档'): + audit_snapshots( + self.repo, self.entry, self.metadata, {'ref': self.old, 'head': new}, + '2026-10-31T01:02:03Z', special_review=bad_doc) + if __name__ == '__main__': unittest.main()